Author: pnedonosko
Date: 2009-12-10 11:23:38 -0500 (Thu, 10 Dec 2009)
New Revision: 989
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractValueData.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/PersistedValueData.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/FileStreamPersistedValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
Log:
EXOJCR-274 createTransientCopy deprecated; ValueData.equals right impl
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -89,6 +89,7 @@
*
* @throws RepositoryException if ValueData IOException occurs.
*/
+ @Deprecated
public abstract TransientItemData createTransientCopy() throws RepositoryException;
/**
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -106,14 +106,18 @@
return true;
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public TransientItemData createTransientCopy()
{
- TransientNodeData dataCopy =
- new TransientNodeData(getQPath(), getIdentifier(), getPersistedVersion(),
getPrimaryTypeName(),
- getMixinTypeNames(), getOrderNumber(), getParentIdentifier() != null ?
getParentIdentifier() : null,
- getACL());
-
- return dataCopy;
+// TransientNodeData dataCopy =
+// new TransientNodeData(getQPath(), getIdentifier(), getPersistedVersion(),
getPrimaryTypeName(),
+// getMixinTypeNames(), getOrderNumber(), getParentIdentifier() != null ?
getParentIdentifier() : null,
+// getACL());
+//
+// return dataCopy;
+ throw new IllegalStateException("createTransientCopy deprecated");
}
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -98,19 +98,25 @@
visitor.visit(this);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
+ @Deprecated
public TransientItemData createTransientCopy() throws RepositoryException
{
- List<ValueData> copyValues = new ArrayList<ValueData>();
- for (ValueData vdata : getValues())
- {
- copyValues.add(((PersistedValueData)vdata).createTransientCopy());
- }
-
- TransientPropertyData dataCopy =
- new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(),
getType(),
- getParentIdentifier(), isMultiValued(), copyValues);
-
- return dataCopy;
+// List<ValueData> copyValues = new ArrayList<ValueData>();
+// for (ValueData vdata : getValues())
+// {
+// copyValues.add(((PersistedValueData)vdata).createTransientCopy());
+// }
+//
+// TransientPropertyData dataCopy =
+// new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(),
getType(),
+// getParentIdentifier(), isMultiValued(), copyValues);
+//
+// return dataCopy;
+
+ throw new IllegalStateException("createTransientCopy deprecated");
}
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -550,7 +550,7 @@
Value[] values = new Value[propertyData.getValues().size()];
for (int i = 0; i < values.length; i++)
{
- values[i] = valueFactory.loadValue((ValueData)propertyData.getValues().get(i),
propertyData.getType());
+ values[i] = valueFactory.loadValue(propertyData.getValues().get(i),
propertyData.getType());
}
return values;
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractValueData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractValueData.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -33,8 +33,6 @@
public abstract class AbstractValueData implements ValueData
{
- protected final static Log log =
ExoLogger.getLogger("jcr.AbstractValueData");
-
protected int orderNumber;
protected AbstractValueData(int orderNumber)
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-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/EditableValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -19,6 +19,8 @@
package org.exoplatform.services.jcr.impl.dataflow;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -37,6 +39,8 @@
public class EditableValueData extends TransientValueData
{
+ protected final static Log LOG =
ExoLogger.getLogger("jcr.EditableValueData");
+
protected final int maxIOBuffSize;
public EditableValueData(byte[] bytes, int orderNumber, FileCleaner fileCleaner, int
maxBufferSize,
@@ -408,12 +412,12 @@
{
if (fileCleaner != null)
{
- log.info("Could not remove file. Add to fileCleaner " +
spoolFile);
+ LOG.info("Could not remove file. Add to fileCleaner " +
spoolFile);
fileCleaner.addFile(spoolFile);
}
else
{
- log.warn("Could not remove temporary file on switch to bytes,
fileCleaner not found. "
+ LOG.warn("Could not remove temporary file on switch to bytes,
fileCleaner not found. "
+ spoolFile.getAbsolutePath());
}
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/PersistedValueData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/PersistedValueData.java 2009-12-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/PersistedValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -19,6 +19,8 @@
package org.exoplatform.services.jcr.impl.dataflow;
import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import javax.jcr.RepositoryException;
@@ -29,6 +31,8 @@
public abstract class PersistedValueData implements ValueData
{
+ protected final static Log LOG =
ExoLogger.getLogger("jcr.PersistedValueData");
+
protected int orderNumber;
protected PersistedValueData(int orderNumber)
@@ -50,5 +54,6 @@
* @return TransientValueData
* @throws RepositoryException if error ocurs
*/
+ @Deprecated
public abstract TransientValueData createTransientCopy() throws RepositoryException;
}
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-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -22,10 +22,14 @@
import org.exoplatform.services.jcr.datamodel.Identifier;
import org.exoplatform.services.jcr.datamodel.InternalQName;
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.StreamPersistedValueData;
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;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.ByteArrayInputStream;
import java.io.Externalizable;
@@ -58,6 +62,8 @@
public class TransientValueData extends AbstractValueData implements Externalizable
{
+ protected final static Log LOG =
ExoLogger.getLogger("jcr.TransientValueData");
+
private static final long serialVersionUID = -5280857006905550884L;
protected byte[] data;
@@ -177,7 +183,7 @@
if (this.tmpStream != null)
{
this.tmpStream.close();
- this.tmpStream = null;
+ this.tmpStream = null;
}
this.spooled = true;
@@ -376,17 +382,17 @@
public long getLength()
{
// TODO try ask on FileChannel (via FileInputStream if have such stream).
-
+
if (isByteArrayAfterSpool())
{
- if (log.isDebugEnabled())
- log.debug("getLength data : " + data.length);
+ if (LOG.isDebugEnabled())
+ LOG.debug("getLength data : " + data.length);
return data.length;
}
else
{
- if (log.isDebugEnabled())
- log.debug("getLength spoolFile : " + spoolFile.length());
+ if (LOG.isDebugEnabled())
+ LOG.debug("getLength spoolFile : " + spoolFile.length());
return spoolFile.length();
}
}
@@ -400,36 +406,36 @@
}
// 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;
-// }
-// }
-
+ // /**
+ // * {@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.
*
@@ -563,32 +569,32 @@
}
// TODO cleanup
-// /**
-// * Set spool as persisted file. It's means ValueData has its data stored to a
External Value
-// * Storage. And it's a file with the content which cannot be deleted or moved
outside Value
-// * Storage.
-// *
-// * @param persistedFile
-// * File
-// * @throws IOException
-// * if any Exception is occurred
-// */
-// public void setPersistedFile(File persistedFile) throws IOException
-// {
-// if (isTransient())
-// {
-// deleteCurrentSpoolFile();
-// }
-//
-// this.spoolFile = persistedFile;
-// this.deleteSpoolFile = false;
-// this.spooled = true;
-//
-// this.tmpStream = null;
-// this.data = null;
-//
-// this.isTransient = false;
-// }
+ // /**
+ // * Set spool as persisted file. It's means ValueData has its data stored to a
External Value
+ // * Storage. And it's a file with the content which cannot be deleted or moved
outside Value
+ // * Storage.
+ // *
+ // * @param persistedFile
+ // * File
+ // * @throws IOException
+ // * if any Exception is occurred
+ // */
+ // public void setPersistedFile(File persistedFile) throws IOException
+ // {
+ // if (isTransient())
+ // {
+ // deleteCurrentSpoolFile();
+ // }
+ //
+ // this.spoolFile = persistedFile;
+ // this.deleteSpoolFile = false;
+ // this.spooled = true;
+ //
+ // this.tmpStream = null;
+ // this.data = null;
+ //
+ // this.isTransient = false;
+ // }
/**
* Helper method to simplify operations that requires stringified data.
@@ -599,8 +605,8 @@
*/
public String getString() throws IOException
{
- if (log.isDebugEnabled())
- log.debug("getString");
+ if (LOG.isDebugEnabled())
+ LOG.debug("getString");
return new String(getAsByteArray(), Constants.DEFAULT_ENCODING);
}
@@ -652,26 +658,62 @@
return true;
}
- if (obj instanceof TransientValueData)
+ if (obj instanceof ValueData)
{
- TransientValueData other = (TransientValueData)obj;
- if (isByteArray() != other.isByteArray())
- return false;
- try
+ ValueData other = (ValueData)obj;
+ if (isByteArray() == other.isByteArray())
{
- if (isByteArray())
+ // by content
+ try
{
- return Arrays.equals(getAsByteArray(), other.getAsByteArray());
+ if (isByteArray())
+ {
+ // compare bytes
+ return Arrays.equals(getAsByteArray(), other.getAsByteArray());
+ }
+ else
+ {
+ // compare files
+ if (other instanceof TransientValueData)
+ {
+ // if both transient... or stream of file can be equal
+ TransientValueData transnt = (TransientValueData)other;
+
+ if (tmpStream == transnt.tmpStream)
+ {
+ return true;
+ }
+ else if (spoolFile != null)
+ {
+ return spoolFile.equals(transnt.spoolFile);
+ }
+ }
+ else if (other instanceof StreamPersistedValueData)
+ {
+ // else - it's comparison of values from transient and peristent
layers
+ // they can be equal in theory, but we will not check BLOB files
content due to performance
+ // check only if it's not a same file or stream (not real)
backed both
+
+ StreamPersistedValueData persisted =
(StreamPersistedValueData)other;
+
+ if (tmpStream == persisted.getStream())
+ {
+ return true;
+ }
+ else if (spoolFile != null)
+ {
+ return spoolFile.equals(persisted.getFile());
+ }
+ }
+ }
}
- else
- return getSpoolFile().equals(other.getSpoolFile());
+ catch (IOException e)
+ {
+ LOG.error("Read error", e);
+ return false;
+ }
}
- catch (IOException e)
- {
- log.error("Read error", e);
- return false;
- }
}
return false;
}
@@ -719,7 +761,7 @@
}
catch (IOException e)
{
- log.error("Error of spool output close.", e);
+ LOG.error("Error of spool output close.", e);
}
if (this.closeTmpStream)
@@ -729,7 +771,7 @@
}
catch (IOException e)
{
- log.error("Error of source input close.", e);
+ LOG.error("Error of source input close.", e);
}
this.tmpStream = null;
}
@@ -832,7 +874,7 @@
}
catch (IOException e)
{
- log.error("Error of spool output close.", e);
+ LOG.error("Error of spool output close.", e);
}
if (this.closeTmpStream)
@@ -842,7 +884,7 @@
}
catch (IOException e)
{
- log.error("Error of source input close.", e);
+ LOG.error("Error of source input close.", e);
}
this.tmpStream = null;
}
@@ -858,9 +900,9 @@
{
FileChannel fch = new FileInputStream(spoolFile).getChannel();
- if (log.isDebugEnabled() && fch.size() > maxBufferSize)
+ if (LOG.isDebugEnabled() && fch.size() > maxBufferSize)
{
- log.debug("Potential lack of memory due to call getAsByteArray() on stream
data exceeded " + fch.size()
+ LOG.debug("Potential lack of memory due to call getAsByteArray() on stream
data exceeded " + fch.size()
+ " bytes");
}
@@ -911,28 +953,28 @@
{
fileCleaner.addFile(spoolFile);
- if (log.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
- log.debug("Could not remove file. Add to fileCleaner " +
spoolFile.getAbsolutePath());
+ LOG.debug("Could not remove file. Add to fileCleaner " +
spoolFile.getAbsolutePath());
}
}
else
{
- log.warn("Could not remove temporary file on finalize " +
spoolFile.getAbsolutePath());
+ LOG.warn("Could not remove temporary file on finalize " +
spoolFile.getAbsolutePath());
}
}
}
}
}
-
+
// TODO
-// /**
-// * {@inheritDoc}
-// */
-// public final void setOrderNumber(int orderNumber)
-// {
-// this.orderNumber = orderNumber;
-// }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public final void setOrderNumber(int orderNumber)
+ // {
+ // this.orderNumber = orderNumber;
+ // }
// ------------- Serializable
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-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ByteArrayPersistedValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -18,8 +18,11 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
@@ -30,6 +33,7 @@
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
+import java.util.Arrays;
import javax.jcr.RepositoryException;
@@ -113,6 +117,36 @@
return true;
}
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (obj instanceof ValueData)
+ {
+
+ ValueData other = (ValueData)obj;
+ if (isByteArray() && other.isByteArray())
+ {
+ // by content
+ try
+ {
+ return Arrays.equals(getAsByteArray(), other.getAsByteArray());
+ }
+ catch (IOException e)
+ {
+ LOG.error("Read error", e);
+ return false;
+ }
+ }
+ }
+
+ return false;
+ }
+
/**
* {@inheritDoc}
*/
Modified:
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-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamPersistedValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
@@ -31,6 +32,7 @@
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.WritableByteChannel;
+import java.util.Arrays;
import javax.jcr.RepositoryException;
@@ -60,6 +62,11 @@
this.file = file;
}
+ public File getFile() throws IOException
+ {
+ return file;
+ }
+
/**
* {@inheritDoc}
*/
@@ -131,6 +138,46 @@
return false;
}
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (obj instanceof ValueData)
+ {
+ ValueData other = (ValueData)obj;
+ if (!isByteArray() && !other.isByteArray())
+ {
+ // by content
+ try
+ {
+ // compare files
+ if (other instanceof TransientValueData)
+ {
+ // if other transient... files can be equal
+ return file.equals(((TransientValueData)other).getSpoolFile());
+ }
+ else if (other instanceof FileStreamPersistedValueData)
+ {
+ // else - it's comparison of values from peristent layer
+ // they can be equal by file backed them
+
+ return file.equals(((FileStreamPersistedValueData)other).getFile());
+ }
+ }
+ catch (IOException e)
+ {
+ LOG.error("Read error", e);
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* {@inheritDoc}
*/
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-10
15:26:20 UTC (rev 988)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java 2009-12-10
16:23:38 UTC (rev 989)
@@ -125,6 +125,24 @@
}
}
+ // 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}
*/