Author: nfilotto
Date: 2009-12-15 03:37:26 -0500 (Tue, 15 Dec 2009)
New Revision: 1052
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-199: JBoss Cache persistence prototype
Fix issues related to 2 TCK tests that did not pass
testSaveInvalidStateException(org.apache.jackrabbit.test.api.SessionTest)
testSaveInvalidStateException(org.apache.jackrabbit.test.api.NodeTest)
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-12-15
08:31:59 UTC (rev 1051)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-15
08:37:26 UTC (rev 1052)
@@ -175,24 +175,35 @@
{
startBatch();
- if (data.getParentIdentifier() != null) {
- final Fqn<String> name = makeChildNodeFqn(data.getQPath()
- .getEntries()[data.getQPath().getEntries().length - 1]);
- Object value = cache.put(Fqn.fromRelativeFqn(Fqn
- .fromElements(JBossCacheStorage.NODES), Fqn
- .fromRelativeFqn(makeNodeFqn(data.getParentIdentifier()),
- name)), ITEM_ID, data.getIdentifier());
+ Object value;
+ if (data.getParentIdentifier() != null)
+ {
+ Node<Serializable, Object> parent =
nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
+ if (parent == null)
+ {
+ throw new InvalidItemStateException("Node's parent doesn't exist
or removed by another Session "
+ + data.getQPath().getAsString());
+ }
+ final Fqn<String> name =
+
makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]);
+ value =
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES),
Fqn.fromRelativeFqn(
+ makeNodeFqn(data.getParentIdentifier()), name)), ITEM_ID,
data.getIdentifier());
- if (value != null) {
- throw new ItemExistsException("Node already exists "
- + data.getQPath().getAsString());
- }
- }
+ if (value != null)
+ {
+ throw new ItemExistsException("Node already exists " +
data.getQPath().getAsString());
+ }
+ }
- // add in NODES
- cache.put(Fqn.fromRelativeFqn(
- Fqn.fromElements(JBossCacheStorage.NODES), makeNodeFqn(data
- .getIdentifier())), ITEM_DATA, data);
+ // add in NODES
+ value =
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES),
makeNodeFqn(data.getIdentifier())),
+ ITEM_DATA, data);
+ if (value != null)
+ {
+ throw new ItemExistsException("Node already exists " +
data.getQPath().getAsString());
+ }
}
/**
@@ -203,25 +214,37 @@
{
startBatch();
- String propName = data.getQPath().getName().getAsString();
- Object value = cache.put(Fqn.fromRelativeFqn(Fqn
- .fromElements(JBossCacheStorage.NODES), makeNodeFqn(data
- .getParentIdentifier())), propName, data.getIdentifier());
+ Node<Serializable, Object> parent =
nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
+ if (parent == null)
+ {
+ throw new InvalidItemStateException("Property's parent doesn't
exist or removed by another Session "
+ + data.getQPath().getAsString());
+ }
+
+ String propName = data.getQPath().getName().getAsString();
+ Object value =
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.NODES),
makeNodeFqn(data
+ .getParentIdentifier())), propName, data.getIdentifier());
- if (value != null) {
- throw new ItemExistsException("Property already exists "
- + data.getQPath().getAsString());
- }
+ if (value != null)
+ {
+ throw new ItemExistsException("Property already exists " +
data.getQPath().getAsString());
+ }
- // add in PROPERTIES
- cache.put(Fqn.fromRelativeFqn(
- Fqn.fromElements(JBossCacheStorage.PROPS), makePropFqn(data
- .getIdentifier())), ITEM_DATA, data);
+ // add in PROPERTIES
+ value =
+ cache.put(Fqn.fromRelativeFqn(Fqn.fromElements(JBossCacheStorage.PROPS),
makePropFqn(data.getIdentifier())),
+ ITEM_DATA, data);
- // REFERENCEs hadnling
- if (data.getType() == PropertyType.REFERENCE) {
- addReferences(data);
- }
+ if (value != null)
+ {
+ throw new ItemExistsException("Property already exists " +
data.getQPath().getAsString());
+ }
+
+ // REFERENCEs hadnling
+ if (data.getType() == PropertyType.REFERENCE) {
+ addReferences(data);
+ }
}
/**
Show replies by date