exo-jcr SVN: r485 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2009-11-06 09:49:54 -0500 (Fri, 06 Nov 2009)
New Revision: 485
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedSession.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
Log:
EXOJCR-228 : add method
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedSession.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedSession.java 2009-11-06 14:47:58 UTC (rev 484)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedSession.java 2009-11-06 14:49:54 UTC (rev 485)
@@ -26,6 +26,8 @@
import javax.jcr.InvalidSerializedDataException;
import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -52,6 +54,16 @@
LocationFactory getLocationFactory();
/**
+ * Get node by unique identifier.
+ *
+ * @param identifier node identifier
+ * @return node with specified identifier
+ * @throws ItemNotFoundException id node with supplied identifier not found
+ * @throws RepositoryException if any repository errors occurs
+ */
+ Node getNodeByIdentifier(String identifier) throws ItemNotFoundException, RepositoryException;
+
+ /**
* Deserialize an XML document and adds the resulting item subtree as a child of the node at
* parentAbsPath.
*
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2009-11-06 14:47:58 UTC (rev 484)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2009-11-06 14:49:54 UTC (rev 485)
@@ -622,7 +622,19 @@
{
return getNamespaceURI(prefix);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public Node getNodeByIdentifier(String identifier) throws ItemNotFoundException, RepositoryException
+ {
+ Item item = dataManager.getItemByIdentifier(identifier, true);
+ if (item != null && item.isNode())
+ return (Node)item;
+ throw new ItemNotFoundException("Node not found " + identifier + " at " + workspaceName);
+ }
+
/**
* {@inheritDoc}
*/
16 years, 8 months
exo-jcr SVN: r484 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: impl/core and 1 other directory.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2009-11-06 09:47:58 -0500 (Fri, 06 Nov 2009)
New Revision: 484
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedNode.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
Log:
EXOJCR-227 : add method
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedNode.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedNode.java 2009-11-06 10:21:09 UTC (rev 483)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/ExtendedNode.java 2009-11-06 14:47:58 UTC (rev 484)
@@ -55,6 +55,14 @@
* @return Access Control List
*/
AccessControlList getACL() throws RepositoryException;
+
+ /**
+ * Get unique node identifier.
+ *
+ * @return node identifier
+ * @throws RepositoryException if any repository errors occurs
+ */
+ String getIdentifier() throws RepositoryException;
/**
* Clears Access Control List.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-06 10:21:09 UTC (rev 483)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-11-06 14:47:58 UTC (rev 484)
@@ -956,6 +956,15 @@
+ itemPath.getAsString(false));
return (NodeImpl)node;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getIdentifier() throws RepositoryException
+ {
+ checkValid();
+ return this.getInternalIdentifier();
+ }
/**
* {@inheritDoc}
16 years, 8 months
exo-jcr SVN: r483 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query: cacheloader and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-11-06 05:21:09 -0500 (Fri, 06 Nov 2009)
New Revision: 483
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java
Log:
EXOJCR-202: empty IndexerCacheLoader class added
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java 2009-11-06 10:21:09 UTC (rev 483)
@@ -0,0 +1,72 @@
+/*
+ * 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.core.query.cacheloader;
+
+import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Modification;
+
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: CacheIndexer.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class IndexerCacheLoader extends AbstractWriteOnlyCacheLoader
+{
+
+ @Override
+ public void put(List<Modification> modifications) throws Exception
+ {
+ for (Modification m : modifications)
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA :
+ put(m.getFqn(), m.getData());
+ break;
+ case PUT_DATA_ERASE :
+ removeData(m.getFqn());
+ put(m.getFqn(), m.getData());
+ break;
+ case PUT_KEY_VALUE :
+ put(m.getFqn(), m.getKey(), m.getValue());
+ break;
+ case REMOVE_DATA :
+ removeData(m.getFqn());
+ break;
+ case REMOVE_KEY_VALUE :
+ remove(m.getFqn(), m.getKey());
+ break;
+ case REMOVE_NODE :
+ remove(m.getFqn());
+ break;
+ case MOVE :
+ // involve moving all children too
+ move(m.getFqn(), m.getFqn2());
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
+ }
+
+}
16 years, 8 months
exo-jcr SVN: r482 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-06 05:19:12 -0500 (Fri, 06 Nov 2009)
New Revision: 482
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
Log:
EXOJCR-205: add new class
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-06 10:19:12 UTC (rev 482)
@@ -0,0 +1,74 @@
+/*
+ * 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.jboss.cache.CacheException;
+import org.jboss.cache.Modification;
+
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class LockCacheLoader extends AbstractWriteOnlyCacheLoader
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void put(List<Modification> modifications) throws Exception
+ {
+ for (Modification m : modifications)
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA :
+ // put(m.getFqn(), m.getData());
+ break;
+ case PUT_DATA_ERASE :
+ // removeData(m.getFqn());
+ // put(m.getFqn(), m.getData());
+ break;
+ case PUT_KEY_VALUE :
+ // put(m.getFqn(), m.getKey(), m.getValue());
+ break;
+ case REMOVE_DATA :
+ // removeData(m.getFqn());
+ break;
+ case REMOVE_KEY_VALUE :
+ // remove(m.getFqn(), m.getKey());
+ break;
+ case REMOVE_NODE :
+ // remove(m.getFqn());
+ break;
+ case MOVE :
+ // involve moving all children too
+ // move(m.getFqn(), m.getFqn2());
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r481 - jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-06 05:17:56 -0500 (Fri, 06 Nov 2009)
New Revision: 481
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml
Log:
EXOJCR-200: reorg for new storage arch (config)
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml 2009-11-06 10:17:07 UTC (rev 480)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml 2009-11-06 10:17:56 UTC (rev 481)
@@ -60,7 +60,7 @@
</properties>
</loader -->
- <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.ExoJCRCacheLoader"
+ <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
16 years, 8 months
exo-jcr SVN: r480 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-06 05:17:07 -0500 (Fri, 06 Nov 2009)
New Revision: 480
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.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/JBossCacheTreeStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
Log:
EXOJCR-200: reorg for new storage arch
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -16,16 +16,16 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.loader.AbstractCacheLoader;
-
/**
* Created by The eXo Platform SAS.
*
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-06 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -1,322 +0,0 @@
-/*
- * 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 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;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.AbstractCacheLoader;
-
-/**
- * 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 class ExoJCRCacheLoader extends AbstractCacheLoader
-{
-
- private WorkspaceDataContainer dataContainer;
-
- /**
- * Init the loader DataContainer with given WorkspaceDataContainer instance.
- *
- * @param dataContainer WorkspaceDataContainer
- */
- @Inject
- public void initDataContainer(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
- {
- if (this.dataContainer != null)
- {
- throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
- }
-
- this.dataContainer = dataContainer;
- }
-
- protected QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
- {
- List<String> elements = nodeFqn.peekElements();
- QPathEntry[] path = new QPathEntry[elements.size()];
-
- for (int i = 0; i < elements.size(); i++)
- {
- path[i] = QPathEntry.parse(elements.get(i));
- }
-
- return path;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map<Object, Object> get(Fqn name) throws Exception
- {
-
- Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
- if (name.size() > 1)
- {
- if (name.get(1).equals(JBossCacheStorage.TREE))
- {
- // return Node
- if (name.size() > 3)
- {
- QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
-
- // 1) all subtree will be cached
- // 2) all subtree will be read from DB (with allprops) for only Ids.
- // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
- String parentId = (String)cache.get(name.getParent(), JBossCacheStorage.ITEM_ID);
-
- WorkspaceStorageConnection conn = dataContainer.openConnection();
- try
- {
- NodeData parent = (NodeData)conn.getItemData(parentId);
-
- ItemData item = conn.getItemData(parent, nodeName);
-
- // item Id
- attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier());
-
- // if Node (Property cannot due to logic of StorageConnection) add props
- for (PropertyData prop : conn.getChildPropertiesData(parent))
- {
- attrs.put(prop.getQPath().getName().getAsString(), prop.getIdentifier());
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- // root Node (/$TREE/[]:1)
- attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
- }
- }
- else if (name.get(1).equals(JBossCacheStorage.ITEMS))
- {
- // we have all data on thrid level
- if (name.size() == 3)
- {
- // return Node or Property
- String itemId = name.getLastElementAsString();
-
- WorkspaceStorageConnection conn = dataContainer.openConnection();
- try
- {
- attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(itemId));
- }
- finally
- {
- conn.close();
- }
- }
- }
- }
- return attrs;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean exists(Fqn name) throws Exception
- {
- // TODO do it with less cost
- return get(name) != null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<?> getChildrenNames(Fqn fqn) throws Exception
- {
- // return child nodes names
-
- Set<String> childs = new LinkedHashSet<String>();
- if (fqn.size() > 2)
- {
- if (fqn.get(2).equals(JBossCacheStorage.TREE))
- {
- // return Node
- if (fqn.size() > 3)
- {
- QPathEntry nodeName = QPathEntry.parse(fqn.getLastElementAsString());
-
- // TODO non effective, in this way 1) all subtree will be cached
- // 2) all subtree will be read from DB (with allprops) for only Ids.
- // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
- String parentId = (String)cache.get(fqn.getParent(), JBossCacheStorage.ITEM_ID);
-
- WorkspaceStorageConnection conn = dataContainer.openConnection();
- try
- {
- NodeData parent = (NodeData)conn.getItemData(parentId);
-
- NodeData node = (NodeData)conn.getItemData(parent, nodeName);
-
- // get child nodes by parent Id
- for (NodeData prop : conn.getChildNodesData(node))
- {
- childs
- .add(node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getAsString(true));
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- // root Node (/$TREE/[]:1)
- childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true));
- }
- }
- else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
- {
- // we have all data on thrid level
- if (fqn.size() == 3)
- {
- // return all Nodes and Properties Ids
-
-// WorkspaceStorageConnection conn = dataContainer.openConnection();
-// try
-// {
-// for (String itemId : conn.getAllItemIdentifiers())
-// {
-// childs.add(itemId);
-// }
-// }
-// finally
-// {
-// conn.close();
-// }
- }
- }
- }
- else if (fqn.equals(Fqn.ROOT))
- {
- childs.add(JBossCacheStorage.TREE);
- childs.add(JBossCacheStorage.ITEMS);
- }
- return childs;
- }
-
- /**
- * {@inheritDoc}
- */
- public IndividualCacheLoaderConfig getConfig()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(Fqn name, Map<Object, Object> attributes) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public Object remove(Fqn fqn, Object key) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove(Fqn fqn) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeData(Fqn fqn) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- // TODO Auto-generated method stub
-
- }
-
-}
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 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -51,6 +51,7 @@
public abstract class JBossCacheStorage
{
+ @Deprecated
public static final String TREE = "$TREE".intern();
public static final String ITEMS = "$ITEMS".intern();
@@ -59,14 +60,24 @@
public static final String ITEM_ID = "$id".intern();
+ @Deprecated
protected final Fqn<String> treeRoot;
protected final Fqn<String> itemsRoot;
+ @Deprecated
protected JBossCacheStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
{
+ this.itemsRoot = itemsRoot;
+
this.treeRoot = treeRoot;
+ }
+
+ protected JBossCacheStorage(Fqn<String> itemsRoot)
+ {
this.itemsRoot = itemsRoot;
+
+ this.treeRoot = null;
}
@Deprecated
@@ -97,13 +108,26 @@
return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
}
-
- protected Fqn<String> makeTreeFqn(String parentId, QPathEntry itemName)
+
+ /**
+ * Make Child Node Fqn, i.e. /IDxxx/NAMExxx.
+ *
+ * @param parentId String
+ * @param itemName QPathEntry
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildNodeFqn(String parentId, QPathEntry itemName)
{
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(parentId, itemName.getAsString(true)));
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromElements(parentId, itemName.getAsString(true)));
}
- protected Fqn<String> makeIdFqn(String itemId)
+ /**
+ * Make Item Fqn, i.e. /IDxxx.
+ *
+ * @param itemId String
+ * @return Fqn
+ */
+ protected Fqn<String> makeItemFqn(String itemId)
{
return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
}
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 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -69,14 +69,11 @@
*
* @param cache Cache<Serializable, Object>
*/
- public JBossCacheStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
- Node<Serializable, Object> itemsRoot)
+ public JBossCacheStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> itemsRoot)
{
- super(treeRoot.getFqn(), itemsRoot.getFqn());
-
+ super(itemsRoot.getFqn());
+
this.cache = cache;
- //this.itemsRoot = itemsRoot;
- //this.treeRoot = treeRoot;
}
/**
@@ -86,8 +83,8 @@
IllegalStateException
{
startBatch();
- cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
+ //cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
+ //cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
}
/**
@@ -97,11 +94,11 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- Fqn<String> parentFqn = makeParentFqn(data.getQPath());
+ //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);
+ //cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
+ //cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
}
/**
@@ -111,8 +108,8 @@
InvalidItemStateException, IllegalStateException
{
startBatch();
- cache.removeNode(makeNodeFqn(data.getQPath()));
- cache.removeNode(makeIdFqn(data.getIdentifier()));
+ //cache.removeNode(makeNodeFqn(data.getQPath()));
+ //cache.removeNode(makeIdFqn(data.getIdentifier()));
}
/**
@@ -123,8 +120,8 @@
{
startBatch();
// delete attr on parent by key=PropertyName
- cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
- cache.removeNode(makeIdFqn(data.getIdentifier()));
+ //cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
+ //cache.removeNode(makeIdFqn(data.getIdentifier()));
}
/**
@@ -133,29 +130,31 @@
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;
}
private void treePrint(Node<Serializable, Object> node)
@@ -180,30 +179,32 @@
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;
}
/**
@@ -220,34 +221,34 @@
*/
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());
- }
+// 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);
+// }
+// }
+// }
- // 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);
- }
- }
- }
-
return null;
}
@@ -256,7 +257,7 @@
*/
public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
{
- return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+ return (ItemData)cache.get(makeItemFqn(identifier), ITEM_DATA);
}
/**
@@ -295,7 +296,7 @@
throw new IllegalStateException("Node was deleted (tree)");
}
- prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
if (prev == null)
{
throw new IllegalStateException("Node was deleted (items)");
@@ -311,18 +312,18 @@
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)");
- }
+// 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)");
+// }
}
/**
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 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -93,7 +93,7 @@
{
startBatch();
cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
+ cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
}
/**
@@ -107,7 +107,7 @@
// 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);
+ cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
}
/**
@@ -118,7 +118,7 @@
{
startBatch();
cache.removeNode(makeNodeFqn(data.getQPath()));
- cache.removeNode(makeIdFqn(data.getIdentifier()));
+ cache.removeNode(makeItemFqn(data.getIdentifier()));
}
/**
@@ -130,7 +130,7 @@
startBatch();
// delete attr on parent by key=PropertyName
cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
- cache.removeNode(makeIdFqn(data.getIdentifier()));
+ cache.removeNode(makeItemFqn(data.getIdentifier()));
}
/**
@@ -153,7 +153,7 @@
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);
+ NodeData node = (NodeData)cache.get(makeItemFqn(childId), ITEM_DATA);
if (node == null)
{
throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
@@ -200,7 +200,7 @@
{
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);
+ PropertyData property = (PropertyData)cache.get(makeItemFqn(propId), ITEM_DATA);
if (property == null)
{
throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
@@ -238,7 +238,7 @@
if (propertyId != null)
{
// it's Property Item
- return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
+ return (PropertyData)cache.get(makeItemFqn(propertyId), ITEM_DATA);
}
else
{
@@ -249,7 +249,7 @@
String nodeId = (String)node.get(ITEM_ID);
if (nodeId != null)
{
- return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
+ return (NodeData)cache.get(makeItemFqn(nodeId), ITEM_DATA);
}
}
}
@@ -262,7 +262,7 @@
*/
public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
{
- return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+ return (ItemData)cache.get(makeItemFqn(identifier), ITEM_DATA);
}
/**
@@ -301,7 +301,7 @@
throw new IllegalStateException("Node was deleted (tree)");
}
- prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
if (prev == null)
{
throw new IllegalStateException("Node was deleted (items)");
@@ -324,7 +324,7 @@
throw new IllegalStateException("Property was deleted (tree)");
}
- prev = cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
if (prev == null)
{
throw new IllegalStateException("Property was deleted (items)");
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 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -67,8 +67,6 @@
private final Cache<Serializable, Object> cache;
- private final Node<Serializable, Object> tree;
-
private final Node<Serializable, Object> items;
/**
@@ -113,7 +111,6 @@
//Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements(repositoryName, containerName));
// prepare cache structures
- this.tree = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
this.items = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS));
}
@@ -146,7 +143,7 @@
*/
public WorkspaceStorageConnection openConnection() throws RepositoryException
{
- return new JBossCacheStorageConnection(cache, tree, items);
+ return new JBossCacheStorageConnection(cache, items);
}
/**
@@ -154,7 +151,7 @@
*/
public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
{
- return new JBossCacheStorageConnection(cache, tree, items);
+ return new JBossCacheStorageConnection(cache, items);
}
/**
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java (from rev 479, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-06 10:17:07 UTC (rev 480)
@@ -0,0 +1,333 @@
+/*
+ * 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 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;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
+/**
+ * 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 class JDBCCacheLoader extends AbstractCacheLoader
+{
+
+ private WorkspaceDataContainer dataContainer;
+
+ /**
+ * Init the loader DataContainer with given WorkspaceDataContainer instance.
+ *
+ * @param dataContainer WorkspaceDataContainer
+ */
+ @Inject
+ public void initDataContainer(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
+ {
+ if (this.dataContainer != null)
+ {
+ throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
+ }
+
+ this.dataContainer = dataContainer;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(List<Modification> modifications) throws Exception
+ {
+
+
+ }
+
+ protected QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
+ {
+ List<String> elements = nodeFqn.peekElements();
+ QPathEntry[] path = new QPathEntry[elements.size()];
+
+ for (int i = 0; i < elements.size(); i++)
+ {
+ path[i] = QPathEntry.parse(elements.get(i));
+ }
+
+ return path;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<Object, Object> get(Fqn name) throws Exception
+ {
+
+ Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
+ if (name.size() > 1)
+ {
+ if (name.get(1).equals(JBossCacheStorage.TREE))
+ {
+ // return Node
+ if (name.size() > 3)
+ {
+ QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
+
+ // 1) all subtree will be cached
+ // 2) all subtree will be read from DB (with allprops) for only Ids.
+ // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
+ String parentId = (String)cache.get(name.getParent(), JBossCacheStorage.ITEM_ID);
+
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ ItemData item = conn.getItemData(parent, nodeName);
+
+ // item Id
+ attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier());
+
+ // if Node (Property cannot due to logic of StorageConnection) add props
+ for (PropertyData prop : conn.getChildPropertiesData(parent))
+ {
+ attrs.put(prop.getQPath().getName().getAsString(), prop.getIdentifier());
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
+ }
+ }
+ else if (name.get(1).equals(JBossCacheStorage.ITEMS))
+ {
+ // we have all data on thrid level
+ if (name.size() == 3)
+ {
+ // return Node or Property
+ String itemId = name.getLastElementAsString();
+
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(itemId));
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ }
+ }
+ return attrs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn name) throws Exception
+ {
+ // TODO do it with less cost
+ return get(name) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
+ {
+ // return child nodes names
+
+ Set<String> childs = new LinkedHashSet<String>();
+ if (fqn.size() > 2)
+ {
+ if (fqn.get(2).equals(JBossCacheStorage.TREE))
+ {
+ // return Node
+ if (fqn.size() > 3)
+ {
+ QPathEntry nodeName = QPathEntry.parse(fqn.getLastElementAsString());
+
+ // TODO non effective, in this way 1) all subtree will be cached
+ // 2) all subtree will be read from DB (with allprops) for only Ids.
+ // The effective way DON NOT use calls to cache and use special SQLs for Ids only read.
+ String parentId = (String)cache.get(fqn.getParent(), JBossCacheStorage.ITEM_ID);
+
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ NodeData parent = (NodeData)conn.getItemData(parentId);
+
+ NodeData node = (NodeData)conn.getItemData(parent, nodeName);
+
+ // get child nodes by parent Id
+ for (NodeData prop : conn.getChildNodesData(node))
+ {
+ childs
+ .add(node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getAsString(true));
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true));
+ }
+ }
+ else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
+ {
+ // we have all data on thrid level
+ if (fqn.size() == 3)
+ {
+ // return all Nodes and Properties Ids
+
+// WorkspaceStorageConnection conn = dataContainer.openConnection();
+// try
+// {
+// for (String itemId : conn.getAllItemIdentifiers())
+// {
+// childs.add(itemId);
+// }
+// }
+// finally
+// {
+// conn.close();
+// }
+ }
+ }
+ }
+ else if (fqn.equals(Fqn.ROOT))
+ {
+ childs.add(JBossCacheStorage.TREE);
+ childs.add(JBossCacheStorage.ITEMS);
+ }
+ return childs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn fqn) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn fqn) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
16 years, 8 months
exo-jcr SVN: r479 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-06 05:06:18 -0500 (Fri, 06 Nov 2009)
New Revision: 479
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 10:00:28 UTC (rev 478)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 10:06:18 UTC (rev 479)
@@ -16,9 +16,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -123,7 +121,7 @@
}
/**
- * That method should be override in other loaders (indexer, lock, observation).
+ * {@inheritDoc}
*/
public abstract void put(List<Modification> modifications) throws Exception ;
16 years, 8 months
exo-jcr SVN: r478 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-06 05:00:28 -0500 (Fri, 06 Nov 2009)
New Revision: 478
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 09:39:33 UTC (rev 477)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 10:00:28 UTC (rev 478)
@@ -63,7 +63,7 @@
*/
public Set<Object> getChildrenNames(Fqn arg0) throws Exception
{
- return new HashSet<Object>();
+ return null;
}
/**
16 years, 8 months
exo-jcr SVN: r477 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-06 04:39:33 -0500 (Fri, 06 Nov 2009)
New Revision: 477
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 09:36:42 UTC (rev 476)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 09:39:33 UTC (rev 477)
@@ -55,7 +55,7 @@
*/
public Map<Object, Object> get(Fqn arg0) throws Exception
{
- throw new WriteOnlyCacheLoaderException("The method 'Map<Object, Object> get(Fqn arg0)' should not be called.");
+ return Collections.emptyMap();
}
/**
16 years, 8 months
exo-jcr SVN: r476 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-06 04:36:42 -0500 (Fri, 06 Nov 2009)
New Revision: 476
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was added.
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-11-06 09:36:42 UTC (rev 476)
@@ -0,0 +1,130 @@
+/*
+ * 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 java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>
+ * Date: 06.11.2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public abstract class AbstractWriteOnlyCacheLoader
+ extends AbstractCacheLoader
+{
+ private IndividualCacheLoaderConfig config;
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn arg0) throws Exception
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<Object, Object> get(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'Map<Object, Object> get(Fqn arg0)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<Object> getChildrenNames(Fqn arg0) throws Exception
+ {
+ return new HashSet<Object>();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn arg0, Map<Object, Object> arg1) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, Map<Object, Object> arg1))' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn arg0, Object arg1, Object arg2) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, Object arg1, Object arg2)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'remove(Fqn arg0)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn arg0, Object arg1) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'remove(Fqn arg0, Object arg1)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'removeData(Fqn arg0)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config = config;
+ }
+
+ /**
+ * That method should be override in other loaders (indexer, lock, observation).
+ */
+ public abstract void put(List<Modification> modifications) throws Exception ;
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java 2009-11-06 09:36:42 UTC (rev 476)
@@ -0,0 +1,48 @@
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+public class WriteOnlyCacheLoaderException
+ extends Exception
+{
+ /**
+ * Constructs an Exception without a message.
+ */
+ public WriteOnlyCacheLoaderException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an Exception with a detailed message.
+ *
+ * @param Message
+ * The message associated with the exception.
+ */
+ public WriteOnlyCacheLoaderException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs an Exception with a detailed message and base exception.
+ *
+ * @param Message
+ * The message associated with the exception.
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public WriteOnlyCacheLoaderException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * WriteOnlyCacheLoaderException constructor.
+ *
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public WriteOnlyCacheLoaderException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months