Oliver,

For some reason I keep getting "Create attachment Bug 30317:  No file was
provided, or it was empty." error, when uploading the patch on bugzilla. I
am attaching the patch here. Could you please upload it?

Also I have created the patch on latest from CVS head but tested the fix on
2.1M1 with Oracle Store. Please review it and let me know if you face any
problem with it.

Regards,
Ritu



-----Original Message-----
From: Oliver Zeigermann [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 28, 2004 2:38 PM
To: Slide Developers Mailing List
Subject: Re: Patch for Bug# 30317


Where is that patch? Simply attach it to the bug report.

Oliver

Ritu Kedia wrote:

> I have a fix for Bug# 30317 for RDBMS Content Stores. 
> Could someone review the patch for the same? If yes, please let me know..
I
> will send the patch file.
> 
> Regards,
> Ritu
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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

Index: DB2RDBMSAdapter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/DB2RDBMSAdapter.java,v
retrieving revision 1.1
diff -u -r1.1 DB2RDBMSAdapter.java
--- DB2RDBMSAdapter.java        15 Jul 2004 06:38:24 -0000      1.1
+++ DB2RDBMSAdapter.java        28 Jul 2004 10:13:20 -0000
@@ -606,6 +606,7 @@
                                  throw ex;
                          }
                  }
+                 revisionDescriptor.setContentLength(contentLength);
                  // Changed (contentlength - 1) to (contentlength) as DB2 was 
complaining about
                  // length mismatch for stream in the below method
                  // insertStatement.setBinaryStream(2, is, (int)contentLength -1);
Index: OracleRDBMSAdapter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/OracleRDBMSAdapter.java,v
retrieving revision 1.6
diff -u -r1.6 OracleRDBMSAdapter.java
--- OracleRDBMSAdapter.java     15 Jul 2004 06:38:24 -0000      1.6
+++ OracleRDBMSAdapter.java     28 Jul 2004 10:13:20 -0000
@@ -117,12 +117,11 @@
         Connection connection,
         Uri uri,
         NodeRevisionDescriptor revisionDescriptor,
-        NodeRevisionContent revisionContent)
+        InputStream in)
         throws IOException, SQLException
     {
         getLogger().log("storeContent: " + uri, Logger.DEBUG);
 
-        assureVersionInfo(connection, uri, revisionDescriptor);
         long versionContentId = getVersionContentId(connection, uri, 
revisionDescriptor);
         insertEmptyContent(connection, versionContentId);
 
@@ -134,15 +133,7 @@
             try {
                 res.next();
                 Blob blob = res.getBlob(1);
-                InputStream in = revisionContent.streamContent();
                 OutputStream out = ((oracle.sql.BLOB) blob).getBinaryOutputStream();
-
-                if (bcompress) {
-                    getLogger().log("Compressing the data", LOG_CHANNEL, 6);
-                    StoreContentZip ziputil = new StoreContentZip();
-                    ziputil.Zip(in);
-                    in = ziputil.getInputStream();
-                }
 
                 try {
                     copy(in, out, ((oracle.sql.BLOB) blob).getBufferSize());
Index: StandardRDBMSAdapter.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-slide/src/stores/org/apache/slide/store/impl/rdbms/StandardRDBMSAdapter.java,v
retrieving revision 1.28
diff -u -r1.28 StandardRDBMSAdapter.java
--- StandardRDBMSAdapter.java   25 Jul 2004 09:48:56 -0000      1.28
+++ StandardRDBMSAdapter.java   28 Jul 2004 10:13:21 -0000
@@ -1185,62 +1185,80 @@
             }
             byte buffer[] = new byte[2048];
             File tempFile = null;
-            if (contentLength == -1) {
-                try {
-                    tempFile = File.createTempFile("content", null);
-                    FileOutputStream fos = new FileOutputStream(tempFile);
-                    do {
-                        int nChar = is.read(buffer);
-                        if (nChar == -1)
-                            break;
-                        fos.write(buffer, 0, nChar);
-                    } while (true);
-                    fos.close();
-                    is.close();
-                    is = new FileInputStream(tempFile);
-                    contentLength = tempFile.length();
-                } catch (IOException ex) {
-                    getLogger().log(
-                        ex.toString() + " during the calculation of the content 
length.",
-                        LOG_CHANNEL,
-                        Logger.ERROR);
-                    getLogger().log("tempFile: " + tempFile.getAbsolutePath(), 
LOG_CHANNEL, Logger.ERROR);
-                    throw ex;
-                }
+            try 
+            {
+                               if (contentLength == -1) {
+                                       try {
+                                               tempFile = 
File.createTempFile("content", null);
+                                               FileOutputStream fos = new 
FileOutputStream(tempFile);
+                                               do {
+                                                       int nChar = is.read(buffer);
+                                                       if (nChar == -1)
+                                                               break;
+                                                       fos.write(buffer, 0, nChar);
+                                               } while (true);
+                                               fos.close();
+                                               is.close();
+                                               is = new FileInputStream(tempFile);
+                                               contentLength = tempFile.length();
+                                       } catch (IOException ex) {
+                                               getLogger().log(
+                                                       ex.toString() + " during the 
calculation of the content length.",
+                                                       LOG_CHANNEL,
+                                                       Logger.ERROR);
+                                               getLogger().log("tempFile: " + 
tempFile.getAbsolutePath(), LOG_CHANNEL, Logger.ERROR);
+                                               throw ex;
+                                       }
+                               }
+                               revisionDescriptor.setContentLength(contentLength);
+                               storeContent(connection, uri, revisionDescriptor, is);
+                               if (tempFile != null) {
+                                       is.close();
+                                       is = null;
+                                       tempFile.delete();
+                               }
             }
-            // Changed (contentlength - 1) to (contentlength) as DB2 was complaining 
about
-            // length mismatch for stream in the below method
-            // insertStatement.setBinaryStream(2, is, (int)contentLength -1);
-            try {
-                statement =
-                    connection.prepareStatement(
-                        "insert into VERSION_CONTENT (VERSION_ID, CONTENT) 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"
-                            + 
getRevisionNumberAsWhereQueryFragement(revisionDescriptor.getRevisionNumber()));
-                statement.setBinaryStream(1, is, (int) contentLength);
-                statement.setString(2, uri.toString());
-                statement.executeUpdate();
-                if (tempFile != null) {
-                    is.close();
-                    is = null;
-                    tempFile.delete();
-                }
-            } finally {
-                try {
-                    close(statement);
-                } finally {
-                    if (is != null) {
-                        // XXX some JDBC drivers seem to close the stream upon 
closing of 
-                        // the statement; if so this will raise an IOException 
-                        // silently ignore it...
-                        try {
-                            is.close();
-                        } catch (IOException ioe) {
-                            logger.log("Could not close stream", ioe, LOG_CHANNEL, 
Logger.DEBUG);
-                        }
-                    }
-                }
+            finally 
+            {
+                               if (tempFile != null && tempFile.exists()) {
+                                       is.close();
+                                       is = null;
+                                       tempFile.delete();
+                               }
             }
         }
+    }
+    
+       protected void storeContent(Connection connection, Uri uri, 
NodeRevisionDescriptor revisionDescriptor, InputStream is) throws SQLException, 
IOException 
+    {
+               PreparedStatement statement = null;
+               // Changed (contentlength - 1) to (contentlength) as DB2 was 
complaining about
+               // length mismatch for stream in the below method
+               // insertStatement.setBinaryStream(2, is, (int)contentLength -1);
+               try {
+                       statement =
+                               connection.prepareStatement(
+                                       "insert into VERSION_CONTENT (VERSION_ID, 
CONTENT) 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"
+                                               + 
getRevisionNumberAsWhereQueryFragement(revisionDescriptor.getRevisionNumber()));
+                       statement.setBinaryStream(1, is, (int) contentLength);
+                       statement.setString(2, uri.toString());
+                       statement.executeUpdate();
+               } finally {
+                       try {
+                               close(statement);
+                       } finally {
+                               if (is != null) {
+                                       // XXX some JDBC drivers seem to close the 
stream upon closing of 
+                                       // the statement; if so this will raise an 
IOException 
+                                       // silently ignore it...
+                                       try {
+                                               is.close();
+                                       } catch (IOException ioe) {
+                                               logger.log("Could not close stream", 
ioe, LOG_CHANNEL, Logger.DEBUG);
+                                       }
+                               }
+                       }
+               }
     }
 
     public void storeRevisionDescriptor(Connection connection, Uri uri, 
NodeRevisionDescriptor revisionDescriptor)

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

Reply via email to