Update of /var/cvs/src/org/mmbase/storage/implementation/database In directory james.mmbase.org:/tmp/cvs-serv4009
Modified Files: Tag: MMBase-1_8 DatabaseStorageManager.java Log Message: made it compile against java 1.6 as far as possible See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/storage/implementation/database Index: DatabaseStorageManager.java =================================================================== RCS file: /var/cvs/src/org/mmbase/storage/implementation/database/DatabaseStorageManager.java,v retrieving revision 1.169.2.8 retrieving revision 1.169.2.9 diff -u -b -r1.169.2.8 -r1.169.2.9 --- DatabaseStorageManager.java 12 Dec 2007 17:09:05 -0000 1.169.2.8 +++ DatabaseStorageManager.java 7 Mar 2008 14:41:26 -0000 1.169.2.9 @@ -32,7 +32,7 @@ * * @author Pierre van Rooden * @since MMBase-1.7 - * @version $Id: DatabaseStorageManager.java,v 1.169.2.8 2007/12/12 17:09:05 michiel Exp $ + * @version $Id: DatabaseStorageManager.java,v 1.169.2.9 2008/03/07 14:41:26 michiel Exp $ */ public class DatabaseStorageManager implements StorageManager { @@ -765,16 +765,28 @@ return; } } - //log.warn("Storing " + field + " for " + node.getNumber()); + long size = 0; InputStream in = node.getInputStreamValue(fieldName); + + log.service("Storing " + field + " for " + node.getNumber() + " in " + binaryFile); OutputStream out = new BufferedOutputStream(new FileOutputStream(binaryFile)); - long size = 0; int c = in.read(); while (c > -1) { out.write(c); c = in.read(); size ++; } + + //log.warn("Storing " + field + " for " + node.getNumber()); + /* +x BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(binaryFile)); + byte[] buf = new byte[1024]; + int b = 0; + while ((b = in.read(buf)) != -1) { + size += b; + out.write(buf, 0, b); + } + */ out.close(); in.close(); // unload the input-stream, it is of no use any more. @@ -926,7 +938,7 @@ getActiveConnection(); executeUpdateCheckConnection(query, node, fields); } catch (SQLException se) { - throw new StorageException(se.getMessage() + " during creation of " + UNICODE_ESCAPER.transform(node.toString()), se); + throw new StorageException(se.getMessage() + " during creation of " + UNICODE_ESCAPER.transform(node.toString()) + " " + fieldNames + " " + fieldValues, se); } finally { releaseActiveConnection(); } @@ -2896,6 +2908,9 @@ } } + + + protected static class InputStreamBlob implements Blob { private InputStream inputStream; private byte[] bytes = null; @@ -2917,6 +2932,9 @@ return inputStream; } } + public InputStream getBinaryStream(long pos, long length) { + return new ByteArrayInputStream(getBytes(pos, (int) length)); + } public byte[] getBytes(long pos, int length) { if (pos == 1 && size == length && bytes != null) return bytes; @@ -2984,5 +3002,16 @@ public void truncate(long len) { throw new UnsupportedOperationException(""); } + public void free() { + bytes = null; + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException ioe) { + log.warn(ioe); + } + inputStream = null; + } + } } } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs