exo-jcr SVN: r565 - 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-11 10:02:33 -0500 (Wed, 11 Nov 2009)
New Revision: 565
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:47:46 UTC (rev 564)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-11 15:02:33 UTC (rev 565)
@@ -398,7 +398,7 @@
}
}
- return attrs;
+ return (attrs.size() == 0 ? null : attrs);
/*if (name.size() > 1)
{
if (name.get(1).equals(JBossCacheStorage.NODES))
@@ -508,7 +508,7 @@
// childs.add(JBossCacheStorage.PROPS);
}
- return childs;
+ return (childs.size() == 0 ? null : childs);
/* Set<String> childs = new LinkedHashSet<String>();
if (fqn.size() > 2)
16 years, 8 months
exo-jcr SVN: r564 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-11 09:47:46 -0500 (Wed, 11 Nov 2009)
New Revision: 564
Modified:
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/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml
Log:
EXOJCR-205: small refactoring
Modified: 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 2009-11-11 14:43:09 UTC (rev 563)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-11 14:47:46 UTC (rev 564)
@@ -89,7 +89,7 @@
for (Modification m : modifications)
{
- if (m.getFqn().hasElement(JBossCacheStorage.SESSION))
+ if (m.getFqn().get(0).equals(JBossCacheStorage.SESSION))
{
switch (m.getType())
{
@@ -98,13 +98,14 @@
case PUT_DATA :
break;
case PUT_KEY_VALUE :
+ // begin new changes log
if (m.getKey().equals(JBossCacheStorage.SESSION_ID))
{
sessionId = (String)m.getValue();
}
break;
case REMOVE_DATA :
- // perform lock or unlock operation
+ // end changes log
if (lockChanges.size() == 2)
{
if (lockChanges.get(0).getType() == ModificationType.PUT_KEY_VALUE
@@ -112,11 +113,10 @@
{
performLock(lockChanges, sessionId);
}
- else if (lockChanges.get(0).getType() == ModificationType.REMOVE_NODE
- && lockChanges.get(1).getType() == ModificationType.REMOVE_NODE)
+ else if (lockChanges.get(0).getType() == ModificationType.REMOVE_KEY_VALUE
+ && lockChanges.get(1).getType() == ModificationType.REMOVE_KEY_VALUE)
{
- PropertyData propertyData = (PropertyData)lockChanges.get(0).getValue();
- performUnLock(lockChanges, propertyData.getParentIdentifier(), sessionId);
+ performUnLock(lockChanges, (String)lockChanges.get(0).getFqn().get(1), sessionId);
}
else
{
@@ -147,7 +147,7 @@
throw new CacheException("Unknown modification " + m.getType());
}
}
- else if (m.getFqn().hasElement(JBossCacheStorage.PROPS))
+ else if (m.getFqn().get(0).equals(JBossCacheStorage.PROPS))
{
switch (m.getType())
{
@@ -156,12 +156,11 @@
case PUT_DATA :
break;
case PUT_KEY_VALUE :
+ // lock operation
if (m.getKey().equals(JBossCacheStorage.ITEM_DATA))
{
- PropertyData propertyData = (PropertyData)m.getValue();
- InternalQName propertyName = propertyData.getQPath().getName();
-
- if (propertyName.equals(Constants.JCR_LOCKISDEEP) || propertyName.equals(Constants.JCR_LOCKOWNER))
+ InternalQName propName = ((PropertyData)m.getValue()).getQPath().getName();
+ if (propName.equals(Constants.JCR_LOCKISDEEP) || propName.equals(Constants.JCR_LOCKOWNER))
{
lockChanges.add(m);
}
@@ -172,16 +171,6 @@
case REMOVE_KEY_VALUE :
break;
case REMOVE_NODE :
- if (m.getKey().equals(JBossCacheStorage.ITEM_DATA))
- {
- PropertyData propertyData = (PropertyData)m.getValue();
- InternalQName propertyName = propertyData.getQPath().getName();
-
- if (propertyName.equals(Constants.JCR_LOCKISDEEP) || propertyName.equals(Constants.JCR_LOCKOWNER))
- {
- lockChanges.add(m);
- }
- }
break;
case MOVE :
break;
@@ -189,38 +178,56 @@
throw new CacheException("Unknown modification " + m.getType());
}
}
- else if (m.getFqn().hasElement(JBossCacheStorage.NODES))
+ else if (m.getFqn().get(0).equals(JBossCacheStorage.NODES))
{
- int nodesPos = getElementPosition(m.getFqn(), JBossCacheStorage.NODES);
- // this is a node and node is locked
- String nodeIdentifier = (String)m.getFqn().get(nodesPos + 1);
- if (m.getFqn().size() == nodesPos + 2)
+ switch (m.getType())
{
- if (lockManager.hasLockNode(nodeIdentifier))
- {
- switch (m.getType())
+ case PUT_DATA_ERASE :
+ break;
+ case PUT_DATA :
+ if (m.getFqn().size() == 2)
{
- case PUT_DATA_ERASE :
- break;
- case PUT_DATA :
+ String nodeIdentifier = (String)m.getFqn().get(1);
+ if (lockManager.hasLockNode(nodeIdentifier))
+ {
removedLock.remove(nodeIdentifier);
- break;
- case PUT_KEY_VALUE :
- break;
- case REMOVE_DATA :
- break;
- case REMOVE_KEY_VALUE :
- break;
- case REMOVE_NODE :
+ }
+ }
+ break;
+ case PUT_KEY_VALUE :
+ break;
+ case REMOVE_DATA :
+ break;
+ case REMOVE_KEY_VALUE :
+ // unLock operation
+ if (m.getKey().equals(Constants.JCR_LOCKISDEEP.getAsString())
+ || m.getKey().equals(Constants.JCR_LOCKOWNER.getAsString()))
+ {
+ lockChanges.add(m);
+ }
+ break;
+ case REMOVE_NODE :
+ if (m.getFqn().size() == 2)
+ {
+ String nodeIdentifier = (String)m.getFqn().get(1);
+ if (lockManager.hasLockNode(nodeIdentifier))
+ {
removedLock.add(nodeIdentifier);
- break;
- case MOVE :
+ }
+ }
+ break;
+ case MOVE :
+ if (m.getFqn().size() == 2)
+ {
+ String nodeIdentifier = (String)m.getFqn().get(1);
+ if (lockManager.hasLockNode(nodeIdentifier))
+ {
removedLock.remove(nodeIdentifier);
- break;
- default :
- throw new CacheException("Unknown modification " + m.getType());
+ }
}
- }
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
}
}
}
@@ -316,13 +323,4 @@
return null;
}
- private int getElementPosition(Fqn<String> fqn, String element)
- {
- for (int i = 0; i < fqn.size(); i++)
- if (fqn.get(i).equals(element))
- return i;
-
- return -1;
- }
-
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 14:43:09 UTC (rev 563)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 14:47:46 UTC (rev 564)
@@ -16,16 +16,12 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import sun.security.util.PendingException;
-
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.core.lock.LockData;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.jboss.cache.factories.annotations.NonVolatile;
-import java.util.Map;
-
import javax.jcr.lock.LockException;
/**
@@ -40,9 +36,9 @@
public class TesterLockManagerImpl extends LockManagerImpl
{
- private String nodeIdentifier;
+ private String nodeIdentifier = null;
- private String sessionId;
+ private String sessionId = null;
public TesterLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
{
@@ -59,6 +55,9 @@
*/
public synchronized void internalLock(String nodeIdentifier) throws LockException
{
+ if (this.nodeIdentifier != null)
+ throw new LockException("NodeIdentifier already exist!");
+
this.nodeIdentifier = nodeIdentifier;
}
@@ -67,6 +66,12 @@
*/
public synchronized void internalUnLock(String nodeIdentifier, String sessionId) throws LockException
{
+ if (this.nodeIdentifier != null)
+ throw new LockException("NodeIdentifier already exist!");
+
+ if (this.sessionId != null)
+ throw new LockException("SessionId already exist!");
+
this.nodeIdentifier = nodeIdentifier;
this.sessionId = sessionId;
}
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-11 14:43:09 UTC (rev 563)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml 2009-11-11 14:47:46 UTC (rev 564)
@@ -65,6 +65,12 @@
<properties>
</properties>
</loader>
+
+ <loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.LockCacheLoader"
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
+ <properties>
+ </properties>
+ </loader>
</loaders>
<!-- Enable batching -->
16 years, 8 months
exo-jcr SVN: r563 - 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-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;*/
}
/**
16 years, 8 months
exo-jcr SVN: r562 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-11 09:42:45 -0500 (Wed, 11 Nov 2009)
New Revision: 562
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 : The JDBCCacheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-11 13:37:09 UTC (rev 561)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-11 14:42:45 UTC (rev 562)
@@ -24,6 +24,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import javax.naming.Context;
@@ -43,15 +44,15 @@
import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.impl.storage.value.StandaloneStoragePluginProvider;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.jcr.util.ConfigurationHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
-import org.exoplatform.services.naming.InitialContextInitializer;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
/**
@@ -121,6 +122,20 @@
{
jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
}
+
+ public void testAddNodeAndGetNode() throws Exception
+ {
+ // prepare
+ super.testAddNode();
+ conn.commit();
+
+ cache.stop();
+ cache.start();
+
+ Map<Serializable, Object> data = cache.getData(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID));
+
+
+ }
public void testAddNode() throws Exception
{
16 years, 8 months
exo-jcr SVN: r561 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-11 08:37:09 -0500 (Wed, 11 Nov 2009)
New Revision: 561
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
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/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
Log:
EXOJCR-205: new tests added
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-11-11 13:02:31 UTC (rev 560)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-11-11 13:37:09 UTC (rev 561)
@@ -109,8 +109,10 @@
/**
* Map NodeIdentifier -- lockData
+ *
+ * TODO: changed from private to protected
*/
- private final Map<String, LockData> locks;
+ protected final Map<String, LockData> locks;
/**
* Data manager.
Modified: 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 2009-11-11 13:02:31 UTC (rev 560)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-11 13:37:09 UTC (rev 561)
@@ -128,13 +128,13 @@
log.error("Incorrect changes log size for lock or unlock operation");
}
- // changesLog end
for (String identifier : removedLock)
{
- lockManager.internalUnLock(sessionId, identifier);
+ lockManager.internalUnLock(identifier, sessionId);
}
lockChanges = new ArrayList<Modification>();
+ removedLock = new HashSet<String>();
sessionId = null;
break;
case REMOVE_KEY_VALUE :
@@ -192,10 +192,10 @@
else if (m.getFqn().hasElement(JBossCacheStorage.NODES))
{
int nodesPos = getElementPosition(m.getFqn(), JBossCacheStorage.NODES);
+ // this is a node and node is locked
+ String nodeIdentifier = (String)m.getFqn().get(nodesPos + 1);
if (m.getFqn().size() == nodesPos + 2)
{
- // this is a node and node is locked
- String nodeIdentifier = (String)m.getFqn().get(nodesPos + 1);
if (lockManager.hasLockNode(nodeIdentifier))
{
switch (m.getType())
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-11 13:02:31 UTC (rev 560)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-11 13:37:09 UTC (rev 561)
@@ -208,8 +208,8 @@
list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString("/" + JBossCacheStorage.SESSION),
JBossCacheStorage.SESSION_ID, sessionId));
// add UserID by the key USER_ID
- list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString("/" + JBossCacheStorage.SESSION),
- JBossCacheStorage.USER_ID, userId));
+ // list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString("/" + JBossCacheStorage.SESSION),
+ // JBossCacheStorage.USER_ID, userId));
// return
return list;
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-11 13:02:31 UTC (rev 560)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-11 13:37:09 UTC (rev 561)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.impl.core.lock.LockData;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
@@ -140,4 +141,44 @@
assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
assertEquals(sessionId, lockManager.getSessionid());
}
+
+ public void testAddNodeLock() throws Exception
+ {
+ List<Modification> modifications = new ArrayList<Modification>();
+ String nodeIdentifier = "node1";
+ String sessionId = "session1";
+
+ TransientNodeData node =
+ new TransientNodeData(testRoot, nodeIdentifier, 0, null, null, 0, Constants.ROOT_UUID, null);
+
+ lockManager.addLock(nodeIdentifier, new LockData(nodeIdentifier, "token", false, false, "__system", -1));
+
+ modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(addNode(node));
+ modifications.addAll(removeSession());
+ lockCacheLoader.put(modifications);
+
+ assertNull(lockManager.getNodeIdentifier());
+ assertNull(lockManager.getSessionid());
+ }
+
+ public void testRemoveNodeLock() throws Exception
+ {
+ List<Modification> modifications = new ArrayList<Modification>();
+ String nodeIdentifier = "node1";
+ String sessionId = "session1";
+
+ TransientNodeData node =
+ new TransientNodeData(testRoot, nodeIdentifier, 0, null, null, 0, Constants.ROOT_UUID, null);
+
+ lockManager.addLock(nodeIdentifier, new LockData(nodeIdentifier, "token", false, false, "__system", -1));
+
+ modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(removeNode(node));
+ modifications.addAll(removeSession());
+ lockCacheLoader.put(modifications);
+
+ assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
+ assertEquals(sessionId, lockManager.getSessionid());
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 13:02:31 UTC (rev 560)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 13:37:09 UTC (rev 561)
@@ -86,4 +86,8 @@
pendingLocks.put(nodeIdentifier, lData);
}
+ public void addLock(String nodeIdentifier, LockData lData)
+ {
+ locks.put(nodeIdentifier, lData);
+ }
}
16 years, 8 months
exo-jcr SVN: r560 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-11 08:02:31 -0500 (Wed, 11 Nov 2009)
New Revision: 560
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-204: Updated functionality for node-type filtering
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java 2009-11-11 12:53:06 UTC (rev 559)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java 2009-11-11 13:02:31 UTC (rev 560)
@@ -61,7 +61,7 @@
protected WorkspacePersistentDataManager workspaceDataManager;
public ObservationManagerRegistry(WorkspacePersistentDataManager workspaceDataManager,
- SessionRegistry sessionRegistry, NamespaceAccessor namespaceAccessor)
+ SessionRegistry sessionRegistry, NamespaceAccessor namespaceAccessor, NodeTypeDataManager nodeTypeDataManager)
{
this.sessionRegistry = sessionRegistry;
this.listenersMap = new HashMap<EventListener, ListenerCriteria>();
@@ -119,17 +119,5 @@
{
return nodeTypeDataManager;
}
-
- // TODO: remove hardcode
- public WorkspacePersistentDataManager getWorkspaceDataManager()
- {
- return workspaceDataManager;
- }
-
- // TODO: remove hardcode
- public LocationFactory getLocationFactory()
- {
- return new LocationFactory(namespaceAccessor);
- }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoader.java 2009-11-11 12:53:06 UTC (rev 559)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoader.java 2009-11-11 13:02:31 UTC (rev 560)
@@ -18,15 +18,20 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.core.NamespaceAccessor;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.observation.EventImpl;
import org.exoplatform.services.jcr.impl.core.observation.ListenerCriteria;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
import org.exoplatform.services.jcr.impl.util.EntityCollection;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Fqn;
@@ -60,17 +65,23 @@
private ObservationManagerRegistry observationManagerRegistry = null;
+ private WorkspaceDataContainer dataContainer = null;
+
+ private LocationFactory locationFactory = null;
+
/**
- *
+ * Init the loader DataContainer with given WorkspaceDataContainer instance.
+ *
+ * @param dataContainer WorkspaceDataContainer
*/
- public ObservationCacheLoader()
- {
- }
-
@Inject
- public void insertObservationRegistry(ObservationManagerRegistry observationManagerRegistry)
+ public void injectDependencies(ObservationManagerRegistry observationManagerRegistry,
+ WorkspaceDataContainer dataContainer, NamespaceAccessor namespaceAccessor)
+ throws RepositoryConfigurationException
{
+ this.dataContainer = dataContainer;
this.observationManagerRegistry = observationManagerRegistry;
+ this.locationFactory = new LocationFactory(namespaceAccessor);
}
/**
@@ -85,15 +96,12 @@
// get UserID from list
String sessionId = "";
- // extract real list from list of modification
- // real - means list with out fake modifications containing UserID & etc
-
// for each listener
// for each element from real list post and event, if filtering ok
if (observationManagerRegistry != null)
{
-
+ WorkspaceStorageConnection storageConnection = dataContainer.openConnection();
EventListenerIterator eventListeners = observationManagerRegistry.getEventListeners();
while (eventListeners.hasNext())
{
@@ -120,15 +128,12 @@
// check UUID
result &= isIdentifierMatch(criteria, item);
// check NodeType
- // TODO: FIX nodetype checks
- //result &= isNodeTypeMatch(criteria, item, changesLog);
+ result &= isNodeTypeMatch(criteria, item, modifications, storageConnection);
// check session
result &= isSessionMatch(criteria, sessionId);
if (result)
{
- String path =
- observationManagerRegistry.getLocationFactory().createJCRPath(item.getQPath()).getAsString(
- false);
+ String path = locationFactory.createJCRPath(item.getQPath()).getAsString(false);
events.add(new EventImpl(eventType, path, userId));
}
} // it wasn't able to retrive item's data
@@ -136,24 +141,35 @@
// if this is session
else if (isSessionSubtree(m))
{
- if (m.getType() == ModificationType.PUT_KEY_VALUE){
+ if (m.getType() == ModificationType.PUT_KEY_VALUE)
+ {
if (m.getKey().equals(JBossCacheStorage.SESSION_ID))
sessionId = (String)m.getValue();
else if (m.getKey().equals(JBossCacheStorage.USER_ID))
- userId = (String)m.getValue();}
- else if (m.getType() == ModificationType.REMOVE_NODE){
- sessionId = "";
- userId = "";
- }
+ userId = (String)m.getValue();
+ }
+ else if (m.getType() == ModificationType.REMOVE_DATA)
+ {
+ sessionId = "";
+ userId = "";
+ }
}
}
if (events.size() > 0)
{
// no events - no onEvent() action
- listener.onEvent(events);
+ try
+ {
+ listener.onEvent(events);
+ }
+ catch (Exception e)
+ {
+ log.error("Onservation listener (" + listener + ") in error, skipping.", e);
+ }
}
}
+ storageConnection.close();
}
}
@@ -245,24 +261,21 @@
return itemPath.isDescendantOf(criteria.getAbsPath(), !criteria.isDeep());
}
- // shoud be changed in order to obtain parent's data elsewhere. Cache is not accessible from cacheloader.put(List)
- @Deprecated
- private boolean isNodeTypeMatch(ListenerCriteria criteria, ItemData item, List<Modification> modifications)
- throws RepositoryException
+ // should be changed in order to obtain parent's data elsewhere. Cache is not accessible from cacheloader.put(List)
+ private boolean isNodeTypeMatch(ListenerCriteria criteria, ItemData item, List<Modification> modifications,
+ WorkspaceStorageConnection storageConnection) throws RepositoryException
{
if (criteria.getNodeTypeName() == null)
return true;
- // TODO: IT IS IMPOSSIBLE TO ACCESS CACHE ON CACHELOADER.PUT()!!!
- NodeData node =
- (NodeData)observationManagerRegistry.getWorkspaceDataManager().getItemData(item.getParentIdentifier());
+ NodeData node = (NodeData)storageConnection.getItemData(item.getParentIdentifier());
if (node == null)
{
// check if parent exists in changes log
for (int i = modifications.size() - 1; i >= 0; i--)
{
ItemData data = getItemData(modifications.get(i));
- if (data.getIdentifier().equals(item.getParentIdentifier()))
+ if (data != null && data.getIdentifier().equals(item.getParentIdentifier()))
{
// parent found
node = (NodeData)data;
@@ -280,19 +293,8 @@
for (int i = 0; i < criteria.getNodeTypeName().length; i++)
{
- NodeTypeData criteriaNT =
- observationManagerRegistry.getNodeTypeDataManager().getNodeType(criteria.getNodeTypeName()[i]);
- InternalQName[] testQNames;
- if (criteriaNT.isMixin())
- {
- testQNames = node.getMixinTypeNames();
- }
- else
- {
- testQNames = new InternalQName[1];
- testQNames[0] = node.getPrimaryTypeName();
- }
- if (observationManagerRegistry.getNodeTypeDataManager().isNodeType(criteriaNT.getName(), testQNames))
+ if (observationManagerRegistry.getNodeTypeDataManager().isNodeType(criteria.getNodeTypeName()[i],
+ node.getPrimaryTypeName(), node.getMixinTypeNames()))
return true;
}
return false;
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-11 12:53:06 UTC (rev 559)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-11 13:02:31 UTC (rev 560)
@@ -19,27 +19,46 @@
package org.exoplatform.services.jcr.impl.storage.jbosscache;
import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.core.NamespaceAccessor;
+import org.exoplatform.services.jcr.core.nodetype.ItemDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.NodeDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataImpl;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeValue;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionDatas;
+import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.observation.ListenerCriteria;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.storage.inmemory.InmemoryContainerImpl;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.jboss.cache.Modification;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import javax.jcr.InvalidItemStateException;
import javax.jcr.NamespaceException;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;
@@ -56,6 +75,10 @@
private ObservationManagerRegistry registry;
+ private DummyWorkspaceStorageConnection workspaceStorageConnection;
+
+ private NamespaceAccessor accessor;
+
private LocationFactory lf;
@Override
@@ -63,8 +86,8 @@
{
super.setUp();
loader = new ObservationCacheLoader();
- registry = new DummyObservationRegistry();
- loader.insertObservationRegistry(registry);
+ registry = new ObservationManagerRegistry(null, null, null,new DummyNodeTypeDataManager());
+ workspaceStorageConnection = new DummyWorkspaceStorageConnection();
final Map<String, String> ns = new HashMap<String, String>();
@@ -77,9 +100,8 @@
ns.put("nt", "http://nt");
nss.put("http://nt", "nt");
- this.lf = new LocationFactory(new NamespaceAccessor()
+ accessor = new NamespaceAccessor()
{
-
public String getNamespaceURIByPrefix(String prefix) throws NamespaceException, RepositoryException
{
return ns.get(prefix);
@@ -94,7 +116,10 @@
{
return ns.keySet().toArray(new String[ns.keySet().size()]);
}
- });
+ };
+
+ lf = new LocationFactory(accessor);
+ loader.injectDependencies(registry, new DummyWorkspaceDataContainer(workspaceStorageConnection), accessor);
}
public void testFilterByUUID() throws Exception
@@ -220,58 +245,314 @@
public void testFilterByNodeType() throws Exception
{
- QPath node1path = QPath.parse("[]:1[]node:1");
- NodeData newNode =
- new TransientNodeData(node1path, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ String parent1uuid = "uuid1";
+ String parent2uuid = "uuid2";
+
+ QPath node1path = QPath.parse("[]:1[]node1:1");
+ NodeData parentNode1 =
+ new TransientNodeData(node1path, parent1uuid, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList());
- NodeData newNode2 =
- new TransientNodeData(node1path, Constants.SYSTEM_UUID, 1, Constants.NT_RESOURCE, new InternalQName[0], 0,
+ workspaceStorageConnection.add(parentNode1);
+
+ QPath node2path = QPath.parse("[]:1[]node2:1");
+ NodeData parentNode2 =
+ new TransientNodeData(node2path, parent2uuid, 1, Constants.NT_RESOURCE, new InternalQName[0], 0,
Constants.ROOT_UUID, new AccessControlList());
+ workspaceStorageConnection.add(parentNode2);
+
+ QPath child1path = QPath.parse("[]:1[]child1:1");
+ NodeData childNode1 =
+ new TransientNodeData(child1path, "child1", 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ parent1uuid, new AccessControlList());
+
+ QPath child2path = QPath.parse("[]:1[]child2:1");
+ NodeData childNode2 =
+ new TransientNodeData(child2path, "child2", 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ parent2uuid, new AccessControlList());
+
DummyListener listener = new DummyListener();
// listening only to NT_RESOURCE nodes
registry.addEventListener(listener, new ListenerCriteria(Event.NODE_ADDED,
- lf.parseAbsPath("/").getInternalPath(), true, null, new InternalQName[]{Constants.NT_RESOURCE}, false, "session1"));
+ lf.parseAbsPath("/").getInternalPath(), true, null, new InternalQName[]{Constants.NT_RESOURCE}, false,
+ "session1"));
List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
- modifications.addAll(addNode(newNode));
- modifications.addAll(addNode(newNode2));
+ modifications.addAll(addNode(childNode1));
+ modifications.addAll(addNode(childNode2));
modifications.addAll(removeSession());
loader.put(modifications);
// one event expected
- assertEvent(Event.NODE_ADDED, node1path, listener, "admin");
+ assertEvent(Event.NODE_ADDED, child2path, listener, "admin");
}
-
+
@Override
protected void tearDown() throws Exception
{
super.tearDown();
}
- class DummyObservationRegistry extends ObservationManagerRegistry
+ class DummyListener implements EventListener
{
- public DummyObservationRegistry()
+ public List<Event> eventList = new ArrayList<Event>();
+
+ public void onEvent(EventIterator events)
{
- super(null, null, null);
+ while (events.hasNext())
+ {
+ eventList.add(events.nextEvent());
+ }
}
- public LocationFactory getLocationFactory()
- {
- return lf;
- }
}
- class DummyListener implements EventListener
+ class DummyNodeTypeDataManager implements NodeTypeDataManager
{
- public List<Event> eventList = new ArrayList<Event>();
- public void onEvent(EventIterator events)
+ public NodeDefinitionData[] getAllChildNodeDefinitions(InternalQName... nodeTypeNames)
{
- while (events.hasNext())
+ return null;
+ }
+
+ public List<NodeTypeData> getAllNodeTypes()
+ {
+ return null;
+ }
+
+ public PropertyDefinitionData[] getAllPropertyDefinitions(InternalQName... nodeTypeNames)
+ {
+ return null;
+ }
+
+ public NodeDefinitionData getChildNodeDefinition(InternalQName nodeName, InternalQName... nodeTypeNames)
+ throws RepositoryException
+ {
+ return null;
+ }
+
+ public NodeDefinitionData getChildNodeDefinition(InternalQName nodeName, InternalQName primaryNodeType,
+ InternalQName[] mixinTypes) throws RepositoryException
+ {
+ return null;
+ }
+
+ public Set<InternalQName> getDeclaredSubtypes(InternalQName nodeTypeName)
+ {
+ return null;
+ }
+
+ public List<ItemDefinitionData> getManadatoryItemDefs(InternalQName primaryNodeType, InternalQName[] mixinTypes)
+ throws RepositoryException
+ {
+ return null;
+ }
+
+ public NodeTypeData getNodeType(InternalQName typeName)
+ {
+ return null;
+ }
+
+ public PropertyDefinitionDatas getPropertyDefinitions(InternalQName propertyName, InternalQName... nodeTypeNames)
+ throws RepositoryException
+ {
+ return null;
+ }
+
+ public PropertyDefinitionDatas getPropertyDefinitions(InternalQName propertyName, InternalQName primaryNodeType,
+ InternalQName[] mixinTypes) throws RepositoryException
+ {
+ return null;
+ }
+
+ public Set<InternalQName> getSubtypes(InternalQName nodeTypeName)
+ {
+ return null;
+ }
+
+ public Set<InternalQName> getSupertypes(InternalQName nodeTypeName)
+ {
+ return null;
+ }
+
+ public boolean isChildNodePrimaryTypeAllowed(InternalQName childNodeTypeName, InternalQName parentNodeType,
+ InternalQName[] parentMixinNames) throws RepositoryException
+ {
+ return false;
+ }
+
+ public boolean isNodeType(InternalQName testTypeName, InternalQName... typeNames)
+ {
+ return false;
+ }
+
+ public boolean isNodeType(InternalQName testTypeName, InternalQName primaryNodeType, InternalQName[] mixinNames)
+ {
+ if (testTypeName.equals(primaryNodeType))
{
- eventList.add(events.nextEvent());
+ return true;
}
+ for (InternalQName name : mixinNames)
+ {
+ if (testTypeName.equals(name))
+ {
+ return true;
+ }
+ }
+ return false;
}
+ public boolean isOrderableChildNodesSupported(InternalQName primaryNodeType, InternalQName[] mixinTypes)
+ throws RepositoryException
+ {
+ return false;
+ }
+
+ public List<NodeTypeData> registerNodeTypes(InputStream xml, int alreadyExistsBehaviour, String contentType)
+ throws RepositoryException
+ {
+ return null;
+ }
+
+ public List<NodeTypeData> registerNodeTypes(List<NodeTypeValue> ntValues, int alreadyExistsBehaviour)
+ throws RepositoryException
+ {
+ return null;
+ }
+
+ public PlainChangesLog setPrimaryType(NodeData nodeData, InternalQName nodeTypeName) throws RepositoryException
+ {
+ return null;
+ }
+
+ public void unregisterNodeType(InternalQName nodeTypeName) throws RepositoryException
+ {
+ }
+
+ public PlainChangesLog updateNodeType(NodeTypeData ancestorDefinition, NodeTypeData recipientDefinition,
+ Map<InternalQName, NodeTypeData> volatileNodeTypes) throws ConstraintViolationException, RepositoryException
+ {
+ return null;
+ }
+
}
+ class DummyWorkspaceDataContainer extends InmemoryContainerImpl
+ {
+
+ private DummyWorkspaceStorageConnection storageConnection;
+
+ public DummyWorkspaceDataContainer(DummyWorkspaceStorageConnection storageConnection) throws RepositoryException
+ {
+ super(new WorkspaceEntry("", ""));
+ this.storageConnection = storageConnection;
+ }
+
+ public WorkspaceStorageConnection openConnection()
+ {
+ return storageConnection;
+ }
+ }
+
+ class DummyWorkspaceStorageConnection implements WorkspaceStorageConnection
+ {
+
+ private Map<String, ItemData> storage = new HashMap<String, ItemData>();
+
+ public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
+ {
+ return storage.get(identifier);
+ }
+
+ public void add(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ storage.put(data.getIdentifier(), data);
+ }
+
+ public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ storage.put(data.getIdentifier(), data);
+ }
+
+ public void addSessionInfo(String sessionId, String userId) throws RepositoryException
+ {
+ }
+
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
+ {
+ return null;
+ }
+
+ public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ return null;
+ }
+
+ public boolean isOpened()
+ {
+ return false;
+ }
+
+ public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException,
+ IllegalStateException
+ {
+ return null;
+ }
+
+ public void removeSessionInfo() throws RepositoryException
+ {
+ }
+
+ public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ }
+
+ public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ }
+
+ }
+
}
16 years, 8 months
exo-jcr SVN: r559 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 5 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-11 07:53:06 -0500 (Wed, 11 Nov 2009)
New Revision: 559
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.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/LockCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
Log:
EXOJCR-205: small fix
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -52,6 +52,7 @@
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import org.jboss.cache.factories.annotations.NonVolatile;
import org.picocontainer.Startable;
import java.io.IOException;
@@ -77,6 +78,7 @@
*/
@Managed
@NameTemplate(@Property(key = "service", value = "lockmanager"))
+@NonVolatile
public class LockManagerImpl implements ItemsPersistenceListener, SessionLifecycleListener, LockManager, Startable
{
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -187,8 +187,9 @@
if (!systemConnSessionInfoAdded)
{
+ // TODO userId
if (!systemConnection.equals(thisConnection))
- systemConnection.addSessionInfo(currChangesLog.getSessionId(), "");
+ systemConnection.addSessionInfo(currChangesLog.getSessionId());
systemConnSessionInfoAdded = true;
}
}
@@ -215,8 +216,9 @@
if (!thisConnSessionInfoAdded)
{
+ // TODO userId
if (!thisConnection.equals(systemConnection))
- thisConnection.addSessionInfo(currChangesLog.getSessionId(), "");
+ thisConnection.addSessionInfo(currChangesLog.getSessionId());
thisConnSessionInfoAdded = true;
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -214,7 +214,7 @@
/**
* {@inheritDoc}
*/
- public void addSessionInfo(String sessionId, String userId) throws RepositoryException
+ public void addSessionInfo(String sessionId) throws RepositoryException
{
}
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-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -556,7 +556,7 @@
/**
* {@inheritDoc}
*/
- public void addSessionInfo(String sessionId, String userId) throws RepositoryException
+ public void addSessionInfo(String sessionId) throws RepositoryException
{
startBatch();
@@ -567,7 +567,6 @@
// add attributes
sessionRoot.put(JBossCacheStorage.SESSION_ID, sessionId);
- sessionRoot.put(JBossCacheStorage.USER_ID, userId);
}
/**
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-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -396,7 +396,7 @@
/**
* {@inheritDoc}
*/
- public void addSessionInfo(String sessionId, String userId) throws RepositoryException
+ public void addSessionInfo(String sessionId) throws RepositoryException
{
}
Modified: 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 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -16,11 +16,13 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -28,6 +30,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
+import org.jboss.cache.factories.annotations.Inject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
@@ -51,7 +54,7 @@
/**
* Lock manager.
*/
- private final LockManagerImpl lockManager;
+ private LockManagerImpl lockManager;
/**
* Logger.
@@ -59,12 +62,18 @@
private final Log log = ExoLogger.getLogger("jcr.LockCacheLoader");
/**
- * LockCacheLoader constructor.
+ * Injection dependencies.
*
- * @param lockManager
+ * @param lockManager LockManagerImpl
*/
- public LockCacheLoader(LockManagerImpl lockManager)
+ @Inject
+ public void injectDependencies(LockManagerImpl lockManager) throws RepositoryConfigurationException
{
+ if (this.lockManager != null)
+ {
+ throw new RepositoryConfigurationException("Cannot set LockManagerImpl twice");
+ }
+
this.lockManager = lockManager;
}
@@ -106,7 +115,7 @@
else if (lockChanges.get(0).getType() == ModificationType.REMOVE_NODE
&& lockChanges.get(1).getType() == ModificationType.REMOVE_NODE)
{
- PropertyData propertyData = (PropertyData)lockChanges.get(0).getOldValue();
+ PropertyData propertyData = (PropertyData)lockChanges.get(0).getValue();
performUnLock(lockChanges, propertyData.getParentIdentifier(), sessionId);
}
else
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -700,7 +700,7 @@
/**
* {@inheritDoc}
*/
- public void addSessionInfo(String sessionId, String userId) throws RepositoryException
+ public void addSessionInfo(String sessionId) throws RepositoryException
{
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -314,13 +314,10 @@
* @param sessionId
* the session identifier to be added
*
- * @param userId
- * the user identifier to be added
- *
* @throws RepositoryException
* if some exception occured
*/
- void addSessionInfo(String sessionId, String userId) throws RepositoryException;
+ void addSessionInfo(String sessionId) throws RepositoryException;
/**
* Remove session information from cache storage.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -41,6 +41,11 @@
protected static boolean addPUTDATA = true;
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
/**
* Returns {@link Modification} like as node added. NodeData is written to /$NODE/IDxxxx as an attribute by key ITEM_DATA.
*
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -16,20 +16,38 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
+import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.lock.LockData;
+import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.impl.storage.value.StandaloneStoragePluginProvider;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import org.jboss.cache.Node;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.jcr.PropertyType;
+import javax.naming.Context;
/**
* Created by The eXo Platform SAS.
@@ -46,16 +64,26 @@
private LockCacheLoader lockCacheLoader;
- private ValueFactoryImpl valueFactory;
-
private final QPath testRoot = QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testRoot"));
public void setUp() throws Exception
{
- this.lockManager = new TesterLockManagerImpl();
- this.lockCacheLoader = new LockCacheLoader(lockManager);
+ super.setUp();
+
+ lockManager = new TesterLockManagerImpl();
+ lockCacheLoader = new LockCacheLoader();
+ lockCacheLoader.injectDependencies(lockManager);
}
+ /**
+ * {@inheritDoc}
+ */
+ protected void tearDown() throws Exception
+ {
+
+ super.tearDown();
+ }
+
public void testLock() throws Exception
{
List<Modification> modifications = new ArrayList<Modification>();
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 11:30:51 UTC (rev 558)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-11 12:53:06 UTC (rev 559)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.impl.core.lock.LockData;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.jboss.cache.factories.annotations.NonVolatile;
import java.util.Map;
@@ -35,6 +36,7 @@
* @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
* @version $Id$
*/
+@NonVolatile
public class TesterLockManagerImpl extends LockManagerImpl
{
16 years, 8 months
exo-jcr SVN: r558 - 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-11 06:30:51 -0500 (Wed, 11 Nov 2009)
New Revision: 558
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderException.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java
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/ExoJCRCacheLoaderException.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java 2009-11-11 09:34:47 UTC (rev 557)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderException.java 2009-11-11 11:30:51 UTC (rev 558)
@@ -61,7 +61,7 @@
}
/**
- * RepositoryConfigurationException constructor.
+ * ExoJCRCacheLoaderException constructor.
*
* @param cause
* Throwable, the base exception.
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 09:34:47 UTC (rev 557)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-11 11:30:51 UTC (rev 558)
@@ -309,8 +309,88 @@
{
Map<Object, Object> attrs = new LinkedHashMap<Object, Object>();
+
if (name.size() > 1)
{
+ if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ // return NodeData [ITEM_DATA : NodeData]
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+
+ try
+ {
+ NodeData nodeData = (NodeData) conn.getItemData(name.getLastElementAsString());
+
+ if (nodeData != null)
+ {
+ attrs.put(JBossCacheStorage.ITEM_DATA, nodeData);
+
+ // put [PROPERTY_NAME : propertyData_ID]
+ for (PropertyData prop : conn.getChildPropertiesData(nodeData))
+ {
+ attrs.put(prop.getQPath().getName().getAsString(), prop.getIdentifier());
+ }
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ QPathEntry nodeName = QPathEntry.parse(name.getLastElementAsString());
+
+ // return [ITEM_Id : nodeData_ID]
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+
+ try
+ {
+ NodeData parentNodeData = (NodeData) conn.getItemData((String)name.get(2));
+
+ if (parentNodeData == null)
+ throw new JDBCCacheLoaderException("The parent node with ID = " + (String)name.get(2) + " not exis, FQN = '" + name + "'.");
+
+ NodeData nodeData = (NodeData) conn.getItemData(parentNodeData, nodeName);
+ if (nodeData != null)
+ attrs.put(JBossCacheStorage.ITEM_ID, nodeData.getIdentifier());
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ // return PropertyData [ITEM_DATA : PropertyData]
+ WorkspaceStorageConnection conn = dataContainer.openConnection();
+
+ try
+ {
+ PropertyData propertyData = (PropertyData) conn.getItemData(name.getLastElementAsString());
+
+ if (propertyData != null)
+ attrs.put(JBossCacheStorage.ITEM_DATA, propertyData);
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ }
+ }
+
+ return attrs;
+ /*if (name.size() > 1)
+ {
if (name.get(1).equals(JBossCacheStorage.NODES))
{
// return Node
@@ -369,8 +449,7 @@
}
}
}
- }
- return attrs;
+ }*/
}
/**
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderException.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderException.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderException.java 2009-11-11 11:30:51 UTC (rev 558)
@@ -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.storage.jbosscache;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
+ * @version $Id$
+ */
+public class JDBCCacheLoaderException
+ extends Exception
+{
+ /**
+ * Constructs an Exception without a message.
+ */
+ public JDBCCacheLoaderException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an Exception with a detailed message.
+ *
+ * @param Message
+ * The message associated with the exception.
+ */
+ public JDBCCacheLoaderException(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 JDBCCacheLoaderException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * JDBCCacheLoaderException constructor.
+ *
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public JDBCCacheLoaderException(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/JDBCCacheLoaderException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r557 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-11 04:34:47 -0500 (Wed, 11 Nov 2009)
New Revision: 557
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
Log:
EXOJCR-201: refactoring
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-11 09:12:32 UTC (rev 556)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2009-11-11 09:34:47 UTC (rev 557)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.dataflow.PersistentDataManager;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.ReadOnlyThroughChanges;
-import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListenerFilter;
import org.exoplatform.services.jcr.dataflow.persistent.MandatoryItemsPersistenceListener;
@@ -150,6 +149,9 @@
{
for (PlainChangesLog currChangesLog : chengesLogList)
{
+ boolean systemConnSessionInfoAdded = false;
+ boolean thisConnSessionInfoAdded = false;
+
for (Iterator<ItemState> iter = currChangesLog.getAllStates().iterator(); iter.hasNext();)
{
ItemState itemState = iter.next();
@@ -169,7 +171,7 @@
? systemConnection = (systemDataContainer != dataContainer
// if it's different container instances
? systemDataContainer.equals(dataContainer) && thisConnection != null
- // but container confugrations are same and non-system connnection open
+ // but container configurations are same and non-system connection open
// reuse this connection as system
? systemDataContainer.reuseConnection(thisConnection)
// or open one new system
@@ -182,15 +184,22 @@
: thisConnection)
// system connection opened - use it
: systemConnection;
+
+ if (!systemConnSessionInfoAdded)
+ {
+ if (!systemConnection.equals(thisConnection))
+ systemConnection.addSessionInfo(currChangesLog.getSessionId(), "");
+ systemConnSessionInfoAdded = true;
+ }
}
else
{
conn = thisConnection == null
- // we need this conatiner conection
+ // we need this container connection
? thisConnection = (systemDataContainer != dataContainer
// if it's different container instances
? dataContainer.equals(systemDataContainer) && systemConnection != null
- // but container confugrations are same and system connnection open
+ // but container configurations are same and system connection open
// reuse system connection as this
? dataContainer.reuseConnection(systemConnection)
// or open one new
@@ -203,6 +212,13 @@
: systemConnection)
// this connection opened - use it
: thisConnection;
+
+ if (!thisConnSessionInfoAdded)
+ {
+ if (!thisConnection.equals(systemConnection))
+ thisConnection.addSessionInfo(currChangesLog.getSessionId(), "");
+ thisConnSessionInfoAdded = true;
+ }
}
data.increasePersistedVersion();
@@ -228,10 +244,10 @@
LOG.debug(ItemState.nameFromValue(itemState.getState()) + " " + (System.currentTimeMillis() - start)
+ "ms, " + data.getQPath().getAsString());
}
- // if (thisConnection != null)
- // thisConnection.removeSessionInfo();
- // if (systemConnection != null && !systemConnection.equals(thisConnection))
- // systemConnection.removeSessionInfo();
+ if (thisConnection != null)
+ thisConnection.removeSessionInfo();
+ if (systemConnection != null && !systemConnection.equals(thisConnection))
+ systemConnection.removeSessionInfo();
}
if (thisConnection != null)
thisConnection.commit();
16 years, 8 months
exo-jcr SVN: r556 - jcr/trunk.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-11 04:12:32 -0500 (Wed, 11 Nov 2009)
New Revision: 556
Modified:
jcr/trunk/pom.xml
Log:
EXOJCR-208 Duplicated (ws-commons-util) entry in dependencyMangement removed
Modified: jcr/trunk/pom.xml
===================================================================
--- jcr/trunk/pom.xml 2009-11-11 08:22:24 UTC (rev 555)
+++ jcr/trunk/pom.xml 2009-11-11 09:12:32 UTC (rev 556)
@@ -218,12 +218,6 @@
</dependency>
<dependency>
- <groupId>org.apache.ws.commons</groupId>
- <artifactId>ws-commons-util</artifactId>
- <version>1.0.1</version>
- </dependency>
-
- <dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>1.0</version>
16 years, 8 months