[exo-jcr-commits] exo-jcr SVN: r1071 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow and 9 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 15 12:08:55 EST 2009
Author: pnedonosko
Date: 2009-12-15 12:08:54 -0500 (Tue, 15 Dec 2009)
New Revision: 1071
Added:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractSessionValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
Removed:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractTransientValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamTransientValueData.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DateValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
Log:
EXOJCR-274 TransientValueData rework part3: stream spooling, temp files handling. Binary Value handling in session.
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -22,7 +22,7 @@
import org.exoplatform.services.jcr.core.value.ReadableBinaryValue;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractTransientValueData;
+import org.exoplatform.services.jcr.impl.dataflow.AbstractSessionValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -53,7 +53,7 @@
protected final int type;
- protected LocalTransientValueData data;
+ protected LocalSessionValueData data;
protected ValueData internalData;
@@ -76,15 +76,15 @@
*
* @param asStream
* boolean
- * @return LocalTransientValueData
+ * @return LocalSessionValueData
* @throws IOException
* if error
*/
- protected LocalTransientValueData getLocalData(boolean asStream) throws IOException
+ protected LocalSessionValueData getLocalData(boolean asStream) throws IOException
{
if (data == null)
{
- data = new LocalTransientValueData(asStream);
+ data = new LocalSessionValueData(asStream);
}
return data;
@@ -323,7 +323,7 @@
/**
* Session scope ValueData.
*/
- protected class LocalTransientValueData extends AbstractTransientValueData
+ protected class LocalSessionValueData extends AbstractSessionValueData
{
protected InputStream stream;
@@ -340,7 +340,7 @@
* @throws IOException
* if error
*/
- public LocalTransientValueData(boolean asStream) throws IOException
+ public LocalSessionValueData(boolean asStream) throws IOException
{
super(getInternalData().getOrderNumber());
ValueData idata = getInternalData();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -77,7 +77,7 @@
public BinaryValue(InputStream stream, FileCleaner fileCleaner, File tempDirectory, int maxFufferSize)
throws IOException
{
- this(new TransientValueData(0, null, stream, null, fileCleaner, maxFufferSize, tempDirectory, true));
+ this(new TransientValueData(0, null, stream, null, fileCleaner, maxFufferSize, tempDirectory, true, false));
}
BinaryValue(TransientValueData data) throws IOException
@@ -106,7 +106,7 @@
}
@Override
- protected LocalTransientValueData getLocalData(boolean asStream) throws IOException
+ protected LocalSessionValueData getLocalData(boolean asStream) throws IOException
{
if (this.changed)
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DateValue.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DateValue.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DateValue.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -147,7 +147,7 @@
String inernalString = getInternalString();
// force replace of data
- data = new LocalTransientValueData(true);
+ data = new LocalSessionValueData(true);
// Replace internall stram
data.stream = new ByteArrayInputStream(inernalString.getBytes(Constants.DEFAULT_ENCODING));
Copied: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractSessionValueData.java (from rev 1062, jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractTransientValueData.java)
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractSessionValueData.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractSessionValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.dataflow;
+
+import org.exoplatform.services.jcr.datamodel.ValueData;
+
+/**
+ *
+ * Created by The eXo Platform SAS .
+ *
+ * @author Gennady Azarenkov
+ * @version $Id:AbstractValueData.java 12534 2007-02-02 15:30:52Z peterit $
+ */
+
+public abstract class AbstractSessionValueData implements ValueData
+{
+
+ protected int orderNumber;
+
+ protected AbstractSessionValueData(int orderNumber)
+ {
+ this.orderNumber = orderNumber;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final int getOrderNumber()
+ {
+ return orderNumber;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ValueData)
+ {
+ return this.equals((ValueData)obj);
+ }
+
+ return false;
+ }
+}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractSessionValueData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractTransientValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractTransientValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractTransientValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.dataflow;
-
-import org.exoplatform.services.jcr.datamodel.ValueData;
-
-/**
- *
- * Created by The eXo Platform SAS .
- *
- * @author Gennady Azarenkov
- * @version $Id:AbstractValueData.java 12534 2007-02-02 15:30:52Z peterit $
- */
-
-public abstract class AbstractTransientValueData implements ValueData
-{
-
- protected int orderNumber;
-
- protected AbstractTransientValueData(int orderNumber)
- {
- this.orderNumber = orderNumber;
- }
-
- /**
- * {@inheritDoc}
- */
- public final int getOrderNumber()
- {
- return orderNumber;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj)
- {
- if (obj instanceof ValueData)
- {
- return this.equals((ValueData)obj);
- }
-
- return false;
- }
-}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -51,7 +51,7 @@
{
// send bytes to super.<init>
- super(orderNumber, bytes, null, null, fileCleaner, maxBufferSize, tempDirectory, true);
+ super(orderNumber, bytes, null, null, fileCleaner, maxBufferSize, tempDirectory, true, true);
this.maxIOBuffSize = calcMaxIOSize();
@@ -64,7 +64,7 @@
{
// don't send any data there (no stream, no bytes)
- super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true);
+ super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true, true);
this.maxIOBuffSize = calcMaxIOSize();
@@ -119,7 +119,7 @@
{
// don't send any data there (no stream, no bytes)
- super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true);
+ super(orderNumber, null, null, null, fileCleaner, maxBufferSize, tempDirectory, true, true);
this.maxIOBuffSize = calcMaxIOSize();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -24,7 +24,7 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
@@ -63,7 +63,7 @@
protected ValueData delegate;
- protected class NewValueData extends AbstractTransientValueData
+ protected class NewValueData extends AbstractSessionValueData
{
protected byte[] data;
@@ -141,17 +141,20 @@
* File
* @param deleteSpoolFile
* boolean
+ * @param closeTmpStream
+ * boolean
* @throws IOException
* if read error
*/
protected NewValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
- FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile) throws IOException
+ FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile, boolean closeTmpStream)
+ throws IOException
{
super(orderNumber);
this.data = bytes;
this.tmpStream = stream;
- this.closeTmpStream = true;
+ this.closeTmpStream = closeTmpStream;
this.spoolFile = spoolFile;
this.fileCleaner = fileCleaner;
this.maxBufferSize = maxBufferSize;
@@ -276,69 +279,7 @@
return data != null;
}
- // TODO
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public TransientValueData createTransientCopy() throws RepositoryException
- // {
- // if (isByteArray())
- // {
- // // bytes, make a copy of real data
- // // TODO JCR-992 don't copy bytes
- // // byte[] newBytes = new byte[data.length];
- // // System.arraycopy(data, 0, newBytes, 0, newBytes.length);
- //
- // try
- // {
- // return new TransientValueData(orderNumber, data, // TODO JCR-992
- // null, null, fileCleaner, maxBufferSize, tempDirectory, deleteSpoolFile);
- // }
- // catch (IOException e)
- // {
- // throw new RepositoryException(e);
- // }
- // }
- // else
- // {
- // // stream (or file) based , i.e. shared across sessions
- // return this;
- // }
- // }
-
/**
- * Create TransientCopy of data.
- *
- * TODO workaround for JBC branch, issued by the FileRestoreTest.
- *
- * @return TransientValueData
- * @throws RepositoryException
- */
- public TransientValueData createTransientCopy1() throws RepositoryException
- {
- try
- {
- if (isByteArray())
- {
- // bytes based
- return new TransientValueData(orderNumber, data, null, null, fileCleaner, maxBufferSize, tempDirectory,
- deleteSpoolFile);
- }
- else
- {
- // stream (or file) based , i.e. shared across sessions
- return new TransientValueData(orderNumber, null, getAsStream(), null, fileCleaner, maxBufferSize,
- tempDirectory, true);
- }
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
* Create editable ValueData copy.
*
* @return EditableValueData
@@ -523,19 +464,19 @@
}
dataFile = otherVd.spoolFile;
}
- else if (transnt.delegate instanceof FileStreamPersistedValueData)
+ else if (transnt.delegate instanceof FilePersistedValueData)
{
// if other persistent as delegated - check file
- dataFile = ((FileStreamPersistedValueData)transnt.delegate).getFile();
+ dataFile = ((FilePersistedValueData)transnt.delegate).getFile();
}
else
{
return false;
}
}
- else if (another instanceof FileStreamPersistedValueData)
+ else if (another instanceof FilePersistedValueData)
{
- FileStreamPersistedValueData persisted = (FileStreamPersistedValueData)another;
+ FilePersistedValueData persisted = (FilePersistedValueData)another;
// if other persistent - check file
dataFile = persisted.getFile();
@@ -701,7 +642,8 @@
}
catch (IOException e)
{
- throw new IllegalStateException(e);
+ throw new IllegalStateException("Error of spooling to temp file from " + tmpStream
+ + ". Check if stream is not consumed or is not closed.", e);
}
finally
{
@@ -716,6 +658,7 @@
}
if (this.closeTmpStream)
+ {
try
{
this.tmpStream.close();
@@ -724,6 +667,7 @@
{
LOG.error("Error of source input close.", e);
}
+ }
this.tmpStream = null;
}
}
@@ -831,18 +775,98 @@
* File
* @param deleteSpoolFile
* boolean
+ * @param closeTmpStream
+ * boolean
* @throws IOException
* if read error
*/
public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
+ FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile, boolean closeTmpStream)
+ throws IOException
+ {
+ this.delegate =
+ new NewValueData(orderNumber, bytes, stream, spoolFile, fileCleaner, maxBufferSize, tempDirectory,
+ deleteSpoolFile, closeTmpStream);
+ }
+
+ /**
+ * TransientValueData constructor.
+ *
+ * @param orderNumber
+ * int
+ * @param bytes
+ * byte[]
+ * @param stream
+ * InputStream
+ * @param spoolFile
+ * File
+ * @param fileCleaner
+ * FileCleaner
+ * @param maxBufferSize
+ * int
+ * @param tempDirectory
+ * File
+ * @param deleteSpoolFile
+ * boolean
+ * @throws IOException
+ * if read error
+ */
+ public TransientValueData(int orderNumber, byte[] bytes, InputStream stream, File spoolFile,
FileCleaner fileCleaner, int maxBufferSize, File tempDirectory, boolean deleteSpoolFile) throws IOException
{
this.delegate =
new NewValueData(orderNumber, bytes, stream, spoolFile, fileCleaner, maxBufferSize, tempDirectory,
- deleteSpoolFile);
+ deleteSpoolFile, true);
}
/**
+ * TransientValueData constructor for stream data.
+ *
+ * @param orderNumber
+ * int
+ * @param stream
+ * InputStream
+ * @param fileCleaner
+ * FileCleaner
+ * @param maxBufferSize
+ * int
+ * @param tempDirectory
+ * File
+ * @param deleteSpoolFile
+ * boolean
+ * @throws IOException
+ * if read error
+ */
+ public TransientValueData(int orderNumber, InputStream stream, FileCleaner fileCleaner, int maxBufferSize,
+ File tempDirectory, boolean deleteSpoolFile) throws IOException
+ {
+ this.delegate =
+ new NewValueData(orderNumber, null, stream, null, fileCleaner, maxBufferSize, tempDirectory, deleteSpoolFile,
+ true);
+ }
+
+ /**
+ * TransientValueData constructor for file data.
+ *
+ * @param orderNumber
+ * int
+ * @param spoolFile
+ * File
+ * @param fileCleaner
+ * FileCleaner
+ * @param deleteSpoolFile
+ * boolean
+ * @throws IOException
+ * if read error
+ */
+ public TransientValueData(int orderNumber, File spoolFile, FileCleaner fileCleaner, boolean deleteSpoolFile)
+ throws IOException
+ {
+ this.delegate =
+ new NewValueData(orderNumber, null, null, spoolFile, fileCleaner, -1, null, deleteSpoolFile, true);
+ }
+
+ /**
* Creates TransientValueData with incoming byte array.
* @param orderNumber
* int
@@ -1096,6 +1120,16 @@
}
/**
+ * Constructor for Persisted ValueData delegate (for transient copy).
+ *
+ * @param persistent AbstractPersistedValueData
+ */
+ public TransientValueData(AbstractPersistedValueData persistent)
+ {
+ this.delegate = persistent;
+ }
+
+ /**
* Constructor for Editable value data.
*
* @param orderNumber
@@ -1195,7 +1229,8 @@
}
/**
- * Get original stream. Can be consumed or null. For persistent operations on newly created data only.
+ * Get original stream. Can be consumed or null. <p/>
+ * WARN: method for persistent operations on modified ValueData only.
*
* @return InputStream original stream
*/
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -151,14 +151,7 @@
@Override
public TransientValueData createTransientCopy() throws RepositoryException
{
- try
- {
- return new TransientValueData(orderNumber, data, null, null, null, -1, null, false);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
+ return new TransientValueData(orderNumber, data);
}
}
Copied: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java (from rev 1062, jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java)
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFilePersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent;
+
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.impl.util.io.SwapFile;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS. Implementation of FileStream ValueData secures deleting file in
+ * object finalization
+ *
+ * @author Gennady Azarenkov
+ * @version $Id: CleanableFilePersistedValueData.java 35209 2009-08-07 15:32:27Z pnedonosko $
+ */
+
+public class CleanableFilePersistedValueData extends FilePersistedValueData
+{
+
+ protected final static Log LOG = ExoLogger.getLogger("jcr.CleanableFileStreamValueData");
+
+ protected final FileCleaner cleaner;
+
+ /**
+ * CleanableFilePersistedValueData constructor.
+ * @param orderNumber
+ * int
+ * @param file
+ * SwapFile
+ * @param cleaner
+ * FileCleaner
+ */
+ public CleanableFilePersistedValueData(int orderNumber, SwapFile file, FileCleaner cleaner)
+ throws FileNotFoundException
+ {
+ super(orderNumber, file);
+ this.cleaner = cleaner;
+
+ // aquire this file
+ file.acquire(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ // release file
+ ((SwapFile)file).release(this);
+
+ if (!file.delete())
+ {
+ cleaner.addFile(file);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Could not remove temporary file on finalize: inUse=" + (((SwapFile)file).inUse()) + ", "
+ + file.getAbsolutePath());
+ }
+ }
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @Deprecated
+ public TransientValueData createTransientCopy() throws RepositoryException
+ {
+ return new TransientValueData(this);
+ }
+}
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.dataflow.persistent;
-
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-import org.exoplatform.services.jcr.impl.util.io.SwapFile;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS. Implementation of FileStream ValueData secures deleting file in
- * object finalization
- *
- * @author Gennady Azarenkov
- * @version $Id: CleanableFileStreamValueData.java 35209 2009-08-07 15:32:27Z pnedonosko $
- */
-
-public class CleanableFileStreamValueData extends FileStreamPersistedValueData
-{
-
- protected final static Log LOG = ExoLogger.getLogger("jcr.CleanableFileStreamValueData");
-
- protected final FileCleaner cleaner;
-
- /**
- * CleanableFileStreamValueData constructor.
- *
- * @param file
- * SwapFile
- * @param orderNumber
- * int
- * @param cleaner
- * FileCleaner
- */
- public CleanableFileStreamValueData(SwapFile file, int orderNumber, FileCleaner cleaner)
- throws FileNotFoundException
- {
- super(file, orderNumber);
- this.cleaner = cleaner;
-
- // aquire this file
- file.acquire(this);
- }
-
- /**
- * {@inheritDoc}
- */
- protected void finalize() throws Throwable
- {
- try
- {
- // release file
- ((SwapFile)file).release(this);
-
- if (!file.delete())
- {
- cleaner.addFile(file);
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Could not remove temporary file on finalize: inUse=" + (((SwapFile)file).inUse()) + ", "
- + file.getAbsolutePath());
- }
- }
- }
- finally
- {
- super.finalize();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public TransientValueData createTransientCopy() throws RepositoryException
- {
- try
- {
- return new FileStreamTransientValueData(file, orderNumber, cleaner, true);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-}
Copied: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java (from rev 1062, jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java)
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java (rev 0)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.dataflow.persistent;
+
+import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.WritableByteChannel;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author Gennady Azarenkov
+ * @version $Id$
+ */
+
+public class FilePersistedValueData extends AbstractPersistedValueData
+{
+
+ protected File file;
+
+ protected FileChannel channel;
+
+ /**
+ * FilePersistedValueData constructor.
+ * @param orderNumber int
+ * @param file File
+ */
+ public FilePersistedValueData(int orderNumber, File file)
+ {
+ super(orderNumber);
+ this.file = file;
+ }
+
+ public File getFile() throws IOException
+ {
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public InputStream getAsStream() throws IOException
+ {
+ return new FileInputStream(file);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @throws IOException
+ */
+ public byte[] getAsByteArray() throws IllegalStateException, IOException
+ {
+ return fileToByteArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getLength()
+ {
+ return file.length();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long read(OutputStream stream, long length, long position) throws IOException
+ {
+ if (channel == null)
+ {
+ channel = new FileInputStream(file).getChannel();
+ }
+
+ // validation
+ if (position >= channel.size() && position > 0)
+ {
+ throw new IOException("Position " + position + " out of value size " + channel.size());
+ }
+
+ if (position + length >= channel.size())
+ {
+ length = channel.size() - position;
+ }
+
+ MappedByteBuffer bb = channel.map(FileChannel.MapMode.READ_ONLY, position, length);
+
+ WritableByteChannel ch;
+ if (stream instanceof FileOutputStream)
+ {
+ ch = ((FileOutputStream)stream).getChannel();
+ }
+ else
+ {
+ ch = Channels.newChannel(stream);
+ }
+ ch.write(bb);
+ ch.close();
+
+ return length;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isByteArray()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(ValueData another)
+ {
+ if (this == another)
+ {
+ return true;
+ }
+
+ if (!isByteArray() && !another.isByteArray())
+ {
+ // compare files
+ try
+ {
+ if (another instanceof TransientValueData)
+ {
+ // if another transient
+ return file.equals(((TransientValueData)another).getSpoolFile());
+ }
+ else if (another instanceof FilePersistedValueData)
+ {
+ // both from peristent layer
+ return file.equals(((FilePersistedValueData)another).getFile());
+ }
+ }
+ catch (IOException e)
+ {
+ LOG.error("Read error", e);
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @Deprecated
+ public TransientValueData createTransientCopy() throws RepositoryException
+ {
+ return new TransientValueData(this);
+ }
+
+ /**
+ * Convert File to byte array. <br/>
+ * WARNING: Potential lack of memory due to call getAsByteArray() on stream data.
+ *
+ * @return byte[] bytes array
+ */
+ private byte[] fileToByteArray() throws IOException
+ {
+ // TODO do refactor of work with NIO
+
+ FileChannel fch = new FileInputStream(file).getChannel();
+
+ try
+ {
+ ByteBuffer bb = ByteBuffer.allocate((int)fch.size());
+ fch.read(bb);
+ if (bb.hasArray())
+ {
+ return bb.array();
+ }
+ else
+ {
+ // impossible code in most cases, as we use heap backed buffer
+ byte[] tmpb = new byte[bb.capacity()];
+ bb.get(tmpb);
+ return tmpb;
+ }
+ }
+ finally
+ {
+ fch.close();
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FilePersistedValueData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.dataflow.persistent;
-
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
-import java.nio.channels.WritableByteChannel;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author Gennady Azarenkov
- * @version $Id$
- */
-
-public class FileStreamPersistedValueData extends AbstractPersistedValueData
-{
-
- protected File file;
-
- protected FileChannel channel;
-
- /**
- * FileStreamPersistedValueData constructor.
- *
- * @param file File
- * @param orderNumber int
- */
- public FileStreamPersistedValueData(File file, int orderNumber)
- {
- super(orderNumber);
- this.file = file;
- }
-
- public File getFile() throws IOException
- {
- return file;
- }
-
- /**
- * {@inheritDoc}
- */
- public InputStream getAsStream() throws IOException
- {
- return new FileInputStream(file);
- }
-
- /**
- * {@inheritDoc}
- * @throws IOException
- */
- public byte[] getAsByteArray() throws IllegalStateException, IOException
- {
- return fileToByteArray();
- }
-
- /**
- * {@inheritDoc}
- */
- public long getLength()
- {
- return file.length();
- }
-
- /**
- * {@inheritDoc}
- */
- public long read(OutputStream stream, long length, long position) throws IOException
- {
- if (channel == null)
- {
- channel = new FileInputStream(file).getChannel();
- }
-
- // validation
- if (position >= channel.size() && position > 0)
- {
- throw new IOException("Position " + position + " out of value size " + channel.size());
- }
-
- if (position + length >= channel.size())
- {
- length = channel.size() - position;
- }
-
- MappedByteBuffer bb = channel.map(FileChannel.MapMode.READ_ONLY, position, length);
-
- WritableByteChannel ch;
- if (stream instanceof FileOutputStream)
- {
- ch = ((FileOutputStream)stream).getChannel();
- }
- else
- {
- ch = Channels.newChannel(stream);
- }
- ch.write(bb);
- ch.close();
-
- return length;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isByteArray()
- {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(ValueData another)
- {
- if (this == another)
- {
- return true;
- }
-
- if (!isByteArray() && !another.isByteArray())
- {
- // compare files
- try
- {
- if (another instanceof TransientValueData)
- {
- // if another transient
- return file.equals(((TransientValueData)another).getSpoolFile());
- }
- else if (another instanceof FileStreamPersistedValueData)
- {
- // both from peristent layer
- return file.equals(((FileStreamPersistedValueData)another).getFile());
- }
- }
- catch (IOException e)
- {
- LOG.error("Read error", e);
- return false;
- }
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- public TransientValueData createTransientCopy() throws RepositoryException
- {
- try
- {
- return new FileStreamTransientValueData(file, orderNumber);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
- }
-
- /**
- * Convert File to byte array. <br/>
- * WARNING: Potential lack of memory due to call getAsByteArray() on stream data.
- *
- * @return byte[] bytes array
- */
- private byte[] fileToByteArray() throws IOException
- {
- // TODO do refactor of work with NIO
-
- FileChannel fch = new FileInputStream(file).getChannel();
-
- try
- {
- ByteBuffer bb = ByteBuffer.allocate((int)fch.size());
- fch.read(bb);
- if (bb.hasArray())
- {
- return bb.array();
- }
- else
- {
- // impossible code in most cases, as we use heap backed buffer
- byte[] tmpb = new byte[bb.capacity()];
- bb.get(tmpb);
- return tmpb;
- }
- }
- finally
- {
- fch.close();
- }
- }
-}
Deleted: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamTransientValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamTransientValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamTransientValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-/**
- *
- */
-/*
- * Copyright (C) 2003-2009 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.dataflow.persistent;
-
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>
- *
- * NOT USEFUL!
- *
- * Class for Persistent ValueData in Session (transient) level. Methods getSpoolFile(),
- * setSpoolFile() should don't get/set persistent file. Method createTransientCopy() returns this
- * object.
- *
- * <br/>
- * Date: 09.06.2009
- *
- * @author <a href="mailto:peter.nedonosko at exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
- at Deprecated
-public class FileStreamTransientValueData extends TransientValueData
-{
-
- /**
- * FileStreamTransientValueData constructor.
- *
- * @param file
- * File from Value storage
- * @param orderNumber
- * int
- * @throws IOException
- * if error occurs
- */
- FileStreamTransientValueData(File file, int orderNumber) throws IOException
- {
- super(orderNumber, null, null, file, null, -1, null, false);
- }
-
- /**
- * FileStreamTransientValueData constructor for swap files. Swap file it's a temp file used by
- * container for BLOBs read from database or any remote storage.
- *
- * @param file
- * File from storage
- * @param orderNumber
- * int
- * @param fileCleaner
- * FileCleaner
- * @param deleteFile
- * boolean, if true file will be deleted after the FileStreamTransientValueData will be
- * GCed.
- * @throws IOException
- * if error occurs
- */
- FileStreamTransientValueData(File file, int orderNumber, FileCleaner fileCleaner, boolean deleteFile)
- throws IOException
- {
- super(orderNumber, null, null, file, fileCleaner, -1, null, deleteFile);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public File getSpoolFile()
- {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getLength()
- {
- return this.delegate.getLength();
- }
-}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -35,7 +35,7 @@
* @author <a href="mailto:peter.nedonosko at exoplatform.com">Peter Nedonosko</a>
* @version $Id$
*/
-public class StreamPersistedValueData extends FileStreamPersistedValueData
+public class StreamPersistedValueData extends FilePersistedValueData
{
protected InputStream stream;
@@ -43,20 +43,73 @@
protected File tempFile;
/**
- * StreamPersistedValueData constructor.
+ * StreamPersistedValueData constructor for stream data.
*
- * @param file File
+ * @param orderNumber int
* @param stream InputStream
+ */
+ public StreamPersistedValueData(int orderNumber, InputStream stream)
+ {
+ this(orderNumber, stream, null);
+ }
+
+ /**
+ * StreamPersistedValueData constructor for data spooled to temp file.
+ *
* @param orderNumber int
+ * @param tempFile File
*/
- public StreamPersistedValueData(File file, File tempFile, InputStream stream, int orderNumber)
+ public StreamPersistedValueData(int orderNumber, File tempFile)
{
- super(file, orderNumber);
- this.tempFile = tempFile;
+ this(orderNumber, tempFile, null);
+ }
+
+ /**
+ * StreamPersistedValueData constructor for stream data with know destenation file.
+ * <p/>
+ * Destenation file reserved for use in JBC impl.
+ *
+ * @param orderNumber int
+ * @param stream InputStream
+ * @param destFile File
+ */
+ public StreamPersistedValueData(int orderNumber, InputStream stream, File destFile)
+ {
+ super(orderNumber, destFile);
+ this.tempFile = null;
this.stream = stream;
}
/**
+ * StreamPersistedValueData constructor for data spooled to temp file with know destenation file.
+ * <p/>
+ * Destenation file reserved for use in JBC impl.
+ *
+ * @param orderNumber int
+ * @param tempFile File
+ */
+ public StreamPersistedValueData(int orderNumber, File tempFile, File destFile)
+ {
+ super(orderNumber, destFile);
+ this.tempFile = tempFile;
+ this.stream = null;
+ }
+//
+// /**
+// * StreamPersistedValueData constructor for spooled file.
+// *
+// * @param file File
+// * @param stream InputStream
+// * @param orderNumber int
+// */
+// public StreamPersistedValueData(File file, File tempFile, InputStream stream, int orderNumber)
+// {
+// super(orderNumber, file);
+// this.tempFile = tempFile;
+// this.stream = stream;
+// }
+
+ /**
* Return original data stream or null. <br/>
* For persistent transformation from non-spooled TransientValueData to persistent layer.<br/>
* WARN: after the stream will be consumed it will not contains data anymore.
@@ -153,24 +206,6 @@
}
}
- // TODO
- // @Override
- // public boolean equals(Object obj)
- // {
- // if (super.equals(obj))
- // {
- // return true;
- // }
- // else
- // {
- // // we can check stream and temp file additional
- // if (tempFile != null)
- // {
- //
- // }
- // }
- // }
-
/**
* {@inheritDoc}
*/
@@ -178,15 +213,7 @@
@Deprecated
public TransientValueData createTransientCopy() throws RepositoryException
{
- // TODO check logic
- try
- {
- return new FileStreamTransientValueData(file, orderNumber);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e);
- }
+ return new TransientValueData(this);
}
/**
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -39,7 +39,6 @@
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
@@ -386,7 +385,7 @@
if (vd instanceof TransientValueData)
{
TransientValueData tvd = (TransientValueData)vd;
- AbstractPersistedValueData pvd;
+ ValueData pvd;
if (vd.isByteArray())
{
@@ -396,14 +395,21 @@
else
{
// TODO ask dest file from VS provider, can be null after
- // TODO what if JDBC spool used, i.e. without VS = storage will setPersistedFile()
// TODO for JBC case, the storage connection will evict the replicated Value to read it from the DB
File destFile = null;
// TODO review TransientValueData logic about spool file and stream
- pvd =
- new StreamPersistedValueData(destFile, tvd.getSpoolFile(), tvd.getSpoolFile() == null
- ? tvd.getOriginalStream() : null, i);
+ if (tvd.getSpoolFile() != null)
+ {
+ // spooled to temp file
+ pvd = new StreamPersistedValueData(i, tvd.getSpoolFile());
+ }
+ else
+ {
+ // with original stream
+ pvd = new StreamPersistedValueData(i, tvd.getOriginalStream());
+ }
+
values.add(pvd);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataReader.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -23,7 +23,7 @@
import org.exoplatform.services.jcr.dataflow.serialization.UnknownClassIdException;
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SpoolFile;
@@ -118,14 +118,14 @@
// TODO optimize writeToFile - use channels or streams
writeToFile(in, sf, length);
holder.put(id, sf);
- return new FileStreamPersistedValueData(sf, orderNumber);
+ return new FilePersistedValueData(orderNumber, sf);
}
else
{
sf.acquire(this); // TODO workaround for AsyncReplication test
try
{
- AbstractPersistedValueData vd = new FileStreamPersistedValueData(sf, orderNumber);
+ AbstractPersistedValueData vd = new FilePersistedValueData(orderNumber, sf);
// skip data in input stream
if (in.skip(length) != length)
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedValueDataWriter.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -22,7 +22,7 @@
import org.exoplatform.services.jcr.dataflow.serialization.SerializationConstants;
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.util.IdGenerator;
import java.io.IOException;
@@ -66,7 +66,7 @@
else
{
// write file content
- FileStreamPersistedValueData streamed = (FileStreamPersistedValueData)vd;
+ FilePersistedValueData streamed = (FilePersistedValueData)vd;
InputStream in = streamed.getAsStream();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -34,7 +34,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFileStreamValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
@@ -1829,7 +1829,7 @@
}
if (buffer == null)
- return new CleanableFileStreamValueData(swapFile, orderNumber, swapCleaner);
+ return new CleanableFilePersistedValueData(orderNumber, swapFile, swapCleaner);
return new ByteArrayPersistedValueData(buffer, orderNumber);
}
@@ -1922,6 +1922,7 @@
StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
stream = streamData.getStream();
+ // TODO spool on JDBC driver read - multiplexing the data to two stores, database and spool file, with one read.
SwapFile swapFile = swapValueData(cid, i, data.getPersistedVersion(), stream);
long vlen = swapFile.length();
@@ -1942,6 +1943,7 @@
+ ". Property " + data.getQPath().getAsString());
}
+ // set persistent file to ValueData, will be available for saving Property.
streamData.setPersistedFile(swapFile);
}
storageId = null;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -20,7 +20,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -79,7 +79,7 @@
if (fileSize > maxBufferSize)
{
- return new FileStreamPersistedValueData(file, orderNum);
+ return new FilePersistedValueData(orderNum, file);
}
else
{
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCleanableFileStreamValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -51,7 +51,7 @@
private FileCleaner testCleaner;
- private CleanableFileStreamValueData cleanableValueData;
+ private CleanableFilePersistedValueData cleanableValueData;
private static class TestSwapFile extends SwapFile
{
@@ -91,7 +91,7 @@
fout.close();
sf.spoolDone();
- cleanableValueData = new CleanableFileStreamValueData(sf, 1, testCleaner);
+ cleanableValueData = new CleanableFilePersistedValueData(1, sf, testCleaner);
}
@Override
@@ -138,8 +138,8 @@
System.gc();
Thread.sleep(CLEANER_TIMEOUT / 2);
- CleanableFileStreamValueData cfvd2 =
- new CleanableFileStreamValueData(SwapFile.get(parentDir, FILE_NAME), 1, testCleaner);
+ CleanableFilePersistedValueData cfvd2 =
+ new CleanableFilePersistedValueData(1, SwapFile.get(parentDir, FILE_NAME), testCleaner);
assertTrue(testFile.exists());
cleanableValueData = null; // CleanableVD dies but another instance points swapped file
@@ -230,8 +230,8 @@
System.gc();
// file shared with third CleanableVD, i.e. file still exists (aquired by TransientVD)
- CleanableFileStreamValueData cfvd2 =
- new CleanableFileStreamValueData(SwapFile.get(parentDir, FILE_NAME), 1, testCleaner);
+ CleanableFilePersistedValueData cfvd2 =
+ new CleanableFilePersistedValueData(1, SwapFile.get(parentDir, FILE_NAME), testCleaner);
assertTrue(testFile.exists());
trvd = null; // TransientVD dies
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/serialization/JCRSerializationVSJavaSerializationTestLoad.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -20,7 +20,7 @@
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import java.io.ByteArrayInputStream;
@@ -60,7 +60,7 @@
for (int i = 0; i < nodes; i++)
{
bin = new ByteArrayInputStream(createBLOBTempData(20));
- list.add(new StreamPersistedValueData(null, null, bin, 0));
+ list.add(new StreamPersistedValueData(0, bin));
}
Iterator<AbstractPersistedValueData> it;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/CASableFileIOChannelTestBase.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -21,7 +21,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.value.cas.RecordAlreadyExistsException;
import org.exoplatform.services.jcr.impl.storage.value.cas.RecordNotFoundException;
@@ -112,7 +112,7 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0);
+ ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
@@ -143,7 +143,7 @@
// prepare
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0);
+ ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
@@ -152,7 +152,7 @@
try
{
fch = openCASChannel(digestType);
- fch.write(new String(propertyId), new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0));
+ fch.write(new String(propertyId), new StreamPersistedValueData(0, new FileInputStream(testFile)));
fch.commit();
fail("RecordAlreadyExistsException should be thrown, record exists");
@@ -182,10 +182,10 @@
String propertyId = IdGenerator.generate();
try
{
- ValueData value = new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0);
+ ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
fch.write(propertyId, value);
fch.delete(propertyId);
- fch.write(propertyId, new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0));
+ fch.write(propertyId, new StreamPersistedValueData(0, new FileInputStream(testFile)));
fch.commit();
// long initialSize = calcDirSize(rootDir);
@@ -209,7 +209,7 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0);
+ ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
@@ -232,7 +232,7 @@
FileIOChannel fch = openCASChannel(digestType);
String propertyId = IdGenerator.generate();
- ValueData value = new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0);
+ ValueData value = new StreamPersistedValueData(0, new FileInputStream(testFile));
fch.write(propertyId, value);
fch.commit();
@@ -316,7 +316,7 @@
for (int i = 0; i < 20; i++)
{
- fch.write(propertyId, new StreamPersistedValueData(null, null, new FileInputStream(testFile), i));
+ fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(testFile)));
}
fch.commit();
@@ -346,7 +346,7 @@
{
File f = createBLOBTempFile(300);
addedSize += f.length();
- fch.write(propertyId, new StreamPersistedValueData(null, null, new FileInputStream(f), i));
+ fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(testFile)));
}
fch.commit();
@@ -375,7 +375,7 @@
propertyId = IdGenerator.generate();
FileIOChannel fch = openCASChannel(digestType);
- fch.write(propertyId, new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0));
+ fch.write(propertyId, new StreamPersistedValueData(0, new FileInputStream(testFile)));
fch.commit();
}
@@ -404,7 +404,7 @@
addedSize += f.length();
FileIOChannel fch = openCASChannel(digestType);
- fch.write(propertyId, new StreamPersistedValueData(null, null, new FileInputStream(f), 0));
+ fch.write(propertyId, new StreamPersistedValueData(i, new FileInputStream(f)));
fch.commit();
}
@@ -434,7 +434,7 @@
propertyId = pid;
FileIOChannel fch = openCASChannel(digestType);
- fch.write(pid, new StreamPersistedValueData(null, null, new FileInputStream(testFile), 0));
+ fch.write(pid, new StreamPersistedValueData(0, new FileInputStream(testFile)));
fch.commit();
}
@@ -475,7 +475,7 @@
addedSize += (fileSize = f.length());
FileIOChannel fch = openCASChannel(digestType);
- fch.write(pid, new StreamPersistedValueData(null, null, new FileInputStream(f), 0));
+ fch.write(pid, new StreamPersistedValueData(i, new FileInputStream(f)));
fch.commit();
}
@@ -515,7 +515,7 @@
File f = createBLOBTempFile(450);
addedSize += (m1fileSize = f.length());
- StreamPersistedValueData v = new StreamPersistedValueData(null, null, new FileInputStream(f), i);
+ StreamPersistedValueData v = new StreamPersistedValueData(i, new FileInputStream(testFile));
if (i == 1)
sharedValue = v;
@@ -537,7 +537,7 @@
if (i == 2)
{
// use shared
- sharedValue = new StreamPersistedValueData(null, null, sharedValue.getAsStream(), i);
+ sharedValue = new StreamPersistedValueData(i, sharedValue.getAsStream());
v = sharedValue;
}
else
@@ -546,7 +546,7 @@
m2filesCount++;
File f = createBLOBTempFile(350);
addedSize += (m2fileSize = f.length()); // add size
- v = new StreamPersistedValueData(null, null, new FileInputStream(f), i);
+ v = new StreamPersistedValueData(i, new FileInputStream(testFile));
}
fch.write(property2MultivaluedId, v);
}
@@ -555,7 +555,7 @@
// add some single valued properties, two new property will have shared value too
String property1Id = null;
String property2Id = null;
- sharedValue = new StreamPersistedValueData(null, null, sharedValue.getAsStream(), 0);
+ sharedValue = new StreamPersistedValueData(0, sharedValue.getAsStream());
for (int i = 0; i < 10; i++)
{
String pid = IdGenerator.generate();
@@ -574,7 +574,7 @@
{
File f = createBLOBTempFile(425);
addedSize += f.length();
- v = new StreamPersistedValueData(null, null, new FileInputStream(f), 0);
+ v = new StreamPersistedValueData(i, new FileInputStream(f));
}
FileIOChannel vfch = openCASChannel(digestType);
vfch.write(pid, v);
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestFileValueIO.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -23,7 +23,7 @@
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
import java.io.ByteArrayInputStream;
@@ -116,7 +116,7 @@
// max buffer size = 5 - so File will be created
ValueData vd = FileValueIOUtil.testReadValue(file, 0, 5);
- assertTrue(vd instanceof FileStreamPersistedValueData);
+ assertTrue(vd instanceof FilePersistedValueData);
assertFalse(vd.isByteArray());
assertEquals(10, vd.getLength());
assertEquals(0, vd.getOrderNumber());
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/value/TestPersistedValueData.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -21,8 +21,8 @@
import junit.framework.TestCase;
import org.exoplatform.services.jcr.impl.dataflow.persistent.ByteArrayPersistedValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFileStreamValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.CleanableFilePersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.storage.value.fs.Probe;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
import org.exoplatform.services.jcr.impl.util.io.SwapFile;
@@ -64,7 +64,7 @@
out.write(buf);
out.close();
- FileStreamPersistedValueData vd = new FileStreamPersistedValueData(file, 0);
+ FilePersistedValueData vd = new FilePersistedValueData(0, file);
assertFalse(vd.isByteArray());
assertEquals(10, vd.getLength());
assertEquals(0, vd.getOrderNumber());
@@ -91,7 +91,7 @@
out.write(buf);
out.close();
- CleanableFileStreamValueData vd = new CleanableFileStreamValueData(file, 0, new FileCleaner(1000, true));
+ CleanableFilePersistedValueData vd = new CleanableFilePersistedValueData(0, file, new FileCleaner(1000, true));
assertTrue(file.exists());
vd = null;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2009-12-15 16:57:58 UTC (rev 1070)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/usecases/RemoveVDTest.java 2009-12-15 17:08:54 UTC (rev 1071)
@@ -23,7 +23,7 @@
import org.exoplatform.services.jcr.dataflow.serialization.UnknownClassIdException;
import org.exoplatform.services.jcr.impl.dataflow.AbstractPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.FileStreamPersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.FilePersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectReaderImpl;
import org.exoplatform.services.jcr.impl.dataflow.serialization.ObjectWriterImpl;
@@ -51,7 +51,7 @@
File f = this.createBLOBTempFile("tempFile", 300);
- FileStreamPersistedValueData vd = new FileStreamPersistedValueData(f, 0);
+ FilePersistedValueData vd = new FilePersistedValueData(0, f);
// vd.setMaxBufferSize(200*1024);
// assertNull(vd.getFile()); // not spooling by default until getAsStream() will be call
@@ -69,12 +69,12 @@
// read first time
ObjectReader or = new ObjectReaderImpl(new FileInputStream(serf));
- FileStreamPersistedValueData vd1 = null;
+ FilePersistedValueData vd1 = null;
PersistedValueDataReader vdr = new PersistedValueDataReader(fileCleaner, maxBufferSize, holder);
try
{
- vd1 = (FileStreamPersistedValueData)vdr.read(or);
+ vd1 = (FilePersistedValueData)vdr.read(or);
}
catch (UnknownClassIdException e)
{
@@ -85,11 +85,11 @@
// read second time
or = new ObjectReaderImpl(new FileInputStream(serf));
- FileStreamPersistedValueData vd2 = null;
+ FilePersistedValueData vd2 = null;
try
{
- vd2 = (FileStreamPersistedValueData)vdr.read(or);
+ vd2 = (FilePersistedValueData)vdr.read(or);
}
catch (UnknownClassIdException e)
{
More information about the exo-jcr-commits
mailing list