Author: pnedonosko
Date: 2009-11-06 10:51:12 -0500 (Fri, 06 Nov 2009)
New Revision: 488
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
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/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.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/JBossCacheTreeStorageConnectionTest.java
Log:
EXOJCR-200: new impl of ADD, REMOVE, UPDATE and GETs
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-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -39,7 +39,10 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import java.io.Serializable;
+
/**
* Created by The eXo Platform SAS.
*
@@ -51,85 +54,74 @@
public abstract class JBossCacheStorage
{
- @Deprecated
- public static final String TREE = "$TREE".intern();
+ public static final String NODES = "$NODES".intern();
+
+ public static final String PROPS = "$PROPS".intern();
- public static final String ITEMS = "$ITEMS".intern();
-
public static final String ITEM_DATA = "$data".intern();
public static final String ITEM_ID = "$id".intern();
- @Deprecated
- protected final Fqn<String> treeRoot;
+ protected final Node<Serializable, Object> nodesRoot;
+
+ protected final Node<Serializable, Object> propsRoot;
- protected final Fqn<String> itemsRoot;
-
- @Deprecated
- protected JBossCacheStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
+ protected JBossCacheStorage(Node<Serializable, Object> nodesRoot,
Node<Serializable, Object> propsRoot)
{
- this.itemsRoot = itemsRoot;
+ this.nodesRoot = nodesRoot;
- this.treeRoot = treeRoot;
+ this.propsRoot = propsRoot;
}
- protected JBossCacheStorage(Fqn<String> itemsRoot)
+ /**
+ * Make Child Node relative Fqn, i.e. ./NIDxxx/NAMExxx.
+ *
+ * @param parentId String
+ * @param nodeName QPathEntry
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildNodeFqn(String parentId, QPathEntry nodeName)
{
- this.itemsRoot = itemsRoot;
-
- this.treeRoot = null;
+ //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));
}
-
- @Deprecated
- protected Fqn<String> makeNodeFqn(QPath nodePath)
+
+ /**
+ * Make Child Node relative Fqn. i.e. ./NAMExxx.
+ *
+ * @param nodeName QPathEntry
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildNodeFqn(QPathEntry nodeName)
{
- QPathEntry[] path = nodePath.getEntries();
- String[] fqns = new String[path.length];
-
- for (int i = 0; i < path.length; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ return Fqn.fromElements(nodeName.getAsString(true));
}
- @Deprecated
- protected Fqn<String> makeParentFqn(QPath propertyPath)
- {
- QPathEntry[] path = propertyPath.getEntries();
- int pathLen = path.length - 1;
- String[] fqns = new String[pathLen];
- for (int i = 0; i < pathLen; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
- }
-
/**
- * Make Child Node Fqn, i.e. /IDxxx/NAMExxx.
+ * Make Node relative Fqn, i.e. ./NIDxxx.
*
- * @param parentId String
- * @param itemName QPathEntry
+ * @param nodeId String
* @return Fqn
*/
- protected Fqn<String> makeChildNodeFqn(String parentId, QPathEntry itemName)
+ protected Fqn<String> makeNodeFqn(String nodeId)
{
- return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromElements(parentId,
itemName.getAsString(true)));
+ //return Fqn.fromRelativeFqn(nodesRoot, Fqn.fromElements(nodeId));
+ return Fqn.fromElements(nodeId);
}
/**
- * Make Item Fqn, i.e. /IDxxx.
+ * Make Property relative Fqn, i.e. ./PIDxxx.
*
- * @param itemId String
+ * @param propId String
* @return Fqn
*/
- protected Fqn<String> makeItemFqn(String itemId)
+ protected Fqn<String> makePropFqn(String propId)
{
- return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
+ //return Fqn.fromRelativeFqn(propsRoot, Fqn.fromElements(propId));
+ return Fqn.fromElements(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-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -18,17 +18,10 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
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.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
@@ -37,6 +30,13 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -69,9 +69,10 @@
*
* @param cache Cache<Serializable, Object>
*/
- public JBossCacheStorageConnection(Cache<Serializable, Object> cache,
Node<Serializable, Object> itemsRoot)
+ public JBossCacheStorageConnection(Cache<Serializable, Object> cache,
Node<Serializable, Object> nodesRoot,
+ Node<Serializable, Object> propsRoot)
{
- super(itemsRoot.getFqn());
+ super(nodesRoot, propsRoot);
this.cache = cache;
}
@@ -83,8 +84,29 @@
IllegalStateException
{
startBatch();
- //cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- //cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); //
treePrint(treeRoot);
+
+ if (data.getParentIdentifier() != null)
+ {
+ // check if parent is cached
+ Fqn<String> parentFqn = makeNodeFqn(data.getParentIdentifier());
+
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent == null)
+ {
+ throw new RepositoryException("Node parent doesn't exist " +
data.getQPath().getAsString());
+ }
+
+ // add child to Parent
+ Node<Serializable, Object> childNode =
+
parent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length
- 1]));
+
+ // set child id attr
+ childNode.put(ITEM_ID, data.getIdentifier());
+ }
+
+ // add in NODES
+ Node<Serializable, Object> node =
nodesRoot.addChild(makeNodeFqn(data.getIdentifier()));
+ node.put(ITEM_DATA, data);
}
/**
@@ -94,11 +116,22 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- //Fqn<String> parentFqn = makeParentFqn(data.getQPath());
- // add an attr to the parent node as key=PropertyName value=PropertyId
- //cache.put(parentFqn, data.getQPath().getName().getAsString(),
data.getIdentifier());
- //cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ // check if parent is cached
+ Fqn<String> parentFqn = makeNodeFqn(data.getParentIdentifier());
+
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent == null)
+ {
+ throw new RepositoryException("Property parent doesn't exist " +
data.getQPath().getAsString());
+ }
+
+ // add to parent's properties attr
+ parent.put(data.getQPath().getName().getAsString(), data.getIdentifier());
+
+ // add in PROPERTIES
+ Node<Serializable, Object> prop =
propsRoot.addChild(makePropFqn(data.getIdentifier()));
+ prop.put(ITEM_DATA, data);
}
/**
@@ -108,8 +141,25 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- //cache.removeNode(makeNodeFqn(data.getQPath()));
- //cache.removeNode(makeIdFqn(data.getIdentifier()));
+
+ if (data.getParentIdentifier() != null)
+ {
+ // check if parent is cached
+ Fqn<String> parentFqn = makeNodeFqn(data.getParentIdentifier());
+
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent == null)
+ {
+ throw new RepositoryException("Node parent doesn't exist " +
data.getQPath().getAsString());
+ }
+
+ // remove child on Parent
+ boolean removed =
+
parent.removeChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length
- 1]));
+ }
+
+ // remove from NODES
+ boolean removed = nodesRoot.removeChild(makeNodeFqn(data.getIdentifier()));
}
/**
@@ -119,9 +169,21 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- // delete attr on parent by key=PropertyName
- //cache.remove(makeParentFqn(data.getQPath()),
data.getQPath().getName().getAsString());
- //cache.removeNode(makeIdFqn(data.getIdentifier()));
+
+ // check if parent is cached
+ Fqn<String> parentFqn = makeNodeFqn(data.getParentIdentifier());
+
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent == null)
+ {
+ throw new RepositoryException("Property parent doesn't exist " +
data.getQPath().getAsString());
+ }
+
+ // remove from parent's properties attr
+ Object prev = parent.remove(data.getQPath().getName().getAsString());
+
+ // remove from PROPERTIES
+ boolean removed = propsRoot.removeChild(makePropFqn(data.getIdentifier()));
}
/**
@@ -130,30 +192,30 @@
public List<NodeData> getChildNodesData(NodeData parent) throws
RepositoryException, IllegalStateException
{
//Set<Object> childNames =
cache.getChildrenNames(makeNodeFqn(parent.getQPath()));
-// Node<Serializable, Object> parentNode =
cache.getNode(makeNodeFqn(parent.getQPath()));
-// if (parentNode == null)
-// {
-// throw new IllegalStateException("Get child Nodes error: parent not found
" + parent.getQPath().getAsString());
-// }
-//
-// Set<Node<Serializable, Object>> childNodes =
parentNode.getChildren();
-//
-// List<NodeData> childs = new ArrayList<NodeData>();
-// for (Node<Serializable, Object> child : childNodes)
-// {
-// String childId = (String)child.get(ITEM_ID);
-//
-// // TODO NodeData or PropertyData? As ItemData check then and cast.
-// NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
-// if (node == null)
-// {
-// throw new RepositoryException("One of childs is null. Parent " +
parent.getQPath().getAsString());
-// }
-// childs.add(node);
-// }
-//
-// return childs;
-
+ // Node<Serializable, Object> parentNode =
cache.getNode(makeNodeFqn(parent.getQPath()));
+ // if (parentNode == null)
+ // {
+ // throw new IllegalStateException("Get child Nodes error: parent not
found " + parent.getQPath().getAsString());
+ // }
+ //
+ // Set<Node<Serializable, Object>> childNodes =
parentNode.getChildren();
+ //
+ // List<NodeData> childs = new ArrayList<NodeData>();
+ // for (Node<Serializable, Object> child : childNodes)
+ // {
+ // String childId = (String)child.get(ITEM_ID);
+ //
+ // // TODO NodeData or PropertyData? As ItemData check then and cast.
+ // NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
+ // if (node == null)
+ // {
+ // throw new RepositoryException("One of childs is null. Parent
" + parent.getQPath().getAsString());
+ // }
+ // childs.add(node);
+ // }
+ //
+ // return childs;
+
return null;
}
@@ -179,31 +241,31 @@
public List<PropertyData> getChildPropertiesData(NodeData parent) throws
RepositoryException, IllegalStateException
{
// TODO treeRoot.getChild(f) possible if f not a direct child???
-// Node<Serializable, Object> parentNode =
cache.getNode(makeNodeFqn(parent.getQPath()));
-// if (parentNode == null)
-// {
-// throw new IllegalStateException("Get child Nodes error: parent not found
" + parent.getQPath().getAsString());
-// }
-//
-// List<PropertyData> childs = new ArrayList<PropertyData>();
-//
-// for (Serializable key : parentNode.getKeys())
-// {
-// if (!key.equals(ITEM_ID))
-// {
-// String propId = (String)parentNode.get(key);
-// // TODO NodeData or PropertyData? As ItemData check then and cast.
-// PropertyData property = (PropertyData)cache.get(makeIdFqn(propId),
ITEM_DATA);
-// if (property == null)
-// {
-// throw new RepositoryException("One of childs is null. Parent "
+ parent.getQPath().getAsString());
-// }
-// childs.add(property);
-// }
-// }
-//
-// return childs;
-
+ // Node<Serializable, Object> parentNode =
cache.getNode(makeNodeFqn(parent.getQPath()));
+ // if (parentNode == null)
+ // {
+ // throw new IllegalStateException("Get child Nodes error: parent not
found " + parent.getQPath().getAsString());
+ // }
+ //
+ // List<PropertyData> childs = new ArrayList<PropertyData>();
+ //
+ // for (Serializable key : parentNode.getKeys())
+ // {
+ // if (!key.equals(ITEM_ID))
+ // {
+ // String propId = (String)parentNode.get(key);
+ // // TODO NodeData or PropertyData? As ItemData check then and cast.
+ // PropertyData property = (PropertyData)cache.get(makeIdFqn(propId),
ITEM_DATA);
+ // if (property == null)
+ // {
+ // throw new RepositoryException("One of childs is null. Parent
" + parent.getQPath().getAsString());
+ // }
+ // childs.add(property);
+ // }
+ // }
+ //
+ // return childs;
+
return null;
}
@@ -221,34 +283,28 @@
*/
public ItemData getItemData(NodeData parentData, QPathEntry name) throws
RepositoryException, IllegalStateException
{
-// Node<Serializable, Object> parentNode =
cache.getNode(makeNodeFqn(parentData.getQPath()));
-// if (parentNode == null)
-// {
-// throw new IllegalStateException("Get Item data error: parent not found
" + parentData.getQPath().getAsString());
-// }
-//
-// // TODO check performance of Node vs Property get
-//
-// String propertyId = (String)parentNode.get(name.getAsString());
-// if (propertyId != null)
-// {
-// // it's Property Item
-// return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
-// }
-// else
-// {
-// // it's Node Item
-// Node<Serializable, Object> node =
parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
-// if (node != null)
-// {
-// String nodeId = (String)node.get(ITEM_ID);
-// if (nodeId != null)
-// {
-// return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
-// }
-// }
-// }
+ // try as Node
+ Node<Serializable, Object> item =
nodesRoot.getChild(makeChildNodeFqn(parentData.getIdentifier(), name));
+ if (item != null)
+ {
+ return (NodeData)item.get(ITEM_DATA);
+ }
+ else
+ {
+ // try as Property
+ Node<Serializable, Object> parent =
nodesRoot.getChild(makeNodeFqn(parentData.getIdentifier()));
+ if (parent != null)
+ {
+ // get property id
+ String propId = (String)parent.get(name.getAsString(false));
+ if (propId != null)
+ {
+ return (PropertyData)propsRoot.get(makePropFqn(propId));
+ }
+ }
+ }
+
return null;
}
@@ -257,7 +313,29 @@
*/
public ItemData getItemData(String identifier) throws RepositoryException,
IllegalStateException
{
- return (ItemData)cache.get(makeItemFqn(identifier), ITEM_DATA);
+
+ Node<Serializable, Object> item =
nodesRoot.getChild(makeNodeFqn(identifier));
+ if (item == null)
+ {
+ item = propsRoot.getChild(makePropFqn(identifier));
+ }
+
+ if (item != null)
+ {
+ Object itemData = item.get(ITEM_DATA);
+ if (itemData != null)
+ {
+ return (ItemData)itemData;
+ }
+ else
+ {
+ throw new RepositoryException("FATAL ItemData empty " +
item.getFqn());
+ }
+ }
+ else
+ {
+ return null;
+ }
}
/**
@@ -289,18 +367,57 @@
{
startBatch();
- // TODO it's put anyway.. but with check?
- Object prev = cache.put(makeNodeFqn(data.getQPath()), ITEM_ID,
data.getIdentifier());
- if (prev == null)
+ // TODO recheck the logic
+
+ Node<Serializable, Object> node =
nodesRoot.getChild(makeNodeFqn(data.getIdentifier()));
+ if (node == null)
{
- throw new IllegalStateException("Node was deleted (tree)");
+ throw new InvalidItemStateException("Node was updated previously or removed
" + data.getQPath().getAsString());
}
- prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
- if (prev == null)
+ QPath prevPath;
+
+ Object itemData = node.get(ITEM_DATA);
+ if (itemData == null)
{
- throw new IllegalStateException("Node was deleted (items)");
+ throw new RepositoryException("FATAL NodeData empty " +
node.getFqn());
}
+
+ if (itemData instanceof NodeData)
+ {
+ prevPath = ((NodeData)itemData).getQPath();
+ }
+ else
+ {
+ throw new RepositoryException("FATAL Node data is not NodeData " +
node.getFqn());
+ }
+
+ if (data.getParentIdentifier() != null)
+ {
+ // check if parent is cached
+ Fqn<String> parentFqn = makeNodeFqn(data.getParentIdentifier());
+
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent == null)
+ {
+ throw new RepositoryException("Node parent doesn't exist " +
data.getQPath().getAsString());
+ }
+
+ // update child on Parent (remove prev, add new)
+
+ // get previously cached NodeData and using its name remove child on the parent
+ boolean removed =
+
parent.removeChild(makeChildNodeFqn(prevPath.getEntries()[prevPath.getEntries().length -
1]));
+
+ Node<Serializable, Object> childNode =
+
parent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length
- 1]));
+
+ // set child id attr
+ childNode.put(ITEM_ID, data.getIdentifier());
+ }
+
+ // update in NODES
+ node.put(ITEM_DATA, data);
}
/**
@@ -311,19 +428,14 @@
{
startBatch();
- // TODO it's put anyway.. but with check?
-// Fqn<String> parentFqn = makeParentFqn(data.getQPath());
-// Object prev = cache.put(parentFqn, data.getQPath().getName().getAsString(),
data.getIdentifier());
-// if (prev == null)
-// {
-// throw new IllegalStateException("Property was deleted (tree)");
-// }
-//
-// prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
-// if (prev == null)
-// {
-// throw new IllegalStateException("Property was deleted (items)");
-// }
+ // update in PROPERTIES
+ Node<Serializable, Object> prop =
propsRoot.getChild(makePropFqn(data.getIdentifier()));
+ if (prop == null)
+ {
+ throw new IllegalStateException("Property was deleted " +
data.getQPath().getAsString());
+ }
+
+ prop.put(ITEM_DATA, data);
}
/**
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
(rev 0)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+/*
+ * 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.storage.jbosscache;
+
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.jboss.cache.Fqn;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 31.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
+ * @version $Id$
+ */
+@Deprecated
+public abstract class JBossCacheTreeStorage
+{
+
+ @Deprecated
+ public static final String TREE = "$TREE".intern();
+
+ @Deprecated
+ public static final String ITEMS = "$ITEMS".intern();
+
+ public static final String ITEM_DATA = "$data".intern();
+
+ public static final String ITEM_ID = "$id".intern();
+
+ @Deprecated
+ protected final Fqn<String> treeRoot;
+
+ protected final Fqn<String> itemsRoot;
+
+ @Deprecated
+ protected JBossCacheTreeStorage(Fqn<String> treeRoot, Fqn<String>
itemsRoot)
+ {
+ this.itemsRoot = itemsRoot;
+
+ this.treeRoot = treeRoot;
+ }
+
+ @Deprecated
+ protected Fqn<String> makeNodeFqn(QPath nodePath)
+ {
+ QPathEntry[] path = nodePath.getEntries();
+ String[] fqns = new String[path.length];
+
+ for (int i = 0; i < path.length; i++)
+ {
+ fqns[i] = path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ @Deprecated
+ protected Fqn<String> makeParentFqn(QPath propertyPath)
+ {
+ QPathEntry[] path = propertyPath.getEntries();
+ int pathLen = path.length - 1;
+ String[] fqns = new String[pathLen];
+
+ for (int i = 0; i < pathLen; i++)
+ {
+ fqns[i] = path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ protected Fqn<String> makeItemFqn(String nodeId)
+ {
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(nodeId));
+ }
+
+}
Property changes on:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -53,7 +53,7 @@
* @version $Id$
*/
@Deprecated
-public class JBossCacheTreeStorageConnection extends JBossCacheStorage implements
WorkspaceStorageConnection
+public class JBossCacheTreeStorageConnection extends JBossCacheTreeStorage implements
WorkspaceStorageConnection
{
protected static final Log LOG =
ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -67,7 +67,8 @@
private final Cache<Serializable, Object> cache;
- private final Node<Serializable, Object> items;
+ private final Node<Serializable, Object> nodes;
+ private final Node<Serializable, Object> properties;
/**
* JBossWorkspaceDataContainer constructor.
@@ -111,7 +112,8 @@
//Node<Serializable, Object> wsRoot =
cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
// prepare cache structures
- this.items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
+ this.nodes = cacheRoot.addChild(Fqn.fromElements(JBossCacheStorage.NODES));
+ this.properties = cacheRoot.addChild(Fqn.fromElements(JBossCacheStorage.PROPS));
}
public void start()
@@ -143,7 +145,7 @@
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
{
- return new JBossCacheStorageConnection(cache, items);
+ return new JBossCacheStorageConnection(cache, nodes, properties);
}
/**
@@ -151,7 +153,7 @@
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws
RepositoryException
{
- return new JBossCacheStorageConnection(cache, items);
+ return new JBossCacheStorageConnection(cache, nodes, properties);
}
/**
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-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -36,12 +36,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.ItemData;
@@ -57,6 +51,12 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.loader.AbstractCacheLoader;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* Created by The eXo Platform SAS.
*
@@ -92,7 +92,7 @@
*/
public void put(List<Modification> modifications) throws Exception
{
-
+ // TODO
}
@@ -118,7 +118,7 @@
Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
if (name.size() > 1)
{
- if (name.get(1).equals(JBossCacheStorage.TREE))
+ if (name.get(1).equals(JBossCacheStorage.NODES))
{
// return Node
if (name.size() > 3)
@@ -157,7 +157,7 @@
attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
}
}
- else if (name.get(1).equals(JBossCacheStorage.ITEMS))
+ else if (name.get(1).equals(JBossCacheStorage.NODES))
{
// we have all data on thrid level
if (name.size() == 3)
@@ -199,7 +199,7 @@
Set<String> childs = new LinkedHashSet<String>();
if (fqn.size() > 2)
{
- if (fqn.get(2).equals(JBossCacheStorage.TREE))
+ if (fqn.get(2).equals(JBossCacheStorage.NODES))
{
// return Node
if (fqn.size() > 3)
@@ -237,7 +237,7 @@
.getAsString(true));
}
}
- else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
+ else if (fqn.get(2).equals(JBossCacheStorage.NODES))
{
// we have all data on thrid level
if (fqn.size() == 3)
@@ -261,8 +261,8 @@
}
else if (fqn.equals(Fqn.ROOT))
{
- childs.add(JBossCacheStorage.TREE);
- childs.add(JBossCacheStorage.ITEMS);
+ childs.add(JBossCacheStorage.NODES);
+ childs.add(JBossCacheStorage.PROPS);
}
return childs;
}
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java 2009-11-06
15:01:45 UTC (rev 487)
+++
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java 2009-11-06
15:51:12 UTC (rev 488)
@@ -94,8 +94,8 @@
//Node<Serializable, Object> wsRoot =
cacheRoot.addChild(Fqn.fromElements("repo", "ws"));
// prepare cache structures
- tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
- items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
+ tree = cacheRoot.addChild(Fqn.fromString(JBossCacheTreeStorage.TREE));
+ items = cacheRoot.addChild(Fqn.fromString(JBossCacheTreeStorage.ITEMS));
// run cache
cache.create();