exo-jcr SVN: r954 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/lab and 3 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-09 03:48:35 -0500 (Wed, 09 Dec 2009)
New Revision: 954
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestFullSearchPrepare.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestQueryPrepare.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestFullSearchAssert.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestQueryAssert.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/ChangesFilterListsWrapper.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/
Log:
EXOJCR-291: Tests moved to separate folders, Cleaned and updated code of Changes filter and CacheLoader-s
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/ChangesFilterListsWrapper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/ChangesFilterListsWrapper.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/ChangesFilterListsWrapper.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -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.core.query.jbosscache;
import java.io.Serializable;
@@ -4,7 +22,7 @@
import java.util.Set;
/**
- * FOR TESTING PURPOSES ONLY
+ * FOR TESTING PURPOSES ONLY. Used to avoid batching usage in indexer cache.
*
* @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
* @version $Id: ChangesFilterListsWrapper.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
@@ -14,22 +32,49 @@
{
private static final long serialVersionUID = 1L;
- public Set<String> addedNodes;
+ private Set<String> addedNodes;
- public Set<String> removedNodes;
+ private Set<String> removedNodes;
- public Set<String> parentAddedNodes;
+ private Set<String> parentAddedNodes;
- public Set<String> parentRemovedNodes;
+ private Set<String> parentRemovedNodes;
+ /**
+ * Creates ChangesFilterListsWrapper data class, containing given lists.
+ *
+ * @param addedNodes
+ * @param removedNodes
+ * @param parentAddedNodes
+ * @param parentRemovedNodes
+ */
public ChangesFilterListsWrapper(Set<String> addedNodes, Set<String> removedNodes, Set<String> parentAddedNodes,
Set<String> parentRemovedNodes)
{
- super();
this.addedNodes = addedNodes;
this.removedNodes = removedNodes;
this.parentAddedNodes = parentAddedNodes;
this.parentRemovedNodes = parentRemovedNodes;
}
+ public Set<String> getAddedNodes()
+ {
+ return addedNodes;
+ }
+
+ public Set<String> getRemovedNodes()
+ {
+ return removedNodes;
+ }
+
+ public Set<String> getParentAddedNodes()
+ {
+ return parentAddedNodes;
+ }
+
+ public Set<String> getParentRemovedNodes()
+ {
+ return parentRemovedNodes;
+ }
+
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -17,6 +17,7 @@
package org.exoplatform.services.jcr.impl.core.query.jbosscache;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
import org.exoplatform.services.jcr.impl.core.query.SearchManager;
import org.exoplatform.services.jcr.impl.storage.jbosscache.AbstractWriteOnlyCacheLoader;
import org.exoplatform.services.log.ExoLogger;
@@ -24,9 +25,12 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
+import java.io.IOException;
import java.util.List;
import java.util.Set;
+import javax.jcr.RepositoryException;
+
/**
* @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
* @version $Id: IndexerCacheLoader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
@@ -40,17 +44,23 @@
private SearchManager parentSearchManager;
- public void init(SearchManager searchManager, SearchManager parentSearchManager)
- throws RepositoryConfigurationException
+ private QueryHandler handler;
+
+ private QueryHandler parentHandler;
+
+ public void init(SearchManager searchManager, SearchManager parentSearchManager, QueryHandler handler,
+ QueryHandler parentHandler) throws RepositoryConfigurationException
{
this.searchManager = searchManager;
this.parentSearchManager = parentSearchManager;
+ this.handler = handler;
+ this.parentHandler = parentHandler;
}
@Override
public void put(List<Modification> modifications) throws Exception
{
- // FOR TESTING PURPOSES
+ // FOR TESTING PURPOSES, avoid batches, use single puts.
for (Modification m : modifications)
{
switch (m.getType())
@@ -61,7 +71,7 @@
case REMOVE_DATA :
}
}
-
+ // This code was used if batching.
// if (log.isDebugEnabled())
// {
// log.info("Received list of modifications");
@@ -105,41 +115,75 @@
}
+ // Put used avoiding patching
@Override
public Object put(Fqn arg0, Object key, Object val) throws Exception
{
if (key.equals("key"))
{
ChangesFilterListsWrapper wrapper = (ChangesFilterListsWrapper)val;
- updateIndex(wrapper.addedNodes, wrapper.removedNodes, wrapper.parentAddedNodes, wrapper.parentRemovedNodes);
+ updateIndex(wrapper.getAddedNodes(), wrapper.getRemovedNodes(), wrapper.getParentAddedNodes(), wrapper
+ .getParentRemovedNodes());
}
return null;
}
+ /**
+ * Flushes lists of added/removed nodes to SearchManagers, starting indexing.
+ *
+ * @param addedNodes
+ * @param removedNodes
+ * @param parentAddedNodes
+ * @param parentRemovedNodes
+ */
protected void updateIndex(Set<String> addedNodes, Set<String> removedNodes, Set<String> parentAddedNodes,
Set<String> parentRemovedNodes)
{
- if (searchManager != null && addedNodes.size() + removedNodes.size() > 0)
+ if (searchManager != null && (addedNodes.size() > 0 || removedNodes.size() > 0))
{
try
{
searchManager.updateIndex(removedNodes, addedNodes);
}
- catch (Exception e)
+ catch (RepositoryException e)
{
- e.printStackTrace();
+ log.error("Error indexing changes " + e, e);
}
+ catch (IOException e)
+ {
+ log.error("Error indexing changes " + e, e);
+ try
+ {
+ handler.logErrorChanges(removedNodes, addedNodes);
+ }
+ catch (IOException ioe)
+ {
+ log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+ }
+ }
}
- if (parentSearchManager != null && addedNodes.size() + removedNodes.size() > 0)
+ if (parentSearchManager != null && (parentAddedNodes.size() > 0 || parentRemovedNodes.size() > 0))
{
try
{
parentSearchManager.updateIndex(parentRemovedNodes, parentAddedNodes);
}
- catch (Exception e)
+ catch (RepositoryException e)
{
- e.printStackTrace();
+ log.error("Error indexing changes " + e, e);
}
+ catch (IOException e)
+ {
+ log.error("Error indexing changes " + e, e);
+ try
+ {
+ parentHandler.logErrorChanges(removedNodes, addedNodes);
+ }
+ catch (IOException ioe)
+ {
+ log.warn("Exception occure when errorLog writed. Error log is not complete. " + ioe, ioe);
+ }
+ }
}
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -24,7 +24,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
-import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -78,10 +77,11 @@
final Set<String> parentRemovedNodes = new HashSet<String>();
final Set<String> parentAddedNodes = new HashSet<String>();
// merging all lists stored in memory
+ //TODO: re-write: lists are now stored in wrapper.
Collection<NodeSPI> children = cache.getRoot().getChildrenDirect();
for (NodeSPI aChildren : children)
{
- Fqn fqn = aChildren.getFqn();
+ Fqn<?> fqn = aChildren.getFqn();
Object value = cache.get(fqn, JbossCacheIndexChangesFilter.ADDED);
if (value != null && value instanceof Set<?>)
{
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JbossCacheIndexChangesFilter.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -81,7 +81,7 @@
// initialize IndexerCacheLoader
IndexerCacheLoader indexerCacheLoader = new IndexerCacheLoader();
// inject dependencies
- indexerCacheLoader.init(searchManager, parentSearchManager);
+ indexerCacheLoader.init(searchManager, parentSearchManager, handler, parentHandler);
// set SingltonStoreCacheLoader
SingletonStoreConfig singletonStoreConfig = new SingletonStoreConfig();
singletonStoreConfig.setClassName(IndexerSingletonStoreCacheLoader.class.getName());
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab
___________________________________________________________________
Name: svn:ignore
+ lucene
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -1,137 +0,0 @@
-/*
- * 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.lab.cluster;
-
-import org.exoplatform.services.jcr.JcrAPIBaseTest;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.query.Query;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.Row;
-import javax.jcr.query.RowIterator;
-
-/**
- * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
- * @version $Id: TestQueryAssert.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
- *
- */
-public class TestQueryAssert extends JcrAPIBaseTest
-{
- public void testAssert() throws RepositoryException, IOException
- {
- System.out.println("Start asserting....");
-
- Node doc1 = root.getNode("document1");
- Node doc2 = root.getNode("document2");
-
- // make SQL query
- QueryManager qman = this.workspace.getQueryManager();
-
- Query q = qman.createQuery("SELECT * FROM nt:file ", Query.SQL);
- QueryResult res = q.execute();
- long sqlsize = res.getNodes().getSize();
- assertEquals(2, sqlsize);
- checkResult(res, new Node[]{doc1, doc2});
-
- //make XPath query
-
- Query xq = qman.createQuery("//element(*,nt:file)", Query.XPATH);
- QueryResult xres = xq.execute();
- long xpathsize = xres.getNodes().getSize();
- assertEquals(2, xpathsize);
- checkResult(xres, new Node[]{doc1, doc2});
- System.out.println("Done!");
- try
- {
- Thread.sleep(1024*1024*1024);
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- protected void checkResult(QueryResult result, Node[] nodes) throws RepositoryException
- {
- // collect paths
-
- String[] columnNames = result.getColumnNames();
- String[][] vals = new String[(int)result.getNodes().getSize()][result.getColumnNames().length];
-
- RowIterator rit = result.getRows();
- int j = 0;
- while (rit.hasNext())
- {
- Row r = rit.nextRow();
- Value[] v = r.getValues();
- for (int i = 0; i < v.length; i++)
- {
- vals[j][i] = (v[i] != null) ? v[i].getString() : "null";
- }
- j++;
- }
-
- Set<String> expectedPaths = new HashSet<String>();
- for (int i = 0; i < nodes.length; i++)
- {
- expectedPaths.add(nodes[i].getPath());
- }
- Set<String> resultPaths = new HashSet<String>();
- for (NodeIterator it = result.getNodes(); it.hasNext();)
- {
- resultPaths.add(it.nextNode().getPath());
- }
-
- comparePaths(expectedPaths, resultPaths, false);
- }
-
- private void comparePaths(Set<String> expectedPaths, Set<String> resultPaths, boolean canContainMore)
- {
- // check if all expected are in result
- for (Iterator<String> it = expectedPaths.iterator(); it.hasNext();)
- {
- String path = it.next();
- assertTrue(path + " is not part of the result set", resultPaths.contains(path));
- }
-
- if (!canContainMore)
- {
- // check result does not contain more than expected
-
- for (Iterator<String> it = resultPaths.iterator(); it.hasNext();)
- {
- String path = it.next();
- assertTrue(path + " is not expected to be part of the result set. " + " Total size:" + resultPaths.size(),
- expectedPaths.contains(path));
- }
- }
- }
-}
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java 2009-12-09 08:38:07 UTC (rev 953)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -1,71 +0,0 @@
-/*
- * 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.lab.cluster;
-
-import org.exoplatform.services.jcr.JcrAPIBaseTest;
-import org.exoplatform.services.jcr.impl.core.NodeImpl;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Calendar;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-/**
- * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
- * @version $Id: TestQueryPrepare.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
- *
- */
-public class TestQueryPrepare extends JcrAPIBaseTest
-{
- public void testPrepareNodes() throws RepositoryException, IOException
- {
- System.out.println("preparing....");
-
- root.addNode("simplenode", "nt:unstructured");
-
- Node doc1 = root.addNode("document1", "nt:file");
- NodeImpl cont = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
- cont.setProperty("jcr:mimeType", "text/plain");
- cont.setProperty("jcr:lastModified", Calendar.getInstance());
- cont.setProperty("jcr:encoding", "UTF-8");
- cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
-
- Node doc2 = root.addNode("document2", "nt:file");
- cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
- cont.setProperty("jcr:mimeType", "text/plain");
- cont.setProperty("jcr:lastModified", Calendar.getInstance());
- cont.setProperty("jcr:encoding", "UTF-8");
- cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
- session.save();
- System.out.println("Done!");
- try
- {
- Thread.sleep(1024*1024*1024);
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-}
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestFullSearchPrepare.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestFullSearchPrepare.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestFullSearchPrepare.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -0,0 +1,75 @@
+/*
+ * 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.lab.cluster.prepare;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestFullSearchPrepare.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestFullSearchPrepare extends JcrAPIBaseTest
+{
+
+ public void testFullSearch() throws RepositoryException
+ {
+ Node doc1 = root.addNode("document1", "nt:file");
+ NodeImpl cont1 = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
+ cont1.setProperty("jcr:mimeType", "text/plain");
+ cont1.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont1.setProperty("jcr:data", "The quick brown fox jump over the lazy dog");
+ session.save();
+
+ Node doc2 = root.addNode("document2", "nt:file");
+ NodeImpl cont2 = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
+ cont2.setProperty("jcr:mimeType", "text/plain");
+ cont2.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont2.setProperty("jcr:data", "Dogs do not like cats.");
+
+ Node doc3 = root.addNode("document3", "nt:file");
+ NodeImpl cont3 = (NodeImpl)doc3.addNode("jcr:content", "nt:resource");
+ cont3.setProperty("jcr:mimeType", "text/plain");
+ cont3.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont3.setProperty("jcr:data", "Cats jumping high.");
+ session.save();
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // do noting
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestFullSearchPrepare.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestQueryPrepare.java (from rev 948, jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestQueryPrepare.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestQueryPrepare.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -0,0 +1,75 @@
+/*
+ * 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.lab.cluster.prepare;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestQueryPrepare.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestQueryPrepare extends JcrAPIBaseTest
+{
+ public void testPrepareNodes() throws RepositoryException, IOException
+ {
+ System.out.println("preparing....");
+
+ root.addNode("simplenode", "nt:unstructured");
+
+ Node doc1 = root.addNode("document1", "nt:file");
+ NodeImpl cont = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
+ cont.setProperty("jcr:mimeType", "text/plain");
+ cont.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont.setProperty("jcr:encoding", "UTF-8");
+ cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+
+ Node doc2 = root.addNode("document2", "nt:file");
+ cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
+ cont.setProperty("jcr:mimeType", "text/plain");
+ cont.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont.setProperty("jcr:encoding", "UTF-8");
+ cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+ session.save();
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // do noting
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/prepare/TestQueryPrepare.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestFullSearchAssert.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestFullSearchAssert.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestFullSearchAssert.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -0,0 +1,141 @@
+/*
+ * 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.lab.cluster.test;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import java.util.Calendar;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestFullSearchAssert.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestFullSearchAssert extends JcrAPIBaseTest
+{
+
+ public void testFullSearch() throws RepositoryException
+ {
+ Node cont1 = root.getNode("document1/jcr:content");
+ Node cont2 = root.getNode("document2/jcr:content");
+ Node cont3 = root.getNode("document3/jcr:content");
+
+ // make SQL query
+ QueryManager qman = this.workspace.getQueryManager();
+
+ Query q = qman.createQuery("SELECT * FROM nt:resource WHERE CONTAINS(*,'do')", Query.SQL);
+ QueryResult res = q.execute();
+ long sqlsize = res.getNodes().getSize();
+ assertEquals(1, sqlsize);
+ checkResult(res, new Node[]{cont2});
+
+ //make XPath query
+ Query xq = qman.createQuery("//element(*,nt:resource)[jcr:contains(.,'cats')]", Query.XPATH);
+ QueryResult xres = xq.execute();
+ long xpathsize = xres.getNodes().getSize();
+ assertEquals(2, xpathsize);
+ checkResult(xres, new Node[]{cont2, cont3});
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void checkResult(QueryResult result, Node[] nodes) throws RepositoryException
+ {
+ // collect paths
+
+ String[] columnNames = result.getColumnNames();
+ String[][] vals = new String[(int)result.getNodes().getSize()][result.getColumnNames().length];
+
+ RowIterator rit = result.getRows();
+ int j = 0;
+ while (rit.hasNext())
+ {
+ Row r = rit.nextRow();
+ Value[] v = r.getValues();
+ for (int i = 0; i < v.length; i++)
+ {
+ vals[j][i] = (v[i] != null) ? v[i].getString() : "null";
+ }
+ j++;
+ }
+
+ Set<String> expectedPaths = new HashSet<String>();
+ for (int i = 0; i < nodes.length; i++)
+ {
+ expectedPaths.add(nodes[i].getPath());
+ }
+ Set<String> resultPaths = new HashSet<String>();
+ for (NodeIterator it = result.getNodes(); it.hasNext();)
+ {
+ resultPaths.add(it.nextNode().getPath());
+ }
+
+ comparePaths(expectedPaths, resultPaths, false);
+ }
+
+ private void comparePaths(Set<String> expectedPaths, Set<String> resultPaths, boolean canContainMore)
+ {
+ // check if all expected are in result
+ for (Iterator<String> it = expectedPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not part of the result set", resultPaths.contains(path));
+ }
+
+ if (!canContainMore)
+ {
+ // check result does not contain more than expected
+
+ for (Iterator<String> it = resultPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not expected to be part of the result set. " + " Total size:" + resultPaths.size(),
+ expectedPaths.contains(path));
+ }
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // do noting
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestFullSearchAssert.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestQueryAssert.java (from rev 949, jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java)
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestQueryAssert.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestQueryAssert.java 2009-12-09 08:48:35 UTC (rev 954)
@@ -0,0 +1,141 @@
+/*
+ * 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.lab.cluster.test;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestQueryAssert.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestQueryAssert extends JcrAPIBaseTest
+{
+ public void testAssert() throws RepositoryException, IOException
+ {
+ System.out.println("Start asserting....");
+
+ Node doc1 = root.getNode("document1");
+ Node doc2 = root.getNode("document2");
+
+ // make SQL query
+ QueryManager qman = this.workspace.getQueryManager();
+
+ Query q = qman.createQuery("SELECT * FROM nt:file ", Query.SQL);
+ QueryResult res = q.execute();
+ long sqlsize = res.getNodes().getSize();
+ assertEquals(2, sqlsize);
+ checkResult(res, new Node[]{doc1, doc2});
+
+ //make XPath query
+
+ Query xq = qman.createQuery("//element(*,nt:file)", Query.XPATH);
+ QueryResult xres = xq.execute();
+ long xpathsize = xres.getNodes().getSize();
+ assertEquals(2, xpathsize);
+ checkResult(xres, new Node[]{doc1, doc2});
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(60000);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void checkResult(QueryResult result, Node[] nodes) throws RepositoryException
+ {
+ // collect paths
+
+ String[] columnNames = result.getColumnNames();
+ String[][] vals = new String[(int)result.getNodes().getSize()][result.getColumnNames().length];
+
+ RowIterator rit = result.getRows();
+ int j = 0;
+ while (rit.hasNext())
+ {
+ Row r = rit.nextRow();
+ Value[] v = r.getValues();
+ for (int i = 0; i < v.length; i++)
+ {
+ vals[j][i] = (v[i] != null) ? v[i].getString() : "null";
+ }
+ j++;
+ }
+
+ Set<String> expectedPaths = new HashSet<String>();
+ for (int i = 0; i < nodes.length; i++)
+ {
+ expectedPaths.add(nodes[i].getPath());
+ }
+ Set<String> resultPaths = new HashSet<String>();
+ for (NodeIterator it = result.getNodes(); it.hasNext();)
+ {
+ resultPaths.add(it.nextNode().getPath());
+ }
+
+ comparePaths(expectedPaths, resultPaths, false);
+ }
+
+ private void comparePaths(Set<String> expectedPaths, Set<String> resultPaths, boolean canContainMore)
+ {
+ // check if all expected are in result
+ for (Iterator<String> it = expectedPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not part of the result set", resultPaths.contains(path));
+ }
+
+ if (!canContainMore)
+ {
+ // check result does not contain more than expected
+
+ for (Iterator<String> it = resultPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not expected to be part of the result set. " + " Total size:" + resultPaths.size(),
+ expectedPaths.contains(path));
+ }
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // do noting
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/test/TestQueryAssert.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 7 months
exo-jcr SVN: r953 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-12-09 03:38:07 -0500 (Wed, 09 Dec 2009)
New Revision: 953
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
Log:
EXOJCR-264 don't open stream on VS file without need (i.e. if smaller of MaxBuffSize)
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-08 16:32:40 UTC (rev 952)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/value/fs/operations/ValueFileIOHelper.java 2009-12-09 08:38:07 UTC (rev 953)
@@ -75,17 +75,17 @@
protected ValueData readValue(File file, int orderNum, int maxBufferSize) throws IOException
{
- FileInputStream is = new FileInputStream(file);
- try
- {
- long fileSize = file.length();
+ long fileSize = file.length();
- if (fileSize > maxBufferSize)
+ if (fileSize > maxBufferSize)
+ {
+ return new FileStreamPersistedValueData(file, orderNum);
+ }
+ else
+ {
+ FileInputStream is = new FileInputStream(file);
+ try
{
- return new FileStreamPersistedValueData(file, orderNum);
- }
- else
- {
int buffSize = (int)fileSize;
byte[] res = new byte[buffSize];
int rpos = 0;
@@ -96,14 +96,13 @@
System.arraycopy(buff, 0, res, rpos, r);
rpos += r;
}
-
return new ByteArrayPersistedValueData(res, orderNum);
}
+ finally
+ {
+ is.close();
+ }
}
- finally
- {
- is.close();
- }
}
/**
16 years, 7 months
exo-jcr SVN: r952 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-08 11:32:40 -0500 (Tue, 08 Dec 2009)
New Revision: 952
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-278 : The commit in DB on prepare phase in JDBCCacheLoder.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 16:21:28 UTC (rev 951)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 16:32:40 UTC (rev 952)
@@ -59,8 +59,8 @@
/**
* Storage connections involved in transactions.
- */
- protected Map<Object, JDBCStorageConnection> transactions = new ConcurrentHashMap<Object, JDBCStorageConnection>();
+ *//*
+ protected Map<Object, JDBCStorageConnection> transactions = new ConcurrentHashMap<Object, JDBCStorageConnection>();*/
private IndividualCacheLoaderConfig config;
16 years, 7 months
exo-jcr SVN: r951 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-08 11:21:28 -0500 (Tue, 08 Dec 2009)
New Revision: 951
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-278 : The commit in DB on prepare phase in JDBCCacheLoder.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 15:53:12 UTC (rev 950)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 16:21:28 UTC (rev 951)
@@ -1,878 +1,882 @@
-/*
- * 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.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
-import org.exoplatform.services.jcr.impl.storage.jdbc.PropertyDataInfo;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.AbstractCacheLoader;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jcr.RepositoryException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 31.10.2009
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class JDBCCacheLoader extends AbstractCacheLoader
-{
- protected static final Log LOG = ExoLogger.getLogger("jcr.JDBCCacheLoader");
-
- /**
- * Storage connections involved in transactions.
- */
- protected Map<Object, JDBCStorageConnection> transactions = new ConcurrentHashMap<Object, JDBCStorageConnection>();
-
- private IndividualCacheLoaderConfig config;
-
- private WorkspaceDataContainer dataContainer;
-
- public JDBCCacheLoader()
- {
- }
-
- /**
- * Init the loader DataContainer with given WorkspaceDataContainer instance.
- *
- * @param dataContainer WorkspaceDataContainer
- */
- @Inject
- public void init(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
- {
- if (this.dataContainer != null)
- {
- throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
- }
-
- this.dataContainer = dataContainer;
- }
-
- /**
- * Apply all Modifications on JDBC database, but don't commit them.
- *
- * @param modifications List if Modification
- * @param conn JDBCStorageConnection
- * @throws RepositoryException if error occurs
- */
- protected void apply(List<Modification> modifications, JDBCStorageConnection conn) throws RepositoryException
- {
- for (Modification m : modifications)
- {
- switch (m.getType())
- {
- case PUT_DATA :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("PUT_DATA modification");
- }
- break;
- case PUT_DATA_ERASE :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("PUT_DATA_ERASE modification");
- }
- break;
- case PUT_KEY_VALUE :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("PUT_KEY_VALUE modification");
- }
-
- doUpdate(m, conn);
-
- break;
- case REMOVE_DATA :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("REMOVE_DATA modification");
- }
- break;
- case REMOVE_KEY_VALUE :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("REMOVE_KEY_VALUE modification");
- }
- break;
- case REMOVE_NODE :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("REMOVE_NODE modification");
- }
-
- doRemove(m, conn);
-
- break;
- case MOVE :
- if (LOG.isDebugEnabled())
- {
- LOG.debug("MOVE modification");
- }
- break;
- default :
- throw new CacheException("Unknown modification " + m.getType());
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(List<Modification> modifications) throws Exception
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Modifications list size = " + modifications.size());
- }
-
- JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
-
- try
- {
- apply(modifications, conn);
- conn.commit();
- }
- catch (RepositoryException e)
- {
- LOG.error("RepositoryException: ", e); // TODO don't catch, but be sure it will be thrown to JCR
- throw new RepositoryException(e);
- }
- catch (IllegalStateException e)
- {
- LOG.error("IllegalStateException: ", e); // TODO don't catch, but be sure it will be thrown to JCR
- throw new IllegalStateException(e);
- }
- finally
- {
- if (conn != null && conn.isOpened())
- {
- conn.rollback();
- }
- }
- }
-
- /**
- * Remove NodeData or PropertyData.
- *
- * @param modification Modification
- * @param conn JDBCStorageConnection
- * @throws IllegalStateException if connection closed
- * @throws RepositoryException if error occurs
- */
- private void doRemove(Modification modification, JDBCStorageConnection conn) throws IllegalStateException,
- RepositoryException
- {
- Fqn fqn = IdTreeHelper.buildFqn(modification.getFqn());
-
- if (fqn.size() == 2)
- {
- String identifier = (String)fqn.get(1);
-
- if (fqn.get(0).equals(JBossCacheStorage.NODES))
- {
- conn.deleteNode(identifier);
- }
- else if (fqn.get(0).equals(JBossCacheStorage.PROPS))
- {
- conn.deleteProperty(identifier);
- }
- }
- else
- {
- // remove of child node, we're not interested in such info for persistence
- }
- }
-
- /**
- * Performs ADD to NodeData and PropertyData.
- *
- * @param modification Modification
- * @param conn JDBCStorageConnection
- * @throws IllegalStateException if connection closed
- * @throws RepositoryException if error occurs
- */
- private void doAdd(Modification modification, JDBCStorageConnection conn) throws IllegalStateException,
- RepositoryException
- {
- if (modification.getValue() instanceof NodeData)
- {
- //add node data
- conn.add((NodeData)modification.getValue());
- }
- else if (modification.getValue() instanceof PropertyData)
- {
- //add property data
- conn.add((PropertyData)modification.getValue());
- }
- }
-
- /**
- * Performs UPDATE to NodeData or PropertyData.
- *
- * @param modification Modification
- * @param conn JDBCStorageConnection
- * @throws IllegalStateException if connection closed
- * @throws RepositoryException if error occurs
- */
- private void doUpdate(Modification m, JDBCStorageConnection conn) throws IllegalStateException, RepositoryException
- {
- Fqn fqn = IdTreeHelper.buildFqn(m.getFqn());
-
- if (fqn.size() == 2 && m.getValue() instanceof TransientItemData)
- {
- //Check flag it's mixin update for node, if this flag set we have node need to
- TransientItemData item = (TransientItemData)m.getValue();
-
- if ((item.getState() & TransientItemData.TRANSITIVE_PATH_UPDATED) == 0)
- {
- // if not a transitive update of path, update it in the database
- if (conn.itemExists((String)fqn.get(1), item.isNode()))
- {
- // update if it's non transitive update
- if (item.isNode())
- {
- if ((item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0
- && (item.getState() & TransientItemData.TRANSITIVE_ACL_UPDATED) == 0)
- {
- // TODO do not handle mixin or ACL updates in db; it's a workaround - review logic in the connection
-
- // TODO conn.rename() is used to update all the fields in DB.
- // Original conn.update() will be matched as deprecated,
- // and conn.rename() should be renamed to update. This
- // is done to solve the issue, when we need to guess each
- // time whether node is moved or just updated. This
- // solution is used as the fastest among other.
- conn.rename((NodeData)item);
- }
- }
- else
- {
- //update property data
- conn.update((PropertyData)item);
- }
- }
- else
- {
- doAdd(m, conn);
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Map<Object, Object> get(Fqn fqn) throws Exception
- {
- Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
- Map<Object, Object> attrs;
-
- if (name.size() > 1)
- {
- if (name.get(0).equals(JBossCacheStorage.NODES))
- {
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String nodeId = name.getLastElementAsString();
- NodeData nodeData = (NodeData) conn.getItemData(nodeId);
- if (nodeData != null)
- {
- List<PropertyDataInfo> childProps = conn.getChildProperties(nodeId);
- if (childProps.size() <= 0)
- {
- throw new JDBCCacheLoaderException("FATAL Empty attributes for Node " + nodeId + " '" + name
- + "'");
- }
-
- attrs = new LinkedHashMap<Object, Object>();
- attrs.put(JBossCacheStorage.ITEM_DATA, nodeData);
- for (PropertyDataInfo prop : childProps)
- {
- attrs.put(prop.getPropertyName(), prop.getPropertyId());
- }
- }
- else
- {
- attrs = null;
- }
- }
- finally
- {
- conn.close();
- }
- }
- // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
- else if (name.size() == 3)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
- String parentId = (String) name.get(1);
-
- String nodeId =
- conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
- if (nodeId != null)
- {
- attrs = new LinkedHashMap<Object, Object>();
- attrs.put(JBossCacheStorage.ITEM_ID, nodeId);
- }
- else
- {
- attrs = null;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- // /$PROPS/<PROPERTY_ID>
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
- {
- if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String propertyId = name.getLastElementAsString();
- PropertyData propertyData = (PropertyData) conn.getItemData(propertyId);
- if (propertyData != null)
- {
- attrs = new LinkedHashMap<Object, Object>();
- attrs.put(JBossCacheStorage.ITEM_DATA, propertyData);
- }
- else
- {
- attrs = null;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- else if (name.get(0).equals(JBossCacheStorage.REFS))
- {
- // get reference
- if (name.size() == 3)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- // do we have such property reference
- String nodeID = String.valueOf(name.get(1));
- String propID = String.valueOf(name.get(2));
-
- if (conn.hasReference(nodeID, propID))
- {
- attrs = new LinkedHashMap<Object, Object>();
- }
- else
- {
- attrs = null;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- // do we have node with any reference
- String nodeID = name.getLastElementAsString();
- if (conn.getReferenceIdentifiers(nodeID).size() > 0)
- {
- attrs = new LinkedHashMap<Object, Object>();
- }
- else
- {
- attrs = null;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
- }
-
- }
- else
- {
- attrs = null;
- if (LOG.isDebugEnabled())
- {
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- }
- else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
- || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
- || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
- {
- // roots, like NODES, PROPS etc
- attrs = new LinkedHashMap<Object, Object>();
- }
- else
- {
- LOG.warn("Unexpected Fqn asked " + name);
- attrs = null;
- }
-
- return attrs;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean exists(Fqn fqn) throws Exception
- {
- Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
-
- boolean exists;
-
- if (name.size() > 1)
- {
- if (name.get(0).equals(JBossCacheStorage.NODES))
- {
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String nodeId = name.getLastElementAsString();
- String nodeName = conn.getNodeName(nodeId);
-
- if (nodeName != null)
- {
- exists = true;
- }
- else
- {
- exists = false;
- }
- }
- finally
- {
- conn.close();
- }
- }
- // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
- else if (name.size() == 3)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
- String parentId = (String) name.get(1);
-
- String nodeId =
- conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
- if (nodeId != null)
- {
- exists = true;
- }
- else
- {
- exists = false;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- // /$PROPS/<PROPERTY_ID>
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
- {
- if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String propertyId = name.getLastElementAsString();
- String propertyName = conn.getPropertyName(propertyId);
-
- if (propertyName != null)
- {
- exists = true;
- }
- else
- {
- exists = false;
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- else if (name.get(0).equals(JBossCacheStorage.REFS))
- {
- // /$REFS/<NODE_ID>
- if (name.size() == 2)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String nodeId = name.getLastElementAsString();
- exists = conn.getReferenceIdentifiers(nodeId).size() > 0;
- }
- finally
- {
- conn.close();
- }
- }
- // /$REFS/<NODE_ID>/<REF_PROP_ID>
- else if (name.size() == 3)
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- String refPropertyId = name.getLastElementAsString();
- String nodeId = (String) name.get(1);
-
- exists = conn.hasReference(nodeId, refPropertyId);
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
- }
- }
- else
- {
- exists = false;
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Unexpected Fqn asked " + name);
- }
- }
- }
- else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
- || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
- || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
- {
- // roots, like NODES, PROPS etc
- exists = true;
- }
- else
- {
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
- }
-
- return exists;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<?> getChildrenNames(Fqn fqn) throws Exception
- {
- // return child nodes names
-
- //to sub Fqn (example /$LOCKS/5/4/3)
- // if (IdTreeHelper.isSubFqn(fqn))
- // return null;
-
- Fqn name = (fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
-
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
- {
- String nodeId = (String) name.get(1);
- if (name.get(0).equals(JBossCacheStorage.NODES))
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- return conn.getChildNodeNames(nodeId);
- }
- finally
- {
- conn.close();
- }
- }
- else if (name.get(0).equals(JBossCacheStorage.REFS))
- {
- JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
- try
- {
- List<String> references = conn.getReferenceIdentifiers(nodeId);
- Set<String> result = new LinkedHashSet<String>();
- result.addAll(references);
- return result;
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- // TODO this a property on any unexpected part of cache throw Exception
- return null;
- }
- }
- else if (name.isRoot() || name.get(0).equals(Fqn.ROOT) || name.getLastElementAsString().equals("/"))
- {
- Set<String> childs = new LinkedHashSet<String>();
- childs.add(JBossCacheStorage.NODES);
- childs.add(JBossCacheStorage.PROPS);
- childs.add(JBossCacheStorage.LOCKS);
- childs.add(JBossCacheStorage.REFS);
- return childs;
- }
- else if (name.size() > 2)
- {
- // seems it is fqn like /$NODES/nodeUUID/childname[/...] or /$REFS/nodeUUID/propUUUIS[/...]
- // TODO this is unexpected part of cache throw Exception
- LOG.warn("This is unexpected FQN " + name);
- return null;
- }
- else if (name.get(0).equals(JBossCacheStorage.NODES))
- {
- // TODO should never be called
- LOG.warn("conn.getAllNodeIdentifiers()");
- return null/*conn.getAllNodeIdentifiers()*/;
- }
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
- {
- // TODO should never be called
- LOG.warn("conn.getAllPropertyIdentifiers()");
- return null/*conn.getAllPropertyIdentifiers()*/;
- }
- else if (name.get(0).equals(JBossCacheStorage.LOCKS))
- {
- // TODO return all Locks in workspace
- return new LinkedHashSet<String>();
- }
- else if (name.get(0).equals(JBossCacheStorage.REFS))
- {
- return null/*conn.getAllRefencedNodeIdentifiers()*/;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public IndividualCacheLoaderConfig getConfig()
- {
- return config;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- this.config = config;
-
- }
-
- // 2-phase TRANSACTION support
-
- /**
- * {@inheritDoc}
- */
- public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
- {
- if (onePhase)
- {
- final JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
- apply(modifications, conn);
- conn.commit(); // same immediately
- }
- else
- {
- final JDBCStorageConnection exconn = transactions.remove(tx);
- if (exconn != null)
- {
- // apply in existed connection associated with tx
- apply(modifications, exconn);
- }
- else
- {
- // open new tx conn, apply in it, save the conn
- final JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
- apply(modifications, conn);
- transactions.put(tx, conn);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void commit(Object tx) throws Exception
- {
- final WorkspaceStorageConnection conn = transactions.remove(tx);
- if (conn == null)
- {
- throw new RepositoryException("Transaction " + tx + " not found in transaction table.");
- }
-
- conn.commit();
- }
-
- /**
- * {@inheritDoc}
- */
- public void rollback(Object tx)
- {
- final WorkspaceStorageConnection conn = transactions.remove(tx);
- if (conn != null)
- {
- try
- {
- conn.rollback();
- }
- catch (Throwable e)
- {
- // TODO why we cannot throw an exception??? (throws Exception expected)
- LOG.error("Error of transaction " + tx + " rollback.", e);
- }
- }
- else
- {
- LOG.warn("Transaction " + tx + " not found in transaction table, but rollback called.");
- }
- }
-
- // SHOULD NOT BE USED methods
-
- /**
- * {@inheritDoc}
- */
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- LOG.error("The method 'put(Fqn name, Object key, Object value))' should not be called. " + name + " " + key + " "
- + value);
- throw new JDBCCacheLoaderException("The method 'put(Fqn name, Object key, Object value))' should not be called.");
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(Fqn name, Map<Object, Object> attributes) throws Exception
- {
- LOG.error("The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called. " + name + " "
- + attributes);
- throw new JDBCCacheLoaderException(
- "The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called.");
- }
-
- /**
- * {@inheritDoc}
- */
- public Object remove(Fqn fqn, Object key) throws Exception
- {
- LOG.error("The method 'remove(Fqn fqn, Object key)' should not be called. " + fqn + " " + key);
- throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn, Object key)' should not be called.");
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove(Fqn fqn) throws Exception
- {
- LOG.error("The method 'remove(Fqn fqn)' should not be called. " + fqn);
- throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn)' should not be called.");
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeData(Fqn fqn) throws Exception
- {
- LOG.error("The method 'removeData(Fqn fqn)' should not be called. " + fqn);
- throw new JDBCCacheLoaderException("The method 'removeData(Fqn fqn)' should not be called.");
- }
-
+/*
+ * 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.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.dataflow.TransientItemData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
+import org.exoplatform.services.jcr.impl.storage.jdbc.PropertyDataInfo;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 31.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class JDBCCacheLoader extends AbstractCacheLoader
+{
+ protected static final Log LOG = ExoLogger.getLogger("jcr.JDBCCacheLoader");
+
+ /**
+ * Storage connections involved in transactions.
+ */
+ protected Map<Object, JDBCStorageConnection> transactions = new ConcurrentHashMap<Object, JDBCStorageConnection>();
+
+ private IndividualCacheLoaderConfig config;
+
+ private WorkspaceDataContainer dataContainer;
+
+ public JDBCCacheLoader()
+ {
+ }
+
+ /**
+ * Init the loader DataContainer with given WorkspaceDataContainer instance.
+ *
+ * @param dataContainer WorkspaceDataContainer
+ */
+ @Inject
+ public void init(WorkspaceDataContainer dataContainer) throws RepositoryConfigurationException
+ {
+ if (this.dataContainer != null)
+ {
+ throw new RepositoryConfigurationException("Cannot set WorkspaceDataContainer twice");
+ }
+
+ this.dataContainer = dataContainer;
+ }
+
+ /**
+ * Apply all Modifications on JDBC database, but don't commit them.
+ *
+ * @param modifications List if Modification
+ * @param conn JDBCStorageConnection
+ * @throws RepositoryException if error occurs
+ */
+ protected void apply(List<Modification> modifications, JDBCStorageConnection conn) throws RepositoryException
+ {
+ for (Modification m : modifications)
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("PUT_DATA modification");
+ }
+ break;
+ case PUT_DATA_ERASE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("PUT_DATA_ERASE modification");
+ }
+ break;
+ case PUT_KEY_VALUE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("PUT_KEY_VALUE modification");
+ }
+
+ doUpdate(m, conn);
+
+ break;
+ case REMOVE_DATA :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("REMOVE_DATA modification");
+ }
+ break;
+ case REMOVE_KEY_VALUE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("REMOVE_KEY_VALUE modification");
+ }
+ break;
+ case REMOVE_NODE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("REMOVE_NODE modification");
+ }
+
+ doRemove(m, conn);
+
+ break;
+ case MOVE :
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("MOVE modification");
+ }
+ break;
+ default :
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(List<Modification> modifications) throws Exception
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Modifications list size = " + modifications.size());
+ }
+
+ JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+
+ try
+ {
+ apply(modifications, conn);
+ conn.commit();
+ }
+ catch (RepositoryException e)
+ {
+ LOG.error("RepositoryException: ", e); // TODO don't catch, but be sure it will be thrown to JCR
+ throw new RepositoryException(e);
+ }
+ catch (IllegalStateException e)
+ {
+ LOG.error("IllegalStateException: ", e); // TODO don't catch, but be sure it will be thrown to JCR
+ throw new IllegalStateException(e);
+ }
+ finally
+ {
+ if (conn != null && conn.isOpened())
+ {
+ conn.rollback();
+ }
+ }
+ }
+
+ /**
+ * Remove NodeData or PropertyData.
+ *
+ * @param modification Modification
+ * @param conn JDBCStorageConnection
+ * @throws IllegalStateException if connection closed
+ * @throws RepositoryException if error occurs
+ */
+ private void doRemove(Modification modification, JDBCStorageConnection conn) throws IllegalStateException,
+ RepositoryException
+ {
+ Fqn fqn = IdTreeHelper.buildFqn(modification.getFqn());
+
+ if (fqn.size() == 2)
+ {
+ String identifier = (String)fqn.get(1);
+
+ if (fqn.get(0).equals(JBossCacheStorage.NODES))
+ {
+ conn.deleteNode(identifier);
+ }
+ else if (fqn.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ conn.deleteProperty(identifier);
+ }
+ }
+ else
+ {
+ // remove of child node, we're not interested in such info for persistence
+ }
+ }
+
+ /**
+ * Performs ADD to NodeData and PropertyData.
+ *
+ * @param modification Modification
+ * @param conn JDBCStorageConnection
+ * @throws IllegalStateException if connection closed
+ * @throws RepositoryException if error occurs
+ */
+ private void doAdd(Modification modification, JDBCStorageConnection conn) throws IllegalStateException,
+ RepositoryException
+ {
+ if (modification.getValue() instanceof NodeData)
+ {
+ //add node data
+ conn.add((NodeData)modification.getValue());
+ }
+ else if (modification.getValue() instanceof PropertyData)
+ {
+ //add property data
+ conn.add((PropertyData)modification.getValue());
+ }
+ }
+
+ /**
+ * Performs UPDATE to NodeData or PropertyData.
+ *
+ * @param modification Modification
+ * @param conn JDBCStorageConnection
+ * @throws IllegalStateException if connection closed
+ * @throws RepositoryException if error occurs
+ */
+ private void doUpdate(Modification m, JDBCStorageConnection conn) throws IllegalStateException, RepositoryException
+ {
+ Fqn fqn = IdTreeHelper.buildFqn(m.getFqn());
+
+ if (fqn.size() == 2 && m.getValue() instanceof TransientItemData)
+ {
+ //Check flag it's mixin update for node, if this flag set we have node need to
+ TransientItemData item = (TransientItemData)m.getValue();
+
+ if ((item.getState() & TransientItemData.TRANSITIVE_PATH_UPDATED) == 0)
+ {
+ // if not a transitive update of path, update it in the database
+ if (conn.itemExists((String)fqn.get(1), item.isNode()))
+ {
+ // update if it's non transitive update
+ if (item.isNode())
+ {
+ if ((item.getState() & TransientItemData.TRANSITIVE_MIXIN_UPDATED) == 0
+ && (item.getState() & TransientItemData.TRANSITIVE_ACL_UPDATED) == 0)
+ {
+ // TODO do not handle mixin or ACL updates in db; it's a workaround - review logic in the connection
+
+ // TODO conn.rename() is used to update all the fields in DB.
+ // Original conn.update() will be matched as deprecated,
+ // and conn.rename() should be renamed to update. This
+ // is done to solve the issue, when we need to guess each
+ // time whether node is moved or just updated. This
+ // solution is used as the fastest among other.
+ conn.rename((NodeData)item);
+ }
+ }
+ else
+ {
+ //update property data
+ conn.update((PropertyData)item);
+ }
+ }
+ else
+ {
+ doAdd(m, conn);
+ }
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map<Object, Object> get(Fqn fqn) throws Exception
+ {
+ Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
+ Map<Object, Object> attrs;
+
+ if (name.size() > 1)
+ {
+ if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String nodeId = name.getLastElementAsString();
+ NodeData nodeData = (NodeData) conn.getItemData(nodeId);
+ if (nodeData != null)
+ {
+ List<PropertyDataInfo> childProps = conn.getChildProperties(nodeId);
+ if (childProps.size() <= 0)
+ {
+ throw new JDBCCacheLoaderException("FATAL Empty attributes for Node " + nodeId + " '" + name
+ + "'");
+ }
+
+ attrs = new LinkedHashMap<Object, Object>();
+ attrs.put(JBossCacheStorage.ITEM_DATA, nodeData);
+ for (PropertyDataInfo prop : childProps)
+ {
+ attrs.put(prop.getPropertyName(), prop.getPropertyId());
+ }
+ }
+ else
+ {
+ attrs = null;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
+ String parentId = (String) name.get(1);
+
+ String nodeId =
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ if (nodeId != null)
+ {
+ attrs = new LinkedHashMap<Object, Object>();
+ attrs.put(JBossCacheStorage.ITEM_ID, nodeId);
+ }
+ else
+ {
+ attrs = null;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ attrs = null;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String propertyId = name.getLastElementAsString();
+ PropertyData propertyData = (PropertyData) conn.getItemData(propertyId);
+ if (propertyData != null)
+ {
+ attrs = new LinkedHashMap<Object, Object>();
+ attrs.put(JBossCacheStorage.ITEM_DATA, propertyData);
+ }
+ else
+ {
+ attrs = null;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ attrs = null;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // get reference
+ if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ // do we have such property reference
+ String nodeID = String.valueOf(name.get(1));
+ String propID = String.valueOf(name.get(2));
+
+ if (conn.hasReference(nodeID, propID))
+ {
+ attrs = new LinkedHashMap<Object, Object>();
+ }
+ else
+ {
+ attrs = null;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ // do we have node with any reference
+ String nodeID = name.getLastElementAsString();
+ if (conn.getReferenceIdentifiers(nodeID).size() > 0)
+ {
+ attrs = new LinkedHashMap<Object, Object>();
+ }
+ else
+ {
+ attrs = null;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ attrs = null;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+
+ }
+ else
+ {
+ attrs = null;
+ if (LOG.isDebugEnabled())
+ {
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ }
+ else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
+ || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
+ || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // roots, like NODES, PROPS etc
+ attrs = new LinkedHashMap<Object, Object>();
+ }
+ else
+ {
+ LOG.warn("Unexpected Fqn asked " + name);
+ attrs = null;
+ }
+
+ return attrs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn fqn) throws Exception
+ {
+ Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
+
+ boolean exists;
+
+ if (name.size() > 1)
+ {
+ if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String nodeId = name.getLastElementAsString();
+ String nodeName = conn.getNodeName(nodeId);
+
+ if (nodeName != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
+ String parentId = (String) name.get(1);
+
+ String nodeId =
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ if (nodeId != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String propertyId = name.getLastElementAsString();
+ String propertyName = conn.getPropertyName(propertyId);
+
+ if (propertyName != null)
+ {
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // /$REFS/<NODE_ID>
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String nodeId = name.getLastElementAsString();
+ exists = conn.getReferenceIdentifiers(nodeId).size() > 0;
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ // /$REFS/<NODE_ID>/<REF_PROP_ID>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ String refPropertyId = name.getLastElementAsString();
+ String nodeId = (String) name.get(1);
+
+ exists = conn.hasReference(nodeId, refPropertyId);
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else
+ {
+ exists = false;
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Unexpected Fqn asked " + name);
+ }
+ }
+ }
+ else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
+ || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
+ || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // roots, like NODES, PROPS etc
+ exists = true;
+ }
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+
+ return exists;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<?> getChildrenNames(Fqn fqn) throws Exception
+ {
+ // return child nodes names
+
+ //to sub Fqn (example /$LOCKS/5/4/3)
+ // if (IdTreeHelper.isSubFqn(fqn))
+ // return null;
+
+ Fqn name = (fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
+
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
+ {
+ String nodeId = (String) name.get(1);
+ if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ return conn.getChildNodeNames(nodeId);
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
+ List<String> references = conn.getReferenceIdentifiers(nodeId);
+ Set<String> result = new LinkedHashSet<String>();
+ result.addAll(references);
+ return result;
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // TODO this a property on any unexpected part of cache throw Exception
+ return null;
+ }
+ }
+ else if (name.isRoot() || name.get(0).equals(Fqn.ROOT) || name.getLastElementAsString().equals("/"))
+ {
+ Set<String> childs = new LinkedHashSet<String>();
+ childs.add(JBossCacheStorage.NODES);
+ childs.add(JBossCacheStorage.PROPS);
+ childs.add(JBossCacheStorage.LOCKS);
+ childs.add(JBossCacheStorage.REFS);
+ return childs;
+ }
+ else if (name.size() > 2)
+ {
+ // seems it is fqn like /$NODES/nodeUUID/childname[/...] or /$REFS/nodeUUID/propUUUIS[/...]
+ // TODO this is unexpected part of cache throw Exception
+ LOG.warn("This is unexpected FQN " + name);
+ return null;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // TODO should never be called
+ LOG.warn("conn.getAllNodeIdentifiers()");
+ return null/*conn.getAllNodeIdentifiers()*/;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ // TODO should never be called
+ LOG.warn("conn.getAllPropertyIdentifiers()");
+ return null/*conn.getAllPropertyIdentifiers()*/;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.LOCKS))
+ {
+ // TODO return all Locks in workspace
+ return new LinkedHashSet<String>();
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ return null/*conn.getAllRefencedNodeIdentifiers()*/;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config = config;
+
+ }
+
+ // 2-phase TRANSACTION not support
+
+ /**
+ * {@inheritDoc}
+ */
+ public void prepare(Object tx, List<Modification> modifications, boolean onePhase) throws Exception
+ {
+ final JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ apply(modifications, conn);
+ conn.commit();
+
+ /*if (onePhase)
+ {
+ final JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ apply(modifications, conn);
+ conn.commit(); // same immediately
+ }
+ else
+ {
+ final JDBCStorageConnection exconn = transactions.remove(tx);
+ if (exconn != null)
+ {
+ // apply in existed connection associated with tx
+ apply(modifications, exconn);
+ }
+ else
+ {
+ // open new tx conn, apply in it, save the conn
+ final JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
+ apply(modifications, conn);
+ transactions.put(tx, conn);
+ }
+ }*/
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit(Object tx) throws Exception
+ {
+ /*final WorkspaceStorageConnection conn = transactions.remove(tx);
+ if (conn == null)
+ {
+ throw new RepositoryException("Transaction " + tx + " not found in transaction table.");
+ }
+
+ conn.commit();*/
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback(Object tx)
+ {
+ /*final WorkspaceStorageConnection conn = transactions.remove(tx);
+ if (conn != null)
+ {
+ try
+ {
+ conn.rollback();
+ }
+ catch (Throwable e)
+ {
+ // TODO why we cannot throw an exception??? (throws Exception expected)
+ LOG.error("Error of transaction " + tx + " rollback.", e);
+ }
+ }
+ else
+ {
+ LOG.warn("Transaction " + tx + " not found in transaction table, but rollback called.");
+ }*/
+ }
+
+ // SHOULD NOT BE USED methods
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ LOG.error("The method 'put(Fqn name, Object key, Object value))' should not be called. " + name + " " + key + " "
+ + value);
+ throw new JDBCCacheLoaderException("The method 'put(Fqn name, Object key, Object value))' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn name, Map<Object, Object> attributes) throws Exception
+ {
+ LOG.error("The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called. " + name + " "
+ + attributes);
+ throw new JDBCCacheLoaderException(
+ "The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ LOG.error("The method 'remove(Fqn fqn, Object key)' should not be called. " + fqn + " " + key);
+ throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn, Object key)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn fqn) throws Exception
+ {
+ LOG.error("The method 'remove(Fqn fqn)' should not be called. " + fqn);
+ throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn fqn) throws Exception
+ {
+ LOG.error("The method 'removeData(Fqn fqn)' should not be called. " + fqn);
+ throw new JDBCCacheLoaderException("The method 'removeData(Fqn fqn)' should not be called.");
+ }
+
}
\ No newline at end of file
16 years, 7 months
exo-jcr SVN: r950 - in jcr/branches/1.12.0-OPT/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration and 3 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2009-12-08 10:53:12 -0500 (Tue, 08 Dec 2009)
New Revision: 950
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java
Log:
EXOJCR-939: remove setters from code
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -354,22 +354,22 @@
private void initStorage(NodeData nsSystem, boolean addACL) throws RepositoryException
{
PlainChangesLog changesLog = new PlainChangesLogImpl();
- TransientNodeData exoNamespaces =
- TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED);
+ TransientNodeData exoNamespaces;
- TransientPropertyData primaryType =
- TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
- new TransientValueData(exoNamespaces.getPrimaryTypeName()));
-
- changesLog.add(ItemState.createAddedState(exoNamespaces)).add(ItemState.createAddedState(primaryType));
-
if (addACL)
{
AccessControlList acl = new AccessControlList();
-
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
- exoNamespaces.setMixinTypeNames(mixins);
+ exoNamespaces =
+ TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED, mixins);
+
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
+ false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(exoNamespaces)).add(ItemState.createAddedState(primaryType));
+
// jcr:mixinTypes
List<ValueData> mixValues = new ArrayList<ValueData>();
for (InternalQName mixin : mixins)
@@ -398,7 +398,18 @@
ItemState.createAddedState(exoPerms));
changesLog.add(new ItemState(exoNamespaces, ItemState.MIXIN_CHANGED, false, null));
}
+ else
+ {
+ exoNamespaces =
+ TransientNodeData.createNodeData(nsSystem, Constants.EXO_NAMESPACES, Constants.NT_UNSTRUCTURED);
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(exoNamespaces, Constants.JCR_PRIMARYTYPE, PropertyType.NAME,
+ false, new TransientValueData(exoNamespaces.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(exoNamespaces)).add(ItemState.createAddedState(primaryType));
+ }
+
nsRoot = exoNamespaces;
dataManager.save(new TransactionChangesLog(changesLog));
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -1642,10 +1642,13 @@
session.getActionHandler().preRemoveMixin(this, name);
- TransientPropertyData prop =
+ TransientPropertyData propData =
(TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MIXINTYPES, 0));
- prop.setValues(values);
+ // create new property data with new values
+ TransientPropertyData prop =
+ new TransientPropertyData(propData.getQPath(), propData.getIdentifier(), propData.getPersistedVersion(),
+ propData.getType(), propData.getParentIdentifier(), propData.isMultiValued(), values);
NodeTypeDataManager ntmanager = session.getWorkspace().getNodeTypesHolder();
@@ -2409,9 +2412,12 @@
{
newData = ((TransientNodeData)sdata).cloneAsSibling(sameNameIndex);
}
- // crate update
- ((TransientNodeData)newData).setOrderNumber(j);
+ // create update
+ newData =
+ new TransientNodeData(newData.getQPath(), newData.getIdentifier(), newData.getPersistedVersion(), newData
+ .getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(), newData.getACL());
+
/*
* 8.3.7.8 Re-ordering a set of Child Nodes. When an orderBefore(A, B) is
* performed, an implementation must generate a NODE_REMOVED for node A
@@ -2856,6 +2862,11 @@
private void setACL(AccessControlList acl)
{
+ // NodeData nodeData = (NodeData)data;
+ // data =
+ // new TransientNodeData(data.getQPath(), data.getIdentifier(), data.getPersistedVersion(), nodeData
+ // .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
+ // .getParentIdentifier(), acl);
((NodeData)data).setACL(acl);
}
@@ -2863,6 +2874,12 @@
{
InternalQName[] mixins = new InternalQName[newMixin.size()];
newMixin.toArray(mixins);
+
+ // NodeData nodeData = (NodeData)data;
+ // data =
+ // new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
+ // .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());
+
((TransientNodeData)data).setMixinTypeNames(mixins);
dataManager.update(new ItemState(data, ItemState.MIXIN_CHANGED, false, null), false);
}
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -190,21 +190,11 @@
private NodeData initRootNode(InternalQName rootNodeType) throws RepositoryException
{
+ boolean addACL = !accessControlType.equals(AccessControlPolicy.DISABLE);
+
PlainChangesLog changesLog = new PlainChangesLogImpl();
+ TransientNodeData rootNode;
- TransientNodeData rootNode =
- new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, -1, rootNodeType, new InternalQName[0], 0,
- null, new AccessControlList());
- changesLog.add(new ItemState(rootNode, ItemState.ADDED, false, null));
-
- TransientPropertyData primaryType =
- new TransientPropertyData(QPath.makeChildPath(rootNode.getQPath(), Constants.JCR_PRIMARYTYPE), IdGenerator
- .generate(), -1, PropertyType.NAME, rootNode.getIdentifier(), false, new TransientValueData(rootNodeType));
-
- changesLog.add(new ItemState(primaryType, ItemState.ADDED, false, null)); //
-
- boolean addACL = !accessControlType.equals(AccessControlPolicy.DISABLE);
-
if (addACL)
{
AccessControlList acl = new AccessControlList();
@@ -215,11 +205,19 @@
acl.addPermissions(rootPermissions);
}
- rootNode.setACL(acl);
-
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
- rootNode.setMixinTypeNames(mixins);
+ rootNode =
+ new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, -1, rootNodeType, mixins, 0, null, acl);
+ changesLog.add(new ItemState(rootNode, ItemState.ADDED, false, null));
+
+ TransientPropertyData primaryType =
+ new TransientPropertyData(QPath.makeChildPath(rootNode.getQPath(), Constants.JCR_PRIMARYTYPE), IdGenerator
+ .generate(), -1, PropertyType.NAME, rootNode.getIdentifier(), false,
+ new TransientValueData(rootNodeType));
+
+ changesLog.add(new ItemState(primaryType, ItemState.ADDED, false, null)); //
+
// jcr:mixinTypes
List<ValueData> mixValues = new ArrayList<ValueData>();
for (InternalQName mixin : mixins)
@@ -248,35 +246,46 @@
ItemState.createAddedState(exoPerms));
changesLog.add(new ItemState(rootNode, ItemState.MIXIN_CHANGED, false, null));
}
+ else
+ {
+ rootNode =
+ new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, -1, rootNodeType, new InternalQName[0], 0,
+ null, new AccessControlList());
+ changesLog.add(new ItemState(rootNode, ItemState.ADDED, false, null));
+ TransientPropertyData primaryType =
+ new TransientPropertyData(QPath.makeChildPath(rootNode.getQPath(), Constants.JCR_PRIMARYTYPE), IdGenerator
+ .generate(), -1, PropertyType.NAME, rootNode.getIdentifier(), false,
+ new TransientValueData(rootNodeType));
+ changesLog.add(new ItemState(primaryType, ItemState.ADDED, false, null)); //
+ }
+
dataManager.save(new TransactionChangesLog(changesLog));
-
return rootNode;
}
private NodeData initJcrSystemNode(NodeData root) throws RepositoryException
{
+ boolean addACL = !accessControlType.equals(AccessControlPolicy.DISABLE);
PlainChangesLog changesLog = new PlainChangesLogImpl();
+ TransientNodeData jcrSystem;
- TransientNodeData jcrSystem =
- TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED, Constants.SYSTEM_UUID);
-
- TransientPropertyData primaryType =
- TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
- new TransientValueData(jcrSystem.getPrimaryTypeName()));
-
- changesLog.add(ItemState.createAddedState(jcrSystem)).add(ItemState.createAddedState(primaryType));
-
- boolean addACL = !accessControlType.equals(AccessControlPolicy.DISABLE);
-
if (addACL)
{
AccessControlList acl = new AccessControlList();
-
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
- jcrSystem.setMixinTypeNames(mixins);
+ jcrSystem =
+ TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED, mixins,
+ Constants.SYSTEM_UUID);
+
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrSystem.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrSystem)).add(ItemState.createAddedState(primaryType));
+
// jcr:mixinTypes
List<ValueData> mixValues = new ArrayList<ValueData>();
for (InternalQName mixin : mixins)
@@ -305,7 +314,19 @@
ItemState.createAddedState(exoPerms));
changesLog.add(new ItemState(jcrSystem, ItemState.MIXIN_CHANGED, false, null));
}
+ else
+ {
+ jcrSystem =
+ TransientNodeData.createNodeData(root, Constants.JCR_SYSTEM, Constants.NT_UNSTRUCTURED,
+ Constants.SYSTEM_UUID);
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrSystem, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrSystem.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrSystem)).add(ItemState.createAddedState(primaryType));
+ }
+
// init version storage
TransientNodeData versionStorageNodeData =
TransientNodeData.createNodeData(jcrSystem, Constants.JCR_VERSIONSTORAGE, Constants.EXO_VERSIONSTORAGE,
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JcrNodeTypeDataPersister.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -153,25 +153,25 @@
public NodeData initNodetypesRoot(NodeData nsSystem, boolean addACL) throws RepositoryException
{
PlainChangesLog changesLog = new PlainChangesLogImpl();
+ TransientNodeData jcrNodetypes;
long start = System.currentTimeMillis();
- TransientNodeData jcrNodetypes =
- TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED,
- Constants.NODETYPESROOT_UUID);
-
- TransientPropertyData primaryType =
- TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
- new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
-
- changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
-
if (addACL)
{
AccessControlList acl = new AccessControlList();
InternalQName[] mixins = new InternalQName[]{Constants.EXO_OWNEABLE, Constants.EXO_PRIVILEGEABLE};
- jcrNodetypes.setMixinTypeNames(mixins);
+ jcrNodetypes =
+ TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED, mixins,
+ Constants.NODETYPESROOT_UUID);
+
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
+
// jcr:mixinTypes
List<ValueData> mixValues = new ArrayList<ValueData>();
for (InternalQName mixin : mixins)
@@ -200,7 +200,19 @@
ItemState.createAddedState(exoPerms));
changesLog.add(new ItemState(jcrNodetypes, ItemState.MIXIN_CHANGED, false, null));
}
+ else
+ {
+ jcrNodetypes =
+ TransientNodeData.createNodeData(nsSystem, Constants.JCR_NODETYPES, Constants.NT_UNSTRUCTURED,
+ Constants.NODETYPESROOT_UUID);
+ TransientPropertyData primaryType =
+ TransientPropertyData.createPropertyData(jcrNodetypes, Constants.JCR_PRIMARYTYPE, PropertyType.NAME, false,
+ new TransientValueData(jcrNodetypes.getPrimaryTypeName()));
+
+ changesLog.add(ItemState.createAddedState(jcrNodetypes)).add(ItemState.createAddedState(primaryType));
+ }
+
if (log.isDebugEnabled())
log.debug("/jcr:system/jcr:nodetypes is created, creation time: " + (System.currentTimeMillis() - start)
+ " ms");
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/TransientNodeData.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -223,6 +223,25 @@
* @return
*/
public static TransientNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
+ InternalQName[] mixinTypesName)
+ {
+ TransientNodeData nodeData = null;
+ QPath path = QPath.makeChildPath(parent.getQPath(), name);
+ nodeData =
+ new TransientNodeData(path, IdGenerator.generate(), -1, primaryTypeName, mixinTypesName, 0, parent
+ .getIdentifier(), parent.getACL());
+ return nodeData;
+ }
+
+ /**
+ * Factory method
+ *
+ * @param parent
+ * @param name
+ * @param primaryTypeName
+ * @return
+ */
+ public static TransientNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
int index)
{
TransientNodeData nodeData = null;
@@ -242,6 +261,25 @@
* @return
*/
public static TransientNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
+ int index, int orderNumber)
+ {
+ TransientNodeData nodeData = null;
+ QPath path = QPath.makeChildPath(parent.getQPath(), name, index);
+ nodeData =
+ new TransientNodeData(path, IdGenerator.generate(), -1, primaryTypeName, new InternalQName[0], orderNumber,
+ parent.getIdentifier(), parent.getACL());
+ return nodeData;
+ }
+
+ /**
+ * Factory method
+ *
+ * @param parent
+ * @param name
+ * @param primaryTypeName
+ * @return
+ */
+ public static TransientNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
String identifier)
{
TransientNodeData nodeData = null;
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/DocumentViewImporter.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -142,8 +142,7 @@
{
TransientNodeData nodeData =
TransientNodeData.createNodeData(getParent(), Constants.JCR_XMLTEXT, Constants.NT_UNSTRUCTURED,
- getNodeIndex(getParent(), Constants.JCR_XMLTEXT, null));
- nodeData.setOrderNumber(getNextChildOrderNum(getParent()));
+ getNodeIndex(getParent(), Constants.JCR_XMLTEXT, null), getNextChildOrderNum(getParent()));
changesLog.add(new ItemState(nodeData, ItemState.ADDED, true, getAncestorToSave()));
if (log.isDebugEnabled())
Modified: jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java
===================================================================
--- jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java 2009-12-08 14:49:36 UTC (rev 949)
+++ jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/BaseVersionImplTest.java 2009-12-08 15:53:12 UTC (rev 950)
@@ -354,8 +354,8 @@
versionableLog.add(ItemState.createAddedState(vChildNode1_node5_propertyVersioned));
NodeData vChildNode1_node5_nodeVersioned =
- TransientNodeData.createNodeData(vChildNode1_node5, NODE_VERSIONED, Constants.NT_UNSTRUCTURED);
- ((TransientNodeData)vChildNode1_node5_nodeVersioned).setMixinTypeNames(mixVersionable);
+ TransientNodeData.createNodeData(vChildNode1_node5, NODE_VERSIONED, Constants.NT_UNSTRUCTURED,
+ mixVersionable);
versionableLog.add(ItemState.createAddedState(vChildNode1_node5_nodeVersioned));
PropertyData vChildNode1_node5_node1_property2 =
TransientPropertyData.createPropertyData(vChildNode1_node5_nodeVersioned, propertyName2, 0, false,
16 years, 7 months
exo-jcr SVN: r949 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-08 09:49:36 -0500 (Tue, 08 Dec 2009)
New Revision: 949
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
Log:
EXOJCR-291: Fixed cluster query tests.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-08 14:47:25 UTC (rev 948)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-08 14:49:36 UTC (rev 949)
@@ -47,7 +47,6 @@
public void testAssert() throws RepositoryException, IOException
{
System.out.println("Start asserting....");
- int datum = System.in.read();
Node doc1 = root.getNode("document1");
Node doc2 = root.getNode("document2");
16 years, 7 months
exo-jcr SVN: r948 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-08 09:47:25 -0500 (Tue, 08 Dec 2009)
New Revision: 948
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
Log:
EXOJCR-291: Fixed cluster query tests.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-08 14:38:08 UTC (rev 947)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-08 14:47:25 UTC (rev 948)
@@ -46,11 +46,9 @@
{
public void testAssert() throws RepositoryException, IOException
{
- System.out.println("Press enter to start asserting....");
+ System.out.println("Start asserting....");
+ int datum = System.in.read();
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
- String sample = br.readLine();
-
Node doc1 = root.getNode("document1");
Node doc2 = root.getNode("document2");
@@ -70,8 +68,16 @@
long xpathsize = xres.getNodes().getSize();
assertEquals(2, xpathsize);
checkResult(xres, new Node[]{doc1, doc2});
- System.out.println("Done! Press enter to finish...");
- br.readLine();
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(1024*1024*1024);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
protected void checkResult(QueryResult result, Node[] nodes) throws RepositoryException
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java 2009-12-08 14:38:08 UTC (rev 947)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java 2009-12-08 14:47:25 UTC (rev 948)
@@ -39,11 +39,8 @@
{
public void testPrepareNodes() throws RepositoryException, IOException
{
- System.out.println("Press enter to start preparing....");
+ System.out.println("preparing....");
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
- String sample = br.readLine();
-
root.addNode("simplenode", "nt:unstructured");
Node doc1 = root.addNode("document1", "nt:file");
@@ -59,10 +56,16 @@
cont.setProperty("jcr:lastModified", Calendar.getInstance());
cont.setProperty("jcr:encoding", "UTF-8");
cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
-
session.save();
-
- System.out.println("Done! Press enter to finish...");
- br.readLine();
+ System.out.println("Done!");
+ try
+ {
+ Thread.sleep(1024*1024*1024);
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
}
16 years, 7 months
exo-jcr SVN: r947 - in jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab: cluster and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-12-08 09:38:08 -0500 (Tue, 08 Dec 2009)
New Revision: 947
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
Log:
EXOJCR-291: Added experimental cluster query tests.
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java 2009-12-08 14:38:08 UTC (rev 947)
@@ -0,0 +1,132 @@
+/*
+ * 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.lab.cluster;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestQueryAssert.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestQueryAssert extends JcrAPIBaseTest
+{
+ public void testAssert() throws RepositoryException, IOException
+ {
+ System.out.println("Press enter to start asserting....");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ String sample = br.readLine();
+
+ Node doc1 = root.getNode("document1");
+ Node doc2 = root.getNode("document2");
+
+ // make SQL query
+ QueryManager qman = this.workspace.getQueryManager();
+
+ Query q = qman.createQuery("SELECT * FROM nt:file ", Query.SQL);
+ QueryResult res = q.execute();
+ long sqlsize = res.getNodes().getSize();
+ assertEquals(2, sqlsize);
+ checkResult(res, new Node[]{doc1, doc2});
+
+ //make XPath query
+
+ Query xq = qman.createQuery("//element(*,nt:file)", Query.XPATH);
+ QueryResult xres = xq.execute();
+ long xpathsize = xres.getNodes().getSize();
+ assertEquals(2, xpathsize);
+ checkResult(xres, new Node[]{doc1, doc2});
+ System.out.println("Done! Press enter to finish...");
+ br.readLine();
+ }
+
+ protected void checkResult(QueryResult result, Node[] nodes) throws RepositoryException
+ {
+ // collect paths
+
+ String[] columnNames = result.getColumnNames();
+ String[][] vals = new String[(int)result.getNodes().getSize()][result.getColumnNames().length];
+
+ RowIterator rit = result.getRows();
+ int j = 0;
+ while (rit.hasNext())
+ {
+ Row r = rit.nextRow();
+ Value[] v = r.getValues();
+ for (int i = 0; i < v.length; i++)
+ {
+ vals[j][i] = (v[i] != null) ? v[i].getString() : "null";
+ }
+ j++;
+ }
+
+ Set<String> expectedPaths = new HashSet<String>();
+ for (int i = 0; i < nodes.length; i++)
+ {
+ expectedPaths.add(nodes[i].getPath());
+ }
+ Set<String> resultPaths = new HashSet<String>();
+ for (NodeIterator it = result.getNodes(); it.hasNext();)
+ {
+ resultPaths.add(it.nextNode().getPath());
+ }
+
+ comparePaths(expectedPaths, resultPaths, false);
+ }
+
+ private void comparePaths(Set<String> expectedPaths, Set<String> resultPaths, boolean canContainMore)
+ {
+ // check if all expected are in result
+ for (Iterator<String> it = expectedPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not part of the result set", resultPaths.contains(path));
+ }
+
+ if (!canContainMore)
+ {
+ // check result does not contain more than expected
+
+ for (Iterator<String> it = resultPaths.iterator(); it.hasNext();)
+ {
+ String path = it.next();
+ assertTrue(path + " is not expected to be part of the result set. " + " Total size:" + resultPaths.size(),
+ expectedPaths.contains(path));
+ }
+ }
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryAssert.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java 2009-12-08 14:38:08 UTC (rev 947)
@@ -0,0 +1,68 @@
+/*
+ * 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.lab.cluster;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id: TestQueryPrepare.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
+ *
+ */
+public class TestQueryPrepare extends JcrAPIBaseTest
+{
+ public void testPrepareNodes() throws RepositoryException, IOException
+ {
+ System.out.println("Press enter to start preparing....");
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
+ String sample = br.readLine();
+
+ root.addNode("simplenode", "nt:unstructured");
+
+ Node doc1 = root.addNode("document1", "nt:file");
+ NodeImpl cont = (NodeImpl)doc1.addNode("jcr:content", "nt:resource");
+ cont.setProperty("jcr:mimeType", "text/plain");
+ cont.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont.setProperty("jcr:encoding", "UTF-8");
+ cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+
+ Node doc2 = root.addNode("document2", "nt:file");
+ cont = (NodeImpl)doc2.addNode("jcr:content", "nt:resource");
+ cont.setProperty("jcr:mimeType", "text/plain");
+ cont.setProperty("jcr:lastModified", Calendar.getInstance());
+ cont.setProperty("jcr:encoding", "UTF-8");
+ cont.setProperty("jcr:data", new ByteArrayInputStream("".getBytes()));
+
+ session.save();
+
+ System.out.println("Done! Press enter to finish...");
+ br.readLine();
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/lab/cluster/TestQueryPrepare.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 7 months
exo-jcr SVN: r946 - jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-12-08 08:49:58 -0500 (Tue, 08 Dec 2009)
New Revision: 946
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws1.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws2.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws3.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws1.xml
jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws2.xml
Log:
EXOJCR-199: updated config for cluster
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,7 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1_ws">
-
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
@@ -28,7 +28,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34521" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34521" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
@@ -48,11 +48,12 @@
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
fetchPersistentState="true" ignoreModifications="false"
purgeOnStartup="false">
@@ -62,7 +63,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws1.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws1.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,6 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1_ws1">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
@@ -28,7 +29,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34522" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34522" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
@@ -48,13 +49,14 @@
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -62,7 +64,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws2.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws2.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws2.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,6 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1_ws2">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
@@ -28,7 +29,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34523" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34523" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
@@ -48,13 +49,14 @@
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -62,7 +64,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws3.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws3.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1_ws3.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,6 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1_ws3">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!--UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
@@ -28,7 +29,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34524" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34524" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
@@ -48,13 +49,15 @@
</jgroupsConfig>
<sync />
+
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -62,7 +65,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,6 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1tck_ws">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!-- UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
@@ -28,7 +29,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34531" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34531" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
@@ -47,13 +48,14 @@
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -61,7 +63,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws1.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws1.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws1.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,7 +7,9 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1tck_ws1">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
+
<jgroupsConfig>
<!-- UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
@@ -28,7 +30,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34532" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34532" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
@@ -47,13 +49,14 @@
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -61,7 +64,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws2.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws2.xml 2009-12-08 13:32:32 UTC (rev 945)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader_db1tck_ws2.xml 2009-12-08 13:49:58 UTC (rev 946)
@@ -7,6 +7,7 @@
transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
<clustering mode="replication" clusterName="JBoss-Cache-Cluster_db1tck_ws2">
+ <stateRetrieval timeout="20000" fetchInMemoryState="false" />
<jgroupsConfig>
<!-- UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
@@ -28,7 +29,7 @@
oob_thread_pool.enabled="true" oob_thread_pool.min_threads="1" oob_thread_pool.max_threads="8" oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="100" oob_thread_pool.rejection_policy="run" />
- <MPING timeout="2000" num_initial_members="3" mcast_port="34533" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
+ <MPING timeout="2000" num_initial_members="2" mcast_port="34533" bind_addr="127.0.0.1" mcast_addr="224.0.0.1" />
<MERGE2 max_interval="30000" min_interval="10000"/>
<FD_SOCK/>
@@ -41,19 +42,20 @@
<pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
view_bundling="true"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
<sync />
+
<!-- Alternatively, to use async replication, comment out the element above and uncomment the element below. -->
<!-- <async /> -->
</clustering>
- <loaders passivation="false" shared="false">
+ <loaders passivation="false" shared="true">
<!-- loader class="org.jboss.cache.loader.FileCacheLoader" async="false"
- fetchPersistentState="true" ignoreModifications="false"
+ fetchPersistentState="false" ignoreModifications="false"
purgeOnStartup="false">
<properties>
location=/tmp/test-jboss-cache/proxy
@@ -61,7 +63,7 @@
</loader -->
<loader class="org.exoplatform.services.jcr.impl.storage.jbosscache.JDBCCacheLoader"
- async="false" fetchPersistentState="true" ignoreModifications="false" purgeOnStartup="false">
+ async="false" fetchPersistentState="false" ignoreModifications="false" purgeOnStartup="false">
<properties>
</properties>
</loader>
16 years, 7 months
exo-jcr SVN: r945 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-12-08 08:32:32 -0500 (Tue, 08 Dec 2009)
New Revision: 945
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-293 : The JDBCCacheLoader was changed. The open connection to DB on demand.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 13:31:21 UTC (rev 944)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-12-08 13:32:32 UTC (rev 945)
@@ -305,26 +305,25 @@
Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
Map<Object, Object> attrs;
- JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
- try
+ if (name.size() > 1)
{
-
- if (name.size() > 1)
+ if (name.get(0).equals(JBossCacheStorage.NODES))
{
- if (name.get(0).equals(JBossCacheStorage.NODES))
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
{
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
String nodeId = name.getLastElementAsString();
- NodeData nodeData = (NodeData)conn.getItemData(nodeId);
+ NodeData nodeData = (NodeData) conn.getItemData(nodeId);
if (nodeData != null)
{
List<PropertyDataInfo> childProps = conn.getChildProperties(nodeId);
if (childProps.size() <= 0)
{
throw new JDBCCacheLoaderException("FATAL Empty attributes for Node " + nodeId + " '" + name
- + "'");
+ + "'");
}
attrs = new LinkedHashMap<Object, Object>();
@@ -339,14 +338,22 @@
attrs = null;
}
}
- // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
- else if (name.size() == 3)
+ finally
{
+ conn.close();
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
- String parentId = (String)name.get(1);
+ String parentId = (String) name.get(1);
String nodeId =
- conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
if (nodeId != null)
{
attrs = new LinkedHashMap<Object, Object>();
@@ -357,19 +364,27 @@
attrs = null;
}
}
- else
+ finally
{
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
}
- // /$PROPS/<PROPERTY_ID>
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ else
{
- if (name.size() == 2)
+ attrs = null;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
String propertyId = name.getLastElementAsString();
- PropertyData propertyData = (PropertyData)conn.getItemData(propertyId);
+ PropertyData propertyData = (PropertyData) conn.getItemData(propertyId);
if (propertyData != null)
{
attrs = new LinkedHashMap<Object, Object>();
@@ -380,18 +395,25 @@
attrs = null;
}
}
- else
+ finally
{
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
}
- else if (name.get(0).equals(JBossCacheStorage.REFS))
+ else
{
- // get reference
- if (name.size() == 3)
+ attrs = null;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // get reference
+ if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
-
// do we have such property reference
String nodeID = String.valueOf(name.get(1));
String propID = String.valueOf(name.get(2));
@@ -405,8 +427,16 @@
attrs = null;
}
}
- else if (name.size() == 2)
+ finally
{
+ conn.close();
+ }
+ }
+ else if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
// do we have node with any reference
String nodeID = name.getLastElementAsString();
if (conn.getReferenceIdentifiers(nodeID).size() > 0)
@@ -418,39 +448,39 @@
attrs = null;
}
}
- else
+ finally
{
- attrs = null;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
-
}
else
{
attrs = null;
- if (LOG.isDebugEnabled())
- {
- LOG.warn("Unexpected Fqn asked " + name);
- }
+ LOG.warn("Unexpected Fqn asked " + name);
}
+
}
- else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
- || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
- || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
- {
- // roots, like NODES, PROPS etc
- attrs = new LinkedHashMap<Object, Object>();
- }
else
{
- LOG.warn("Unexpected Fqn asked " + name);
attrs = null;
+ if (LOG.isDebugEnabled())
+ {
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
}
}
- finally
+ else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
+ || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
+ || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
{
- conn.close();
+ // roots, like NODES, PROPS etc
+ attrs = new LinkedHashMap<Object, Object>();
}
+ else
+ {
+ LOG.warn("Unexpected Fqn asked " + name);
+ attrs = null;
+ }
return attrs;
}
@@ -460,20 +490,19 @@
*/
public boolean exists(Fqn fqn) throws Exception
{
- JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
-
Fqn name = (fqn.size() > 1 ? IdTreeHelper.buildFqn(fqn) : fqn);
boolean exists;
- try
+ if (name.size() > 1)
{
- if (name.size() > 1)
+ if (name.get(0).equals(JBossCacheStorage.NODES))
{
- if (name.get(0).equals(JBossCacheStorage.NODES))
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
{
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
String nodeId = name.getLastElementAsString();
String nodeName = conn.getNodeName(nodeId);
@@ -487,14 +516,22 @@
exists = false;
}
}
- // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
- else if (name.size() == 3)
+ finally
{
+ conn.close();
+ }
+ }
+ // /$NODES/<NODE_ID>/<SUB_NODE_NAME>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
QPathEntry childNodeName = QPathEntry.parse(name.getLastElementAsString());
- String parentId = (String)name.get(1);
+ String parentId = (String) name.get(1);
String nodeId =
- conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
+ conn.getNodeIdentifier(parentId, childNodeName.getAsString(false), childNodeName.getIndex());
if (nodeId != null)
{
exists = true;
@@ -504,16 +541,24 @@
exists = false;
}
}
- else
+ finally
{
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
}
- // /$PROPS/<PROPERTY_ID>
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ else
{
- if (name.size() == 2)
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ // /$PROPS/<PROPERTY_ID>
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
String propertyId = name.getLastElementAsString();
String propertyName = conn.getPropertyName(propertyId);
@@ -527,60 +572,76 @@
exists = false;
}
}
- else
+ finally
{
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
}
- else if (name.get(0).equals(JBossCacheStorage.REFS))
+ else
{
- // /$REFS/<NODE_ID>
- if (name.size() == 2)
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ // /$REFS/<NODE_ID>
+ if (name.size() == 2)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
String nodeId = name.getLastElementAsString();
exists = conn.getReferenceIdentifiers(nodeId).size() > 0;
}
- // /$REFS/<NODE_ID>/<REF_PROP_ID>
- else if (name.size() == 3)
+ finally
{
+ conn.close();
+ }
+ }
+ // /$REFS/<NODE_ID>/<REF_PROP_ID>
+ else if (name.size() == 3)
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
String refPropertyId = name.getLastElementAsString();
- String nodeId = (String)name.get(1);
+ String nodeId = (String) name.get(1);
exists = conn.hasReference(nodeId, refPropertyId);
}
- else
+ finally
{
- exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
+ conn.close();
}
}
else
{
exists = false;
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Unexpected Fqn asked " + name);
- }
+ LOG.warn("Unexpected Fqn asked " + name);
}
}
- else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
- || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
- || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
- {
- // roots, like NODES, PROPS etc
- exists = true;
- }
else
{
exists = false;
- LOG.warn("Unexpected Fqn asked " + name);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Unexpected Fqn asked " + name);
+ }
}
}
- finally
+ else if (name.isRoot() || name.equals(Fqn.ROOT) || name.getLastElementAsString().equals("/")
+ || name.get(0).equals(JBossCacheStorage.PROPS) || name.get(0).equals(JBossCacheStorage.NODES)
+ || name.get(0).equals(JBossCacheStorage.LOCKS) || name.get(0).equals(JBossCacheStorage.REFS))
{
- conn.close();
+ // roots, like NODES, PROPS etc
+ exists = true;
}
+ else
+ {
+ exists = false;
+ LOG.warn("Unexpected Fqn asked " + name);
+ }
return exists;
}
@@ -598,77 +659,84 @@
Fqn name = (fqn.size() >= 2 ? IdTreeHelper.buildFqn(fqn) : fqn);
- JDBCStorageConnection conn = (JDBCStorageConnection)dataContainer.openConnection();
- try
+ // /$NODES/<NODE_ID>
+ if (name.size() == 2)
{
- // /$NODES/<NODE_ID>
- if (name.size() == 2)
+ String nodeId = (String) name.get(1);
+ if (name.get(0).equals(JBossCacheStorage.NODES))
{
- String nodeId = (String)name.get(1);
- if (name.get(0).equals(JBossCacheStorage.NODES))
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
{
return conn.getChildNodeNames(nodeId);
}
- else if (name.get(0).equals(JBossCacheStorage.REFS))
+ finally
{
+ conn.close();
+ }
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ JDBCStorageConnection conn = (JDBCStorageConnection) dataContainer.openConnection();
+ try
+ {
List<String> references = conn.getReferenceIdentifiers(nodeId);
Set<String> result = new LinkedHashSet<String>();
result.addAll(references);
return result;
}
- else
+ finally
{
- // TODO this a property on any unexpected part of cache throw Exception
- return null;
+ conn.close();
}
}
- else if (name.isRoot() || name.get(0).equals(Fqn.ROOT) || name.getLastElementAsString().equals("/"))
- {
- Set<String> childs = new LinkedHashSet<String>();
- childs.add(JBossCacheStorage.NODES);
- childs.add(JBossCacheStorage.PROPS);
- childs.add(JBossCacheStorage.LOCKS);
- childs.add(JBossCacheStorage.REFS);
- return childs;
- }
- else if (name.size() > 2)
- {
- // seems it is fqn like /$NODES/nodeUUID/childname[/...] or /$REFS/nodeUUID/propUUUIS[/...]
- // TODO this is unexpected part of cache throw Exception
- LOG.warn("This is unexpected FQN " + name);
- return null;
- }
- else if (name.get(0).equals(JBossCacheStorage.NODES))
- {
- // TODO should never be called
- LOG.warn("conn.getAllNodeIdentifiers()");
- return null/*conn.getAllNodeIdentifiers()*/;
- }
- else if (name.get(0).equals(JBossCacheStorage.PROPS))
- {
- // TODO should never be called
- LOG.warn("conn.getAllPropertyIdentifiers()");
- return null/*conn.getAllPropertyIdentifiers()*/;
- }
- else if (name.get(0).equals(JBossCacheStorage.LOCKS))
- {
- // TODO return all Locks in workspace
- return new LinkedHashSet<String>();
- }
- else if (name.get(0).equals(JBossCacheStorage.REFS))
- {
- return null/*conn.getAllRefencedNodeIdentifiers()*/;
- }
else
{
+ // TODO this a property on any unexpected part of cache throw Exception
return null;
}
}
- finally
+ else if (name.isRoot() || name.get(0).equals(Fqn.ROOT) || name.getLastElementAsString().equals("/"))
{
- conn.close();
+ Set<String> childs = new LinkedHashSet<String>();
+ childs.add(JBossCacheStorage.NODES);
+ childs.add(JBossCacheStorage.PROPS);
+ childs.add(JBossCacheStorage.LOCKS);
+ childs.add(JBossCacheStorage.REFS);
+ return childs;
}
- // return null;
+ else if (name.size() > 2)
+ {
+ // seems it is fqn like /$NODES/nodeUUID/childname[/...] or /$REFS/nodeUUID/propUUUIS[/...]
+ // TODO this is unexpected part of cache throw Exception
+ LOG.warn("This is unexpected FQN " + name);
+ return null;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.NODES))
+ {
+ // TODO should never be called
+ LOG.warn("conn.getAllNodeIdentifiers()");
+ return null/*conn.getAllNodeIdentifiers()*/;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.PROPS))
+ {
+ // TODO should never be called
+ LOG.warn("conn.getAllPropertyIdentifiers()");
+ return null/*conn.getAllPropertyIdentifiers()*/;
+ }
+ else if (name.get(0).equals(JBossCacheStorage.LOCKS))
+ {
+ // TODO return all Locks in workspace
+ return new LinkedHashSet<String>();
+ }
+ else if (name.get(0).equals(JBossCacheStorage.REFS))
+ {
+ return null/*conn.getAllRefencedNodeIdentifiers()*/;
+ }
+ else
+ {
+ return null;
+ }
}
/**
16 years, 7 months