Author: tolusha
Date: 2010-11-02 09:47:09 -0400 (Tue, 02 Nov 2010)
New Revision: 3379
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
Log:
EXOJCR-1029: Storing result of the method getReferencesData into the cache
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-11-02
11:13:27 UTC (rev 3378)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-11-02
13:47:09 UTC (rev 3379)
@@ -684,11 +684,11 @@
* @param key
* @param value
*/
- public void addToList(Fqn fqn, String key, Object value)
+ public void addToList(Fqn fqn, String key, Object value, boolean forceModify)
{
CompressedChangesBuffer changesContainer = getChangesBufferSafe();
- changesContainer.add(new AddToListContainer(fqn, key, value, parentCache,
changesContainer.getHistoryIndex(),
- local.get(), useExpiration, expirationTimeOut));
+ changesContainer.add(new AddToListContainer(fqn, key, value, parentCache,
forceModify, changesContainer
+ .getHistoryIndex(), local.get(), useExpiration, expirationTimeOut));
}
/**
@@ -861,13 +861,16 @@
private final Serializable key;
private final Object value;
+
+ private final boolean forceModify;
public AddToListContainer(Fqn fqn, Serializable key, Object value,
Cache<Serializable, Object> cache,
- int historicalIndex, boolean local, boolean useExpiration, long timeOut)
+ boolean forceModify, int historicalIndex, boolean local, boolean useExpiration,
long timeOut)
{
super(fqn, ChangesType.PUT_KEY, cache, historicalIndex, local, useExpiration,
timeOut);
this.key = key;
this.value = value;
+ this.forceModify = forceModify;
}
@Override
@@ -879,7 +882,7 @@
Object existingObject = cache.get(getFqn(), key);
Set<Object> newSet = new HashSet<Object>();
// if set found of null, perform add
- if (existingObject instanceof Set || existingObject == null)
+ if (existingObject instanceof Set || (existingObject == null &&
forceModify))
{
// set found
if (existingObject instanceof Set)
@@ -896,7 +899,7 @@
setCacheLocalMode();
cache.put(fqn, key, newSet);
}
- else
+ else if (existingObject != null)
{
LOG.error("Unexpected object found by FQN:" + getFqn() + " and
key:" + key + ". Expected Set, but found:"
+ existingObject.getClass().getName());
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-02
11:13:27 UTC (rev 3378)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-11-02
13:47:09 UTC (rev 3379)
@@ -1025,13 +1025,11 @@
// add in CHILD_NODES
cache.put(makeChildFqn(childNodes, node.getParentIdentifier(),
node.getQPath().getEntries()[node.getQPath()
.getEntries().length - 1]), ITEM_ID, node.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY &&
cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+
+ if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()),
ITEM_LIST, node
- .getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()),
ITEM_LIST,
+ node.getIdentifier(), modifyListsOfChild ==
ModifyChildOption.FORCE_MODIFY);
}
}
@@ -1082,13 +1080,11 @@
// add in CHILD_NODES
cache.put(makeChildFqn(childNodes, node.getParentIdentifier(),
node.getQPath().getEntries()[node.getQPath()
.getEntries().length - 1]), ITEM_ID, node.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY &&
cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+
+ if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()),
ITEM_LIST, node
- .getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()),
ITEM_LIST,
+ node.getIdentifier(), modifyListsOfChild ==
ModifyChildOption.FORCE_MODIFY);
}
}
// add in ITEMS
@@ -1115,18 +1111,17 @@
// add in CHILD_PROPS
cache.put(makeChildFqn(childProps, prop.getParentIdentifier(),
prop.getQPath().getEntries()[prop.getQPath()
.getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY &&
cache.getNode(makeChildListFqn(childPropsList, prop
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+
+ if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY)
{
- cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()),
ITEM_LIST, prop.getIdentifier());
+ cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()),
ITEM_LIST, prop.getIdentifier(),
+ modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
get(prop.getParentIdentifier(),
prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]);
// add referenced property
- if (prop.getType() == PropertyType.REFERENCE)
+ if (modifyListsOfChild != ModifyChildOption.NOT_MODIFY && prop.getType() ==
PropertyType.REFERENCE)
{
for (ValueData vdata : prop.getValues())
{
@@ -1144,13 +1139,8 @@
// Do nothing. Never happens.
}
- Fqn refFqn = makeRefFqn(nodeIdentifier);
- Set<String> set = (Set<String>)cache.get(refFqn, ITEM_LIST);
- if (set != null)
- {
- set.add(prop.getIdentifier());
- cache.addToList(refFqn, ITEM_LIST, prop.getIdentifier());
- }
+ cache.addToList(makeRefFqn(nodeIdentifier), ITEM_LIST, prop.getIdentifier(),
+ modifyListsOfChild == ModifyChildOption.FORCE_MODIFY);
}
}
@@ -1198,22 +1188,6 @@
// remove from CHILD_PROPS_LIST
cache.removeFromList(makeChildListFqn(childPropsList,
item.getParentIdentifier()), ITEM_LIST, item
.getIdentifier());
-
- // remove referenced property
- PropertyData prop = (PropertyData)item;
- if (prop.getType() == PropertyType.REFERENCE)
- {
- // value data is empty on delete, so will try to remove from all lists
- for (Object child : cache.getChildrenNames(refRoot))
- {
- Fqn refFqn = makeRefFqn((String)child);
- Set<String> set = (Set<String>)cache.get(refFqn, ITEM_LIST);
- if (set != null && set.contains(prop.getIdentifier()))
- {
- cache.removeFromList(refFqn, ITEM_LIST, prop.getIdentifier());
- }
- }
- }
}
// remove from ITEMS
cache.removeNode(makeItemFqn(item.getIdentifier()));