remm        01/05/20 15:00:53

  Modified:    src/stores/slidestore/reference JDBCDescriptorsStore.java
  Log:
  - Close statements after use.
  - Add a new revision number field to the permissions table.
  
  Revision  Changes    Path
  1.16      +241 -185  
jakarta-slide/src/stores/slidestore/reference/JDBCDescriptorsStore.java
  
  Index: JDBCDescriptorsStore.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/slidestore/reference/JDBCDescriptorsStore.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JDBCDescriptorsStore.java 2001/05/16 12:09:07     1.15
  +++ JDBCDescriptorsStore.java 2001/05/20 22:00:53     1.16
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/stores/slidestore/reference/JDBCDescriptorsStore.java,v 
1.15 2001/05/16 12:09:07 juergen Exp $
  - * $Revision: 1.15 $
  - * $Date: 2001/05/16 12:09:07 $
  + * $Header: 
/home/cvs/jakarta-slide/src/stores/slidestore/reference/JDBCDescriptorsStore.java,v 
1.16 2001/05/20 22:00:53 remm Exp $
  + * $Revision: 1.16 $
  + * $Date: 2001/05/20 22:00:53 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    * JDBC 1.0 and 2.0 compliant store implementation.
    * 
    * @author <a href="mailto:[EMAIL PROTECTED]";>Remy Maucherat</a>
  - * @version $Revision: 1.15 $
  + * @version $Revision: 1.16 $
    */
   
   public class JDBCDescriptorsStore
  @@ -112,10 +112,11 @@
       // Security descriptors
       
       protected static final int PERMISSIONS_OBJECT = 1;
  -    protected static final int PERMISSIONS_SUBJECT = 2;
  -    protected static final int PERMISSIONS_ACTION = 3;
  -    protected static final int PERMISSIONS_INHERITABLE = 4;
  -    protected static final int PERMISSIONS_NEGATIVE = 5;
  +    protected static final int PERMISSIONS_REVISION_NUMBER = 2;
  +    protected static final int PERMISSIONS_SUBJECT = 3;
  +    protected static final int PERMISSIONS_ACTION = 4;
  +    protected static final int PERMISSIONS_INHERITABLE = 5;
  +    protected static final int PERMISSIONS_NEGATIVE = 6;
       
       // Lock descriptors
       
  @@ -278,6 +279,7 @@
               statement.execute(s);
               
               s = "create table permissions(object varchar(65536)," 
  +                + " revisionnumber varchar(20), "
                   + " subject varchar(65536), action varchar(65536), " 
                   + "inheritable int, negative int)";
               statement.execute(s);
  @@ -533,8 +535,8 @@
           
           try {
               
  -            statement = connection.prepareStatement(
  -             "select * from objects where uri= ?");
  +            statement = connection.prepareStatement
  +                ("select * from objects where uri= ?");
            statement.setString(1, uri.toString());
               
               ResultSet res = statement.executeQuery();
  @@ -551,9 +553,11 @@
                   throw new ObjectNotFoundException(uri);
               }
               
  +            closeStatement(statement);
  +            
               // Then, retrieve the children
  -            statement = connection.prepareStatement(
  -                 "select * from children where uri= ?");
  +            statement = connection.prepareStatement
  +                ("select * from children where uri= ?");
            statement.setString(1,uri.toString());
               res = statement.executeQuery();
               
  @@ -565,8 +569,8 @@
                   childrenVector.addElement(res.getString(CHILDREN_CHILDURI));
               }
               
  -            statement = connection.prepareStatement(
  -                 "select * from links where linkto= ?");
  +            statement = connection.prepareStatement
  +                ("select * from links where linkto= ?");
               statement.setString(1,uri.toString());
               res = statement.executeQuery();
               
  @@ -577,18 +581,22 @@
                   // Load each permission
                   linksVector.addElement(res.getString(LINKS_LINKTO));
               }
  +            
  +            closeStatement(statement);
               
  -            if(className.equals("org.apache.slide.structure.LinkNode")) {
  +            if (className.equals("org.apache.slide.structure.LinkNode")) {
                   
                   String linkTo = new String();
  -                statement = connection.prepareStatement(
  -                     "select * from links where link= ?");
  +                statement = connection.prepareStatement
  +                    ("select * from links where link= ?");
                   statement.setString(1,uri.toString());
                   res = statement.executeQuery();
                   
                   if(res.next())
                       linkTo = res.getString(LINKS_LINKTO);
                   
  +                closeStatement(statement);
  +                
                   result = new LinkNode(uri.toString(), childrenVector,
                                         linksVector, linkTo);
                   
  @@ -638,9 +646,9 @@
           PreparedStatement statement = null;
           
           try {
  -            statement = connection.prepareStatement(
  -                 "select * from objects where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("select * from objects where uri= ?");
  +            statement.setString(1, uri.toString());
               
               ResultSet res = statement.executeQuery();
               
  @@ -650,19 +658,23 @@
                   throw new ObjectNotFoundException(uri);
               }
               
  +            closeStatement(statement);
  +            
               // Updating children
  -            statement = connection.prepareStatement(
  -             "delete from children where uri= ?");
  +            statement = connection.prepareStatement
  +                ("delete from children where uri= ?");
            statement.setString(1, object.getUri());
            statement.execute();
  -
  +            closeStatement(statement);
  +            
               Enumeration children = object.enumerateChildren();
               while (children.hasMoreElements()) {
  -                statement = connection.prepareStatement(
  -                 "insert into children values(?, ?)");
  -             statement.setString(1, object.getUri());
  -             statement.setString(2, (String)children.nextElement());
  +                statement = connection.prepareStatement
  +                    ("insert into children values(?, ?)");
  +                statement.setString(1, object.getUri());
  +                statement.setString(2, (String)children.nextElement());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               // Updating inbound links
  @@ -679,17 +691,19 @@
               */
               
               // Updating links
  -            statement = connection.prepareStatement(
  -                 "delete from links where link= ?");
  -         statement.setString(1, object.getUri());
  +            statement = connection.prepareStatement
  +                ("delete from links where link= ?");
  +            statement.setString(1, object.getUri());
               statement.execute();
  +            closeStatement(statement);
               
               if (object instanceof LinkNode) {
  -             statement = connection.prepareStatement(
  -                 "insert into links values(?,?)");
  -             statement.setString(1, object.getUri());
  -             statement.setString(2, ((LinkNode) object).getLinkedUri());
  +                statement = connection.prepareStatement
  +                    ("insert into links values(?,?)");
  +                statement.setString(1, object.getUri());
  +                statement.setString(2, ((LinkNode) object).getLinkedUri());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               res.close();
  @@ -721,9 +735,9 @@
               
               String className = object.getClass().getName();
               
  -            statement = connection.prepareStatement(
  -                 "select * from objects where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("select * from objects where uri= ?");
  +            statement.setString(1, uri.toString());
               
               ResultSet res = statement.executeQuery();
               
  @@ -733,21 +747,25 @@
                   throw new ObjectAlreadyExistsException(uri.toString());
               }
               
  -            statement = connection.prepareStatement(
  -                 "insert into objects values(?,?)");
  -         statement.setString(1, uri.toString());
  +            closeStatement(statement);
  +            
  +            statement = connection.prepareStatement
  +                ("insert into objects values(?,?)");
  +            statement.setString(1, uri.toString());
               statement.setString(2, className );
               
               statement.execute();
  +            closeStatement(statement);
               
               // Inserting children
               Enumeration children = object.enumerateChildren();
               while (children.hasMoreElements()) {
  -                statement = connection.prepareStatement(
  -                     "insert into children values(?,?)");
  -             statement.setString(1, uri.toString());
  -             statement.setString(2, (String) children.nextElement());
  +                statement = connection.prepareStatement
  +                    ("insert into children values(?,?)");
  +                statement.setString(1, uri.toString());
  +                statement.setString(2, (String) children.nextElement());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               // Updating inbound links
  @@ -763,11 +781,12 @@
               
               // If the object is a link, also store the link information
               if (object instanceof LinkNode) {
  -             statement = connection.prepareStatement(
  -                     "insert into links values(?,?)");
  -             statement.setString(1, uri.toString());
  -             statement.setString(2, ((LinkNode) object).getLinkedUri());
  +             statement = connection.prepareStatement
  +                    ("insert into links values(?,?)");
  +                statement.setString(1, uri.toString());
  +                statement.setString(2, ((LinkNode) object).getLinkedUri());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               res.close();
  @@ -796,16 +815,18 @@
           try {
               
               // Removing object
  -            statement = connection.prepareStatement(
  -                 "delete from objects where uri= ?");
  -         statement.setString(1,object.getUri());
  +            statement = connection.prepareStatement
  +                ("delete from objects where uri= ?");
  +            statement.setString(1,object.getUri());
               statement.execute();
  +            closeStatement(statement);
               
               // Removing children
  -            statement = connection.prepareStatement(
  -                 "delete from children where uri=?");
  -         statement.setString(1, object.getUri());
  +            statement = connection.prepareStatement
  +                ("delete from children where uri=?");
  +            statement.setString(1, object.getUri());
               statement.execute();
  +            closeStatement(statement);
               
               // Removing inbound links
               /*
  @@ -814,10 +835,11 @@
               */
               
               // Removing links
  -            statement = connection.prepareStatement(
  -                 "delete from links where link= ?");
  -         statement.setString(1, object.getUri());
  +            statement = connection.prepareStatement
  +                ("delete from links where link= ?");
  +            statement.setString(1, object.getUri());
               statement.execute();
  +            closeStatement(statement);
               
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -846,14 +868,19 @@
               if (permission.isNegative()) {
                   negative = 1;
               }
  +            
  +            NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
  +            String revisionNumberStr = 
  +                (revisionNumber == null) ? "null" : revisionNumber.toString();
               
  -            statement = connection.prepareStatement(
  -                 "insert into permissions values(?,?,?,?,?)");
  -         statement.setString(1, permission.getObjectUri());
  -         statement.setString(2, permission.getSubjectUri());
  -         statement.setString(3, permission.getActionUri());
  -         statement.setInt(4, inheritable);
  -         statement.setInt(5, negative);
  +            statement = connection.prepareStatement
  +                ("insert into permissions values(?,?,?,?,?,?)");
  +            statement.setString(1, permission.getObjectUri());
  +            statement.setString(2, revisionNumberStr);
  +            statement.setString(3, permission.getSubjectUri());
  +            statement.setString(4, permission.getActionUri());
  +            statement.setInt(5, inheritable);
  +            statement.setInt(6, negative);
               statement.execute();
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -876,11 +903,16 @@
           PreparedStatement statement = null;
           
           try {
  +            NodeRevisionNumber revisionNumber = permission.getRevisionNumber();
  +            String revisionNumberStr = 
  +                (revisionNumber == null) ? "null" : revisionNumber.toString();
  +
               statement = connection.prepareStatement
  -                ("delete from permissions where object= ? and subject = ? and 
action = ?");
  -         statement.setString(1,permission.getObjectUri());
  -         statement.setString(2, permission.getSubjectUri());
  -         statement.setString(3, permission.getActionUri());
  +                ("delete from permissions where object= ? and revisionnumber = ? 
and subject = ? and action = ?");
  +            statement.setString(1, permission.getObjectUri());
  +            statement.setString(2, revisionNumberStr);
  +            statement.setString(3, permission.getSubjectUri());
  +            statement.setString(4, permission.getActionUri());
               statement.execute();
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -904,9 +936,9 @@
           
           try {
               
  -            statement = connection.prepareStatement(
  -                 "delete from permissions where object= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("delete from permissions where object= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -930,9 +962,9 @@
           PreparedStatement statement = null;
           
           try {
  -            statement = connection.prepareStatement(
  -                 "select * from permissions where object= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("select * from permissions where object= ?");
  +            statement.setString(1, uri.toString());
               ResultSet res = statement.executeQuery();
               
               while (res.next()) {
  @@ -946,6 +978,8 @@
                   }
                   NodePermission permission = 
                       new NodePermission(res.getString(PERMISSIONS_OBJECT),
  +                                       res.getString
  +                                       (PERMISSIONS_REVISION_NUMBER),
                                          res.getString(PERMISSIONS_SUBJECT),
                                          res.getString(PERMISSIONS_ACTION), 
                                          inheritable, negative);
  @@ -985,16 +1019,16 @@
                   exclusive = 1;
               }
               
  -            statement = connection.prepareStatement(
  -                 "insert into locks values(?,?,?,?,?,?,?)");
  -         statement.setString(1, lock.getLockId());
  -         statement.setString(2, lock.getObjectUri());
  -         statement.setString(3, lock.getSubjectUri());
  -         statement.setString(4, lock.getTypeUri());
  -         statement.setString(5, 
  -                 String.valueOf(lock.getExpirationDate().getTime()));
  -         statement.setInt(6,inheritable);
  -         statement.setInt(7, exclusive);
  +            statement = connection.prepareStatement
  +                ("insert into locks values(?,?,?,?,?,?,?)");
  +            statement.setString(1, lock.getLockId());
  +            statement.setString(2, lock.getObjectUri());
  +            statement.setString(3, lock.getSubjectUri());
  +            statement.setString(4, lock.getTypeUri());
  +            statement.setString
  +                (5, String.valueOf(lock.getExpirationDate().getTime()));
  +            statement.setInt(6,inheritable);
  +            statement.setInt(7, exclusive);
               statement.execute();
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -1029,21 +1063,22 @@
                   exclusive = 1;
               }
               
  -            statement = connection.prepareStatement(
  -                 "delete from locks where id=?");
  -         statement.setString(1, lock.getLockId());
  +            statement = connection.prepareStatement
  +                ("delete from locks where id=?");
  +            statement.setString(1, lock.getLockId());
               statement.execute();
  +            closeStatement(statement);
               
  -            statement = connection.prepareStatement(
  -                "insert into locks values(?,?,?,?,?,?,?)");
  -         statement.setString(1, lock.getLockId());
  -         statement.setString(2, lock.getObjectUri());
  -         statement.setString(3, lock.getSubjectUri());
  -         statement.setString(4, lock.getTypeUri());
  -         statement.setString(5, 
  -                 String.valueOf(lock.getExpirationDate().getTime()));
  -         statement.setInt(6, inheritable);
  -         statement.setInt(7, exclusive);
  +            statement = connection.prepareStatement
  +                ("insert into locks values(?,?,?,?,?,?,?)");
  +            statement.setString(1, lock.getLockId());
  +            statement.setString(2, lock.getObjectUri());
  +            statement.setString(3, lock.getSubjectUri());
  +            statement.setString(4, lock.getTypeUri());
  +            statement.setString
  +                (5, String.valueOf(lock.getExpirationDate().getTime()));
  +            statement.setInt(6, inheritable);
  +            statement.setInt(7, exclusive);
               statement.execute();
               
           } catch (SQLException e) {
  @@ -1120,9 +1155,9 @@
           
           try {
               
  -            statement = connection.prepareStatement(
  -                 "select * from locks where object= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("select * from locks where object= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
               ResultSet res = statement.getResultSet();
               
  @@ -1181,8 +1216,8 @@
               Hashtable branches = new Hashtable();
               boolean isVersioned = false;
               
  -            statement = connection.prepareStatement(
  -                 "select * from revisions where uri= ?");
  +            statement = connection.prepareStatement
  +                ("select * from revisions where uri= ?");
            statement.setString(1, uri.toString());
               res = statement.executeQuery();
               
  @@ -1195,18 +1230,22 @@
                   throw new RevisionDescriptorNotFoundException(uri.toString());
               }
               
  -            statement = connection.prepareStatement(
  -                 "select * from workingrevision where uri= ?");
  -         statement.setString(1, uri.toString());
  +            closeStatement(statement);
  +            
  +            statement = connection.prepareStatement
  +                ("select * from workingrevision where uri= ?");
  +            statement.setString(1, uri.toString());
               res = statement.executeQuery();
               
               while(res.next()) {
                   // TODO : Parse each working revision definition
               }
               
  -            statement = connection.prepareStatement(
  -                 "select * from latestrevisions where uri=?");
  -         statement.setString(1, uri.toString());
  +            closeStatement(statement);
  +            
  +            statement = connection.prepareStatement
  +                ("select * from latestrevisions where uri=?");
  +            statement.setString(1, uri.toString());
               res = statement.executeQuery();
               
               while(res.next()) {
  @@ -1216,19 +1255,19 @@
                                (res.getString(LATESTREVISIONS_NUMBER)));
               }
               
  -            statement = connection.prepareStatement(
  -                 "select * from revision where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("select * from revision where uri= ?");
  +            statement.setString(1, uri.toString());
               res = statement.executeQuery();
               
               while(res.next()) {
                   String currentRevisionNumber = res.getString(REVISION_NUMBER);
                   
                   // We parse the revision list of the object
  -                statement2 = connection.prepareStatement(
  -                     "select * from branches where uri = ? and xnumber = ?");
  -             statement2.setString(1, uri.toString());
  -             statement2.setString(2, currentRevisionNumber);
  +                statement2 = connection.prepareStatement
  +                    ("select * from branches where uri = ? and xnumber = ?");
  +                statement2.setString(1, uri.toString());
  +                statement2.setString(2, currentRevisionNumber);
                   ResultSet res2 = statement2.executeQuery();
                   Vector childList = new Vector();
                   
  @@ -1241,6 +1280,7 @@
                                childList);
                   
                   res2.close();
  +                closeStatement(statement2);
               }
               
               revisionDescriptors = new NodeRevisionDescriptors
  @@ -1285,13 +1325,14 @@
                   isVersioned = 1;
               }
               
  -            statement = connection.prepareStatement(
  -                 "insert into revisions values(?,?,?)");
  -         statement.setString(1,uri.toString());
  -         statement.setInt(2, isVersioned);
  -         statement.setString(3, 
  -                 revisionDescriptors.getInitialRevision().toString());
  +            statement = connection.prepareStatement
  +                ("insert into revisions values(?,?,?)");
  +            statement.setString(1,uri.toString());
  +            statement.setInt(2, isVersioned);
  +            statement.setString
  +                (3, revisionDescriptors.getInitialRevision().toString());
               statement.execute();
  +            closeStatement(statement);
               
               // Creating records in working revisions table
               // ... TODO (working revisions are not used for now)
  @@ -1300,14 +1341,15 @@
               
               // For now, only the latest revision from the main branch is stored
               if (revisionDescriptors.getLatestRevision() != null) {
  -                statement = connection.prepareStatement(
  -                     "insert into latestrevisions values(?,?,?)");
  +                statement = connection.prepareStatement
  +                    ("insert into latestrevisions values(?,?,?)");
                statement.setString(1, uri.toString());
  -             statement.setString(2, 
  -                     NodeRevisionDescriptors.MAIN_BRANCH.toString());
  -             statement.setString(3, 
  -                     revisionDescriptors.getLatestRevision().toString());
  +             statement.setString
  +                    (2, NodeRevisionDescriptors.MAIN_BRANCH.toString());
  +             statement.setString
  +                    (3, revisionDescriptors.getLatestRevision().toString());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               // Creating records in the branches table
  @@ -1354,25 +1396,29 @@
           
           try {
               
  -            statement = connection.prepareStatement(
  -                 "delete from revisions where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("delete from revisions where uri= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
  +            closeStatement(statement);
               
  -            statement = connection.prepareStatement(
  -                 "delete from workingrevision where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("delete from workingrevision where uri= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
  +            closeStatement(statement);
               
  -            statement = connection.prepareStatement(
  -                 "delete from latestrevisions where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("delete from latestrevisions where uri= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
  +            closeStatement(statement);
               
  -            statement = connection.prepareStatement(
  -                 "delete from branches where uri= ?");
  -         statement.setString(1, uri.toString());
  +            statement = connection.prepareStatement
  +                ("delete from branches where uri= ?");
  +            statement.setString(1, uri.toString());
               statement.execute();
  +            closeStatement(statement);
               
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -1410,10 +1456,10 @@
               // Retrieving branch name (and also check that revision 
               // does indeed exist)
               
  -            statement = connection.prepareStatement(
  -                 "select * from revision where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, revisionNumber.toString());
  +            statement = connection.prepareStatement
  +                ("select * from revision where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, revisionNumber.toString());
               res = statement.executeQuery();
               
               if (res.next()) {
  @@ -1422,24 +1468,28 @@
                   throw new RevisionDescriptorNotFoundException(uri.toString());
               }
               
  +            closeStatement(statement);
  +            
               // Retrieve labels
               
  -            statement = connection.prepareStatement(
  -                 "select * from label where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, revisionNumber.toString());
  +            statement = connection.prepareStatement
  +                ("select * from label where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, revisionNumber.toString());
               res = statement.executeQuery();
               
               while (res.next()) {
                   labels.addElement(res.getString(LABEL_LABEL));
               }
               
  +            closeStatement(statement);
  +            
               // Retrieve properties
               
  -            statement = connection.prepareStatement(
  -                 "select * from property where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, revisionNumber.toString());
  +            statement = connection.prepareStatement
  +                ("select * from property where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, revisionNumber.toString());
               res = statement.executeQuery();
               
               while (res.next()) {
  @@ -1459,6 +1509,7 @@
                                              labels, properties);
               
               res.close();
  +            closeStatement(statement);
               
           } catch (SQLException e) {
               throw new ServiceAccessException(this, e);
  @@ -1487,25 +1538,27 @@
               
               ResultSet res = null;
               
  -            statement = connection.prepareStatement(
  -                 "insert into revision values(?, ?, ?)");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, 
  -                 revisionDescriptor.getRevisionNumber().toString());
  -         statement.setString(3, revisionDescriptor.getBranchName());
  +            statement = connection.prepareStatement
  +                ("insert into revision values(?, ?, ?)");
  +            statement.setString(1, uri.toString());
  +            statement.setString
  +                (2, revisionDescriptor.getRevisionNumber().toString());
  +            statement.setString(3, revisionDescriptor.getBranchName());
               statement.execute();
  +            closeStatement(statement);
               
               // Creating revision labels
               
               Enumeration labels = revisionDescriptor.enumerateLabels();
               while (labels.hasMoreElements()) {
  -                statement = connection.prepareStatement(
  -                    "insert into label values(?,?,?)");
  -             statement.setString(1, uri.toString());
  -             statement.setString(2, 
  -                     revisionDescriptor.getRevisionNumber().toString());
  -             statement.setString(3, (String)labels.nextElement());
  +                statement = connection.prepareStatement
  +                    ("insert into label values(?,?,?)");
  +                statement.setString(1, uri.toString());
  +                statement.setString
  +                    (2, revisionDescriptor.getRevisionNumber().toString());
  +                statement.setString(3, (String)labels.nextElement());
                   statement.execute();
  +                closeStatement(statement);
               }
               
               // Creating associated properties
  @@ -1518,17 +1571,18 @@
                   if (property.isProtected()) {
                       protectedProperty = 1;
                   }
  -                statement = connection.prepareStatement(
  -                     "insert into property values(?,?,?,?,?,?,?)");
  -             statement.setString(1, uri.toString());
  -             statement.setString(2, 
  -                     revisionDescriptor.getRevisionNumber().toString());
  -             statement.setString(3, property.getName());
  -             statement.setString(4, property.getValue().toString());
  -             statement.setString(5, property.getNamespace());
  -             statement.setString(6, property.getType());
  -             statement.setInt(7, protectedProperty);
  +                statement = connection.prepareStatement
  +                    ("insert into property values(?,?,?,?,?,?,?)");
  +                statement.setString(1, uri.toString());
  +                statement.setString
  +                    (2, revisionDescriptor.getRevisionNumber().toString());
  +                statement.setString(3, property.getName());
  +                statement.setString(4, property.getValue().toString());
  +                statement.setString(5, property.getNamespace());
  +                statement.setString(6, property.getType());
  +                statement.setInt(7, protectedProperty);
                   statement.execute();
  +                closeStatement(statement);
               }
               
           } catch (SQLException e) {
  @@ -1573,26 +1627,28 @@
           
           try {
               
  -            statement = connection.prepareStatement(
  -                 "delete from revision where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, number.toString());
  +            statement = connection.prepareStatement
  +                ("delete from revision where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, number.toString());
               statement.execute();
  +            closeStatement(statement);
               
               // Removing revision labels
               
  -            statement = connection.prepareStatement(
  -                 "delete from label where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, number.toString());
  +            statement = connection.prepareStatement
  +                ("delete from label where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, number.toString());
               statement.execute();
  +            closeStatement(statement);
               
               // Removing associated properties
               
  -            statement = connection.prepareStatement(
  -                 "delete from property where uri= ? and xnumber = ?");
  -         statement.setString(1, uri.toString());
  -         statement.setString(2, number.toString());
  +            statement = connection.prepareStatement
  +                ("delete from property where uri= ? and xnumber = ?");
  +            statement.setString(1, uri.toString());
  +            statement.setString(2, number.toString());
               statement.execute();
               
           } catch (SQLException e) {
  
  
  

Reply via email to