exo-jcr SVN: r617 - 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-12 11:32:27 -0500 (Thu, 12 Nov 2009)
New Revision: 617
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 for JDBC loader
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-12 16:31:23 UTC (rev 616)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 16:32:27 UTC (rev 617)
@@ -390,7 +390,7 @@
// prepare
String nodeId = IdGenerator.generate();
- QPath nodePath = QPath.parse("[]node:1");
+ QPath nodePath = QPath.parse("[]:1[]node:1");
NodeData node =
new TransientNodeData(nodePath, nodeId, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
Constants.ROOT_PARENT_UUID, new AccessControlList());
@@ -561,11 +561,11 @@
NodeData srcNodeData = (NodeData)conn.getItemData(nodeId);
- Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + nodeId));
+ Map<Object, Object> attributes = loader.get(Fqn.fromElements(JBossCacheStorage.NODES, nodeId));
- assertNotNull(attrebutes);
+ assertNotNull(attributes);
- NodeData destNodeData = (NodeData)attrebutes.get(JBossCacheStorage.ITEM_DATA);
+ NodeData destNodeData = (NodeData)attributes.get(JBossCacheStorage.ITEM_DATA);
assertNotNull(destNodeData);
assertEquals(srcNodeData.getIdentifier(), destNodeData.getIdentifier());
16 years, 8 months
exo-jcr SVN: r616 - 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-12 11:31:23 -0500 (Thu, 12 Nov 2009)
New Revision: 616
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 JDBCCacheLoaderTest 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-12 16:30:44 UTC (rev 615)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 16:31:23 UTC (rev 616)
@@ -580,9 +580,21 @@
{
// prepare
-
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+
+ String nodeId = IdGenerator.generate();
+ addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED);
+ conn.commit();
+
// tests it
-
+ Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID + "/" + "[]node:1"));
+
+ assertNotNull(attrebutes);
+
+ String destNodeId = (String) attrebutes.get(JBossCacheStorage.ITEM_ID);
+
+ assertNotNull(destNodeId);
+ assertEquals(nodeId, destNodeId);
}
public void testGetPropertyByIdentifier() throws Exception
16 years, 8 months
exo-jcr SVN: r615 - 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-12 11:30:44 -0500 (Thu, 12 Nov 2009)
New Revision: 615
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
Log:
EXOJCR-202: IndexerCacheLoaderRuntimeTest test updated
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-12 16:28:45 UTC (rev 614)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-12 16:30:44 UTC (rev 615)
@@ -41,6 +41,7 @@
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.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
@@ -257,37 +258,97 @@
}
- // public void testAddProperty() throws Exception
- // {
- // // prepare
- // TransientPropertyData propData =
- // createProperty(Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE", false);
- //
- // List<Modification> modifications = new ArrayList<Modification>();
- //
- // modifications.addAll(addProperty(propData));
- //
- // loader.put(modifications);
- //
- // // tests it
- // WorkspaceStorageConnection connection = persistentContainer.openConnection();
- //
- // PropertyData destPropData = (PropertyData)connection.getItemData(propData.getIdentifier());
- //
- // assertNotNull(destPropData);
- // assertEquals(propData.getIdentifier(), destPropData.getIdentifier());
- // assertEquals(propData.getParentIdentifier(), destPropData.getParentIdentifier());
- // assertEquals(propData.getPersistedVersion(), destPropData.getPersistedVersion());
- // assertEquals(propData.getType(), destPropData.getType());
- // assertEquals(propData.getQPath(), destPropData.getQPath());
- // assertEquals(propData.getValues().size(), destPropData.getValues().size());
- // assertEquals(1, destPropData.getValues().size());
- //
- // ValueData valueData = destPropData.getValues().get(0);
- // assertEquals("JCR DATA VALUE", new String(valueData.getAsByteArray(), "UTF-8"));
- //
- // }
+ public void testUpdateAddProperty() throws Exception
+ {
+ List<Modification> modifications = new ArrayList<Modification>();
+
+ // prepare add node to storage
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+
+ String node1id = IdGenerator.generate();
+ QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
+
+ // add node (/) with jcr:primaryType
+ NodeData nodeData =
+ new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList());
+ conn.add(nodeData);
+ modifications.addAll(this.addNode(nodeData));
+
+ // add property (/jcr:primaryType)
+ TransientPropertyData propData =
+ createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
+ conn.add(propData);
+ modifications.addAll(this.addProperty(propData));
+
+ conn.commit();
+ loader.put(modifications);
+
+ // check do we really have node and its property
+ conn = persistentContainer.openConnection();
+ NodeData nd = (NodeData)conn.getItemData(node1id);
+ assertNotNull(nd);
+ assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
+
+ PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
+ assertNotNull(pd);
+ assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
+
+ // find node by search engine
+ SearchIndex index = ((SearchIndex)manager.getHandler());
+ IndexReader reader = index.getIndexReader();
+
+ IndexSearcher searcher = new IndexSearcher(reader);
+
+ Query query = new TermQuery(new Term("_:UUID", node1id));
+ Hits hit = searcher.search(query);
+ assertEquals(1, hit.length());
+
+ modifications.clear();
+ // prepare
+ TransientPropertyData newPropData =
+ createProperty(node1path, node1id, new InternalQName(Constants.NS_DEFAULT_URI, "myProp"), "JCR DATA VALUE",
+ false);
+
+ conn = persistentContainer.openConnection();
+ conn.add(newPropData);
+ modifications.addAll(addProperty(newPropData));
+ conn.commit();
+
+ loader.put(modifications);
+
+ // tests it
+ WorkspaceStorageConnection connection = persistentContainer.openConnection();
+
+ PropertyData destPropData = (PropertyData)connection.getItemData(newPropData.getIdentifier());
+
+ assertNotNull(destPropData);
+ assertEquals(newPropData.getIdentifier(), destPropData.getIdentifier());
+ assertEquals(newPropData.getParentIdentifier(), destPropData.getParentIdentifier());
+ assertEquals(newPropData.getPersistedVersion(), destPropData.getPersistedVersion());
+ assertEquals(newPropData.getType(), destPropData.getType());
+ assertEquals(newPropData.getQPath(), destPropData.getQPath());
+ assertEquals(newPropData.getValues().size(), destPropData.getValues().size());
+ assertEquals(1, destPropData.getValues().size());
+
+ ValueData valueData = destPropData.getValues().get(0);
+ assertEquals("JCR DATA VALUE", new String(valueData.getAsByteArray(), "UTF-8"));
+
+ reader = index.getIndexReader();
+
+ searcher = new IndexSearcher(reader);
+
+ query = new TermQuery(new Term("_:UUID", node1id));
+ hit = searcher.search(query);
+ assertEquals(1, hit.length());
+
+ query = new TermQuery(new Term("FULL:myProp", "data"));
+ hit = searcher.search(query);
+ assertEquals(1, hit.length());
+
+ }
+
/**
* Add Property to the connection but doesn't save it.
*
16 years, 8 months
exo-jcr SVN: r614 - 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-12 11:28:45 -0500 (Thu, 12 Nov 2009)
New Revision: 614
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 for JDBC loader: fix of helpers
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-12 16:18:40 UTC (rev 613)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 16:28:45 UTC (rev 614)
@@ -18,19 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-
import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
import org.exoplatform.services.jcr.access.AccessControlList;
@@ -45,7 +32,6 @@
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.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
@@ -59,6 +45,19 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
/**
* @author <a href="mailto:reshetnyak.alex@gmail.com">Alex Reshetnyak</a>
* @version $Id$
@@ -281,7 +280,8 @@
* @param primaryType InternalQName
* @throws Exception
*/
- private void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType) throws Exception
+ private void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType)
+ throws Exception
{
// add root (/)
conn.add(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, null,
@@ -292,30 +292,6 @@
}
/**
- * Create Node to the connection but doesn't save it.
- *
- * @param path QPath
- * @param nodeId String
- * @param primaryType InternalQName
- * @param mixinTypeNames InternalQName
- * @throws Exception
- */
- private List<ItemData> createNode(QPath path, String nodeId, InternalQName primaryType,
- InternalQName[] mixinTypeNames) throws Exception
- {
- List<ItemData> list = new ArrayList<ItemData>();
-
- // add node
- list.add(new TransientNodeData(path, nodeId, 1, primaryType, (mixinTypeNames == null ? new InternalQName[0]
- : null), 0, null, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- list.add(createProperty(path, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false));
-
- return list;
- }
-
- /**
* Add Property to the connection but doesn't save it.
*
* @param conn WorkspaceStorageConnection
@@ -356,9 +332,9 @@
List<Object> values = new ArrayList<Object>();
if (multiValued)
{
- if (propertyValue instanceof List)
+ if (propertyValue instanceof List<?>)
{
- values.addAll((List<Object>)propertyValue);
+ values.addAll((List<?>)propertyValue);
}
else
throw new Exception("propertyValue should be a List");
@@ -413,34 +389,33 @@
{
// prepare
String nodeId = IdGenerator.generate();
- List<ItemData> list =
- createNode(QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
- Constants.NT_UNSTRUCTURED, null);
- List<Modification> modifications = new ArrayList<Modification>();
+ QPath nodePath = QPath.parse("[]node:1");
+ NodeData node =
+ new TransientNodeData(nodePath, nodeId, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_PARENT_UUID, new AccessControlList());
- for (ItemData itemData : list)
- if (itemData instanceof NodeData)
- modifications.addAll(addNode((NodeData)itemData));
- else
- modifications.addAll(addProperty((PropertyData)itemData));
+ PropertyData primaryType =
+ createProperty(nodePath, nodeId, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
+ List<Modification> modifications = new ArrayList<Modification>();
+ modifications.addAll(addNode(node));
+ modifications.addAll(addProperty(primaryType));
+
loader.put(modifications);
// tests it
- NodeData srcNodeData = (NodeData)list.get(0);
-
WorkspaceStorageConnection conn = persistentContainer.openConnection();
NodeData destNodeData = (NodeData)conn.getItemData(nodeId);
assertNotNull(destNodeData);
- assertEquals(srcNodeData.getIdentifier(), destNodeData.getIdentifier());
- assertEquals(srcNodeData.getOrderNumber(), destNodeData.getOrderNumber());
- assertEquals(srcNodeData.getParentIdentifier(), destNodeData.getParentIdentifier());
- assertEquals(srcNodeData.getPersistedVersion(), destNodeData.getPersistedVersion());
- assertEquals(srcNodeData.getQPath().getAsString(), destNodeData.getQPath().getAsString());
- assertEquals(srcNodeData.getPrimaryTypeName().getAsString(), destNodeData.getPrimaryTypeName().getAsString());
+ assertEquals(node.getIdentifier(), destNodeData.getIdentifier());
+ assertEquals(node.getOrderNumber(), destNodeData.getOrderNumber());
+ assertEquals(node.getParentIdentifier(), destNodeData.getParentIdentifier());
+ assertEquals(node.getPersistedVersion(), destNodeData.getPersistedVersion());
+ assertEquals(node.getQPath().getAsString(), destNodeData.getQPath().getAsString());
+ assertEquals(node.getPrimaryTypeName().getAsString(), destNodeData.getPrimaryTypeName().getAsString());
}
public void testAddProperty() throws Exception
16 years, 8 months
exo-jcr SVN: r613 - 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-12 11:18:40 -0500 (Thu, 12 Nov 2009)
New Revision: 613
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 for JDBC loader
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-12 16:07:40 UTC (rev 612)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 16:18:40 UTC (rev 613)
@@ -83,23 +83,18 @@
loader = new JDBCCacheLoader();
loader.injectDependencies(persistentContainer);
-
+
initJCRRoot();
}
-
-
@Override
protected void tearDown() throws Exception
{
// delete all in DB
-
-
+
super.tearDown();
}
-
-
protected void initPersistence() throws Exception
{
// Create WorkspaceEntry
@@ -180,36 +175,36 @@
containerEntry.setValueStorages(list);
}
-
+
WorkspaceEntry workspaceEntry =
new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
workspaceEntry.setContainer(containerEntry);
-// // Indexer
-// ArrayList qParams = new ArrayList();
-// qParams.add(new SimpleParameterEntry("indexDir", "../temp/index/" + IdGenerator.generate()));
-// QueryHandlerEntry qEntry =
-// new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
-// workspaceEntry.setQueryHandler(qEntry);
-//
-// // cache
-// ArrayList cacheParams = new ArrayList();
-// cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
-// cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
-// CacheEntry cacheEntry = new CacheEntry(cacheParams);
-// cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
-// workspaceEntry.setCache(cacheEntry);
-//
-// // lock
-// LockManagerEntry lockManagerEntry = new LockManagerEntry();
-// lockManagerEntry.setTimeout(900000);
-// LockPersisterEntry persisterEntry = new LockPersisterEntry();
-// persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
-// ArrayList lpParams = new ArrayList();
-// lpParams.add(new SimpleParameterEntry("path", "../temp/lock"));
-// persisterEntry.setParameters(lpParams);
-// lockManagerEntry.setPersister(persisterEntry);
-// workspaceEntry.setLockManager(lockManagerEntry);
+ // // Indexer
+ // ArrayList qParams = new ArrayList();
+ // qParams.add(new SimpleParameterEntry("indexDir", "../temp/index/" + IdGenerator.generate()));
+ // QueryHandlerEntry qEntry =
+ // new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
+ // workspaceEntry.setQueryHandler(qEntry);
+ //
+ // // cache
+ // ArrayList cacheParams = new ArrayList();
+ // cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
+ // cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
+ // CacheEntry cacheEntry = new CacheEntry(cacheParams);
+ // cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
+ // workspaceEntry.setCache(cacheEntry);
+ //
+ // // lock
+ // LockManagerEntry lockManagerEntry = new LockManagerEntry();
+ // lockManagerEntry.setTimeout(900000);
+ // LockPersisterEntry persisterEntry = new LockPersisterEntry();
+ // persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
+ // ArrayList lpParams = new ArrayList();
+ // lpParams.add(new SimpleParameterEntry("path", "../temp/lock"));
+ // persisterEntry.setParameters(lpParams);
+ // lockManagerEntry.setPersister(persisterEntry);
+ // workspaceEntry.setLockManager(lockManagerEntry);
// workspaceEntry
return workspaceEntry;
@@ -247,7 +242,7 @@
WorkspaceStorageConnection conn = persistentContainer.openConnection();
// add root (/) with jcr:primaryType
- addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED, null);
+ addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED);
// add property (/jcr:mixinTypes)
List<InternalQName> mixins = new ArrayList<InternalQName>();
@@ -258,14 +253,14 @@
conn.commit();
}
-
+
private void deleteJCRRoot() throws Exception
{
// prepare
WorkspaceStorageConnection conn = persistentContainer.openConnection();
// add root (/) with jcr:primaryType
- addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED, null);
+ addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED);
// add property (/jcr:mixinTypes)
List<InternalQName> mixins = new ArrayList<InternalQName>();
@@ -286,20 +281,14 @@
* @param primaryType InternalQName
* @throws Exception
*/
- private void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType, InternalQName[] mixinTypeNames)
- throws Exception
+ private void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType) throws Exception
{
- // create node with property jcr:primaryType
- List<ItemData> list = createNode(root, nodeId, primaryType, mixinTypeNames);
-
- // add node with property jcr:primaryType
- for (ItemData itemData : list)
- {
- if (itemData instanceof NodeData)
- conn.add((NodeData)itemData);
- else
- conn.add((PropertyData)itemData);
- }
+ // add root (/)
+ conn.add(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, null,
+ new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ conn.add(createProperty(root, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false));
}
/**
@@ -311,18 +300,18 @@
* @param mixinTypeNames InternalQName
* @throws Exception
*/
- private List<ItemData> createNode(QPath path, String nodeId, InternalQName primaryType, InternalQName[] mixinTypeNames)
- throws Exception
+ private List<ItemData> createNode(QPath path, String nodeId, InternalQName primaryType,
+ InternalQName[] mixinTypeNames) throws Exception
{
List<ItemData> list = new ArrayList<ItemData>();
-
+
// add node
- list.add(new TransientNodeData(path, nodeId, 1, primaryType, (mixinTypeNames == null ? new InternalQName[0] : null), 0, null,
- new AccessControlList()));
+ list.add(new TransientNodeData(path, nodeId, 1, primaryType, (mixinTypeNames == null ? new InternalQName[0]
+ : null), 0, null, new AccessControlList()));
// add property (/jcr:primaryType)
list.add(createProperty(path, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false));
-
+
return list;
}
@@ -341,14 +330,14 @@
InternalQName propertyName, Object propertyValue, boolean multiValued) throws Exception
{
TransientPropertyData propData = createProperty(nodePath, nodeId, propertyName, propertyValue, multiValued);
-
+
conn.add(propData);
return propData;
}
-
+
/**
- * Create Property.
+ * Create Property data.
*
* @param nodePath QPath
* @param nodeId String
@@ -357,13 +346,12 @@
* @return TransientPropertyData
* @throws Exception
*/
- private TransientPropertyData createProperty(QPath nodePath, String nodeId,
- InternalQName propertyName, Object propertyValue, boolean multiValued) throws Exception
+ private TransientPropertyData createProperty(QPath nodePath, String nodeId, InternalQName propertyName,
+ Object propertyValue, boolean multiValued) throws Exception
{
String propId = IdGenerator.generate();
QPath propPath = QPath.makeChildPath(nodePath, propertyName);
- TransientPropertyData propData =
- new TransientPropertyData(propPath, propId, 1, 1, nodeId, multiValued);
+ TransientPropertyData propData = new TransientPropertyData(propPath, propId, 1, 1, nodeId, multiValued);
List<Object> values = new ArrayList<Object>();
if (multiValued)
@@ -398,7 +386,7 @@
return propData;
}
-
+
/**
* Delete Property to the connection but doesn't save it.
*
@@ -413,7 +401,7 @@
{
// add property (/jcr:primaryType)
addDbProperty(conn, root, Constants.ROOT_UUID, Constants.JCR_PRIMARYTYPE, primaryType, false);
-
+
// add root (/)
conn.delete(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, null,
new AccessControlList()));
@@ -425,25 +413,27 @@
{
// prepare
String nodeId = IdGenerator.generate();
- List<ItemData> list = createNode(QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
-
+ List<ItemData> list =
+ createNode(QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
+ Constants.NT_UNSTRUCTURED, null);
+
List<Modification> modifications = new ArrayList<Modification>();
-
- for (ItemData itemData : list)
+
+ for (ItemData itemData : list)
if (itemData instanceof NodeData)
- modifications.addAll(addNode((NodeData) itemData));
+ modifications.addAll(addNode((NodeData)itemData));
else
- modifications.addAll(addProperty((PropertyData) itemData));
-
+ modifications.addAll(addProperty((PropertyData)itemData));
+
loader.put(modifications);
// tests it
- NodeData srcNodeData = (NodeData) list.get(0);
-
+ NodeData srcNodeData = (NodeData)list.get(0);
+
WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- NodeData destNodeData = (NodeData) conn.getItemData(nodeId);
-
+
+ NodeData destNodeData = (NodeData)conn.getItemData(nodeId);
+
assertNotNull(destNodeData);
assertEquals(srcNodeData.getIdentifier(), destNodeData.getIdentifier());
assertEquals(srcNodeData.getOrderNumber(), destNodeData.getOrderNumber());
@@ -456,19 +446,20 @@
public void testAddProperty() throws Exception
{
// prepare
- TransientPropertyData propData = createProperty(Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE", false);
-
+ TransientPropertyData propData =
+ createProperty(Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE", false);
+
List<Modification> modifications = new ArrayList<Modification>();
-
+
modifications.addAll(addProperty(propData));
-
+
loader.put(modifications);
// tests it
WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- PropertyData destPropData = (PropertyData) connection.getItemData(propData.getIdentifier());
-
+
+ PropertyData destPropData = (PropertyData)connection.getItemData(propData.getIdentifier());
+
assertNotNull(destPropData);
assertEquals(propData.getIdentifier(), destPropData.getIdentifier());
assertEquals(propData.getParentIdentifier(), destPropData.getParentIdentifier());
@@ -477,10 +468,10 @@
assertEquals(propData.getQPath(), destPropData.getQPath());
assertEquals(propData.getValues().size(), destPropData.getValues().size());
assertEquals(1, destPropData.getValues().size());
-
+
ValueData valueData = destPropData.getValues().get(0);
- assertEquals("JCR DATA VALUE", new String (valueData.getAsByteArray(), "UTF-8"));
-
+ assertEquals("JCR DATA VALUE", new String(valueData.getAsByteArray(), "UTF-8"));
+
}
public void testDeleteNode() throws Exception
@@ -488,35 +479,36 @@
// prepare
WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
+
String nodeId = IdGenerator.generate();
- addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
+ addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
+ Constants.NT_UNSTRUCTURED);
conn.commit();
-
+
List<Modification> modifications = new ArrayList<Modification>();
-
+
conn = persistentContainer.openConnection();
-
- NodeData nodeData = (NodeData) conn.getItemData(nodeId);
-
+
+ NodeData nodeData = (NodeData)conn.getItemData(nodeId);
+
List<PropertyData> properties = conn.getChildPropertiesData(nodeData);
-
+
for (PropertyData propertyData : properties)
modifications.addAll(removeProperty(propertyData));
-
+
modifications.addAll(removeNode(nodeData));
-
+
loader.put(modifications);
-
+
// tests it
conn = persistentContainer.openConnection();
-
- NodeData removedNodeData = (NodeData) conn.getItemData(nodeData.getIdentifier());
-
+
+ NodeData removedNodeData = (NodeData)conn.getItemData(nodeData.getIdentifier());
+
assertNull(removedNodeData);
-
+
for (PropertyData propertyData : properties)
- assertNull((PropertyData) conn.getItemData(propertyData.getIdentifier()));
+ assertNull((PropertyData)conn.getItemData(propertyData.getIdentifier()));
}
@@ -525,26 +517,29 @@
// prepare
WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
+
String nodeId = IdGenerator.generate();
- addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
+ addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
+ Constants.NT_UNSTRUCTURED);
conn.commit();
-
+
conn = persistentContainer.openConnection();
- PropertyData propData = addDbProperty(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, InternalQName.parse("[]prop1"), "_Tesed_VALUE", false);
+ PropertyData propData =
+ addDbProperty(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
+ InternalQName.parse("[]prop1"), "_Tesed_VALUE", false);
conn.commit();
-
+
List<Modification> modifications = new ArrayList<Modification>();
-
+
modifications.addAll(removeProperty(propData));
-
+
loader.put(modifications);
-
+
// tests it
conn = persistentContainer.openConnection();
-
- PropertyData removedPropertyData = (PropertyData) conn.getItemData(propData.getIdentifier());
-
+
+ PropertyData removedPropertyData = (PropertyData)conn.getItemData(propData.getIdentifier());
+
assertNull(removedPropertyData);
}
@@ -552,9 +547,9 @@
{
// prepare
-
+
// tests it
-
+
}
public void testUpdateProperty() throws Exception
@@ -580,22 +575,23 @@
// prepare
WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
+
String nodeId = IdGenerator.generate();
- addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
+ addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId,
+ Constants.NT_UNSTRUCTURED);
conn.commit();
-
+
// tests it
conn = persistentContainer.openConnection();
-
- NodeData srcNodeData = (NodeData) conn.getItemData(nodeId);
-
- Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + nodeId));
-
+
+ NodeData srcNodeData = (NodeData)conn.getItemData(nodeId);
+
+ Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/" + JBossCacheStorage.NODES + "/" + nodeId));
+
assertNotNull(attrebutes);
-
- NodeData destNodeData = (NodeData) attrebutes.get(JBossCacheStorage.ITEM_DATA);
-
+
+ NodeData destNodeData = (NodeData)attrebutes.get(JBossCacheStorage.ITEM_DATA);
+
assertNotNull(destNodeData);
assertEquals(srcNodeData.getIdentifier(), destNodeData.getIdentifier());
assertEquals(srcNodeData.getOrderNumber(), destNodeData.getOrderNumber());
@@ -619,17 +615,20 @@
// prepare
WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- TransientPropertyData propData = addDbProperty(connection, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE", false);
+
+ TransientPropertyData propData =
+ addDbProperty(connection, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.JCR_DATA, "JCR DATA VALUE",
+ false);
connection.commit();
-
+
// tests it
- Map<Object, Object> attrebutes = loader.get(Fqn.fromString("/"+JBossCacheStorage.PROPS + "/" + propData.getIdentifier()));
-
+ Map<Object, Object> attrebutes =
+ loader.get(Fqn.fromString("/" + JBossCacheStorage.PROPS + "/" + propData.getIdentifier()));
+
assertNotNull(attrebutes);
-
- PropertyData destPropData = (PropertyData) attrebutes.get(JBossCacheStorage.ITEM_DATA);
-
+
+ PropertyData destPropData = (PropertyData)attrebutes.get(JBossCacheStorage.ITEM_DATA);
+
assertNotNull(destPropData);
assertEquals(propData.getIdentifier(), destPropData.getIdentifier());
assertEquals(propData.getParentIdentifier(), destPropData.getParentIdentifier());
@@ -638,9 +637,9 @@
assertEquals(propData.getQPath(), destPropData.getQPath());
assertEquals(propData.getValues().size(), destPropData.getValues().size());
assertEquals(1, destPropData.getValues().size());
-
+
ValueData valueData = destPropData.getValues().get(0);
- assertEquals("JCR DATA VALUE", new String (valueData.getAsByteArray(), "UTF-8"));
+ assertEquals("JCR DATA VALUE", new String(valueData.getAsByteArray(), "UTF-8"));
}
16 years, 8 months
exo-jcr SVN: r612 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-11-12 11:07:40 -0500 (Thu, 12 Nov 2009)
New Revision: 612
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java
Log:
EXOJCR-237 syntax for seconds added
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java 2009-11-12 16:04:22 UTC (rev 611)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/util/StringNumberParser.java 2009-11-12 16:07:40 UTC (rev 612)
@@ -160,6 +160,10 @@
{
return Long.valueOf(text.substring(0, text.length() - 2));
}
+ else if (text.endsWith("s"))
+ {
+ return Long.valueOf(text) * 1000;
+ }
else if (text.endsWith("m"))
{
return Long.valueOf(text.substring(0, text.length() - 1)) * 60000; // 1000 * 60
16 years, 8 months
exo-jcr SVN: r611 - 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-12 11:04:22 -0500 (Thu, 12 Nov 2009)
New Revision: 611
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 JDBCCacheLoaderTest 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-12 15:55:39 UTC (rev 610)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 16:04:22 UTC (rev 611)
@@ -499,6 +499,11 @@
NodeData nodeData = (NodeData) conn.getItemData(nodeId);
+ List<PropertyData> properties = conn.getChildPropertiesData(nodeData);
+
+ for (PropertyData propertyData : properties)
+ modifications.addAll(removeProperty(propertyData));
+
modifications.addAll(removeNode(nodeData));
loader.put(modifications);
@@ -509,6 +514,9 @@
NodeData removedNodeData = (NodeData) conn.getItemData(nodeData.getIdentifier());
assertNull(removedNodeData);
+
+ for (PropertyData propertyData : properties)
+ assertNull((PropertyData) conn.getItemData(propertyData.getIdentifier()));
}
16 years, 8 months
exo-jcr SVN: r610 - 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-12 10:55:39 -0500 (Thu, 12 Nov 2009)
New Revision: 610
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
Log:
EXOJCR-202: IndexerCacheLoaderRuntimeTest test updated
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-12 15:46:23 UTC (rev 609)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-12 15:55:39 UTC (rev 610)
@@ -117,96 +117,102 @@
public void setUp() throws Exception
{
- try
- {
- super.setUp();
+ super.setUp();
- initPersistence();
+ initPersistence();
- loader = new IndexerCacheLoader();
- loader.injectDependencies(manager);
+ loader = new IndexerCacheLoader();
+ loader.injectDependencies(manager);
- initJCRRoot();
+ initJCRRoot();
- // // JBossCache
- // initJBCConfig();
- //
- // cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig, false);
- //
- // initJBC();
-
- // // 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));
- // session = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.SESSION));
- //
- // // JCR connection
- // conn = new JBossCacheStorageConnection(cache, nodes, props, session);
- // // add root (/)
- // conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- // new InternalQName[0], 0, null, new AccessControlList()));
- //
- // String propId1 = "rootf111111";
- // QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
- // TransientPropertyData propData1 =
- // new TransientPropertyData(propPath1, propId1, 1, PropertyType.NAME, Constants.ROOT_UUID, false);
- // propData1.setValue(new TransientValueData(Constants.NT_UNSTRUCTURED));
- // conn.add(propData1);
- //
- // conn.commit();
- manager.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw e;
- }
+ manager.start();
}
public void testAddNode() throws Exception
{
+ List<Modification> modifications = new ArrayList<Modification>();
+
// prepare add node to storage
WorkspaceStorageConnection conn = persistentContainer.openConnection();
String node1id = IdGenerator.generate();
QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
- // add root (/) with jcr:primaryType
- addDbNode(conn, node1path, node1id, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED);
+ // add node (/) with jcr:primaryType
+ NodeData nodeData =
+ new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList());
+ conn.add(nodeData);
+ modifications.addAll(this.addNode(nodeData));
+
+ // add property (/jcr:primaryType)
+ TransientPropertyData propData =
+ createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
+ conn.add(propData);
+ modifications.addAll(this.addProperty(propData));
+
conn.commit();
+ loader.put(modifications);
- List<ItemData> node = this.createNode(node1path, node1id, Constants.NT_UNSTRUCTURED, new InternalQName[0]);
+ // check do we really have node and its property
+ conn = persistentContainer.openConnection();
+ NodeData nd = (NodeData)conn.getItemData(node1id);
+ assertNotNull(nd);
+ assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
+ PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
+ assertNotNull(pd);
+ assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
+
+ // find node by search engine
+ SearchIndex index = ((SearchIndex)manager.getHandler());
+ IndexReader reader = index.getIndexReader();
+
+ IndexSearcher searcher = new IndexSearcher(reader);
+
+ Query query = new TermQuery(new Term("_:UUID", node1id));
+ Hits hit = searcher.search(query);
+ assertEquals(1, hit.length());
+
+ }
+
+ public void testRemoveNode() throws Exception
+ {
List<Modification> modifications = new ArrayList<Modification>();
- for (ItemData data : node)
- {
- if (data.isNode())
- {
- modifications.addAll(addNode((NodeData)data));
- }
- else
- {
- modifications.addAll(addProperty((PropertyData)data));
- }
- }
+ // prepare add node to storage
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+ String node1id = IdGenerator.generate();
+ QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
+
+ // add node (/) with jcr:primaryType
+ NodeData nodeData =
+ new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList());
+ conn.add(nodeData);
+ modifications.addAll(this.addNode(nodeData));
+
+ // add property (/jcr:primaryType)
+ TransientPropertyData propData =
+ createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
+ conn.add(propData);
+ modifications.addAll(this.addProperty(propData));
+
+ conn.commit();
loader.put(modifications);
- // check do we really have node
- WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- NodeData nd = (NodeData)connection.getItemData(node1id);
+ // check do we really have node and its property
+ conn = persistentContainer.openConnection();
+ NodeData nd = (NodeData)conn.getItemData(node1id);
assertNotNull(nd);
assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
+ PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
+ assertNotNull(pd);
+ assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
+
// find node by search engine
SearchIndex index = ((SearchIndex)manager.getHandler());
IndexReader reader = index.getIndexReader();
@@ -216,6 +222,39 @@
Query query = new TermQuery(new Term("_:UUID", node1id));
Hits hit = searcher.search(query);
assertEquals(1, hit.length());
+
+ // remove node1
+ modifications.clear();
+
+ // PropertyData prop = (PropertyData)node.get(1);
+ // NodeData n = (NodeData)node.get(0);
+
+ conn.delete(pd);
+ modifications.addAll(removeProperty(pd));
+ conn.delete(nd);
+ modifications.addAll(removeNode(nd));
+ conn.commit();
+
+ // NodeData data =
+ // new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, null,
+ // new AccessControlList());
+ // conn.delete(data);
+ //conn.commit();
+
+ // check removing
+ conn = persistentContainer.openConnection();
+ nd = (NodeData)conn.getItemData(node1id);
+ assertNull(nd);
+
+ loader.put(modifications);
+
+ // check index;
+ reader = index.getIndexReader();
+
+ searcher = new IndexSearcher(reader);
+ hit = searcher.search(query);
+ assertEquals(0, hit.length());
+
}
// public void testAddProperty() throws Exception
16 years, 8 months
exo-jcr SVN: r609 - 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-12 10:46:23 -0500 (Thu, 12 Nov 2009)
New Revision: 609
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 JDBCCacheLoaderTest 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-12 15:46:07 UTC (rev 608)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 15:46:23 UTC (rev 609)
@@ -487,8 +487,28 @@
{
// prepare
-
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+
+ String nodeId = IdGenerator.generate();
+ addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
+ conn.commit();
+
+ List<Modification> modifications = new ArrayList<Modification>();
+
+ conn = persistentContainer.openConnection();
+
+ NodeData nodeData = (NodeData) conn.getItemData(nodeId);
+
+ modifications.addAll(removeNode(nodeData));
+
+ loader.put(modifications);
+
// tests it
+ conn = persistentContainer.openConnection();
+
+ NodeData removedNodeData = (NodeData) conn.getItemData(nodeData.getIdentifier());
+
+ assertNull(removedNodeData);
}
@@ -524,28 +544,9 @@
{
// prepare
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
- String nodeId = IdGenerator.generate();
- addDbNode(conn, QPath.makeChildPath(Constants.ROOT_PATH, InternalQName.parse("[]node")), nodeId, Constants.NT_UNSTRUCTURED, null);
- conn.commit();
-
- List<Modification> modifications = new ArrayList<Modification>();
-
- conn = persistentContainer.openConnection();
-
- NodeData nodeData = (NodeData) conn.getItemData(nodeId);
-
- modifications.addAll(removeNode(nodeData));
-
- loader.put(modifications);
-
// tests it
- conn = persistentContainer.openConnection();
- NodeData removedNodeData = (NodeData) conn.getItemData(nodeData.getIdentifier());
-
- assertNull(removedNodeData);
}
public void testUpdateProperty() throws Exception
16 years, 8 months
exo-jcr SVN: r608 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry.
by do-not-reply@jboss.org
Author: vparfonov
Date: 2009-11-12 10:46:07 -0500 (Thu, 12 Nov 2009)
New Revision: 608
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java
Log:
EXOJCR-233 : if you need update RegitryEnter and create it if it's not exist just add QueryParam createIfNotExist=true
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java 2009-11-12 15:43:12 UTC (rev 607)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RESTRegistryService.java 2009-11-12 15:46:07 UTC (rev 608)
@@ -18,16 +18,6 @@
*/
package org.exoplatform.services.jcr.ext.registry;
-import org.exoplatform.services.jcr.ext.app.ThreadLocalSessionProviderService;
-import org.exoplatform.services.jcr.ext.common.SessionProvider;
-import org.exoplatform.services.jcr.ext.registry.Registry.RegistryNode;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.rest.ext.util.XlinkHref;
-import org.exoplatform.services.rest.resource.ResourceContainer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
import java.io.InputStream;
import java.net.URI;
@@ -42,6 +32,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@@ -50,6 +41,16 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.dom.DOMSource;
+import org.exoplatform.services.jcr.ext.app.ThreadLocalSessionProviderService;
+import org.exoplatform.services.jcr.ext.common.SessionProvider;
+import org.exoplatform.services.jcr.ext.registry.Registry.RegistryNode;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.rest.ext.util.XlinkHref;
+import org.exoplatform.services.rest.resource.ResourceContainer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
/**
* @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a>
* @version $Id: $
@@ -181,7 +182,7 @@
@Path("/{groupName:.+}/")
@Consumes(MediaType.APPLICATION_XML)
public Response recreateEntry(InputStream entryStream, @PathParam("repository") String repository,
- @PathParam("groupName") String groupName, @Context UriInfo uriInfo)
+ @PathParam("groupName") String groupName, @Context UriInfo uriInfo, @QueryParam("createIfNotExist") boolean createIfNotExist)
{
SessionProvider sessionProvider = sessionProviderService.getSessionProvider(null);
@@ -189,7 +190,10 @@
{
regService.getRepositoryService().setCurrentRepositoryName(repository);
RegistryEntry entry = RegistryEntry.parse(entryStream);
- regService.recreateEntry(sessionProvider, normalizePath(groupName), entry);
+ if (createIfNotExist)
+ regService.updateEntry(sessionProvider, normalizePath(groupName), entry);
+ else
+ regService.recreateEntry(sessionProvider, normalizePath(groupName), entry);
URI location = uriInfo.getRequestUriBuilder().path(entry.getName()).build();
return Response.created(location).build();
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java 2009-11-12 15:43:12 UTC (rev 607)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/registry/RegistryService.java 2009-11-12 15:46:07 UTC (rev 608)
@@ -239,7 +239,51 @@
throw new RepositoryException("Can't get XML representation from stream " + te);
}
}
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateEntry(final SessionProvider sessionProvider, final String groupPath, final RegistryEntry entry)
+ throws RepositoryException
+ {
+ final String entryRelPath = EXO_REGISTRY + "/" + groupPath + "/" + entry.getName();
+ final String parentFullPath = "/" + EXO_REGISTRY + "/" + groupPath;
+
+ try
+ {
+ Session session = session(sessionProvider, repositoryService.getCurrentRepository());
+
+ // Don't care about concurrency, Session should be dedicated to the Thread, see JCR-765
+ // synchronized (session) {
+ try {
+ Node node = session.getRootNode().getNode(entryRelPath);
+ // delete existing entry...
+ node.remove();
+ // create same entry,
+ // [PN] no check we need here, as we have deleted this node before
+ // checkGroup(sessionProvider, fullParentPath);
+ session.importXML(parentFullPath, entry.getAsInputStream(), IMPORT_UUID_CREATE_NEW);
+ } catch (PathNotFoundException e) {
+ createEntry(sessionProvider, groupPath, entry);
+ }
+ // save recreated changes
+ session.save();
+ // }
+ }
+ catch (IOException ioe)
+ {
+ throw new RepositoryException("Item " + parentFullPath + "can't be created " + ioe);
+ }
+ catch (TransformerException te)
+ {
+ throw new RepositoryException("Can't get XML representation from stream " + te);
+ }
+ }
+
+
/**
* {@inheritDoc}
*/
16 years, 8 months