unico       2005/05/19 06:01:00

  Modified:    src/stores/org/apache/slide/store/impl/rdbms Tag:
                        SLIDE_2_1_RELEASE_BRANCH DB2RDBMSAdapter.java
                        CommonRDBMSAdapter.java StandardRDBMSAdapter.java
  Log:
  Repair removePermission delete statement. 
Apply patch by Johan Stuyts at Hippo for bug #34954
(fix failure of grantPermission)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.3.2.7   +5 -4      
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/DB2RDBMSAdapter.java
  
  Index: DB2RDBMSAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/DB2RDBMSAdapter.java,v
  retrieving revision 1.3.2.6
  retrieving revision 1.3.2.7
  diff -u -r1.3.2.6 -r1.3.2.7
  --- DB2RDBMSAdapter.java      18 May 2005 15:59:50 -0000      1.3.2.6
  +++ DB2RDBMSAdapter.java      19 May 2005 13:01:00 -0000      1.3.2.7
  @@ -257,6 +257,7 @@
                       + "," + permission.getActionUri()
                       + ")";
                       getLogger().log(msg,LOG_CHANNEL,Logger.ERROR);
  +                    throw new ServiceAccessException(service, msg);
                   }
               } finally {
                   close(statement);
  
  
  
  1.4.2.6   +16 -15    
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
  
  Index: CommonRDBMSAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java,v
  retrieving revision 1.4.2.5
  retrieving revision 1.4.2.6
  diff -u -r1.4.2.5 -r1.4.2.6
  --- CommonRDBMSAdapter.java   18 May 2005 17:36:08 -0000      1.4.2.5
  +++ CommonRDBMSAdapter.java   19 May 2005 13:01:00 -0000      1.4.2.6
  @@ -5,7 +5,7 @@
    *
    * ====================================================================
    *
  - * Copyright 2004 The Apache Software Foundation 
  + * Copyright 2004-2005 The Apache Software Foundation 
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -32,7 +32,6 @@
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
  -import java.sql.Types;
   
   import org.apache.slide.common.Service;
   import org.apache.slide.common.ServiceAccessException;
  @@ -228,21 +227,23 @@
       public void revokePermission(Connection connection, Uri uri, 
NodePermission permission)
           throws ServiceAccessException {
           if (permission == null) return;
  +        StringBuffer sql = new StringBuffer("delete from PERMISSIONS where 
(OBJECT_ID, SUBJECT_ID, ACTION_ID) IN" +
  +            " (SELECT ou.URI_ID, su.URI_ID, au.URI_ID FROM URI ou, URI su, 
URI au WHERE ou.URI_STRING = ? and su.URI_STRING = ? and au.URI_STRING = ?)");
           PreparedStatement statement = null;
           try {
  -            NodeRevisionNumber revisionNumber = 
permission.getRevisionNumber();
  -            statement =
  -                connection.prepareStatement(
  -                  "delete from PERMISSIONS where (OBJECT_ID, SUBJECT_ID, 
ACTION_ID) IN" +
  -                  " (SELECT ou.URI_ID, su.URI_ID, au.URI_ID FROM URI ou, URI 
su, URI au " +
  -                  " WHERE ou.URI_STRING = ? and su.URI_STRING = ? and 
au.URI_STRING = ?)" +
  -                  " and VERSION_NO = ?");
  +            final NodeRevisionNumber revisionNumber;
  +            revisionNumber = permission.getRevisionNumber();
  +            // generate proper sql based on content of revision number
  +            if (revisionNumber != null) {
  +             sql.append(" and VERSION_NO = ?");
  +            } else {
  +             sql.append(" and VERSION_NO IS NULL");
  +            }
  +            statement = connection.prepareStatement(sql.toString());
               statement.setString(1, uri.toString());
               statement.setString(2, permission.getSubjectUri());
               statement.setString(3, permission.getActionUri());
  -            if (revisionNumber == null) {
  -                statement.setNull(4, Types.VARCHAR);
  -            } else {
  +            if (revisionNumber != null) {
                   statement.setString(4, revisionNumber.toString());
               }
               statement.executeUpdate();
  
  
  
  1.32.2.7  +18 -16    
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java
  
  Index: StandardRDBMSAdapter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java,v
  retrieving revision 1.32.2.6
  retrieving revision 1.32.2.7
  diff -u -r1.32.2.6 -r1.32.2.7
  --- StandardRDBMSAdapter.java 18 May 2005 17:36:08 -0000      1.32.2.6
  +++ StandardRDBMSAdapter.java 19 May 2005 13:01:00 -0000      1.32.2.7
  @@ -5,7 +5,7 @@
    *
    * ====================================================================
    *
  - * Copyright 1999-2003 The Apache Software Foundation 
  + * Copyright 1999-2005 The Apache Software Foundation 
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -33,7 +33,6 @@
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
  -import java.sql.Types;
   import java.util.Date;
   import java.util.Enumeration;
   import java.util.Hashtable;
  @@ -578,6 +577,7 @@
                       + "," + permission.getActionUri() 
                       + ")"; 
                       getLogger().log(msg,LOG_CHANNEL,Logger.ERROR);
  +                    throw new ServiceAccessException(service, msg);
                   }
               } finally {
                   close(statement);
  @@ -590,21 +590,23 @@
       public void revokePermission(Connection connection, Uri uri, 
NodePermission permission)
           throws ServiceAccessException {
           if (permission == null) return;
  +        StringBuffer sql = new StringBuffer("delete from PERMISSIONS where 
(OBJECT_ID, SUBJECT_ID, ACTION_ID) IN" +
  +            " (SELECT ou.URI_ID, su.URI_ID, au.URI_ID FROM URI ou, URI su, 
URI au WHERE ou.URI_STRING = ? and su.URI_STRING = ? and au.URI_STRING = ?)");
           PreparedStatement statement = null;
           try {
  -            NodeRevisionNumber revisionNumber = 
permission.getRevisionNumber();
  -            statement =
  -                connection.prepareStatement(
  -                        "delete from PERMISSIONS where (OBJECT_ID, 
SUBJECT_ID, ACTION_ID) IN" +
  -                        " (SELECT ou.URI_ID, su.URI_ID, au.URI_ID FROM URI 
ou, URI su, URI au " +
  -                        " WHERE ou.URI_STRING = ? and su.URI_STRING = ? and 
au.URI_STRING = ?)" +
  -                        " and VERSION_NO = ?");
  +            final NodeRevisionNumber revisionNumber;
  +            revisionNumber = permission.getRevisionNumber();
  +            // generate proper sql based on content of revision number
  +            if (revisionNumber != null) {
  +                sql.append(" and VERSION_NO = ?");
  +            } else {
  +                sql.append(" and VERSION_NO IS NULL");
  +            }
  +            statement = connection.prepareStatement(sql.toString());
               statement.setString(1, uri.toString());
               statement.setString(2, permission.getSubjectUri());
               statement.setString(3, permission.getActionUri());
  -            if (revisionNumber == null) {
  -                statement.setNull(4, Types.VARCHAR);
  -            } else {
  +            if (revisionNumber != null) {
                   statement.setString(4, revisionNumber.toString());
               }
               statement.executeUpdate();
  
  
  

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

Reply via email to