exo-jcr SVN: r515 - 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-09 09:43:13 -0500 (Mon, 09 Nov 2009)
New Revision: 515
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCWorkspaceDataContainerTester.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 : test JDBCCacheLoadetTest.
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-09 14:38:12 UTC (rev 514)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-09 14:43:13 UTC (rev 515)
@@ -1,3 +1,21 @@
+/*
+ * 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.io.Serializable;
@@ -2,13 +20,4 @@
-import javax.jcr.RepositoryException;
-
-import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.picocontainer.Startable;
@@ -55,66 +64,3 @@
}
}
-@NonVolatile
-class JDBCWorkspaceDataContainerTester extends WorkspaceDataContainerBase implements Startable
-{
-
- public JDBCWorkspaceDataContainerTester()
- {
- }
-
- public void start()
- {
- // TODO Auto-generated method stub
-
- }
-
- public void stop()
- {
- // TODO Auto-generated method stub
-
- }
-
- public boolean isSame(WorkspaceDataContainer another)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
- public WorkspaceStorageConnection openConnection() throws RepositoryException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getInfo()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getStorageVersion()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCWorkspaceDataContainerTester.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCWorkspaceDataContainerTester.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCWorkspaceDataContainerTester.java 2009-11-09 14:43:13 UTC (rev 515)
@@ -0,0 +1,91 @@
+/*
+ * 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 javax.jcr.RepositoryException;
+
+import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.jboss.cache.factories.annotations.NonVolatile;
+import org.picocontainer.Startable;
+
+@NonVolatile
+class JDBCWorkspaceDataContainerTester extends WorkspaceDataContainerBase implements Startable
+{
+
+ public JDBCWorkspaceDataContainerTester()
+ {
+ }
+
+ public void start()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isSame(WorkspaceDataContainer another)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public WorkspaceStorageConnection openConnection() throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getInfo()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getStorageVersion()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCWorkspaceDataContainerTester.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r514 - in jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl: storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-11-09 09:38:12 -0500 (Mon, 09 Nov 2009)
New Revision: 514
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/JBossCacheStorage.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
Log:
EXOJCR-205: refactoring LockCacheLoader
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-09 14:29:33 UTC (rev 513)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2009-11-09 14:38:12 UTC (rev 514)
@@ -814,4 +814,12 @@
{
return pendingLocks.containsKey(nodeIdentifier);
}
+
+ /**
+ * TODO: Added. Need for LockCacheLoader..
+ */
+ public boolean hasLockNode(String nodeIdentifier)
+ {
+ return locks.containsKey(nodeIdentifier);
+ }
}
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-09 14:29:33 UTC (rev 513)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-09 14:38:12 UTC (rev 514)
@@ -16,24 +16,6 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
package org.exoplatform.services.jcr.impl.storage.jbosscache;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -54,31 +36,33 @@
public abstract class JBossCacheStorage
{
+ public static final String SESSION = "$SESSION".intern();
+
public static final String NODES = "$NODES".intern();
-
+
public static final String PROPS = "$PROPS".intern();
-
+
public static final String OBSERVATION = "$OBSERVATION".intern();
public static final String ITEM_DATA = "$data".intern();
public static final String ITEM_ID = "$id".intern();
-
+
public static final String SESSION_ID = "$sessionId".intern();
-
+
public static final String USER_ID = "$userId".intern();
protected final Node<Serializable, Object> nodesRoot;
-
+
protected final Node<Serializable, Object> propsRoot;
protected JBossCacheStorage(Node<Serializable, Object> nodesRoot, Node<Serializable, Object> propsRoot)
{
this.nodesRoot = nodesRoot;
-
+
this.propsRoot = propsRoot;
}
-
+
/**
* Make Child Node relative Fqn, i.e. ./NIDxxx/NAMExxx.
*
@@ -92,7 +76,7 @@
//return Fqn.fromRelativeFqn(nodesRoot.getFqn(), Fqn.fromElements(parentId, nodeName.getAsString(true)));
return Fqn.fromElements(parentId, nodeName.getAsString(true));
}
-
+
/**
* Make Child Node relative Fqn. i.e. ./NAMExxx.
*
@@ -104,8 +88,6 @@
return Fqn.fromElements(nodeName.getAsString(true));
}
-
-
/**
* Make Node relative Fqn, i.e. ./NIDxxx.
*
@@ -129,5 +111,5 @@
//return Fqn.fromRelativeFqn(propsRoot, Fqn.fromElements(propId));
return Fqn.fromElements(propId);
}
-
+
}
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-09 14:29:33 UTC (rev 513)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-09 14:38:12 UTC (rev 514)
@@ -16,8 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.impl.Constants;
@@ -27,10 +25,14 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import javax.jcr.lock.LockException;
@@ -62,17 +64,76 @@
@Override
public void put(List<Modification> modifications) throws Exception
{
+ String sessionId = null;
+ HashSet<String> removedLock = new HashSet<String>();
List<Modification> lockChanges = new ArrayList<Modification>();
for (Modification m : modifications)
{
- if (m.getFqn().hasElement(JBossCacheStorage.PROPS))
+ if (m.getFqn().hasElement(JBossCacheStorage.SESSION))
{
switch (m.getType())
{
+ case PUT_DATA_ERASE :
+ break;
case PUT_DATA :
+ // changesLog begin
+ int pos = getElementPosition(m.getFqn(), JBossCacheStorage.SESSION);
+ sessionId = (String)m.getFqn().get(pos + 1);
break;
+ case PUT_KEY_VALUE :
+ break;
+ case REMOVE_DATA :
+ break;
+ case REMOVE_KEY_VALUE :
+ break;
+ case REMOVE_NODE :
+ // perform lock or unlock operation
+ if (lockChanges.size() == 2)
+ {
+ if (lockChanges.get(0).getType() == ModificationType.PUT_KEY_VALUE
+ && lockChanges.get(1).getType() == ModificationType.PUT_KEY_VALUE)
+ {
+ performLock(lockChanges, sessionId);
+ }
+ else if (lockChanges.get(0).getType() == ModificationType.REMOVE_KEY_VALUE
+ && lockChanges.get(1).getType() == ModificationType.REMOVE_KEY_VALUE)
+ {
+ performUnLock(lockChanges, sessionId);
+ }
+ else
+ {
+ log.error("Incorrect changes log contains lock and unlock operation simultaneously");
+ }
+ }
+ else if (lockChanges.size() != 0)
+ {
+ log.error("Incorrect changes log size for lock or unlock operation");
+ }
+ // changesLog end
+ for (String identifier : removedLock)
+ {
+ lockManager.internalUnLock(sessionId, identifier);
+ }
+
+ lockChanges = new ArrayList<Modification>();
+ sessionId = null;
+ break;
+ case MOVE :
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
+ else if (m.getFqn().hasElement(JBossCacheStorage.PROPS))
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA_ERASE :
+ break;
+ case PUT_DATA :
+ break;
case PUT_KEY_VALUE :
if (m.getKey().equals(JBossCacheStorage.ITEM_DATA))
{
@@ -85,56 +146,63 @@
}
}
break;
-
case REMOVE_DATA :
break;
-
case REMOVE_KEY_VALUE :
- PropertyData propertyData = (PropertyData)m.getValue();
- InternalQName propertyName = propertyData.getQPath().getName();
+ 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);
+ if (propertyName.equals(Constants.JCR_LOCKISDEEP) || propertyName.equals(Constants.JCR_LOCKOWNER))
+ {
+ lockChanges.add(m);
+ }
}
break;
-
case REMOVE_NODE :
break;
-
case MOVE :
break;
-
default :
throw new CacheException("Unknown modification " + m.getType());
}
}
-
- if (lockChanges.size() == 2)
+ else if (m.getFqn().hasElement(JBossCacheStorage.NODES))
{
- if (lockChanges.get(0).getType() == ModificationType.PUT_KEY_VALUE
- && lockChanges.get(1).getType() == ModificationType.PUT_KEY_VALUE)
+ int nodesPos = getElementPosition(m.getFqn(), JBossCacheStorage.NODES);
+ if (m.getFqn().size() == nodesPos + 1)
{
- performLock(lockChanges);
+ // this is a node and node is locked
+ String nodeIdentifier = (String)m.getFqn().get(nodesPos + 1);
+ if (lockManager.hasLockNode(nodeIdentifier))
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA_ERASE :
+ break;
+ case PUT_DATA :
+ removedLock.remove(nodeIdentifier);
+ break;
+ case PUT_KEY_VALUE :
+ break;
+ case REMOVE_DATA :
+ break;
+ case REMOVE_KEY_VALUE :
+ break;
+ case REMOVE_NODE :
+ removedLock.add(nodeIdentifier);
+ break;
+ case MOVE :
+ removedLock.remove(nodeIdentifier);
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
}
- else if (lockChanges.get(0).getType() == ModificationType.REMOVE_KEY_VALUE
- && lockChanges.get(1).getType() == ModificationType.REMOVE_KEY_VALUE)
- {
- performUnLock(lockChanges);
- }
- else
- {
-
- }
}
-
- lockChanges = new ArrayList<Modification>();
}
-
- if (lockChanges.size() != 0)
- {
- log.error("Incorrect changes log size for lock or unlock operation");
- }
}
/**
@@ -143,45 +211,70 @@
* @param lockChanges
* @throws LockException
*/
- private void performLock(List<Modification> lockChanges) throws Exception
+ private void performLock(List<Modification> lockChanges, String sessionId)
{
String nodeIdentifier = ((PropertyData)lockChanges.get(0).getValue()).getParentIdentifier();
- if (lockManager.hasPendingLocks(nodeIdentifier))
+ try
{
- lockManager.internalLock(nodeIdentifier);
- }
- else
- {
- log.warn("No lock in pendingLocks for identifier " + nodeIdentifier + " Probably lock come from replication.");
+ if (lockManager.hasPendingLocks(nodeIdentifier))
+ {
+ lockManager.internalLock(nodeIdentifier);
+ }
+ else
+ {
+ log.warn("No lock in pendingLocks for identifier " + nodeIdentifier
+ + " Probably lock come from replication.");
- String lockToken = IdGenerator.generate();
- Modification ownerModification = getModification(lockChanges, Constants.JCR_LOCKOWNER);
- Modification isDeepModification = getModification(lockChanges, Constants.JCR_LOCKISDEEP);
+ String lockToken = IdGenerator.generate();
+ Modification ownerModification = getModification(lockChanges, Constants.JCR_LOCKOWNER);
+ Modification isDeepModification = getModification(lockChanges, Constants.JCR_LOCKISDEEP);
- if (ownerModification != null && isDeepModification != null)
- {
+ if (ownerModification != null && isDeepModification != null)
+ {
- String owner =
- new String(((((TransientPropertyData)(ownerModification.getValue())).getValues()).get(0))
- .getAsByteArray(), Constants.DEFAULT_ENCODING);
+ String owner =
+ new String(((((TransientPropertyData)(ownerModification.getValue())).getValues()).get(0))
+ .getAsByteArray(), Constants.DEFAULT_ENCODING);
- boolean isDeep =
- Boolean.valueOf(
- new String(((((TransientPropertyData)(isDeepModification.getValue())).getValues()).get(0))
- .getAsByteArray(), Constants.DEFAULT_ENCODING)).booleanValue();
+ boolean isDeep =
+ Boolean.valueOf(
+ new String(((((TransientPropertyData)(isDeepModification.getValue())).getValues()).get(0))
+ .getAsByteArray(), Constants.DEFAULT_ENCODING)).booleanValue();
- // TODO sessionId
- lockManager.createRemoteLock("sessionId", nodeIdentifier, lockToken, isDeep, false, owner);
+ lockManager.createRemoteLock(sessionId, nodeIdentifier, lockToken, isDeep, false, owner);
+ }
}
}
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (IllegalStateException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
}
- private void performUnLock(List<Modification> lockChanges) throws Exception
+ private void performUnLock(List<Modification> lockChanges, String sessionId)
{
- // TODO sessionId
- // TODO nodeIdentifier
- lockManager.internalUnLock("sessionId", "nodeIdentifier");
+ // TODO parent nodeIdentifier
+ try
+ {
+ lockManager.internalUnLock(sessionId, "nodeIdentifier");
+ }
+ catch (LockException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
}
/**
@@ -201,4 +294,13 @@
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;
+ }
+
}
16 years, 8 months
exo-jcr SVN: r513 - 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: nzamosenchuk
Date: 2009-11-09 09:29:33 -0500 (Mon, 09 Nov 2009)
New Revision: 513
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
Log:
EXOJCR-204: Added constants to determine Observation's sub-tree.
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-09 14:25:48 UTC (rev 512)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-09 14:29:33 UTC (rev 513)
@@ -57,10 +57,16 @@
public static final String NODES = "$NODES".intern();
public static final String PROPS = "$PROPS".intern();
+
+ public static final String OBSERVATION = "$OBSERVATION".intern();
public static final String ITEM_DATA = "$data".intern();
public static final String ITEM_ID = "$id".intern();
+
+ public static final String SESSION_ID = "$sessionId".intern();
+
+ public static final String USER_ID = "$userId".intern();
protected final Node<Serializable, Object> nodesRoot;
16 years, 8 months
exo-jcr SVN: r512 - 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: pnedonosko
Date: 2009-11-09 09:25:48 -0500 (Mon, 09 Nov 2009)
New Revision: 512
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201: test for loader update
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-09 14:25:45 UTC (rev 511)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-09 14:25:48 UTC (rev 512)
@@ -92,6 +92,8 @@
cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
+ initJBC();
+
// run cache
cache.create();
cache.start();
@@ -110,6 +112,11 @@
{
jbcConfig = "conf/standalone/test-jbosscache-config-jdbcloader.xml";
}
+
+ protected void initJBC()
+ {
+ // empty here
+ }
/**
* {@inheritDoc}
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-09 14:25:45 UTC (rev 511)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-09 14:25:48 UTC (rev 512)
@@ -14,7 +14,6 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.picocontainer.Startable;
-
public class JDBCCacheLoaderTest extends JBossCacheStorageConnectionTest
{
@@ -23,51 +22,41 @@
*/
protected void setUp() throws Exception
{
- try {
-
- // JBossCache
- initJBCConfig();
-
- cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig ,false);
-
-
-
-
- WorkspaceDataContainer persistentContainer = new JDBCWorkspaceDataContainerTester();
-
- ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(persistentContainer, WorkspaceDataContainer.class);
-
- // run cache
- cache.create();
- cache.start();
-
- Node<Serializable, Object> cacheRoot = cache.getRoot();
-
- // prepare cache structures
- nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
- props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
-
- // JCR connection
- conn = new JBossCacheStorageConnection(cache, nodes, props);
- } catch (Exception e) {
+ try
+ {
+ super.setUp();
+ }
+ catch (Exception e)
+ {
e.printStackTrace();
throw e;
}
}
-
+
+ @Override
+ protected void initJBC()
+ {
+ WorkspaceDataContainer persistentContainer = new JDBCWorkspaceDataContainerTester();
+
+ ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(persistentContainer,
+ WorkspaceDataContainer.class);
+ }
+
+ @Override
protected void initJBCConfig()
{
jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
}
-
+
public void testAddNode() throws Exception
{
super.testAddNode();
conn.commit();
}
}
+
@NonVolatile
-class JDBCWorkspaceDataContainerTester extends WorkspaceDataContainerBase implements Startable
+class JDBCWorkspaceDataContainerTester extends WorkspaceDataContainerBase implements Startable
{
public JDBCWorkspaceDataContainerTester()
@@ -77,13 +66,13 @@
public void start()
{
// TODO Auto-generated method stub
-
+
}
public void stop()
{
// TODO Auto-generated method stub
-
+
}
public boolean isSame(WorkspaceDataContainer another)
@@ -127,7 +116,5 @@
// TODO Auto-generated method stub
return null;
}
-
-
-}
+}
16 years, 8 months
exo-jcr SVN: r511 - 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: nzamosenchuk
Date: 2009-11-09 09:25:45 -0500 (Mon, 09 Nov 2009)
New Revision: 511
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-204:Observation loader test updated.
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-09 14:20:47 UTC (rev 510)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-09 14:25:45 UTC (rev 511)
@@ -24,12 +24,14 @@
import org.exoplatform.services.jcr.core.NamespaceAccessor;
import org.exoplatform.services.jcr.datamodel.InternalQName;
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.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.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
@@ -40,6 +42,7 @@
import java.util.Map;
import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
@@ -115,15 +118,123 @@
assertEquals(lf.createJCRPath(node1path).getAsString(false), event.getPath());
}
+ public void testRemoveNode() 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,
+ Constants.ROOT_UUID, new AccessControlList());
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.NODE_REMOVED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(removeNode(newNode));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.NODE_REMOVED, event.getType());
+ assertEquals(lf.createJCRPath(node1path).getAsString(false), event.getPath());
+ }
+
+ public void testAddProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_ADDED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(addProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_ADDED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
+ public void testUpdateProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_CHANGED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(updateProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_CHANGED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
+ public void testRemoveProperty() throws Exception
+ {
+ QPath prop1path = QPath.parse("[]:1[]node:1[]property:1");
+ PropertyData newProperty =
+ new TransientPropertyData(prop1path, "PropertyUUID", 0, PropertyType.UNDEFINED, Constants.SYSTEM_UUID, false);
+
+ DummyListener listener = new DummyListener();
+ registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_REMOVED, lf.parseAbsPath("/")
+ .getInternalPath(), true, null, null, false, "asd"));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.add(removeProperty(newProperty));
+ loader.put(modifications);
+ assertEquals(1, listener.eventList.size());
+ Event event = listener.eventList.get(0);
+ assertEquals(Event.PROPERTY_REMOVED, event.getType());
+ assertEquals(lf.createJCRPath(prop1path).getAsString(false), event.getPath());
+ }
+
public Modification addNode(NodeData data)
{
- // add in NODES
String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
(Object)data);
- //node.put(ITEM_DATA, data);
}
+ public Modification removeNode(NodeData data)
+ {
+ String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
+ return new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ }
+
+ public Modification addProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ }
+
+ public Modification updateProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ Modification modification =
+ new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ modification.setOldValue(data);
+ return modification;
+ }
+
+ public Modification removeProperty(PropertyData data)
+ {
+ String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
+ Modification modification =
+ new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
+ (Object)data);
+ modification.setOldValue(data);
+ return modification;
+ }
+
@Override
protected void tearDown() throws Exception
{
16 years, 8 months
exo-jcr SVN: r510 - 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-09 09:20:47 -0500 (Mon, 09 Nov 2009)
New Revision: 510
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 :Add test JDBCCacheLoaderTest.
Added: 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 (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-09 14:20:47 UTC (rev 510)
@@ -0,0 +1,133 @@
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.io.Serializable;
+
+import javax.jcr.RepositoryException;
+
+import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.factories.annotations.NonVolatile;
+import org.picocontainer.Startable;
+
+
+public class JDBCCacheLoaderTest extends JBossCacheStorageConnectionTest
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setUp() throws Exception
+ {
+ try {
+
+ // JBossCache
+ initJBCConfig();
+
+ cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig ,false);
+
+
+
+
+ WorkspaceDataContainer persistentContainer = new JDBCWorkspaceDataContainerTester();
+
+ ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(persistentContainer, WorkspaceDataContainer.class);
+
+ // run cache
+ cache.create();
+ cache.start();
+
+ Node<Serializable, Object> cacheRoot = cache.getRoot();
+
+ // prepare cache structures
+ nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
+ props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
+
+ // JCR connection
+ conn = new JBossCacheStorageConnection(cache, nodes, props);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected void initJBCConfig()
+ {
+ jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
+ }
+
+ public void testAddNode() throws Exception
+ {
+ super.testAddNode();
+ conn.commit();
+ }
+}
+@NonVolatile
+class JDBCWorkspaceDataContainerTester extends WorkspaceDataContainerBase implements Startable
+{
+
+ public JDBCWorkspaceDataContainerTester()
+ {
+ }
+
+ public void start()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void stop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isSame(WorkspaceDataContainer another)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public WorkspaceStorageConnection openConnection() throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getInfo()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getName()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getStorageVersion()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
+
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r509 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-09 09:04:45 -0500 (Mon, 09 Nov 2009)
New Revision: 509
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/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-200: get childs impls
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-09 13:04:57 UTC (rev 508)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-09 14:04:45 UTC (rev 509)
@@ -148,6 +148,7 @@
}
// remove child on Parent
+ // TODO validate does deleted
boolean removed =
parent.removeChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
}
@@ -172,6 +173,7 @@
}
// remove from parent's properties attr
+ // TODO validate does deleted
Object prev = parent.remove(data.getQPath().getName().getAsString());
// remove from PROPERTIES
@@ -187,7 +189,7 @@
Node<Serializable, Object> parentNode = nodesRoot.getChild(makeNodeFqn(parent.getIdentifier()));
if (parentNode == null)
{
- throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
+ throw new IllegalStateException("FATAL Get child Nodes: parent not found " + parent.getQPath().getAsString());
}
Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
@@ -195,13 +197,18 @@
List<NodeData> childs = new ArrayList<NodeData>();
for (Node<Serializable, Object> child : childNodes)
{
- String childId = (String)child.get(ITEM_ID);
+ String nodeId = (String)child.get(ITEM_ID);
+ if (nodeId == null)
+ {
+ throw new RepositoryException("FATAL Child Node Id key is null. Parent " + parent.getQPath().getAsString());
+ }
// TODO NodeData or PropertyData? As ItemData check then and cast.
- Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(childId));
+ Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
if (node == null)
{
- throw new RepositoryException("Child node is null. Parent " + parent.getQPath().getAsString());
+ throw new RepositoryException("FATAL Node record not found(" + nodeId + "), but listed in proprties of "
+ + parent.getQPath().getAsString());
}
NodeData nodeData = (NodeData)node.get(ITEM_DATA);
if (nodeData == null)
@@ -236,11 +243,10 @@
*/
public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
{
- //TODO treeRoot.getChild(f) possible if f not a direct child???
Node<Serializable, Object> parentNode = nodesRoot.getChild(makeNodeFqn(parent.getIdentifier()));
if (parentNode == null)
{
- throw new IllegalStateException("Get child Properties error: parent not found "
+ throw new IllegalStateException("FATAL Get child Properties: parent not found "
+ parent.getQPath().getAsString());
}
@@ -248,21 +254,26 @@
for (Serializable key : parentNode.getKeys())
{
- if (!key.equals(ITEM_ID))
+ if (!key.equals(ITEM_DATA))
{
String propId = (String)parentNode.get(key);
+ if (propId == null)
+ {
+ throw new RepositoryException("FATAL Child Property Id key is null. Parent "
+ + parent.getQPath().getAsString());
+ }
Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(propId));
if (prop == null)
{
- throw new RepositoryException("Child property is null. Parent " + parent.getQPath().getAsString());
+ throw new RepositoryException("FATAL Property record not found(" + propId
+ + "), but listed in proprties of " + parent.getQPath().getAsString());
}
PropertyData propData = (PropertyData)prop.get(ITEM_DATA);
if (propData == null)
{
- // TODO should not occurs by contract
- throw new RepositoryException("Child property data is null. Parent " + parent.getQPath().getAsString());
+ throw new RepositoryException("FATAL Property data is null. Parent " + parent.getQPath().getAsString());
}
childs.add(propData);
@@ -293,15 +304,31 @@
if (childNode != null)
{
String nodeId = (String)childNode.get(ITEM_ID);
- Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
- Object itemData = node.get(ITEM_DATA);
- if (itemData != null)
+ if (nodeId != null)
{
- return (NodeData)itemData;
+ Node<Serializable, Object> node = nodesRoot.getChild(makeNodeFqn(nodeId));
+ if (node != null)
+ {
+ Object itemData = node.get(ITEM_DATA);
+ if (itemData != null)
+ {
+ return (NodeData)itemData;
+ }
+ else
+ {
+ throw new RepositoryException("FATAL NodeData empty " + parentData.getQPath()
+ + name.getAsString(true));
+ }
+ }
+ else
+ {
+ throw new RepositoryException("FATAL Node record not found (" + name.getAsString(true)
+ + "), but listed in childs of " + parentData.getQPath());
+ }
}
else
{
- throw new RepositoryException("FATAL NodeData empty " + parentData.getQPath() + name.getAsString(true));
+ throw new RepositoryException("FATAL Node Id empty " + parentData.getQPath() + name.getAsString(true));
}
}
else
@@ -314,14 +341,31 @@
String propId = (String)parent.get(name.getAsString(false));
if (propId != null)
{
- return (PropertyData)propsRoot.get(makePropFqn(propId));
+ Node<Serializable, Object> prop = propsRoot.getChild(makePropFqn(propId));
+ if (prop != null)
+ {
+ Object itemData = prop.get(ITEM_DATA);
+ if (itemData != null)
+ {
+ return (PropertyData)itemData;
+ }
+ else
+ {
+ throw new RepositoryException("FATAL PropertyData empty " + parentData.getQPath()
+ + name.getAsString(true));
+ }
+ }
+ else
+ {
+ throw new RepositoryException("FATAL Property record not found(" + name.getAsString(true)
+ + "), but listed in proprties of " + parentData.getQPath().getAsString());
+ }
}
}
else
{
- // TODO validation of ParentNotFound for Property
- throw new RepositoryException("Parent not found " + parentData.getIdentifier() + ", "
- + parentData.getQPath().getAsString());
+ throw new RepositoryException("FATAL Parent not found " + parentData.getQPath().getAsString() + " for "
+ + name.getAsString(true));
}
}
@@ -404,38 +448,20 @@
throw new InvalidItemStateException("Node was updated previously or removed " + data.getQPath().getAsString());
}
- QPath prevPath;
-
- Object itemData = node.get(ITEM_DATA);
- if (itemData == null)
- {
- throw new RepositoryException("FATAL NodeData empty " + node.getFqn());
- }
-
- if (itemData instanceof NodeData)
- {
- prevPath = ((NodeData)itemData).getQPath();
- }
- else
- {
- throw new RepositoryException("FATAL Node data is not NodeData " + node.getFqn());
- }
-
if (data.getParentIdentifier() != null)
{
// check if parent is cached
Node<Serializable, Object> parent = nodesRoot.getChild(makeNodeFqn(data.getParentIdentifier()));
if (parent == null)
{
- throw new RepositoryException("Node parent doesn't exist " + data.getQPath().getAsString());
+ throw new RepositoryException("FATAL Node's parent not found " + data.getQPath().getAsString());
}
- // update child on Parent (remove prev, add new)
+ // update child on Parent
+ // TODO (wrong logic) get previously cached NodeData and using its name remove child on the parent
+ //boolean removed =
+ // parent.removeChild(makeChildNodeFqn(prevPath.getEntries()[prevPath.getEntries().length - 1]));
- // get previously cached NodeData and using its name remove child on the parent
- boolean removed =
- parent.removeChild(makeChildNodeFqn(prevPath.getEntries()[prevPath.getEntries().length - 1]));
-
Node<Serializable, Object> childNode =
parent.addChild(makeChildNodeFqn(data.getQPath().getEntries()[data.getQPath().getEntries().length - 1]));
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-09 13:04:57 UTC (rev 508)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-09 14:04:45 UTC (rev 509)
@@ -54,7 +54,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import java.io.IOException;
import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
import java.util.List;
/**
@@ -90,16 +92,16 @@
cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
+ // run cache
+ cache.create();
+ cache.start();
+
Node<Serializable, Object> cacheRoot = cache.getRoot();
// prepare cache structures
nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
- // run cache
- cache.create();
- cache.start();
-
// JCR connection
conn = new JBossCacheStorageConnection(cache, nodes, props);
}
@@ -150,13 +152,39 @@
assertEquals("Node path wrong", nodePath, data.getQPath());
}
+ private void checkProp(String propId, QPath propPath, Object propValue) throws UnsupportedEncodingException,
+ IllegalStateException, IOException
+ {
+ Node<Serializable, Object> prop = props.getChild(Fqn.fromElements(propId));
+ Object dataObject = prop.get(JBossCacheStorage.ITEM_DATA);
+ assertNotNull("Property item data should exists", dataObject);
+ assertTrue("Property item data is not a Property", dataObject instanceof PropertyData);
+
+ PropertyData propData = (PropertyData)dataObject;
+ assertEquals("Property id wrong", propId, propData.getIdentifier());
+ assertEquals("Property path wrong", propPath, propData.getQPath());
+ assertEquals("Property Value wrong", propValue, new String(propData.getValues().get(0).getAsByteArray(),
+ Constants.DEFAULT_ENCODING));
+ }
+
+ private void checkChildProp(Node<Serializable, Object> node, InternalQName propName, String propId, QPath propPath,
+ Object propValue) throws UnsupportedEncodingException, IllegalStateException, IOException
+ {
+ String pid = (String)node.get(propName.getAsString());
+
+ assertNotNull("Property ID should exists", pid);
+ assertEquals("Property ID wrong", propId, pid);
+
+ checkProp(propId, propPath, propValue);
+ }
+
private void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath)
{
- checkChildNode(rootNode, childId, childPath, null, null);
+ checkChildNode(rootNode, childId, childPath, -1, -1);
}
- private void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath, Integer orderNum,
- Integer version)
+ private void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath, int orderNum,
+ int version)
{
Node<Serializable, Object> childNode =
rootNode.getChild(Fqn
@@ -164,7 +192,7 @@
assertNotNull("Child Node should exists", childNode);
String childNodeId = (String)childNode.get(JBossCacheStorage.ITEM_ID);
- Node<Serializable, Object> node = props.getChild(Fqn.fromElements(childNodeId));
+ Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(childNodeId));
assertNotNull("Node by ID should exists", node);
Object childNodeObject = node.get(JBossCacheStorage.ITEM_DATA);
@@ -173,14 +201,14 @@
assertEquals("Node id wrong", childId, childNodeData.getIdentifier());
assertEquals("Node path wrong", childPath, childNodeData.getQPath());
- if (orderNum != null)
+ if (orderNum >= 0)
{
- //assertEquals("Node order number wrong", orderNum, childNodeData.getOrderNumber());
+ assertEquals("Node order number wrong", orderNum, childNodeData.getOrderNumber());
}
- if (version != null)
+ if (version >= 0)
{
- //assertEquals("Node persisted version wrong", version, childNodeData.getPersistedVersion());
+ assertEquals("Node persisted version wrong", version, childNodeData.getPersistedVersion());
}
}
@@ -238,21 +266,16 @@
propData2.setValue(new TransientValueData(propValue2));
conn.add(propData2);
- // check in nodes
- treePrint(nodes);
+ // check in props
+ treePrint(props);
Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
- String pid1 = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
- assertNotNull("Property ID should exists", pid1);
- assertEquals("Property ID wrong", propId1, pid1);
-
- String pid2 = (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsString());
- assertNotNull("Property ID should exists", pid2);
- assertEquals("Property ID wrong", propId2, pid2);
-
+ checkChildProp(rootNode, Constants.JCR_PRIMARYTYPE, propId1, propPath1, propValue1);
+ checkChildProp(rootNode, Constants.JCR_MIXINTYPES, propId2, propPath2, propValue2);
+
// TODO check order
int index = 0;
for (Serializable key : rootNode.getKeys())
@@ -260,31 +283,6 @@
//System.out.println(key);
//index++;
}
-
- // check in props
- treePrint(props);
-
- Node<Serializable, Object> itemsProp1 = props.getChild(Fqn.fromElements(propId1));
- Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
- PropertyData data1 = (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValue1, new String(data1.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
-
- Node<Serializable, Object> itemsProp2 = props.getChild(Fqn.fromElements(propId2));
- Object data2Object = itemsProp2.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data2Object);
- assertTrue("Property item data is not a Property", data2Object instanceof PropertyData);
-
- PropertyData data2 = (PropertyData)data2Object;
- assertEquals("Property id wrong", propId2, data2.getIdentifier());
- assertEquals("Property path wrong", propPath2, data2.getQPath());
- assertEquals("Property Value wrong", propValue2, new String(data2.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
}
public void testDeleteNode() throws Exception
@@ -437,45 +435,45 @@
checkChildNode(rootNode, node2id, node1path);
checkChildNode(rootNode, node3id, node3path);
-// Node<Serializable, Object> childNode1 =
-// rootNode.getChild(Fqn
-// .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
-//
-// assertNotNull("Child Node should exists", childNode1);
-// String childNode1id = (String)childNode1.get(JBossCacheStorage.ITEM_ID);
-// Node<Serializable, Object> node1 = props.getChild(Fqn.fromElements(childNode1id));
-// assertNotNull("Node by ID should exists", node1);
-//
-// Object childNode1Object = node1.get(JBossCacheStorage.ITEM_DATA);
-// assertTrue("Node item data is not a Node", childNode1Object instanceof NodeData);
-// assertEquals("Node id wrong", node2id, ((NodeData)childNode1Object).getIdentifier());
-// assertEquals("Node path wrong", node2path, ((NodeData)childNode1Object).getQPath());
-//
-// // get /snsNode:2 from childs of root /
-// Node<Serializable, Object> childNode2 =
-// rootNode.getChild(Fqn
-// .fromElements(node2path.getEntries()[node2path.getEntries().length - 1].getAsString(true)));
-//
-// assertNotNull("Child Node should exists", childNode2);
-// String childNode2id = (String)childNode2.get(JBossCacheStorage.ITEM_ID);
-// Node<Serializable, Object> node2 = props.getChild(Fqn.fromElements(childNode2id));
-// assertNotNull("Node by ID should exists", node2);
-//
-// Object childNode1Object = node1.get(JBossCacheStorage.ITEM_DATA);
-// assertTrue("Node item data is not a Node", childNode1Object instanceof NodeData);
-// assertEquals("Node id wrong", node2id, ((NodeData)childNode1Object).getIdentifier());
-// assertEquals("Node path wrong", node2path, ((NodeData)childNode1Object).getQPath());
-//
-// assertEquals("Child expected", 3, rootNode.getChildren().size());
-//
-// Node<Serializable, Object> itemNode = nodes.getChild(Fqn.fromElements(node1id));
-// assertNotNull("Node item data should exists", itemNode);
-//
-// Object dataObject = itemNode.get(JBossCacheStorageConnection.ITEM_DATA);
-// assertTrue("Node item data should be a NodeData", dataObject instanceof NodeData);
-// assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIdentifier());
-// assertEquals("Node path wrong", node1path, ((NodeData)dataObject).getQPath());
-// assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)dataObject).getOrderNumber());
+ // Node<Serializable, Object> childNode1 =
+ // rootNode.getChild(Fqn
+ // .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
+ //
+ // assertNotNull("Child Node should exists", childNode1);
+ // String childNode1id = (String)childNode1.get(JBossCacheStorage.ITEM_ID);
+ // Node<Serializable, Object> node1 = props.getChild(Fqn.fromElements(childNode1id));
+ // assertNotNull("Node by ID should exists", node1);
+ //
+ // Object childNode1Object = node1.get(JBossCacheStorage.ITEM_DATA);
+ // assertTrue("Node item data is not a Node", childNode1Object instanceof NodeData);
+ // assertEquals("Node id wrong", node2id, ((NodeData)childNode1Object).getIdentifier());
+ // assertEquals("Node path wrong", node2path, ((NodeData)childNode1Object).getQPath());
+ //
+ // // get /snsNode:2 from childs of root /
+ // Node<Serializable, Object> childNode2 =
+ // rootNode.getChild(Fqn
+ // .fromElements(node2path.getEntries()[node2path.getEntries().length - 1].getAsString(true)));
+ //
+ // assertNotNull("Child Node should exists", childNode2);
+ // String childNode2id = (String)childNode2.get(JBossCacheStorage.ITEM_ID);
+ // Node<Serializable, Object> node2 = props.getChild(Fqn.fromElements(childNode2id));
+ // assertNotNull("Node by ID should exists", node2);
+ //
+ // Object childNode1Object = node1.get(JBossCacheStorage.ITEM_DATA);
+ // assertTrue("Node item data is not a Node", childNode1Object instanceof NodeData);
+ // assertEquals("Node id wrong", node2id, ((NodeData)childNode1Object).getIdentifier());
+ // assertEquals("Node path wrong", node2path, ((NodeData)childNode1Object).getQPath());
+ //
+ // assertEquals("Child expected", 3, rootNode.getChildren().size());
+ //
+ // Node<Serializable, Object> itemNode = nodes.getChild(Fqn.fromElements(node1id));
+ // assertNotNull("Node item data should exists", itemNode);
+ //
+ // Object dataObject = itemNode.get(JBossCacheStorageConnection.ITEM_DATA);
+ // assertTrue("Node item data should be a NodeData", dataObject instanceof NodeData);
+ // assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIdentifier());
+ // assertEquals("Node path wrong", node1path, ((NodeData)dataObject).getQPath());
+ // assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)dataObject).getOrderNumber());
}
public void testUpdateProperty() throws Exception
@@ -498,29 +496,14 @@
propDataU.setValue(new TransientValueData(propValueU));
conn.update(propDataU);
- // check in tree
- treePrint(nodes);
-
+ // check
+ treePrint(props);
+
Node<Serializable, Object> rootNode = nodes.getChild(Fqn.fromElements(Constants.ROOT_UUID));
assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size());
-
- String pid = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
- assertEquals("Property ID wrong", propId1, pid);
-
- // check in items
- treePrint(nodes);
-
- Node<Serializable, Object> itemsProp1 = props.getChild(Fqn.fromElements(propId1));
- Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
- PropertyData data1 = (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValueU, new String(data1.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
+
+ checkChildProp(rootNode, Constants.JCR_PRIMARYTYPE, propId1, propPath1, propValueU);
}
public void testGetNodeByName() throws Exception
@@ -569,6 +552,9 @@
conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
// check
+ treePrint(props);
+
+ // check
ItemData propItem =
conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
new InternalQName[0], 0, null, new AccessControlList()),
@@ -629,7 +615,7 @@
assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
}
- public void _testGetChildNodes() throws Exception
+ public void testGetChildNodes() throws Exception
{
// TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
@@ -672,7 +658,7 @@
}
}
- public void _testGetChildProperties() throws Exception
+ public void testGetChildProperties() throws Exception
{
// TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
// add root (/)
@@ -703,6 +689,7 @@
// check
treePrint(nodes);
+ treePrint(props);
List<PropertyData> childs =
conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
16 years, 8 months
exo-jcr SVN: r508 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-11-09 08:04:57 -0500 (Mon, 09 Nov 2009)
New Revision: 508
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java
Log:
EXOJCR-202: IndexerCacheLoader updated
Modified: 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 2009-11-09 12:19:15 UTC (rev 507)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/cacheloader/IndexerCacheLoader.java 2009-11-09 13:04:57 UTC (rev 508)
@@ -19,6 +19,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
+import org.exoplatform.services.jcr.impl.storage.jbosscache.JBossCacheStorage;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.CacheException;
@@ -58,21 +59,27 @@
searchManager = manager;
}
- private String parseUUID(Fqn fqn)
+ private String parseUUID(Fqn<String> fqn)
{
- // TODO check is zero element not ROOT
- // get just uuid
- Fqn uuid = (Fqn)fqn.get(1);
- //remove slash
- return uuid.toString().substring(1);
+ if (fqn.size() > 1)
+ {
+
+ // get only uuid
+ String uuid = (String)fqn.get(1);
+ //remove slash
+ return uuid;
+ }
+ else
+ {
+ return null;
+ }
}
- private boolean isNode(Fqn fqn)
+ private boolean isNode(Fqn<String> fqn)
{
- Fqn items = (Fqn)fqn.get(0);
+ String items = (String)fqn.get(0);
String s = items.toString();
- //TODO check Constants
- return s.equals("/$NODES");
+ return s.equals(JBossCacheStorage.NODES);
}
@Override
@@ -92,81 +99,84 @@
String uuid = parseUUID(m.getFqn());
- switch (m.getType())
+ if (uuid != null)
{
- case PUT_DATA :
- // add node
- // TODO do we need there update for property?
- // if this is property ignore
- if (isNode(m.getFqn()))
- {
- addedNodes.add(uuid);
- }
+ switch (m.getType())
+ {
+ case PUT_DATA :
+ // add node
+ // TODO do we need there update for property?
+ // if this is property ignore
+ if (isNode(m.getFqn()))
+ {
+ addedNodes.add(uuid);
+ }
- break;
- case PUT_DATA_ERASE :
- // must be never called
- // update node
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
- break;
- case PUT_KEY_VALUE :
- // must be never called
- // update node
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
- break;
- case REMOVE_DATA :
- // must be never called
- // update node
- if (isNode(m.getFqn()))
- {
- addedNodes.add(uuid);
- removedNodes.add(uuid);
- }
- break;
- case REMOVE_KEY_VALUE :
- // must be never called
- // removed property what to do
- if (isNode(m.getFqn()))
- {
- addedNodes.add(uuid);
- removedNodes.add(uuid);
- }
- break;
- case REMOVE_NODE :
- // if node - remove it, otherwise ignore it
- if (isNode(m.getFqn()))
- {
- removedNodes.add(uuid);
- }
+ break;
+ case PUT_DATA_ERASE :
+ // must be never called
+ // update node
+ if (isNode(m.getFqn()))
+ {
+ removedNodes.add(uuid);
+ addedNodes.add(uuid);
+ }
+ break;
+ case PUT_KEY_VALUE :
+ // must be never called
+ // update node
+ if (isNode(m.getFqn()))
+ {
+ removedNodes.add(uuid);
+ addedNodes.add(uuid);
+ }
+ break;
+ case REMOVE_DATA :
+ // must be never called
+ // update node
+ if (isNode(m.getFqn()))
+ {
+ addedNodes.add(uuid);
+ removedNodes.add(uuid);
+ }
+ break;
+ case REMOVE_KEY_VALUE :
+ // must be never called
+ // removed property what to do
+ if (isNode(m.getFqn()))
+ {
+ addedNodes.add(uuid);
+ removedNodes.add(uuid);
+ }
+ break;
+ case REMOVE_NODE :
+ // if node - remove it, otherwise ignore it
+ if (isNode(m.getFqn()))
+ {
+ removedNodes.add(uuid);
+ }
- break;
- case MOVE :
- // involve moving all children too
- move(m.getFqn(), m.getFqn2());
- if (isNode(m.getFqn()))
- {
- //remove first
- removedNodes.add(parseUUID(m.getFqn()));
- //add second
- addedNodes.add(parseUUID(m.getFqn2()));
- }
- else
- {
- // must be never happen
- // TODO update both nodes
- }
+ break;
+ case MOVE :
+ // involve moving all children too
+ move(m.getFqn(), m.getFqn2());
+ if (isNode(m.getFqn()))
+ {
+ //remove first
+ removedNodes.add(parseUUID(m.getFqn()));
+ //add second
+ addedNodes.add(parseUUID(m.getFqn2()));
+ }
+ else
+ {
+ // must be never happen
+ // TODO update both nodes
+ }
- break;
- default :
- throw new CacheException("Unknown modification " + m.getType());
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
}
}
16 years, 8 months
exo-jcr SVN: r507 - 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: skabashnyuk
Date: 2009-11-09 07:19:15 -0500 (Mon, 09 Nov 2009)
New Revision: 507
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
Log:
EXOJCR-202 : sort members
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-09 12:16:49 UTC (rev 506)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-09 12:19:15 UTC (rev 507)
@@ -55,6 +55,37 @@
private FakeSearchManager manager;
+ public void testAddNode() throws Exception
+ {
+
+ }
+
+ public void testAddRoot() throws Exception
+ {
+ // add root (/)
+ jBossCacheStorageConnection.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, null, new AccessControlList()));
+ jBossCacheStorageConnection.commit();
+
+ assertTrue(manager.getRemovedNodes().isEmpty());
+ assertFalse(manager.getAddedNodes().isEmpty());
+
+ }
+
+ /**
+ * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractCacheLoaderTest#createIndividualCacheLoaderConfig()
+ */
+ @Override
+ protected IndividualCacheLoaderConfig createIndividualCacheLoaderConfig()
+ {
+ IndividualCacheLoaderConfig individualCacheLoaderConfig = new IndividualCacheLoaderConfig();
+ loader = new IndexerCacheLoader();
+ manager = new FakeSearchManager();
+ loader.registerSearchManager(manager);
+ individualCacheLoaderConfig.setCacheLoader(loader);
+ return individualCacheLoaderConfig;
+ }
+
class FakeSearchManager implements SearchManager
{
@@ -74,6 +105,11 @@
return null;
}
+ public Set<String> getAddedNodes()
+ {
+ return addedNodes;
+ }
+
public Set<String> getFieldNames() throws IndexException
{
return null;
@@ -94,49 +130,18 @@
return null;
}
- public void updateIndex(Set<String> removedNodes, Set<String> addedNodes) throws RepositoryException, IOException
- {
- this.removedNodes = removedNodes;
- this.addedNodes = addedNodes;
- }
-
public Set<String> getRemovedNodes()
{
return removedNodes;
}
- public Set<String> getAddedNodes()
+ public void updateIndex(Set<String> removedNodes, Set<String> addedNodes) throws RepositoryException, IOException
{
- return addedNodes;
+ this.removedNodes = removedNodes;
+ this.addedNodes = addedNodes;
}
}
- public void testAddRoot() throws Exception
- {
- // add root (/)
- jBossCacheStorageConnection.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
- Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, null, new AccessControlList()));
- jBossCacheStorageConnection.commit();
-
- assertTrue(manager.getRemovedNodes().isEmpty());
- assertFalse(manager.getAddedNodes().isEmpty());
-
- }
-
- /**
- * @see org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractCacheLoaderTest#createIndividualCacheLoaderConfig()
- */
- @Override
- protected IndividualCacheLoaderConfig createIndividualCacheLoaderConfig()
- {
- IndividualCacheLoaderConfig individualCacheLoaderConfig = new IndividualCacheLoaderConfig();
- loader = new IndexerCacheLoader();
- manager = new FakeSearchManager();
- loader.registerSearchManager(manager);
- individualCacheLoaderConfig.setCacheLoader(loader);
- return individualCacheLoaderConfig;
- }
-
private class DummyCacheLoader extends AbstractWriteOnlyCacheLoader
{
@@ -149,11 +154,5 @@
log.info("put:" + modifications);
}
-
}
-
- public void testAddNode() throws Exception
- {
-
- }
}
16 years, 8 months
exo-jcr SVN: r506 - 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: sergiykarpenko
Date: 2009-11-09 07:16:49 -0500 (Mon, 09 Nov 2009)
New Revision: 506
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
Log:
EXOJCR-202: IndexerCacheLoaderTest updated
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-09 11:37:43 UTC (rev 505)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-09 12:16:49 UTC (rev 506)
@@ -21,14 +21,27 @@
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.core.query.IndexException;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
+import org.exoplatform.services.jcr.impl.core.query.SearchManager;
+import org.exoplatform.services.jcr.impl.core.query.cacheloader.IndexerCacheLoader;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import java.io.IOException;
import java.util.List;
+import java.util.Set;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.Query;
+
/**
* @author <a href="mailto:Sergey.Kabashnyuk@exoplatform.org">Sergey Kabashnyuk</a>
* @version $Id: exo-jboss-codetemplates.xml 34360 2009-07-22 23:58:59Z ksm $
@@ -38,12 +51,76 @@
{
private final Log log = ExoLogger.getLogger(IndexerCacheLoaderTest.class.getName());
+ private IndexerCacheLoader loader;
+
+ private FakeSearchManager manager;
+
+ class FakeSearchManager implements SearchManager
+ {
+
+ private Set<String> removedNodes;
+
+ private Set<String> addedNodes;
+
+ public Query createQuery(SessionImpl session, SessionDataManager sessionDataManager, Node node)
+ throws InvalidQueryException, RepositoryException
+ {
+ return null;
+ }
+
+ public Query createQuery(SessionImpl session, SessionDataManager sessionDataManager, String statement,
+ String language) throws InvalidQueryException, RepositoryException
+ {
+ return null;
+ }
+
+ public Set<String> getFieldNames() throws IndexException
+ {
+ return null;
+ }
+
+ public QueryHandler getHandler()
+ {
+ return null;
+ }
+
+ public Set<String> getNodesByNodeType(InternalQName nodeType) throws RepositoryException
+ {
+ return null;
+ }
+
+ public Set<String> getNodesByUri(String uri) throws RepositoryException
+ {
+ return null;
+ }
+
+ public void updateIndex(Set<String> removedNodes, Set<String> addedNodes) throws RepositoryException, IOException
+ {
+ this.removedNodes = removedNodes;
+ this.addedNodes = addedNodes;
+ }
+
+ public Set<String> getRemovedNodes()
+ {
+ return removedNodes;
+ }
+
+ public Set<String> getAddedNodes()
+ {
+ return addedNodes;
+ }
+ }
+
public void testAddRoot() throws Exception
{
// add root (/)
jBossCacheStorageConnection.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, null, new AccessControlList()));
jBossCacheStorageConnection.commit();
+
+ assertTrue(manager.getRemovedNodes().isEmpty());
+ assertFalse(manager.getAddedNodes().isEmpty());
+
}
/**
@@ -53,7 +130,10 @@
protected IndividualCacheLoaderConfig createIndividualCacheLoaderConfig()
{
IndividualCacheLoaderConfig individualCacheLoaderConfig = new IndividualCacheLoaderConfig();
- individualCacheLoaderConfig.setCacheLoader(new DummyCacheLoader());
+ loader = new IndexerCacheLoader();
+ manager = new FakeSearchManager();
+ loader.registerSearchManager(manager);
+ individualCacheLoaderConfig.setCacheLoader(loader);
return individualCacheLoaderConfig;
}
@@ -71,4 +151,9 @@
}
}
+
+ public void testAddNode() throws Exception
+ {
+
+ }
}
16 years, 8 months