unico 2005/05/19 06:01:32
Modified: src/stores/org/apache/slide/store/impl/rdbms
CommonRDBMSAdapter.java PostgresRDBMSAdapter.java
DB2RDBMSAdapter.java StandardRDBMSAdapter.java
Log:
Repair removePermission delete statement.
Apply patch by Johan Stuyts at Hippo for bug #34954
(silent failure of grantPermission)
Revision Changes Path
1.13 +16 -14
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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- CommonRDBMSAdapter.java 18 May 2005 17:34:30 -0000 1.12
+++ CommonRDBMSAdapter.java 19 May 2005 13:01:32 -0000 1.13
@@ -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,20 +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 {
- final 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.18 +5 -5
jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/PostgresRDBMSAdapter.java
Index: PostgresRDBMSAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/PostgresRDBMSAdapter.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- PostgresRDBMSAdapter.java 18 May 2005 17:34:30 -0000 1.17
+++ PostgresRDBMSAdapter.java 19 May 2005 13:01:32 -0000 1.18
@@ -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.
1.12 +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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DB2RDBMSAdapter.java 18 May 2005 15:58:18 -0000 1.11
+++ DB2RDBMSAdapter.java 19 May 2005 13:01:32 -0000 1.12
@@ -259,6 +259,7 @@
+ "," + permission.getActionUri()
+ ")";
getLogger().log(msg,LOG_CHANNEL,Logger.ERROR);
+ throw new ServiceAccessException(service, msg);
}
} finally {
close(statement);
1.45 +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.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- StandardRDBMSAdapter.java 18 May 2005 17:34:30 -0000 1.44
+++ StandardRDBMSAdapter.java 19 May 2005 13:01:32 -0000 1.45
@@ -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;
@@ -586,6 +585,7 @@
+ "," + permission.getActionUri()
+ ")";
getLogger().log(msg,LOG_CHANNEL,Logger.ERROR);
+ throw new ServiceAccessException(service, msg);
}
} finally {
close(statement);
@@ -598,21 +598,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]