exo-jcr SVN: r984 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/value and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-10 07:17:44 -0500 (Thu, 10 Dec 2009)
New Revision: 984
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/PropertyImpl.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/VersionImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
Log:
EXOJCR-274 save can accept persistent data also now; VersionImpl data-flow rework.
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 11:28:57 UTC (rev 983)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-10 12:17:44 UTC (rev 984)
@@ -389,19 +389,20 @@
{
QPath qpath = QPath.makeChildPath(parentNode.getInternalPath(), propertyName);
+
int state;
String identifier;
int version;
- PropertyImpl oldProp = null;
- ItemImpl oldItem = dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true);
- PropertyDefinitionDatas defs = null;
+ PropertyImpl prevProp;
+ PropertyDefinitionDatas defs;
+ ItemImpl prevItem = dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true);
NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
NodeData parentData = (NodeData)parentNode.getData();
boolean isMultiValue = multiValue;
- if (oldItem == null || oldItem.isNode())
- { // new prop
+ if (prevItem == null || prevItem.isNode())
+ { // new property
identifier = IdGenerator.generate();
version = -1;
if (propertyValues == null)
@@ -416,18 +417,19 @@
}
defs =
ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
-
+ prevProp = null;
state = ItemState.ADDED;
}
else
{
- oldProp = (PropertyImpl)oldItem;
- isMultiValue = oldProp.isMultiValued();
+ // update of the property
+ prevProp = (PropertyImpl)prevItem;
+ isMultiValue = prevProp.isMultiValued();
defs =
ntm.getPropertyDefinitions(propertyName, parentData.getPrimaryTypeName(), parentData.getMixinTypeNames());
- identifier = oldProp.getInternalIdentifier();
- version = oldProp.getData().getPersistedVersion();
+ identifier = prevProp.getInternalIdentifier();
+ version = prevProp.getData().getPersistedVersion();
if (propertyValues == null)
state = ItemState.DELETED;
else
@@ -435,6 +437,7 @@
state = ItemState.UPDATED;
}
}
+
if (defs == null || defs.getAnyDefinition() == null)
throw new RepositoryException("Property definition '" + propertyName.getAsString() + "' is not found.");
@@ -443,22 +446,23 @@
throw new ConstraintViolationException("Can not set protected property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
- if (multiValue && (def == null || (oldProp != null && !oldProp.isMultiValued())))
+ if (multiValue && (def == null || (prevProp != null && !prevProp.isMultiValued())))
{
throw new ValueFormatException("Can not assign multiple-values Value to a single-valued property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
}
- if (!multiValue && (def == null || (oldProp != null && oldProp.isMultiValued())))
+ if (!multiValue && (def == null || (prevProp != null && prevProp.isMultiValued())))
{
throw new ValueFormatException("Can not assign single-value Value to a multiple-valued property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
}
+ // Check if checked-in (versionable)
if (!parentNode.checkedOut())
throw new VersionException("Node " + parentNode.getPath() + " or its nearest ancestor is checked-in");
- // Check locking
+ // Check is locked
if (!parentNode.checkLocking())
throw new LockException("Node " + parentNode.getPath() + " is locked ");
@@ -532,18 +536,19 @@
+ "type of the property do not match required type" + ExtendedPropertyType.nameFromValue(requiredType));
}
- PropertyImpl prop = null;
+ PropertyImpl prop;
if (state != ItemState.DELETED)
{
+ // add or update
TransientPropertyData newData =
new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
multiValue, valueDataList);
ItemState itemState = new ItemState(newData, state, true, qpath, false);
prop = (PropertyImpl)dataManager.update(itemState, true);
- // launch event
+
+ // launch event: post-set
session.getActionHandler().postSetProperty(prop, state);
-
}
else
{
@@ -552,14 +557,16 @@
throw new ConstraintViolationException("Can not remove (by setting null value) mandatory property "
+ locationFactory.createJCRPath(qpath).getAsString(false));
}
+
TransientPropertyData newData =
new TransientPropertyData(qpath, identifier, version, propType, parentNode.getInternalIdentifier(),
multiValue);
- // launch event
- session.getActionHandler().preRemoveItem(oldProp);
+ // launch event: pre-remove
+ session.getActionHandler().preRemoveItem(prevProp);
+
dataManager.delete(newData);
- prop = oldProp;
+ prop = prevProp;
}
return prop;
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 11:28:57 UTC (rev 983)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2009-12-10 12:17:44 UTC (rev 984)
@@ -108,11 +108,11 @@
ConstraintViolationException
{
- if (!(data instanceof TransientPropertyData))
- throw new RepositoryException("Load data: TransientPropertyData is expected, but have " + data);
+ //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.location = null;
@@ -136,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());
}
@@ -352,8 +354,10 @@
session.getWorkspace().getNodeTypesHolder().getPropertyDefinitions(pname, parent.getPrimaryTypeName(),
parent.getMixinTypeNames());
if (definitions == null)
+ {
throw new ConstraintViolationException("Definition for property " + getPath() + " not found.");
-
+ }
+
propertyDef = definitions.getDefinition(multiple);
}
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 11:28:57 UTC (rev 983)
+++ 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 12:17:44 UTC (rev 984)
@@ -377,7 +377,7 @@
* Creates new Value object using ValueData
*
* @param data
- * TransientValueData
+ * ValueData
* @param type
* int
* @return Value
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 11:28:57 UTC (rev 983)
+++ 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 12:17:44 UTC (rev 984)
@@ -59,14 +59,16 @@
public VersionImpl(NodeData data, SessionImpl session) throws PathNotFoundException, RepositoryException
{
-
super(data, session);
if (!this.isNodeType(Constants.NT_VERSION))
+ {
throw new RepositoryException("Node " + getLocation().getAsString(true) + " is not nt:version type");
+ }
}
@Override
+ /* needed for VersionHistoryImpl.removeVersion */
protected void invalidate()
{
super.invalidate();
@@ -77,17 +79,16 @@
*/
public Calendar getCreated() throws RepositoryException
{
-
checkValid();
PropertyData pdata = (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_CREATED, 0));
if (pdata == null)
+ {
throw new VersionException("jcr:created property is not found for version " + getPath());
+ }
- Value created =
- session.getValueFactory().loadValue((TransientValueData)pdata.getValues().get(0), pdata.getType());
-
+ Value created = session.getValueFactory().loadValue(pdata.getValues().get(0), pdata.getType());
return created.getDate();
}
@@ -96,14 +97,15 @@
*/
public Version[] getSuccessors() throws RepositoryException
{
-
checkValid();
PropertyData successorsData =
(PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
if (successorsData == null)
+ {
return new Version[0];
+ }
List<ValueData> successorsValues = successorsData.getValues();
Version[] successors = new Version[successorsValues.size()];
@@ -127,7 +129,6 @@
}
return successors;
-
}
/**
@@ -135,7 +136,6 @@
*/
public Version[] getPredecessors() throws RepositoryException
{
-
checkValid();
PropertyData predecessorsData =
@@ -166,15 +166,14 @@
}
return predecessors;
-
}
public void addSuccessor(String successorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
ValueData successorRef = new TransientValueData(new Identifier(successorIdentifier));
- TransientPropertyData successorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ PropertyData successorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
if (successorsProp == null)
{
@@ -188,20 +187,29 @@
}
else
{
- // add successor in existed one
- TransientPropertyData newSuccessorsProp = successorsProp.createTransientCopy();
- newSuccessorsProp.getValues().add(successorRef);
+ // add successor
+ List<ValueData> newSuccessorsValue = new ArrayList<ValueData>();
+ for (ValueData svd : successorsProp.getValues())
+ {
+ newSuccessorsValue.add(svd);
+ }
+ newSuccessorsValue.add(successorRef);
+
+ TransientPropertyData newSuccessorsProp =
+ new TransientPropertyData(successorsProp.getQPath(), successorsProp.getIdentifier(), successorsProp
+ .getPersistedVersion(), successorsProp.getType(), successorsProp.getParentIdentifier(), successorsProp
+ .isMultiValued(), newSuccessorsValue);
+
changesLog.add(ItemState.createUpdatedState(newSuccessorsProp));
}
}
public void addPredecessor(String predeccessorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
-
ValueData predeccessorRef = new TransientValueData(new Identifier(predeccessorIdentifier));
- TransientPropertyData predeccessorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ PropertyData predeccessorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
if (predeccessorsProp == null)
{
@@ -214,17 +222,27 @@
}
else
{
- // add successor in existed one
- TransientPropertyData newPredeccessorsProp = predeccessorsProp.createTransientCopy();
- newPredeccessorsProp.getValues().add(predeccessorRef);
+ // add predeccessor
+ List<ValueData> newPredeccessorValue = new ArrayList<ValueData>();
+ for (ValueData svd : predeccessorsProp.getValues())
+ {
+ newPredeccessorValue.add(svd);
+ }
+ newPredeccessorValue.add(predeccessorRef);
+
+ TransientPropertyData newPredeccessorsProp =
+ new TransientPropertyData(predeccessorsProp.getQPath(), predeccessorsProp.getIdentifier(),
+ predeccessorsProp.getPersistedVersion(), predeccessorsProp.getType(), predeccessorsProp
+ .getParentIdentifier(), predeccessorsProp.isMultiValued(), newPredeccessorValue);
+
changesLog.add(ItemState.createUpdatedState(newPredeccessorsProp));
}
}
void removeSuccessor(String successorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
- TransientPropertyData successorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ PropertyData successorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
if (successorsProp != null)
{
List<ValueData> newSuccessors = new ArrayList<ValueData>();
@@ -234,7 +252,9 @@
for (ValueData sdata : successorsProp.getValues())
{
if (!successorIdentifier.equals(new String(sdata.getAsByteArray())))
+ {
newSuccessors.add(sdata);
+ }
}
}
catch (IOException e)
@@ -246,6 +266,7 @@
new TransientPropertyData(QPath.makeChildPath(nodeData().getQPath(), Constants.JCR_SUCCESSORS,
successorsProp.getQPath().getIndex()), successorsProp.getIdentifier(), successorsProp
.getPersistedVersion(), PropertyType.REFERENCE, nodeData().getIdentifier(), true, newSuccessors);
+
changesLog.add(ItemState.createUpdatedState(newSuccessorsProp));
}
else
@@ -258,8 +279,8 @@
PlainChangesLog changesLog) throws RepositoryException
{
- TransientPropertyData successorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ PropertyData successorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
if (successorsProp != null)
{
@@ -270,7 +291,9 @@
for (ValueData sdata : successorsProp.getValues())
{
if (!removedSuccessorIdentifier.equals(new String(sdata.getAsByteArray())))
+ {
newSuccessors.add(sdata);
+ }
}
}
catch (IOException e)
@@ -284,6 +307,7 @@
new TransientPropertyData(QPath.makeChildPath(nodeData().getQPath(), Constants.JCR_SUCCESSORS,
successorsProp.getQPath().getIndex()), successorsProp.getIdentifier(), successorsProp
.getPersistedVersion(), PropertyType.REFERENCE, nodeData().getIdentifier(), true, newSuccessors);
+
changesLog.add(ItemState.createUpdatedState(newSuccessorsProp));
}
else
@@ -294,8 +318,8 @@
void removePredecessor(String predecessorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
- TransientPropertyData predeccessorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ PropertyData predeccessorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
if (predeccessorsProp != null)
{
@@ -306,7 +330,9 @@
for (ValueData sdata : predeccessorsProp.getValues())
{
if (!predecessorIdentifier.equals(new String(sdata.getAsByteArray())))
+ {
newPredeccessors.add(sdata);
+ }
}
}
catch (IOException e)
@@ -318,6 +344,7 @@
new TransientPropertyData(QPath.makeChildPath(nodeData().getQPath(), Constants.JCR_PREDECESSORS,
predeccessorsProp.getQPath().getIndex()), predeccessorsProp.getIdentifier(), predeccessorsProp
.getPersistedVersion(), PropertyType.REFERENCE, nodeData().getIdentifier(), true, newPredeccessors);
+
changesLog.add(ItemState.createUpdatedState(newPredecessorsProp));
}
else
@@ -330,8 +357,8 @@
PlainChangesLog changesLog) throws RepositoryException
{
- TransientPropertyData predeccessorsProp =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ PropertyData predeccessorsProp =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
if (predeccessorsProp != null)
{
@@ -342,7 +369,9 @@
for (ValueData sdata : predeccessorsProp.getValues())
{
if (!removedPredecessorIdentifier.equals(new String(sdata.getAsByteArray())))
+ {
newPredeccessors.add(sdata);
+ }
}
}
catch (IOException e)
@@ -356,6 +385,7 @@
new TransientPropertyData(QPath.makeChildPath(nodeData().getQPath(), Constants.JCR_PREDECESSORS,
predeccessorsProp.getQPath().getIndex()), predeccessorsProp.getIdentifier(), predeccessorsProp
.getPersistedVersion(), PropertyType.REFERENCE, nodeData().getIdentifier(), true, newPredeccessors);
+
changesLog.add(ItemState.createUpdatedState(newPredecessorsProp));
}
else
@@ -376,7 +406,9 @@
(VersionHistoryImpl)dataManager.getItemByIdentifier(nodeData().getParentIdentifier(), true);
if (vhistory == null)
+ {
throw new VersionException("Version history item is not found for version " + getPath());
+ }
return vhistory;
}
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 11:28:57 UTC (rev 983)
+++ 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 12:17:44 UTC (rev 984)
@@ -38,8 +38,7 @@
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.PersistedValueData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
@@ -124,6 +123,7 @@
this.systemDataContainer = systemDataContainerHolder.getContainer();
}
+ // TODO cleanup prev impl
// /**
// * {@inheritDoc}
// */
@@ -216,10 +216,6 @@
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;
-
ChangesLogPersister persister = new ChangesLogPersister();
// whole log will be reconstructed with persisted data
@@ -227,13 +223,9 @@
try
{
- //List<PlainChangesLog> chengesLogList = new ArrayList<PlainChangesLog>();
if (changesLog instanceof PlainChangesLogImpl)
{
persistedLog = persister.save((PlainChangesLogImpl)changesLog);
- //new PlainChangesLogImpl(new ArrayList<ItemState>(), prev.getSessionId(), prev.getEventType(), prev.getPairId());
-
- //chengesLogList.add((PlainChangesLog)changesLog);
}
else if (changesLog instanceof TransactionChangesLog)
{
@@ -245,8 +237,6 @@
for (ChangesLogIterator iter = orig.getLogIterator(); iter.hasNextLog();)
{
persisted.addLog(persister.save(iter.nextLog()));
-
- //chengesLogList.add(iter.nextLog());
}
persistedLog = persisted;
@@ -257,6 +247,7 @@
throw new RepositoryException("Unsupported changes log class " + changesLog.getClass());
}
+ // TODO cleanup prev impl
// for (PlainChangesLog clog : chengesLogList)
// {
// for (Iterator<ItemState> iter = clog.getAllStates().iterator(); iter.hasNext();)
@@ -306,12 +297,6 @@
// }
// }
// }
-
- // if (thisConnection != null)
- // thisConnection.commit();
- // if (systemConnection != null && !systemConnection.equals(thisConnection))
- // systemConnection.commit();
-
persister.commit();
}
catch (IOException e)
@@ -320,14 +305,6 @@
}
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();
}
@@ -437,7 +414,7 @@
}
else
{
- TransientPropertyData prevData = (TransientPropertyData)prevState.getData();
+ PropertyData prevData = (PropertyData)prevState.getData();
List<ValueData> values = new ArrayList<ValueData>();
for (ValueData vd : prevData.getValues())
@@ -453,11 +430,23 @@
// 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()));
+ if (vd instanceof TransientValueData)
+ {
+ TransientValueData tvd = (TransientValueData)vd;
+ // TODO review TransientValueData logic about spool file and stream
+ values.add(new StreamPersistedValueData(destFile, tvd.getSpoolFile(),
+ tvd.getSpoolFile() == null ? tvd.getAsStream(false) : null, vd.getOrderNumber()));
+ }
+ else if (vd instanceof PersistedValueData)
+ {
+ values.add(((PersistedValueData)vd).createTransientCopy());
+ }
+ else
+ {
+ throw new RepositoryException(
+ "Unexpected ValueData implementaion on persistent level, only TransientValueData or PersistedValueData allowed. "
+ + vd.getClass());
+ }
}
}
@@ -691,8 +680,8 @@
* @throws InvalidItemStateException
* if the item is already deleted
*/
- protected void doDelete(final ItemData item, final WorkspaceStorageConnection con)
- throws RepositoryException, InvalidItemStateException
+ protected void doDelete(final ItemData item, final WorkspaceStorageConnection con) throws RepositoryException,
+ InvalidItemStateException
{
if (item.isNode())
@@ -712,8 +701,8 @@
* @throws InvalidItemStateException
* if the item not found TODO compare persistedVersion number
*/
- protected void doUpdate(final ItemData item, final WorkspaceStorageConnection con)
- throws RepositoryException, InvalidItemStateException
+ protected void doUpdate(final ItemData item, final WorkspaceStorageConnection con) throws RepositoryException,
+ InvalidItemStateException
{
if (item.isNode())
@@ -765,8 +754,8 @@
* @throws RepositoryException
* @throws InvalidItemStateException
*/
- protected void doRename(final ItemData item, final WorkspaceStorageConnection con,
- final Set<QPath> addedNodes) throws RepositoryException, InvalidItemStateException
+ protected void doRename(final ItemData item, final WorkspaceStorageConnection con, final Set<QPath> addedNodes)
+ throws RepositoryException, InvalidItemStateException
{
final NodeData node = (NodeData)item;
16 years, 7 months
exo-jcr SVN: r983 - in kernel/branches/mc-int-branch: exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss and 1 other directory.
by do-not-reply@jboss.org
Author: mstruk
Date: 2009-12-10 06:28:57 -0500 (Thu, 10 Dec 2009)
New Revision: 983
Modified:
kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java
kernel/branches/mc-int-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
Log:
Merged trunk changes up to r978
Modified: kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java 2009-12-10 11:10:42 UTC (rev 982)
+++ kernel/branches/mc-int-branch/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java 2009-12-10 11:28:57 UTC (rev 983)
@@ -70,7 +70,7 @@
* @param key the cache key
* @return the cached value which may be evaluated to null
*/
- public V get(Serializable key) throws Exception;
+ public V get(Serializable key);
/**
* Removes an entry from the cache.
@@ -79,7 +79,7 @@
* @return the previously cached value or null if no entry existed or that entry value was evaluated to null
* @throws NullPointerException if the provided key is null
*/
- public V remove(Serializable key) throws Exception;
+ public V remove(Serializable key) throws NullPointerException;
/**
* Performs a put in the cache.
@@ -88,7 +88,7 @@
* @param value the cached value
* @throws NullPointerException if the key is null
*/
- public void put(K key, V value) throws Exception;
+ public void put(K key, V value) throws NullPointerException;
/**
* Performs a put of all the entries provided by the map argument.
@@ -104,7 +104,7 @@
*/
@Managed
@ManagedDescription("Evict all entries of the cache")
- public void clearCache() throws Exception;
+ public void clearCache();
/**
* Selects a subset of the cache.
@@ -198,7 +198,7 @@
* @return the list of cached objects
* @throws Exception any exception
*/
- public List<? extends V> removeCachedObjects() throws Exception;
+ public List<? extends V> removeCachedObjects();
/**
* Add a listener.
Modified: kernel/branches/mc-int-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/branches/mc-int-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-10 11:10:42 UTC (rev 982)
+++ kernel/branches/mc-int-branch/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-10 11:28:57 UTC (rev 983)
@@ -106,7 +106,7 @@
/**
* {@inheritDoc}
*/
- public void clearCache() throws Exception
+ public void clearCache()
{
final Node<K, V> rootNode = cache.getRoot();
for (Node<K, V> node : rootNode.getChildren())
@@ -124,7 +124,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
- public V get(Serializable name) throws Exception
+ public V get(Serializable name)
{
if (name == null)
{
@@ -231,7 +231,7 @@
/**
* {@inheritDoc}
*/
- public void put(K key, V value) throws Exception
+ public void put(K key, V value) throws NullPointerException
{
if (key == null)
{
@@ -244,7 +244,7 @@
/**
* Only puts the data into the cache nothing more
*/
- private V putOnly(K key, V value) throws Exception
+ private V putOnly(K key, V value)
{
return cache.put(getFqn(key), key, value);
}
@@ -296,7 +296,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
- public V remove(Serializable name) throws Exception
+ public V remove(Serializable name) throws NullPointerException
{
if (name == null)
{
@@ -319,7 +319,7 @@
/**
* {@inheritDoc}
*/
- public List<V> removeCachedObjects() throws Exception
+ public List<V> removeCachedObjects()
{
final List<V> list = getCachedObjects();
clearCache();
16 years, 7 months
exo-jcr SVN: r982 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: datamodel and 2 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-10 06:10:42 -0500 (Thu, 10 Dec 2009)
New Revision: 982
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableItemData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableNodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.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/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
Log:
EXOJCR-274 item copy (clone) methods; NodeData.setACL moved to MutableNodeData; ACL manager full recreate of items.
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 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -20,14 +20,17 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS. </br>
*
* Immutable ItemData from persistent storage
*
* @author Gennady Azarenkov
- * @version $Id: PersistedItemData.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public abstract class PersistedItemData implements ItemData
@@ -80,6 +83,13 @@
{
return parentId;
}
+
+ /**
+ * Creates transient copy of this persistent ItemData.
+ *
+ * @throws RepositoryException if ValueData IOException occurs.
+ */
+ public abstract TransientItemData createTransientCopy() throws RepositoryException;
/**
* @see java.lang.Object#equals(java.lang.Object)
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
___________________________________________________________________
Name: svn:keywords
+ Id
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 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -23,6 +23,8 @@
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import javax.jcr.RepositoryException;
@@ -32,7 +34,7 @@
* Immutable NodeData from persistense storage
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
- * @version $Id: PersistedNodeData.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public class PersistedNodeData extends PersistedItemData implements NodeData
@@ -89,15 +91,6 @@
}
/**
- * @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");
- }
-
- /**
* @see org.exoplatform.services.jcr.datamodel.ItemData#accept(org.exoplatform.services.jcr.dataflow.ItemDataVisitor)
*/
public void accept(ItemDataVisitor visitor) throws RepositoryException
@@ -113,4 +106,14 @@
return true;
}
+ @Override
+ public TransientItemData createTransientCopy()
+ {
+ TransientNodeData dataCopy =
+ new TransientNodeData(getQPath(), getIdentifier(), getPersistedVersion(), getPrimaryTypeName(),
+ getMixinTypeNames(), getOrderNumber(), getParentIdentifier() != null ? getParentIdentifier() : null,
+ getACL());
+
+ return dataCopy;
+ }
}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedNodeData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -22,7 +22,11 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.ValueData;
+import org.exoplatform.services.jcr.impl.dataflow.PersistedValueData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import java.util.ArrayList;
import java.util.List;
import javax.jcr.RepositoryException;
@@ -33,7 +37,7 @@
* Persisted PropertyData
*
* @author Gennady Azarenkov
- * @version $Id: PersistedPropertyData.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public class PersistedPropertyData extends PersistedItemData implements PropertyData
@@ -54,50 +58,59 @@
this.multiValued = multiValued;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.datamodel.PropertyData#getType()
+ /**
+ * {@inheritDoc}
*/
public int getType()
{
return type;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.datamodel.PropertyData#getValues()
+ /**
+ * {@inheritDoc}
*/
public List<ValueData> getValues()
{
return values;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.datamodel.PropertyData#isMultiValued()
+ /**
+ * {@inheritDoc}
*/
public boolean isMultiValued()
{
return multiValued;
}
- /*
- * (non-Javadoc)
- * @see org.exoplatform.services.jcr.datamodel.ItemData#isNode()
+ /**
+ * {@inheritDoc}
*/
public boolean isNode()
{
return false;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.datamodel.ItemData#accept(org.exoplatform.services.jcr.dataflow
- * .ItemDataVisitor)
+ /**
+ * {@inheritDoc}
*/
public void accept(ItemDataVisitor visitor) throws RepositoryException
{
visitor.visit(this);
}
+
+ @Override
+ public TransientItemData createTransientCopy() throws RepositoryException
+ {
+ List<ValueData> copyValues = new ArrayList<ValueData>();
+ for (ValueData vdata : getValues())
+ {
+ copyValues.add(((PersistedValueData)vdata).createTransientCopy());
+ }
+
+ TransientPropertyData dataCopy =
+ new TransientPropertyData(getQPath(), getIdentifier(), getPersistedVersion(), getType(),
+ getParentIdentifier(), isMultiValued(), copyValues);
+
+ return dataCopy;
+ }
}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedPropertyData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableItemData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableItemData.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableItemData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -29,7 +29,8 @@
{
/**
- * Adds 1 to current persistedVersion value
+ * Adds 1 to current persistedVersion value. NOT USED.
*/
+ @Deprecated
void increasePersistedVersion();
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableNodeData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableNodeData.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableNodeData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -24,7 +24,7 @@
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
- * @version $Id: MutableNodeData.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public interface MutableNodeData extends NodeData, MutableItemData
@@ -37,5 +37,4 @@
void setIdentifier(String identifier);
void setACL(AccessControlList acl);
-
}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/MutableNodeData.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeData.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -24,7 +24,7 @@
* Created by The eXo Platform SAS.
*
* @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
- * @version $Id: NodeData.java 11907 2008-03-13 15:36:21Z ksm $
+ * @version $Id$
*/
public interface NodeData extends ItemData
@@ -51,10 +51,4 @@
* @return access control list either this node's data or nearest ancestor's data
*/
AccessControlList getACL();
-
- /**
- * @param acl
- */
- void setACL(AccessControlList acl);
-
}
Property changes on: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NodeData.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/TransientNodeData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -399,6 +399,7 @@
// ------------ Cloneable ------------------
@Override
+ @Deprecated
public TransientNodeData clone()
{
TransientNodeData dataCopy =
@@ -409,6 +410,7 @@
return dataCopy;
}
+ @Deprecated
public TransientNodeData cloneAsSibling(int index) throws PathNotFoundException, IllegalPathException
{
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 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientPropertyData.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -218,6 +218,7 @@
/**
* Clone node data without value data!!!
*/
+ @Deprecated
public TransientPropertyData createTransientCopy()
{
List<ValueData> copyValues = new ArrayList<ValueData>();
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-12-10 10:30:50 UTC (rev 981)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-12-10 11:10:42 UTC (rev 982)
@@ -100,12 +100,18 @@
if (parent != null)
{
// use parent ACL
- node.setACL(parent.getACL());
+ node =
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ node.getParentIdentifier(), parent.getACL());
}
else
{
// use nearest ancestor ACL... case of get by id
- node.setACL(getNearestACAncestorAcl(node));
+ node =
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ node.getParentIdentifier(), getNearestACAncestorAcl(node));
}
}
else if (!acl.hasPermissions())
16 years, 7 months
exo-jcr SVN: r981 - in jcr/branches/1.12.0-JBC/component/core: src/test/java/org/exoplatform/services/jcr/usecases and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-12-10 05:30:50 -0500 (Thu, 10 Dec 2009)
New Revision: 981
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestValueReplication.java
Modified:
jcr/branches/1.12.0-JBC/component/core/known-issues.txt
jcr/branches/1.12.0-JBC/component/core/pom.xml
Log:
EXOJCR-264: TestValueReplication added
Modified: jcr/branches/1.12.0-JBC/component/core/known-issues.txt
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/known-issues.txt 2009-12-10 10:23:17 UTC (rev 980)
+++ jcr/branches/1.12.0-JBC/component/core/known-issues.txt 2009-12-10 10:30:50 UTC (rev 981)
@@ -2,5 +2,5 @@
// https://jira.jboss.org/jira/browse/EXOJCR-193
org.exoplatform.services.jcr.impl.core.query.TestSimilarity.java
-//https://jira.jboss.org/jira/browse/EXOJCR-192
-org.exoplatform.services.jcr.api.core.query.lucene.spell.SpellCheckerTest.java
\ No newline at end of file
+// https://jira.jboss.org/jira/browse/EXOJCR-264 - there is IOException under Windows
+org/exoplatform/services/jcr/usecases/TestValueReplication.java
\ No newline at end of file
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-12-10 10:23:17 UTC (rev 980)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-12-10 10:30:50 UTC (rev 981)
@@ -346,6 +346,7 @@
<include>org/exoplatform/services/jcr/impl/**/Test*.java</include>
</includes>
<excludes>
+ <exclude>org/exoplatform/services/jcr/usecases/TestValueReplication.java</exclude>
<exclude>org/exoplatform/services/jcr/**/TestQueryUsecases.java</exclude>
<exclude>org/exoplatform/services/jcr/**/TestImport.java</exclude>
<exclude>org/exoplatform/services/jcr/**/TestRollbackBigFiles.java</exclude>
@@ -368,9 +369,9 @@
<exclude>org/exoplatform/services/jcr/**/usecases/**/TestQueryWithNumberAndSpace.java</exclude>
<exclude>org/exoplatform/services/jcr/**/usecases/BaseUsecasesTest.java</exclude>
<exclude>org/exoplatform/services/jcr/**/api/**/TestSameNameItems.java</exclude>
- <exclude>org/exoplatform/services/jcr/**/api/**/TestVersionRestore.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/api/**/TestVersionRestore.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCache.java</exclude>
- <exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
+ <exclude>org/exoplatform/services/jcr/**/impl/**/TestLinkedWorkspaceStorageCacheMetrics.java</exclude>
<exclude>org/exoplatform/services/jcr/**/impl/**/TestSessionDataManager.java</exclude>
</excludes>
</configuration>
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestValueReplication.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestValueReplication.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/usecases/TestValueReplication.java 2009-12-10 10:30:50 UTC (rev 981)
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.usecases;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import javax.jcr.Node;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: TestValueReplication.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class TestValueReplication extends BaseUsecasesTest
+{
+ private final int NODE_COUNT = 1;
+
+ private final String NODE_NAME = "repTestNode";
+
+ private final String PROP_NAME = "repTestNode";
+
+ public void setUp() throws Exception
+ {
+
+ // Fqn fqn = new Fqn("/");
+ // String rep = fqn.getLastElementAsString();
+ //
+ // boolean eq = fqn.getLastElementAsString().equals("/");
+ //
+ // fqn = Fqn.ROOT;
+ //
+ // rep = fqn.getLastElementAsString();
+ // eq = fqn.getLastElementAsString().equals("/");
+
+ // System.out.println("Enter 'x' to start ...");
+ // boolean shutdown = false;
+ // Object obj = new Object();
+ // while (!shutdown)
+ // {
+ // int ch = System.in.read();
+ // if (ch == 'x' || ch == 'X')
+ // {
+ // shutdown = true;
+ // }
+ //
+ // synchronized (obj)
+ // {
+ // obj.wait(20);
+ // }
+ // }
+
+ super.setUp();
+ }
+
+ public void testAdd() throws Exception
+ {
+ // System.out.println("Enter 'x' to add nodes...");
+ // boolean shutdown = false;
+ // Object obj = new Object();
+ // while (!shutdown)
+ // {
+ // int ch = System.in.read();
+ // if (ch == 'x' || ch == 'X')
+ // {
+ // shutdown = true;
+ // }
+ //
+ // synchronized (obj)
+ // {
+ // obj.wait(20);
+ // }
+ // }
+
+ File src = this.createBLOBTempFile(1024 * 1024);
+ //File src = new File("f:\\test.avi");
+
+ // add all
+ for (int i = 0; i < NODE_COUNT; i++)
+ {
+ Node n = root.addNode(NODE_NAME + i, "nt:unstructured");
+ n.setProperty(PROP_NAME, new FileInputStream(src));
+ root.save();
+ System.out.println("Node " + NODE_NAME + i + " added.");
+ }
+ }
+
+ /* public void testRead() throws Exception
+ {
+ System.out.println("Enter 'x' to read nodes...");
+ boolean shutdown = false;
+ Object obj = new Object();
+ while (!shutdown)
+ {
+ int ch = System.in.read();
+ if (ch == 'x' || ch == 'X')
+ {
+ shutdown = true;
+ }
+
+ synchronized (obj)
+ {
+ obj.wait(20);
+ }
+ }
+
+ File src = this.createBLOBTempFile(15 * 1024);
+
+ // add all
+ for (int i = 0; i < NODE_COUNT; i++)
+ {
+
+ if (root.hasNode(NODE_NAME + i))
+ {
+ Node n = root.getNode(NODE_NAME + i);
+ Property prop = n.getProperty(PROP_NAME);
+ InputStream in = prop.getValue().getStream();
+
+ byte[] testbuf = new byte[1024];
+ if (in.read(testbuf) != 1024)
+ {
+ System.out.println("FAIL. Node " + NODE_NAME + i + " unexpected content.");
+ }
+
+ System.out.println("Node " + NODE_NAME + i + " readeded.");
+ }
+ else
+ {
+ System.out.println("FAIL. Node " + NODE_NAME + i + " not found.");
+ }
+ }
+ }
+ */
+ public void tearDown() throws Exception
+ {
+ // System.out.println("Enter 'x' to stop JCR ...");
+ // boolean shutdown = false;
+ // Object obj = new Object();
+ // while (!shutdown)
+ // {
+ // int ch = System.in.read();
+ // if (ch == 'x' || ch == 'X')
+ // {
+ // shutdown = true;
+ // }
+ //
+ // synchronized (obj)
+ // {
+ // obj.wait(20);
+ // }
+ // }
+ super.tearDown();
+ }
+
+}
16 years, 7 months
exo-jcr SVN: r980 - jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-10 05:23:17 -0500 (Thu, 10 Dec 2009)
New Revision: 980
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-939: NodeImp.mixin create node NodeData. TCK not passed
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 10:10:40 UTC (rev 979)
+++ 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:23:17 UTC (rev 980)
@@ -2885,14 +2885,14 @@
InternalQName[] mixins = new InternalQName[newMixin.size()];
newMixin.toArray(mixins);
- // NodeData nodeData = (NodeData)data;
- //
- // data =
- // new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
- // .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());
+ NodeData nodeData = (NodeData)data;
- ((TransientNodeData)data).setMixinTypeNames(mixins);
+ data =
+ new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
+ .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());
+ // ((TransientNodeData)data).setMixinTypeNames(mixins);
+
dataManager.update(new ItemState(data, ItemState.MIXIN_CHANGED, false, null), false);
}
16 years, 7 months
exo-jcr SVN: r979 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/dataflow/persistent and 16 other directories.
by do-not-reply@jboss.org
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);
16 years, 7 months
exo-jcr SVN: r978 - in kernel/trunk: exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss and 1 other directory.
by do-not-reply@jboss.org
Author: nfilotto
Date: 2009-12-10 03:01:31 -0500 (Thu, 10 Dec 2009)
New Revision: 978
Modified:
kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java
kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
Log:
EXOJCR-296: Apply some remarks after the work done for KER-119
Rollback the changes made in the ExoCache Interface
Modified: kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java 2009-12-09 17:04:54 UTC (rev 977)
+++ kernel/trunk/exo.kernel.component.cache/src/main/java/org/exoplatform/services/cache/ExoCache.java 2009-12-10 08:01:31 UTC (rev 978)
@@ -70,7 +70,7 @@
* @param key the cache key
* @return the cached value which may be evaluated to null
*/
- public V get(Serializable key) throws Exception;
+ public V get(Serializable key);
/**
* Removes an entry from the cache.
@@ -79,7 +79,7 @@
* @return the previously cached value or null if no entry existed or that entry value was evaluated to null
* @throws NullPointerException if the provided key is null
*/
- public V remove(Serializable key) throws Exception;
+ public V remove(Serializable key) throws NullPointerException;
/**
* Performs a put in the cache.
@@ -88,7 +88,7 @@
* @param value the cached value
* @throws NullPointerException if the key is null
*/
- public void put(K key, V value) throws Exception;
+ public void put(K key, V value) throws NullPointerException;
/**
* Performs a put of all the entries provided by the map argument.
@@ -104,7 +104,7 @@
*/
@Managed
@ManagedDescription("Evict all entries of the cache")
- public void clearCache() throws Exception;
+ public void clearCache();
/**
* Selects a subset of the cache.
@@ -198,7 +198,7 @@
* @return the list of cached objects
* @throws Exception any exception
*/
- public List<? extends V> removeCachedObjects() throws Exception;
+ public List<? extends V> removeCachedObjects();
/**
* Add a listener.
Modified: kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java
===================================================================
--- kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-09 17:04:54 UTC (rev 977)
+++ kernel/trunk/exo.kernel.component.ext.cache.impl.jboss.v3/src/main/java/org/exoplatform/services/cache/impl/jboss/AbstractExoCache.java 2009-12-10 08:01:31 UTC (rev 978)
@@ -106,7 +106,7 @@
/**
* {@inheritDoc}
*/
- public void clearCache() throws Exception
+ public void clearCache()
{
final Node<K, V> rootNode = cache.getRoot();
for (Node<K, V> node : rootNode.getChildren())
@@ -124,7 +124,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
- public V get(Serializable name) throws Exception
+ public V get(Serializable name)
{
if (name == null)
{
@@ -231,7 +231,7 @@
/**
* {@inheritDoc}
*/
- public void put(K key, V value) throws Exception
+ public void put(K key, V value) throws NullPointerException
{
if (key == null)
{
@@ -244,7 +244,7 @@
/**
* Only puts the data into the cache nothing more
*/
- private V putOnly(K key, V value) throws Exception
+ private V putOnly(K key, V value)
{
return cache.put(getFqn(key), key, value);
}
@@ -296,7 +296,7 @@
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
- public V remove(Serializable name) throws Exception
+ public V remove(Serializable name) throws NullPointerException
{
if (name == null)
{
@@ -319,7 +319,7 @@
/**
* {@inheritDoc}
*/
- public List<V> removeCachedObjects() throws Exception
+ public List<V> removeCachedObjects()
{
final List<V> list = getCachedObjects();
clearCache();
16 years, 7 months
exo-jcr SVN: r977 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query: jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-09 12:04:54 -0500 (Wed, 09 Dec 2009)
New Revision: 977
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
Log:
EXOJCR-291: initialization changed
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-09 16:26:19 UTC (rev 976)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/DefaultChangesFilter.java 2009-12-09 17:04:54 UTC (rev 977)
@@ -34,18 +34,21 @@
*/
public class DefaultChangesFilter extends IndexerChangesFilter
{
+
/**
* @param searchManager
* @param parentSearchManager
* @param config
* @param indexingTree
* @param parentIndexingTree
+ * @param handler
+ * @param parentHandler
*/
public DefaultChangesFilter(SearchManager searchManager, SearchManager parentSearchManager,
- QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree)
+ QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree, QueryHandler handler,
+ QueryHandler parentHandler)
{
- super(searchManager, parentSearchManager, config, indexingTree, parentIndexingTree);
- // TODO Auto-generated constructor stub
+ super(searchManager, parentSearchManager, config, indexingTree, parentIndexingTree, handler, parentHandler);
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2009-12-09 16:26:19 UTC (rev 976)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2009-12-09 17:04:54 UTC (rev 977)
@@ -49,9 +49,9 @@
protected final QueryHandlerEntry config;
- protected QueryHandler handler;
+ protected final QueryHandler handler;
- protected QueryHandler parentHandler;
+ protected final QueryHandler parentHandler;
protected final IndexingTree indexingTree;
@@ -66,7 +66,8 @@
* @param indexingTree
*/
public IndexerChangesFilter(SearchManager searchManager, SearchManager parentSearchManager,
- QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree)
+ QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree, QueryHandler handler,
+ QueryHandler parentHandler)
{
super();
this.searchManager = searchManager;
@@ -74,6 +75,8 @@
this.config = config;
this.parentIndexingTree = parentIndexingTree;
this.indexingTree = indexingTree;
+ this.handler = handler;
+ this.parentHandler = parentHandler;
}
/**
@@ -224,14 +227,6 @@
}
/**
- * @param handler the handler to set
- */
- public void setHandler(QueryHandler handler)
- {
- this.handler = handler;
- }
-
- /**
* Update index.
* @param removedNodes
* @param addedNodes
@@ -239,14 +234,6 @@
protected abstract void doUpdateIndex(Set<String> removedNodes, Set<String> addedNodes,
Set<String> parentRemovedNodes, Set<String> parentAddedNodes);
- /**
- * @param parentHandler the parentHandler to set
- */
- protected void setParentHandler(QueryHandler parentHandler)
- {
- this.parentHandler = parentHandler;
- }
-
private void createNewOrAdd(String key, ItemState state, Map<String, List<ItemState>> updatedNodes)
{
List<ItemState> list = updatedNodes.get(key);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-09 16:26:19 UTC (rev 976)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-12-09 17:04:54 UTC (rev 977)
@@ -497,7 +497,6 @@
indexingTree = new IndexingTree(indexingRootData, excludedPath);
}
- initializeChangesFilter();
initializeQueryHandler();
if (changesLogBuffer.size() > 0)
@@ -691,9 +690,11 @@
* @throws NoSuchMethodException
* @throws SecurityException
*/
- protected void initializeChangesFilter() throws RepositoryException, RepositoryConfigurationException
+ protected IndexerChangesFilter initializeChangesFilter() throws RepositoryException,
+ RepositoryConfigurationException
{
+ IndexerChangesFilter newChangesFilter = null;
Class<? extends IndexerChangesFilter> changesFilterClass = DefaultChangesFilter.class;
String changesFilterClassName = config.getParameterValue(QueryHandlerParams.PARAM_CHANGES_FILTER_CLASS, null);
try
@@ -706,19 +707,13 @@
}
Constructor<? extends IndexerChangesFilter> constuctor =
changesFilterClass.getConstructor(SearchManager.class, SearchManager.class, QueryHandlerEntry.class,
- IndexingTree.class, IndexingTree.class);
+ IndexingTree.class, IndexingTree.class, QueryHandler.class, QueryHandler.class);
if (parentSearchManager != null)
{
- changesFilter =
+ newChangesFilter =
constuctor.newInstance(this, parentSearchManager, config, indexingTree, parentSearchManager
- .getIndexingTree());
+ .getIndexingTree(), handler, parentSearchManager.getHandler());
}
- //Disabled for system search manager
- // else
- // {
- // changesFilter = constuctor.newInstance(this, null, config, indexingTree, null);
- // }
-
}
catch (SecurityException e)
{
@@ -748,6 +743,7 @@
{
throw new RepositoryException(e.getMessage(), e);
}
+ return newChangesFilter;
}
/**
@@ -773,10 +769,10 @@
QueryHandler parentHandler = (this.parentSearchManager != null) ? parentSearchManager.getHandler() : null;
QueryHandlerContext context = createQueryHandlerContext(parentHandler);
handler.init(context);
- if (parentSearchManager != null && changesFilter != null)
+
+ if (parentSearchManager != null)
{
- changesFilter.setHandler(handler);
- changesFilter.setParentHandler(parentSearchManager.getHandler());
+ changesFilter = initializeChangesFilter();
}
}
catch (SecurityException e)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-09 16:26:19 UTC (rev 976)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-12-09 17:04:54 UTC (rev 977)
@@ -103,7 +103,6 @@
indexingTree = new IndexingTree(indexingRootNodeData, excludedPaths);
}
- initializeChangesFilter();
initializeQueryHandler();
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-09 16:26:19 UTC (rev 976)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-09 17:04:54 UTC (rev 977)
@@ -23,18 +23,17 @@
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.impl.core.query.IndexerChangesFilter;
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.loader.SingletonStoreCacheLoader;
import java.io.Serializable;
import java.util.Properties;
@@ -71,10 +70,10 @@
* @throws RepositoryConfigurationException
*/
public JbossCacheIndexChangesFilter(SearchManager searchManager, SearchManager parentSearchManager,
- QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree)
- throws RepositoryConfigurationException
+ QueryHandlerEntry config, IndexingTree indexingTree, IndexingTree parentIndexingTree, QueryHandler handler,
+ QueryHandler parentHandler) throws RepositoryConfigurationException
{
- super(searchManager, parentSearchManager, config, indexingTree, parentIndexingTree);
+ super(searchManager, parentSearchManager, config, indexingTree, parentIndexingTree, handler, parentHandler);
String jbcConfig = config.getParameterValue(QueryHandlerParams.PARAM_CHANGES_FILTER_CONFIG_PATH);
CacheFactory<Serializable, Object> factory = new DefaultCacheFactory<Serializable, Object>();
log.info("JBoss Cache configuration used: " + jbcConfig);
16 years, 7 months
exo-jcr SVN: r976 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl: core/nodetype and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-09 11:26:19 -0500 (Wed, 09 Dec 2009)
New Revision: 976
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/nodetype/ItemAutocreator.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
Log:
EXOJCR-939: remove setters from code
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-09 16:25:01 UTC (rev 975)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-09 16:26:19 UTC (rev 976)
@@ -598,11 +598,24 @@
state = ItemState.createAddedState(prop);
}
- // Should register jcr:mixinTypes and autocreated items if node is not added
+ NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
+
+ // change ACL
+ for (PropertyDefinitionData def : ntmanager.getAllPropertyDefinitions(type.getName()))
+ {
+ if (ntmanager.isNodeType(Constants.EXO_OWNEABLE, new InternalQName[]{type.getName()})
+ && def.getName().equals(Constants.EXO_OWNER))
+ {
+ AccessControlList acl =
+ new AccessControlList(session.getUserID(), ((NodeData)data).getACL().getPermissionEntries());
+ setACL(acl);
+ }
+ }
+
updateMixin(newMixin);
dataManager.update(state, false);
- NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
+ // Should register jcr:mixinTypes and autocreated items if node is not added
ItemAutocreator itemAutocreator = new ItemAutocreator(ntmanager, valueFactory, dataManager, false);
PlainChangesLog changes =
@@ -1712,9 +1725,8 @@
AccessControlList acl = new AccessControlList(getACL().getOwner(), getACL().getPermissionEntries());
acl.removePermissions(identity);
+ setACL(acl);
updatePermissions(acl);
- setACL(acl);
-
}
/**
@@ -1730,9 +1742,8 @@
AccessControlList acl = new AccessControlList(getACL().getOwner(), getACL().getPermissionEntries());
acl.removePermissions(identity, permission);
+ setACL(acl);
updatePermissions(acl);
- setACL(acl);
-
}
/**
@@ -1878,8 +1889,8 @@
AccessControlList acl = new AccessControlList(getACL().getOwner(), getACL().getPermissionEntries());
acl.removePermissions(identity);
acl.addPermissions(identity, permission);
+ setACL(acl);
updatePermissions(acl);
- setACL(acl);
}
// //////////////////////// OPTIONAL
@@ -1919,8 +1930,8 @@
}
}
AccessControlList acl = new AccessControlList(getACL().getOwner(), aces);
+ setACL(acl);
updatePermissions(acl);
- setACL(acl);
}
/**
@@ -2862,12 +2873,11 @@
private void setACL(AccessControlList acl)
{
- // NodeData nodeData = (NodeData)data;
- // data =
- // new TransientNodeData(data.getQPath(), data.getIdentifier(), data.getPersistedVersion(), nodeData
- // .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
- // .getParentIdentifier(), acl);
- ((NodeData)data).setACL(acl);
+ NodeData nodeData = (NodeData)data;
+ data =
+ new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
+ .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
+ .getParentIdentifier(), acl);
}
private void updateMixin(List<InternalQName> newMixin) throws RepositoryException
@@ -2876,11 +2886,13 @@
newMixin.toArray(mixins);
// NodeData nodeData = (NodeData)data;
+ //
// data =
// new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
// .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());
((TransientNodeData)data).setMixinTypeNames(mixins);
+
dataManager.update(new ItemState(data, ItemState.MIXIN_CHANGED, false, null), false);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2009-12-09 16:25:01 UTC (rev 975)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2009-12-09 16:26:19 UTC (rev 976)
@@ -241,8 +241,6 @@
{
// String owner = session.getUserID();
vals.add(new TransientValueData(owner));
- parent.setACL(new AccessControlList(owner, parent.getACL().getPermissionEntries()));
-
}
else if (nodeTypeDataManager.isNodeType(Constants.EXO_PRIVILEGEABLE, new InternalQName[]{typeName})
&& def.getName().equals(Constants.EXO_PERMISSIONS))
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java 2009-12-09 16:25:01 UTC (rev 975)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java 2009-12-09 16:26:19 UTC (rev 976)
@@ -191,7 +191,6 @@
*/
public boolean isNodeType(final InternalQName testTypeName, final InternalQName... typesNames)
{
-
for (InternalQName typeName : typesNames)
{
if (testTypeName.equals(typeName))
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-12-09 16:25:01 UTC (rev 975)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2009-12-09 16:26:19 UTC (rev 976)
@@ -31,6 +31,7 @@
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -111,13 +112,22 @@
{
// use nearest ancestor permissions
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
- node.setACL(new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
+
+ node =
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
+ new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
}
else if (!acl.hasOwner())
{
// use nearest ancestor owner
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
- node.setACL(new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
+
+ node =
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
+ .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
+ new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
+
}
}
@@ -128,7 +138,6 @@
* {@inheritDoc}
*/
// ------------ ItemDataConsumer impl ------------
-
public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException
{
final List<NodeData> nodes = persistentManager.getChildNodesData(parent);
@@ -136,11 +145,11 @@
initACL(parent, node);
return nodes;
}
-
+
/**
* {@inheritDoc}
*/
- public int getChildNodesCount(final NodeData parent) throws RepositoryException
+ public int getChildNodesCount(final NodeData parent) throws RepositoryException
{
return persistentManager.getChildNodesCount(parent);
}
16 years, 7 months
exo-jcr SVN: r975 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-09 11:25:01 -0500 (Wed, 09 Dec 2009)
New Revision: 975
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
Log:
EXOJCR-291: Io mode
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-09 16:24:25 UTC (rev 974)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2009-12-09 16:25:01 UTC (rev 975)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.query.IndexerIoMode;
import org.exoplatform.services.jcr.impl.core.query.IndexingTree;
import org.exoplatform.services.jcr.impl.core.query.lucene.directory.DirectoryManager;
import org.slf4j.Logger;
@@ -73,2024 +74,2285 @@
* thread and reader threads is done using {@link #updateMonitor} and
* {@link #updateInProgress}.
*/
-public class MultiIndex {
+public class MultiIndex
+{
- /**
- * The logger instance for this class
- */
- private static final Logger log = LoggerFactory.getLogger(MultiIndex.class);
+ /**
+ * The logger instance for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger(MultiIndex.class);
- /**
- * Names of active persistent index directories.
- */
- private final IndexInfos indexNames = new IndexInfos("indexes");
+ /**
+ * Names of active persistent index directories.
+ */
+ private final IndexInfos indexNames = new IndexInfos("indexes");
- /**
- * Names of index directories that can be deleted.
- */
- private final Set deletable = new HashSet();
+ /**
+ * Names of index directories that can be deleted.
+ */
+ private final Set deletable = new HashSet();
- /**
- * List of open persistent indexes. This list may also contain an open
- * PersistentIndex owned by the IndexMerger daemon. Such an index is not
- * registered with indexNames and <b>must not</b> be used in regular index
- * operations (delete node, etc.)!
- */
- private final List indexes = new ArrayList();
+ /**
+ * List of open persistent indexes. This list may also contain an open
+ * PersistentIndex owned by the IndexMerger daemon. Such an index is not
+ * registered with indexNames and <b>must not</b> be used in regular index
+ * operations (delete node, etc.)!
+ */
+ private final List indexes = new ArrayList();
- /**
- * The internal namespace mappings of the query manager.
- */
- private final NamespaceMappings nsMappings;
+ /**
+ * The internal namespace mappings of the query manager.
+ */
+ private final NamespaceMappings nsMappings;
- /**
- * The directory manager.
- */
- private final DirectoryManager directoryManager;
+ /**
+ * The directory manager.
+ */
+ private final DirectoryManager directoryManager;
- /**
- * The base directory to store the index.
- */
- private final Directory indexDir;
+ /**
+ * The base directory to store the index.
+ */
+ private final Directory indexDir;
- /**
- * The query handler
- */
- private final SearchIndex handler;
+ /**
+ * The query handler
+ */
+ private final SearchIndex handler;
- /**
- * The volatile index.
- */
- private VolatileIndex volatileIndex;
+ /**
+ * The volatile index.
+ */
+ private VolatileIndex volatileIndex;
- /**
- * Flag indicating whether an update operation is in progress.
- */
- private boolean updateInProgress = false;
+ /**
+ * Flag indicating whether an update operation is in progress.
+ */
+ private boolean updateInProgress = false;
- /**
- * If not <code>null</code> points to a valid <code>IndexReader</code> that
- * reads from all indexes, including volatile and persistent indexes.
- */
- private CachingMultiIndexReader multiReader;
+ /**
+ * If not <code>null</code> points to a valid <code>IndexReader</code> that
+ * reads from all indexes, including volatile and persistent indexes.
+ */
+ private CachingMultiIndexReader multiReader;
- /**
- * Shared document number cache across all persistent indexes.
- */
- private final DocNumberCache cache;
+ /**
+ * Shared document number cache across all persistent indexes.
+ */
+ private final DocNumberCache cache;
- /**
- * Monitor to use to synchronize access to {@link #multiReader} and
- * {@link #updateInProgress}.
- */
- private final Object updateMonitor = new Object();
+ /**
+ * Monitor to use to synchronize access to {@link #multiReader} and
+ * {@link #updateInProgress}.
+ */
+ private final Object updateMonitor = new Object();
- /**
- * <code>true</code> if the redo log contained entries on startup.
- */
- private boolean redoLogApplied = false;
+ /**
+ * <code>true</code> if the redo log contained entries on startup.
+ */
+ private boolean redoLogApplied = false;
- /**
- * The time this index was last flushed or a transaction was committed.
- */
- private long lastFlushTime;
+ /**
+ * The time this index was last flushed or a transaction was committed.
+ */
+ private long lastFlushTime;
- /**
- * The <code>IndexMerger</code> for this <code>MultiIndex</code>.
- */
- private final IndexMerger merger;
+ /**
+ * The <code>IndexMerger</code> for this <code>MultiIndex</code>.
+ */
+ private final IndexMerger merger;
- /**
- * Timer to schedule flushes of this index after some idle time.
- */
- private static final Timer FLUSH_TIMER = new Timer(true);
+ /**
+ * Timer to schedule flushes of this index after some idle time.
+ */
+ private static final Timer FLUSH_TIMER = new Timer(true);
- /**
- * Task that is periodically called by {@link #FLUSH_TIMER} and checks if
- * index should be flushed.
- */
- private final TimerTask flushTask;
+ /**
+ * Task that is periodically called by {@link #FLUSH_TIMER} and checks if
+ * index should be flushed.
+ */
+ private final TimerTask flushTask;
- /**
- * The RedoLog of this <code>MultiIndex</code>.
- */
- private final RedoLog redoLog;
+ /**
+ * The RedoLog of this <code>MultiIndex</code>.
+ */
+ private final RedoLog redoLog;
- /**
- * The indexing queue with pending text extraction jobs.
- */
- private IndexingQueue indexingQueue;
+ /**
+ * The indexing queue with pending text extraction jobs.
+ */
+ private IndexingQueue indexingQueue;
- /**
- * Set<NodeId> of uuids that should not be indexed.
- */
- private final IndexingTree indexingTree;
+ /**
+ * Set<NodeId> of uuids that should not be indexed.
+ */
+ private final IndexingTree indexingTree;
- /**
- * The next transaction id.
- */
- private long nextTransactionId = 0;
+ /**
+ * The next transaction id.
+ */
+ private long nextTransactionId = 0;
- /**
- * The current transaction id.
- */
- private long currentTransactionId = -1;
+ /**
+ * The current transaction id.
+ */
+ private long currentTransactionId = -1;
- /**
- * Flag indicating whether re-indexing is running.
- */
- private boolean reindexing = false;
+ /**
+ * Flag indicating whether re-indexing is running.
+ */
+ private boolean reindexing = false;
- /**
- * The index format version of this multi index.
- */
- private final IndexFormatVersion version;
+ /**
+ * The index format version of this multi index.
+ */
+ private final IndexFormatVersion version;
- /**
- * Creates a new MultiIndex.
- *
- * @param handler
- * the search handler
- * @param excludedIDs
- * Set<NodeId> that contains uuids that should not be indexed
- * nor further traversed.
- * @throws IOException
- * if an error occurs
- */
- MultiIndex(SearchIndex handler, IndexingTree indexingTree)
- throws IOException {
- this.directoryManager = handler.getDirectoryManager();
- this.indexDir = directoryManager.getDirectory(".");
- this.handler = handler;
- this.cache = new DocNumberCache(handler.getCacheSize());
- this.redoLog = new RedoLog(indexDir);
- this.indexingTree = indexingTree;
- this.nsMappings = handler.getNamespaceMappings();
+ /**
+ * Indexer io mode
+ */
+ private IndexerIoMode ioMode = IndexerIoMode.READ_WRITE;
- if (indexNames.exists(indexDir)) {
- indexNames.read(indexDir);
- }
+ /**
+ * Creates a new MultiIndex.
+ *
+ * @param handler
+ * the search handler
+ * @param excludedIDs
+ * Set<NodeId> that contains uuids that should not be indexed
+ * nor further traversed.
+ * @throws IOException
+ * if an error occurs
+ */
+ MultiIndex(SearchIndex handler, IndexingTree indexingTree) throws IOException
+ {
+ this.directoryManager = handler.getDirectoryManager();
+ this.indexDir = directoryManager.getDirectory(".");
+ this.handler = handler;
+ this.cache = new DocNumberCache(handler.getCacheSize());
+ this.redoLog = new RedoLog(indexDir);
+ this.indexingTree = indexingTree;
+ this.nsMappings = handler.getNamespaceMappings();
- // as of 1.5 deletable file is not used anymore
- removeDeletable();
+ if (indexNames.exists(indexDir))
+ {
+ indexNames.read(indexDir);
+ }
- // initialize IndexMerger
- merger = new IndexMerger(this);
- merger.setMaxMergeDocs(handler.getMaxMergeDocs());
- merger.setMergeFactor(handler.getMergeFactor());
- merger.setMinMergeDocs(handler.getMinMergeDocs());
+ // as of 1.5 deletable file is not used anymore
+ removeDeletable();
- IndexingQueueStore store = new IndexingQueueStore(indexDir);
+ // initialize IndexMerger
+ merger = new IndexMerger(this);
+ merger.setMaxMergeDocs(handler.getMaxMergeDocs());
+ merger.setMergeFactor(handler.getMergeFactor());
+ merger.setMinMergeDocs(handler.getMinMergeDocs());
- // initialize indexing queue
- this.indexingQueue = new IndexingQueue(store);
+ IndexingQueueStore store = new IndexingQueueStore(indexDir);
- // open persistent indexes
- for (int i = 0; i < indexNames.size(); i++) {
- String name = indexNames.getName(i);
- // only open if it still exists
- // it is possible that indexNames still contains a name for
- // an index that has been deleted, but indexNames has not been
- // written to disk.
- if (!directoryManager.hasDirectory(name)) {
- log.debug("index does not exist anymore: " + name);
- // move on to next index
- continue;
- }
- PersistentIndex index = new PersistentIndex(name, handler
- .getTextAnalyzer(), handler.getSimilarity(), cache,
- indexingQueue, directoryManager);
- index.setMaxFieldLength(handler.getMaxFieldLength());
- index.setUseCompoundFile(handler.getUseCompoundFile());
- index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
- indexes.add(index);
- merger.indexAdded(index.getName(), index.getNumDocuments());
- }
+ // initialize indexing queue
+ this.indexingQueue = new IndexingQueue(store);
- // init volatile index
- resetVolatileIndex();
+ // open persistent indexes
+ for (int i = 0; i < indexNames.size(); i++)
+ {
+ String name = indexNames.getName(i);
+ // only open if it still exists
+ // it is possible that indexNames still contains a name for
+ // an index that has been deleted, but indexNames has not been
+ // written to disk.
+ if (!directoryManager.hasDirectory(name))
+ {
+ log.debug("index does not exist anymore: " + name);
+ // move on to next index
+ continue;
+ }
+ PersistentIndex index =
+ new PersistentIndex(name, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
+ directoryManager);
+ index.setMaxFieldLength(handler.getMaxFieldLength());
+ index.setUseCompoundFile(handler.getUseCompoundFile());
+ index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
+ indexes.add(index);
+ merger.indexAdded(index.getName(), index.getNumDocuments());
+ }
- // set index format version and at the same time
- // initialize hierarchy cache if requested.
- CachingMultiIndexReader reader = getIndexReader(handler
- .isInitializeHierarchyCache());
- try {
- version = IndexFormatVersion.getVersion(reader);
- } finally {
- reader.release();
- }
+ // init volatile index
+ resetVolatileIndex();
- indexingQueue.initialize(this);
+ // set index format version and at the same time
+ // initialize hierarchy cache if requested.
+ CachingMultiIndexReader reader = getIndexReader(handler.isInitializeHierarchyCache());
+ try
+ {
+ version = IndexFormatVersion.getVersion(reader);
+ }
+ finally
+ {
+ reader.release();
+ }
- redoLogApplied = redoLog.hasEntries();
+ indexingQueue.initialize(this);
- // run recovery
- Recovery.run(this, redoLog);
+ redoLogApplied = redoLog.hasEntries();
- // enqueue unused segments for deletion
- enqueueUnusedSegments();
- attemptDelete();
+ // run recovery
+ Recovery.run(this, redoLog);
- // now that we are ready, start index merger
- merger.start();
+ // enqueue unused segments for deletion
+ enqueueUnusedSegments();
+ attemptDelete();
- if (redoLogApplied) {
- // wait for the index merge to finish pending jobs
- try {
- merger.waitUntilIdle();
- } catch (InterruptedException e) {
- // move on
- }
- flush();
- }
+ // now that we are ready, start index merger
+ merger.start();
- flushTask = new TimerTask() {
- public void run() {
- // check if there are any indexing jobs finished
- checkIndexingQueue();
- // check if volatile index should be flushed
- checkFlush();
- }
- };
+ if (redoLogApplied)
+ {
+ // wait for the index merge to finish pending jobs
+ try
+ {
+ merger.waitUntilIdle();
+ }
+ catch (InterruptedException e)
+ {
+ // move on
+ }
+ flush();
+ }
- if (indexNames.size() > 0) {
- scheduleFlushTask();
- }
- }
+ flushTask = new TimerTask()
+ {
+ public void run()
+ {
+ // check if there are any indexing jobs finished
+ checkIndexingQueue();
+ // check if volatile index should be flushed
+ checkFlush();
+ }
+ };
- /**
- * Returns the number of documents in this index.
- *
- * @return the number of documents in this index.
- * @throws IOException
- * if an error occurs while reading from the index.
- */
- int numDocs() throws IOException {
- if (indexNames.size() == 0) {
- return volatileIndex.getNumDocuments();
- } else {
- CachingMultiIndexReader reader = getIndexReader();
- try {
- return reader.numDocs();
- } finally {
- reader.release();
- }
- }
- }
+ if (indexNames.size() > 0)
+ {
+ scheduleFlushTask();
+ }
+ }
- /**
- * @return the index format version for this multi index.
- */
- IndexFormatVersion getIndexFormatVersion() {
- return version;
- }
+ /**
+ * Returns the number of documents in this index.
+ *
+ * @return the number of documents in this index.
+ * @throws IOException
+ * if an error occurs while reading from the index.
+ */
+ int numDocs() throws IOException
+ {
+ if (indexNames.size() == 0)
+ {
+ return volatileIndex.getNumDocuments();
+ }
+ else
+ {
+ CachingMultiIndexReader reader = getIndexReader();
+ try
+ {
+ return reader.numDocs();
+ }
+ finally
+ {
+ reader.release();
+ }
+ }
+ }
- /**
- * Creates an initial index by traversing the node hierarchy starting at the
- * node with <code>rootId</code>.
- *
- * @param stateMgr
- * the item state manager.
- * @param rootId
- * the id of the node from where to start.
- * @param rootPath
- * the path of the node from where to start.
- * @throws IOException
- * if an error occurs while indexing the workspace.
- * @throws IllegalStateException
- * if this index is not empty.
- */
- void createInitialIndex(ItemDataConsumer stateMgr) throws IOException {
- // only do an initial index if there are no indexes at all
- if (indexNames.size() == 0) {
- reindexing = true;
- try {
- long count = 0;
- // traverse and index workspace
- executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- // NodeData rootState = (NodeData) stateMgr.getItemData(rootId);
- count = createIndex(indexingTree.getIndexingRoot(), stateMgr,
- count);
- executeAndLog(new Commit(getTransactionId()));
- log.info("Created initial index for {} nodes", new Long(count));
- releaseMultiReader();
- scheduleFlushTask();
- } catch (Exception e) {
- String msg = "Error indexing workspace";
- IOException ex = new IOException(msg);
- ex.initCause(e);
- throw ex;
- } finally {
- reindexing = false;
- }
- } else {
- throw new IllegalStateException("Index already present");
- }
- }
+ /**
+ * @return the index format version for this multi index.
+ */
+ IndexFormatVersion getIndexFormatVersion()
+ {
+ return version;
+ }
- /**
- * Atomically updates the index by removing some documents and adding
- * others.
- *
- * @param remove
- * collection of <code>UUID</code>s that identify documents to
- * remove
- * @param add
- * collection of <code>Document</code>s to add. Some of the
- * elements in this collection may be <code>null</code>, to
- * indicate that a node could not be indexed successfully.
- * @throws IOException
- * if an error occurs while updating the index.
- */
- synchronized void update(Collection remove, Collection add)
- throws IOException {
- // make sure a reader is available during long updates
- if (add.size() > handler.getBufferSize()) {
- try {
- getIndexReader().release();
- } catch (IOException e) {
- // do not fail if an exception is thrown here
- log.warn("unable to prepare index reader "
- + "for queries during update", e);
- }
- }
+ /**
+ * Creates an initial index by traversing the node hierarchy starting at the
+ * node with <code>rootId</code>.
+ *
+ * @param stateMgr
+ * the item state manager.
+ * @param rootId
+ * the id of the node from where to start.
+ * @param rootPath
+ * the path of the node from where to start.
+ * @throws IOException
+ * if an error occurs while indexing the workspace.
+ * @throws IllegalStateException
+ * if this index is not empty.
+ */
+ void createInitialIndex(ItemDataConsumer stateMgr) throws IOException
+ {
+ // only do an initial index if there are no indexes at all
+ if (indexNames.size() == 0)
+ {
+ reindexing = true;
+ try
+ {
+ long count = 0;
+ // traverse and index workspace
+ executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
+ // NodeData rootState = (NodeData) stateMgr.getItemData(rootId);
+ count = createIndex(indexingTree.getIndexingRoot(), stateMgr, count);
+ executeAndLog(new Commit(getTransactionId()));
+ log.info("Created initial index for {} nodes", new Long(count));
+ releaseMultiReader();
+ scheduleFlushTask();
+ }
+ catch (Exception e)
+ {
+ String msg = "Error indexing workspace";
+ IOException ex = new IOException(msg);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ reindexing = false;
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Index already present");
+ }
+ }
- synchronized (updateMonitor) {
- updateInProgress = true;
- }
- try {
- long transactionId = nextTransactionId++;
- executeAndLog(new Start(transactionId));
+ /**
+ * Atomically updates the index by removing some documents and adding
+ * others.
+ *
+ * @param remove
+ * collection of <code>UUID</code>s that identify documents to
+ * remove
+ * @param add
+ * collection of <code>Document</code>s to add. Some of the
+ * elements in this collection may be <code>null</code>, to
+ * indicate that a node could not be indexed successfully.
+ * @throws IOException
+ * if an error occurs while updating the index.
+ */
+ synchronized void update(Collection remove, Collection add) throws IOException
+ {
+ // make sure a reader is available during long updates
+ if (add.size() > handler.getBufferSize())
+ {
+ try
+ {
+ getIndexReader().release();
+ }
+ catch (IOException e)
+ {
+ // do not fail if an exception is thrown here
+ log.warn("unable to prepare index reader " + "for queries during update", e);
+ }
+ }
- boolean flush = false;
- for (Iterator it = remove.iterator(); it.hasNext();) {
- executeAndLog(new DeleteNode(transactionId, (String) it.next()));
- }
- for (Iterator it = add.iterator(); it.hasNext();) {
- Document doc = (Document) it.next();
- if (doc != null) {
- executeAndLog(new AddNode(transactionId, doc));
- // commit volatile index if needed
- flush |= checkVolatileCommit();
- }
- }
- executeAndLog(new Commit(transactionId));
+ synchronized (updateMonitor)
+ {
+ updateInProgress = true;
+ }
+ try
+ {
+ long transactionId = nextTransactionId++;
+ executeAndLog(new Start(transactionId));
- // flush whole index when volatile index has been commited.
- if (flush) {
- flush();
- }
- } finally {
- synchronized (updateMonitor) {
- updateInProgress = false;
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- }
+ boolean flush = false;
+ for (Iterator it = remove.iterator(); it.hasNext();)
+ {
+ executeAndLog(new DeleteNode(transactionId, (String)it.next()));
+ }
+ for (Iterator it = add.iterator(); it.hasNext();)
+ {
+ Document doc = (Document)it.next();
+ if (doc != null)
+ {
+ executeAndLog(new AddNode(transactionId, doc));
+ // commit volatile index if needed
+ flush |= checkVolatileCommit();
+ }
+ }
+ executeAndLog(new Commit(transactionId));
- /**
- * Adds a document to the index.
- *
- * @param doc
- * the document to add.
- * @throws IOException
- * if an error occurs while adding the document to the index.
- */
- void addDocument(Document doc) throws IOException {
- update(Collections.EMPTY_LIST, Arrays.asList(new Document[] { doc }));
- }
+ // flush whole index when volatile index has been commited.
+ if (flush)
+ {
+ flush();
+ }
+ }
+ finally
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = false;
+ updateMonitor.notifyAll();
+ releaseMultiReader();
+ }
+ }
+ }
- /**
- * Deletes the first document that matches the <code>uuid</code>.
- *
- * @param uuid
- * document that match this <code>uuid</code> will be deleted.
- * @throws IOException
- * if an error occurs while deleting the document.
- */
- void removeDocument(String uuid) throws IOException {
- update(Arrays.asList(new String[] { uuid }), Collections.EMPTY_LIST);
- }
+ /**
+ * Adds a document to the index.
+ *
+ * @param doc
+ * the document to add.
+ * @throws IOException
+ * if an error occurs while adding the document to the index.
+ */
+ void addDocument(Document doc) throws IOException
+ {
+ update(Collections.EMPTY_LIST, Arrays.asList(new Document[]{doc}));
+ }
- /**
- * Deletes all documents that match the <code>uuid</code>.
- *
- * @param uuid
- * documents that match this <code>uuid</code> will be deleted.
- * @return the number of deleted documents.
- * @throws IOException
- * if an error occurs while deleting documents.
- */
- synchronized int removeAllDocuments(String uuid) throws IOException {
- synchronized (updateMonitor) {
- updateInProgress = true;
- }
- int num;
- try {
- Term idTerm = new Term(FieldNames.UUID, uuid.toString());
- executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- num = volatileIndex.removeDocument(idTerm);
- if (num > 0) {
- redoLog.append(new DeleteNode(getTransactionId(), uuid));
- }
- for (int i = 0; i < indexes.size(); i++) {
- PersistentIndex index = (PersistentIndex) indexes.get(i);
- // only remove documents from registered indexes
- if (indexNames.contains(index.getName())) {
- int removed = index.removeDocument(idTerm);
- if (removed > 0) {
- redoLog
- .append(new DeleteNode(getTransactionId(), uuid));
- }
- num += removed;
- }
- }
- executeAndLog(new Commit(getTransactionId()));
- } finally {
- synchronized (updateMonitor) {
- updateInProgress = false;
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- return num;
- }
+ /**
+ * Deletes the first document that matches the <code>uuid</code>.
+ *
+ * @param uuid
+ * document that match this <code>uuid</code> will be deleted.
+ * @throws IOException
+ * if an error occurs while deleting the document.
+ */
+ void removeDocument(String uuid) throws IOException
+ {
+ update(Arrays.asList(new String[]{uuid}), Collections.EMPTY_LIST);
+ }
- /**
- * Returns <code>IndexReader</code>s for the indexes named
- * <code>indexNames</code>. An <code>IndexListener</code> is registered and
- * notified when documents are deleted from one of the indexes in
- * <code>indexNames</code>.
- * <p/>
- * Note: the number of <code>IndexReaders</code> returned by this method is
- * not necessarily the same as the number of index names passed. An index
- * might have been deleted and is not reachable anymore.
- *
- * @param indexNames
- * the names of the indexes for which to obtain readers.
- * @param listener
- * the listener to notify when documents are deleted.
- * @return the <code>IndexReaders</code>.
- * @throws IOException
- * if an error occurs acquiring the index readers.
- */
- synchronized IndexReader[] getIndexReaders(String[] indexNames,
- IndexListener listener) throws IOException {
- Set names = new HashSet(Arrays.asList(indexNames));
- Map indexReaders = new HashMap();
+ /**
+ * Deletes all documents that match the <code>uuid</code>.
+ *
+ * @param uuid
+ * documents that match this <code>uuid</code> will be deleted.
+ * @return the number of deleted documents.
+ * @throws IOException
+ * if an error occurs while deleting documents.
+ */
+ synchronized int removeAllDocuments(String uuid) throws IOException
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = true;
+ }
+ int num;
+ try
+ {
+ Term idTerm = new Term(FieldNames.UUID, uuid.toString());
+ executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
+ num = volatileIndex.removeDocument(idTerm);
+ if (num > 0)
+ {
+ redoLog.append(new DeleteNode(getTransactionId(), uuid));
+ }
+ for (int i = 0; i < indexes.size(); i++)
+ {
+ PersistentIndex index = (PersistentIndex)indexes.get(i);
+ // only remove documents from registered indexes
+ if (indexNames.contains(index.getName()))
+ {
+ int removed = index.removeDocument(idTerm);
+ if (removed > 0)
+ {
+ redoLog.append(new DeleteNode(getTransactionId(), uuid));
+ }
+ num += removed;
+ }
+ }
+ executeAndLog(new Commit(getTransactionId()));
+ }
+ finally
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = false;
+ updateMonitor.notifyAll();
+ releaseMultiReader();
+ }
+ }
+ return num;
+ }
- try {
- for (Iterator it = indexes.iterator(); it.hasNext();) {
- PersistentIndex index = (PersistentIndex) it.next();
- if (names.contains(index.getName())) {
- indexReaders.put(index.getReadOnlyIndexReader(listener),
- index);
- }
- }
- } catch (IOException e) {
- // release readers obtained so far
- for (Iterator it = indexReaders.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- ReadOnlyIndexReader reader = (ReadOnlyIndexReader) entry
- .getKey();
- try {
- reader.release();
- } catch (IOException ex) {
- log.warn("Exception releasing index reader: " + ex);
- }
- ((PersistentIndex) entry.getValue()).resetListener();
- }
- throw e;
- }
+ /**
+ * Returns <code>IndexReader</code>s for the indexes named
+ * <code>indexNames</code>. An <code>IndexListener</code> is registered and
+ * notified when documents are deleted from one of the indexes in
+ * <code>indexNames</code>.
+ * <p/>
+ * Note: the number of <code>IndexReaders</code> returned by this method is
+ * not necessarily the same as the number of index names passed. An index
+ * might have been deleted and is not reachable anymore.
+ *
+ * @param indexNames
+ * the names of the indexes for which to obtain readers.
+ * @param listener
+ * the listener to notify when documents are deleted.
+ * @return the <code>IndexReaders</code>.
+ * @throws IOException
+ * if an error occurs acquiring the index readers.
+ */
+ synchronized IndexReader[] getIndexReaders(String[] indexNames, IndexListener listener) throws IOException
+ {
+ Set names = new HashSet(Arrays.asList(indexNames));
+ Map indexReaders = new HashMap();
- return (IndexReader[]) indexReaders.keySet().toArray(
- new IndexReader[indexReaders.size()]);
- }
+ try
+ {
+ for (Iterator it = indexes.iterator(); it.hasNext();)
+ {
+ PersistentIndex index = (PersistentIndex)it.next();
+ if (names.contains(index.getName()))
+ {
+ indexReaders.put(index.getReadOnlyIndexReader(listener), index);
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // release readers obtained so far
+ for (Iterator it = indexReaders.entrySet().iterator(); it.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)it.next();
+ ReadOnlyIndexReader reader = (ReadOnlyIndexReader)entry.getKey();
+ try
+ {
+ reader.release();
+ }
+ catch (IOException ex)
+ {
+ log.warn("Exception releasing index reader: " + ex);
+ }
+ ((PersistentIndex)entry.getValue()).resetListener();
+ }
+ throw e;
+ }
- /**
- * Creates a new Persistent index. The new index is not registered with this
- * <code>MultiIndex</code>.
- *
- * @param indexName
- * the name of the index to open, or <code>null</code> if an
- * index with a new name should be created.
- * @return a new <code>PersistentIndex</code>.
- * @throws IOException
- * if a new index cannot be created.
- */
- synchronized PersistentIndex getOrCreateIndex(String indexName)
- throws IOException {
- // check existing
- for (Iterator it = indexes.iterator(); it.hasNext();) {
- PersistentIndex idx = (PersistentIndex) it.next();
- if (idx.getName().equals(indexName)) {
- return idx;
- }
- }
+ return (IndexReader[])indexReaders.keySet().toArray(new IndexReader[indexReaders.size()]);
+ }
- // otherwise open / create it
- if (indexName == null) {
- do {
- indexName = indexNames.newName();
- } while (directoryManager.hasDirectory(indexName));
- }
- PersistentIndex index;
- try {
- index = new PersistentIndex(indexName, handler.getTextAnalyzer(),
- handler.getSimilarity(), cache, indexingQueue,
- directoryManager);
- } catch (IOException e) {
- // do some clean up
- if (!directoryManager.delete(indexName)) {
- deletable.add(indexName);
- }
- throw e;
- }
- index.setMaxFieldLength(handler.getMaxFieldLength());
- index.setUseCompoundFile(handler.getUseCompoundFile());
- index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
+ /**
+ * Creates a new Persistent index. The new index is not registered with this
+ * <code>MultiIndex</code>.
+ *
+ * @param indexName
+ * the name of the index to open, or <code>null</code> if an
+ * index with a new name should be created.
+ * @return a new <code>PersistentIndex</code>.
+ * @throws IOException
+ * if a new index cannot be created.
+ */
+ synchronized PersistentIndex getOrCreateIndex(String indexName) throws IOException
+ {
+ // check existing
+ for (Iterator it = indexes.iterator(); it.hasNext();)
+ {
+ PersistentIndex idx = (PersistentIndex)it.next();
+ if (idx.getName().equals(indexName))
+ {
+ return idx;
+ }
+ }
- // add to list of open indexes and return it
- indexes.add(index);
- return index;
- }
+ // otherwise open / create it
+ if (indexName == null)
+ {
+ do
+ {
+ indexName = indexNames.newName();
+ }
+ while (directoryManager.hasDirectory(indexName));
+ }
+ PersistentIndex index;
+ try
+ {
+ index =
+ new PersistentIndex(indexName, handler.getTextAnalyzer(), handler.getSimilarity(), cache, indexingQueue,
+ directoryManager);
+ }
+ catch (IOException e)
+ {
+ // do some clean up
+ if (!directoryManager.delete(indexName))
+ {
+ deletable.add(indexName);
+ }
+ throw e;
+ }
+ index.setMaxFieldLength(handler.getMaxFieldLength());
+ index.setUseCompoundFile(handler.getUseCompoundFile());
+ index.setTermInfosIndexDivisor(handler.getTermInfosIndexDivisor());
- /**
- * Returns <code>true</code> if this multi index has an index segment with
- * the given name. This method even returns <code>true</code> if an index
- * segments has not yet been loaded / initialized but exists on disk.
- *
- * @param indexName
- * the name of the index segment.
- * @return <code>true</code> if it exists; otherwise <code>false</code>.
- * @throws IOException
- * if an error occurs while checking existence of directory.
- */
- synchronized boolean hasIndex(String indexName) throws IOException {
- // check existing
- for (Iterator it = indexes.iterator(); it.hasNext();) {
- PersistentIndex idx = (PersistentIndex) it.next();
- if (idx.getName().equals(indexName)) {
- return true;
- }
- }
- // check if it exists on disk
- return directoryManager.hasDirectory(indexName);
- }
+ // add to list of open indexes and return it
+ indexes.add(index);
+ return index;
+ }
- /**
- * Replaces the indexes with names <code>obsoleteIndexes</code> with
- * <code>index</code>. Documents that must be deleted in <code>index</code>
- * can be identified with <code>Term</code>s in <code>deleted</code>.
- *
- * @param obsoleteIndexes
- * the names of the indexes to replace.
- * @param index
- * the new index that is the result of a merge of the indexes to
- * replace.
- * @param deleted
- * <code>Term</code>s that identify documents that must be
- * deleted in <code>index</code>.
- * @throws IOException
- * if an exception occurs while replacing the indexes.
- */
- void replaceIndexes(String[] obsoleteIndexes, PersistentIndex index,
- Collection deleted) throws IOException {
+ /**
+ * Returns <code>true</code> if this multi index has an index segment with
+ * the given name. This method even returns <code>true</code> if an index
+ * segments has not yet been loaded / initialized but exists on disk.
+ *
+ * @param indexName
+ * the name of the index segment.
+ * @return <code>true</code> if it exists; otherwise <code>false</code>.
+ * @throws IOException
+ * if an error occurs while checking existence of directory.
+ */
+ synchronized boolean hasIndex(String indexName) throws IOException
+ {
+ // check existing
+ for (Iterator it = indexes.iterator(); it.hasNext();)
+ {
+ PersistentIndex idx = (PersistentIndex)it.next();
+ if (idx.getName().equals(indexName))
+ {
+ return true;
+ }
+ }
+ // check if it exists on disk
+ return directoryManager.hasDirectory(indexName);
+ }
- if (handler.isInitializeHierarchyCache()) {
- // force initializing of caches
- long time = System.currentTimeMillis();
- index.getReadOnlyIndexReader(true).release();
- time = System.currentTimeMillis() - time;
- log.debug("hierarchy cache initialized in {} ms", new Long(time));
- }
+ /**
+ * Replaces the indexes with names <code>obsoleteIndexes</code> with
+ * <code>index</code>. Documents that must be deleted in <code>index</code>
+ * can be identified with <code>Term</code>s in <code>deleted</code>.
+ *
+ * @param obsoleteIndexes
+ * the names of the indexes to replace.
+ * @param index
+ * the new index that is the result of a merge of the indexes to
+ * replace.
+ * @param deleted
+ * <code>Term</code>s that identify documents that must be
+ * deleted in <code>index</code>.
+ * @throws IOException
+ * if an exception occurs while replacing the indexes.
+ */
+ void replaceIndexes(String[] obsoleteIndexes, PersistentIndex index, Collection deleted) throws IOException
+ {
- synchronized (this) {
- synchronized (updateMonitor) {
- updateInProgress = true;
- }
- try {
- // if we are reindexing there is already an active transaction
- if (!reindexing) {
- executeAndLog(new Start(Action.INTERNAL_TRANS_REPL_INDEXES));
- }
- // delete obsolete indexes
- Set names = new HashSet(Arrays.asList(obsoleteIndexes));
- for (Iterator it = names.iterator(); it.hasNext();) {
- // do not try to delete indexes that are already gone
- String indexName = (String) it.next();
- if (indexNames.contains(indexName)) {
- executeAndLog(new DeleteIndex(getTransactionId(),
- indexName));
- }
- }
+ if (handler.isInitializeHierarchyCache())
+ {
+ // force initializing of caches
+ long time = System.currentTimeMillis();
+ index.getReadOnlyIndexReader(true).release();
+ time = System.currentTimeMillis() - time;
+ log.debug("hierarchy cache initialized in {} ms", new Long(time));
+ }
- // Index merger does not log an action when it creates the
- // target
- // index of the merge. We have to do this here.
- executeAndLog(new CreateIndex(getTransactionId(), index
- .getName()));
+ synchronized (this)
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = true;
+ }
+ try
+ {
+ // if we are reindexing there is already an active transaction
+ if (!reindexing)
+ {
+ executeAndLog(new Start(Action.INTERNAL_TRANS_REPL_INDEXES));
+ }
+ // delete obsolete indexes
+ Set names = new HashSet(Arrays.asList(obsoleteIndexes));
+ for (Iterator it = names.iterator(); it.hasNext();)
+ {
+ // do not try to delete indexes that are already gone
+ String indexName = (String)it.next();
+ if (indexNames.contains(indexName))
+ {
+ executeAndLog(new DeleteIndex(getTransactionId(), indexName));
+ }
+ }
- executeAndLog(new AddIndex(getTransactionId(), index.getName()));
+ // Index merger does not log an action when it creates the
+ // target
+ // index of the merge. We have to do this here.
+ executeAndLog(new CreateIndex(getTransactionId(), index.getName()));
- // delete documents in index
- for (Iterator it = deleted.iterator(); it.hasNext();) {
- Term id = (Term) it.next();
- index.removeDocument(id);
- }
- index.commit();
+ executeAndLog(new AddIndex(getTransactionId(), index.getName()));
- if (!reindexing) {
- // only commit if we are not reindexing
- // when reindexing the final commit is done at the very end
- executeAndLog(new Commit(getTransactionId()));
- }
- } finally {
- synchronized (updateMonitor) {
- updateInProgress = false;
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- }
- if (reindexing) {
- // do some cleanup right away when reindexing
- attemptDelete();
- }
- }
+ // delete documents in index
+ for (Iterator it = deleted.iterator(); it.hasNext();)
+ {
+ Term id = (Term)it.next();
+ index.removeDocument(id);
+ }
+ index.commit();
- /**
- * Returns an read-only <code>IndexReader</code> that spans alls indexes of
- * this <code>MultiIndex</code>.
- *
- * @return an <code>IndexReader</code>.
- * @throws IOException
- * if an error occurs constructing the <code>IndexReader</code>.
- */
- public CachingMultiIndexReader getIndexReader() throws IOException {
- return getIndexReader(false);
- }
+ if (!reindexing)
+ {
+ // only commit if we are not reindexing
+ // when reindexing the final commit is done at the very end
+ executeAndLog(new Commit(getTransactionId()));
+ }
+ }
+ finally
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = false;
+ updateMonitor.notifyAll();
+ releaseMultiReader();
+ }
+ }
+ }
+ if (reindexing)
+ {
+ // do some cleanup right away when reindexing
+ attemptDelete();
+ }
+ }
- /**
- * Returns an read-only <code>IndexReader</code> that spans alls indexes of
- * this <code>MultiIndex</code>.
- *
- * @param initCache
- * when set <code>true</code> the hierarchy cache is completely
- * initialized before this call returns.
- * @return an <code>IndexReader</code>.
- * @throws IOException
- * if an error occurs constructing the <code>IndexReader</code>.
- */
- public synchronized CachingMultiIndexReader getIndexReader(boolean initCache)
- throws IOException {
- synchronized (updateMonitor) {
- if (multiReader != null) {
- multiReader.acquire();
- return multiReader;
- }
- // no reader available
- // wait until no update is in progress
- while (updateInProgress) {
- try {
- updateMonitor.wait();
- } catch (InterruptedException e) {
- throw new IOException(
- "Interrupted while waiting to aquire reader");
- }
- }
- // some other read thread might have created the reader in the
- // meantime -> check again
- if (multiReader == null) {
- List readerList = new ArrayList();
- for (int i = 0; i < indexes.size(); i++) {
- PersistentIndex pIdx = (PersistentIndex) indexes.get(i);
- if (indexNames.contains(pIdx.getName())) {
- readerList.add(pIdx.getReadOnlyIndexReader(initCache));
- }
- }
- readerList.add(volatileIndex.getReadOnlyIndexReader());
- ReadOnlyIndexReader[] readers = (ReadOnlyIndexReader[]) readerList
- .toArray(new ReadOnlyIndexReader[readerList.size()]);
- multiReader = new CachingMultiIndexReader(readers, cache);
- }
- multiReader.acquire();
- return multiReader;
- }
- }
+ /**
+ * Returns an read-only <code>IndexReader</code> that spans alls indexes of
+ * this <code>MultiIndex</code>.
+ *
+ * @return an <code>IndexReader</code>.
+ * @throws IOException
+ * if an error occurs constructing the <code>IndexReader</code>.
+ */
+ public CachingMultiIndexReader getIndexReader() throws IOException
+ {
+ return getIndexReader(false);
+ }
- /**
- * Returns the volatile index.
- *
- * @return the volatile index.
- */
- VolatileIndex getVolatileIndex() {
- return volatileIndex;
- }
+ /**
+ * Returns an read-only <code>IndexReader</code> that spans alls indexes of
+ * this <code>MultiIndex</code>.
+ *
+ * @param initCache
+ * when set <code>true</code> the hierarchy cache is completely
+ * initialized before this call returns.
+ * @return an <code>IndexReader</code>.
+ * @throws IOException
+ * if an error occurs constructing the <code>IndexReader</code>.
+ */
+ public synchronized CachingMultiIndexReader getIndexReader(boolean initCache) throws IOException
+ {
+ synchronized (updateMonitor)
+ {
+ if (multiReader != null)
+ {
+ multiReader.acquire();
+ return multiReader;
+ }
+ // no reader available
+ // wait until no update is in progress
+ while (updateInProgress)
+ {
+ try
+ {
+ updateMonitor.wait();
+ }
+ catch (InterruptedException e)
+ {
+ throw new IOException("Interrupted while waiting to aquire reader");
+ }
+ }
+ // some other read thread might have created the reader in the
+ // meantime -> check again
+ if (multiReader == null)
+ {
+ List readerList = new ArrayList();
+ for (int i = 0; i < indexes.size(); i++)
+ {
+ PersistentIndex pIdx = (PersistentIndex)indexes.get(i);
+ if (indexNames.contains(pIdx.getName()))
+ {
+ readerList.add(pIdx.getReadOnlyIndexReader(initCache));
+ }
+ }
+ readerList.add(volatileIndex.getReadOnlyIndexReader());
+ ReadOnlyIndexReader[] readers =
+ (ReadOnlyIndexReader[])readerList.toArray(new ReadOnlyIndexReader[readerList.size()]);
+ multiReader = new CachingMultiIndexReader(readers, cache);
+ }
+ multiReader.acquire();
+ return multiReader;
+ }
+ }
- /**
- * Closes this <code>MultiIndex</code>.
- */
- void close() {
+ /**
+ * Returns the volatile index.
+ *
+ * @return the volatile index.
+ */
+ VolatileIndex getVolatileIndex()
+ {
+ return volatileIndex;
+ }
- // stop index merger
- // when calling this method we must not lock this MultiIndex, otherwise
- // a deadlock might occur
- merger.dispose();
+ /**
+ * Closes this <code>MultiIndex</code>.
+ */
+ void close()
+ {
- synchronized (this) {
- // stop timer
- flushTask.cancel();
+ // stop index merger
+ // when calling this method we must not lock this MultiIndex, otherwise
+ // a deadlock might occur
+ merger.dispose();
- // commit / close indexes
- try {
- releaseMultiReader();
- } catch (IOException e) {
- log.error("Exception while closing search index.", e);
- }
- try {
- flush();
- } catch (IOException e) {
- log.error("Exception while closing search index.", e);
- }
- volatileIndex.close();
- for (int i = 0; i < indexes.size(); i++) {
- ((PersistentIndex) indexes.get(i)).close();
- }
+ synchronized (this)
+ {
+ // stop timer
+ flushTask.cancel();
- // close indexing queue
- indexingQueue.close();
+ // commit / close indexes
+ try
+ {
+ releaseMultiReader();
+ }
+ catch (IOException e)
+ {
+ log.error("Exception while closing search index.", e);
+ }
+ try
+ {
+ flush();
+ }
+ catch (IOException e)
+ {
+ log.error("Exception while closing search index.", e);
+ }
+ volatileIndex.close();
+ for (int i = 0; i < indexes.size(); i++)
+ {
+ ((PersistentIndex)indexes.get(i)).close();
+ }
- // finally close directory
- try {
- indexDir.close();
- } catch (IOException e) {
- log.error("Exception while closing directory.", e);
- }
- }
- }
+ // close indexing queue
+ indexingQueue.close();
- /**
- * Returns the namespace mappings of this search index.
- *
- * @return the namespace mappings of this search index.
- */
- NamespaceMappings getNamespaceMappings() {
- return nsMappings;
- }
+ // finally close directory
+ try
+ {
+ indexDir.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Exception while closing directory.", e);
+ }
+ }
+ }
- /**
- * Returns the indexing queue for this multi index.
- *
- * @return the indexing queue for this multi index.
- */
- public IndexingQueue getIndexingQueue() {
- return indexingQueue;
- }
+ /**
+ * Returns the namespace mappings of this search index.
+ *
+ * @return the namespace mappings of this search index.
+ */
+ NamespaceMappings getNamespaceMappings()
+ {
+ return nsMappings;
+ }
- /**
- * Returns a lucene Document for the <code>node</code>.
- *
- * @param node
- * the node to index.
- * @return the index document.
- * @throws RepositoryException
- * if an error occurs while reading from the workspace.
- */
- Document createDocument(NodeData node) throws RepositoryException {
- return handler.createDocument(node, nsMappings, version);
- }
+ /**
+ * Returns the indexing queue for this multi index.
+ *
+ * @return the indexing queue for this multi index.
+ */
+ public IndexingQueue getIndexingQueue()
+ {
+ return indexingQueue;
+ }
- /**
- * Returns a lucene Document for the Node with <code>id</code>.
- *
- * @param id
- * the id of the node to index.
- * @return the index document.
- * @throws RepositoryException
- * if an error occurs while reading from the workspace or if
- * there is no node with <code>id</code>.
- */
- Document createDocument(String id) throws RepositoryException {
- ItemData data = handler.getContext().getItemStateManager().getItemData(
- id);
- if (data == null)
- throw new ItemNotFoundException("Item id=" + id + " not found");
- if (!data.isNode())
- throw new RepositoryException("Item with id " + id
- + " is not a node");
- return createDocument((NodeData) data);
+ /**
+ * Returns a lucene Document for the <code>node</code>.
+ *
+ * @param node
+ * the node to index.
+ * @return the index document.
+ * @throws RepositoryException
+ * if an error occurs while reading from the workspace.
+ */
+ Document createDocument(NodeData node) throws RepositoryException
+ {
+ return handler.createDocument(node, nsMappings, version);
+ }
- }
+ /**
+ * Returns a lucene Document for the Node with <code>id</code>.
+ *
+ * @param id
+ * the id of the node to index.
+ * @return the index document.
+ * @throws RepositoryException
+ * if an error occurs while reading from the workspace or if
+ * there is no node with <code>id</code>.
+ */
+ Document createDocument(String id) throws RepositoryException
+ {
+ ItemData data = handler.getContext().getItemStateManager().getItemData(id);
+ if (data == null)
+ throw new ItemNotFoundException("Item id=" + id + " not found");
+ if (!data.isNode())
+ throw new RepositoryException("Item with id " + id + " is not a node");
+ return createDocument((NodeData)data);
- /**
- * Returns <code>true</code> if the redo log contained entries while this
- * index was instantiated; <code>false</code> otherwise.
- *
- * @return <code>true</code> if the redo log contained entries.
- */
- boolean getRedoLogApplied() {
- return redoLogApplied;
- }
+ }
- /**
- * Removes the <code>index</code> from the list of active sub indexes. The
- * Index is not acutally deleted right away, but postponed to the
- * transaction commit.
- * <p/>
- * This method does not close the index, but rather expects that the index
- * has already been closed.
- *
- * @param index
- * the index to delete.
- */
- synchronized void deleteIndex(PersistentIndex index) {
- // remove it from the lists if index is registered
- indexes.remove(index);
- indexNames.removeName(index.getName());
- synchronized (deletable) {
- log.debug("Moved " + index.getName() + " to deletable");
- deletable.add(index.getName());
- }
- }
+ /**
+ * Returns <code>true</code> if the redo log contained entries while this
+ * index was instantiated; <code>false</code> otherwise.
+ *
+ * @return <code>true</code> if the redo log contained entries.
+ */
+ boolean getRedoLogApplied()
+ {
+ return redoLogApplied;
+ }
- /**
- * Flushes this <code>MultiIndex</code>. Persists all pending changes and
- * resets the redo log.
- *
- * @throws IOException
- * if the flush fails.
- */
- public void flush() throws IOException {
- synchronized (this) {
- // commit volatile index
- executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
- commitVolatileIndex();
+ /**
+ * Removes the <code>index</code> from the list of active sub indexes. The
+ * Index is not acutally deleted right away, but postponed to the
+ * transaction commit.
+ * <p/>
+ * This method does not close the index, but rather expects that the index
+ * has already been closed.
+ *
+ * @param index
+ * the index to delete.
+ */
+ synchronized void deleteIndex(PersistentIndex index)
+ {
+ // remove it from the lists if index is registered
+ indexes.remove(index);
+ indexNames.removeName(index.getName());
+ synchronized (deletable)
+ {
+ log.debug("Moved " + index.getName() + " to deletable");
+ deletable.add(index.getName());
+ }
+ }
- // commit persistent indexes
- for (int i = indexes.size() - 1; i >= 0; i--) {
- PersistentIndex index = (PersistentIndex) indexes.get(i);
- // only commit indexes we own
- // index merger also places PersistentIndex instances in
- // indexes,
- // but does not make them public by registering the name in
- // indexNames
- if (indexNames.contains(index.getName())) {
- index.commit();
- // check if index still contains documents
- if (index.getNumDocuments() == 0) {
- executeAndLog(new DeleteIndex(getTransactionId(), index
- .getName()));
- }
- }
- }
- executeAndLog(new Commit(getTransactionId()));
+ /**
+ * Flushes this <code>MultiIndex</code>. Persists all pending changes and
+ * resets the redo log.
+ *
+ * @throws IOException
+ * if the flush fails.
+ */
+ public void flush() throws IOException
+ {
+ synchronized (this)
+ {
+ // commit volatile index
+ executeAndLog(new Start(Action.INTERNAL_TRANSACTION));
+ commitVolatileIndex();
- indexNames.write(indexDir);
+ // commit persistent indexes
+ for (int i = indexes.size() - 1; i >= 0; i--)
+ {
+ PersistentIndex index = (PersistentIndex)indexes.get(i);
+ // only commit indexes we own
+ // index merger also places PersistentIndex instances in
+ // indexes,
+ // but does not make them public by registering the name in
+ // indexNames
+ if (indexNames.contains(index.getName()))
+ {
+ index.commit();
+ // check if index still contains documents
+ if (index.getNumDocuments() == 0)
+ {
+ executeAndLog(new DeleteIndex(getTransactionId(), index.getName()));
+ }
+ }
+ }
+ executeAndLog(new Commit(getTransactionId()));
- // reset redo log
- redoLog.clear();
+ indexNames.write(indexDir);
- lastFlushTime = System.currentTimeMillis();
- }
+ // reset redo log
+ redoLog.clear();
- // delete obsolete indexes
- attemptDelete();
- }
+ lastFlushTime = System.currentTimeMillis();
+ }
- /**
- * Releases the {@link #multiReader} and sets it <code>null</code>. If the
- * reader is already <code>null</code> this method does nothing. When this
- * method returns {@link #multiReader} is guaranteed to be <code>null</code>
- * even if an exception is thrown.
- * <p/>
- * Please note that this method does not take care of any synchronization. A
- * caller must ensure that it is the only thread operating on this multi
- * index, or that it holds the {@link #updateMonitor}.
- *
- * @throws IOException
- * if an error occurs while releasing the reader.
- */
- void releaseMultiReader() throws IOException {
- if (multiReader != null) {
- try {
- multiReader.release();
- } finally {
- multiReader = null;
- }
- }
- }
+ // delete obsolete indexes
+ attemptDelete();
+ }
- // -------------------------< internal
- // >-------------------------------------
+ /**
+ * Releases the {@link #multiReader} and sets it <code>null</code>. If the
+ * reader is already <code>null</code> this method does nothing. When this
+ * method returns {@link #multiReader} is guaranteed to be <code>null</code>
+ * even if an exception is thrown.
+ * <p/>
+ * Please note that this method does not take care of any synchronization. A
+ * caller must ensure that it is the only thread operating on this multi
+ * index, or that it holds the {@link #updateMonitor}.
+ *
+ * @throws IOException
+ * if an error occurs while releasing the reader.
+ */
+ void releaseMultiReader() throws IOException
+ {
+ if (multiReader != null)
+ {
+ try
+ {
+ multiReader.release();
+ }
+ finally
+ {
+ multiReader = null;
+ }
+ }
+ }
- /**
- * Enqueues unused segments for deletion in {@link #deletable}. This method
- * does not synchronize on {@link #deletable}! A caller must ensure that it
- * is the only one acting on the {@link #deletable} map.
- *
- * @throws IOException
- * if an error occurs while reading directories.
- */
- private void enqueueUnusedSegments() throws IOException {
- // walk through index segments
- String[] dirNames = directoryManager.getDirectoryNames();
- for (int i = 0; i < dirNames.length; i++) {
- if (dirNames[i].startsWith("_")
- && !indexNames.contains(dirNames[i])) {
- deletable.add(dirNames[i]);
- }
- }
- }
+ // -------------------------< internal
+ // >-------------------------------------
- private void scheduleFlushTask() {
- lastFlushTime = System.currentTimeMillis();
- FLUSH_TIMER.schedule(flushTask, 0, 1000);
- }
+ /**
+ * Enqueues unused segments for deletion in {@link #deletable}. This method
+ * does not synchronize on {@link #deletable}! A caller must ensure that it
+ * is the only one acting on the {@link #deletable} map.
+ *
+ * @throws IOException
+ * if an error occurs while reading directories.
+ */
+ private void enqueueUnusedSegments() throws IOException
+ {
+ // walk through index segments
+ String[] dirNames = directoryManager.getDirectoryNames();
+ for (int i = 0; i < dirNames.length; i++)
+ {
+ if (dirNames[i].startsWith("_") && !indexNames.contains(dirNames[i]))
+ {
+ deletable.add(dirNames[i]);
+ }
+ }
+ }
- /**
- * Resets the volatile index to a new instance.
- */
- private void resetVolatileIndex() throws IOException {
- volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler
- .getSimilarity(), indexingQueue);
- volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
- volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
- volatileIndex.setBufferSize(handler.getBufferSize());
- }
+ private void scheduleFlushTask()
+ {
+ lastFlushTime = System.currentTimeMillis();
+ FLUSH_TIMER.schedule(flushTask, 0, 1000);
+ }
- /**
- * Returns the current transaction id.
- *
- * @return the current transaction id.
- */
- private long getTransactionId() {
- return currentTransactionId;
- }
+ /**
+ * Resets the volatile index to a new instance.
+ */
+ private void resetVolatileIndex() throws IOException
+ {
+ volatileIndex = new VolatileIndex(handler.getTextAnalyzer(), handler.getSimilarity(), indexingQueue);
+ volatileIndex.setUseCompoundFile(handler.getUseCompoundFile());
+ volatileIndex.setMaxFieldLength(handler.getMaxFieldLength());
+ volatileIndex.setBufferSize(handler.getBufferSize());
+ }
- /**
- * Executes action <code>a</code> and appends the action to the redo log if
- * successful.
- *
- * @param a
- * the <code>Action</code> to execute.
- * @return the executed action.
- * @throws IOException
- * if an error occurs while executing the action or appending
- * the action to the redo log.
- */
- private Action executeAndLog(Action a) throws IOException {
- a.execute(this);
- redoLog.append(a);
- // please note that flushing the redo log is only required on
- // commit, but we also want to keep track of new indexes for sure.
- // otherwise it might happen that unused index folders are orphaned
- // after a crash.
- if (a.getType() == Action.TYPE_COMMIT
- || a.getType() == Action.TYPE_ADD_INDEX) {
- redoLog.flush();
- }
- return a;
- }
+ /**
+ * Returns the current transaction id.
+ *
+ * @return the current transaction id.
+ */
+ private long getTransactionId()
+ {
+ return currentTransactionId;
+ }
- /**
- * Checks if it is needed to commit the volatile index according to
- * {@link SearchIndex#getMaxVolatileIndexSize()}.
- *
- * @return <code>true</code> if the volatile index has been committed,
- * <code>false</code> otherwise.
- * @throws IOException
- * if an error occurs while committing the volatile index.
- */
- private boolean checkVolatileCommit() throws IOException {
- if (volatileIndex.getRamSizeInBytes() >= handler
- .getMaxVolatileIndexSize()) {
- commitVolatileIndex();
- return true;
- }
- return false;
- }
+ /**
+ * Executes action <code>a</code> and appends the action to the redo log if
+ * successful.
+ *
+ * @param a
+ * the <code>Action</code> to execute.
+ * @return the executed action.
+ * @throws IOException
+ * if an error occurs while executing the action or appending
+ * the action to the redo log.
+ */
+ private Action executeAndLog(Action a) throws IOException
+ {
+ a.execute(this);
+ redoLog.append(a);
+ // please note that flushing the redo log is only required on
+ // commit, but we also want to keep track of new indexes for sure.
+ // otherwise it might happen that unused index folders are orphaned
+ // after a crash.
+ if (a.getType() == Action.TYPE_COMMIT || a.getType() == Action.TYPE_ADD_INDEX)
+ {
+ redoLog.flush();
+ }
+ return a;
+ }
- /**
- * Commits the volatile index to a persistent index. The new persistent
- * index is added to the list of indexes but not written to disk. When this
- * method returns a new volatile index has been created.
- *
- * @throws IOException
- * if an error occurs while writing the volatile index to disk.
- */
- private void commitVolatileIndex() throws IOException {
+ /**
+ * Checks if it is needed to commit the volatile index according to
+ * {@link SearchIndex#getMaxVolatileIndexSize()}.
+ *
+ * @return <code>true</code> if the volatile index has been committed,
+ * <code>false</code> otherwise.
+ * @throws IOException
+ * if an error occurs while committing the volatile index.
+ */
+ private boolean checkVolatileCommit() throws IOException
+ {
+ if (volatileIndex.getRamSizeInBytes() >= handler.getMaxVolatileIndexSize())
+ {
+ commitVolatileIndex();
+ return true;
+ }
+ return false;
+ }
- // check if volatile index contains documents at all
- if (volatileIndex.getNumDocuments() > 0) {
+ /**
+ * Commits the volatile index to a persistent index. The new persistent
+ * index is added to the list of indexes but not written to disk. When this
+ * method returns a new volatile index has been created.
+ *
+ * @throws IOException
+ * if an error occurs while writing the volatile index to disk.
+ */
+ private void commitVolatileIndex() throws IOException
+ {
- long time = System.currentTimeMillis();
- // create index
- CreateIndex create = new CreateIndex(getTransactionId(), null);
- executeAndLog(create);
+ // check if volatile index contains documents at all
+ if (volatileIndex.getNumDocuments() > 0)
+ {
- // commit volatile index
- executeAndLog(new VolatileCommit(getTransactionId(), create
- .getIndexName()));
+ long time = System.currentTimeMillis();
+ // create index
+ CreateIndex create = new CreateIndex(getTransactionId(), null);
+ executeAndLog(create);
- // add new index
- AddIndex add = new AddIndex(getTransactionId(), create
- .getIndexName());
- executeAndLog(add);
+ // commit volatile index
+ executeAndLog(new VolatileCommit(getTransactionId(), create.getIndexName()));
- // create new volatile index
- resetVolatileIndex();
+ // add new index
+ AddIndex add = new AddIndex(getTransactionId(), create.getIndexName());
+ executeAndLog(add);
- time = System.currentTimeMillis() - time;
- log.debug("Committed in-memory index in " + time + "ms.");
- }
- }
+ // create new volatile index
+ resetVolatileIndex();
- /**
- * Recursively creates an index starting with the NodeState
- * <code>node</code>.
- *
- * @param node
- * the current NodeState.
- * @param path
- * the path of the current node.
- * @param stateMgr
- * the shared item state manager.
- * @param count
- * the number of nodes already indexed.
- * @return the number of nodes indexed so far.
- * @throws IOException
- * if an error occurs while writing to the index.
- * @throws ItemStateException
- * if an node state cannot be found.
- * @throws RepositoryException
- * if any other error occurs
- */
- private long createIndex(NodeData node, ItemDataConsumer stateMgr,
- long count) throws IOException, RepositoryException {
- // NodeId id = node.getNodeId();
+ time = System.currentTimeMillis() - time;
+ log.debug("Committed in-memory index in " + time + "ms.");
+ }
+ }
- if (indexingTree.isExcluded(node)) {
- return count;
- }
- executeAndLog(new AddNode(getTransactionId(), node.getIdentifier()));
- if (++count % 100 == 0) {
+ /**
+ * Recursively creates an index starting with the NodeState
+ * <code>node</code>.
+ *
+ * @param node
+ * the current NodeState.
+ * @param path
+ * the path of the current node.
+ * @param stateMgr
+ * the shared item state manager.
+ * @param count
+ * the number of nodes already indexed.
+ * @return the number of nodes indexed so far.
+ * @throws IOException
+ * if an error occurs while writing to the index.
+ * @throws ItemStateException
+ * if an node state cannot be found.
+ * @throws RepositoryException
+ * if any other error occurs
+ */
+ private long createIndex(NodeData node, ItemDataConsumer stateMgr, long count) throws IOException,
+ RepositoryException
+ {
+ // NodeId id = node.getNodeId();
- log.info("indexing... {} ({})", node.getQPath().getAsString(),
- new Long(count));
- }
- if (count % 10 == 0) {
- checkIndexingQueue(true);
- }
- checkVolatileCommit();
- List<NodeData> children = stateMgr.getChildNodesData(node);
- for (NodeData nodeData : children) {
+ if (indexingTree.isExcluded(node))
+ {
+ return count;
+ }
+ executeAndLog(new AddNode(getTransactionId(), node.getIdentifier()));
+ if (++count % 100 == 0)
+ {
- NodeData childState = (NodeData) stateMgr.getItemData(nodeData
- .getIdentifier());
- if (childState == null) {
- handler.getOnWorkspaceInconsistencyHandler()
- .handleMissingChildNode(
- new ItemNotFoundException("Child not found "),
- handler, nodeData.getQPath(), node, nodeData);
- }
+ log.info("indexing... {} ({})", node.getQPath().getAsString(), new Long(count));
+ }
+ if (count % 10 == 0)
+ {
+ checkIndexingQueue(true);
+ }
+ checkVolatileCommit();
+ List<NodeData> children = stateMgr.getChildNodesData(node);
+ for (NodeData nodeData : children)
+ {
- if (nodeData != null) {
- count = createIndex(nodeData, stateMgr, count);
- }
- }
+ NodeData childState = (NodeData)stateMgr.getItemData(nodeData.getIdentifier());
+ if (childState == null)
+ {
+ handler.getOnWorkspaceInconsistencyHandler().handleMissingChildNode(
+ new ItemNotFoundException("Child not found "), handler, nodeData.getQPath(), node, nodeData);
+ }
- return count;
- }
+ if (nodeData != null)
+ {
+ count = createIndex(nodeData, stateMgr, count);
+ }
+ }
- /**
- * Attempts to delete all files recorded in {@link #deletable}.
- */
- private void attemptDelete() {
- synchronized (deletable) {
- for (Iterator it = deletable.iterator(); it.hasNext();) {
- String indexName = (String) it.next();
- if (directoryManager.delete(indexName)) {
- it.remove();
- } else {
- log.info("Unable to delete obsolete index: " + indexName);
- }
- }
- }
- }
+ return count;
+ }
- /**
- * Removes the deletable file if it exists. The file is not used anymore in
- * Jackrabbit versions >= 1.5.
- */
- private void removeDeletable() {
- String fileName = "deletable";
- try {
- if (indexDir.fileExists(fileName)) {
- indexDir.deleteFile(fileName);
- }
- } catch (IOException e) {
- log.warn("Unable to remove file 'deletable'.", e);
- }
- }
+ /**
+ * Attempts to delete all files recorded in {@link #deletable}.
+ */
+ private void attemptDelete()
+ {
+ synchronized (deletable)
+ {
+ for (Iterator it = deletable.iterator(); it.hasNext();)
+ {
+ String indexName = (String)it.next();
+ if (directoryManager.delete(indexName))
+ {
+ it.remove();
+ }
+ else
+ {
+ log.info("Unable to delete obsolete index: " + indexName);
+ }
+ }
+ }
+ }
- /**
- * Checks the duration between the last commit to this index and the current
- * time and flushes the index (if there are changes at all) if the duration
- * (idle time) is more than {@link SearchIndex#getVolatileIdleTime()}
- * seconds.
- */
- private synchronized void checkFlush() {
- long idleTime = System.currentTimeMillis() - lastFlushTime;
- // do not flush if volatileIdleTime is zero or negative
- if (handler.getVolatileIdleTime() > 0
- && idleTime > handler.getVolatileIdleTime() * 1000) {
- try {
- if (redoLog.hasEntries()) {
- log.debug("Flushing index after being idle for " + idleTime
- + " ms.");
- synchronized (updateMonitor) {
- updateInProgress = true;
- }
- try {
- flush();
- } finally {
- synchronized (updateMonitor) {
- updateInProgress = false;
- updateMonitor.notifyAll();
- releaseMultiReader();
- }
- }
- }
- } catch (IOException e) {
- log.error("Unable to commit volatile index", e);
- }
- }
- }
+ /**
+ * Removes the deletable file if it exists. The file is not used anymore in
+ * Jackrabbit versions >= 1.5.
+ */
+ private void removeDeletable()
+ {
+ String fileName = "deletable";
+ try
+ {
+ if (indexDir.fileExists(fileName))
+ {
+ indexDir.deleteFile(fileName);
+ }
+ }
+ catch (IOException e)
+ {
+ log.warn("Unable to remove file 'deletable'.", e);
+ }
+ }
- /**
- * Checks the indexing queue for finished text extrator jobs and updates the
- * index accordingly if there are any new ones. This method is synchronized
- * and should only be called by the timer task that periodically checks if
- * there are documents ready in the indexing queue. A new transaction is
- * used when documents are transfered from the indexing queue to the index.
- */
- private synchronized void checkIndexingQueue() {
- checkIndexingQueue(false);
- }
+ /**
+ * Checks the duration between the last commit to this index and the current
+ * time and flushes the index (if there are changes at all) if the duration
+ * (idle time) is more than {@link SearchIndex#getVolatileIdleTime()}
+ * seconds.
+ */
+ private synchronized void checkFlush()
+ {
+ long idleTime = System.currentTimeMillis() - lastFlushTime;
+ // do not flush if volatileIdleTime is zero or negative
+ if (handler.getVolatileIdleTime() > 0 && idleTime > handler.getVolatileIdleTime() * 1000)
+ {
+ try
+ {
+ if (redoLog.hasEntries())
+ {
+ log.debug("Flushing index after being idle for " + idleTime + " ms.");
+ synchronized (updateMonitor)
+ {
+ updateInProgress = true;
+ }
+ try
+ {
+ flush();
+ }
+ finally
+ {
+ synchronized (updateMonitor)
+ {
+ updateInProgress = false;
+ updateMonitor.notifyAll();
+ releaseMultiReader();
+ }
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ log.error("Unable to commit volatile index", e);
+ }
+ }
+ }
- /**
- * Checks the indexing queue for finished text extrator jobs and updates the
- * index accordingly if there are any new ones.
- *
- * @param transactionPresent
- * whether a transaction is in progress and the current
- * {@link #getTransactionId()} should be used. If
- * <code>false</code> a new transaction is created when documents
- * are transfered from the indexing queue to the index.
- */
- private void checkIndexingQueue(boolean transactionPresent) {
- Document[] docs = indexingQueue.getFinishedDocuments();
- Map finished = new HashMap();
- for (int i = 0; i < docs.length; i++) {
- String uuid = docs[i].get(FieldNames.UUID);
- finished.put(uuid, docs[i]);
- }
+ /**
+ * Checks the indexing queue for finished text extrator jobs and updates the
+ * index accordingly if there are any new ones. This method is synchronized
+ * and should only be called by the timer task that periodically checks if
+ * there are documents ready in the indexing queue. A new transaction is
+ * used when documents are transfered from the indexing queue to the index.
+ */
+ private synchronized void checkIndexingQueue()
+ {
+ checkIndexingQueue(false);
+ }
- // now update index with the remaining ones if there are any
- if (!finished.isEmpty()) {
- log.info("updating index with {} nodes from indexing queue.",
- new Long(finished.size()));
+ /**
+ * Checks the indexing queue for finished text extrator jobs and updates the
+ * index accordingly if there are any new ones.
+ *
+ * @param transactionPresent
+ * whether a transaction is in progress and the current
+ * {@link #getTransactionId()} should be used. If
+ * <code>false</code> a new transaction is created when documents
+ * are transfered from the indexing queue to the index.
+ */
+ private void checkIndexingQueue(boolean transactionPresent)
+ {
+ Document[] docs = indexingQueue.getFinishedDocuments();
+ Map finished = new HashMap();
+ for (int i = 0; i < docs.length; i++)
+ {
+ String uuid = docs[i].get(FieldNames.UUID);
+ finished.put(uuid, docs[i]);
+ }
- // remove documents from the queue
- for (Iterator it = finished.keySet().iterator(); it.hasNext();) {
- indexingQueue.removeDocument(it.next().toString());
- }
+ // now update index with the remaining ones if there are any
+ if (!finished.isEmpty())
+ {
+ log.info("updating index with {} nodes from indexing queue.", new Long(finished.size()));
- try {
- if (transactionPresent) {
- for (Iterator it = finished.keySet().iterator(); it
- .hasNext();) {
- executeAndLog(new DeleteNode(getTransactionId(),
- (String) it.next()));
- }
- for (Iterator it = finished.values().iterator(); it
- .hasNext();) {
- executeAndLog(new AddNode(getTransactionId(),
- (Document) it.next()));
- }
- } else {
- update(finished.keySet(), finished.values());
- }
- } catch (IOException e) {
- // update failed
- log.warn(
- "Failed to update index with deferred text extraction",
- e);
- }
- }
- }
+ // remove documents from the queue
+ for (Iterator it = finished.keySet().iterator(); it.hasNext();)
+ {
+ indexingQueue.removeDocument(it.next().toString());
+ }
- // ------------------------< Actions
- // >---------------------------------------
+ try
+ {
+ if (transactionPresent)
+ {
+ for (Iterator it = finished.keySet().iterator(); it.hasNext();)
+ {
+ executeAndLog(new DeleteNode(getTransactionId(), (String)it.next()));
+ }
+ for (Iterator it = finished.values().iterator(); it.hasNext();)
+ {
+ executeAndLog(new AddNode(getTransactionId(), (Document)it.next()));
+ }
+ }
+ else
+ {
+ update(finished.keySet(), finished.values());
+ }
+ }
+ catch (IOException e)
+ {
+ // update failed
+ log.warn("Failed to update index with deferred text extraction", e);
+ }
+ }
+ }
- /**
- * Defines an action on an <code>MultiIndex</code>.
- */
- public abstract static class Action {
+ // ------------------------< Actions
+ // >---------------------------------------
- /**
- * Action identifier in redo log for transaction start action.
- */
- static final String START = "STR";
+ /**
+ * Defines an action on an <code>MultiIndex</code>.
+ */
+ public abstract static class Action
+ {
- /**
- * Action type for start action.
- */
- public static final int TYPE_START = 0;
+ /**
+ * Action identifier in redo log for transaction start action.
+ */
+ static final String START = "STR";
- /**
- * Action identifier in redo log for add node action.
- */
- static final String ADD_NODE = "ADD";
+ /**
+ * Action type for start action.
+ */
+ public static final int TYPE_START = 0;
- /**
- * Action type for add node action.
- */
- public static final int TYPE_ADD_NODE = 1;
+ /**
+ * Action identifier in redo log for add node action.
+ */
+ static final String ADD_NODE = "ADD";
- /**
- * Action identifier in redo log for node delete action.
- */
- static final String DELETE_NODE = "DEL";
+ /**
+ * Action type for add node action.
+ */
+ public static final int TYPE_ADD_NODE = 1;
- /**
- * Action type for delete node action.
- */
- public static final int TYPE_DELETE_NODE = 2;
+ /**
+ * Action identifier in redo log for node delete action.
+ */
+ static final String DELETE_NODE = "DEL";
- /**
- * Action identifier in redo log for transaction commit action.
- */
- static final String COMMIT = "COM";
+ /**
+ * Action type for delete node action.
+ */
+ public static final int TYPE_DELETE_NODE = 2;
- /**
- * Action type for commit action.
- */
- public static final int TYPE_COMMIT = 3;
+ /**
+ * Action identifier in redo log for transaction commit action.
+ */
+ static final String COMMIT = "COM";
- /**
- * Action identifier in redo log for volatile index commit action.
- */
- static final String VOLATILE_COMMIT = "VOL_COM";
+ /**
+ * Action type for commit action.
+ */
+ public static final int TYPE_COMMIT = 3;
- /**
- * Action type for volatile index commit action.
- */
- public static final int TYPE_VOLATILE_COMMIT = 4;
+ /**
+ * Action identifier in redo log for volatile index commit action.
+ */
+ static final String VOLATILE_COMMIT = "VOL_COM";
- /**
- * Action identifier in redo log for index create action.
- */
- static final String CREATE_INDEX = "CRE_IDX";
+ /**
+ * Action type for volatile index commit action.
+ */
+ public static final int TYPE_VOLATILE_COMMIT = 4;
- /**
- * Action type for create index action.
- */
- public static final int TYPE_CREATE_INDEX = 5;
+ /**
+ * Action identifier in redo log for index create action.
+ */
+ static final String CREATE_INDEX = "CRE_IDX";
- /**
- * Action identifier in redo log for index add action.
- */
- static final String ADD_INDEX = "ADD_IDX";
+ /**
+ * Action type for create index action.
+ */
+ public static final int TYPE_CREATE_INDEX = 5;
- /**
- * Action type for add index action.
- */
- public static final int TYPE_ADD_INDEX = 6;
+ /**
+ * Action identifier in redo log for index add action.
+ */
+ static final String ADD_INDEX = "ADD_IDX";
- /**
- * Action identifier in redo log for delete index action.
- */
- static final String DELETE_INDEX = "DEL_IDX";
+ /**
+ * Action type for add index action.
+ */
+ public static final int TYPE_ADD_INDEX = 6;
- /**
- * Action type for delete index action.
- */
- public static final int TYPE_DELETE_INDEX = 7;
+ /**
+ * Action identifier in redo log for delete index action.
+ */
+ static final String DELETE_INDEX = "DEL_IDX";
- /**
- * Transaction identifier for internal actions like volatile index
- * commit triggered by timer thread.
- */
- static final long INTERNAL_TRANSACTION = -1;
+ /**
+ * Action type for delete index action.
+ */
+ public static final int TYPE_DELETE_INDEX = 7;
- /**
- * Transaction identifier for internal action that replaces indexs.
- */
- static final long INTERNAL_TRANS_REPL_INDEXES = -2;
+ /**
+ * Transaction identifier for internal actions like volatile index
+ * commit triggered by timer thread.
+ */
+ static final long INTERNAL_TRANSACTION = -1;
- /**
- * The id of the transaction that executed this action.
- */
- private final long transactionId;
+ /**
+ * Transaction identifier for internal action that replaces indexs.
+ */
+ static final long INTERNAL_TRANS_REPL_INDEXES = -2;
- /**
- * The action type.
- */
- private final int type;
+ /**
+ * The id of the transaction that executed this action.
+ */
+ private final long transactionId;
- /**
- * Creates a new <code>Action</code>.
- *
- * @param transactionId
- * the id of the transaction that executed this action.
- * @param type
- * the action type.
- */
- Action(long transactionId, int type) {
- this.transactionId = transactionId;
- this.type = type;
- }
+ /**
+ * The action type.
+ */
+ private final int type;
- /**
- * Returns the transaction id for this <code>Action</code>.
- *
- * @return the transaction id for this <code>Action</code>.
- */
- long getTransactionId() {
- return transactionId;
- }
+ /**
+ * Creates a new <code>Action</code>.
+ *
+ * @param transactionId
+ * the id of the transaction that executed this action.
+ * @param type
+ * the action type.
+ */
+ Action(long transactionId, int type)
+ {
+ this.transactionId = transactionId;
+ this.type = type;
+ }
- /**
- * Returns the action type.
- *
- * @return the action type.
- */
- int getType() {
- return type;
- }
+ /**
+ * Returns the transaction id for this <code>Action</code>.
+ *
+ * @return the transaction id for this <code>Action</code>.
+ */
+ long getTransactionId()
+ {
+ return transactionId;
+ }
- /**
- * Executes this action on the <code>index</code>.
- *
- * @param index
- * the index where to execute the action.
- * @throws IOException
- * if the action fails due to some I/O error in the index or
- * some other error.
- */
- public abstract void execute(MultiIndex index) throws IOException;
+ /**
+ * Returns the action type.
+ *
+ * @return the action type.
+ */
+ int getType()
+ {
+ return type;
+ }
- /**
- * Executes the inverse operation of this action. That is, does an undo
- * of this action. This default implementation does nothing, but returns
- * silently.
- *
- * @param index
- * the index where to undo the action.
- * @throws IOException
- * if the action cannot be undone.
- */
- public void undo(MultiIndex index) throws IOException {
- }
+ /**
+ * Executes this action on the <code>index</code>.
+ *
+ * @param index
+ * the index where to execute the action.
+ * @throws IOException
+ * if the action fails due to some I/O error in the index or
+ * some other error.
+ */
+ public abstract void execute(MultiIndex index) throws IOException;
- /**
- * Returns a <code>String</code> representation of this action that can
- * be written to the {@link RedoLog}.
- *
- * @return a <code>String</code> representation of this action.
- */
- public abstract String toString();
+ /**
+ * Executes the inverse operation of this action. That is, does an undo
+ * of this action. This default implementation does nothing, but returns
+ * silently.
+ *
+ * @param index
+ * the index where to undo the action.
+ * @throws IOException
+ * if the action cannot be undone.
+ */
+ public void undo(MultiIndex index) throws IOException
+ {
+ }
- /**
- * Parses an line in the redo log and created an {@link Action}.
- *
- * @param line
- * the line from the redo log.
- * @return an <code>Action</code>.
- * @throws IllegalArgumentException
- * if the line is malformed.
- */
- static Action fromString(String line) throws IllegalArgumentException {
- int endTransIdx = line.indexOf(' ');
- if (endTransIdx == -1) {
- throw new IllegalArgumentException(line);
- }
- long transactionId;
- try {
- transactionId = Long.parseLong(line.substring(0, endTransIdx));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(line);
- }
- int endActionIdx = line.indexOf(' ', endTransIdx + 1);
- if (endActionIdx == -1) {
- // action does not have arguments
- endActionIdx = line.length();
- }
- String actionLabel = line.substring(endTransIdx + 1, endActionIdx);
- String arguments = "";
- if (endActionIdx + 1 <= line.length()) {
- arguments = line.substring(endActionIdx + 1);
- }
- Action a;
- if (actionLabel.equals(Action.ADD_NODE)) {
- a = AddNode.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.ADD_INDEX)) {
- a = AddIndex.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.COMMIT)) {
- a = Commit.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.CREATE_INDEX)) {
- a = CreateIndex.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.DELETE_INDEX)) {
- a = DeleteIndex.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.DELETE_NODE)) {
- a = DeleteNode.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.START)) {
- a = Start.fromString(transactionId, arguments);
- } else if (actionLabel.equals(Action.VOLATILE_COMMIT)) {
- a = VolatileCommit.fromString(transactionId, arguments);
- } else {
- throw new IllegalArgumentException(line);
- }
- return a;
- }
- }
+ /**
+ * Returns a <code>String</code> representation of this action that can
+ * be written to the {@link RedoLog}.
+ *
+ * @return a <code>String</code> representation of this action.
+ */
+ public abstract String toString();
- /**
- * Adds an index to the MultiIndex's active persistent index list.
- */
- private static class AddIndex extends Action {
+ /**
+ * Parses an line in the redo log and created an {@link Action}.
+ *
+ * @param line
+ * the line from the redo log.
+ * @return an <code>Action</code>.
+ * @throws IllegalArgumentException
+ * if the line is malformed.
+ */
+ static Action fromString(String line) throws IllegalArgumentException
+ {
+ int endTransIdx = line.indexOf(' ');
+ if (endTransIdx == -1)
+ {
+ throw new IllegalArgumentException(line);
+ }
+ long transactionId;
+ try
+ {
+ transactionId = Long.parseLong(line.substring(0, endTransIdx));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException(line);
+ }
+ int endActionIdx = line.indexOf(' ', endTransIdx + 1);
+ if (endActionIdx == -1)
+ {
+ // action does not have arguments
+ endActionIdx = line.length();
+ }
+ String actionLabel = line.substring(endTransIdx + 1, endActionIdx);
+ String arguments = "";
+ if (endActionIdx + 1 <= line.length())
+ {
+ arguments = line.substring(endActionIdx + 1);
+ }
+ Action a;
+ if (actionLabel.equals(Action.ADD_NODE))
+ {
+ a = AddNode.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.ADD_INDEX))
+ {
+ a = AddIndex.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.COMMIT))
+ {
+ a = Commit.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.CREATE_INDEX))
+ {
+ a = CreateIndex.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.DELETE_INDEX))
+ {
+ a = DeleteIndex.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.DELETE_NODE))
+ {
+ a = DeleteNode.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.START))
+ {
+ a = Start.fromString(transactionId, arguments);
+ }
+ else if (actionLabel.equals(Action.VOLATILE_COMMIT))
+ {
+ a = VolatileCommit.fromString(transactionId, arguments);
+ }
+ else
+ {
+ throw new IllegalArgumentException(line);
+ }
+ return a;
+ }
+ }
- /**
- * The name of the index to add.
- */
- private String indexName;
+ /**
+ * Adds an index to the MultiIndex's active persistent index list.
+ */
+ private static class AddIndex extends Action
+ {
- /**
- * Creates a new AddIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param indexName
- * the name of the index to add, or <code>null</code> if an
- * index with a new name should be created.
- */
- AddIndex(long transactionId, String indexName) {
- super(transactionId, Action.TYPE_ADD_INDEX);
- this.indexName = indexName;
- }
+ /**
+ * The name of the index to add.
+ */
+ private String indexName;
- /**
- * Creates a new AddIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * the name of the index to add.
- * @return the AddIndex action.
- * @throws IllegalArgumentException
- * if the arguments are malformed.
- */
- static AddIndex fromString(long transactionId, String arguments) {
- return new AddIndex(transactionId, arguments);
- }
+ /**
+ * Creates a new AddIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param indexName
+ * the name of the index to add, or <code>null</code> if an
+ * index with a new name should be created.
+ */
+ AddIndex(long transactionId, String indexName)
+ {
+ super(transactionId, Action.TYPE_ADD_INDEX);
+ this.indexName = indexName;
+ }
- /**
- * Adds a sub index to <code>index</code>.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- PersistentIndex idx = index.getOrCreateIndex(indexName);
- if (!index.indexNames.contains(indexName)) {
- index.indexNames.addName(indexName);
- // now that the index is in the active list let the merger know
- // about it
- index.merger.indexAdded(indexName, idx.getNumDocuments());
- }
- }
+ /**
+ * Creates a new AddIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * the name of the index to add.
+ * @return the AddIndex action.
+ * @throws IllegalArgumentException
+ * if the arguments are malformed.
+ */
+ static AddIndex fromString(long transactionId, String arguments)
+ {
+ return new AddIndex(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer();
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.ADD_INDEX);
- logLine.append(' ');
- logLine.append(indexName);
- return logLine.toString();
- }
- }
+ /**
+ * Adds a sub index to <code>index</code>.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ PersistentIndex idx = index.getOrCreateIndex(indexName);
+ if (!index.indexNames.contains(indexName))
+ {
+ index.indexNames.addName(indexName);
+ // now that the index is in the active list let the merger know
+ // about it
+ index.merger.indexAdded(indexName, idx.getNumDocuments());
+ }
+ }
- /**
- * Adds a node to the index.
- */
- private static class AddNode extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer();
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.ADD_INDEX);
+ logLine.append(' ');
+ logLine.append(indexName);
+ return logLine.toString();
+ }
+ }
- /**
- * The maximum length of a AddNode String.
- */
- private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE)
- .length()
- + Action.ADD_NODE.length()
- + Constants.UUID_FORMATTED_LENGTH
- + 2;
+ /**
+ * Adds a node to the index.
+ */
+ private static class AddNode extends Action
+ {
- /**
- * The uuid of the node to add.
- */
- private final String uuid;
+ /**
+ * The maximum length of a AddNode String.
+ */
+ private static final int ENTRY_LENGTH =
+ Long.toString(Long.MAX_VALUE).length() + Action.ADD_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
- /**
- * The document to add to the index, or <code>null</code> if not
- * available.
- */
- private Document doc;
+ /**
+ * The uuid of the node to add.
+ */
+ private final String uuid;
- /**
- * Creates a new AddNode action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param uuid
- * the uuid of the node to add.
- */
- AddNode(long transactionId, String uuid) {
- super(transactionId, Action.TYPE_ADD_NODE);
- this.uuid = uuid;
- }
+ /**
+ * The document to add to the index, or <code>null</code> if not
+ * available.
+ */
+ private Document doc;
- /**
- * Creates a new AddNode action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param doc
- * the document to add.
- */
- AddNode(long transactionId, Document doc) {
- this(transactionId, doc.get(FieldNames.UUID));
- this.doc = doc;
- }
+ /**
+ * Creates a new AddNode action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param uuid
+ * the uuid of the node to add.
+ */
+ AddNode(long transactionId, String uuid)
+ {
+ super(transactionId, Action.TYPE_ADD_NODE);
+ this.uuid = uuid;
+ }
- /**
- * Creates a new AddNode action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * the arguments to this action. The uuid of the node to add
- * @return the AddNode action.
- * @throws IllegalArgumentException
- * if the arguments are malformed. Not a UUID.
- */
- static AddNode fromString(long transactionId, String arguments)
- throws IllegalArgumentException {
- // simple length check
- if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) {
- throw new IllegalArgumentException("arguments is not a uuid");
- }
- return new AddNode(transactionId, arguments);
- }
+ /**
+ * Creates a new AddNode action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param doc
+ * the document to add.
+ */
+ AddNode(long transactionId, Document doc)
+ {
+ this(transactionId, doc.get(FieldNames.UUID));
+ this.doc = doc;
+ }
- /**
- * Adds a node to the index.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- if (doc == null) {
- try {
- doc = index.createDocument(uuid);
- } catch (RepositoryException e) {
- // node does not exist anymore
- log.debug(e.getMessage());
- }
- }
- if (doc != null) {
- index.volatileIndex.addDocuments(new Document[] { doc });
- }
- }
+ /**
+ * Creates a new AddNode action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * the arguments to this action. The uuid of the node to add
+ * @return the AddNode action.
+ * @throws IllegalArgumentException
+ * if the arguments are malformed. Not a UUID.
+ */
+ static AddNode fromString(long transactionId, String arguments) throws IllegalArgumentException
+ {
+ // simple length check
+ if (arguments.length() != Constants.UUID_FORMATTED_LENGTH)
+ {
+ throw new IllegalArgumentException("arguments is not a uuid");
+ }
+ return new AddNode(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer(ENTRY_LENGTH);
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.ADD_NODE);
- logLine.append(' ');
- logLine.append(uuid);
- return logLine.toString();
- }
- }
+ /**
+ * Adds a node to the index.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ if (doc == null)
+ {
+ try
+ {
+ doc = index.createDocument(uuid);
+ }
+ catch (RepositoryException e)
+ {
+ // node does not exist anymore
+ log.debug(e.getMessage());
+ }
+ }
+ if (doc != null)
+ {
+ index.volatileIndex.addDocuments(new Document[]{doc});
+ }
+ }
- /**
- * Commits a transaction.
- */
- private static class Commit extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer(ENTRY_LENGTH);
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.ADD_NODE);
+ logLine.append(' ');
+ logLine.append(uuid);
+ return logLine.toString();
+ }
+ }
- /**
- * Creates a new Commit action.
- *
- * @param transactionId
- * the id of the transaction that is committed.
- */
- Commit(long transactionId) {
- super(transactionId, Action.TYPE_COMMIT);
- }
+ /**
+ * Commits a transaction.
+ */
+ private static class Commit extends Action
+ {
- /**
- * Creates a new Commit action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * ignored by this method.
- * @return the Commit action.
- */
- static Commit fromString(long transactionId, String arguments) {
- return new Commit(transactionId);
- }
+ /**
+ * Creates a new Commit action.
+ *
+ * @param transactionId
+ * the id of the transaction that is committed.
+ */
+ Commit(long transactionId)
+ {
+ super(transactionId, Action.TYPE_COMMIT);
+ }
- /**
- * Touches the last flush time (sets it to the current time).
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- index.lastFlushTime = System.currentTimeMillis();
- }
+ /**
+ * Creates a new Commit action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * ignored by this method.
+ * @return the Commit action.
+ */
+ static Commit fromString(long transactionId, String arguments)
+ {
+ return new Commit(transactionId);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- return Long.toString(getTransactionId()) + ' ' + Action.COMMIT;
- }
- }
+ /**
+ * Touches the last flush time (sets it to the current time).
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ index.lastFlushTime = System.currentTimeMillis();
+ }
- /**
- * Creates an new sub index but does not add it to the active persistent
- * index list.
- */
- private static class CreateIndex extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ return Long.toString(getTransactionId()) + ' ' + Action.COMMIT;
+ }
+ }
- /**
- * The name of the index to add.
- */
- private String indexName;
+ /**
+ * Creates an new sub index but does not add it to the active persistent
+ * index list.
+ */
+ private static class CreateIndex extends Action
+ {
- /**
- * Creates a new CreateIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param indexName
- * the name of the index to add, or <code>null</code> if an
- * index with a new name should be created.
- */
- CreateIndex(long transactionId, String indexName) {
- super(transactionId, Action.TYPE_CREATE_INDEX);
- this.indexName = indexName;
- }
+ /**
+ * The name of the index to add.
+ */
+ private String indexName;
- /**
- * Creates a new CreateIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * the name of the index to create.
- * @return the AddIndex action.
- * @throws IllegalArgumentException
- * if the arguments are malformed.
- */
- static CreateIndex fromString(long transactionId, String arguments) {
- // when created from String, this action is executed as redo action
- return new CreateIndex(transactionId, arguments);
- }
+ /**
+ * Creates a new CreateIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param indexName
+ * the name of the index to add, or <code>null</code> if an
+ * index with a new name should be created.
+ */
+ CreateIndex(long transactionId, String indexName)
+ {
+ super(transactionId, Action.TYPE_CREATE_INDEX);
+ this.indexName = indexName;
+ }
- /**
- * Creates a new index.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- PersistentIndex idx = index.getOrCreateIndex(indexName);
- indexName = idx.getName();
- }
+ /**
+ * Creates a new CreateIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * the name of the index to create.
+ * @return the AddIndex action.
+ * @throws IllegalArgumentException
+ * if the arguments are malformed.
+ */
+ static CreateIndex fromString(long transactionId, String arguments)
+ {
+ // when created from String, this action is executed as redo action
+ return new CreateIndex(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public void undo(MultiIndex index) throws IOException {
- if (index.hasIndex(indexName)) {
- PersistentIndex idx = index.getOrCreateIndex(indexName);
- idx.close();
- index.deleteIndex(idx);
- }
- }
+ /**
+ * Creates a new index.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ PersistentIndex idx = index.getOrCreateIndex(indexName);
+ indexName = idx.getName();
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer();
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.CREATE_INDEX);
- logLine.append(' ');
- logLine.append(indexName);
- return logLine.toString();
- }
+ /**
+ * @inheritDoc
+ */
+ public void undo(MultiIndex index) throws IOException
+ {
+ if (index.hasIndex(indexName))
+ {
+ PersistentIndex idx = index.getOrCreateIndex(indexName);
+ idx.close();
+ index.deleteIndex(idx);
+ }
+ }
- /**
- * Returns the index name that has been created. If this method is
- * called before {@link #execute(MultiIndex)} it will return
- * <code>null</code>.
- *
- * @return the name of the index that has been created.
- */
- String getIndexName() {
- return indexName;
- }
- }
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer();
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.CREATE_INDEX);
+ logLine.append(' ');
+ logLine.append(indexName);
+ return logLine.toString();
+ }
- /**
- * Closes and deletes an index that is no longer in use.
- */
- private static class DeleteIndex extends Action {
+ /**
+ * Returns the index name that has been created. If this method is
+ * called before {@link #execute(MultiIndex)} it will return
+ * <code>null</code>.
+ *
+ * @return the name of the index that has been created.
+ */
+ String getIndexName()
+ {
+ return indexName;
+ }
+ }
- /**
- * The name of the index to add.
- */
- private String indexName;
+ /**
+ * Closes and deletes an index that is no longer in use.
+ */
+ private static class DeleteIndex extends Action
+ {
- /**
- * Creates a new DeleteIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param indexName
- * the name of the index to delete.
- */
- DeleteIndex(long transactionId, String indexName) {
- super(transactionId, Action.TYPE_DELETE_INDEX);
- this.indexName = indexName;
- }
+ /**
+ * The name of the index to add.
+ */
+ private String indexName;
- /**
- * Creates a new DeleteIndex action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * the name of the index to delete.
- * @return the DeleteIndex action.
- * @throws IllegalArgumentException
- * if the arguments are malformed.
- */
- static DeleteIndex fromString(long transactionId, String arguments) {
- return new DeleteIndex(transactionId, arguments);
- }
+ /**
+ * Creates a new DeleteIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param indexName
+ * the name of the index to delete.
+ */
+ DeleteIndex(long transactionId, String indexName)
+ {
+ super(transactionId, Action.TYPE_DELETE_INDEX);
+ this.indexName = indexName;
+ }
- /**
- * Removes a sub index from <code>index</code>.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- // get index if it exists
- for (Iterator it = index.indexes.iterator(); it.hasNext();) {
- PersistentIndex idx = (PersistentIndex) it.next();
- if (idx.getName().equals(indexName)) {
- idx.close();
- index.deleteIndex(idx);
- break;
- }
- }
- }
+ /**
+ * Creates a new DeleteIndex action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * the name of the index to delete.
+ * @return the DeleteIndex action.
+ * @throws IllegalArgumentException
+ * if the arguments are malformed.
+ */
+ static DeleteIndex fromString(long transactionId, String arguments)
+ {
+ return new DeleteIndex(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer();
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.DELETE_INDEX);
- logLine.append(' ');
- logLine.append(indexName);
- return logLine.toString();
- }
- }
+ /**
+ * Removes a sub index from <code>index</code>.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ // get index if it exists
+ for (Iterator it = index.indexes.iterator(); it.hasNext();)
+ {
+ PersistentIndex idx = (PersistentIndex)it.next();
+ if (idx.getName().equals(indexName))
+ {
+ idx.close();
+ index.deleteIndex(idx);
+ break;
+ }
+ }
+ }
- /**
- * Deletes a node from the index.
- */
- private static class DeleteNode extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer();
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.DELETE_INDEX);
+ logLine.append(' ');
+ logLine.append(indexName);
+ return logLine.toString();
+ }
+ }
- /**
- * The maximum length of a DeleteNode String.
- */
- private static final int ENTRY_LENGTH = Long.toString(Long.MAX_VALUE)
- .length()
- + Action.DELETE_NODE.length()
- + Constants.UUID_FORMATTED_LENGTH
- + 2;
+ /**
+ * Deletes a node from the index.
+ */
+ private static class DeleteNode extends Action
+ {
- /**
- * The uuid of the node to remove.
- */
- private final String uuid;
+ /**
+ * The maximum length of a DeleteNode String.
+ */
+ private static final int ENTRY_LENGTH =
+ Long.toString(Long.MAX_VALUE).length() + Action.DELETE_NODE.length() + Constants.UUID_FORMATTED_LENGTH + 2;
- /**
- * Creates a new DeleteNode action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param uuid
- * the uuid of the node to delete.
- */
- DeleteNode(long transactionId, String uuid) {
- super(transactionId, Action.TYPE_DELETE_NODE);
- this.uuid = uuid;
- }
+ /**
+ * The uuid of the node to remove.
+ */
+ private final String uuid;
- /**
- * Creates a new DeleteNode action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * the uuid of the node to delete.
- * @return the DeleteNode action.
- * @throws IllegalArgumentException
- * if the arguments are malformed. Not a UUID.
- */
- static DeleteNode fromString(long transactionId, String arguments) {
- // simple length check
- if (arguments.length() != Constants.UUID_FORMATTED_LENGTH) {
- throw new IllegalArgumentException("arguments is not a uuid");
- }
- return new DeleteNode(transactionId, arguments);
- }
+ /**
+ * Creates a new DeleteNode action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param uuid
+ * the uuid of the node to delete.
+ */
+ DeleteNode(long transactionId, String uuid)
+ {
+ super(transactionId, Action.TYPE_DELETE_NODE);
+ this.uuid = uuid;
+ }
- /**
- * Deletes a node from the index.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- String uuidString = uuid.toString();
- // check if indexing queue is still working on
- // this node from a previous update
- Document doc = index.indexingQueue.removeDocument(uuidString);
- if (doc != null) {
- Util.disposeDocument(doc);
- }
- Term idTerm = new Term(FieldNames.UUID, uuidString);
- // if the document cannot be deleted from the volatile index
- // delete it from one of the persistent indexes.
- int num = index.volatileIndex.removeDocument(idTerm);
- if (num == 0) {
- for (int i = index.indexes.size() - 1; i >= 0; i--) {
- // only look in registered indexes
- PersistentIndex idx = (PersistentIndex) index.indexes
- .get(i);
- if (index.indexNames.contains(idx.getName())) {
- num = idx.removeDocument(idTerm);
- if (num > 0) {
- return;
- }
- }
- }
- }
- }
+ /**
+ * Creates a new DeleteNode action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * the uuid of the node to delete.
+ * @return the DeleteNode action.
+ * @throws IllegalArgumentException
+ * if the arguments are malformed. Not a UUID.
+ */
+ static DeleteNode fromString(long transactionId, String arguments)
+ {
+ // simple length check
+ if (arguments.length() != Constants.UUID_FORMATTED_LENGTH)
+ {
+ throw new IllegalArgumentException("arguments is not a uuid");
+ }
+ return new DeleteNode(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer(ENTRY_LENGTH);
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.DELETE_NODE);
- logLine.append(' ');
- logLine.append(uuid);
- return logLine.toString();
- }
- }
+ /**
+ * Deletes a node from the index.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ String uuidString = uuid.toString();
+ // check if indexing queue is still working on
+ // this node from a previous update
+ Document doc = index.indexingQueue.removeDocument(uuidString);
+ if (doc != null)
+ {
+ Util.disposeDocument(doc);
+ }
+ Term idTerm = new Term(FieldNames.UUID, uuidString);
+ // if the document cannot be deleted from the volatile index
+ // delete it from one of the persistent indexes.
+ int num = index.volatileIndex.removeDocument(idTerm);
+ if (num == 0)
+ {
+ for (int i = index.indexes.size() - 1; i >= 0; i--)
+ {
+ // only look in registered indexes
+ PersistentIndex idx = (PersistentIndex)index.indexes.get(i);
+ if (index.indexNames.contains(idx.getName()))
+ {
+ num = idx.removeDocument(idTerm);
+ if (num > 0)
+ {
+ return;
+ }
+ }
+ }
+ }
+ }
- /**
- * Starts a transaction.
- */
- private static class Start extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer(ENTRY_LENGTH);
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.DELETE_NODE);
+ logLine.append(' ');
+ logLine.append(uuid);
+ return logLine.toString();
+ }
+ }
- /**
- * Creates a new Start transaction action.
- *
- * @param transactionId
- * the id of the transaction that started.
- */
- Start(long transactionId) {
- super(transactionId, Action.TYPE_START);
- }
+ /**
+ * Starts a transaction.
+ */
+ private static class Start extends Action
+ {
- /**
- * Creates a new Start action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * ignored by this method.
- * @return the Start action.
- */
- static Start fromString(long transactionId, String arguments) {
- return new Start(transactionId);
- }
+ /**
+ * Creates a new Start transaction action.
+ *
+ * @param transactionId
+ * the id of the transaction that started.
+ */
+ Start(long transactionId)
+ {
+ super(transactionId, Action.TYPE_START);
+ }
- /**
- * Sets the current transaction id on <code>index</code>.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- index.currentTransactionId = getTransactionId();
- }
+ /**
+ * Creates a new Start action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * ignored by this method.
+ * @return the Start action.
+ */
+ static Start fromString(long transactionId, String arguments)
+ {
+ return new Start(transactionId);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- return Long.toString(getTransactionId()) + ' ' + Action.START;
- }
- }
+ /**
+ * Sets the current transaction id on <code>index</code>.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ index.currentTransactionId = getTransactionId();
+ }
- /**
- * Commits the volatile index to disk.
- */
- private static class VolatileCommit extends Action {
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ return Long.toString(getTransactionId()) + ' ' + Action.START;
+ }
+ }
- /**
- * The name of the target index to commit to.
- */
- private final String targetIndex;
+ /**
+ * Commits the volatile index to disk.
+ */
+ private static class VolatileCommit extends Action
+ {
- /**
- * Creates a new VolatileCommit action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- */
- VolatileCommit(long transactionId, String targetIndex) {
- super(transactionId, Action.TYPE_VOLATILE_COMMIT);
- this.targetIndex = targetIndex;
- }
+ /**
+ * The name of the target index to commit to.
+ */
+ private final String targetIndex;
- /**
- * Creates a new VolatileCommit action.
- *
- * @param transactionId
- * the id of the transaction that executes this action.
- * @param arguments
- * ignored by this implementation.
- * @return the VolatileCommit action.
- */
- static VolatileCommit fromString(long transactionId, String arguments) {
- return new VolatileCommit(transactionId, arguments);
- }
+ /**
+ * Creates a new VolatileCommit action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ */
+ VolatileCommit(long transactionId, String targetIndex)
+ {
+ super(transactionId, Action.TYPE_VOLATILE_COMMIT);
+ this.targetIndex = targetIndex;
+ }
- /**
- * Commits the volatile index to disk.
- *
- * @inheritDoc
- */
- public void execute(MultiIndex index) throws IOException {
- VolatileIndex volatileIndex = index.getVolatileIndex();
- PersistentIndex persistentIndex = index
- .getOrCreateIndex(targetIndex);
- persistentIndex.copyIndex(volatileIndex);
- index.resetVolatileIndex();
- }
+ /**
+ * Creates a new VolatileCommit action.
+ *
+ * @param transactionId
+ * the id of the transaction that executes this action.
+ * @param arguments
+ * ignored by this implementation.
+ * @return the VolatileCommit action.
+ */
+ static VolatileCommit fromString(long transactionId, String arguments)
+ {
+ return new VolatileCommit(transactionId, arguments);
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- StringBuffer logLine = new StringBuffer();
- logLine.append(Long.toString(getTransactionId()));
- logLine.append(' ');
- logLine.append(Action.VOLATILE_COMMIT);
- logLine.append(' ');
- logLine.append(targetIndex);
- return logLine.toString();
- }
- }
+ /**
+ * Commits the volatile index to disk.
+ *
+ * @inheritDoc
+ */
+ public void execute(MultiIndex index) throws IOException
+ {
+ VolatileIndex volatileIndex = index.getVolatileIndex();
+ PersistentIndex persistentIndex = index.getOrCreateIndex(targetIndex);
+ persistentIndex.copyIndex(volatileIndex);
+ index.resetVolatileIndex();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ StringBuffer logLine = new StringBuffer();
+ logLine.append(Long.toString(getTransactionId()));
+ logLine.append(' ');
+ logLine.append(Action.VOLATILE_COMMIT);
+ logLine.append(' ');
+ logLine.append(targetIndex);
+ return logLine.toString();
+ }
+ }
+
+ /**
+ * Set indexer io mode.
+ * @param ioMode
+ */
+ public void setIndexerIoMode(IndexerIoMode ioMode)
+ {
+ log.info("Indexer io mode=" + ioMode);
+ //do some thing if changed
+ if (!this.ioMode.equals(ioMode))
+ {
+ this.ioMode = ioMode;
+ switch (ioMode)
+ {
+ case READ_ONLY :
+ // stop timer
+ flushTask.cancel();
+ break;
+ case READ_WRITE :
+ scheduleFlushTask();
+ break;
+ }
+ }
+
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-12-09 16:24:25 UTC (rev 974)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-12-09 16:25:01 UTC (rev 975)
@@ -418,7 +418,7 @@
/**
* Indexer io mode
*/
- private IndexerIoMode ioMode;
+ private IndexerIoMode ioMode = IndexerIoMode.READ_WRITE;
/**
* Working constructor.
@@ -2651,8 +2651,20 @@
public void setIndexerIoMode(IndexerIoMode ioMode) throws IOException, RepositoryException
{
log.info("Indexer io mode=" + ioMode);
- this.ioMode = ioMode;
+ //do some thing if changed
+ if (!this.ioMode.equals(ioMode))
+ {
+ this.ioMode = ioMode;
+ switch (ioMode)
+ {
+ case READ_ONLY :
+ index.setIndexerIoMode(ioMode);
+ break;
+ case READ_WRITE :
+ index.setIndexerIoMode(ioMode);
+ break;
+ }
+ }
}
-
}
16 years, 7 months