Author: pnedonosko
Date: 2009-11-24 02:45:22 -0500 (Tue, 24 Nov 2009)
New Revision: 815
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-246: References handling on the end ofoperations
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-23
17:09:12 UTC (rev 814)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-24
07:45:22 UTC (rev 815)
@@ -196,6 +196,22 @@
+ data.getQPath().getAsString());
}
+ // add to parent's properties attr
+ String propName = data.getQPath().getName().getAsString();
+ if (parent.get(propName) == null)
+ {
+ parent.put(propName, data.getIdentifier());
+ }
+ else
+ {
+ throw new ItemExistsException("Property already exists " +
data.getQPath().getAsString());
+ }
+
+ // add in PROPERTIES
+ Node<Serializable, Object> prop =
propsRoot.addChild(makePropFqn(data.getIdentifier()));
+ prop.put(ITEM_DATA, data);
+
+ // REFERENCEs hadnling
if (data.getType() == PropertyType.REFERENCE)
{
Fqn propIdentifier = Fqn.fromElements(data.getIdentifier());
@@ -210,16 +226,14 @@
}
catch (UnsupportedEncodingException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
catch (IOException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
- Fqn refNode = makeNodeFqn(refNodeUUID);
+ Fqn<String> refNode = makeNodeFqn(refNodeUUID);
// add to $REFS map
Node<Serializable, Object> refParent = refsRoot.getChild(refNode);
@@ -230,23 +244,7 @@
refParent.addChild(propIdentifier);
}
-
- }
-
- // add to parent's properties attr
- String propName = data.getQPath().getName().getAsString();
- if (parent.get(propName) == null)
- {
- parent.put(propName, data.getIdentifier());
- }
- else
- {
- throw new ItemExistsException("Property already exists " +
data.getQPath().getAsString());
- }
-
- // add in PROPERTIES
- Node<Serializable, Object> prop =
propsRoot.addChild(makePropFqn(data.getIdentifier()));
- prop.put(ITEM_DATA, data);
+ }
}
/**
@@ -337,37 +335,49 @@
+ data.getQPath().getAsString());
}
- Fqn propUUID = makePropFqn(data.getIdentifier());
+ Fqn<String> propUUID = makePropFqn(data.getIdentifier());
Node<Serializable, Object> prop = propsRoot.getChild(propUUID);
- PropertyData oldData = (PropertyData)prop.get(ITEM_DATA);
- if (oldData == null)
+ PropertyData prevData = (PropertyData)prop.get(ITEM_DATA);
+ if (prevData == null)
{
throw new RepositoryException("FATAL PropertyData already empty " +
data.getQPath().getAsString());
}
- if (oldData.getType() == PropertyType.REFERENCE)
+ // remove from parent's properties attributes
+ // TODO validate does deleted
+ if (parent.remove(data.getQPath().getName().getAsString()) == null)
{
+ throw new InvalidItemStateException("Property doesn't exist or deleted
by another Session "
+ + data.getQPath().getAsString());
+ }
+
+ // remove from PROPERTIES
+ if (!propsRoot.removeChild(makePropFqn(data.getIdentifier())))
+ {
+ LOG.warn("Property want not deleted " +
data.getQPath().getAsString());
+ }
+
+ // REFERENCEs handling
+ if (prevData.getType() == PropertyType.REFERENCE)
+ {
// get values from cahce
Set<String> remNodes = new HashSet<String>();
- for (ValueData value : oldData.getValues())
+ for (ValueData value : prevData.getValues())
{
-
try
{
remNodes.add(ValueDataConvertor.readString(value));
}
catch (UnsupportedEncodingException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
catch (IOException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
}
@@ -409,21 +419,7 @@
LOG.warn("Reference record of node " + refNodeUUID + " was
already removed.");
}
}
- }
-
- // remove from parent's properties attributes
- // TODO validate does deleted
- if (parent.remove(data.getQPath().getName().getAsString()) == null)
- {
- throw new InvalidItemStateException("Property doesn't exist or deleted
by another Session "
- + data.getQPath().getAsString());
- }
-
- // remove from PROPERTIES
- if (!propsRoot.removeChild(makePropFqn(data.getIdentifier())))
- {
- LOG.warn("Property want not deleted " +
data.getQPath().getAsString());
- }
+ }
}
/**
@@ -826,8 +822,7 @@
* @param node Node - cache node containing root of JCR subtree.
* @throws RepositoryException on error state detected
*/
- protected void updateTreePath(Node<Serializable, Object> node, QPath rootPath)
- throws RepositoryException
+ protected void updateTreePath(Node<Serializable, Object> node, QPath rootPath)
throws RepositoryException
{
QPath nodePath = rootPath;
@@ -846,12 +841,12 @@
{
// recreate with new path for child Nodes only
nodePath =
- QPath.makeChildPath(rootPath,
prevData.getQPath().getEntries()[prevData.getQPath()
- .getEntries().length - 1]);
+ QPath.makeChildPath(rootPath,
+
prevData.getQPath().getEntries()[prevData.getQPath().getEntries().length - 1]);
TransientNodeData newData =
- new TransientNodeData(nodePath, prevData.getIdentifier(),
prevData.getPersistedVersion(),
- prevData.getPrimaryTypeName(), prevData.getMixinTypeNames(),
prevData
- .getOrderNumber(), prevData.getParentIdentifier(),
prevData.getACL());
+ new TransientNodeData(nodePath, prevData.getIdentifier(),
prevData.getPersistedVersion(), prevData
+ .getPrimaryTypeName(), prevData.getMixinTypeNames(),
prevData.getOrderNumber(), prevData
+ .getParentIdentifier(), prevData.getACL());
newData.addState(TransientPropertyData.TRANSITIVE_PATH_UPDATED);
node.put(ITEM_DATA, newData);
}
@@ -878,11 +873,11 @@
// recreate the property data with new path
QPath newPath =
- QPath.makeChildPath(rootPath,
prevData.getQPath().getEntries()[prevData.getQPath()
- .getEntries().length - 1]);
+ QPath.makeChildPath(rootPath,
+
prevData.getQPath().getEntries()[prevData.getQPath().getEntries().length - 1]);
TransientPropertyData newData =
- new TransientPropertyData(newPath, prevData.getIdentifier(),
prevData.getPersistedVersion(),
- prevData.getType(), prevData.getParentIdentifier(),
prevData.isMultiValued());
+ new TransientPropertyData(newPath, prevData.getIdentifier(),
prevData.getPersistedVersion(), prevData
+ .getType(), prevData.getParentIdentifier(),
prevData.isMultiValued());
newData.addState(TransientPropertyData.TRANSITIVE_PATH_UPDATED);
newData.setValues(prevData.getValues());
prop.put(ITEM_DATA, newData);
@@ -918,22 +913,6 @@
}
updateTreePath(childNode, nodePath);
-
- // TODO cleanup
- // NodeData cacheNodeData = (NodeData)childNode.get(ITEM_DATA);
- // if (cacheNodeData == null)
- // {
- // throw new RepositoryException("Child node data is null.
Parent " + rootPath);
- // }
- //
- // // recreate child Node with new path
- // QPath newPath = QPath.makeChildPath(rootPath,
cacheNodeData.getQPath().getName());
- // TransientNodeData newNodeData =
- // new TransientNodeData(newPath, cacheNodeData.getIdentifier(),
cacheNodeData.getPersistedVersion(),
- // cacheNodeData.getPrimaryTypeName(),
cacheNodeData.getMixinTypeNames(), cacheNodeData.getOrderNumber(),
- // cacheNodeData.getParentIdentifier(), cacheNodeData.getACL());
- // newNodeData.addState(TransientPropertyData.TRANSITIVE_PATH_UPDATED);
- // childNode.put(ITEM_DATA, newNodeData);
}
}
@@ -1028,13 +1007,16 @@
PropertyData prevData = (PropertyData)prop.get(ITEM_DATA);
if (prevData == null)
{
- throw new RepositoryException("FATAL Old Property data is null. Parent
" + data.getQPath().getAsString());
+ throw new RepositoryException("FATAL Previous Property data is null. Parent
" + data.getQPath().getAsString());
}
+ // update data
+ prop.put(ITEM_DATA, data);
+
+ // REFERENCEs handling
if (prevData.getType() == PropertyType.REFERENCE || data.getType() ==
PropertyType.REFERENCE)
{
-
- //get Set of old values
+ // get Set of old values
Set<String> removeSet = new HashSet<String>();
if (prevData.getType() == PropertyType.REFERENCE)
{
@@ -1046,13 +1028,11 @@
}
catch (UnsupportedEncodingException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
catch (IOException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
}
}
@@ -1069,13 +1049,11 @@
}
catch (UnsupportedEncodingException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
catch (IOException e)
{
- // TODO Auto-generated catch block
- throw new RepositoryException(e.getMessage(), e);
+ throw new RepositoryException(e);
}
}
}
@@ -1122,9 +1100,6 @@
node.addChild(propFqn);
}
}
-
- // remove
- prop.put(ITEM_DATA, data);
}
/**
@@ -1187,7 +1162,7 @@
*/
public void close() throws IllegalStateException, RepositoryException
{
- // TODO Auto-generated method stub
+ // not actual
}
/**