Martin Kal�n wrote:
Attaching an updated version of the patch against CVS rev 1.11
Hmm... not so. :(
The attached v3 of the patch is indeed against CVS rev 1.11,
including the uri.toString() that unesco committed.
Beg your pardon for the repeated confusion.
Regards,
Martin
Index: src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
===================================================================
RCS file:
/home/cvspublic/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java,v
retrieving revision 1.11
diff -u -r1.11 CommonRDBMSAdapter.java
--- src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
18 May 2005 15:58:18 -0000 1.11
+++ src/stores/org/apache/slide/store/impl/rdbms/CommonRDBMSAdapter.java
18 May 2005 17:11:27 -0000
@@ -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.
@@ -23,7 +23,11 @@
package org.apache.slide.store.impl.rdbms;
-import java.io.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -223,21 +227,25 @@
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();
- final String versionNoCriteria;
-
- if (revisionNumber == null) {
- versionNoCriteria = "IS NULL";
+ final NodeRevisionNumber revisionNumber;
+ revisionNumber = permission.getRevisionNumber();
+ // generate proper sql based on content of revision number
+ if (revisionNumber != null) {
+ sql.append(" and VERSION_NO = ?");
} else {
- versionNoCriteria = "= '" + revisionNumber.toString() + "'";
+ sql.append(" and VERSION_NO IS NULL");
}
- statement = connection.prepareStatement(
- "delete from PERMISSIONS where PERMISSIONS.OBJECT_ID in
(select ou.URI_ID from URI ou, URI su, URI au where ou.URI_STRING = ? and
SUBJECT_ID = su.URI_ID and su.URI_STRING = ? and ACTION_ID = au.URI_ID and
au.URI_STRING = ? and VERSION_NO " + versionNoCriteria + ")");
+ statement = connection.prepareStatement(sql.toString());
statement.setString(1, uri.toString());
statement.setString(2, permission.getSubjectUri());
statement.setString(3, permission.getActionUri());
+ if (revisionNumber != null) {
+ statement.setString(4, revisionNumber.toString());
+ }
statement.executeUpdate();
} catch (SQLException e) {
throw createException(e, uri.toString());
@@ -290,26 +298,26 @@
protected void storeContent(
Connection connection, Uri uri,
NodeRevisionDescriptor revisionDescriptor,
- NodeRevisionContent revisionContent) throws IOException, SQLException
+ NodeRevisionContent revisionContent) throws IOException, SQLException
{
assureVersionInfo(connection, uri, revisionDescriptor);
-
+
InputStream is = revisionContent.streamContent();
if (is != null) {
long blobLength = 0;
File tempFile = null;
-
+
if (bcompress) {
getLogger().log("Compressing the data", LOG_CHANNEL,
Logger.DEBUG);
StoreContentZip ziputil = new StoreContentZip();
ziputil.Zip(is);
is = ziputil.getInputStream();
-
+
// fix RevisionDescriptor Content Length
if (revisionDescriptor.getContentLength() == -1) {
revisionDescriptor.setContentLength(ziputil.getInitialContentLength());
}
-
+
blobLength = ziputil.getContentLength();
} else {
// fix RevisionDescriptor Content Length
@@ -331,19 +339,19 @@
}
is.close();
is = new FileInputStream(tempFile);
-
+
revisionDescriptor.setContentLength(tempFile.length());
-
+
} catch (IOException ex) {
getLogger().log(ex.toString() + " during the
calculation of the content length.",
LOG_CHANNEL, Logger.ERROR);
throw ex;
}
}
-
+
blobLength = revisionDescriptor.getContentLength();
}
-
+
PreparedStatement statement = null;
try {
long versionID = getVersionID(connection, uri.toString(),
revisionDescriptor);
@@ -377,14 +385,14 @@
}
protected long getVersionID(
- Connection connection,
- String uriString,
- NodeRevisionDescriptor revisionDescriptor) throws SQLException
+ Connection connection,
+ String uriString,
+ NodeRevisionDescriptor revisionDescriptor) throws SQLException
{
PreparedStatement statement = null;
ResultSet rs = null;
long versionID = 0l;
- try {
+ try {
statement = connection.prepareStatement(
"select vh.VERSION_ID from VERSION_HISTORY vh, URI u where
vh.URI_ID = u.URI_ID and u.URI_STRING = ? and vh.REVISION_NO = ?");
statement.setString(1,uriString);
@@ -396,7 +404,7 @@
} finally {
close(statement,rs);
}
-
+
return versionID;
}
@@ -405,5 +413,3 @@
}
}
-
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]