[exo-jcr-commits] exo-jcr SVN: r898 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl: dataflow and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Nov 26 21:12:58 EST 2009
Author: pnedonosko
Date: 2009-11-26 21:12:58 -0500 (Thu, 26 Nov 2009)
New Revision: 898
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
Log:
EXOJCR-275: Version.restore workaround for Value storage right work (it's normal logic actually, but not so good tested yet)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-11-26 16:53:49 UTC (rev 897)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-11-27 02:12:58 UTC (rev 898)
@@ -104,7 +104,11 @@
List<ValueData> values = new ArrayList<ValueData>();
for (ValueData valueData : property.getValues())
{
- values.add(((TransientValueData)valueData).createTransientCopy());
+ //values.add(((TransientValueData)valueData).createTransientCopy());
+
+ // TODO workaround for JBC branch, issued by the FileRestoreTest
+ TransientValueData tvd = (TransientValueData)valueData;
+ values.add(tvd.createTransientCopy1());
}
boolean mv = property.isMultiValued();
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-11-26 16:53:49 UTC (rev 897)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-11-27 02:12:58 UTC (rev 898)
@@ -125,7 +125,7 @@
* @param orderNumber
* int
*/
- protected TransientValueData(InputStream stream, int orderNumber)
+ public TransientValueData(InputStream stream, int orderNumber)
{
super(orderNumber);
this.tmpStream = stream;
@@ -428,6 +428,37 @@
}
/**
+ * 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
@@ -931,23 +962,23 @@
// write streams
out.writeInt(2);
//TODO Need optimization in backup service.
- byte[] buf = new byte[4*1024];
-
- if (!spooled)
+ byte[] buf = new byte[4 * 1024];
+
+ if (!spooled)
spoolInputStream();
InputStream in = (spoolFile == null ? new ByteArrayInputStream(data) : new FileInputStream(spoolFile));
long dataLength = (spoolFile == null ? data.length : spoolFile.length());
int len;
-
+
//write length of spoolFile
out.writeLong(dataLength);
-
+
while ((len = in.read(buf)) > 0)
- out.write(buf, 0, len);
-
+ out.write(buf, 0, len);
+
in.close();
}
-
+
out.writeInt(orderNumber);
out.writeInt(maxBufferSize);
}
@@ -967,16 +998,17 @@
else
{
//read file form stream
- long lengthSpoolFile = in.readLong();
-
+ long lengthSpoolFile = in.readLong();
+
//TODO May be optimization.
SpoolFile sf = SpoolFile.createTempFile("jcrvd", null, tempDirectory);
sf.acquire(this);
- OutputStream outStream = new FileOutputStream(sf);
-
- byte[] buf = new byte[4*1024];
-
- while (lengthSpoolFile > 0) {
+ OutputStream outStream = new FileOutputStream(sf);
+
+ byte[] buf = new byte[4 * 1024];
+
+ while (lengthSpoolFile > 0)
+ {
if (lengthSpoolFile - buf.length > 0)
{
in.readFully(buf);
@@ -984,17 +1016,17 @@
}
else
{
- in.readFully(buf, 0, (int) lengthSpoolFile);
- outStream.write(buf, 0, (int) lengthSpoolFile);
+ in.readFully(buf, 0, (int)lengthSpoolFile);
+ outStream.write(buf, 0, (int)lengthSpoolFile);
}
- lengthSpoolFile-=buf.length;
+ lengthSpoolFile -= buf.length;
}
outStream.flush();
outStream.close();
spoolFile = sf;
spooled = true;
}
-
+
orderNumber = in.readInt();
maxBufferSize = in.readInt();
}
More information about the exo-jcr-commits
mailing list