[exo-jcr-commits] exo-jcr SVN: r563 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Nov 11 09:43:10 EST 2009
Author: areshetnyak
Date: 2009-11-11 09:43:09 -0500 (Wed, 11 Nov 2009)
New Revision: 563
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-201 : The JDBCCacheLoader was changed.
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-11 14:42:45 UTC (rev 562)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-11 14:43:09 UTC (rev 563)
@@ -126,7 +126,7 @@
break;
case REMOVE_NODE:
System.out.println(m);
- doRemove(m, jdbcConnection, getID(m.getFqn()));
+ doRemove(m, jdbcConnection);
break;
case MOVE:
System.out.println(m);
@@ -138,6 +138,7 @@
if (jdbcConnection != null) {
jdbcConnection.commit();
+// jdbcConnection.close();
jdbcConnection = null;
}
}
@@ -148,8 +149,10 @@
}
finally
{
- if (jdbcConnection != null && jdbcConnection.isOpened())
+ if (jdbcConnection != null && jdbcConnection.isOpened()) {
jdbcConnection.rollback();
+ }
+
}
}
@@ -173,16 +176,23 @@
* @throws IllegalStateException
* @throws RepositoryException
*/
- private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
+ private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection)
throws IllegalStateException, RepositoryException
{
- ItemData itemData = jdbcConnection.getItemData(identifier);
-
- if (itemData instanceof NodeData)
- jdbcConnection.delete((NodeData) itemData);
- if (itemData instanceof PropertyData)
- jdbcConnection.delete((PropertyData) itemData);
+ if (modification.getFqn().get(1).equals(JBossCacheStorage.NODES) ||
+ modification.getFqn().get(1).equals(JBossCacheStorage.PROPS))
+ {
+
+ String identifier = (String) modification.getFqn().get(1);
+
+ ItemData itemData = jdbcConnection.getItemData(identifier);
+
+ if (itemData instanceof NodeData)
+ jdbcConnection.delete((NodeData) itemData);
+ if (itemData instanceof PropertyData)
+ jdbcConnection.delete((PropertyData) itemData);
+ }
}
private boolean isNodeData(Fqn<String> fqn)
@@ -350,7 +360,7 @@
try
{
- NodeData parentNodeData = (NodeData) conn.getItemData((String)name.get(2));
+ NodeData parentNodeData = (NodeData) conn.getItemData((String)name.get(1));
if (parentNodeData == null)
throw new JDBCCacheLoaderException("The parent node with ID = " + (String)name.get(2) + " not exis, FQN = '" + name + "'.");
@@ -464,11 +474,43 @@
/**
* {@inheritDoc}
*/
- public Set<?> getChildrenNames(Fqn fqn) throws Exception
+ public Set<?> getChildrenNames(Fqn name) throws Exception
{
// return child nodes names
+
+ Set<String> childs = new LinkedHashSet<String>();
+
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+ try
+ {
+ NodeData parentNodeData = (NodeData)conn.getItemData((String) name.get(1));
+
+ if (parentNodeData == null)
+ throw new JDBCCacheLoaderException("The parent node with ID = " + (String)name.get(2) + " not exis, FQN = '" + name + "'.");
- Set<String> childs = new LinkedHashSet<String>();
+ // get child nodes by parent Id
+ for (NodeData node : conn.getChildNodesData(parentNodeData))
+ {
+ childs.add(node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getAsString(true));
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else if (name.equals(Fqn.ROOT))
+ {
+// childs.add(JBossCacheStorage.NODES);
+// childs.add(JBossCacheStorage.PROPS);
+ }
+
+ return childs;
+
+/* Set<String> childs = new LinkedHashSet<String>();
if (fqn.size() > 2)
{
if (fqn.get(2).equals(JBossCacheStorage.NODES))
@@ -536,7 +578,7 @@
childs.add(JBossCacheStorage.NODES);
childs.add(JBossCacheStorage.PROPS);
}
- return childs;
+ return childs;*/
}
/**
More information about the exo-jcr-commits
mailing list