[exo-jcr-commits] exo-jcr SVN: r923 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Dec 4 05:45:17 EST 2009
Author: areshetnyak
Date: 2009-12-04 05:45:15 -0500 (Fri, 04 Dec 2009)
New Revision: 923
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexModificationsBuilder.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
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/JDBCCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-293 : The reuse tree algorithm for JbossCache nodes.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexModificationsBuilder.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexModificationsBuilder.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexModificationsBuilder.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jbosscache.IdTreeHelper;
import org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheStorage;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
@@ -62,7 +63,7 @@
@Override
public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
@@ -79,7 +80,7 @@
@Override
public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
@@ -98,7 +99,7 @@
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
@@ -115,7 +116,7 @@
@Override
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
String uuid = parseUUID(fqn);
@@ -138,7 +139,7 @@
@Override
public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
@@ -159,7 +160,7 @@
@Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- Fqn fqn = command.getFqn();
+ Fqn fqn = IdTreeHelper.buildFqn(command.getFqn());
if (fqn.size() == 2)
{
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -0,0 +1,123 @@
+/*
+ * 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.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.jboss.cache.Fqn;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak at exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class IdTreeHelper
+{
+
+ private final static int xLength = 8;
+
+ /**
+ * Build path by UUID.
+ *
+ * @param id
+ * the identifier (IdGenerator.generate())
+ * @return String[]
+ * the tree id
+ */
+ public static String[] buildPath(String id)
+ {
+ String tree[] = new String[id.length()];
+
+ for (int i = 1; i < id.length() + 1; i++)
+ tree[i-1] = id.substring(i - 1, i);
+
+ return tree;
+ }
+
+ /*public static String[] buildPath(String id)
+ {
+ String tree[] = new String[xLength +1];
+
+ char[] chs = id.toCharArray();
+ for (int i = 0; i < xLength; i++)
+ tree[i] = String.valueOf(chs[i]);
+
+ tree[xLength] = id.substring(xLength);
+
+ return tree;
+ }*/
+
+ /**
+ * Create that transformation
+ *
+ * /$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0
+ * -->
+ * /$NODES/00exo0jcr0root0uuid0000000000000
+ *
+ * /$NODES/0/0/e/x/o/0/j/c/r/0/r/o/o/t/0/u/u/i/d/0/0/0/0/0/0/0/0/0/0/0/0/0/subNodeName:1
+ * -->
+ * /$NODES/00exo0jcr0root0uuid0000000000000/subNodeName:1
+ *
+ * @param treeFqn
+ * the tree Fqn
+ * @return Fqn
+ */
+ public static Fqn buildFqn(Fqn treeFqn)
+ {
+ String id = treeFqn.getSubFqn(1, IdGenerator.IDENTIFIER_LENGTH + 1).toString();
+
+ id = id.replaceAll(Fqn.SEPARATOR, "");
+
+ String[] sArray = new String[treeFqn.size() - IdGenerator.IDENTIFIER_LENGTH + 1];
+
+ sArray[0] = (String) treeFqn.get(0);
+ sArray[1] = id;
+
+ int sArrayIndex = 2;
+
+ for (int i=(IdGenerator.IDENTIFIER_LENGTH + 1); i < treeFqn.size(); i++)
+ {
+ sArray[sArrayIndex++] = (String) treeFqn.get(i);
+ }
+
+ return Fqn.fromElements(sArray);
+ }
+
+ /*public static Fqn buildFqn(Fqn treeFqn)
+ {
+ String oldId = treeFqn.getSubFqn(1, xLength + 2).toString();
+
+ String id = oldId.replaceAll(Fqn.SEPARATOR, "");
+
+ String[] sArray = new String[treeFqn.size() - (xLength)];
+
+ sArray[0] = (String) treeFqn.get(0);
+ sArray[1] = id;
+
+ int sArrayIndex = 1;
+
+ for (int i=(xLength + 2); i < treeFqn.size(); i++)
+ {
+ sArray[++sArrayIndex] = (String) treeFqn.get(i);
+ }
+
+ return Fqn.fromElements(sArray);
+ }*/
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IdTreeHelper.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -91,7 +91,7 @@
{
//return Fqn.fromRelativeFqn(nodesRoot, Fqn.fromElements(parentId, itemName.getAsString(true)));
//return Fqn.fromRelativeFqn(nodesRoot.getFqn(), Fqn.fromElements(parentId, nodeName.getAsString(true)));
- return Fqn.fromElements(parentId, nodeName.getAsString(true));
+ return Fqn.fromRelativeElements(Fqn.fromElements(IdTreeHelper.buildPath(parentId)), nodeName.getAsString(true));
}
/**
@@ -114,7 +114,7 @@
protected Fqn<String> makeNodeFqn(String nodeId)
{
//return Fqn.fromRelativeFqn(nodesRoot, Fqn.fromElements(nodeId));
- return Fqn.fromElements(nodeId);
+ return Fqn.fromElements(IdTreeHelper.buildPath(nodeId));
}
/**
@@ -126,7 +126,7 @@
protected Fqn<String> makePropFqn(String propId)
{
//return Fqn.fromRelativeFqn(propsRoot, Fqn.fromElements(propId));
- return Fqn.fromElements(propId);
+ return Fqn.fromElements(IdTreeHelper.buildPath(propId));
}
}
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-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -174,7 +174,7 @@
if (data.getParentIdentifier() != null)
{
// check if parent is cached
- Node<Serializable, Object> parent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
+ 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 "
@@ -621,7 +621,7 @@
{
ArrayList<PropertyData> references = new ArrayList<PropertyData>();
- Node<Serializable, Object> node = this.refsRoot.getChild(Fqn.fromElements(nodeIdentifier));
+ Node<Serializable, Object> node = this.refsRoot.getChild(Fqn.fromElements(IdTreeHelper.buildPath(nodeIdentifier)));
if (node != null)
{
Set<Object> props = node.getChildrenNames();
@@ -629,7 +629,7 @@
for (Object o : props)
{
String propUUID = (String)o;
- Node<Serializable, Object> prop = propsRoot.getChild(Fqn.fromElements(propUUID));
+ Node<Serializable, Object> prop = propsRoot.getChild(Fqn.fromElements(IdTreeHelper.buildPath(propUUID)));
if (prop == null)
{
throw new RepositoryException("FATAL Property record not found(" + propUUID
@@ -817,7 +817,7 @@
String propId = (String)node.get((String)key);
if (propId != null)
{
- Node<Serializable, Object> prop = propsRoot.getChild(Fqn.fromElements(propId));
+ Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(propId));
if (prop == null)
{
throw new IllegalStateException("Property not exists or was deleted by another Session " + rootPath
@@ -1017,10 +1017,8 @@
{
startBatch();
- final Fqn propFqn = Fqn.fromElements(data.getIdentifier());
-
// update in PROPERTIES
- Node<Serializable, Object> prop = propsRoot.getChild(propFqn);
+ Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(data.getIdentifier()));
if (prop == null)
{
throw new IllegalStateException("Property was deleted " + data.getQPath().getAsString());
@@ -1246,8 +1244,8 @@
// add references to nodes
for (String id : addSet)
{
- Fqn nodeFqn = Fqn.fromElements(id);
- Node<Serializable, Object> node = refsRoot.getChild(nodeFqn);
+ Fqn nodeFqn = makeNodeFqn(id);
+ Node<Serializable, Object> node = refsRoot.getChild(nodeFqn);
if (node == null)
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -202,15 +202,17 @@
private void doRemove(Modification modification, JDBCStorageConnection conn) throws IllegalStateException,
RepositoryException
{
- if (modification.getFqn().size() == 2)
+ Fqn fqn = IdTreeHelper.buildFqn(modification.getFqn());
+
+ if (fqn.size() == 2)
{
- String identifier = (String)modification.getFqn().get(1);
+ String identifier = (String)fqn.get(1);
- if (modification.getFqn().get(0).equals(JBossCacheStorage.NODES))
+ if (fqn.get(0).equals(JBossCacheStorage.NODES))
{
conn.deleteNode(identifier);
}
- else if (modification.getFqn().get(0).equals(JBossCacheStorage.PROPS))
+ else if (fqn.get(0).equals(JBossCacheStorage.PROPS))
{
conn.deleteProperty(identifier);
}
@@ -254,7 +256,9 @@
*/
private void doUpdate(Modification m, JDBCStorageConnection conn) throws IllegalStateException, RepositoryException
{
- if (m.getFqn().size() == 2 && m.getValue() instanceof TransientItemData)
+ Fqn fqn = IdTreeHelper.buildFqn(m.getFqn());
+
+ if (fqn.size() == 2 && m.getValue() instanceof TransientItemData)
{
//Check flag it's mixin update for node, if this flag set we have node need to
TransientItemData item = (TransientItemData)m.getValue();
@@ -262,7 +266,7 @@
if ((item.getState() & TransientItemData.TRANSITIVE_PATH_UPDATED) == 0)
{
// if not a transitive update of path, update it in the database
- if (conn.itemExists((String)m.getFqn().get(1), item.isNode()))
+ if (conn.itemExists((String)fqn.get(1), item.isNode()))
{
// update if it's non transitive update
if (item.isNode())
@@ -298,8 +302,9 @@
/**
* {@inheritDoc}
*/
- public Map<Object, Object> get(Fqn name) throws Exception
+ public Map<Object, Object> get(Fqn fqn) throws Exception
{
+ Fqn name = ( fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
Map<Object, Object> attrs;
@@ -456,10 +461,12 @@
/**
* {@inheritDoc}
*/
- public boolean exists(Fqn name) throws Exception
+ public boolean exists(Fqn fqn) throws Exception
{
JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ Fqn name = ( fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
+
boolean exists;
try
@@ -584,9 +591,11 @@
/**
* {@inheritDoc}
*/
- public Set<?> getChildrenNames(Fqn name) throws Exception
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
{
// return child nodes names
+
+ Fqn name = ( fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
try
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -59,7 +59,7 @@
// write to : /$NODES/ParentID/ChildName
// key=ITEM_ID val = uuid
String childFqn =
- "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier() + "/"
+ "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getParentIdentifier())) + "/"
+ data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString();
// Fire modification child added
list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(childFqn)));
@@ -67,7 +67,7 @@
list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(childFqn), JBossCacheStorage.ITEM_ID,
data.getIdentifier()));
}
- String nodeFqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
+ String nodeFqn = "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier()));
// add PUT_DATA modification
list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(nodeFqn)));
@@ -94,11 +94,11 @@
{
// remove child from parent
String childFqn =
- "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier() + "/"
+ "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getParentIdentifier())) + "/"
+ data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString();
list.add(new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(childFqn)));
}
- String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
+ String fqn = "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier()));
list.add(new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data));
return list;
}
@@ -116,12 +116,12 @@
public List<Modification> addProperty(PropertyData data)
{
List<Modification> list = new ArrayList<Modification>();
- String parentFqn = "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier();
+ String parentFqn = "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getParentIdentifier()));
// write attribute to parent's map
list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(parentFqn), data.getQPath().getName()
.getAsString(), data.getIdentifier()));
- String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier()));
// add modification PUT_DATA if enabled
list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(fqn)));
// put property data
@@ -144,7 +144,7 @@
public List<Modification> updateProperty(PropertyData data)
{
List<Modification> list = new ArrayList<Modification>();
- String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier()));
Modification modification =
new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data);
list.add(modification);
@@ -165,14 +165,14 @@
List<Modification> list = new ArrayList<Modification>();
Fqn fqn =
- Fqn.fromElements(JBossCacheStorage.NODES, data.getParentIdentifier(), data.getQPath().getEntries()[data
+ Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getParentIdentifier())) + "/" + data.getQPath().getEntries()[data
.getQPath().getEntries().length - 1].getAsString(true));
Modification modification =
new Modification(ModificationType.PUT_KEY_VALUE, fqn, JBossCacheStorage.ITEM_ID, data.getIdentifier());
list.add(modification);
- fqn = Fqn.fromElements(JBossCacheStorage.NODES, data.getIdentifier());
+ fqn = Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier())));
modification = new Modification(ModificationType.PUT_KEY_VALUE, fqn, JBossCacheStorage.ITEM_DATA, data);
list.add(modification);
@@ -193,12 +193,12 @@
public List<Modification> removeProperty(PropertyData data)
{
List<Modification> list = new ArrayList<Modification>();
- String parentFqn = "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier();
+ String parentFqn = "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(data.getParentIdentifier()));
// write attribute to parent's map
list.add(new Modification(ModificationType.REMOVE_KEY_VALUE, Fqn.fromString(parentFqn), data.getQPath().getName()
.getAsString()));
- String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(data.getIdentifier()));
Modification modification =
new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data);
list.add(modification);
@@ -245,4 +245,22 @@
list.add(new Modification(ModificationType.REMOVE_DATA, Fqn.fromString("/" + JBossCacheStorage.SESSION)));
return list;
}
+
+ /**
+ * Create from array of string the string with separator Fqn.SEPARATOR.
+ *
+ * @param sArray
+ * @return
+ */
+ protected String makeString(String[] sArray ) {
+
+ String result = sArray[0];
+
+ for (int i=1; i<sArray.length; i++)
+ {
+ result += (Fqn.SEPARATOR + sArray[i]);
+ }
+
+ return result;
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -133,7 +133,7 @@
protected void checkNode(Node<Serializable, Object> rootNode, String nodeId, QPath nodePath)
{
- Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(nodeId));
+ Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(nodeId)));
// check Node
Object dataObject = node.get(JBossCacheStorageConnection.ITEM_DATA);
@@ -147,7 +147,7 @@
protected void checkProp(String propId, QPath propPath, Object propValue) throws UnsupportedEncodingException,
IllegalStateException, IOException
{
- Node<Serializable, Object> prop = props.getChild(Fqn.fromElements(propId));
+ Node<Serializable, Object> prop = props.getChild(Fqn.fromElements(IdTreeHelper.buildPath(propId)));
Object dataObject = prop.get(JBossCacheStorage.ITEM_DATA);
assertNotNull("Property item data should exists", dataObject);
assertTrue("Property item data is not a Property", dataObject instanceof PropertyData);
@@ -184,7 +184,7 @@
assertNotNull("Child Node should exists", childNode);
String childNodeId = (String)childNode.get(JBossCacheStorage.ITEM_ID);
- Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(childNodeId));
+ Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(childNodeId)));
assertNotNull("Node by ID should exists", node);
Object childNodeObject = node.get(JBossCacheStorage.ITEM_DATA);
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -29,6 +29,7 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.util.IdGenerator;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -58,7 +59,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -71,7 +72,7 @@
treePrint(nodes);
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertNotNull("Node expected", rootNode);
// check root Node
@@ -90,7 +91,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
String propValue1 = "Property value #1";
@@ -98,7 +99,7 @@
conn.add(propData1);
// add property (/jcr:mixinTypes)
- String propId2 = "2";
+ String propId2 = IdGenerator.generate();
QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
TransientPropertyData propData2 = new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false);
String propValue2 = "Property value #2";
@@ -108,7 +109,7 @@
// check in props
treePrint(props);
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
@@ -131,7 +132,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -141,7 +142,7 @@
new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertEquals("Number of childs wrong", 2, rootNode.getChildren().size());
@@ -170,9 +171,9 @@
assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
// check nodes
- assertNull("Node item data should not exists", nodes.getChild(Fqn.fromElements(node1id)));
+ assertNull("Node item data should not exists", nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(node1id))));
- Node<Serializable, Object> system = nodes.getChild(Fqn.fromElements(Constants.SYSTEM_UUID));
+ Node<Serializable, Object> system = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.SYSTEM_UUID)));
assertNotNull("Node item data should exists", system);
}
@@ -183,17 +184,17 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
1, 1, Constants.ROOT_UUID, false));
// add property (/jcr:mixinTypes)
- String propId2 = "2";
+ String propId2 = IdGenerator.generate();
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
1, 1, Constants.ROOT_UUID, false));
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
// delete /jcr:primaryType
conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE),
@@ -209,8 +210,8 @@
// check in props
treePrint(props);
- assertNull("Property item data should not exists", props.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should exists", props.getChild(Fqn.fromElements(propId2)));
+ assertNull("Property item data should not exists", props.getChild(Fqn.fromElements(IdTreeHelper.buildPath(propId1))));
+ assertNotNull("Property item data should exists", props.getChild(Fqn.fromElements(IdTreeHelper.buildPath(propId2))));
}
public void testUpdateNode() throws Exception
@@ -220,27 +221,27 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]snsNode:1");
int node1OrderNumb = 0;
int node1version = 1;
conn.add(new TransientNodeData(node1path, node1id, node1version, Constants.NT_UNSTRUCTURED, new InternalQName[0],
node1OrderNumb, Constants.ROOT_UUID, new AccessControlList()));
- String node2id = "2";
+ String node2id = IdGenerator.generate();
QPath node2path = QPath.parse("[]:1[]snsNode:2");
int node2OrderNumb = 1;
conn.add(new TransientNodeData(node2path, node2id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
node2OrderNumb, Constants.ROOT_UUID, new AccessControlList()));
- String node3id = "3";
+ String node3id = IdGenerator.generate();
QPath node3path = QPath.parse("[]:1[]baseNode:1");
int node3OrderNumb = 2;
conn.add(new TransientNodeData(node3path, node3id, 1, Constants.NT_BASE, new InternalQName[0], node3OrderNumb,
Constants.ROOT_UUID, new AccessControlList()));
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
// before
treePrint(nodes);
@@ -322,27 +323,27 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]snsNode:1");
int node1OrderNumb = 0;
int node1version = 1;
conn.add(new TransientNodeData(node1path, node1id, node1version, Constants.NT_UNSTRUCTURED, new InternalQName[0],
node1OrderNumb, Constants.ROOT_UUID, new AccessControlList()));
- String node2id = "2";
+ String node2id = IdGenerator.generate();
QPath node2path = QPath.parse("[]:1[]snsNode:2");
int node2OrderNumb = 1;
conn.add(new TransientNodeData(node2path, node2id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
node2OrderNumb, Constants.ROOT_UUID, new AccessControlList()));
- String node3id = "3";
+ String node3id = IdGenerator.generate();
QPath node3path = QPath.parse("[]:1[]snsNode:3");
int node3OrderNumb = 2;
conn.add(new TransientNodeData(node3path, node3id, 1, Constants.NT_BASE, new InternalQName[0], node3OrderNumb,
Constants.ROOT_UUID, new AccessControlList()));
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
// before
treePrint(nodes);
@@ -394,7 +395,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/prop1)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
String propValue1 = "Property value #1";
@@ -410,7 +411,7 @@
// check
treePrint(props);
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size());
@@ -425,7 +426,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -453,12 +454,12 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
// add property (/jcr:mixinTypes)
- String propId2 = "2";
+ String propId2 = IdGenerator.generate();
QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
@@ -484,7 +485,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -509,12 +510,12 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
// add property (/jcr:mixinTypes)
- String propId2 = "2";
+ String propId2 = IdGenerator.generate();
QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
@@ -534,7 +535,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -577,23 +578,23 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
1, 1, Constants.ROOT_UUID, false));
// add property (/jcr:mixinTypes)
- String propId2 = "2";
+ String propId2 = IdGenerator.generate();
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
1, 1, Constants.ROOT_UUID, false));
// add property (/a)
- String propId3 = "3";
+ String propId3 = IdGenerator.generate();
InternalQName propName3 = InternalQName.parse("[]a");
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName3), propId3, 1, 1,
Constants.ROOT_UUID, false));
// add property (/b)
- String propId4 = "4";
+ String propId4 = IdGenerator.generate();
InternalQName propName4 = InternalQName.parse("[]b");
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName4), propId4, 1, 1,
Constants.ROOT_UUID, false));
@@ -640,17 +641,17 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]firstParent:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
- String node2id = "2";
+ String node2id = IdGenerator.generate();
QPath node2path = QPath.parse("[]:1[]secondParent:1");
conn.add(new TransientNodeData(node2path, node2id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
- String node3id = "3";
+ String node3id = IdGenerator.generate();
QPath node3path = QPath.parse("[]:1[]firstParent:1[]node:1");
conn.add(new TransientNodeData(node3path, node3id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
node1id, new AccessControlList()));
@@ -659,7 +660,7 @@
treePrint(nodes);
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertNotNull("Node expected", rootNode);
// check root Node
@@ -670,11 +671,11 @@
checkChildNode(rootNode, node1id, node1path);
checkChildNode(rootNode, node2id, node2path);
- Node<Serializable, Object> firstParent = nodes.getChild(Fqn.fromElements(node1id));
+ Node<Serializable, Object> firstParent = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(node1id)));
assertEquals("Childs expected", 1, firstParent.getChildren().size());
checkChildNode(firstParent, node3id, node3path);
- Node<Serializable, Object> secondParent = nodes.getChild(Fqn.fromElements(node2id));
+ Node<Serializable, Object> secondParent = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(node2id)));
assertEquals("Childs expected", 0, secondParent.getChildren().size());
// lets move node
@@ -684,10 +685,10 @@
node2id, new AccessControlList()));
//check results
- firstParent = nodes.getChild(Fqn.fromElements(node1id));
+ firstParent = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(node1id)));
assertEquals("Childs expected", 0, firstParent.getChildren().size());
- secondParent = nodes.getChild(Fqn.fromElements(node2id));
+ secondParent = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(node2id)));
assertEquals("Childs expected", 1, secondParent.getChildren().size());
checkChildNode(secondParent, node3id, newnode3path);
@@ -700,7 +701,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -732,7 +733,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
String propValue1 = "Property value #1";
@@ -761,7 +762,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]node:1");
conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
@@ -797,7 +798,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
- String propId1 = "1";
+ String propId1 = IdGenerator.generate();
conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
1, 1, Constants.ROOT_UUID, false));
@@ -828,7 +829,7 @@
new InternalQName[0], 0, null, new AccessControlList()));
// add refernceable node (/node)
- String node1id = "1";
+ String node1id = IdGenerator.generate();
QPath node1path = QPath.parse("[]:1[]firstParent:1");
NodeData node1 =
@@ -837,12 +838,12 @@
conn.add(node1);
// add node2 with reference on node
- String node2id = "2";
+ String node2id = IdGenerator.generate();
QPath node2path = QPath.parse("[]:1[]secondParent:1");
conn.add(new TransientNodeData(node2path, node2id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList()));
- String refpropid = "21";
+ String refpropid = IdGenerator.generate();
TransientPropertyData prop =
new TransientPropertyData(QPath.makeChildPath(node2path, "[]refprop:1"), refpropid, 0, PropertyType.REFERENCE,
node2id, false);
@@ -850,7 +851,7 @@
prop.setValue(new TransientValueData(node1id));
conn.add(prop);
- String node3id = "3";
+ String node3id = IdGenerator.generate();
QPath node3path = QPath.parse("[]:1[]node3:1");
NodeData node3 =
@@ -862,7 +863,7 @@
treePrint(nodes);
// get root node ([]:1)
- Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
+ Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(IdTreeHelper.buildPath(Constants.ROOT_UUID)));
assertNotNull("Node expected", rootNode);
// check root Node
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-12-03 16:07:55 UTC (rev 922)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-12-04 10:45:15 UTC (rev 923)
@@ -348,7 +348,7 @@
NodeData srcNodeData = (NodeData)conn.getItemData(nodeId);
- Map<Object, Object> attributes = loader.get(Fqn.fromElements(JBossCacheStorage.NODES, nodeId));
+ Map<Object, Object> attributes = loader.get(Fqn.fromString( "/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(nodeId))));
assertNotNull(attributes);
@@ -380,7 +380,7 @@
conn.commit();
// tests it
- Map<Object, Object> attrebutes = loader.get(Fqn.fromElements(JBossCacheStorage.NODES, baseNodeId, "[]node1:1"));
+ Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(baseNodeId)) + "/" + "[]node1:1"));
assertNotNull(attrebutes);
@@ -402,7 +402,7 @@
connection.commit();
// tests it
- Map<Object, Object> attrebutes = loader.get(Fqn.fromElements(JBossCacheStorage.PROPS, propData.getIdentifier()));
+ Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(propData.getIdentifier()))));
assertNotNull(attrebutes);
@@ -451,7 +451,7 @@
conn.commit();
// tests it
- Set<String> childs = (Set<String>)loader.getChildrenNames(Fqn.fromElements(JBossCacheStorage.NODES, baseNodeId));
+ Set<String> childs = (Set<String>)loader.getChildrenNames(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(baseNodeId))));
assertNotNull(childs);
@@ -481,7 +481,7 @@
conn.commit();
// tests it
- Map<Object, Object> attrebutes = loader.get(Fqn.fromElements(JBossCacheStorage.NODES, baseNodeId));
+ Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(baseNodeId))));
assertNotNull(attrebutes);
@@ -565,7 +565,7 @@
// tests it
- Set names = loader.getChildrenNames(Fqn.fromString("/$REFS/" + nodeId));
+ Set names = loader.getChildrenNames(Fqn.fromString("/$REFS/" + makeString(IdTreeHelper.buildPath(nodeId))));
assertTrue(names.size() == 2);
@@ -606,8 +606,8 @@
// tests it
String nodeId = IdGenerator.generate();
- assertFalse(loader.exists(Fqn.fromElements(JBossCacheStorage.NODES, nodeId)));
- assertFalse(loader.exists(Fqn.fromElements(JBossCacheStorage.NODES, baseNodeId, "[]node1:1")));
+ assertFalse(loader.exists(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(nodeId)))));
+ assertFalse(loader.exists(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(baseNodeId)) + "/" + "[]node1:1")));
conn = persistentContainer.openConnection();
@@ -615,8 +615,8 @@
Constants.NT_UNSTRUCTURED, baseNodeId);
conn.commit();
- assertTrue(loader.exists(Fqn.fromElements(JBossCacheStorage.NODES, nodeId)));
- assertTrue(loader.exists(Fqn.fromElements(JBossCacheStorage.NODES, baseNodeId, "[]node1:1")));
+ assertTrue(loader.exists(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(nodeId)))));
+ assertTrue(loader.exists(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + makeString(IdTreeHelper.buildPath(baseNodeId)) + "/" + "[]node1:1")));
}
public void testExistProperty() throws Exception
@@ -629,13 +629,13 @@
createProperty(Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE", false);
// tests it
- assertFalse(loader.exists(Fqn.fromElements(JBossCacheStorage.PROPS, propData.getIdentifier())));
+ assertFalse(loader.exists(Fqn.fromString("/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(propData.getIdentifier())))));
// commit in DB
conn.add(propData);
conn.commit();
- assertTrue(loader.exists(Fqn.fromElements(JBossCacheStorage.PROPS, propData.getIdentifier())));
+ assertTrue(loader.exists(Fqn.fromString("/" + JBossCacheStorage.PROPS + "/" + makeString(IdTreeHelper.buildPath(propData.getIdentifier())))));
}
}
More information about the exo-jcr-commits
mailing list