Author: pnedonosko
Date: 2009-11-01 17:06:48 -0500 (Sun, 01 Nov 2009)
New Revision: 461
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
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/JBossCacheWorkspaceDataContainer.java
Log:
EXOJCR-200: connection new hierarchy; paths fixes
Added:
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
(rev 0)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-01
22:06:48 UTC (rev 461)
@@ -0,0 +1,104 @@
+/*
+ * 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$
+ */
+public abstract class JBossCacheStorage
+{
+
+ public static final String TREE = "$TREE".intern();
+
+ public static final String ITEMS = "$ITEMS".intern();
+
+ public static final String ITEM_DATA = "$data".intern();
+
+ public static final String ITEM_ID = "$id".intern();
+
+ protected final Fqn<String> treeRoot;
+
+ protected final Fqn<String> itemsRoot;
+
+ protected JBossCacheStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
+ {
+ this.treeRoot = treeRoot;
+ this.itemsRoot = itemsRoot;
+ }
+
+ 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));
+ }
+
+ 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> makeIdFqn(String itemId)
+ {
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
+ }
+
+}
Property changes on:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.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/JBossCacheStorageConnection.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10-30
22:03:54 UTC (rev 460)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-01
22:06:48 UTC (rev 461)
@@ -18,12 +18,18 @@
*/
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.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -31,42 +37,29 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
*
* <br/>Date: 23.10.2009<br/>
*
* Cache contains several regions:<br/>
- * Workspace tree. /$repo_name/$ws_name/$ROOT: On each leaf (JBossCache Node) an JCR Item
Id stored.<br/>
- * Items map. /$repo_name/$ws_name/$ITEMS: Key=Id, Value = ItemData.<br/>
- * References map ??? /$repo_name/$ws_name/$REFS: Key=NodeId, Value =
PropertyId.<br/>
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id
stored.<br/>
+ * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
+ * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
*
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id$
*/
-public class JBossCacheStorageConnection extends DBConstants implements
WorkspaceStorageConnection
+public class JBossCacheStorageConnection extends JBossCacheStorage implements
WorkspaceStorageConnection
{
protected static final Log LOG =
ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
- //public static final InternalQName NODE = new InternalQName(Constants.NS_DEFAULT_URI,
"$node");
- public static final String ITEM_DATA = "$idata".intern();
-
- public static final String ITEM_ID = "$id".intern();
-
private final Cache<Serializable, Object> cache;
- private final Node<Serializable, Object> treeRoot;
+ //private final Node<Serializable, Object> treeRoot;
- private final Node<Serializable, Object> itemsRoot;
+ //private final Node<Serializable, Object> itemsRoot;
/**
* Start batching flag. 'true' if batching was started, 'false' if
batching is not start.
@@ -81,46 +74,13 @@
public JBossCacheStorageConnection(Cache<Serializable, Object> cache,
Node<Serializable, Object> treeRoot,
Node<Serializable, Object> itemsRoot)
{
+ super(treeRoot.getFqn(), itemsRoot.getFqn());
+
this.cache = cache;
- this.itemsRoot = itemsRoot;
- this.treeRoot = treeRoot;
+ //this.itemsRoot = itemsRoot;
+ //this.treeRoot = treeRoot;
}
- private 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);
- }
-
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns));
- }
-
- private 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);
- }
-
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns));
- }
-
- private Fqn<String> makeIdFqn(String itemId)
- {
- // TODO make Fqn generation clearer
- return Fqn.fromRelativeFqn(itemsRoot.getFqn(), Fqn.fromString(itemId));
- }
-
/**
* {@inheritDoc}
*/
@@ -192,7 +152,6 @@
NodeData node = (NodeData)cache.get(makeIdFqn(childId), ITEM_DATA);
if (node == null)
{
- treePrint(treeRoot);
throw new RepositoryException("One of childs is null. Parent " +
parent.getQPath().getAsString());
}
childs.add(node);
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-10-30
22:03:54 UTC (rev 460)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-01
22:06:48 UTC (rev 461)
@@ -57,10 +57,6 @@
public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
- public static final String ROOT = "$ROOT".intern();
-
- public static final String ITEMS = "$ITEMS".intern();
-
protected static final Log LOG =
ExoLogger.getLogger("jcr.JBossCacheWorkspaceDataContainer");
protected final String repositoryName;
@@ -117,8 +113,8 @@
//Node<Serializable, Object> wsRoot =
cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
// prepare cache structures
- this.tree = cacheRoot.addChild(Fqn.fromString(ROOT));
- this.items = cacheRoot.addChild(Fqn.fromString(ITEMS));
+ this.tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
+ this.items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
}
public void start()