cmlenz      2002/08/21 02:13:11

  Modified:    src/stores/org/apache/slide/store/impl/rdbms JDBCStore.java
  Log:
  More cleanup: variable naming, StringBuffer reuse, etc
  No functional changes
  
  Revision  Changes    Path
  1.7       +445 -474  
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JDBCStore.java    19 Aug 2002 21:36:00 -0000      1.6
  +++ JDBCStore.java    21 Aug 2002 09:13:11 -0000      1.7
  @@ -460,11 +460,11 @@
       }
       
       
  -    // ----------------------------------------------- DescriptorsStore Methods
  +    // ------------------------------------------------------ NodeStore Methods
       
       
       /**
  -     * Retrive an object.
  +     * Retrieve an object.
        *
        * @param uri Uri of the object we want to retrieve
        * @exception ServiceAccessException Error accessing the Service
  @@ -474,99 +474,75 @@
           throws ServiceAccessException, ObjectNotFoundException {
   
           ObjectNode result = null;
  -        Statement statement = null;
  -
  +        Statement stmt = null;
  +        StringBuffer sql = new StringBuffer();
           try {
  +            stmt = connection.createStatement();
   
  -            long currentUriID = getUriId(uri.toString());
  -
  -            statement = connection.createStatement();
  -            if (currentUriID == 0) {
  +            long uriId = getUriId(uri.toString());
  +            if (uriId == 0) {
                   throw new ObjectNotFoundException(uri);
               }
  -            StringBuffer theSQL = new StringBuffer
  -                    ("select CLASS_NAME from OBJECT where URI_ID= ");
  -            theSQL.append(currentUriID);
  -
  -
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  -
  -            // Parsing result set
   
  +            // retrieve class name
               String className;
  -
  -            if (res.next()) {
  -                // Retrieving and loading the object
  -                className = res.getString("CLASS_NAME");
  +            sql.setLength(0);
  +            sql.append("SELECT CLASS_NAME FROM OBJECT WHERE URI_ID = ")
  +               .append(uriId);
  +            ResultSet rs = stmt.executeQuery(sql.toString());
  +            if (rs.next()) {
  +                className = rs.getString("CLASS_NAME");
               } else {
  -                // Object was not found ...
                   throw new ObjectNotFoundException(uri);
               }
   
  -            // Then, retrieve the children
  -            theSQL = new StringBuffer
  -                    ("SELECT A.URI_STRING FROM URI A, CHILDREN B WHERE A.URI_ID = 
");
  -            theSQL.append("B.CHILD_URI_ID AND B.URI_ID = ");
  -            theSQL.append(currentUriID);
  -            res = statement.executeQuery(theSQL.toString());
  -
  -            Vector childrenVector = new Vector();
  -
  -            // Parse result set
  -            while (res.next()) {
  -                // Load each permission
  -                 String sts = res.getString("URI_STRING");
  -                childrenVector.addElement(sts);
  -            }
  -
  -            theSQL = new StringBuffer
  -                ("select A.URI_STRING from URI A, LINKS B where A.URI_ID = ");
  -            theSQL.append("B.URI_ID AND B.LINK_TO_ID= ");
  -            theSQL.append(currentUriID);
  -            res = statement.executeQuery(theSQL.toString());
  -
  -            Vector linksVector = new Vector();
  -
  -            // Parse result set
  -            while (res.next()) {
  -                // Load each permission
  -                linksVector.addElement(res.getString("URI_STRING"));
  +            // retrieve the children
  +            Vector children = new Vector();
  +            sql.setLength(0);
  +            sql.append("SELECT A.URI_STRING FROM URI A, CHILDREN B ")
  +               .append("WHERE A.URI_ID = B.CHILD_URI_ID ")
  +               .append("AND B.URI_ID = ").append(uriId);
  +            rs = stmt.executeQuery(sql.toString());
  +            while (rs.next()) {
  +                children.addElement(rs.getString("URI_STRING"));
               }
  -
  -
  +            
  +            // retrieve the inbound links
  +            Vector links = new Vector();
  +            sql.setLength(0);
  +            sql.append("SELECT A.URI_STRING FROM URI A, LINKS B ")
  +               .append("WHERE A.URI_ID = B.URI_ID ")
  +               .append("AND B.LINK_TO_ID = ").append(uriId);
  +            rs = stmt.executeQuery(sql.toString());
  +            while (rs.next()) {
  +                links.addElement(rs.getString("URI_STRING"));
  +            }
  +            
  +            // if the node is a link, retrieve the link target and instantiate
  +            // the LinkNode
               if (className.equals("org.apache.slide.structure.LinkNode")) {
  -
  -                String linkTo = new String();
  -
  -                theSQL = new StringBuffer("select A.URI_STRING from URI A, LINKS B 
");
  -                theSQL.append(" where A.URI_ID = B.LINK_TO_ID AND B.URI_ID= ");
  -                theSQL.append(currentUriID);
  -                res = statement.executeQuery(theSQL.toString());
  -
  -                if(res.next())
  -                    linkTo = res.getString("URI_STRING");
  -
  -
  -                result = new LinkNode(uri.toString(), childrenVector,
  -                                      linksVector, linkTo);
  -
  +                String linkTarget = null;
  +                sql.setLength(0);
  +                sql.append("SELECT A.URI_STRING FROM URI A, LINKS B ")
  +                   .append("WHERE A.URI_ID = B.LINK_TO_ID ")
  +                   .append("AND B.URI_ID = ").append(uriId);
  +                rs = stmt.executeQuery(sql.toString());
  +                if (rs.next()) {
  +                    linkTarget = rs.getString("URI_STRING");
  +                }
  +                result = new LinkNode(uri.toString(), children, links,
  +                                      linkTarget);
               } else {
  -
                   try {
  -                    Class objclass = Class.forName(className);
  -
  -                    Class[] argClasses = { Class.forName("java.lang.String"),
  -                                           Class.forName("java.util.Vector"),
  -                                           Class.forName("java.util.Vector") };
  -                    Object[] arguments = { uri.toString(),
  -                                           childrenVector,
  -                                           linksVector };
  -
  +                    Class objClass = Class.forName(className);
  +                    Class[] argClasses = 
  +                        { String.class, Vector.class, Vector.class };
  +                    Object[] arguments = { uri.toString(), children, links };
                       Constructor constructor =
  -                        objclass.getConstructor(argClasses);
  +                        objClass.getConstructor(argClasses);
                       result = (ObjectNode)constructor.newInstance(arguments);
                   } catch(Exception e) {
  -                    // ClassNotFoundException, NoSuchMethodException, etc.
  +                    // introspection exceptions
                       throw new ServiceAccessException(this, e);
                   }
   
  @@ -577,12 +553,15 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                if (stmt != null) {
  +                    stmt.close();
  +                }
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
               }
           }
  +        
           return result;
       }
   
  @@ -597,64 +576,66 @@
       public void storeObject(Uri uri, ObjectNode object)
           throws ServiceAccessException, ObjectNotFoundException {
   
  -        Statement statement = null;
  -
  +        Statement stmt = null;
  +        StringBuffer sql = new StringBuffer();
           try {
  +            stmt = connection.createStatement();
   
  -            long uriid = getUriId(uri.toString());
  -
  -            statement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  -                                ("select 1 from OBJECT where URI_ID= ");
  -            theSQL.append(uriid);
  -
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  -
  -            // Parsing result set
  +            long uriId = getUriId(uri.toString());
   
  -            if (!res.next()) {
  +            sql.setLength(0);
  +            sql.append("SELECT CLASS_NAME FROM OBJECT WHERE URI_ID = ");
  +            sql.append(uriId);
  +            ResultSet rs = stmt.executeQuery(sql.toString());
  +            if (!rs.next()) {
                   throw new ObjectNotFoundException(uri);
               }
  -
  -
  +            // TODO: check the class name?
  +            
  +            // store the children
               long parent = getUriId(object.getUri());
  +                // TODO: why not use the already calculated uriId ?
               Enumeration children =
  -                        getNewChildren(parent,object.enumerateChildren());
  +                getNewChildren(parent,object.enumerateChildren());
               if (children != null) {
                   while (children.hasMoreElements()) {
  -                    theSQL = new StringBuffer("insert into CHILDREN ");
  -                    theSQL.append("(URI_ID,CHILD_URI_ID) values( ");
  -                    theSQL.append(parent).append(" , ")
  -                          .append(getUriId((String)children.nextElement()))
  -                          .append(")");
  -                    statement.execute(theSQL.toString());
  +                    sql.setLength(0);
  +                    sql.append("INSERT INTO CHILDREN (URI_ID,CHILD_URI_ID) ")
  +                       .append("VALUES (").append(parent).append(", ")
  +                       .append(getUriId((String)children.nextElement()))
  +                       .append(")");
  +                    stmt.execute(sql.toString());
                   }
               }
  +            
               // Updating link
  -
  +            // [not implemented]
  +            
  +            // store the link target
               if (object instanceof LinkNode) {
  -                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(" , ").
  -                                        append(link_to).append(")");
  -                    statement.execute(theSQL.toString());
  +                long linkTargetId = getUriId(((LinkNode)object).getLinkedUri());
  +                if (!isLinkExist(parent, linkTargetId)) {
  +                    sql.setLength(0);
  +                    sql.append("INSERT INTO LINKS (URI_ID, LINK_TO_ID) ")
  +                       .append("VALUES (").append(parent).append(", ")
  +                       .append(linkTargetId).append(")");
  +                    stmt.execute(sql.toString());
                   }
               }
  -
  +            
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                if (stmt != null) {
  +                    stmt.close();
  +                }
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
               }
           }
  -
       }
   
   
  @@ -665,64 +646,57 @@
        * @param uri Uri of the object we want to create
        * @exception ServiceAccessException Error accessing the Service
        * @exception ObjectAlreadyExistsException An object already exists
  -     * at this Uri
  +     *            at this Uri
        */
       public void createObject(Uri uri, ObjectNode object)
           throws ServiceAccessException, ObjectAlreadyExistsException {
   
  -        Statement statement = null;
  -
  +        Statement stmt = null;
  +        StringBuffer sql = new StringBuffer();
           try {
  +            stmt = connection.createStatement();
  +            
               setUriId(uri.toString());
  -            long uriid = getUriId(uri.toString());
  -
  -            String className = object.getClass().getName();
  -
  -            statement = connection.createStatement();
  -
  -            StringBuffer theSQL = new StringBuffer
  -                            ("select 1 from OBJECT where URI_ID= ");
  -            theSQL.append(uriid);
  -
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  -
  -
  -            // Parsing result set
  -
  -            if (res.next()) {
  +            long uriId = getUriId(uri.toString());
  +            
  +            sql.setLength(0);
  +            sql.append("SELECT CLASS_NAME FROM OBJECT WHERE URI_ID = ")
  +               .append(uriId);
  +            ResultSet rs = stmt.executeQuery(sql.toString());
  +            if (rs.next()) {
                   throw new ObjectAlreadyExistsException(uri.toString());
               }
   
  -            theSQL = new StringBuffer
  -                            ("insert into OBJECT (URI_ID,CLASS_NAME) values ( ");
  -            theSQL.append(uriid).append(" , '")
  -                        .append(className).append("' )");
  -            statement.execute(theSQL.toString());
  -
  -
  -            Enumeration children = getNewChildren
  -                                (uriid,object.enumerateChildren());
  +            // store the class name
  +            sql.setLength(0);
  +            sql.append("INSERT INTO OBJECT (URI_ID,CLASS_NAME) ")
  +               .append("VALUES (").append(uriId).append(", '")
  +               .append(object.getClass().getName()).append("')");
  +            stmt.execute(sql.toString());
  +            
  +            // store children
  +            Enumeration children =
  +                getNewChildren(uriId, object.enumerateChildren());
               if (children != null) {
                   while (children.hasMoreElements()) {
  -                    theSQL = new StringBuffer("insert into CHILDREN ");
  -                    theSQL.append("(URI_ID,CHILD_URI_ID) values( ");
  -                    theSQL.append(uriid).append(" , ")
  -                          .append(getUriId((String)children.nextElement()))
  -                          .append(" )");
  -                    statement.execute(theSQL.toString());
  +                    sql.setLength(0);
  +                    sql.append("INSERT INTO CHILDREN (URI_ID,CHILD_URI_ID) ")
  +                       .append("VALUES (").append(uriId).append(", ")
  +                       .append(getUriId((String)children.nextElement()))
  +                       .append(" )");
  +                    stmt.execute(sql.toString());
                   }
               }
   
  -            // If the object is a link, also store the link information
  +            // if the object is a link, also store the link information
               if (object instanceof LinkNode) {
  -                long link_to = getUriId
  -                            (((LinkNode) object).getLinkedUri());
  -                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("' )");
  -                    statement.execute(theSQL.toString());
  +                long linkTargetId = getUriId(((LinkNode)object).getLinkedUri());
  +                if (!isLinkExist(uriId, linkTargetId)) {
  +                    sql.setLength(0);
  +                    sql.append("INSERT INTO LINKS (URI_ID, LINK_TO_ID) ")
  +                       .append("VALUES (").append(uriId).append(", ")
  +                       .append(linkTargetId).append(")");
  +                    stmt.execute(sql.toString());
                   }
               }
   
  @@ -731,13 +705,14 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                if (stmt != null) {
  +                    stmt.close();
  +                }
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
               }
           }
  -
       }
   
   
  @@ -751,60 +726,56 @@
       public void removeObject(Uri uri, ObjectNode object)
           throws ServiceAccessException, ObjectNotFoundException {
   
  -
  +        Statement stmt = null;
  +        StringBuffer sql = new StringBuffer();
           try {
  -            long uriid = getUriId(object.getUri());
  -            Statement statement = null;
  -
  -            statement = connection.createStatement();
  -
  -            // Removing children
  -            StringBuffer theSQL = new StringBuffer
  -                                ("delete from CHILDREN where URI_ID = ");
  -            theSQL.append(uriid).append(" OR CHILD_URI_ID = ")
  -                                  .append(uriid);
  -            statement.execute(theSQL.toString());
  -
  -            // Removing REST
  -
  -
  -            theSQL = new StringBuffer
  -                            ("delete from LINKS where URI_ID = ");
  -            theSQL.append(uriid);
  -            statement.execute(theSQL.toString());
  -
  -            theSQL = new StringBuffer
  -                            ("delete from VERSION_HISTORY where URI_ID = ");
  -            theSQL.append(uriid);
  -            statement.execute(theSQL.toString());
  -
  -            theSQL = new StringBuffer
  -                            ("delete from VERSION where URI_ID = ");
  -            theSQL.append(uriid);
  -            statement.execute(theSQL.toString());
  -
  -            // Removing object
  -            theSQL = new StringBuffer
  -                            ("delete from OBJECT where URI_ID = ");
  -            theSQL.append(uriid);
  -            statement.execute(theSQL.toString());
  -
  -            theSQL = new StringBuffer
  -                            ("delete from URI where URI_ID = ");
  -            theSQL.append(uriid);
  -            statement.execute(theSQL.toString());
  -
  +            stmt = connection.createStatement();
  +            
  +            long uriId = getUriId(object.getUri());
  +            if (uriId == 0) {
  +                throw new ObjectNotFoundException(uri);
  +            }
  +            
  +            // remove related child associations
  +            sql.setLength(0);
  +            sql.append("DELETE FROM CHILDREN WHERE URI_ID = ")
  +               .append(uriId).append(" OR CHILD_URI_ID = ").append(uriId);
  +            stmt.execute(sql.toString());
  +            
  +            // delete link target and/or inbound links
  +            sql.setLength(0);
  +            sql.append("DELETE FROM LINKS WHERE URI_ID = ").append(uriId);
  +            stmt.execute(sql.toString());
  +            
  +            // delete the object itself
  +            sql.setLength(0);
  +            sql.append("DELETE FROM OBJECT WHERE URI_ID = ").append(uriId);
  +            stmt.execute(sql.toString());
  +            
  +            // delete the URI
               removeUri(object.getUri());
               
  -            statement.close();
  +            stmt.close();
   
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
  +        } finally {
  +            try {
  +                if (stmt != null) {
  +                    stmt.close();
  +                }
  +            } catch (SQLException e) {
  +                getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
  +                throw new ServiceAccessException(this, e);
  +            }
           }
       }
   
   
  +    // -------------------------------------------------- SecurityStore Methods
  +    
  +    
       /**
        * Grant a new permission.
        *
  @@ -814,10 +785,10 @@
       public void grantPermission(Uri uri, NodePermission permission)
           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
               NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
               String revisionNumberStr =
                   (revisionNumber == null) ? "NULL" : revisionNumber.toString();
  @@ -828,30 +799,30 @@
               long subid = getUriId(permission.getSubjectUri());
               long actid = getUriId(permission.getActionUri());
   
  -            StringBuffer theSQL = new StringBuffer("select 1 from PERMISSIONS");
  -                        theSQL.append(" where OBJECT_ID = ");
  -            theSQL.append(objid).append(" and SUBJECT_ID= ")
  +            StringBuffer sql = new StringBuffer("select 1 from PERMISSIONS");
  +                        sql.append(" where OBJECT_ID = ");
  +            sql.append(objid).append(" and SUBJECT_ID= ")
                       .append(subid).append(" and ACTION_ID = " )
                       .append(actid);
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  +            ResultSet rs = stmt.executeQuery(sql.toString());
   
  -            if (! res.next()) {
  -                theSQL = new StringBuffer("insert into PERMISSIONS ");
  -                theSQL.append("(OBJECT_ID,SUBJECT_ID,ACTION_ID,VERSION_NO,");
  -                theSQL.append("IS_INHERITABLE,IS_NEGATIVE) values( ");
  -                theSQL.append(objid).append(", ").append(subid)
  +            if (! rs.next()) {
  +                sql = new StringBuffer("insert into PERMISSIONS ");
  +                sql.append("(OBJECT_ID,SUBJECT_ID,ACTION_ID,VERSION_NO,");
  +                sql.append("IS_INHERITABLE,IS_NEGATIVE) values( ");
  +                sql.append(objid).append(", ").append(subid)
                           .append(", ").append(actid)
                           .append(", ").append(revisionNumberStr)
                           .append(", ").append(permission.isInheritable())
                           .append(", ").append(permission.isNegative()).append(")");
  -                statement.execute(theSQL.toString());
  +                stmt.execute(sql.toString());
               }
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -871,33 +842,33 @@
           throws ServiceAccessException {
   
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
               NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
  -            StringBuffer theSQL = new StringBuffer("delete from PERMISSIONS ");
  -            theSQL.append("where OBJECT_ID= ");
  -            theSQL.append(getUriId(permission.getObjectUri()))
  +            StringBuffer sql = new StringBuffer("delete from PERMISSIONS ");
  +            sql.append("where OBJECT_ID= ");
  +            sql.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 = ")
  +                stmt.execute(sql.append(" and VERSION_NO = ")
                               .append(revisionNumber.toString()).toString());
               }
               else {
  -                statement.execute(
  -                        theSQL.append(" and VERSION_NO = NULL").toString());
  +                stmt.execute(
  +                        sql.append(" and VERSION_NO = NULL").toString());
               }
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -916,22 +887,22 @@
       public void revokePermissions(Uri uri)
           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
   
  -            statement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer("delete from PERMISSIONS");
  -            theSQL.append(" where OBJECT_ID= ");
  -            theSQL.append(getUriId(uri.toString()));
  -            statement.execute(theSQL.toString());
  +            stmt = connection.createStatement();
  +            StringBuffer sql = new StringBuffer("delete from PERMISSIONS");
  +            sql.append(" where OBJECT_ID= ");
  +            sql.append(getUriId(uri.toString()));
  +            stmt.execute(sql.toString());
   
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -951,28 +922,28 @@
           throws ServiceAccessException {
   
           Vector permissionVector = new Vector();
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
  -            StringBuffer theSQL = new StringBuffer("select * from PERMISSIONS ");
  -            theSQL.append("where OBJECT_ID = ");
  -            theSQL.append(getUriId(uri.toString()));
  -            statement.execute(theSQL.toString());
  +            StringBuffer sql = new StringBuffer("select * from PERMISSIONS ");
  +            sql.append("where OBJECT_ID = ");
  +            sql.append(getUriId(uri.toString()));
  +            stmt.execute(sql.toString());
   
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  +            ResultSet rs = stmt.executeQuery(sql.toString());
               String object = null;
  -            while (res.next()) {
  +            while (rs.next()) {
                   if (object == null) {
  -                    object   = getUri(res.getLong("OBJECT_ID"));
  +                    object   = getUri(rs.getLong("OBJECT_ID"));
                   }
  -                String revision = res.getString("VERSION_NO");
  -                String subject  = getUri(res.getLong("SUBJECT_ID"));
  -                String action   = getUri(res.getLong("ACTION_ID"));
  +                String revision = rs.getString("VERSION_NO");
  +                String subject  = getUri(rs.getLong("SUBJECT_ID"));
  +                String action   = getUri(rs.getLong("ACTION_ID"));
   
  -                boolean inheritable = res.getBoolean("IS_INHERITABLE");
  -                boolean negative = res.getBoolean("IS_NEGATIVE");
  +                boolean inheritable = rs.getBoolean("IS_INHERITABLE");
  +                boolean negative = rs.getBoolean("IS_NEGATIVE");
                   NodePermission permission =
                       new NodePermission(object,revision,subject,
                                          action,inheritable,negative);
  @@ -984,7 +955,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1004,35 +975,35 @@
       public void putLock(Uri uri, NodeLock lock)
           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
  -            StringBuffer theSQL =
  +            StringBuffer sql =
                   new StringBuffer("insert into LOCKS (LOCK_ID,OBJECT_ID,");
  -                theSQL.append("SUBJECT_ID,TYPE_ID,EXPIRATION_DATE,");
  -                theSQL.append("IS_INHERITABLE,IS_EXCLUSIVE) values( ");
  +                sql.append("SUBJECT_ID,TYPE_ID,EXPIRATION_DATE,");
  +                sql.append("IS_INHERITABLE,IS_EXCLUSIVE) values( ");
               long in_lockid = getUriId(lock.getLockId());
               if (in_lockid == 0 ) {
                   setUriId(lock.getLockId());
                   in_lockid = getUriId(lock.getLockId());
               }
  -            theSQL.append(in_lockid).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(" ) ");
  -            statement.execute(theSQL.toString());
  +            sql.append(in_lockid).append(", ");
  +            sql.append(getUriId(lock.getObjectUri())).append(", ");
  +            sql.append(getUriId(lock.getSubjectUri())).append(", ");
  +            sql.append(getUriId(lock.getTypeUri())).append(", ");
  +            sql.append(lock.getExpirationDate().getTime()).append(", ");
  +            sql.append(lock.isInheritable()).append(", ");
  +            sql.append(lock.isExclusive()).append(" ) ");
  +            stmt.execute(sql.toString());
   
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1073,23 +1044,23 @@
       public void removeLock(Uri uri, NodeLock lock)
           throws ServiceAccessException, LockTokenNotFoundException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
   
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
               int inheritable = 0;
               if (lock.isInheritable()) {
                   inheritable = 1;
               }
   
  -            StringBuffer theSQL =
  +            StringBuffer sql =
                       new StringBuffer("delete from LOCKS where LOCK_ID= '");
               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);
  +            sql.append(in_lock).append("'");
  +            stmt.execute(sql.toString());
  +            stmt.execute("delete from URI where URI_ID = " + in_lock);
               
               // Lock-IDs shouldn't go into the URI table I think, need to fix
               // that in some other places to
  @@ -1100,7 +1071,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1136,35 +1107,35 @@
           throws ServiceAccessException {
   
           Vector lockVector = new Vector();
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
   
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
  -            StringBuffer theSQL =
  +            StringBuffer sql =
                       new StringBuffer("select * from LOCKS where OBJECT_ID= ");
  -            theSQL.append(getUriId(uri.toString()));
  +            sql.append(getUriId(uri.toString()));
   
  -            ResultSet res = statement.executeQuery(theSQL.toString());
  +            ResultSet rs = stmt.executeQuery(sql.toString());
   
  -            while (res.next()) {
  +            while (rs.next()) {
                   Date expirationDate = null;
                   try {
  -                    Long timeValue = new Long(res.getLong
  +                    Long timeValue = new Long(rs.getLong
                                                 ("EXPIRATION_DATE"));
                       expirationDate = new Date(timeValue.longValue());
                   } catch (NumberFormatException e) {
                       expirationDate = new Date();
                   }
                   NodeLock lock =
  -                    new NodeLock(getUri(res.getLong("LOCK_ID")),
  -                                 getUri(res.getLong("OBJECT_ID")),
  -                                 getUri(res.getLong("SUBJECT_ID")),
  -                                 getUri(res.getLong("TYPE_ID")),
  +                    new NodeLock(getUri(rs.getLong("LOCK_ID")),
  +                                 getUri(rs.getLong("OBJECT_ID")),
  +                                 getUri(rs.getLong("SUBJECT_ID")),
  +                                 getUri(rs.getLong("TYPE_ID")),
                                    expirationDate,
  -                                 res.getBoolean("IS_INHERITABLE"),
  -                                 res.getBoolean("IS_EXCLUSIVE"));
  +                                 rs.getBoolean("IS_INHERITABLE"),
  +                                 rs.getBoolean("IS_EXCLUSIVE"));
                   lockVector.addElement(lock);
               }
   
  @@ -1173,7 +1144,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1195,60 +1166,60 @@
           throws ServiceAccessException, RevisionDescriptorNotFoundException {
   
           NodeRevisionDescriptors revisionDescriptors = null;
  -        Statement statement = null;
  +        Statement stmt = null;
           Statement statement2 = null;
   
           try {
  -            ResultSet res = null;
  +            ResultSet rs = null;
   
               NodeRevisionNumber initialRevision = new NodeRevisionNumber();
               Hashtable workingRevisions = new Hashtable();
               Hashtable latestRevisionNumbers = new Hashtable();
               Hashtable branches = new Hashtable();
               boolean isVersioned = false;
  -            long uriid = getUriId(uri.toString());
  -            statement = connection.createStatement();
  +            long uriId = getUriId(uri.toString());
  +            stmt = connection.createStatement();
               statement2 = connection.createStatement();
  -            StringBuffer theSQL =
  +            StringBuffer sql =
                   new StringBuffer("select IS_VERSIONED from VERSION");
  -            theSQL.append(" where URI_ID= ");
  -            theSQL.append(uriid);
  -            res = statement.executeQuery(theSQL.toString());
  +            sql.append(" where URI_ID= ");
  +            sql.append(uriId);
  +            rs = stmt.executeQuery(sql.toString());
   
  -            if (res.next()) {
  -                isVersioned = res.getBoolean("IS_VERSIONED");
  +            if (rs.next()) {
  +                isVersioned = rs.getBoolean("IS_VERSIONED");
               } else {
                   throw new RevisionDescriptorNotFoundException(uri.toString());
               }
   
   
  -            theSQL = new StringBuffer("select VERSION_ID,REVISION_NO, ");
  -            theSQL.append("B.BRANCH_STRING  from VERSION_HISTORY A , ");
  -            theSQL.append("BRANCH B where A.URI_ID= ");
  -            theSQL.append(uriid).append(" and A.BRANCH_ID = B.BRANCH_ID");
  -            res = statement.executeQuery(theSQL.toString());
  +            sql = new StringBuffer("select VERSION_ID,REVISION_NO, ");
  +            sql.append("B.BRANCH_STRING  from VERSION_HISTORY A , ");
  +            sql.append("BRANCH B where A.URI_ID= ");
  +            sql.append(uriId).append(" and A.BRANCH_ID = B.BRANCH_ID");
  +            rs = stmt.executeQuery(sql.toString());
   
  -            while(res.next()) {
  -                String branchid = res.getString("BRANCH_STRING");
  +            while(rs.next()) {
  +                String branchid = rs.getString("BRANCH_STRING");
   
  -                long versionid = res.getLong("VERSION_ID");
  -                String currentRevisionNumber = res.getString("REVISION_NO");
  +                long versionid = rs.getLong("VERSION_ID");
  +                String currentRevisionNumber = rs.getString("REVISION_NO");
                   latestRevisionNumbers
                       .put(branchid,
                           new NodeRevisionNumber(currentRevisionNumber));
   
   
                   // We parse the revision list of the object
  -                theSQL = new StringBuffer("select PREDECESSOR_ID from ");
  -                theSQL.append("VERSION_PREDS where VERSION_ID  = ");
  -                theSQL.append(versionid);
  -                ResultSet res2 = statement2.executeQuery(theSQL.toString());
  +                sql = new StringBuffer("select PREDECESSOR_ID from ");
  +                sql.append("VERSION_PREDS where VERSION_ID  = ");
  +                sql.append(versionid);
  +                ResultSet res2 = statement2.executeQuery(sql.toString());
                   Vector childList = new Vector();
   
                   while (res2.next()) {
                       childList.addElement(new NodeRevisionNumber
                           (getXNumber(res2.getLong("PREDECESSOR_ID"),
  -                                         uriid,
  +                                         uriId,
                                            branchid)));
                   }
   
  @@ -1267,7 +1238,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
                   statement2.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
  @@ -1292,10 +1263,10 @@
           // TODO : Here, we have the option of "cleaning up" before
           // creating the new records in the database.
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            ResultSet res = null;
  +            ResultSet rs = null;
   
               // Creating record in revisions tables
   
  @@ -1304,43 +1275,43 @@
                   isVersioned = 1;
               }
               long urid = getUriId(uri.toString());
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
  -            StringBuffer theSQL =
  +            StringBuffer sql =
                       new StringBuffer("SELECT 1 FROM VERSION WHERE URI_ID =");
  -            theSQL.append(urid);
  -            res = statement.executeQuery(theSQL.toString());
  -            if (!res.next()) {
  -                theSQL = new StringBuffer("insert into VERSION ");
  -                theSQL.append("(URI_ID,IS_VERSIONED) values( ");
  -                theSQL.append(urid).append(", ").append(isVersioned)
  +            sql.append(urid);
  +            rs = stmt.executeQuery(sql.toString());
  +            if (!rs.next()) {
  +                sql = new StringBuffer("insert into VERSION ");
  +                sql.append("(URI_ID,IS_VERSIONED) values( ");
  +                sql.append(urid).append(", ").append(isVersioned)
                         .append(")");
  -                statement.execute(theSQL.toString());
  +                stmt.execute(sql.toString());
               }
   
             // For now, only the latest revision from the main branch is stored
               long brid = getBranchID( NodeRevisionDescriptors.
                                               MAIN_BRANCH.toString());
  -            theSQL = new StringBuffer
  +            sql = new StringBuffer
                               ("SELECT 1 FROM VERSION_HISTORY WHERE URI_ID =");
  -            theSQL.append(urid).append(" and BRANCH_ID = ").append(brid);
  +            sql.append(urid).append(" and BRANCH_ID = ").append(brid);
               if (revisionDescriptors.getLatestRevision() == null) {
  -                theSQL.append(" and REVISION_NO = ").append("NULL");
  +                sql.append(" and REVISION_NO = ").append("NULL");
               } else {
  -                theSQL.append(" and REVISION_NO = '").
  +                sql.append(" and REVISION_NO = '").
                   append(revisionDescriptors.getLatestRevision().toString())
                   .append("'");
               }
  -            res = statement.executeQuery(theSQL.toString());
  -            if (!res.next()) {
  +            rs = stmt.executeQuery(sql.toString());
  +            if (!rs.next()) {
                   if (revisionDescriptors.getLatestRevision() != null) {
  -                    theSQL = new StringBuffer("insert into VERSION_HISTORY ");
  -                    theSQL.append("(URI_ID,BRANCH_ID,REVISION_NO) values(");
  -                    theSQL.append(urid).append(", ").append(brid);
  -                    theSQL.append(", '").append(
  +                    sql = new StringBuffer("insert into VERSION_HISTORY ");
  +                    sql.append("(URI_ID,BRANCH_ID,REVISION_NO) values(");
  +                    sql.append(urid).append(", ").append(brid);
  +                    sql.append(", '").append(
                               revisionDescriptors.getLatestRevision().toString())
                               .append("')");
  -                    statement.execute(theSQL.toString());
  +                    stmt.execute(sql.toString());
                   }
               }
               // Creating records in the branches table
  @@ -1351,7 +1322,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1389,30 +1360,30 @@
       public void removeRevisionDescriptors(Uri uri)
           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            long uriid = getUriId(uri.toString());
  -            ResultSet res = null;
  -            statement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            long uriId = getUriId(uri.toString());
  +            ResultSet rs = null;
  +            stmt = connection.createStatement();
  +            StringBuffer sql = new StringBuffer
                   ("SELECT VERSION_ID FROM VERSION_HISTORY");
  -            theSQL.append(" where URI_ID = ");
  -            theSQL.append(uriid);
  -            res = statement.executeQuery(theSQL.toString());
  +            sql.append(" where URI_ID = ");
  +            sql.append(uriId);
  +            rs = stmt.executeQuery(sql.toString());
               Statement substatement = connection.createStatement();
  -            if (res.next()) {
  -                theSQL = new StringBuffer
  +            if (rs.next()) {
  +                sql = new StringBuffer
                   ("delete from VERSION_PREDS where VERSION_ID = ");
  -                theSQL.append(res.getLong("VERSION_ID"));
  -                substatement.execute(theSQL.toString());
  +                sql.append(rs.getLong("VERSION_ID"));
  +                substatement.execute(sql.toString());
               }            
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1433,7 +1404,7 @@
           throws ServiceAccessException, RevisionDescriptorNotFoundException {
   
           NodeRevisionDescriptor revisionDescriptor = null;
  -        Statement statement = null;
  +        Statement stmt = null;
   
           if (revisionNumber == null) {
               throw new RevisionDescriptorNotFoundException(uri.toString());
  @@ -1441,8 +1412,8 @@
   
           try {
   
  -            ResultSet res = null;
  -            long uriid = getUriId(uri.toString());
  +            ResultSet rs = null;
  +            long uriId = getUriId(uri.toString());
               String branchName = null;
               Vector labels = new Vector();
               Hashtable properties = new Hashtable();
  @@ -1450,18 +1421,18 @@
               // Retrieving branch name (and also check that revision
               // does indeed exist)
   
  -            statement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer("select A.VERSION_ID, ");
  -            theSQL.append("B.BRANCH_STRING from VERSION_HISTORY A, BRANCH B");
  -            theSQL.append(" where A.URI_ID = ");
  -            theSQL.append(uriid).append(" and A.REVISION_NO = '");
  -            theSQL.append(revisionNumber.toString());
  -            theSQL.append("' and B.BRANCH_ID = A.BRANCH_ID");
  -            res = statement.executeQuery(theSQL.toString());
  +            stmt = connection.createStatement();
  +            StringBuffer sql = new StringBuffer("select A.VERSION_ID, ");
  +            sql.append("B.BRANCH_STRING from VERSION_HISTORY A, BRANCH B");
  +            sql.append(" where A.URI_ID = ");
  +            sql.append(uriId).append(" and A.REVISION_NO = '");
  +            sql.append(revisionNumber.toString());
  +            sql.append("' and B.BRANCH_ID = A.BRANCH_ID");
  +            rs = stmt.executeQuery(sql.toString());
               long Version_ID = 0;
  -            if (res.next()) {
  -                branchName = res.getString("BRANCH_STRING");
  -                Version_ID = res.getLong("VERSION_ID");
  +            if (rs.next()) {
  +                branchName = rs.getString("BRANCH_STRING");
  +                Version_ID = rs.getLong("VERSION_ID");
               } else {
                   throw new RevisionDescriptorNotFoundException(uri.toString());
               }
  @@ -1469,32 +1440,32 @@
   
               // Retrieve labels
   
  -            theSQL = new StringBuffer
  +            sql = new StringBuffer
                    ("select LABEL_ID from VERSION_LABELS where VERSION_ID = ");
  -            theSQL.append(Version_ID);
  -            res = statement.executeQuery(theSQL.toString());
  +            sql.append(Version_ID);
  +            rs = stmt.executeQuery(sql.toString());
   
  -            while (res.next()) {
  -                labels.addElement(getLabelName(res.getLong("LABEL_ID")));
  +            while (rs.next()) {
  +                labels.addElement(getLabelName(rs.getLong("LABEL_ID")));
               }
   
   
               // Retrieve properties
   
  -            theSQL = new StringBuffer
  +            sql = new StringBuffer
                       ("select * from PROPERTIES where VERSION_ID = ");
  -            theSQL.append(Version_ID);
  -            res = statement.executeQuery(theSQL.toString());
  +            sql.append(Version_ID);
  +            rs = stmt.executeQuery(sql.toString());
   
  -            while (res.next()) {
  -                String propertyName = res.getString("PROPERTY_NAME");
  -                String propertyNamespace = res.getString("PROPERTY_NAMESPACE");
  +            while (rs.next()) {
  +                String propertyName = rs.getString("PROPERTY_NAME");
  +                String propertyNamespace = rs.getString("PROPERTY_NAMESPACE");
                   NodeProperty property =
                       new NodeProperty(propertyName,
  -                                     res.getString("PROPERTY_VALUE"),
  +                                     rs.getString("PROPERTY_VALUE"),
                                        propertyNamespace,
  -                                     res.getString("PROPERTY_TYPE"),
  -                                     res.getBoolean("IS_PROTECTED"));
  +                                     rs.getString("PROPERTY_TYPE"),
  +                                     rs.getBoolean("IS_PROTECTED"));
                   properties.put(propertyNamespace + propertyName, property);
               }
   
  @@ -1507,7 +1478,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1529,51 +1500,51 @@
           (Uri uri, NodeRevisionDescriptor revisionDescriptor)
           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            ResultSet res = null;
  +            ResultSet rs = null;
   
  -            long uriid = getUriId(uri.toString());
  +            long uriId = getUriId(uri.toString());
               long brid = getBranchID(revisionDescriptor.getBranchName());
               if (brid == 0 ) {
                   setBranchID(revisionDescriptor.getBranchName());
                   brid = getBranchID(revisionDescriptor.getBranchName());
               }
  -            statement = connection.createStatement();
  +            stmt = connection.createStatement();
   
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                       ("SELECT 1 FROM VERSION WHERE URI_ID =");
  -            theSQL.append(uriid);
  -            res = statement.executeQuery(theSQL.toString());
  -            if (!res.next()) {
  -                theSQL = new StringBuffer
  +            sql.append(uriId);
  +            rs = stmt.executeQuery(sql.toString());
  +            if (!rs.next()) {
  +                sql = new StringBuffer
                           ("insert into VERSION (URI_ID,IS_VERSIONED) values( ");
  -                theSQL.append(uriid).append(", ").append(0).append(")");
  -                statement.execute(theSQL.toString());
  +                sql.append(uriId).append(", ").append(0).append(")");
  +                stmt.execute(sql.toString());
               }
   
  -            theSQL = new StringBuffer
  +            sql = new StringBuffer
                           ("SELECT 1 FROM VERSION_HISTORY WHERE URI_ID =");
  -            theSQL.append(uriid).append(" and BRANCH_ID = ");
  -            theSQL.append(brid).append(" and REVISION_NO = '" );
  -            theSQL.append(revisionDescriptor.getRevisionNumber().toString());
  -            theSQL.append("'");
  +            sql.append(uriId).append(" and BRANCH_ID = ");
  +            sql.append(brid).append(" and REVISION_NO = '" );
  +            sql.append(revisionDescriptor.getRevisionNumber().toString());
  +            sql.append("'");
   
  -            res = statement.executeQuery(theSQL.toString());
  +            rs = stmt.executeQuery(sql.toString());
   
  -            if (!res.next()) {
  +            if (!rs.next()) {
   
  -                theSQL = new StringBuffer
  +                sql = new StringBuffer
                       ("insert into VERSION_HISTORY (URI_ID,BRANCH_ID,");
  -                theSQL.append("REVISION_NO) values(");
  -                theSQL.append(uriid).append(", ").append(brid);
  -                theSQL.append(", '").append
  +                sql.append("REVISION_NO) values(");
  +                sql.append(uriId).append(", ").append(brid);
  +                sql.append(", '").append
                       (revisionDescriptor.getRevisionNumber().toString());
  -                theSQL.append("')");
  -                statement.execute(theSQL.toString());
  +                sql.append("')");
  +                stmt.execute(sql.toString());
               }
  -            long Version_ID = getVersionID(uriid,
  +            long Version_ID = getVersionID(uriId,
                               revisionDescriptor.getBranchName(),
                               revisionDescriptor.getRevisionNumber().toString());
   
  @@ -1586,11 +1557,11 @@
                       setLabelID(sLabel);
                       label= getLabelID(sLabel);
                   }
  -                theSQL = new StringBuffer("insert into VERSION_LABELS ");
  -                theSQL.append("(VERSION_ID,LABEL_ID) values( ");
  -                theSQL.append(Version_ID).append(", ");
  -                theSQL.append(label).append(")");
  -                statement.execute(theSQL.toString());
  +                sql = new StringBuffer("insert into VERSION_LABELS ");
  +                sql.append("(VERSION_ID,LABEL_ID) values( ");
  +                sql.append(Version_ID).append(", ");
  +                sql.append(label).append(")");
  +                stmt.execute(sql.toString());
               }
   
               // Creating associated properties
  @@ -1621,7 +1592,7 @@
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1660,11 +1631,11 @@
                           NodeRevisionNumber revisionNumber)
                           throws ServiceAccessException {
   
  -        Statement statement = null;
  +        Statement stmt = null;
   
           try {
  -            statement = connection.createStatement();
  -            long uriid = getUriId(uri.toString());
  +            stmt = connection.createStatement();
  +            long uriId = getUriId(uri.toString());
               String revisionNumberStr =
                   (revisionNumber == null) ? "NULL" : revisionNumber.toString();
               String branchStr = null;
  @@ -1674,26 +1645,26 @@
                   branchStr = "main";
               }
               long Version_ID =
  -                getVersionID(uriid,branchStr,revisionNumberStr);
  +                getVersionID(uriId,branchStr,revisionNumberStr);
               // Removing revision labels
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                           ("delete from VERSION_LABELS where VERSION_ID= ");
  -            theSQL.append(Version_ID);
  -            statement.execute(theSQL.toString());
  +            sql.append(Version_ID);
  +            stmt.execute(sql.toString());
   
               // Removing associated properties
   
  -            theSQL = new StringBuffer
  +            sql = new StringBuffer
                               ("delete from PROPERTIES where VERSION_ID= ");
  -            theSQL.append(Version_ID);
  -            statement.execute(theSQL.toString());
  +            sql.append(Version_ID);
  +            stmt.execute(sql.toString());
   
           } catch (SQLException e) {
               getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
               throw new ServiceAccessException(this, e);
           } finally {
               try {
  -                statement.close();
  +                stmt.close();
               } catch (SQLException e) {
                   getLogger().log(e,LOG_CHANNEL,Logger.ERROR);
                   throw new ServiceAccessException(this, e);
  @@ -1728,10 +1699,10 @@
                                             revisionDescriptor.getBranchName(),
                                             revisionNumber);
               selectStatement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                   ("select CONTENT from VERSION_CONTENT where VERSION_ID = ");
  -            theSQL.append(versionid);
  -            ResultSet rs = selectStatement.executeQuery(theSQL.toString());
  +            sql.append(versionid);
  +            ResultSet rs = selectStatement.executeQuery(sql.toString());
   
               if (!rs.next()) {
                   rs.close();
  @@ -1762,7 +1733,7 @@
               result.setContent(is);                          
   
               // this input stream passes on the closure of itself onto the
  -            // jdbc statement and resultSet
  +            // jdbc stmt and resultSet
               result.setContent( new JDBCAwareInputStream(is,selectStatement) );
               selectStatement.close();
   
  @@ -1809,10 +1780,10 @@
                                             revisionNumber);
   
               selectStatement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                       ("select 1 from VERSION_CONTENT where VERSION_ID = ");
  -            theSQL.append(versionid);
  -            ResultSet rs = selectStatement.executeQuery(theSQL.toString());
  +            sql.append(versionid);
  +            ResultSet rs = selectStatement.executeQuery(sql.toString());
               if (rs.next()) {
                   rs.close();
                   throw new RevisionAlreadyExistException
  @@ -1875,10 +1846,10 @@
                                             revisionNumber);
   
               selectStatement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                       ("select 1 from VERSION_CONTENT where VERSION_ID = ");
  -            theSQL.append(versionid);
  -            ResultSet rs = selectStatement.executeQuery(theSQL.toString());
  +            sql.append(versionid);
  +            ResultSet rs = selectStatement.executeQuery(sql.toString());
   
               if (!rs.next()) {
                   rs.close();
  @@ -2069,10 +2040,10 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                   ("select BRANCH_ID from BRANCH where BRANCH_STRING = '");
  -        theSQL.append(branchName).append("'");
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append(branchName).append("'");
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           if (rslt.next()) {
               return rslt.getLong("BRANCH_ID");
           } else {
  @@ -2090,10 +2061,10 @@
   
           if (getBranchID(branchName) == 0 ) {
               Statement addStatement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                           ("insert into BRANCH (BRANCH_STRING) values ('");
  -            theSQL.append(branchName).append("')");
  -            addStatement.execute(theSQL.toString());
  +            sql.append(branchName).append("')");
  +            addStatement.execute(sql.toString());
               addStatement.close();
           }
       }
  @@ -2106,10 +2077,10 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                       ("select LABEL_ID from LABEL where LABEL_STRING = '");
  -        theSQL.append(labelName).append("'");
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append(labelName).append("'");
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           if (rslt.next()) {
               return rslt.getLong("LABEL_ID");
           } else {
  @@ -2125,10 +2096,10 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                       ("select LABEL_STRING from LABEL where LABEL_ID= ");
  -        theSQL.append(labelID);
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append(labelID);
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           if (rslt.next()) {
               return rslt.getString("LABEL_STRING");
           } else {
  @@ -2145,10 +2116,10 @@
   
           if (getBranchID(labelName) == 0 ) {
               Statement addStatement = connection.createStatement();
  -            StringBuffer theSQL = new StringBuffer
  +            StringBuffer sql = new StringBuffer
                           ("insert into LABEL (LABEL_STRING) values ('");
  -            theSQL.append(labelName).append("')");
  -            addStatement.execute(theSQL.toString());
  +            sql.append(labelName).append("')");
  +            addStatement.execute(sql.toString());
               addStatement.close();
           }
       }
  @@ -2164,11 +2135,11 @@
           Hashtable hshtempHash = new Hashtable();
           Hashtable hshnewChild = new Hashtable();
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                   ("select A.URI_STRING FROM URI A, CHILDREN B WHERE A.URI_ID = ");
  -        theSQL.append("B.CHILD_URI_ID AND B.URI_ID = ");
  -        theSQL.append(parent);
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append("B.CHILD_URI_ID AND B.URI_ID = ");
  +        sql.append(parent);
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           String s_child = null;
           while (rslt.next()) {
               s_child = rslt.getString("URI_STRING");
  @@ -2194,10 +2165,10 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                           ("select 1 from LINKS where URI_ID = " );
  -        theSQL.append(parent).append(" and LINK_TO_ID = ").append(child);
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append(parent).append(" and LINK_TO_ID = ").append(child);
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           return rslt.next();
       }
   
  @@ -2209,10 +2180,10 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                               ("select 1 from LOCKS where LOCK_ID = " );
  -        theSQL.append(parent);
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append(parent);
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           return rslt.next();
       }
   
  @@ -2226,13 +2197,13 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
               ("select A.VERSION_ID from VERSION_HISTORY A, BRANCH B ");
  -        theSQL.append("where  A.URI_ID= " );
  -        theSQL.append(uri_id).append(" and A.BRANCH_ID = B.BRANCH_ID and");
  -        theSQL.append(" B.BRANCH_STRING = '").append(branch_name);
  -        theSQL.append("' and A.REVISION_NO= '").append(sXNumber).append("'");
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append("where  A.URI_ID= " );
  +        sql.append(uri_id).append(" and A.BRANCH_ID = B.BRANCH_ID and");
  +        sql.append(" B.BRANCH_STRING = '").append(branch_name);
  +        sql.append("' and A.REVISION_NO= '").append(sXNumber).append("'");
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           if (rslt.next()) {
               return rslt.getLong("VERSION_ID");
           } else {
  @@ -2247,27 +2218,27 @@
       protected void setVersionID(long uri_id, long branch_id, String sXNumber)
           throws SQLException {
           Statement insStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                           ("SELECT 1 FROM VERSION WHERE URI_ID =");
  -        theSQL.append(uri_id);
  +        sql.append(uri_id);
           getLogger().log
                   ("Inside VersionID =="
  -                + theSQL.toString(),
  +                + sql.toString(),
                   LOG_CHANNEL,Logger.DEBUG);
  -        ResultSet res = insStatement.executeQuery(theSQL.toString());
  -        if (!res.next()) {
  -            theSQL = new StringBuffer
  +        ResultSet rs = insStatement.executeQuery(sql.toString());
  +        if (!rs.next()) {
  +            sql = new StringBuffer
                       ("insert into VERSION (URI_ID,IS_VERSIONED) values( ");
  -            theSQL.append(uri_id).append(", ").append(0).append(")");
  -            insStatement.execute(theSQL.toString());
  +            sql.append(uri_id).append(", ").append(0).append(")");
  +            insStatement.execute(sql.toString());
           }
  -        theSQL = new StringBuffer
  +        sql = new StringBuffer
               ("insert into VERSION_HISTORY (URI_ID,BRANCH_ID,REVISION_NO)");
  -        theSQL.append("values(");
  -        theSQL.append(uri_id).append(", ")
  +        sql.append("values(");
  +        sql.append(uri_id).append(", ")
                   .append(branch_id).append(", '")
                   .append(sXNumber).append("')");
  -        insStatement.execute(theSQL.toString());
  +        insStatement.execute(sql.toString());
           insStatement.close();
       }
   
  @@ -2281,14 +2252,14 @@
           throws SQLException {
   
           Statement getStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                   ("select A.REVISION_NO from VERSION_HISTORY A, ");
  -        theSQL.append("BRANCH B where A.VERSION_ID = " );
  -        theSQL.append(version_id).append(" and A.URI_ID= ");
  -        theSQL.append(uri_id).append(" and A.BRANCH_ID = B.BRANCH_ID");
  -        theSQL.append(" and B.BRANCH_STRING = '");
  -        theSQL.append(branch_name).append("'");
  -        ResultSet rslt = getStatement.executeQuery(theSQL.toString());
  +        sql.append("BRANCH B where A.VERSION_ID = " );
  +        sql.append(version_id).append(" and A.URI_ID= ");
  +        sql.append(uri_id).append(" and A.BRANCH_ID = B.BRANCH_ID");
  +        sql.append(" and B.BRANCH_STRING = '");
  +        sql.append(branch_name).append("'");
  +        ResultSet rslt = getStatement.executeQuery(sql.toString());
           if (rslt.next()) {
               return rslt.getString("REVISION_NO");
           } else {
  @@ -2411,10 +2382,10 @@
           throws SQLException {
   
           Statement deleteStatement = connection.createStatement();
  -        StringBuffer theSQL = new StringBuffer
  +        StringBuffer sql = new StringBuffer
                   ("delete from VERSION_CONTENT where VERSION_ID = ");
  -        theSQL.append(version_id);
  -        deleteStatement.execute(theSQL.toString());
  +        sql.append(version_id);
  +        deleteStatement.execute(sql.toString());
           deleteStatement.close();
   
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to