Author: areshetnyak
Date: 2009-11-18 06:18:07 -0500 (Wed, 18 Nov 2009)
New Revision: 746
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-249 : The method exists(Fqn name) was changed in JDBCCacheLoader.
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-18
10:40:33 UTC (rev 745)
+++
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-18
11:18:07 UTC (rev 746)
@@ -386,14 +386,100 @@
public boolean exists(Fqn name) throws Exception
{
// TODO Will be created specialization code to checking exist node or property in
DB without getting NodeData or PropertyData from DB.
+ JDBCStorageConnection conn = (JDBCStorageConnection)
dataContainer.openConnection();
+
+ boolean exists;
+
try
{
- return get(name) != null;
+ if (name.size() > 1)
+ {
+ if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ String nodeId = name.getLastElementAsString();
+ String nodeName = "" /* = conn.getNodeName(nodeId)*/;
+
+ if (nodeName != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ QPathEntry childNodeName =
QPathEntry.parse(name.getLastElementAsString());
+ String parentId = (String)name.get(1);
+
+ String nodeId = "" /* = conn.getIdentifier(parentId,
childNodeName)*/;
+ if (nodeId != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ String propertyId = name.getLastElementAsString();
+ String propertyName = "" /* =
conn.getPropertyName(nodeId)*/;
+
+ if (propertyName != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else if (name.equals(Fqn.ROOT) || name.equals(JBossCacheStorage.PROPS) ||
name.equals(JBossCacheStorage.NODES)
+ || name.equals(JBossCacheStorage.LOCKS))
+ {
+ // roots, like NODES, PROPS etc
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
}
- catch (JDBCCacheLoaderException e)
+ finally
{
- return false;
+ conn.close();
}
+
+ return exists;
}
/**
Show replies by date