cmlenz 2002/08/19 14:36:00
Modified: src/stores/org/apache/slide/store/impl/rdbms JDBCStore.java
Log:
- Removed column number constants
- More cosmetics
Revision Changes Path
1.6 +89 -164
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/JDBCStore.java
Index: JDBCStore.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/JDBCStore.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JDBCStore.java 19 Aug 2002 11:41:54 -0000 1.5
+++ JDBCStore.java 19 Aug 2002 21:36:00 -0000 1.6
@@ -139,76 +139,9 @@
// -------------------------------------------------------------- Constants
- // Column numbers
-
- // Structure descriptors
-
- private static final int OBJECTS_URI = 1;
- private static final int OBJECTS_CLASS = 2;
-
- private static final int CHILDREN_URI = 1;
- private static final int CHILDREN_CHILDURI = 2;
-
- private static final int LINKS_LINK = 1;
- private static final int LINKS_LINKTO = 2;
-
- // Security descriptors
-
- private static final int PERMISSIONS_OBJECT = 1;
- private static final int PERMISSIONS_REVISION_NUMBER = 2;
- private static final int PERMISSIONS_SUBJECT = 3;
- private static final int PERMISSIONS_ACTION = 4;
- private static final int PERMISSIONS_INHERITABLE = 5;
- private static final int PERMISSIONS_NEGATIVE = 6;
-
- // Lock descriptors
-
- private static final int LOCKS_ID = 1;
- private static final int LOCKS_OBJECT = 2;
- private static final int LOCKS_SUBJECT = 3;
- private static final int LOCKS_TYPE = 4;
- private static final int LOCKS_EXPIRATIONDATE = 5;
- private static final int LOCKS_INHERITABLE = 6;
- private static final int LOCKS_EXCLUSIVE = 7;
-
- // Content descriptors
-
- private static final int REVISIONS_URI = 1;
- private static final int REVISIONS_ISVERSIONED = 2;
- private static final int REVISIONS_INITIALREVISION = 3;
-
- private static final int WORKINGREVISION_URI = 1;
- private static final int WORKINGREVISION_BASEREVISION = 2;
- private static final int WORKINGREVISION_NUMBER = 3;
-
- private static final int LATESTREVISIONS_URI = 1;
- private static final int LATESTREVISIONS_BRANCHNAME = 2;
- private static final int LATESTREVISIONS_NUMBER = 3;
-
- private static final int BRANCHES_URI = 1;
- private static final int BRANCHES_NUMBER = 2;
- private static final int BRANCHES_CHILDNUMBER = 3;
-
- private static final int REVISION_URI = 1;
- private static final int REVISION_NUMBER = 2;
- private static final int REVISION_BRANCHNAME = 3;
-
- private static final int LABEL_URI = 1;
- private static final int LABEL_NUMBER = 2;
- private static final int LABEL_LABEL = 3;
-
- private static final int PROPERTY_URI = 1;
- private static final int PROPERTY_NUMBER = 2;
- private static final int PROPERTY_NAME = 3;
- private static final int PROPERTY_VALUE = 4;
- private static final int PROPERTY_NAMESPACE = 5;
- private static final int PROPERTY_TYPE = 6;
- private static final int PROPERTY_PROTECTED = 7;
-
- //private static final int REVISION_URI = 1;
- //private static final int REVISION_NUMBER = 2;
- private static final int REVISION_CONTENT = 3;
-
+ /**
+ * Buffer size used whe copying content streams.
+ */
public static final int BUFFER_SIZE = 2048;
@@ -464,7 +397,7 @@
return false;
}
Statement stmt = connection.createStatement();
- stmt.executeQuery("select 1 from objects where uri is null");
+ stmt.executeQuery("SELECT * FROM URI WHERE URI_ID IS NULL");
return true;
} catch (SQLException e) {
throw new ServiceAccessException(this, e);
@@ -545,7 +478,7 @@
try {
- long currentUriID = this.getUriId(uri.toString());
+ long currentUriID = getUriId(uri.toString());
statement = connection.createStatement();
if (currentUriID == 0) {
@@ -668,7 +601,7 @@
try {
- long uriid = this.getUriId( uri.toString());
+ long uriid = getUriId(uri.toString());
statement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
@@ -684,7 +617,7 @@
}
- long parent = this.getUriId(object.getUri());
+ long parent = getUriId(object.getUri());
Enumeration children =
getNewChildren(parent,object.enumerateChildren());
if (children != null) {
@@ -692,17 +625,16 @@
theSQL = new StringBuffer("insert into CHILDREN ");
theSQL.append("(URI_ID,CHILD_URI_ID) values( ");
theSQL.append(parent).append(" , ")
- .append(this.getUriId((String)children.nextElement()))
- .append(")");
+ .append(getUriId((String)children.nextElement()))
+ .append(")");
statement.execute(theSQL.toString());
}
}
// Updating link
if (object instanceof LinkNode) {
- long link_to = this.getUriId
- (((LinkNode) object).getLinkedUri());
- if (! this.isLinkExist(parent,link_to)) {
+ long link_to = getUriId(((LinkNode)object).getLinkedUri());
+ if (! isLinkExist(parent,link_to)) {
theSQL = new StringBuffer("insert into LINKS (URI_ID,");
theSQL.append("LINK_TO_ID) values( ");
theSQL.append(parent).append(" , ").
@@ -741,8 +673,8 @@
Statement statement = null;
try {
- this.setUriId(uri.toString());
- long uriid = this.getUriId( uri.toString());
+ setUriId(uri.toString());
+ long uriid = getUriId(uri.toString());
String className = object.getClass().getName();
@@ -775,21 +707,21 @@
theSQL = new StringBuffer("insert into CHILDREN ");
theSQL.append("(URI_ID,CHILD_URI_ID) values( ");
theSQL.append(uriid).append(" , ")
- .append(this.getUriId((String)children.nextElement()))
- .append(" )");
+ .append(getUriId((String)children.nextElement()))
+ .append(" )");
statement.execute(theSQL.toString());
}
}
// If the object is a link, also store the link information
if (object instanceof LinkNode) {
- long link_to = this.getUriId
+ long link_to = getUriId
(((LinkNode) object).getLinkedUri());
- if (! this.isLinkExist(uriid,link_to)) {
+ if (!isLinkExist(uriid,link_to)) {
theSQL = new StringBuffer("insert into LINKS (URI_ID,");
theSQL.append("LINK_TO_ID) values( ");
theSQL.append(uriid).append(" , '")
- .append(link_to).append("' )");
+ .append(link_to).append("' )");
statement.execute(theSQL.toString());
}
}
@@ -821,7 +753,7 @@
try {
- long uriid = this.getUriId(object.getUri());
+ long uriid = getUriId(object.getUri());
Statement statement = null;
statement = connection.createStatement();
@@ -889,12 +821,12 @@
NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
String revisionNumberStr =
(revisionNumber == null) ? "NULL" : revisionNumber.toString();
- this.setUriId(permission.getObjectUri());
- this.setUriId(permission.getSubjectUri());
- this.setUriId(permission.getActionUri());
- long objid = this.getUriId(permission.getObjectUri());
- long subid = this.getUriId(permission.getSubjectUri());
- long actid = this.getUriId(permission.getActionUri());
+ setUriId(permission.getObjectUri());
+ setUriId(permission.getSubjectUri());
+ setUriId(permission.getActionUri());
+ long objid = getUriId(permission.getObjectUri());
+ long subid = getUriId(permission.getSubjectUri());
+ long actid = getUriId(permission.getActionUri());
StringBuffer theSQL = new StringBuffer("select 1 from PERMISSIONS");
theSQL.append(" where OBJECT_ID = ");
@@ -946,11 +878,11 @@
NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
StringBuffer theSQL = new StringBuffer("delete from PERMISSIONS ");
theSQL.append("where OBJECT_ID= ");
- theSQL.append(this.getUriId(permission.getObjectUri()))
- .append(" and SUBJECT_ID = ")
- .append(this.getUriId(permission.getSubjectUri()))
- .append(" and ACTION_ID = " )
- .append(this.getUriId(permission.getActionUri()));
+ theSQL.append(getUriId(permission.getObjectUri()))
+ .append(" and SUBJECT_ID = ")
+ .append(getUriId(permission.getSubjectUri()))
+ .append(" and ACTION_ID = " )
+ .append(getUriId(permission.getActionUri()));
if(revisionNumber != null) {
statement.execute(theSQL.append(" and VERSION_NO = ")
@@ -991,7 +923,7 @@
statement = connection.createStatement();
StringBuffer theSQL = new StringBuffer("delete from PERMISSIONS");
theSQL.append(" where OBJECT_ID= ");
- theSQL.append(this.getUriId(uri.toString()));
+ theSQL.append(getUriId(uri.toString()));
statement.execute(theSQL.toString());
} catch (SQLException e) {
@@ -1026,18 +958,18 @@
StringBuffer theSQL = new StringBuffer("select * from PERMISSIONS ");
theSQL.append("where OBJECT_ID = ");
- theSQL.append(this.getUriId(uri.toString()));
+ theSQL.append(getUriId(uri.toString()));
statement.execute(theSQL.toString());
ResultSet res = statement.executeQuery(theSQL.toString());
String object = null;
while (res.next()) {
if (object == null) {
- object = this.getUri(res.getLong("OBJECT_ID"));
+ object = getUri(res.getLong("OBJECT_ID"));
}
String revision = res.getString("VERSION_NO");
- String subject = this.getUri(res.getLong("SUBJECT_ID"));
- String action = this.getUri(res.getLong("ACTION_ID"));
+ String subject = getUri(res.getLong("SUBJECT_ID"));
+ String action = getUri(res.getLong("ACTION_ID"));
boolean inheritable = res.getBoolean("IS_INHERITABLE");
boolean negative = res.getBoolean("IS_NEGATIVE");
@@ -1081,15 +1013,15 @@
new StringBuffer("insert into LOCKS (LOCK_ID,OBJECT_ID,");
theSQL.append("SUBJECT_ID,TYPE_ID,EXPIRATION_DATE,");
theSQL.append("IS_INHERITABLE,IS_EXCLUSIVE) values( ");
- long in_lockid = this.getUriId(lock.getLockId());
+ long in_lockid = getUriId(lock.getLockId());
if (in_lockid == 0 ) {
- this.setUriId(lock.getLockId());
- in_lockid = this.getUriId(lock.getLockId());
+ setUriId(lock.getLockId());
+ in_lockid = getUriId(lock.getLockId());
}
theSQL.append(in_lockid).append(", ");
- theSQL.append(this.getUriId(lock.getObjectUri())).append(", ");
- theSQL.append(this.getUriId(lock.getSubjectUri())).append(", ");
- theSQL.append(this.getUriId(lock.getTypeUri())).append(", ");
+ theSQL.append(getUriId(lock.getObjectUri())).append(", ");
+ theSQL.append(getUriId(lock.getSubjectUri())).append(", ");
+ theSQL.append(getUriId(lock.getTypeUri())).append(", ");
theSQL.append(lock.getExpirationDate().getTime()).append(", ");
theSQL.append(lock.isInheritable()).append(", ");
theSQL.append(lock.isExclusive()).append(" ) ");
@@ -1121,8 +1053,8 @@
throws ServiceAccessException, LockTokenNotFoundException {
try {
- if (! isLockExist(this.getUriId(lock.getLockId())) ) {
- this.putLock(uri,lock);
+ if (!isLockExist(getUriId(lock.getLockId())) ) {
+ putLock(uri,lock);
}
} catch (SQLException e) {
getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
@@ -1154,7 +1086,7 @@
StringBuffer theSQL =
new StringBuffer("delete from LOCKS where LOCK_ID= '");
- long in_lock = this.getUriId(lock.getLockId());
+ long in_lock = getUriId(lock.getLockId());
theSQL.append(in_lock).append("'");
statement.execute(theSQL.toString());
statement.execute("delete from URI where URI_ID = " + in_lock);
@@ -1212,7 +1144,7 @@
StringBuffer theSQL =
new StringBuffer("select * from LOCKS where OBJECT_ID= ");
- theSQL.append(this.getUriId(uri.toString()));
+ theSQL.append(getUriId(uri.toString()));
ResultSet res = statement.executeQuery(theSQL.toString());
@@ -1226,10 +1158,10 @@
expirationDate = new Date();
}
NodeLock lock =
- new NodeLock(this.getUri(res.getLong("LOCK_ID")),
- this.getUri(res.getLong("OBJECT_ID")),
- this.getUri(res.getLong("SUBJECT_ID")),
- this.getUri(res.getLong("TYPE_ID")),
+ new NodeLock(getUri(res.getLong("LOCK_ID")),
+ getUri(res.getLong("OBJECT_ID")),
+ getUri(res.getLong("SUBJECT_ID")),
+ getUri(res.getLong("TYPE_ID")),
expirationDate,
res.getBoolean("IS_INHERITABLE"),
res.getBoolean("IS_EXCLUSIVE"));
@@ -1274,7 +1206,7 @@
Hashtable latestRevisionNumbers = new Hashtable();
Hashtable branches = new Hashtable();
boolean isVersioned = false;
- long uriid = this.getUriId( uri.toString());
+ long uriid = getUriId(uri.toString());
statement = connection.createStatement();
statement2 = connection.createStatement();
StringBuffer theSQL =
@@ -1315,7 +1247,7 @@
while (res2.next()) {
childList.addElement(new NodeRevisionNumber
- (this.getXNumber(res2.getLong("PREDECESSOR_ID"),
+ (getXNumber(res2.getLong("PREDECESSOR_ID"),
uriid,
branchid)));
}
@@ -1371,7 +1303,7 @@
if (revisionDescriptors.isVersioned()) {
isVersioned = 1;
}
- long urid = this.getUriId(uri.toString());
+ long urid = getUriId(uri.toString());
statement = connection.createStatement();
StringBuffer theSQL =
@@ -1387,7 +1319,7 @@
}
// For now, only the latest revision from the main branch is stored
- long brid = this.getBranchID( NodeRevisionDescriptors.
+ long brid = getBranchID( NodeRevisionDescriptors.
MAIN_BRANCH.toString());
theSQL = new StringBuffer
("SELECT 1 FROM VERSION_HISTORY WHERE URI_ID =");
@@ -1460,7 +1392,7 @@
Statement statement = null;
try {
- long uriid = this.getUriId(uri.toString());
+ long uriid = getUriId(uri.toString());
ResultSet res = null;
statement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
@@ -1510,7 +1442,7 @@
try {
ResultSet res = null;
- long uriid = this.getUriId(uri.toString());
+ long uriid = getUriId(uri.toString());
String branchName = null;
Vector labels = new Vector();
Hashtable properties = new Hashtable();
@@ -1543,7 +1475,7 @@
res = statement.executeQuery(theSQL.toString());
while (res.next()) {
- labels.addElement(this.getLabelName(res.getLong("LABEL_ID")));
+ labels.addElement(getLabelName(res.getLong("LABEL_ID")));
}
@@ -1602,11 +1534,11 @@
try {
ResultSet res = null;
- long uriid = this.getUriId(uri.toString());
- long brid = this.getBranchID(revisionDescriptor.getBranchName());
+ long uriid = getUriId(uri.toString());
+ long brid = getBranchID(revisionDescriptor.getBranchName());
if (brid == 0 ) {
- this.setBranchID(revisionDescriptor.getBranchName());
- brid = this.getBranchID(revisionDescriptor.getBranchName());
+ setBranchID(revisionDescriptor.getBranchName());
+ brid = getBranchID(revisionDescriptor.getBranchName());
}
statement = connection.createStatement();
@@ -1641,7 +1573,7 @@
theSQL.append("')");
statement.execute(theSQL.toString());
}
- long Version_ID = this.getVersionID(uriid,
+ long Version_ID = getVersionID(uriid,
revisionDescriptor.getBranchName(),
revisionDescriptor.getRevisionNumber().toString());
@@ -1649,10 +1581,10 @@
Enumeration labels = revisionDescriptor.enumerateLabels();
while (labels.hasMoreElements()) {
String sLabel =(String)labels.nextElement();
- long label= this.getLabelID(sLabel);
+ long label= getLabelID(sLabel);
if (label == 0) {
- this.setLabelID(sLabel);
- label= this.getLabelID(sLabel);
+ setLabelID(sLabel);
+ label= getLabelID(sLabel);
}
theSQL = new StringBuffer("insert into VERSION_LABELS ");
theSQL.append("(VERSION_ID,LABEL_ID) values( ");
@@ -1732,7 +1664,7 @@
try {
statement = connection.createStatement();
- long uriid = this.getUriId(uri.toString());
+ long uriid = getUriId(uri.toString());
String revisionNumberStr =
(revisionNumber == null) ? "NULL" : revisionNumber.toString();
String branchStr = null;
@@ -1742,7 +1674,7 @@
branchStr = "main";
}
long Version_ID =
- this.getVersionID(uriid,branchStr,revisionNumberStr);
+ getVersionID(uriid,branchStr,revisionNumberStr);
// Removing revision labels
StringBuffer theSQL = new StringBuffer
("delete from VERSION_LABELS where VERSION_ID= ");
@@ -1792,10 +1724,9 @@
Statement selectStatement=null;
try {
- long versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ long versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
selectStatement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
("select CONTENT from VERSION_CONTENT where VERSION_ID = ");
@@ -1873,10 +1804,9 @@
try {
- long versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ long versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
selectStatement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
@@ -1940,10 +1870,9 @@
try {
- long versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ long versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
selectStatement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
@@ -2005,10 +1934,9 @@
revisionDescriptor.getRevisionNumber().toString();
try {
- long versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ long versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
removeContent(versionid);
} catch (Exception e) {
@@ -2160,7 +2088,7 @@
protected void setBranchID(String branchName)
throws SQLException {
- if (this.getBranchID(branchName) == 0 ) {
+ if (getBranchID(branchName) == 0 ) {
Statement addStatement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
("insert into BRANCH (BRANCH_STRING) values ('");
@@ -2215,7 +2143,7 @@
protected void setLabelID(String labelName)
throws SQLException {
- if (this.getBranchID(labelName) == 0 ) {
+ if (getBranchID(labelName) == 0 ) {
Statement addStatement = connection.createStatement();
StringBuffer theSQL = new StringBuffer
("insert into LABEL (LABEL_STRING) values ('");
@@ -2376,19 +2304,16 @@
NodeRevisionContent revisionContent)
throws IOException, SQLException {
- long versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ long versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
if (versionid == 0 ) {
- this.setVersionID(
- this.getUriId(revisionUri),
- this.getBranchID(revisionDescriptor.getBranchName()),
- revisionNumber);
- versionid = this.getVersionID(
- this.getUriId(revisionUri),
- revisionDescriptor.getBranchName(),
- revisionNumber);
+ setVersionID(getUriId(revisionUri),
+ getBranchID(revisionDescriptor.getBranchName()),
+ revisionNumber);
+ versionid = getVersionID(getUriId(revisionUri),
+ revisionDescriptor.getBranchName(),
+ revisionNumber);
}
PreparedStatement insertStatement = connection.prepareStatement
("insert into VERSION_CONTENT values(?, ?)");
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>