Author: pnedonosko
Date: 2009-12-10 05:10:40 -0500 (Thu, 10 Dec 2009)
New Revision: 979
Added:
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/persistent/StreamPersistedValueData.java
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PairChangesLog.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/SharedDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
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/datamodel/ValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/Constants.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.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/core/SessionDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
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/BooleanValue.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/core/value/DoubleValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/LongValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/NameValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PathValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ReferenceValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/StringValue.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.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/TransientPropertyData.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/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
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.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/session/LocalWorkspaceStorageDataManagerProxy.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.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/CASableWriteValue.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/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java
Log:
EXOJCR-299 get rid of proxy manager; ValueData in persistent layer rework (stream-file);
use of non copied ItemData on read operations. (TCK fails with 745 errors)
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PairChangesLog.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PairChangesLog.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PairChangesLog.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -26,38 +26,22 @@
* <br/>Date: 04.03.2009
*
* @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex
Reshetnyak</a>
- * @version $Id: PairChangesLog.java 111 2008-11-11 11:11:11Z rainf0x $
+ * @version $Id$
*/
public class PairChangesLog extends PlainChangesLogImpl
{
/**
- * Pair identifier.
- */
- private final String pairId;
-
- /**
- * full qualified constructor
+ * Pair log constructor.
*
- * @param items
- * @param sessionId
- * @param eventType
- * @param pairId
+ * @param items List of ItemStates
+ * @param sessionId String
+ * @param eventType int
+ * @param pairId String
*/
public PairChangesLog(List<ItemState> items, String sessionId, int eventType,
String pairId)
{
super(items, sessionId, eventType);
this.pairId = pairId;
}
-
- /**
- * getPairId.
- *
- * @return String
- * pair identifier
- */
- public String getPairId()
- {
- return pairId;
- }
}
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PairChangesLog.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -27,33 +27,44 @@
* inside)
*
* @author Gennady Azarenkov
- * @version $Id: PlainChangesLog.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public interface PlainChangesLog extends ItemStateChangesLog
{
/**
+ * Return Sesion Id.
+ *
* @return sessionId of a session produced this changes log
*/
String getSessionId();
+
+ /**
+ * Return pair Id of system and non-system logs.
+ *
+ * @return pairId of a pair, null if no pair found.
+ */
+ String getPairId();
/**
- * @return event type produced this log
+ * Return this log event type.
+ *
+ * @return int, event type produced this log
* @see ExtendedEventType
*/
int getEventType();
/**
- * adds an item state object to the bottom of this log
+ * Adds an item state object to the bottom of this log.
*
- * @param state
+ * @param state ItemState
*/
PlainChangesLog add(ItemState state);
/**
- * adds list of states object to the bottom of this log
- *
- * @param states
+ * Adds list of states object to the bottom of this log.
+ *
+ * @param states List of ItemState
*/
PlainChangesLog addAll(List<ItemState> states);
}
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLog.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.jcr.dataflow;
+import org.exoplatform.services.jcr.impl.Constants;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@@ -29,7 +31,7 @@
* Created by The eXo Platform SAS.
*
* @author Gennady Azarenkov
- * @version $Id: PlainChangesLogImpl.java 14464 2008-05-19 11:05:20Z pnedonosko $
+ * @version $Id$
* Stores collection of ItemStates
*/
public class PlainChangesLogImpl implements Externalizable, PlainChangesLog
@@ -44,12 +46,33 @@
protected int eventType;
/**
- * full qualified constructor
+ * Identifier of system and non-system logs pair. Null if no pair found.
+ */
+ protected String pairId = null;
+
+ /**
+ * Full qualified constructor.
*
- * @param items
- * @param sessionId
- * @param eventType
+ * @param items List of ItemState
+ * @param sessionId String
+ * @param eventType int
+ * @param pairId String
*/
+ public PlainChangesLogImpl(List<ItemState> items, String sessionId, int
eventType, String pairId)
+ {
+ this.items = items;
+ this.sessionId = sessionId;
+ this.eventType = eventType;
+ this.pairId = pairId;
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param items List of ItemState
+ * @param sessionId String
+ * @param eventType int
+ */
public PlainChangesLogImpl(List<ItemState> items, String sessionId, int
eventType)
{
this.items = items;
@@ -58,10 +81,10 @@
}
/**
- * constructor with undefined event type
+ * Constructor with undefined event type.
*
- * @param items
- * @param sessionId
+ * @param items List of ItemState
+ * @param sessionId String
*/
public PlainChangesLogImpl(List<ItemState> items, String sessionId)
{
@@ -69,9 +92,9 @@
}
/**
- * an empty log
+ * An empty log.
*
- * @param sessionId
+ * @param sessionId String
*/
public PlainChangesLogImpl(String sessionId)
{
@@ -159,6 +182,17 @@
items.clear();
}
+ /**
+ * Return pair Id for linked logs (when original log splitted into two, for system and
non-system workspaces).
+ *
+ * @return String
+ * pair identifier
+ */
+ public String getPairId()
+ {
+ return pairId;
+ }
+
public String dump()
{
String str = "ChangesLog: \n";
@@ -179,29 +213,39 @@
{
out.writeInt(eventType);
- out.writeInt(sessionId.getBytes().length);
- out.write(sessionId.getBytes());
+ byte[] buff = sessionId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buff.length);
+ out.write(buff);
int listSize = items.size();
out.writeInt(listSize);
for (int i = 0; i < listSize; i++)
+ {
out.writeObject(items.get(i));
+ }
+
+ buff = pairId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buff.length);
+ out.write(buff);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
eventType = in.readInt();
- String DEFAULT_ENCODING = "UTF-8";
- byte[] buf;
-
- buf = new byte[in.readInt()];
+ byte[] buf = new byte[in.readInt()];
in.readFully(buf);
- sessionId = new String(buf, DEFAULT_ENCODING);
+ sessionId = new String(buf, Constants.DEFAULT_ENCODING);
int listSize = in.readInt();
for (int i = 0; i < listSize; i++)
+ {
add((ItemState)in.readObject());
+ }
+
+ buf = new byte[in.readInt()];
+ in.readFully(buf);
+ pairId = new String(buf, Constants.DEFAULT_ENCODING);
}
// ------------------ [ END ] ------------------
}
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/PlainChangesLogImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/SharedDataManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/SharedDataManager.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/SharedDataManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -32,7 +32,7 @@
{
/**
- * Return current time of a persistent data manager
+ * Return current time of a persistent data manager.
*/
Calendar getCurrentTime();
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -251,8 +251,10 @@
if (systemId != null)
{
out.writeInt(1);
- out.writeInt(systemId.getBytes().length);
- out.write(systemId.getBytes());
+
+ byte[] buff = systemId.getBytes(Constants.DEFAULT_ENCODING);
+ out.writeInt(buff.length);
+ out.write(buff);
}
else
{
@@ -262,7 +264,9 @@
int listSize = changesLogs.size();
out.writeInt(listSize);
for (int i = 0; i < listSize; i++)
+ {
out.writeObject(changesLogs.get(i));
+ }
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
@@ -277,7 +281,9 @@
int listSize = in.readInt();
for (int i = 0; i < listSize; i++)
+ {
changesLogs.add((PlainChangesLogImpl)in.readObject());
+ }
}
// ------------------ [ END ] ------------------
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
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -49,8 +49,7 @@
this.version = version;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#getQPath()
*/
public QPath getQPath()
@@ -58,8 +57,7 @@
return qpath;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#getIdentifier()
*/
public String getIdentifier()
@@ -67,8 +65,7 @@
return id;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#getPersistedVersion()
*/
public int getPersistedVersion()
@@ -76,8 +73,7 @@
return version;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#getParentIdentifier()
*/
public String getParentIdentifier()
@@ -85,8 +81,7 @@
return parentId;
}
- /*
- * (non-Javadoc)
+ /**
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj)
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
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -56,8 +56,7 @@
this.acl = acl;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.NodeData#getOrderNumber()
*/
public int getOrderNumber()
@@ -65,8 +64,7 @@
return orderNumber;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.NodeData#getPrimaryTypeName()
*/
public InternalQName getPrimaryTypeName()
@@ -74,8 +72,7 @@
return primaryTypeName;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.NodeData#getMixinTypeNames()
*/
public InternalQName[] getMixinTypeNames()
@@ -83,8 +80,7 @@
return mixinTypeNames;
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.NodeData#getACL()
*/
public AccessControlList getACL()
@@ -92,30 +88,24 @@
return acl;
}
- /*
- * (non-Javadoc)
- * @see
- *
org.exoplatform.services.jcr.datamodel.NodeData#setACL(org.exoplatform.services.jcr.access.
- * AccessControlList)
+ /**
+ * @see
org.exoplatform.services.jcr.datamodel.NodeData#setACL(org.exoplatform.services.jcr.access.AccessControlList)
*/
public void setACL(AccessControlList acl)
{
this.acl = acl;
+ //TODO throw new IllegalStateException("setACL not supported on
PersistedNodeData");
}
- /*
- * (non-Javadoc)
- * @see
- *
org.exoplatform.services.jcr.datamodel.ItemData#accept(org.exoplatform.services.jcr.dataflow
- * .ItemDataVisitor)
+ /**
+ * @see
org.exoplatform.services.jcr.datamodel.ItemData#accept(org.exoplatform.services.jcr.dataflow.ItemDataVisitor)
*/
public void accept(ItemDataVisitor visitor) throws RepositoryException
{
visitor.visit(this);
}
- /*
- * (non-Javadoc)
+ /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#isNode()
*/
public boolean isNode()
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
/**
* Created by The eXo Platform SAS.
@@ -30,13 +31,13 @@
public interface ValueData
{
- /**
- * Set Value order number.
- *
- * @param orderNum
- * int, Value order number
- */
- void setOrderNumber(int orderNum);
+// /**
+// * Set Value order number.
+// *
+// * @param orderNum
+// * int, Value order number
+// */
+// void setOrderNumber(int orderNum);
/**
* Return Value order number.
@@ -79,12 +80,29 @@
* @return long
*/
long getLength();
-
+
/**
- * Tell if this ValueData is transient (not saved).<br/>
- * It means this ValueData instance of <code>TransientValueData<code/>.
+ * Read <code>length</code> bytes from the binary value at
<code>position</code> to the
+ * <code>stream</code>.
*
- * @return boolean, true if ValueData is transient, false - otherwise
+ * @param stream
+ * - destenation OutputStream
+ * @param length
+ * - data length to be read
+ * @param position
+ * - position in value data from which the read will be performed
+ * @return - The number of bytes, possibly zero, that were actually transferred
+ * @throws IOException
+ * if read/write error occurs
*/
- boolean isTransient();
+ long read(OutputStream stream, long length, long position) throws IOException;
+
+ // TODO
+// /**
+// * Tell if this ValueData is transient (not saved).<br/>
+// * It means this ValueData instance of <code>TransientValueData<code/>.
+// *
+// * @return boolean, true if ValueData is transient, false - otherwise
+// */
+// boolean isTransient();
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/Constants.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/Constants.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/Constants.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -667,7 +667,7 @@
* eXo JCR default Strings encoding.
*/
public static final String DEFAULT_ENCODING = "UTF-8";
-
+
/**
* System identifier for remote workspace initializer changes.
*/
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -847,11 +847,11 @@
case PropertyType.STRING :
return new TransientValueData(value.getString());
case PropertyType.BINARY :
- TransientValueData vd = null;
+ ValueData vd;
if (value instanceof BaseValue)
{
// if the value is normaly created in JCR API
- vd = ((BaseValue)value).getInternalData().createTransientCopy();
+ vd = ((BaseValue)value).getInternalData();
}
else if (value instanceof ExtendedValue)
{
@@ -875,17 +875,17 @@
case PropertyType.DATE :
return new TransientValueData(value.getDate());
case PropertyType.PATH :
- TransientValueData tvd = null;
+ ValueData pvd;
if (value instanceof PathValue)
{
- tvd = ((PathValue)value).getInternalData().createTransientCopy();
+ pvd = ((PathValue)value).getInternalData();
}
else
{
QPath pathValue =
locationFactory.parseJCRPath(value.getString()).getInternalPath();
- tvd = new TransientValueData(pathValue);
+ pvd = new TransientValueData(pathValue);
}
- return tvd;
+ return pvd;
case PropertyType.NAME :
InternalQName nameValue =
locationFactory.parseJCRName(value.getString()).getInternalName();
return new TransientValueData(nameValue);
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -327,18 +327,9 @@
return null;
// make a copy, value may be null for deleting items
- List<ValueData> values = null;
- if (prop.getValues() != null)
- {
- values = new ArrayList<ValueData>();
- for (ValueData val : prop.getValues())
- {
- values.add(((AbstractValueData)val).createTransientCopy());
- }
- }
TransientPropertyData newData =
new TransientPropertyData(prop.getQPath(), prop.getIdentifier(),
prop.getPersistedVersion(), prop.getType(),
- prop.getParentIdentifier(), prop.isMultiValued(), values);
+ prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
return newData;
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -2560,7 +2560,7 @@
int state = 0;
if (mergeFailed != null)
{
- mergeFailed = mergeFailed.clone();
+ mergeFailed = mergeFailed.createTransientCopy();
mergeFailedRefs = mergeFailed.getValues();
state = ItemState.UPDATED;
}
@@ -2867,7 +2867,7 @@
// to jcr:predecessors (with doneMerge) or just removed from
// jcr:mergeFailed (with cancelMerge) the jcr:mergeFailed
// property is automatically remove
- changesLog.add(ItemState.createDeletedState(mergeFailed.clone(), true));
+ changesLog.add(ItemState.createDeletedState(mergeFailed.createTransientCopy(),
true));
}
}
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
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -63,7 +63,7 @@
private PropertyDefinitionData propertyDef;
- private TransientPropertyData propertyData;
+ private PropertyData propertyData;
/**
* PropertyImpl constructor.
@@ -87,11 +87,12 @@
void loadData(ItemData data) throws RepositoryException, ConstraintViolationException
{
- if (!(data instanceof TransientPropertyData))
- throw new RepositoryException("Load data: TransientPropertyData is
expected, but have " + data);
+ // TODO
+ //if (!(data instanceof TransientPropertyData))
+ // throw new RepositoryException("Load data: TransientPropertyData is
expected, but have " + data);
this.data = data;
- this.propertyData = (TransientPropertyData)data;
+ this.propertyData = (PropertyData)data;
this.type = propertyData.getType();
this.qpath = data.getQPath();
@@ -135,14 +136,16 @@
checkValid();
- if (isMultiValued())
+ if (isMultiValued()) {
throw new ValueFormatException("The property " + getPath() + " is
multi-valued (6.2.4)");
-
- if (propertyData.getValues() != null && propertyData.getValues().size() ==
0)
+ }
+
+ if (propertyData.getValues() != null && propertyData.getValues().size() ==
0) {
throw new ValueFormatException("The single valued property " +
getPath() + " is empty");
+ }
+
+ return valueFactory.loadValue(propertyData.getValues().get(0),
propertyData.getType());
- return valueFactory.loadValue((TransientValueData)propertyData.getValues().get(0),
propertyData.getType());
-
}
/**
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -113,7 +114,7 @@
/**
* @return Returns the workspDataManager.
*/
- public WorkspaceStorageDataManagerProxy getWorkspaceDataManager()
+ public SharedDataManager getWorkspaceDataManager()
{
return transactionableManager.getStorageDataManager();
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -576,19 +576,9 @@
return null;
// make a copy, value may be null for deleting items
- List<ValueData> values = null;
- if (prop.getValues() != null)
- {
- values = new ArrayList<ValueData>();
- for (ValueData val : prop.getValues())
- {
- values.add(((AbstractValueData)val).createTransientCopy());
- }
- }
-
TransientPropertyData newData =
new TransientPropertyData(prop.getQPath(), prop.getIdentifier(),
prop.getPersistedVersion(), prop.getType(),
- prop.getParentIdentifier(), prop.isMultiValued(), values);
+ prop.getParentIdentifier(), prop.isMultiValued(), prop.getValues());
return newData;
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -345,7 +345,7 @@
for (ValueData value : propertyData.getValues())
{
- if (!constraints.match(((AbstractValueData)value).createTransientCopy(),
propertyData.getType()))
+ if (!constraints.match(value, propertyData.getType()))
{
String strVal = null;
try
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -807,8 +807,7 @@
{
for (final ValueData vdata : propertyData.getValues())
{
- final Value val =
-
valueFactory.loadValue(((AbstractValueData)vdata).createTransientCopy(),
propertyData.getType());
+ final Value val = valueFactory.loadValue(vdata,
propertyData.getType());
if (propertyData.getType() == PropertyType.PATH)
{
if (isPrefixMatch(((PathValue)val).getQPath(), prefix))
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -413,7 +413,7 @@
for (ValueData value : data)
{
- val =
(ExtendedValue)vFactory.loadValue(((AbstractValueData)value).createTransientCopy(),
propType);
+ val = (ExtendedValue)vFactory.loadValue(value, propType);
switch (propType)
{
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BaseValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -20,9 +20,9 @@
import org.exoplatform.services.jcr.core.value.ExtendedValue;
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.AbstractValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -54,7 +54,7 @@
protected LocalTransientValueData data;
- protected TransientValueData internalData;
+ protected ValueData internalData;
/**
* Package-private default constructor.
@@ -64,7 +64,7 @@
* @param data
* TransientValueData
*/
- BaseValue(int type, TransientValueData data)
+ BaseValue(int type, ValueData data)
{
this.type = type;
this.internalData = data;
@@ -239,7 +239,7 @@
/**
* @return Returns the data TransientValueData.
*/
- public TransientValueData getInternalData()
+ public ValueData getInternalData()
{
return internalData;
}
@@ -339,7 +339,7 @@
public LocalTransientValueData(boolean asStream) throws IOException
{
super(getInternalData().getOrderNumber());
- TransientValueData idata = getInternalData();
+ ValueData idata = getInternalData();
if (!asStream)
{
bytes = idata.getAsByteArray();
@@ -380,6 +380,16 @@
{
return length;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public long read(OutputStream stream, long length, long position) throws
IOException
+ {
+ // it's extra feature of eXoJCR, so
+ // read direct from the ValueData, i.e. don't respecting the consumed stream
etc.
+ return getInternalData().read(stream, length, position);
+ }
/**
* {@inheritDoc}
@@ -398,22 +408,5 @@
{
return bytes != null;
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TransientValueData createTransientCopy()
- {
- throw new RuntimeException("LocalTransientValueData.createTransientCopy()
is out of contract");
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransient()
- {
- return true;
- }
}
}
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BinaryValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core.value;
import org.exoplatform.services.jcr.core.value.EditableBinaryValue;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.EditableValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
@@ -84,17 +85,19 @@
}
/** used in ValueFactory.loadValue */
- BinaryValue(TransientValueData data, FileCleaner fileCleaner, File tempDirectory, int
maxFufferSize)
+ BinaryValue(ValueData data, FileCleaner fileCleaner, File tempDirectory, int
maxFufferSize)
throws IOException
{
super(TYPE, data);
- internalData.setFileCleaner(fileCleaner);
- internalData.setTempDirectory(tempDirectory);
- internalData.setMaxBufferSize(maxFufferSize);
+
+ // TODO
+ //internalData.setFileCleaner(fileCleaner);
+ //internalData.setTempDirectory(tempDirectory);
+ //internalData.setMaxBufferSize(maxFufferSize);
}
@Override
- public TransientValueData getInternalData()
+ public ValueData getInternalData()
{
if (changedData != null)
return changedData;
@@ -134,14 +137,15 @@
* */
public void update(InputStream stream, long length, long position) throws IOException,
RepositoryException
{
- if (changedData == null)
- {
- changedData = this.getInternalData().createEditableCopy();
- }
-
- this.changedData.update(stream, length, position);
-
- this.changed = true;
+ // TODO impl it
+// if (changedData == null)
+// {
+// changedData = this.getInternalData().createEditableCopy();
+// }
+//
+// this.changedData.update(stream, length, position);
+//
+// this.changed = true;
}
/**
@@ -152,14 +156,16 @@
*/
public void setLength(long size) throws IOException, RepositoryException
{
- if (changedData == null)
- {
- changedData = this.getInternalData().createEditableCopy();
- }
-
- this.changedData.setLength(size);
-
- this.changed = true;
+
+ // TODO impl it
+// if (changedData == null)
+// {
+// changedData = this.getInternalData().createEditableCopy();
+// }
+//
+// this.changedData.setLength(size);
+//
+// this.changed = true;
}
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BooleanValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BooleanValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/BooleanValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -42,32 +43,29 @@
super(TYPE, new TransientValueData(bool));
}
- public BooleanValue(TransientValueData data) throws IOException
+ public BooleanValue(ValueData data) throws IOException
{
super(TYPE, data);
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDate()
+ /**
+ * {@inheritDoc}
*/
public Calendar getDate() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to date failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getLong()
+ /**
+ * {@inheritDoc}
*/
public long getLong() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to long failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDouble()
+ /**
+ * {@inheritDoc}
*/
public double getDouble() throws ValueFormatException, IllegalStateException,
RepositoryException
{
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DateValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.util.JCRDateFormat;
@@ -54,7 +55,7 @@
super(TYPE, new TransientValueData(date));
}
- DateValue(TransientValueData data) throws IOException
+ DateValue(ValueData data) throws IOException
{
super(TYPE, data);
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DoubleValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DoubleValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/DoubleValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -44,7 +45,7 @@
super(TYPE, new TransientValueData(dbl));
}
- DoubleValue(TransientValueData data) throws IOException
+ DoubleValue(ValueData data) throws IOException
{
super(TYPE, data);
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/LongValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/LongValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/LongValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -45,7 +46,7 @@
super(TYPE, new TransientValueData(l));
}
- LongValue(TransientValueData data) throws IOException
+ LongValue(ValueData data) throws IOException
{
super(TYPE, data);
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/NameValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/NameValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/NameValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.core.JCRName;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
@@ -49,15 +50,14 @@
this.locationFactory = locationFactory;
}
- public NameValue(TransientValueData data, LocationFactory locationFactory) throws
IOException
+ public NameValue(ValueData data, LocationFactory locationFactory) throws IOException
{
super(TYPE, data);
this.locationFactory = locationFactory;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getString()
+ /**
+ * {@inheritDoc}
*/
public String getString() throws ValueFormatException, IllegalStateException,
RepositoryException
{
@@ -65,36 +65,32 @@
return name.getAsString();
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDate()
+ /**
+ * {@inheritDoc}
*/
public Calendar getDate() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to date failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getLong()
+ /**
+ * {@inheritDoc}
*/
public long getLong() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to long failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getBoolean()
+ /**
+ * {@inheritDoc}
*/
public boolean getBoolean() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to boolean failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDouble()
+ /**
+ * {@inheritDoc}
*/
public double getDouble() throws ValueFormatException, IllegalStateException,
RepositoryException
{
@@ -102,7 +98,9 @@
}
/**
- * @return qname
+ * Return name value.
+ *
+ * @return qname InternalQName
* @throws ValueFormatException
* @throws IllegalStateException
* @throws RepositoryException
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PathValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PathValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PathValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core.value;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.core.JCRPath;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
@@ -48,15 +49,14 @@
this.locationFactory = locationFactory;
}
- public PathValue(TransientValueData data, LocationFactory locationFactory) throws
IOException, RepositoryException
+ public PathValue(ValueData data, LocationFactory locationFactory) throws IOException,
RepositoryException
{
super(TYPE, data);
this.locationFactory = locationFactory;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getString()
+ /**
+ * {@inheritDoc}
*/
public String getString() throws ValueFormatException, IllegalStateException,
RepositoryException
{
@@ -64,36 +64,32 @@
return path.getAsString(false);
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDate()
+ /**
+ * {@inheritDoc}
*/
public Calendar getDate() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to date failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getLong()
+ /**
+ * {@inheritDoc}
*/
public long getLong() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to long failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getBoolean()
+ /**
+ * {@inheritDoc}
*/
public boolean getBoolean() throws ValueFormatException, IllegalStateException,
RepositoryException
{
throw new ValueFormatException("conversion to boolean failed: inconvertible
types");
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.impl.core.value.BaseValue#getDouble()
+ /**
+ * {@inheritDoc}
*/
public double getDouble() throws ValueFormatException, IllegalStateException,
RepositoryException
{
@@ -101,7 +97,9 @@
}
/**
- * @return qpath
+ * Return path value.
+ *
+ * @return qpath QPath
* @throws ValueFormatException
* @throws IllegalStateException
* @throws RepositoryException
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/PermissionValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.access.PermissionType;
import org.exoplatform.services.jcr.access.SystemIdentity;
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -46,7 +47,7 @@
private String permission;
- public PermissionValue(TransientValueData data) throws IOException
+ public PermissionValue(ValueData data) throws IOException
{
super(TYPE, data);
@@ -108,6 +109,9 @@
return persArray;
}
+ /**
+ * {@inheritDoc}
+ */
protected String getInternalString() throws ValueFormatException
{
return asString(identity, permission);
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ReferenceValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ReferenceValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ReferenceValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core.value;
import org.exoplatform.services.jcr.datamodel.Identifier;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -47,7 +48,7 @@
this.identifier = identifier;
}
- public ReferenceValue(TransientValueData data) throws IOException,
RepositoryException
+ public ReferenceValue(ValueData data) throws IOException, RepositoryException
{
super(TYPE, data);
this.identifier = new Identifier(getInternalString());
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/StringValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/StringValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/StringValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.core.value;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.IOException;
@@ -47,7 +48,7 @@
* @param data
* @throws IOException
*/
- public StringValue(TransientValueData data) throws IOException
+ public StringValue(ValueData data) throws IOException
{
super(TYPE, data);
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.ExtendedPropertyType;
import org.exoplatform.services.jcr.datamodel.Identifier;
+import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.JCRName;
import org.exoplatform.services.jcr.impl.core.JCRPath;
@@ -383,7 +384,7 @@
* @throws RepositoryException
* if error
*/
- public Value loadValue(TransientValueData data, int type) throws RepositoryException
+ public Value loadValue(ValueData data, int type) throws RepositoryException
{
try
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -104,7 +104,7 @@
List<ValueData> values = new ArrayList<ValueData>();
for (ValueData valueData : property.getValues())
{
- values.add(((TransientValueData)valueData).createTransientCopy());
+ values.add(valueData);
}
boolean mv = property.isMultiValued();
@@ -166,7 +166,7 @@
values.clear();
for (String defValue : pdef.getDefaultValues())
{
- TransientValueData defData;
+ ValueData defData;
if (PropertyType.UNDEFINED == pdef.getRequiredType())
{
defData =
((BaseValue)valueFactory.createValue(defValue)).getInternalData();
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -396,7 +396,7 @@
Map<InternalQName, PropertyData> existedProps = new HashMap<InternalQName,
PropertyData>();
for (PropertyData cp : mergeChildProps)
{
- TransientPropertyData existed = ((TransientPropertyData)cp).clone();
+ TransientPropertyData existed =
((TransientPropertyData)cp).createTransientCopy();
changes.add(new ItemState(existed, ItemState.DELETED, true,
mergedNode.getQPath(), true));
existedProps.put(existed.getQPath().getName(), existed);
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -189,7 +189,7 @@
else
{
// add successor in existed one
- TransientPropertyData newSuccessorsProp = successorsProp.clone();
+ TransientPropertyData newSuccessorsProp = successorsProp.createTransientCopy();
newSuccessorsProp.getValues().add(successorRef);
changesLog.add(ItemState.createUpdatedState(newSuccessorsProp));
}
@@ -215,7 +215,7 @@
else
{
// add successor in existed one
- TransientPropertyData newPredeccessorsProp = predeccessorsProp.clone();
+ TransientPropertyData newPredeccessorsProp =
predeccessorsProp.createTransientCopy();
newPredeccessorsProp.getValues().add(predeccessorRef);
changesLog.add(ItemState.createUpdatedState(newPredeccessorsProp));
}
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
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/AbstractValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -22,8 +22,6 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
-import javax.jcr.RepositoryException;
-
/**
*
* Created by The eXo Platform SAS .
@@ -53,6 +51,4 @@
{
this.orderNumber = orderNumber;
}
-
- public abstract TransientValueData createTransientCopy() throws RepositoryException;
}
Added:
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
(rev 0)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/PersistedValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter
Nedonosko</a>
+ * @version $Id$
+ */
+public abstract class PersistedValueData implements ValueData
+{
+
+ protected int orderNumber;
+
+ protected PersistedValueData(int orderNumber)
+ {
+ this.orderNumber = orderNumber;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final int getOrderNumber()
+ {
+ return orderNumber;
+ }
+
+ /**
+ * Create transient copy of persisted data.
+ *
+ * @return TransientValueData
+ * @throws RepositoryException if error ocurs
+ */
+ public abstract TransientValueData createTransientCopy() throws RepositoryException;
+}
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/PersistedValueData.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientPropertyData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientPropertyData.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientPropertyData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -39,8 +39,7 @@
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:geaz@users.sourceforge.net">Gennady
Azarenkov</a>
- * @version $Id: TransientPropertyData.java 13962 2008-05-07 16:00:48Z
- * pnedonosko $
+ * @version $Id: TransientPropertyData.java 13962 2008-05-07 16:00:48Z pnedonosko $
*/
public class TransientPropertyData extends TransientItemData implements
MutablePropertyData, Externalizable
@@ -219,21 +218,13 @@
/**
* Clone node data without value data!!!
*/
- @Override
- public TransientPropertyData clone()
+ public TransientPropertyData createTransientCopy()
{
List<ValueData> copyValues = new ArrayList<ValueData>();
- try
+ for (ValueData vdata : getValues())
{
- for (ValueData vdata : getValues())
- {
- copyValues.add(((TransientValueData)vdata).createTransientCopy());
- }
+ copyValues.add(vdata);
}
- catch (RepositoryException e)
- {
- throw new RuntimeException(e);
- }
TransientPropertyData dataCopy =
new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(),
getType(),
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
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -375,6 +375,8 @@
*/
public long getLength()
{
+ // TODO try ask on FileChannel (via FileInputStream if have such stream).
+
if (isByteArrayAfterSpool())
{
if (log.isDebugEnabled())
@@ -397,33 +399,65 @@
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;
+// }
+// }
+
/**
- * {@inheritDoc}
+ * Create TransientCopy of data.
+ *
+ * TODO workaround for JBC branch, issued by the FileRestoreTest.
+ *
+ * @return TransientValueData
+ * @throws RepositoryException
*/
- @Override
- public TransientValueData createTransientCopy() throws RepositoryException
+ public TransientValueData createTransientCopy1() throws RepositoryException
{
- if (isByteArray())
+ try
{
- // 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
+ if (isByteArray())
{
- return new TransientValueData(orderNumber, data, // TODO JCR-992
- null, null, fileCleaner, maxBufferSize, tempDirectory, deleteSpoolFile);
+ // bytes based
+ return new TransientValueData(orderNumber, data, null, null, fileCleaner,
maxBufferSize, tempDirectory,
+ deleteSpoolFile);
}
- catch (IOException e)
+ else
{
- throw new RepositoryException(e);
+ // stream (or file) based , i.e. shared across sessions
+ return new TransientValueData(orderNumber, null, getAsStream(), null,
fileCleaner, maxBufferSize,
+ tempDirectory, true);
}
}
- else
+ catch (IOException e)
{
- // stream (or file) based , i.e. shared across sessions
- return this;
+ throw new RepositoryException(e);
}
}
@@ -472,18 +506,7 @@
}
/**
- * Read <code>length</code> bytes from the binary value at
<code>position</code> to the
- * <code>stream</code>.
- *
- * @param stream
- * - destenation OutputStream
- * @param length
- * - data length to be read
- * @param position
- * - position in value data from which the read will be performed
- * @return - The number of bytes, possibly zero, that were actually transferred
- * @throws IOException
- * if read/write error occurs
+ * {@inheritDoc}
*/
public long read(OutputStream stream, long length, long position) throws IOException
{
@@ -539,33 +562,34 @@
return spoolFile;
}
- /**
- * 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();
- }
+ // 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;
+// }
- 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.
*
@@ -900,6 +924,15 @@
}
}
}
+
+ // TODO
+// /**
+// * {@inheritDoc}
+// */
+// public final void setOrderNumber(int orderNumber)
+// {
+// this.orderNumber = orderNumber;
+// }
// ------------- Serializable
@@ -951,7 +984,7 @@
}
/**
- * Set data Stream from outside. FOR Synchronouis replicatiojn only!
+ * Set data Stream from outside. FOR Synchronous replication only!
*
* @param in
* InputStream
@@ -966,12 +999,4 @@
this.spoolFile = null;
this.spoolChannel = null;
}
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransient()
- {
- return isTransient;
- }
}
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
08:01:31 UTC (rev 978)
+++
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
10:10:40 UTC (rev 979)
@@ -18,12 +18,18 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractValueData;
+import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.WritableByteChannel;
import javax.jcr.RepositoryException;
@@ -33,7 +39,7 @@
* @author Gennady Azarenkov
* @version $Id: ByteArrayPersistedValueData.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class ByteArrayPersistedValueData extends AbstractValueData
+public class ByteArrayPersistedValueData extends PersistedValueData
{
protected byte[] data;
@@ -79,6 +85,29 @@
/**
* {@inheritDoc}
*/
+ public long read(OutputStream stream, long length, long position) throws IOException
+ {
+ if (position < 0)
+ throw new IOException("Position must be higher or equals 0. But given
" + position);
+
+ if (length < 0)
+ throw new IOException("Length must be higher or equals 0. But given "
+ length);
+
+ // validation
+ if (position >= data.length && position > 0)
+ throw new IOException("Position " + position + " out of value
size " + data.length);
+
+ if (position + length >= data.length)
+ length = data.length - position;
+
+ stream.write(data, (int)position, (int)length);
+
+ return length;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean isByteArray()
{
return true;
@@ -99,13 +128,4 @@
throw new RepositoryException(e);
}
}
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransient()
- {
- return false;
- }
-
}
Modified:
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CleanableFileStreamValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -21,6 +21,8 @@
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;
@@ -38,6 +40,8 @@
public class CleanableFileStreamValueData extends FileStreamPersistedValueData
{
+ protected final static Log LOG =
ExoLogger.getLogger("jcr.CleanableFileStreamValueData");
+
protected final FileCleaner cleaner;
/**
@@ -74,9 +78,9 @@
{
cleaner.addFile(file);
- if (log.isDebugEnabled())
+ if (LOG.isDebugEnabled())
{
- log.debug("�ould not remove temporary file on finalize: inUse="
+ (((SwapFile)file).inUse()) + ", "
+ LOG.debug("�ould not remove temporary file on finalize: inUse="
+ (((SwapFile)file).inUse()) + ", "
+ file.getAbsolutePath());
}
}
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
08:01:31 UTC (rev 978)
+++
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
10:10:40 UTC (rev 979)
@@ -18,13 +18,19 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractValueData;
+import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
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.MappedByteBuffer;
+import java.nio.channels.Channels;
+import java.nio.channels.FileChannel;
+import java.nio.channels.WritableByteChannel;
import javax.jcr.RepositoryException;
@@ -35,11 +41,13 @@
* @version $Id: FileStreamPersistedValueData.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class FileStreamPersistedValueData extends AbstractValueData
+public class FileStreamPersistedValueData extends PersistedValueData
{
- protected final File file;
+ protected File file;
+ protected FileChannel channel;
+
/**
* FileStreamPersistedValueData constructor.
*
@@ -80,6 +88,44 @@
/**
* {@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;
@@ -100,23 +146,4 @@
throw new RepositoryException(e);
}
}
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransient()
- {
- return false;
- }
-
- // TODO cleanup
- // protected void finalize() throws Throwable {
- // try {
- // if (temp && !file.delete())
- // log.warn("FilePersistedValueData could not remove temporary file on
finalize "
- // + file.getAbsolutePath());
- // } finally {
- // super.finalize();
- // }
- // }
}
Modified:
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/FileStreamTransientValueData.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -103,15 +103,6 @@
* {@inheritDoc}
*/
@Override
- public TransientValueData createTransientCopy() throws RepositoryException
- {
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public File getSpoolFile()
{
return null;
@@ -125,22 +116,4 @@
{
return spoolFile.length();
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setPersistedFile(File spoolFile)
- {
- assert !true : "Set of persistet file is out of contract.";
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTransient()
- {
- return false;
- }
-
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -25,7 +25,7 @@
* Created by The eXo Platform SAS.
*
* @author Gennady Azarenkov
- * @version $Id: LocalWorkspaceDataManagerStub.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public class LocalWorkspaceDataManagerStub extends VersionableWorkspaceDataManager
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LocalWorkspaceDataManagerStub.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added:
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
(rev 0)
+++
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
10:10:40 UTC (rev 979)
@@ -0,0 +1,144 @@
+/*
+ * 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 java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter
Nedonosko</a>
+ * @version $Id$
+ */
+public class StreamPersistedValueData extends FileStreamPersistedValueData
+{
+
+ protected InputStream stream;
+
+ protected File tempFile;
+
+ /**
+ * StreamPersistedValueData constructor.
+ *
+ * @param file File
+ * @param stream InputStream
+ * @param orderNumber int
+ */
+ public StreamPersistedValueData(File file, File tempFile, InputStream stream, int
orderNumber)
+ {
+ super(file, orderNumber);
+ this.tempFile = tempFile;
+ this.stream = stream;
+ }
+
+ public InputStream getStream() throws IOException
+ {
+ return stream;
+ }
+
+ public File getTempFile() throws IOException
+ {
+ return tempFile;
+ }
+
+ public void setPersistedFile(File file)
+ {
+ this.file = file;
+
+ this.tempFile = null;
+ this.stream = null;
+ }
+
+ public boolean isPersisted()
+ {
+ return file != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public InputStream getAsStream() throws IOException
+ {
+ // TODO check if file exists, wait a bit (for replication etc.)
+ return super.getAsStream();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public long getLength()
+ {
+ if (file != null)
+ {
+ return file.length();
+ }
+ else if (tempFile != null)
+ {
+ return tempFile.length();
+ }
+ else if (stream instanceof FileInputStream)
+ {
+ try
+ {
+ return ((FileInputStream)stream).getChannel().size();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ try
+ {
+ return stream.available();
+ }
+ catch (IOException e)
+ {
+ return -1;
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public TransientValueData createTransientCopy() throws RepositoryException
+ {
+ // TODO check logic
+ try
+ {
+ return new FileStreamTransientValueData(file, orderNumber);
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+}
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/StreamPersistedValueData.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -48,7 +48,7 @@
* mix:versionable
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: VersionableWorkspaceDataManager.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public class VersionableWorkspaceDataManager extends
ACLInheritanceSupportedWorkspaceDataManager
@@ -84,19 +84,19 @@
}
return super.getChildNodesData(nodeData);
}
-
+
/**
* {@inheritDoc}
*/
@Override
- public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
{
if (isSystemDescendant(parent.getQPath()) &&
!this.equals(versionDataManager))
{
return versionDataManager.getChildNodesCount(parent);
}
return super.getChildNodesCount(parent);
- }
+ }
/**
* {@inheritDoc}
@@ -177,15 +177,13 @@
return null;
}
- public void save(CompositeChangesLog changesLog) throws RepositoryException,
InvalidItemStateException
+ public void save(final CompositeChangesLog changesLog) throws RepositoryException,
InvalidItemStateException
{
- ChangesLogIterator logIterator = changesLog.getLogIterator();
+ final ChangesLogIterator logIterator = changesLog.getLogIterator();
- boolean saveVersions = false;
- TransactionChangesLog versionLog = new TransactionChangesLog();
- boolean saveNonVersions = false;
- TransactionChangesLog nonVersionLog = new TransactionChangesLog();
+ final TransactionChangesLog versionLogs = new TransactionChangesLog();
+ final TransactionChangesLog nonVersionLogs = new TransactionChangesLog();
while (logIterator.hasNextLog())
{
@@ -196,40 +194,46 @@
for (ItemState change : changes.getAllStates())
{
if (isSystemDescendant(change.getData().getQPath()) &&
!this.equals(versionDataManager))
+ {
vstates.add(change);
+ }
else
+ {
nvstates.add(change);
+ }
}
- String pairId = null;
- if (vstates.size() > 0 && nvstates.size() > 0)
+ if (vstates.size() > 0)
{
- pairId = IdGenerator.generate();
- }
+ if (nvstates.size() > 0)
+ {
+ // we have pair of logs for system and non-system (this) workspaces
+ final String pairId = IdGenerator.generate();
- if (vstates.size() > 0)
- {
- versionLog.addLog((pairId != null) ? new PairChangesLog(vstates,
changes.getSessionId(), changes
- .getEventType(), pairId) : new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes
- .getEventType()));
- saveVersions = true;
+ versionLogs.addLog(new PairChangesLog(vstates, changes.getSessionId(),
changes.getEventType(), pairId));
+ nonVersionLogs.addLog(new PairChangesLog(nvstates, changes.getSessionId(),
changes.getEventType(),
+ pairId));
+ }
+ else
+ {
+ versionLogs.addLog(new PlainChangesLogImpl(vstates,
changes.getSessionId(), changes.getEventType()));
+ }
}
-
- if (nvstates.size() > 0)
+ else if (nvstates.size() > 0)
{
- nonVersionLog.addLog((pairId != null) ? new PairChangesLog(nvstates,
changes.getSessionId(), changes
- .getEventType(), pairId) : new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes
- .getEventType()));
-
- saveNonVersions = true;
+ nonVersionLogs.addLog(new PlainChangesLogImpl(nvstates,
changes.getSessionId(), changes.getEventType()));
}
}
- if (saveVersions)
- versionDataManager.save(versionLog);
+ if (versionLogs.getSize() > 0)
+ {
+ versionDataManager.save(versionLogs);
+ }
- if (saveNonVersions)
- super.save(nonVersionLog);
+ if (nonVersionLogs.getSize() > 0)
+ {
+ super.save(nonVersionLogs);
+ }
}
private boolean isSystemDescendant(QPath path)
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
___________________________________________________________________
Name: svn:keywords
+ Id
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -18,26 +18,37 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.dataflow.ChangesLogIterator;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.PersistentDataManager;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
+import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListenerFilter;
import
org.exoplatform.services.jcr.dataflow.persistent.MandatoryItemsPersistenceListener;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
+import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
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.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
@@ -54,7 +65,7 @@
* instance. Provides read and save operations. Handles listeners on save operation.
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: WorkspacePersistentDataManager.java 34801 2009-07-31 15:44:50Z dkatayev
$
+ * @version $Id$
*/
public abstract class WorkspacePersistentDataManager implements PersistentDataManager
{
@@ -113,6 +124,88 @@
this.systemDataContainer = systemDataContainerHolder.getContainer();
}
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public void save(final ItemStateChangesLog changesLog) throws
RepositoryException
+ // {
+ //
+ // // check if this workspace container is not read-only
+ // if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
+ // throw new ReadOnlyWorkspaceException("Workspace container '"
+ dataContainer.getName() + "' is read-only.");
+ //
+ // final Set<QPath> addedNodes = new HashSet<QPath>();
+ //
+ // WorkspaceStorageConnection thisConnection = null;
+ // WorkspaceStorageConnection systemConnection = null;
+ //
+ // try
+ // {
+ // for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();)
+ // {
+ // ItemState itemState = iter.next();
+ //
+ // if (!itemState.isPersisted())
+ // continue;
+ //
+ // long start = System.currentTimeMillis();
+ //
+ // TransientItemData data = (TransientItemData)itemState.getData();
+ //
+ // WorkspaceStorageConnection conn;
+ // if (isSystemDescendant(data.getQPath()))
+ // {
+ // conn = systemConnection = getSystemConnection(thisConnection,
systemConnection);
+ // }
+ // else
+ // {
+ // conn = thisConnection = getThisConnection(thisConnection,
systemConnection);
+ // }
+ //
+ // data.increasePersistedVersion();
+ //
+ // if (itemState.isAdded())
+ // {
+ // doAdd(data, conn, addedNodes);
+ // }
+ // else if (itemState.isUpdated())
+ // {
+ // doUpdate(data, conn);
+ // }
+ // else if (itemState.isDeleted())
+ // {
+ // doDelete(data, conn);
+ // }
+ // else if (itemState.isRenamed())
+ // {
+ // doRename(data, conn, addedNodes);
+ // }
+ //
+ // if (LOG.isDebugEnabled())
+ // {
+ // LOG.debug(ItemState.nameFromValue(itemState.getState()) + "
" + (System.currentTimeMillis() - start)
+ // + "ms, " + data.getQPath().getAsString());
+ // }
+ // }
+ // if (thisConnection != null)
+ // thisConnection.commit();
+ // if (systemConnection != null &&
!systemConnection.equals(thisConnection))
+ // systemConnection.commit();
+ // }
+ // finally
+ // {
+ // if (thisConnection != null && thisConnection.isOpened())
+ // thisConnection.rollback();
+ // if (systemConnection != null &&
!systemConnection.equals(thisConnection) && systemConnection.isOpened())
+ // systemConnection.rollback();
+ //
+ // // help to GC
+ // addedNodes.clear();
+ // }
+ //
+ // notifySaveItems(changesLog);
+ // }
+
/**
* {@inheritDoc}
*/
@@ -123,108 +216,307 @@
if (readOnly && !(changesLog instanceof ReadOnlyThroughChanges))
throw new ReadOnlyWorkspaceException("Workspace container '" +
dataContainer.getName() + "' is read-only.");
- final Set<QPath> addedNodes = new HashSet<QPath>();
+ //final Set<QPath> addedNodes = new HashSet<QPath>();
+ //WorkspaceStorageConnection thisConnection = null;
+ //WorkspaceStorageConnection systemConnection = null;
- WorkspaceStorageConnection thisConnection = null;
- WorkspaceStorageConnection systemConnection = null;
+ ChangesLogPersister persister = new ChangesLogPersister();
+ // whole log will be reconstructed with persisted data
+ ItemStateChangesLog persistedLog;
+
try
{
- for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();)
+ //List<PlainChangesLog> chengesLogList = new
ArrayList<PlainChangesLog>();
+ if (changesLog instanceof PlainChangesLogImpl)
{
- ItemState itemState = iter.next();
+ persistedLog = persister.save((PlainChangesLogImpl)changesLog);
+ //new PlainChangesLogImpl(new ArrayList<ItemState>(),
prev.getSessionId(), prev.getEventType(), prev.getPairId());
- if (!itemState.isPersisted())
- continue;
+ //chengesLogList.add((PlainChangesLog)changesLog);
+ }
+ else if (changesLog instanceof TransactionChangesLog)
+ {
+ TransactionChangesLog orig = (TransactionChangesLog)changesLog;
- long start = System.currentTimeMillis();
+ TransactionChangesLog persisted = new TransactionChangesLog();
+ persisted.setSystemId(orig.getSystemId());
- TransientItemData data = (TransientItemData)itemState.getData();
+ for (ChangesLogIterator iter = orig.getLogIterator(); iter.hasNextLog();)
+ {
+ persisted.addLog(persister.save(iter.nextLog()));
- WorkspaceStorageConnection conn = null;
- if (isSystemDescendant(data.getQPath()))
- {
- conn = systemConnection == null
- // we need system connection but it's not exist
- ? systemConnection = (systemDataContainer != dataContainer
- // if it's different container instances
- ? systemDataContainer.equals(dataContainer) &&
thisConnection != null
- // but container confugrations are same and non-system connnection
open
- // reuse this connection as system
- ? systemDataContainer.reuseConnection(thisConnection)
- // or open one new system
- : systemDataContainer.openConnection()
- // else if it's same container instances (system and this)
- : thisConnection == null
- // and non-system connection doens't exist - open it
- ? thisConnection = dataContainer.openConnection()
- // if already open - use it
- : thisConnection)
- // system connection opened - use it
- : systemConnection;
+ //chengesLogList.add(iter.nextLog());
}
- else
- {
- conn = thisConnection == null
- // we need this conatiner conection
- ? thisConnection = (systemDataContainer != dataContainer
- // if it's different container instances
- ? dataContainer.equals(systemDataContainer) &&
systemConnection != null
- // but container confugrations are same and system connnection open
- // reuse system connection as this
- ? dataContainer.reuseConnection(systemConnection)
- // or open one new
- : dataContainer.openConnection()
- // else if it's same container instances (system and this)
- : systemConnection == null
- // and system connection doens't exist - open it
- ? systemConnection = dataContainer.openConnection()
- // if already open - use it
- : systemConnection)
- // this connection opened - use it
- : thisConnection;
- }
- data.increasePersistedVersion();
+ persistedLog = persisted;
+ }
+ else
+ {
+ // we don't support other types now... i.e. add else-if for that type
here
+ throw new RepositoryException("Unsupported changes log class " +
changesLog.getClass());
+ }
- if (itemState.isAdded())
- {
- doAdd(data, conn, addedNodes);
- }
- else if (itemState.isUpdated())
- {
- doUpdate(data, conn);
- }
- else if (itemState.isDeleted())
- {
- doDelete(data, conn);
- }
- else if (itemState.isRenamed())
- {
- doRename(data, conn, addedNodes);
- }
+ // for (PlainChangesLog clog : chengesLogList)
+ // {
+ // for (Iterator<ItemState> iter =
clog.getAllStates().iterator(); iter.hasNext();)
+ // {
+ // ItemState itemState = iter.next();
+ //
+ // if (itemState.isPersisted())
+ // {
+ // long start = System.currentTimeMillis();
+ //
+ // TransientItemData data =
(TransientItemData)itemState.getData();
+ //
+ // WorkspaceStorageConnection conn;
+ // if (isSystemDescendant(data.getQPath()))
+ // {
+ // conn = systemConnection =
getSystemConnection(thisConnection, systemConnection);
+ // }
+ // else
+ // {
+ // conn = thisConnection = getThisConnection(thisConnection,
systemConnection);
+ // }
+ //
+ // data.increasePersistedVersion();
+ //
+ // if (itemState.isAdded())
+ // {
+ // doAdd(data, conn, addedNodes);
+ // }
+ // else if (itemState.isUpdated())
+ // {
+ // doUpdate(data, conn);
+ // }
+ // else if (itemState.isDeleted())
+ // {
+ // doDelete(data, conn);
+ // }
+ // else if (itemState.isRenamed())
+ // {
+ // doRename(data, conn, addedNodes);
+ // }
+ //
+ // if (LOG.isDebugEnabled())
+ // {
+ // LOG.debug(ItemState.nameFromValue(itemState.getState()) +
" "
+ // + (System.currentTimeMillis() - start) + "ms,
" + data.getQPath().getAsString());
+ // }
+ // }
+ // }
+ // }
- if (LOG.isDebugEnabled())
- LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " +
(System.currentTimeMillis() - start)
- + "ms, " + data.getQPath().getAsString());
- }
+ // if (thisConnection != null)
+ // thisConnection.commit();
+ // if (systemConnection != null &&
!systemConnection.equals(thisConnection))
+ // systemConnection.commit();
+
+ persister.commit();
+ }
+ catch (IOException e)
+ {
+ throw new RepositoryException("Save error", e);
+ }
+ finally
+ {
+ // if (thisConnection != null && thisConnection.isOpened())
+ // thisConnection.rollback();
+ // if (systemConnection != null &&
!systemConnection.equals(thisConnection) && systemConnection.isOpened())
+ // systemConnection.rollback();
+ //
+ // // help to GC
+ // addedNodes.clear();
+
+ persister.rollback();
+ }
+
+ notifySaveItems(persistedLog);
+ }
+
+ class ChangesLogPersister
+ {
+
+ private final Set<QPath> addedNodes = new HashSet<QPath>();
+
+ private WorkspaceStorageConnection thisConnection = null;
+
+ private WorkspaceStorageConnection systemConnection = null;
+
+ protected void commit() throws IllegalStateException, RepositoryException
+ {
if (thisConnection != null)
+ {
thisConnection.commit();
+ }
if (systemConnection != null &&
!systemConnection.equals(thisConnection))
+ {
systemConnection.commit();
+ }
}
- finally
+
+ protected void rollback() throws IllegalStateException, RepositoryException
{
if (thisConnection != null && thisConnection.isOpened())
+ {
thisConnection.rollback();
+ }
if (systemConnection != null && !systemConnection.equals(thisConnection)
&& systemConnection.isOpened())
+ {
systemConnection.rollback();
+ }
// help to GC
addedNodes.clear();
}
- notifySaveItems(changesLog);
+ protected WorkspaceStorageConnection getSystemConnection() throws
RepositoryException
+ {
+ return thisConnection = systemConnection == null
+ // we need system connection but it's not exist
+ ? (systemDataContainer != dataContainer
+ // if it's different container instances
+ ? systemDataContainer.equals(dataContainer) && thisConnection !=
null
+ // but container confugrations are same and non-system connnection open
+ // reuse this connection as system
+ ? systemDataContainer.reuseConnection(thisConnection)
+ // or open one new system
+ : systemDataContainer.openConnection()
+ // else if it's same container instances (system and this)
+ : thisConnection == null
+ // and non-system connection doens't exist - open it
+ ? thisConnection = dataContainer.openConnection()
+ // if already open - use it
+ : thisConnection)
+ // system connection opened - use it
+ : systemConnection;
+ }
+
+ protected WorkspaceStorageConnection getThisConnection() throws
RepositoryException
+ {
+ return thisConnection = thisConnection == null
+ // we need this conatiner conection
+ ? (systemDataContainer != dataContainer
+ // if it's different container instances
+ ? dataContainer.equals(systemDataContainer) && systemConnection !=
null
+ // but container confugrations are same and system connnection open
+ // reuse system connection as this
+ ? dataContainer.reuseConnection(systemConnection)
+ // or open one new
+ : dataContainer.openConnection()
+ // else if it's same container instances (system and this)
+ : systemConnection == null
+ // and system connection doens't exist - open it
+ ? systemConnection = dataContainer.openConnection()
+ // if already open - use it
+ : systemConnection)
+ // this connection opened - use it
+ : thisConnection;
+ }
+
+ protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws
InvalidItemStateException,
+ RepositoryException, IOException
+ {
+ // copy state
+ PlainChangesLogImpl newLog =
+ new PlainChangesLogImpl(new ArrayList<ItemState>(),
changesLog.getSessionId(), changesLog.getEventType(),
+ changesLog.getPairId());
+
+ for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();)
+ {
+ ItemState prevState = iter.next();
+
+ ItemData newData;
+ if (prevState.isNode())
+ {
+ NodeData prevData = (NodeData)prevState.getData();
+ newData =
+ new PersistedNodeData(prevData.getIdentifier(), prevData.getQPath(),
prevData.getParentIdentifier(),
+ prevData.getPersistedVersion() + 1, prevData.getOrderNumber(),
prevData.getPrimaryTypeName(),
+ prevData.getMixinTypeNames(), prevData.getACL());
+ }
+ else
+ {
+ TransientPropertyData prevData =
(TransientPropertyData)prevState.getData();
+
+ List<ValueData> values = new ArrayList<ValueData>();
+ for (ValueData vd : prevData.getValues())
+ {
+ if (vd.isByteArray())
+ {
+ values.add(new ByteArrayPersistedValueData(vd.getAsByteArray(),
vd.getOrderNumber()));
+ }
+ 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;
+
+ TransientValueData tvd = (TransientValueData)vd;
+
+ // TODO review of TransientValueData logic about get stream and
file, to be sure we got a
+ values.add(new StreamPersistedValueData(destFile,
tvd.getSpoolFile(), tvd.getSpoolFile() == null
+ ? tvd.getAsStream(false) : null, vd.getOrderNumber()));
+ }
+ }
+
+ newData =
+ new PersistedPropertyData(prevData.getIdentifier(),
prevData.getQPath(), prevData
+ .getParentIdentifier(), prevData.getPersistedVersion() + 1,
prevData.getType(), prevData
+ .isMultiValued(), values);
+ }
+
+ ItemState itemState =
+ new ItemState(newData, prevState.getState(), prevState.isEventFire(),
prevState.getAncestorToSave(),
+ prevState.isInternallyCreated(), prevState.isPersisted());
+
+ newLog.add(itemState);
+
+ // save state
+ if (itemState.isPersisted())
+ {
+ long start = System.currentTimeMillis();
+
+ ItemData data = itemState.getData();
+
+ WorkspaceStorageConnection conn;
+ if (isSystemDescendant(data.getQPath()))
+ {
+ conn = getSystemConnection();
+ }
+ else
+ {
+ conn = getThisConnection();
+ }
+
+ if (itemState.isAdded())
+ {
+ doAdd(data, conn, addedNodes);
+ }
+ else if (itemState.isUpdated())
+ {
+ doUpdate(data, conn);
+ }
+ else if (itemState.isDeleted())
+ {
+ doDelete(data, conn);
+ }
+ else if (itemState.isRenamed())
+ {
+ doRename(data, conn, addedNodes);
+ }
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(ItemState.nameFromValue(itemState.getState()) + " "
+ (System.currentTimeMillis() - start)
+ + "ms, " + data.getQPath().getAsString());
+ }
+ }
+ }
+ return newLog;
+ }
+
}
/**
@@ -290,7 +582,7 @@
con.close();
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -305,7 +597,7 @@
{
con.close();
}
- }
+ }
/**
* {@inheritDoc}
@@ -399,7 +691,7 @@
* @throws InvalidItemStateException
* if the item is already deleted
*/
- protected void doDelete(final TransientItemData item, final WorkspaceStorageConnection
con)
+ protected void doDelete(final ItemData item, final WorkspaceStorageConnection con)
throws RepositoryException, InvalidItemStateException
{
@@ -420,7 +712,7 @@
* @throws InvalidItemStateException
* if the item not found TODO compare persistedVersion number
*/
- protected void doUpdate(final TransientItemData item, final WorkspaceStorageConnection
con)
+ protected void doUpdate(final ItemData item, final WorkspaceStorageConnection con)
throws RepositoryException, InvalidItemStateException
{
@@ -445,7 +737,7 @@
* @throws InvalidItemStateException
* if the item is already added
*/
- protected void doAdd(final TransientItemData item, final WorkspaceStorageConnection
con, final Set<QPath> addedNodes)
+ protected void doAdd(final ItemData item, final WorkspaceStorageConnection con, final
Set<QPath> addedNodes)
throws RepositoryException, InvalidItemStateException
{
@@ -473,7 +765,7 @@
* @throws RepositoryException
* @throws InvalidItemStateException
*/
- protected void doRename(final TransientItemData item, final WorkspaceStorageConnection
con,
+ protected void doRename(final ItemData item, final WorkspaceStorageConnection con,
final Set<QPath> addedNodes) throws RepositoryException,
InvalidItemStateException
{
final NodeData node = (NodeData)item;
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -32,7 +32,7 @@
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
-import org.exoplatform.services.jcr.impl.dataflow.AbstractValueData;
+import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
@@ -195,7 +195,7 @@
values = new ArrayList<ValueData>();
for (ValueData val : prop.getValues())
{
- values.add(((AbstractValueData)val).createTransientCopy());
+ values.add(((PersistedValueData)val).createTransientCopy());
}
}
TransientPropertyData newData =
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
+import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -48,7 +49,7 @@
public class TransactionableDataManager implements TransactionResource, DataManager
{
- private WorkspaceStorageDataManagerProxy storageDataManager;
+ private SharedDataManager storageDataManager;
protected static Log log =
ExoLogger.getLogger("jcr.TransactionableDataManager");
@@ -58,15 +59,18 @@
throws RepositoryException
{
super();
- try
- {
- this.storageDataManager = new LocalWorkspaceStorageDataManagerProxy(dataManager,
session.getValueFactory());
- }
- catch (Exception e1)
- {
- String infoString = "[Error of read value factory: " + e1.getMessage()
+ "]";
- throw new RepositoryException(infoString);
- }
+ this.storageDataManager = dataManager;
+
+ // TODO EXOJCR-272
+// try
+// {
+// this.storageDataManager = new
LocalWorkspaceStorageDataManagerProxy(dataManager, session.getValueFactory());
+// }
+// catch (Exception e1)
+// {
+// String infoString = "[Error of read value factory: " +
e1.getMessage() + "]";
+// throw new RepositoryException(infoString);
+// }
}
// --------------- ItemDataConsumer --------
@@ -296,7 +300,7 @@
return txStarted() && transactionLog.getSize() > 0;
}
- public WorkspaceStorageDataManagerProxy getStorageDataManager()
+ public SharedDataManager getStorageDataManager()
{
return storageDataManager;
}
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-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -35,6 +35,7 @@
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.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
import org.exoplatform.services.jcr.impl.storage.value.ValueStorageNotFoundException;
import org.exoplatform.services.jcr.impl.storage.value.fs.operations.ValueFileIOHelper;
@@ -1842,15 +1843,16 @@
* database error
* @throws IOException
* I/O error
+ * @thorws RepositoryException if Value data large of JDBC accepted
(Integer.MAX_VALUE)
*/
- protected void addValues(String cid, PropertyData data) throws IOException,
SQLException
+ protected void addValues(String cid, PropertyData data) throws IOException,
SQLException, RepositoryException
{
List<ValueData> vdata = data.getValues();
for (int i = 0; i < vdata.size(); i++)
{
ValueData vd = vdata.get(i);
- vd.setOrderNumber(i);
+ // TODO vd.setOrderNumber(i);
ValueIOChannel channel = valueStorageProvider.getApplicableChannel(data, i);
InputStream stream;
int streamLength;
@@ -1866,9 +1868,25 @@
}
else
{
- // will spool TransienValueData to a temp file
- stream = vd.getAsStream();
- streamLength = stream.available(); // ask on FileInputStream actually
+ // it's StreamPersistedValueData
+ StreamPersistedValueData streamData = (StreamPersistedValueData)vd;
+ stream = streamData.getStream();
+ long vlen = streamData.getLength();
+ if (vlen < 0)
+ {
+ streamLength = stream.available();
+ LOG.warn("Cannot obtain exact Value data length, will use
available from the stream " + streamLength
+ + ". Property " + data.getQPath().getAsString());
+ }
+ else if (vlen <= Integer.MAX_VALUE)
+ {
+ streamLength = (int)vlen;
+ }
+ else
+ {
+ throw new RepositoryException("Value data large of allowed by JDBC
(Integer.MAX_VALUE) " + vlen
+ + ". Property " + data.getQPath().getAsString());
+ }
}
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/CASableWriteValue.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/CASableWriteValue.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -19,7 +19,7 @@
package org.exoplatform.services.jcr.impl.storage.value.fs.operations;
import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.StreamPersistedValueData;
import org.exoplatform.services.jcr.impl.storage.value.ValueDataResourceHolder;
import org.exoplatform.services.jcr.impl.storage.value.cas.RecordAlreadyExistsException;
import org.exoplatform.services.jcr.impl.storage.value.cas.VCASException;
@@ -180,9 +180,11 @@
+ vcasFile.getAbsolutePath());
} // else - CASed Value already exists
- // set new spool file as persisted
- if (value.isTransient() && !value.isByteArray())
- ((TransientValueData)value).setPersistedFile(vcasFile);
+ // set persisted file
+ if (!value.isByteArray())
+ {
+ ((StreamPersistedValueData)value).setPersistedFile(vcasFile);
+ }
}
finally
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-10
08:01:31 UTC (rev 978)
+++
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-10
10:10:40 UTC (rev 979)
@@ -19,9 +19,9 @@
package org.exoplatform.services.jcr.impl.storage.value.fs.operations;
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.StreamPersistedValueData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -75,17 +75,17 @@
protected ValueData readValue(File file, int orderNum, int maxBufferSize) throws
IOException
{
- FileInputStream is = new FileInputStream(file);
- try
- {
- long fileSize = file.length();
+ long fileSize = file.length();
- if (fileSize > maxBufferSize)
+ if (fileSize > maxBufferSize)
+ {
+ return new FileStreamPersistedValueData(file, orderNum);
+ }
+ else
+ {
+ FileInputStream is = new FileInputStream(file);
+ try
{
- return new FileStreamPersistedValueData(file, orderNum);
- }
- else
- {
int buffSize = (int)fileSize;
byte[] res = new byte[buffSize];
int rpos = 0;
@@ -96,14 +96,13 @@
System.arraycopy(buff, 0, res, rpos, r);
rpos += r;
}
-
return new ByteArrayPersistedValueData(res, orderNum);
}
+ finally
+ {
+ is.close();
+ }
}
- finally
- {
- is.close();
- }
}
/**
@@ -118,9 +117,9 @@
*/
protected void writeValue(File file, ValueData value) throws IOException
{
- TransientValueData tvalue = (TransientValueData)value;
+ StreamPersistedValueData streamValue = (StreamPersistedValueData)value;
- if (tvalue.isByteArray())
+ if (streamValue.isByteArray())
{
OutputStream out = new FileOutputStream(file);
try
@@ -134,34 +133,31 @@
}
else
{
- if (tvalue.isTransient())
+ // transient Value
+ File tempFile;
+ if ((tempFile = streamValue.getTempFile()) != null)
{
- // transient Value
- File spoolFile;
- if ((spoolFile = tvalue.getSpoolFile()) != null)
+ // it's spooled Value, try move its file to VS
+ if (!tempFile.renameTo(file))
{
- // it's spooled Value, try move its file to VS
- if (!spoolFile.renameTo(file))
+ // not succeeded - copy bytes
+ if (LOG.isDebugEnabled())
{
- // not succeeded - copy bytes
- if (LOG.isDebugEnabled())
- LOG
- .debug("Value spool file move (rename) to Values Storage is
not succeeded. Trying bytes copy. Spool file: "
- + spoolFile.getAbsolutePath() + ". Destination: " +
file.getAbsolutePath());
-
- copyClose(new FileInputStream(spoolFile), new FileOutputStream(file));
+ LOG
+ .debug("Value spool file move (rename) to Values Storage is not
succeeded. Trying bytes copy. Spool file: "
+ + tempFile.getAbsolutePath() + ". Destination: " +
file.getAbsolutePath());
}
- }
- else
- // not spooled, use InputStream
- copyClose(tvalue.getAsStream(false), new FileOutputStream(file));
- // map this transient Value to file in VS
- ((TransientValueData)value).setPersistedFile(file);
+ copyClose(new FileInputStream(tempFile), new FileOutputStream(file));
+ }
}
else
- // persisted Value returned from Session, use InputStream on file from VS
- copyClose(tvalue.getAsStream(false), new FileOutputStream(file));
+ {
+ // not spooled, use InputStream
+ copyClose(streamValue.getAsStream(), new FileOutputStream(file));
+ }
+ // map this transient Value to file in VS
+ streamValue.setPersistedFile(file);
}
}
@@ -184,7 +180,7 @@
}
else
{
- InputStream in = ((TransientValueData)value).getAsStream(false);
+ InputStream in = ((StreamPersistedValueData)value).getStream();
try
{
copy(in, out);
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -30,15 +30,14 @@
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov</a>
- * @version $Id: ValueStoragePlugin.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public abstract class ValueStoragePlugin
{
-
protected List<ValuePluginFilter> filters;
- protected String id;
+ protected String id = null;
/**
* Initialize this plugin. Used at start time.
@@ -87,7 +86,7 @@
}
/**
- * Get Stirage Id.
+ * Get Storage Id.
*
* @return String
*/
@@ -97,14 +96,17 @@
}
/**
- * Set Storage Id.
+ * Set Storage Id. Id can be set once only.
*
* @param id
* String
*/
public final void setId(String id)
{
- this.id = id;
+ if (this.id == null)
+ {
+ this.id = id;
+ }
}
/**
Property changes on:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/value/ValueStoragePlugin.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java 2009-12-10
08:01:31 UTC (rev 978)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java 2009-12-10
10:10:40 UTC (rev 979)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
@@ -67,7 +68,7 @@
{
SessionDataManager sdm = session.getTransientNodesManager();
TransactionableDataManager trm = sdm.getTransactManager();
- WorkspaceStorageDataManagerProxy wdm = trm.getStorageDataManager();
+ SharedDataManager wdm = trm.getStorageDataManager();
CompositeChangesLog clog = new TransactionChangesLog();
PlainChangesLogImpl changes = new PlainChangesLogImpl();
@@ -86,7 +87,7 @@
{
SessionDataManager sdm = session.getTransientNodesManager();
TransactionableDataManager trm = sdm.getTransactManager();
- WorkspaceStorageDataManagerProxy wdm = trm.getStorageDataManager();
+ SharedDataManager wdm = trm.getStorageDataManager();
NodeData rootData = (NodeData)wdm.getItemData(Constants.ROOT_UUID);
@@ -159,7 +160,7 @@
{
SessionDataManager sdm = session.getTransientNodesManager();
TransactionableDataManager trm = sdm.getTransactManager();
- WorkspaceStorageDataManagerProxy wdm = trm.getStorageDataManager();
+ SharedDataManager wdm = trm.getStorageDataManager();
NodeData rootData = (NodeData)wdm.getItemData(Constants.ROOT_UUID);