From do-not-reply at jboss.org Sun Nov 1 17:06:48 2009
Content-Type: multipart/mixed; boundary="===============6692315803463131077=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r461 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Sun, 01 Nov 2009 17:06:48 -0500
Message-ID: <200911012206.nA1M6mJ3001920@svn01.web.mwc.hst.phx2.redhat.com>
--===============6692315803463131077==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-01 17:06:48 -0500 (Sun, 01 Nov 2009)
New Revision: 461
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorage.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
Log:
EXOJCR-200: connection new hierarchy; paths fixes
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform=
/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-01 22:06:=
48 UTC (rev 461)
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.jboss.cache.Fqn;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 31.10.2009
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+public abstract class JBossCacheStorage
+{
+
+ public static final String TREE =3D "$TREE".intern();
+
+ public static final String ITEMS =3D "$ITEMS".intern();
+
+ public static final String ITEM_DATA =3D "$data".intern();
+
+ public static final String ITEM_ID =3D "$id".intern();
+
+ protected final Fqn treeRoot;
+
+ protected final Fqn itemsRoot;
+
+ protected JBossCacheStorage(Fqn treeRoot, Fqn itemsRoot)
+ {
+ this.treeRoot =3D treeRoot;
+ this.itemsRoot =3D itemsRoot;
+ }
+
+ protected Fqn makeNodeFqn(QPath nodePath)
+ {
+ QPathEntry[] path =3D nodePath.getEntries();
+ String[] fqns =3D new String[path.length];
+
+ for (int i =3D 0; i < path.length; i++)
+ {
+ fqns[i] =3D path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ protected Fqn makeParentFqn(QPath propertyPath)
+ {
+ QPathEntry[] path =3D propertyPath.getEntries();
+ int pathLen =3D path.length - 1;
+ String[] fqns =3D new String[pathLen];
+
+ for (int i =3D 0; i < pathLen; i++)
+ {
+ fqns[i] =3D path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ }
+
+ protected Fqn makeIdFqn(String itemId)
+ {
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-10=
-30 22:03:54 UTC (rev 460)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-01 22:06:48 UTC (rev 461)
@@ -18,12 +18,18 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
=
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -31,42 +37,29 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
=
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
* =
* Date: 23.10.2009
*
* Cache contains several regions:
- * Workspace tree. /$repo_name/$ws_name/$ROOT: On each leaf (JBossCache No=
de) an JCR Item Id stored.
- * Items map. /$repo_name/$ws_name/$ITEMS: Key=3DId, Value =3D ItemData.
- * References map ??? /$repo_name/$ws_name/$REFS: Key=3DNodeId, Value =3D =
PropertyId.
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id s=
tored.
+ * Items map. /$ITEMS: Key=3DId, Value =3D ItemData.
+ * References map ??? /$REFS: Key=3DNodeId, Value =3D PropertyId.
*
* @author Peter N=
edonosko =
* @version $Id$
*/
-public class JBossCacheStorageConnection extends DBConstants implements Wo=
rkspaceStorageConnection
+public class JBossCacheStorageConnection extends JBossCacheStorage impleme=
nts WorkspaceStorageConnection
{
=
protected static final Log LOG =3D ExoLogger.getLogger("jcr.JBossCacheS=
torageConnection");
=
- //public static final InternalQName NODE =3D new InternalQName(Constant=
s.NS_DEFAULT_URI, "$node");
- public static final String ITEM_DATA =3D "$idata".intern();
-
- public static final String ITEM_ID =3D "$id".intern();
-
private final Cache cache;
=
- private final Node treeRoot;
+ //private final Node treeRoot;
=
- private final Node itemsRoot;
+ //private final Node itemsRoot;
=
/**
* Start batching flag. 'true' if batching was started, 'false' if bat=
ching is not start. =
@@ -81,46 +74,13 @@
public JBossCacheStorageConnection(Cache cache, N=
ode treeRoot,
Node itemsRoot)
{
+ super(treeRoot.getFqn(), itemsRoot.getFqn());
+ =
this.cache =3D cache;
- this.itemsRoot =3D itemsRoot;
- this.treeRoot =3D treeRoot;
+ //this.itemsRoot =3D itemsRoot;
+ //this.treeRoot =3D treeRoot;
}
=
- private Fqn makeNodeFqn(QPath nodePath)
- {
- QPathEntry[] path =3D nodePath.getEntries();
- String[] fqns =3D new String[path.length];
-
- for (int i =3D 0; i < path.length; i++)
- {
- fqns[i] =3D path[i].getAsString(true);
- }
-
- // TODO make Fqn generation clearer =
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns)=
);
- }
-
- private Fqn makeParentFqn(QPath propertyPath)
- {
- QPathEntry[] path =3D propertyPath.getEntries();
- int pathLen =3D path.length - 1;
- String[] fqns =3D new String[pathLen];
-
- for (int i =3D 0; i < pathLen; i++)
- {
- fqns[i] =3D path[i].getAsString(true);
- }
-
- // TODO make Fqn generation clearer =
- return Fqn.fromRelativeFqn(treeRoot.getFqn(), Fqn.fromElements(fqns)=
);
- }
-
- private Fqn makeIdFqn(String itemId)
- {
- // TODO make Fqn generation clearer =
- return Fqn.fromRelativeFqn(itemsRoot.getFqn(), Fqn.fromString(itemId=
));
- }
-
/**
* {@inheritDoc}
*/
@@ -192,7 +152,6 @@
NodeData node =3D (NodeData)cache.get(makeIdFqn(childId), ITEM_DA=
TA);
if (node =3D=3D null)
{
- treePrint(treeRoot);
throw new RepositoryException("One of childs is null. Parent "=
+ parent.getQPath().getAsString());
}
childs.add(node);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.j=
ava
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 20=
09-10-30 22:03:54 UTC (rev 460)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java 20=
09-11-01 22:06:48 UTC (rev 461)
@@ -57,10 +57,6 @@
=
public static final String JBOSSCACHE_CONFIG =3D "jbosscache-configurat=
ion";
=
- public static final String ROOT =3D "$ROOT".intern();
-
- public static final String ITEMS =3D "$ITEMS".intern();
-
protected static final Log LOG =3D ExoLogger.getLogger("jcr.JBossCacheW=
orkspaceDataContainer");
=
protected final String repositoryName;
@@ -117,8 +113,8 @@
//Node wsRoot =3D cacheRoot.addChild(Fqn.fromE=
lements(repositoryName, containerName));
=
// prepare cache structures
- this.tree =3D cacheRoot.addChild(Fqn.fromString(ROOT));
- this.items =3D cacheRoot.addChild(Fqn.fromString(ITEMS));
+ this.tree =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TR=
EE));
+ this.items =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.I=
TEMS));
}
=
public void start()
--===============6692315803463131077==--
From do-not-reply at jboss.org Sun Nov 1 17:10:06 2009
Content-Type: multipart/mixed; boundary="===============5531758877548610168=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r462 - in
jcr/branches/1.12.0-JBC/component/core/src:
test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other
directory.
Date: Sun, 01 Nov 2009 17:10:06 -0500
Message-ID: <200911012210.nA1MA6RP002424@svn01.web.mwc.hst.phx2.redhat.com>
--===============5531758877548610168==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-01 17:10:06 -0500 (Sun, 01 Nov 2009)
New Revision: 462
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
Log:
EXOJCR-201: new loader: get, getChilds impls
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-01 22:06:=
48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-01 22:10:=
06 UTC (rev 462)
@@ -3,7 +3,7 @@
*
* 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 3 of
+ * 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,
@@ -16,51 +16,59 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.exoplatform.services.jcr.impl.storage.jbosscache;
=
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.exoplatform.services.jcr.config.RepositoryConfigurationExceptio=
n;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnectio=
n;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.jboss.cache.CacheSPI;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.RegionManager;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.AbstractCacheLoader;
=
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS.
* =
- * Date: 23.10.2009
+ * Date: 31.10.2009
*
* @author Peter N=
edonosko =
* @version $Id$
*/
-public class ExoJCRCacheLoader implements CacheLoader
+public class ExoJCRCacheLoader extends AbstractCacheLoader
{
- //private CacheSPI cache;
=
- //private RegionManager regionManager;
-
- private IndividualCacheLoaderConfig config;
-
private WorkspaceDataContainer dataContainer;
=
- private HashMap> transactions =3D new HashMa=
p>();
-
/**
* Init the loader DataContainer with given WorkspaceDataContainer inst=
ance.
*
@@ -77,25 +85,17 @@
this.dataContainer =3D dataContainer;
}
=
- /**
- * {@inheritDoc}
- */
- public void commit(Object tx) throws Exception
+ protected QPathEntry[] makeNodePath(Fqn nodeFqn) throws NumberF=
ormatException, IllegalNameException
{
- List modifications =3D transactions.remove(tx);
- if (modifications !=3D null)
- doModified(modifications);
- else
- throw new ExoJCRCacheLoaderException("Transaction " + tx + " not =
exist in transaction table");
- }
+ List elements =3D nodeFqn.peekElements();
+ QPathEntry[] path =3D new QPathEntry[elements.size()];
=
- /**
- * {@inheritDoc}
- */
- public boolean exists(Fqn name) throws Exception
- {
- // TODO use get(Fqn), i.e. get Node!=3Dnull =
- return false;
+ for (int i =3D 0; i < elements.size(); i++)
+ {
+ path[i] =3D QPathEntry.parse(elements.get(i));
+ }
+
+ return path;
}
=
/**
@@ -103,182 +103,182 @@
*/
public Map get(Fqn name) throws Exception
{
- // TODO get Node
- return null;
- }
=
- /**
- * {@inheritDoc}
- */
- public Set> getChildrenNames(Fqn fqn) throws Exception
- {
- // TODO get child nodes names
- return null;
- }
+ Map attrs =3D new LinkedHashMap();
+ if (name.size() > 1)
+ {
+ if (name.get(1).equals(JBossCacheStorage.TREE))
+ {
+ // return Node
+ if (name.size() > 3)
+ {
+ QPathEntry nodeName =3D QPathEntry.parse(name.getLastElemen=
tAsString());
=
- /**
- * {@inheritDoc}
- */
- public IndividualCacheLoaderConfig getConfig()
- {
- return config;
- }
+ // TODO non effective, in this way 1) all subtree will be c=
ached
+ // 2) all subtree will be read from DB (with allprops) for =
only Ids.
+ // The effective way DON NOT use calls to cache and use spe=
cial SQLs for Ids only read. =
+ String parentId =3D (String)cache.get(name.getParent(), JBo=
ssCacheStorage.ITEM_ID);
=
- /**
- * {@inheritDoc}
- */
- public void loadEntireState(ObjectOutputStream os) throws Exception
- {
- // TODO Auto-generated method stub
+ WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
+ try
+ {
+ NodeData parent =3D (NodeData)conn.getItemData(parentId);
=
- }
+ ItemData item =3D conn.getItemData(parent, nodeName);
=
- /**
- * {@inheritDoc}
- */
- public void loadState(Fqn subtree, ObjectOutputStream os) throws Except=
ion
- {
- // TODO Auto-generated method stub
+ // item Id
+ attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier(=
));
=
+ // if Node (Property cannot due to logic of StorageConne=
ction) add props
+ for (PropertyData prop : conn.getChildPropertiesData(par=
ent))
+ {
+ attrs.put(prop.getQPath().getName().getAsString(), pr=
op.getIdentifier());
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
+ }
+ }
+ else if (name.get(1).equals(JBossCacheStorage.ITEMS))
+ {
+ // we have all data on thrid level =
+ if (name.size() =3D=3D 3)
+ {
+ // return Node or Property
+ String itemId =3D name.getLastElementAsString();
+
+ WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
+ try
+ {
+ attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(=
itemId));
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ }
+ }
+ return attrs;
}
=
/**
* {@inheritDoc}
*/
- public void prepare(Object tx, List modifications, boolea=
n onePhase) throws Exception
+ public boolean exists(Fqn name) throws Exception
{
- if (onePhase)
- {
- doModified(modifications);
- }
- else
- {
- transactions.put(tx, modifications);
- }
+ // TODO do it with less cost
+ return get(name) !=3D null;
}
=
/**
- * Will be added data to DB. =
- * =
- * @param modifications
- * @throws Exception
+ * {@inheritDoc}
*/
- private void doModified(List modifications) throws Except=
ion
+ public Set> getChildrenNames(Fqn fqn) throws Exception
{
- JDBCStorageConnection jdbcConnection =3D (JDBCStorageConnection)data=
Container.openConnection();
+ // return child nodes names
=
- try
+ Set childs =3D new LinkedHashSet();
+ if (fqn.size() > 2)
{
- for (int modificatinIndex =3D 0; modificatinIndex < modifications=
.size(); modificatinIndex++)
+ if (fqn.get(2).equals(JBossCacheStorage.TREE))
{
- Modification md =3D modifications.get(modificatinIndex);
- switch (md.getType())
+ // return Node
+ if (fqn.size() > 3)
{
- case PUT_KEY_VALUE :
- doAddOrUpdate(md, jdbcConnection);
- break;
- case REMOVE_NODE :
- doRemove(md, jdbcConnection, "TODO $");
- break;
- }
- }
+ QPathEntry nodeName =3D QPathEntry.parse(fqn.getLastElement=
AsString());
=
- if (jdbcConnection !=3D null)
- jdbcConnection.commit();
- }
- finally
- {
- if (jdbcConnection !=3D null && jdbcConnection.isOpened())
- jdbcConnection.rollback();
- }
- }
+ // TODO non effective, in this way 1) all subtree will be c=
ached
+ // 2) all subtree will be read from DB (with allprops) for =
only Ids.
+ // The effective way DON NOT use calls to cache and use spe=
cial SQLs for Ids only read. =
+ String parentId =3D (String)cache.get(fqn.getParent(), JBos=
sCacheStorage.ITEM_ID);
=
- private void doRemove(Modification modification, JDBCStorageConnection =
jdbcConnection, String identifier)
- throws IllegalStateException, RepositoryException
- {
+ WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
+ try
+ {
+ NodeData parent =3D (NodeData)conn.getItemData(parentId);
=
- ItemData itemData =3D jdbcConnection.getItemData(identifier);
+ NodeData node =3D (NodeData)conn.getItemData(parent, nod=
eName);
=
- if (itemData instanceof NodeData)
- jdbcConnection.delete((NodeData)itemData);
- if (itemData instanceof PropertyData)
- jdbcConnection.delete((PropertyData)itemData);
- }
-
- /**
- * Performs ADD and UPDATE to NodeData and PropertyData.
- * @param modification
- * @param jdbcConnection
- * @throws IllegalStateException
- * @throws RepositoryException
- */
- private void doAddOrUpdate(Modification modification, JDBCStorageConnec=
tion jdbcConnection)
- throws IllegalStateException, RepositoryException
- {
- if (modification.getValue() instanceof NodeData)
- {
- //add or update node data
- NodeData nodeData =3D (NodeData)modification.getValue();
-
- ItemData itemData =3D jdbcConnection.getItemData(nodeData.getIden=
tifier());
-
- if (itemData =3D=3D null)
- {
- //add
- jdbcConnection.add(nodeData);
+ // get child nodes by parent Id
+ for (NodeData prop : conn.getChildNodesData(node))
+ {
+ childs
+ .add(node.getQPath().getEntries()[node.getQPath().=
getEntries().length - 1].getAsString(true));
+ }
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ {
+ // root Node (/$TREE/[]:1)
+ childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_=
PATH.getEntries().length - 1]
+ .getAsString(true));
+ }
}
- else
+ else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
{
- //update
- jdbcConnection.update(nodeData);
+ // we have all data on thrid level =
+ if (fqn.size() =3D=3D 3)
+ {
+ // return all Nodes and Properties Ids
+
+// WorkspaceStorageConnection conn =3D dataContainer.openCon=
nection();
+// try
+// {
+// for (String itemId : conn.getAllItemIdentifiers())
+// {
+// childs.add(itemId);
+// }
+// }
+// finally
+// {
+// conn.close();
+// }
+ }
}
}
- else if (modification.getValue() instanceof PropertyData)
+ else if (fqn.equals(Fqn.ROOT))
{
- //add or update property data
- PropertyData propertyData =3D (PropertyData)modification.getValue=
();
-
- ItemData itemData =3D jdbcConnection.getItemData(propertyData.get=
Identifier());
-
- if (itemData =3D=3D null)
- {
- //add
- jdbcConnection.add(propertyData);
- }
- else
- {
- //update
- jdbcConnection.update(propertyData);
- }
+ childs.add(JBossCacheStorage.TREE);
+ childs.add(JBossCacheStorage.ITEMS);
}
+ return childs;
}
=
/**
* {@inheritDoc}
*/
- public Object put(Fqn name, Object key, Object value) throws Exception
+ public IndividualCacheLoaderConfig getConfig()
{
- // i.e. put Property
+ // TODO Auto-generated method stub
return null;
}
=
/**
* {@inheritDoc}
*/
- public void put(Fqn name, Map attributes) throws Except=
ion
+ public Object put(Fqn name, Object key, Object value) throws Exception
{
- // i.e. put set of Properties =
- =
// TODO Auto-generated method stub
-
+ return null;
}
=
/**
* {@inheritDoc}
*/
- public void put(List modifications) throws Exception
+ public void put(Fqn name, Map attributes) throws Except=
ion
{
- =
// TODO Auto-generated method stub
=
}
@@ -288,7 +288,6 @@
*/
public Object remove(Fqn fqn, Object key) throws Exception
{
- // i.e. remove Property
// TODO Auto-generated method stub
return null;
}
@@ -298,8 +297,6 @@
*/
public void remove(Fqn fqn) throws Exception
{
- // i.e. remove Node
- =
// TODO Auto-generated method stub
=
}
@@ -309,8 +306,6 @@
*/
public void removeData(Fqn fqn) throws Exception
{
- // i.e. remove all Properties of Node =
- =
// TODO Auto-generated method stub
=
}
@@ -318,88 +313,10 @@
/**
* {@inheritDoc}
*/
- public void rollback(Object tx)
- {
- transactions.remove(tx);
- }
-
- /**
- * {@inheritDoc}
- */
- public void setCache(CacheSPI c)
- {
- //this.cache =3D c;
- }
-
- /**
- * {@inheritDoc}
- */
public void setConfig(IndividualCacheLoaderConfig config)
{
- this.config =3D config;
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void setRegionManager(RegionManager manager)
- {
- //this.regionManager =3D manager;
- }
-
- /**
- * {@inheritDoc}
- */
- public void storeEntireState(ObjectInputStream is) throws Exception
- {
// TODO Auto-generated method stub
=
}
=
- /**
- * {@inheritDoc}
- */
- public void storeState(Fqn subtree, ObjectInputStream is) throws Except=
ion
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void create() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void destroy()
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void start() throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- // TODO Auto-generated method stub
-
- }
-
}
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatfor=
m/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java (from rev 46=
0, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java 2009-11-01 22:10=
:06 UTC (rev 462)
@@ -0,0 +1,408 @@
+/*
+ * 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 3 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.RepositoryConfigurationExceptio=
n;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnectio=
n;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.loader.CacheLoader;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 23.10.2009
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+public class ExoJCRCacheLoader1 implements CacheLoader
+{
+ //private CacheSPI cache;
+
+ //private RegionManager regionManager;
+
+ private IndividualCacheLoaderConfig config;
+
+ private WorkspaceDataContainer dataContainer;
+
+ private HashMap> transactions =3D new HashMa=
p>();
+
+ /**
+ * Init the loader DataContainer with given WorkspaceDataContainer inst=
ance.
+ *
+ * @param dataContainer WorkspaceDataContainer
+ */
+ @Inject
+ public void initDataContainer(WorkspaceDataContainer dataContainer) thr=
ows RepositoryConfigurationException
+ {
+ if (this.dataContainer !=3D null)
+ {
+ throw new RepositoryConfigurationException("Cannot set WorkspaceD=
ataContainer twice");
+ }
+
+ this.dataContainer =3D dataContainer;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit(Object tx) throws Exception
+ {
+ List modifications =3D transactions.remove(tx);
+ if (modifications !=3D null)
+ doModified(modifications);
+ else
+ throw new ExoJCRCacheLoaderException("Transaction " + tx + " not =
exist in transaction table");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn name) throws Exception
+ {
+ // TODO use get(Fqn), i.e. get Node!=3Dnull =
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map get(Fqn name) throws Exception
+ {
+ // TODO get Node or Property
+ // e.g.
+ // if $TREE/[]:1 - return $ITEM_ID attribute and all JCR Node Proper=
ties IDs =
+ // if $ITEM/idxxx - return $ITEM_DATA of JCR Node or Property =
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set> getChildrenNames(Fqn fqn) throws Exception
+ {
+ // TODO get child nodes names
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void loadEntireState(ObjectOutputStream os) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void loadState(Fqn subtree, ObjectOutputStream os) throws Except=
ion
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void prepare(Object tx, List modifications, boolea=
n onePhase) throws Exception
+ {
+ if (onePhase)
+ {
+ doModified(modifications);
+ }
+ else
+ {
+ transactions.put(tx, modifications);
+ }
+ }
+
+ /**
+ * Will be added data to DB. =
+ * =
+ * @param modifications
+ * @throws Exception
+ */
+ private void doModified(List modifications) throws Except=
ion
+ {
+ JDBCStorageConnection jdbcConnection =3D (JDBCStorageConnection)data=
Container.openConnection();
+
+ try
+ {
+ for (int modificatinIndex =3D 0; modificatinIndex < modifications=
.size(); modificatinIndex++)
+ {
+ Modification md =3D modifications.get(modificatinIndex);
+ switch (md.getType())
+ {
+ case PUT_KEY_VALUE :
+ doAddOrUpdate(md, jdbcConnection);
+ break;
+ case REMOVE_NODE :
+ doRemove(md, jdbcConnection, "TODO $");
+ break;
+ }
+ }
+
+ if (jdbcConnection !=3D null)
+ jdbcConnection.commit();
+ }
+ finally
+ {
+ if (jdbcConnection !=3D null && jdbcConnection.isOpened())
+ jdbcConnection.rollback();
+ }
+ }
+
+ private void doRemove(Modification modification, JDBCStorageConnection =
jdbcConnection, String identifier)
+ throws IllegalStateException, RepositoryException
+ {
+
+ ItemData itemData =3D jdbcConnection.getItemData(identifier);
+
+ if (itemData instanceof NodeData)
+ jdbcConnection.delete((NodeData)itemData);
+ if (itemData instanceof PropertyData)
+ jdbcConnection.delete((PropertyData)itemData);
+ }
+
+ /**
+ * Performs ADD and UPDATE to NodeData and PropertyData.
+ * @param modification
+ * @param jdbcConnection
+ * @throws IllegalStateException
+ * @throws RepositoryException
+ */
+ private void doAddOrUpdate(Modification modification, JDBCStorageConnec=
tion jdbcConnection)
+ throws IllegalStateException, RepositoryException
+ {
+ if (modification.getValue() instanceof NodeData)
+ {
+ //add or update node data
+ NodeData nodeData =3D (NodeData)modification.getValue();
+
+ ItemData itemData =3D jdbcConnection.getItemData(nodeData.getIden=
tifier());
+
+ if (itemData =3D=3D null)
+ {
+ //add
+ jdbcConnection.add(nodeData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(nodeData);
+ }
+ }
+ else if (modification.getValue() instanceof PropertyData)
+ {
+ //add or update property data
+ PropertyData propertyData =3D (PropertyData)modification.getValue=
();
+
+ ItemData itemData =3D jdbcConnection.getItemData(propertyData.get=
Identifier());
+
+ if (itemData =3D=3D null)
+ {
+ //add
+ jdbcConnection.add(propertyData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(propertyData);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn name, Object key, Object value) throws Exception
+ {
+ // i.e. put Property
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn name, Map attributes) throws Except=
ion
+ {
+ // i.e. put set of Properties =
+ =
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(List modifications) throws Exception
+ {
+ =
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn fqn, Object key) throws Exception
+ {
+ // i.e. remove Property
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn fqn) throws Exception
+ {
+ // i.e. remove Node
+ =
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn fqn) throws Exception
+ {
+ // i.e. remove all Properties of Node =
+ =
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback(Object tx)
+ {
+ transactions.remove(tx);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setCache(CacheSPI c)
+ {
+ //this.cache =3D c;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config =3D config;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setRegionManager(RegionManager manager)
+ {
+ //this.regionManager =3D manager;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void storeEntireState(ObjectInputStream is) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void storeState(Fqn subtree, ObjectInputStream is) throws Except=
ion
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void create() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void destroy()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start() throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop()
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader1.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-01 22=
:06:48 UTC (rev 461)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-01 22=
:10:06 UTC (rev 462)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * 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
--===============5531758877548610168==--
From do-not-reply at jboss.org Mon Nov 2 10:00:39 2009
Content-Type: multipart/mixed; boundary="===============8629328809960262458=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r463 -
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
Date: Mon, 02 Nov 2009 10:00:39 -0500
Message-ID: <200911021500.nA2F0dbO005244@svn01.web.mwc.hst.phx2.redhat.com>
--===============8629328809960262458==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: nfilotto
Date: 2009-11-02 10:00:38 -0500 (Mon, 02 Nov 2009)
New Revision: 463
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/PortalContainer.java
Log:
EXOJCR-166: Support separated ear delivery
The variable currentContainer_ has been removed from the PortalContainer si=
nce it is error prone as it duplicates the ThreaLocal in ExoContainerContex=
t, only the type change (i.e. ExoContainer in ExoContainerContext and Porta=
lContainer in PortalContainer). Now, everything relies on the TL of ExoCont=
ainerContext. =
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/PortalContainer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/PortalContainer.java 2009-11-01 22:10:06 UTC (rev 462)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/PortalContainer.java 2009-11-02 15:00:38 UTC (rev 463)
@@ -93,8 +93,6 @@
}
}
=
- private static ThreadLocal currentContainer_ =3D new T=
hreadLocal();
-
private volatile boolean started_;
=
private PortalContainerInfo pinfo_;
@@ -323,38 +321,24 @@
if (container =3D=3D null)
{
container =3D RootContainer.getInstance().getPortalContainer(DEFA=
ULT_PORTAL_CONTAINER_NAME);
- currentContainer_.set(container);
+ PortalContainer.setInstance(container);
}
return container;
}
=
/**
- * @return the current instance of {@link PortalContainer} that has bee=
n stored into the related
- * {@link ThreadLocal}. If no value has been set, it will return =
null
+ * @return the current instance of {@link ExoContainer} that has been s=
tored into the
+ * {@link ThreadLocal} of {@link ExoContainerContext}. If no {@link Por=
talContainer} has been set, =
+ * it will return null
*/
public static PortalContainer getInstanceIfPresent()
{
- PortalContainer pc =3D currentContainer_.get();
- if (pc !=3D null) =
+ ExoContainer container =3D ExoContainerContext.getCurrentContainerIf=
Present();
+ if (container instanceof PortalContainer) =
{
- ExoContainer container =3D ExoContainerContext.getCurrentContaine=
rIfPresent();
- if (container !=3D pc)
- {
- // Clean the value of currentContainer_ since it should be equ=
als to =
- // ExoContainerContext.getCurrentContainerIfPresent()
- if (container instanceof PortalContainer)
- {
- // The current container is a PortalContainer, this value w=
ill replace the old one
- currentContainer_.set(pc =3D (PortalContainer)container);
- }
- else
- {
- // The current container is not a PortalContainer, the old =
value must be removed
- currentContainer_.set(pc =3D null);
- }
- }
+ return (PortalContainer)container;
}
- return pc;
+ return null;
}
=
/**
@@ -436,17 +420,12 @@
*/
public static PortalContainer getCurrentInstance(ServletContext context)
{
- final ExoContainer container =3D ExoContainerContext.getCurrentConta=
iner();
- if (container instanceof PortalContainer)
+ final PortalContainer container =3D getInstanceIfPresent();
+ if (container =3D=3D null)
{
- if (log.isDebugEnabled())
- log.debug("A portal container has been set in the ThreadLocal =
of ExoContainerContext");
- return (PortalContainer)container;
- }
- else
- {
return PortalContainer.getInstance(context);
}
+ return container;
}
=
/**
@@ -567,7 +546,6 @@
=
public static void setInstance(PortalContainer instance)
{
- currentContainer_.set(instance);
ExoContainerContext.setCurrentContainer(instance);
}
=
--===============8629328809960262458==--
From do-not-reply at jboss.org Mon Nov 2 11:32:35 2009
Content-Type: multipart/mixed; boundary="===============4180025638377409726=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r464 - in
jcr/trunk/exo.jcr.component.core/src:
test/java/org/exoplatform/services/jcr/impl/core and 1 other directories.
Date: Mon, 02 Nov 2009 11:32:35 -0500
Message-ID: <200911021632.nA2GWZxt018189@svn01.web.mwc.hst.phx2.redhat.com>
--===============4180025638377409726==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2009-11-02 11:32:35 -0500 (Mon, 02 Nov 2009)
New Revision: 464
Added:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/impl/core/TestSVNodeDataOptimization.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/core/SysViewWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/test=
-configuration.xml
Log:
EXOJCR-219 : The method SysViewWorkspaceinitializer.SVNodeData.addChildNode=
(InternalQName childName) was optimized.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/SysViewWorkspaceInitializer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-11-02 15:00:38 UTC (re=
v 463)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/SysViewWorkspaceInitializer.java 2009-11-02 16:32:35 UTC (re=
v 464)
@@ -55,6 +55,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;
@@ -299,11 +300,14 @@
}
}
=
- protected class SVNodeData extends TransientNodeData
+ protected class SVNodeData
+ extends TransientNodeData
{
=
- List childNodes =3D new LinkedList();
+ int orderNumber =3D 0;
=
+ HashMap childNodesMap =3D new HashMap();
+
SVNodeData(QPath path, String identifier, String parentIdentifier, i=
nt version, int orderNum)
{
super(path, identifier, version, null, null, orderNum, parentIden=
tifier, null);
@@ -321,15 +325,16 @@
*/
int[] addChildNode(InternalQName childName)
{
- int orderNumber =3D childNodes.size();
- int index =3D 1;
- for (int i =3D 0; i < childNodes.size(); i++)
+ Integer count =3D childNodesMap.get(childName);
+ if (count !=3D null)
{
- if (childName.equals(childNodes.get(i)))
- index++;
+ childNodesMap.put(childName, count + 1);
}
- childNodes.add(childName);
- return new int[]{orderNumber, index};
+ else
+ childNodesMap.put(childName, 1);
+
+ int index =3D childNodesMap.get(childName);
+ return new int[] {orderNumber++, index};
}
}
=
Added: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/servi=
ces/jcr/impl/core/TestSVNodeDataOptimization.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/impl/core/TestSVNodeDataOptimization.java (rev=
0)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/impl/core/TestSVNodeDataOptimization.java 2009-11-02 16:32:35 UTC (rev=
464)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+package org.exoplatform.services.jcr.impl.core;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.config.WorkspaceInitializerEntry;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ *
+ * Date: 02.11.2009
+ * =
+ * @author Alex Re=
shetnyak
+ * @version $Id$
+ */
+public class TestSVNodeDataOptimization
+ extends JcrImplBaseTest
+{
+ =
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ SessionImpl ses =3D (SessionImpl) repository.login(credentials, "ws1=
");
+ if (ses !=3D null)
+ {
+ try
+ {
+ ses.refresh(false);
+ Node rootNode =3D ses.getRootNode();
+ if (rootNode.hasNodes())
+ {
+ // clean test root
+ for (NodeIterator children =3D rootNode.getNodes(); childre=
n.hasNext();)
+ {
+ Node node =3D children.nextNode();
+ if (!node.getPath().startsWith("/jcr:system"))
+ {
+ // log.info("DELETing ------------- "+node.getPath());
+ node.remove();
+ }
+ }
+ ses.save();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("tearDown() ERROR " + getClass().getName() + "." + g=
etName() + " " + e, e);
+ }
+ finally
+ {
+ ses.logout();
+ }
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ SessionImpl ses =3D (SessionImpl) repository.login(credentials, "ws1=
");
+ if (ses !=3D null)
+ {
+ try
+ {
+ ses.refresh(false);
+ Node rootNode =3D ses.getRootNode();
+ if (rootNode.hasNodes())
+ {
+ // clean test root
+ for (NodeIterator children =3D rootNode.getNodes(); childre=
n.hasNext();)
+ {
+ Node node =3D children.nextNode();
+ if (!node.getPath().startsWith("/jcr:system"))
+ {
+ // log.info("DELETing ------------- "+node.getPath());
+ node.remove();
+ }
+ }
+ ses.save();
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("tearDown() ERROR " + getClass().getName() + "." + g=
etName() + " " + e, e);
+ }
+ finally
+ {
+ ses.logout();
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testSVNodeData() throws Exception
+ {
+
+ //ADD content
+ SessionImpl ses =3D (SessionImpl) repository.login(credentials, "ws1=
");
+
+ //Add node with sub name sibling
+ Node nodeSNS =3D ses.getRootNode().addNode("node_with_sns");
+ for (int i =3D 0; i < 100; i++)
+ {
+ nodeSNS.addNode("node_sns_");
+ }
+
+ //Add node without sub name sibling
+ Node nodeWOSNS =3D ses.getRootNode().addNode("node_without_sns");
+ for (int i =3D 0; i < 100; i++)
+ {
+ nodeSNS.addNode("node_" + i);
+ }
+
+ ses.save();
+
+ // Cereate backup
+ File backup =3D File.createTempFile("full-backup", ".xml");
+ backup.deleteOnExit();
+
+ ses.exportWorkspaceSystemView(new FileOutputStream(backup), false, f=
alse);
+
+ // restore to ws1_restored
+ WorkspaceEntry ws1_restore =3D
+ makeWorkspaceEntry("ws1_restored", isMultiDB(session) ? "jd=
bcjcr2export3" : "jdbcjcr", backup, ses);
+ repository.configWorkspace(ws1_restore);
+ repository.createWorkspace(ws1_restore.getName());
+
+ // check
+ SessionImpl backupSession =3D (SessionImpl) repository.login(credent=
ials, "ws1_restored");
+
+ assertNotNull(backupSession);
+
+ checkEquals(ses, backupSession);
+ }
+
+ private void checkEquals(SessionImpl expected, SessionImpl actual) thro=
ws Exception
+ {
+ NodeImpl srcNode =3D (NodeImpl) expected.getRootNode();
+ NodeImpl destNode =3D (NodeImpl) actual.getRootNode();
+
+ checkNodeEquals(srcNode, destNode);
+ }
+
+ private void checkNodeEquals(NodeImpl src, NodeImpl dest) throws Except=
ion
+ {
+ assertTrue(dest.equals(src));
+ assertEquals(src.getIndex(), dest.getIndex());
+ assertEquals(((NodeData) src.getData()).getOrderNumber(), ((NodeData=
) dest.getData()).getOrderNumber());
+
+ NodeIterator srcIterator =3D src.getNodes();
+ NodeIterator destIterator =3D dest.getNodes();
+
+ assertEquals(srcIterator.getSize(), destIterator.getSize());
+
+ while (srcIterator.hasNext())
+ checkNodeEquals((NodeImpl) srcIterator.nextNode(), (NodeImpl) des=
tIterator.nextNode());
+ }
+
+ private WorkspaceEntry makeWorkspaceEntry(String name, String sourceNam=
e, File sysViewFile, SessionImpl ses)
+ {
+ WorkspaceEntry ws1e =3D (WorkspaceEntry) ses.getContainer().getCompo=
nentInstanceOfType(WorkspaceEntry.class);
+
+ WorkspaceEntry ws1back =3D new WorkspaceEntry();
+ ws1back.setName(name);
+ ws1back.setUniqueName(((RepositoryImpl) ses.getRepository()).getName=
() + "_" + ws1back.getName());
+
+ ws1back.setAccessManager(ws1e.getAccessManager());
+ ws1back.setAutoInitializedRootNt(ws1e.getAutoInitializedRootNt());
+ ws1back.setAutoInitPermissions(ws1e.getAutoInitPermissions());
+ ws1back.setCache(ws1e.getCache());
+ ws1back.setContainer(ws1e.getContainer());
+ ws1back.setLockManager(ws1e.getLockManager());
+
+ // Initializer
+ WorkspaceInitializerEntry wiEntry =3D new WorkspaceInitializerEntry(=
);
+ wiEntry.setType(SysViewWorkspaceInitializer.class.getCanonicalName()=
);
+
+ List wieParams =3D new ArrayList();
+ wieParams
+ .add(new SimpleParameterEntry(SysViewWorkspaceInitializer.R=
ESTORE_PATH_PARAMETER, sysViewFile.getPath()));
+
+ wiEntry.setParameters(wieParams);
+
+ ws1back.setInitializer(wiEntry);
+
+ // Indexer
+ ArrayList qParams =3D new ArrayList();
+ qParams.add(new SimpleParameterEntry("indexDir", "target" + File.sep=
arator + name));
+ QueryHandlerEntry qEntry =3D
+ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.co=
re.query.lucene.SearchIndex", qParams);
+
+ ws1back.setQueryHandler(qEntry);
+
+ ArrayList params =3D new ArrayList();
+ for (Iterator i =3D ws1back.getContainer().getParameters().iterator(=
); i.hasNext();)
+ {
+ SimpleParameterEntry p =3D (SimpleParameterEntry) i.next();
+ SimpleParameterEntry newp =3D new SimpleParameterEntry(p.getName(=
), p.getValue());
+
+ if (isMultiDB(ses) && newp.getName().equals("source-name"))
+ newp.setValue(sourceName);
+ else if (newp.getName().equals("swap-directory"))
+ newp.setValue("target/temp/swap/" + name);
+ else if (isMultiDB(ses) && newp.getName().equals("dialect"))
+ newp.setValue("hsqldb");
+
+ params.add(newp);
+ }
+
+ ContainerEntry ce =3D
+ new ContainerEntry("org.exoplatform.services.jcr.impl.stora=
ge.jdbc.JDBCWorkspaceDataContainer", params);
+ ws1back.setContainer(ce);
+
+ return ws1back;
+ }
+
+ private boolean isMultiDB(SessionImpl session)
+ {
+ WorkspaceEntry ws1e =3D (WorkspaceEntry) session.getContainer().getC=
omponentInstanceOfType(WorkspaceEntry.class);
+
+ for (Iterator i =3D ws1e.getContainer().getParameters().iterator(); =
i.hasNext();)
+ {
+ SimpleParameterEntry p =3D (SimpleParameterEntry) i.next();
+ SimpleParameterEntry newp =3D new SimpleParameterEntry(p.getName(=
), p.getValue());
+
+ if (newp.getName().equals("multi-db"))
+ return Boolean.valueOf(newp.getValue());
+ }
+
+ throw new RuntimeException("Can not get property 'multi-db' in confi=
guration on workspace '" + ws1e.getName()
+ + "'");
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/test/java/org/exo=
platform/services/jcr/impl/core/TestSVNodeDataOptimization.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalo=
ne/test-configuration.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/tes=
t-configuration.xml 2009-11-02 15:00:38 UTC (rev 463)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/conf/standalone/tes=
t-configuration.xml 2009-11-02 16:32:35 UTC (rev 464)
@@ -478,6 +478,33 @@
+
+ bind.datasource
+ addPlugin
+ org.exoplatform.services.naming.BindReferencePlugin
+
+
+ bind-name
+ jdbcjcr2export3
+
+
+ class-name
+ javax.sql.DataSource
+
+
+ factory
+ org.apache.commons.dbcp.BasicDataSourceFactory
+
+
+ ref-addresses
+ ref-addresses
+
+
+
+
+
+
+
--===============4180025638377409726==--
From do-not-reply at jboss.org Wed Nov 4 03:36:43 2009
Content-Type: multipart/mixed; boundary="===============5821704868744375117=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r465 -
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
Date: Wed, 04 Nov 2009 03:36:43 -0500
Message-ID: <200911040836.nA48ah6E022540@svn01.web.mwc.hst.phx2.redhat.com>
--===============5821704868744375117==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 03:36:42 -0500 (Wed, 04 Nov 2009)
New Revision: 465
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/RootContainer.java
Log:
EXOJCR-194 log message level changed to log.info (line 431)
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/RootContainer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/RootContainer.java 2009-11-02 16:32:35 UTC (rev 464)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/RootContainer.java 2009-11-04 08:36:42 UTC (rev 465)
@@ -428,7 +428,7 @@
else
{
booting =3D true;
- log.error("Booting root container with id " + RootContai=
ner.class.hashCode() + "");
+ log.info("Booting root container with id " + RootContain=
er.class.hashCode() + "");
log.info("Building root container");
long time =3D -System.currentTimeMillis();
result =3D buildRootContainer();
--===============5821704868744375117==--
From do-not-reply at jboss.org Wed Nov 4 04:10:22 2009
Content-Type: multipart/mixed; boundary="===============7955580164048238118=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r466 - in kernel/trunk:
exo.kernel.container/src/main/java/org/exoplatform/container/configuration
and 1 other directory.
Date: Wed, 04 Nov 2009 04:10:21 -0500
Message-ID: <200911040910.nA49ALLM029133@svn01.web.mwc.hst.phx2.redhat.com>
--===============7955580164048238118==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 04:10:21 -0500 (Wed, 04 Nov 2009)
New Revision: 466
Modified:
kernel/trunk/exo.kernel.component.command/src/main/java/org/exoplatform/=
services/command/impl/CommonsXMLConfigurationPlugin.java
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/configuration/ConfigurationUnmarshaller.java
Log:
System.out.println changed to logger.info
Modified: kernel/trunk/exo.kernel.component.command/src/main/java/org/exopl=
atform/services/command/impl/CommonsXMLConfigurationPlugin.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.component.command/src/main/java/org/exoplatform=
/services/command/impl/CommonsXMLConfigurationPlugin.java 2009-11-04 08:36:=
42 UTC (rev 465)
+++ kernel/trunk/exo.kernel.component.command/src/main/java/org/exoplatform=
/services/command/impl/CommonsXMLConfigurationPlugin.java 2009-11-04 09:10:=
21 UTC (rev 466)
@@ -23,6 +23,8 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
=
import java.net.URL;
=
@@ -40,6 +42,8 @@
{
=
// protected Catalog defaultCatalog;
+ =
+ private static Log log =3D ExoLogger.getLogger(CommonsXMLConfigurationP=
lugin.class);
=
public CommonsXMLConfigurationPlugin(InitParams params, ConfigurationMa=
nager configurationManager) throws Exception
{
@@ -56,7 +60,7 @@
res =3D configurationManager.getResource(path);
if (res =3D=3D null)
throw new Exception("Resource not found " + path);
- System.out.println("Catalog configuration found at " + res);
+ log.info("Catalog configuration found at " + res);
parser.parse(res);
}
=
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/configuration/ConfigurationUnmarshaller.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/configuration/ConfigurationUnmarshaller.java 2009-11-04 08:36:42 UTC (re=
v 465)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/configuration/ConfigurationUnmarshaller.java 2009-11-04 09:10:21 UTC (re=
v 466)
@@ -71,23 +71,16 @@
this.valid =3D true;
}
=
- private void log(String prefix, SAXParseException e)
- {
- System.err.println(prefix + " in document " + url + " at (" + e.=
getLineNumber() + "," + e.getColumnNumber()
- + ") :" + e.getMessage());
- }
-
public void warning(SAXParseException exception) throws SAXException
{
- log("Warning", exception);
+ log.warn(exception.getMessage(), exception);
}
=
public void error(SAXParseException exception) throws SAXException
{
if (exception.getMessage().equals("cvc-elt.1: Cannot find the dec=
laration of element 'configuration'."))
{
- System.out
- .println("The document "
+ log.info("The document "
+ url
+ " does not contain a schema declaration, it should hav=
e an "
+ "XML declaration similar to\n"
@@ -98,14 +91,16 @@
}
else
{
- log("Error", exception);
+ log.error("In document " + url + " at (" + exception.getLineN=
umber() + "," + exception.getColumnNumber()
+ + ") :" + exception.getMessage());
}
valid =3D false;
}
=
public void fatalError(SAXParseException exception) throws SAXExcept=
ion
{
- log("Fatal error", exception);
+ log.fatal("In document " + url + " at (" + exception.getLineNumb=
er() + "," + exception.getColumnNumber()
+ + ") :" + exception.getMessage());
valid =3D false;
}
}
@@ -138,7 +133,7 @@
}
catch (SAXException e)
{
- System.err.print("Got a sax exception when doing XSD validatio=
n");
+ log.error("Got a sax exception when doing XSD validation");
e.printStackTrace(System.err);
return false;
}
@@ -160,14 +155,14 @@
out.write(bytes, 0, s);
}
String s =3D out.toString();
- System.out.println("s =3D " + s);
+ log.info("s =3D " + s);
*/
=
//
boolean valid =3D isValid(url);
if (!valid)
{
- System.out.println("The configuration file " + url + " was not fo=
und valid according to its XSD");
+ log.info("The configuration file " + url + " was not found valid =
according to its XSD");
}
=
// The buffer
--===============7955580164048238118==--
From do-not-reply at jboss.org Wed Nov 4 09:10:22 2009
Content-Type: multipart/mixed; boundary="===============3434645520336432554=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r467 -
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core.
Date: Wed, 04 Nov 2009 09:10:22 -0500
Message-ID: <200911041410.nA4EAMIo015425@svn01.web.mwc.hst.phx2.redhat.com>
--===============3434645520336432554==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2009-11-04 09:10:22 -0500 (Wed, 04 Nov 2009)
New Revision: 467
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/impl/core/TestSessionDataManager.java
Log:
EXOJCR-197: remove incorrect test
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/core/TestSessionDataManager.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/impl/core/TestSessionDataManager.java 2009-11-04 09:10:21 UTC (rev 466)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/impl/core/TestSessionDataManager.java 2009-11-04 14:10:22 UTC (rev 467)
@@ -336,25 +336,4 @@
assertNotNull(modificationManager.getItemData(QPath.makeChildPath(((=
NodeImpl)root).getData().getQPath(),
new InternalQName("", "testgetitemNode"))));
}
- =
- public void testRemove() throws Exception
- {
- Node n =3D session.getRootNode().addNode("node", "nt:unstructured");
- n.addMixin("mix:referenceable");
- session.save();
- String uuid =3D n.getUUID(); =
- Node p =3D n.getParent();
- n.remove();
- p.save();
- try
- {
- modificationManager.getItemByIdentifier(uuid, true);
-// session.getNodeByUUID(uuid);
- fail("Node must be removed.");
- }
- catch(ItemNotFoundException e)
- {
- =
- }
- }
}
--===============3434645520336432554==--
From do-not-reply at jboss.org Wed Nov 4 09:33:11 2009
Content-Type: multipart/mixed; boundary="===============3437065618869316599=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r468 -
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Wed, 04 Nov 2009 09:33:10 -0500
Message-ID: <200911041433.nA4EXAKb021087@svn01.web.mwc.hst.phx2.redhat.com>
--===============3437065618869316599==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-04 09:33:10 -0500 (Wed, 04 Nov 2009)
New Revision: 468
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-201: test for loader
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-04 14=
:10:22 UTC (rev 467)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-04 14=
:33:10 UTC (rev 468)
@@ -18,15 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
=
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
=
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
/**
* Created by The eXo Platform SAS.
* =
@@ -35,49 +27,15 @@
* @author Peter N=
edonosko =
* @version $Id$
*/
-public class ExoJCRCacheLoaderTest extends TestCase
+public class ExoJCRCacheLoaderTest extends JBossCacheStorageConnectionTest
{
=
- private Cache cache;
-
- private Node tree;
-
- private Node items;
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception
+ @Override
+ protected void initJBCConfig()
{
- super.setUp();
-
- // JBossCache =
- String jbcConfig =3D "conf/standalone/test-jbosscache-config-exoload=
er.xml";
-
- cache =3D new DefaultCacheFactory().createCach=
e(jbcConfig);
-
- Node cacheRoot =3D cache.getRoot();
- Node wsRoot =3D cacheRoot.addChild(Fqn.fromEle=
ments("repo", "ws"));
-
- // prepare cache structures
- tree =3D wsRoot.addChild(Fqn.fromString(JBossCacheWorkspaceDataConta=
iner.ROOT));
- items =3D wsRoot.addChild(Fqn.fromString(JBossCacheWorkspaceDataCont=
ainer.ITEMS));
-
- // run cache
- cache.create();
- cache.start();
-
- // JCR connection
- //conn =3D new JBossCacheStorageConnection(cache, tree, items);
-
+ jbcConfig =3D "conf/standalone/test-jbosscache-config-exoloader.xml";
}
=
- /**
- * {@inheritDoc}
- */
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
+ =
+ =
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.ja=
va
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 200=
9-11-04 14:10:22 UTC (rev 467)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 200=
9-11-04 14:33:10 UTC (rev 468)
@@ -68,13 +68,15 @@
public class JBossCacheStorageConnectionTest extends TestCase
{
=
- private JBossCacheStorageConnection conn;
+ protected JBossCacheStorageConnection conn;
=
- private Cache cache;
+ protected Cache cache;
=
- private Node tree;
+ protected Node tree;
=
- private Node items;
+ protected Node items;
+ =
+ protected String jbcConfig; =
=
/**
* {@inheritDoc}
@@ -84,16 +86,16 @@
super.setUp();
=
// JBossCache =
- String jbcConfig =3D "conf/standalone/test-jbosscache-config-jdbcloa=
der.xml";
-
+ initJBCConfig();
+ =
cache =3D new DefaultCacheFactory().createCach=
e(jbcConfig);
=
Node cacheRoot =3D cache.getRoot();
//Node wsRoot =3D cacheRoot.addChild(Fqn.fromE=
lements("repo", "ws"));
=
// prepare cache structures
- tree =3D cacheRoot.addChild(Fqn.fromString(JBossCacheWorkspaceDataCo=
ntainer.ROOT));
- items =3D cacheRoot.addChild(Fqn.fromString(JBossCacheWorkspaceDataC=
ontainer.ITEMS));
+ tree =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
+ items =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS)=
);
=
// run cache
cache.create();
@@ -102,6 +104,10 @@
// JCR connection
conn =3D new JBossCacheStorageConnection(cache, tree, items);
}
+ =
+ protected void initJBCConfig() {
+ jbcConfig =3D "conf/standalone/test-jbosscache-config-jdbcloader.xml=
";
+ }
=
/**
* {@inheritDoc}
--===============3437065618869316599==--
From do-not-reply at jboss.org Wed Nov 4 09:57:59 2009
Content-Type: multipart/mixed; boundary="===============1467717702183019910=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r469 - jcr/branches/1.12.0-JBC.
Date: Wed, 04 Nov 2009 09:57:59 -0500
Message-ID: <200911041457.nA4EvxGV025999@svn01.web.mwc.hst.phx2.redhat.com>
--===============1467717702183019910==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-04 09:57:59 -0500 (Wed, 04 Nov 2009)
New Revision: 469
Modified:
jcr/branches/1.12.0-JBC/pom.xml
Log:
EXOJCR-199: JBossCache 3.2.0.GA
Modified: jcr/branches/1.12.0-JBC/pom.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/pom.xml 2009-11-04 14:33:10 UTC (rev 468)
+++ jcr/branches/1.12.0-JBC/pom.xml 2009-11-04 14:57:59 UTC (rev 469)
@@ -396,7 +396,7 @@
org.jboss.cache
jbosscache-core
- 3.1.0.GA
+ 3.2.0.GA
=
--===============1467717702183019910==--
From do-not-reply at jboss.org Wed Nov 4 11:05:19 2009
Content-Type: multipart/mixed; boundary="===============7820944236690949556=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r470 - in
jcr/branches/1.12.0-JBC/component/core:
src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1
other directories.
Date: Wed, 04 Nov 2009 11:05:18 -0500
Message-ID: <200911041605.nA4G5Iev010601@svn01.web.mwc.hst.phx2.redhat.com>
--===============7820944236690949556==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-04 11:05:15 -0500 (Wed, 04 Nov 2009)
New Revision: 470
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Modified:
jcr/branches/1.12.0-JBC/component/core/pom.xml
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorage.java
Log:
EXOJCR-200: tree-based connection deprecated, but still works if needed
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-11-04 14:57:59 UTC =
(rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-11-04 16:05:15 UTC =
(rev 470)
@@ -569,9 +569,9 @@
**/**/JBossCacheServiceTest__.java
- **/**/TestItem_.java
+ **/**/TestItem__.java
=
- **/**/JBossCacheStorageConnectionTest.jav=
a
+ **/**/JBossCacheTreeStorageConnectionTest=
.java
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-04 14:57:=
59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-04 16:05:=
15 UTC (rev 470)
@@ -114,7 +114,7 @@
{
QPathEntry nodeName =3D QPathEntry.parse(name.getLastElemen=
tAsString());
=
- // TODO non effective, in this way 1) all subtree will be c=
ached
+ // 1) all subtree will be cached
// 2) all subtree will be read from DB (with allprops) for =
only Ids.
// The effective way DON NOT use calls to cache and use spe=
cial SQLs for Ids only read. =
String parentId =3D (String)cache.get(name.getParent(), JBo=
ssCacheStorage.ITEM_ID);
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-04 14:57:=
59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-04 16:05:=
15 UTC (rev 470)
@@ -59,13 +59,13 @@
=
public static final String ITEM_ID =3D "$id".intern();
=
- protected final Fqn treeRoot;
+ protected final Fqn namesRoot;
=
protected final Fqn itemsRoot;
=
- protected JBossCacheStorage(Fqn treeRoot, Fqn itemsRoot)
+ protected JBossCacheStorage(Fqn namesRoot, Fqn itemsRoo=
t)
{
- this.treeRoot =3D treeRoot;
+ this.namesRoot =3D namesRoot;
this.itemsRoot =3D itemsRoot;
}
=
@@ -79,7 +79,7 @@
fqns[i] =3D path[i].getAsString(true);
}
=
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
}
=
protected Fqn makeParentFqn(QPath propertyPath)
@@ -93,7 +93,7 @@
fqns[i] =3D path[i].getAsString(true);
}
=
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
+ return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
}
=
protected Fqn makeIdFqn(String itemId)
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatfo=
rm/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-04 16:05:15 UTC (rev 470)
@@ -1,404 +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 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-/**
- * Created by The eXo Platform SAS.
- * =
- * Date: 23.10.2009
- *
- * Cache contains several regions:
- * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id s=
tored.
- * Items map. /$ITEMS: Key=3DId, Value =3D ItemData.
- * References map ??? /$REFS: Key=3DNodeId, Value =3D PropertyId.
- *
- * @author Peter N=
edonosko =
- * @version $Id$
- */
-public class JBossCacheStorageConnection extends JBossCacheStorage impleme=
nts WorkspaceStorageConnection
-{
-
- protected static final Log LOG =3D ExoLogger.getLogger("jcr.JBossCacheS=
torageConnection");
-
- private final Cache cache;
-
- //private final Node treeRoot;
-
- //private final Node itemsRoot;
-
- /**
- * Start batching flag. 'true' if batching was started, 'false' if bat=
ching is not start. =
- */
- private boolean batchStarted =3D false;
-
- /**
- * JBossCacheStorageConnection constructor.
- *
- * @param cache Cache
- */
- public JBossCacheStorageConnection(Cache cache, N=
ode treeRoot,
- Node itemsRoot)
- {
- super(treeRoot.getFqn(), itemsRoot.getFqn());
- =
- this.cache =3D cache;
- //this.itemsRoot =3D itemsRoot;
- //this.treeRoot =3D treeRoot;
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(NodeData data) throws RepositoryException, UnsupportedO=
perationException, InvalidItemStateException,
- IllegalStateException
- {
- startBatch();
- cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier(=
));
- cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // tree=
Print(treeRoot);
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(PropertyData data) throws RepositoryException, Unsuppor=
tedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- Fqn parentFqn =3D makeParentFqn(data.getQPath());
-
- // add an attr to the parent node as key=3DPropertyName value=3DProp=
ertyId
- cache.put(parentFqn, data.getQPath().getName().getAsString(), data.g=
etIdentifier());
- cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- cache.removeNode(makeNodeFqn(data.getQPath()));
- cache.removeNode(makeIdFqn(data.getIdentifier()));
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- // delete attr on parent by key=3DPropertyName
- cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName=
().getAsString());
- cache.removeNode(makeIdFqn(data.getIdentifier()));
- }
-
- /**
- * {@inheritDoc}
- */
- public List getChildNodesData(NodeData parent) throws Reposit=
oryException, IllegalStateException
- {
- //Set childNames =3D cache.getChildrenNames(makeNodeFqn(pare=
nt.getQPath()));
- Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
- if (parentNode =3D=3D null)
- {
- throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
- }
-
- Set> childNodes =3D parentNode.getChildre=
n();
-
- List childs =3D new ArrayList();
- for (Node child : childNodes)
- {
- String childId =3D (String)child.get(ITEM_ID);
-
- // TODO NodeData or PropertyData? As ItemData check then and cast.
- NodeData node =3D (NodeData)cache.get(makeIdFqn(childId), ITEM_DA=
TA);
- if (node =3D=3D null)
- {
- throw new RepositoryException("One of childs is null. Parent "=
+ parent.getQPath().getAsString());
- }
- childs.add(node);
- }
-
- return childs;
- }
-
- private void treePrint(Node node)
- {
- for (Node child : node.getChildren())
- {
- System.out.println(child.toString());
- for (Serializable key : child.getKeys())
- {
- System.out.println("\t" + key + "=3D" + child.get(key));
- }
- if (!child.isLeaf())
- {
- treePrint(child);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List getChildPropertiesData(NodeData parent) throw=
s RepositoryException, IllegalStateException
- {
- // TODO treeRoot.getChild(f) possible if f not a direct child??? =
- Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
- if (parentNode =3D=3D null)
- {
- throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
- }
-
- List childs =3D new ArrayList();
-
- for (Serializable key : parentNode.getKeys())
- {
- if (!key.equals(ITEM_ID))
- {
- String propId =3D (String)parentNode.get(key);
- // TODO NodeData or PropertyData? As ItemData check then and c=
ast. =
- PropertyData property =3D (PropertyData)cache.get(makeIdFqn(pr=
opId), ITEM_DATA);
- if (property =3D=3D null)
- {
- throw new RepositoryException("One of childs is null. Paren=
t " + parent.getQPath().getAsString());
- }
- childs.add(property);
- }
- }
-
- return childs;
- }
-
- /**
- * {@inheritDoc}
- */
- public List listChildPropertiesData(NodeData parent) thro=
ws RepositoryException, IllegalStateException
- {
- // TODO it's same as getChild... now
- return getChildPropertiesData(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name) throw=
s RepositoryException, IllegalStateException
- {
- Node parentNode =3D cache.getNode(makeNodeFqn(=
parentData.getQPath()));
- if (parentNode =3D=3D null)
- {
- throw new IllegalStateException("Get Item data error: parent not =
found " + parentData.getQPath().getAsString());
- }
-
- // TODO check performance of Node vs Property get
-
- String propertyId =3D (String)parentNode.get(name.getAsString());
- if (propertyId !=3D null)
- {
- // it's Property Item
- return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
- }
- else
- {
- // it's Node Item
- Node node =3D parentNode.getChild(name.getA=
sString(true)); // TODO String not Fqn?
- if (node !=3D null)
- {
- String nodeId =3D (String)node.get(ITEM_ID);
- if (nodeId !=3D null)
- {
- return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
- }
- }
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(String identifier) throws RepositoryExcepti=
on, IllegalStateException
- {
- return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
- }
-
- /**
- * {@inheritDoc}
- */
- public List getReferencesData(String nodeIdentifier) thro=
ws RepositoryException,
- IllegalStateException, UnsupportedOperationException
- {
- // TODO refs impl
- return new ArrayList();
- }
-
- /**
- * {@inheritDoc}
- */
- public void rename(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- // TODO move Node to a new position at the tree,
- // but prev location was in prev DELETE.
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
-
- // TODO it's put anyway.. but with check?
- Object prev =3D cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, dat=
a.getIdentifier());
- if (prev =3D=3D null)
- {
- throw new IllegalStateException("Node was deleted (tree)");
- }
-
- prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
- if (prev =3D=3D null)
- {
- throw new IllegalStateException("Node was deleted (items)");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
-
- // TODO it's put anyway.. but with check?
- Fqn parentFqn =3D makeParentFqn(data.getQPath());
- Object prev =3D cache.put(parentFqn, data.getQPath().getName().getAs=
String(), data.getIdentifier());
- if (prev =3D=3D null)
- {
- throw new IllegalStateException("Property was deleted (tree)");
- }
-
- prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
- if (prev =3D=3D null)
- {
- throw new IllegalStateException("Property was deleted (items)");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void commit() throws IllegalStateException, RepositoryException
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("commit " + batchStarted);
- }
-
- // end batch
- if (batchStarted)
- {
- this.cache.endBatch(true); // treePrint(treeRoot);
- batchStarted =3D false;
- }
- else
- {
- // TODO
- LOG.warn("Commit call without changes made.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void rollback() throws IllegalStateException, RepositoryException
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("rollback " + batchStarted);
- }
-
- // rollback batch
- if (batchStarted)
- {
- this.cache.endBatch(false);
- batchStarted =3D false;
- }
- else
- {
- // TODO
- LOG.warn("Rollback call without changes made.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isOpened()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() throws IllegalStateException, RepositoryException
- {
- // TODO Auto-generated method stub
- }
-
- /**
- * Start batching.
- */
- private void startBatch()
- {
- if (!batchStarted)
- {
- batchStarted =3D true;
- this.cache.startBatch();
- }
- }
-
-}
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform=
/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,404 @@
+/*
+ * 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 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 23.10.2009
+ *
+ * Cache contains several regions:
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id s=
tored.
+ * Items map. /$ITEMS: Key=3DId, Value =3D ItemData.
+ * References map ??? /$REFS: Key=3DNodeId, Value =3D PropertyId.
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+public class JBossCacheStorageConnection extends JBossCacheStorage impleme=
nts WorkspaceStorageConnection
+{
+
+ protected static final Log LOG =3D ExoLogger.getLogger("jcr.JBossCacheS=
torageConnection");
+
+ private final Cache cache;
+
+ //private final Node treeRoot;
+
+ //private final Node itemsRoot;
+
+ /**
+ * Start batching flag. 'true' if batching was started, 'false' if bat=
ching is not start. =
+ */
+ private boolean batchStarted =3D false;
+
+ /**
+ * JBossCacheStorageConnection constructor.
+ *
+ * @param cache Cache
+ */
+ public JBossCacheStorageConnection(Cache cache, N=
ode treeRoot,
+ Node itemsRoot)
+ {
+ super(treeRoot.getFqn(), itemsRoot.getFqn());
+ =
+ this.cache =3D cache;
+ //this.itemsRoot =3D itemsRoot;
+ //this.treeRoot =3D treeRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(NodeData data) throws RepositoryException, UnsupportedO=
perationException, InvalidItemStateException,
+ IllegalStateException
+ {
+ startBatch();
+ cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier(=
));
+ cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // tree=
Print(treeRoot);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(PropertyData data) throws RepositoryException, Unsuppor=
tedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ Fqn parentFqn =3D makeParentFqn(data.getQPath());
+
+ // add an attr to the parent node as key=3DPropertyName value=3DProp=
ertyId
+ cache.put(parentFqn, data.getQPath().getName().getAsString(), data.g=
etIdentifier());
+ cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ cache.removeNode(makeNodeFqn(data.getQPath()));
+ cache.removeNode(makeIdFqn(data.getIdentifier()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ // delete attr on parent by key=3DPropertyName
+ cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName=
().getAsString());
+ cache.removeNode(makeIdFqn(data.getIdentifier()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getChildNodesData(NodeData parent) throws Reposit=
oryException, IllegalStateException
+ {
+ //Set childNames =3D cache.getChildrenNames(makeNodeFqn(pare=
nt.getQPath()));
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
+ }
+
+ Set> childNodes =3D parentNode.getChildre=
n();
+
+ List childs =3D new ArrayList();
+ for (Node child : childNodes)
+ {
+ String childId =3D (String)child.get(ITEM_ID);
+
+ // TODO NodeData or PropertyData? As ItemData check then and cast.
+ NodeData node =3D (NodeData)cache.get(makeIdFqn(childId), ITEM_DA=
TA);
+ if (node =3D=3D null)
+ {
+ throw new RepositoryException("One of childs is null. Parent "=
+ parent.getQPath().getAsString());
+ }
+ childs.add(node);
+ }
+
+ return childs;
+ }
+
+ private void treePrint(Node node)
+ {
+ for (Node child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=3D" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getChildPropertiesData(NodeData parent) throw=
s RepositoryException, IllegalStateException
+ {
+ // TODO treeRoot.getChild(f) possible if f not a direct child??? =
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
+ }
+
+ List childs =3D new ArrayList();
+
+ for (Serializable key : parentNode.getKeys())
+ {
+ if (!key.equals(ITEM_ID))
+ {
+ String propId =3D (String)parentNode.get(key);
+ // TODO NodeData or PropertyData? As ItemData check then and c=
ast. =
+ PropertyData property =3D (PropertyData)cache.get(makeIdFqn(pr=
opId), ITEM_DATA);
+ if (property =3D=3D null)
+ {
+ throw new RepositoryException("One of childs is null. Paren=
t " + parent.getQPath().getAsString());
+ }
+ childs.add(property);
+ }
+ }
+
+ return childs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List listChildPropertiesData(NodeData parent) thro=
ws RepositoryException, IllegalStateException
+ {
+ // TODO it's same as getChild... now
+ return getChildPropertiesData(parent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throw=
s RepositoryException, IllegalStateException
+ {
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parentData.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get Item data error: parent not =
found " + parentData.getQPath().getAsString());
+ }
+
+ // TODO check performance of Node vs Property get
+
+ String propertyId =3D (String)parentNode.get(name.getAsString());
+ if (propertyId !=3D null)
+ {
+ // it's Property Item
+ return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
+ }
+ else
+ {
+ // it's Node Item
+ Node node =3D parentNode.getChild(name.getA=
sString(true)); // TODO String not Fqn?
+ if (node !=3D null)
+ {
+ String nodeId =3D (String)node.get(ITEM_ID);
+ if (nodeId !=3D null)
+ {
+ return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(String identifier) throws RepositoryExcepti=
on, IllegalStateException
+ {
+ return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getReferencesData(String nodeIdentifier) thro=
ws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ // TODO refs impl
+ return new ArrayList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rename(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ // TODO move Node to a new position at the tree,
+ // but prev location was in prev DELETE.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+
+ // TODO it's put anyway.. but with check?
+ Object prev =3D cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, dat=
a.getIdentifier());
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Node was deleted (tree)");
+ }
+
+ prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Node was deleted (items)");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+
+ // TODO it's put anyway.. but with check?
+ Fqn parentFqn =3D makeParentFqn(data.getQPath());
+ Object prev =3D cache.put(parentFqn, data.getQPath().getName().getAs=
String(), data.getIdentifier());
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Property was deleted (tree)");
+ }
+
+ prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Property was deleted (items)");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("commit " + batchStarted);
+ }
+
+ // end batch
+ if (batchStarted)
+ {
+ this.cache.endBatch(true); // treePrint(treeRoot);
+ batchStarted =3D false;
+ }
+ else
+ {
+ // TODO
+ LOG.warn("Commit call without changes made.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("rollback " + batchStarted);
+ }
+
+ // rollback batch
+ if (batchStarted)
+ {
+ this.cache.endBatch(false);
+ batchStarted =3D false;
+ }
+ else
+ {
+ // TODO
+ LOG.warn("Rollback call without changes made.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isOpened()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Start batching.
+ */
+ private void startBatch()
+ {
+ if (!batchStarted)
+ {
+ batchStarted =3D true;
+ this.cache.startBatch();
+ }
+ }
+
+}
Copied: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatfor=
m/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java=
(from rev 465, jcr/branches/1.12.0-JBC/component/core/src/main/java/org/ex=
oplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.=
java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 200=
9-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,408 @@
+/*
+ * 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 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+/**
+ * DEPRECATED - DO NOT USE!
+ * =
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 23.10.2009
+ *
+ * Cache contains several regions:
+ * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id s=
tored.
+ * Items map. /$ITEMS: Key=3DId, Value =3D ItemData.
+ * References map ??? /$REFS: Key=3DNodeId, Value =3D PropertyId.
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+(a)Deprecated
+public class JBossCacheTreeStorageConnection extends JBossCacheStorage imp=
lements WorkspaceStorageConnection
+{
+
+ protected static final Log LOG =3D ExoLogger.getLogger("jcr.JBossCacheS=
torageConnection");
+
+ private final Cache cache;
+
+ //private final Node treeRoot;
+
+ //private final Node itemsRoot;
+
+ /**
+ * Start batching flag. 'true' if batching was started, 'false' if bat=
ching is not start. =
+ */
+ private boolean batchStarted =3D false;
+
+ /**
+ * JBossCacheStorageConnection constructor.
+ *
+ * @param cache Cache
+ */
+ @Deprecated
+ public JBossCacheTreeStorageConnection(Cache cach=
e, Node treeRoot,
+ Node itemsRoot)
+ {
+ super(treeRoot.getFqn(), itemsRoot.getFqn());
+ =
+ this.cache =3D cache;
+ //this.itemsRoot =3D itemsRoot;
+ //this.treeRoot =3D treeRoot;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(NodeData data) throws RepositoryException, UnsupportedO=
perationException, InvalidItemStateException,
+ IllegalStateException
+ {
+ startBatch();
+ cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier(=
));
+ cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data); // tree=
Print(treeRoot);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void add(PropertyData data) throws RepositoryException, Unsuppor=
tedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ Fqn parentFqn =3D makeParentFqn(data.getQPath());
+
+ // add an attr to the parent node as key=3DPropertyName value=3DProp=
ertyId
+ cache.put(parentFqn, data.getQPath().getName().getAsString(), data.g=
etIdentifier());
+ cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ cache.removeNode(makeNodeFqn(data.getQPath()));
+ cache.removeNode(makeIdFqn(data.getIdentifier()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void delete(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ // delete attr on parent by key=3DPropertyName
+ cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName=
().getAsString());
+ cache.removeNode(makeIdFqn(data.getIdentifier()));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getChildNodesData(NodeData parent) throws Reposit=
oryException, IllegalStateException
+ {
+ //Set childNames =3D cache.getChildrenNames(makeNodeFqn(pare=
nt.getQPath()));
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
+ }
+
+ Set> childNodes =3D parentNode.getChildre=
n();
+
+ List childs =3D new ArrayList();
+ for (Node child : childNodes)
+ {
+ String childId =3D (String)child.get(ITEM_ID);
+
+ // TODO NodeData or PropertyData? As ItemData check then and cast.
+ NodeData node =3D (NodeData)cache.get(makeIdFqn(childId), ITEM_DA=
TA);
+ if (node =3D=3D null)
+ {
+ throw new RepositoryException("One of childs is null. Parent "=
+ parent.getQPath().getAsString());
+ }
+ childs.add(node);
+ }
+
+ return childs;
+ }
+
+ private void treePrint(Node node)
+ {
+ for (Node child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=3D" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getChildPropertiesData(NodeData parent) throw=
s RepositoryException, IllegalStateException
+ {
+ // TODO treeRoot.getChild(f) possible if f not a direct child??? =
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parent.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get child Nodes error: parent no=
t found " + parent.getQPath().getAsString());
+ }
+
+ List childs =3D new ArrayList();
+
+ for (Serializable key : parentNode.getKeys())
+ {
+ if (!key.equals(ITEM_ID))
+ {
+ String propId =3D (String)parentNode.get(key);
+ // TODO NodeData or PropertyData? As ItemData check then and c=
ast. =
+ PropertyData property =3D (PropertyData)cache.get(makeIdFqn(pr=
opId), ITEM_DATA);
+ if (property =3D=3D null)
+ {
+ throw new RepositoryException("One of childs is null. Paren=
t " + parent.getQPath().getAsString());
+ }
+ childs.add(property);
+ }
+ }
+
+ return childs;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List listChildPropertiesData(NodeData parent) thro=
ws RepositoryException, IllegalStateException
+ {
+ // TODO it's same as getChild... now
+ return getChildPropertiesData(parent);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name) throw=
s RepositoryException, IllegalStateException
+ {
+ Node parentNode =3D cache.getNode(makeNodeFqn(=
parentData.getQPath()));
+ if (parentNode =3D=3D null)
+ {
+ throw new IllegalStateException("Get Item data error: parent not =
found " + parentData.getQPath().getAsString());
+ }
+
+ // TODO check performance of Node vs Property get
+
+ String propertyId =3D (String)parentNode.get(name.getAsString());
+ if (propertyId !=3D null)
+ {
+ // it's Property Item
+ return (PropertyData)cache.get(makeIdFqn(propertyId), ITEM_DATA);
+ }
+ else
+ {
+ // it's Node Item
+ Node node =3D parentNode.getChild(name.getA=
sString(true)); // TODO String not Fqn?
+ if (node !=3D null)
+ {
+ String nodeId =3D (String)node.get(ITEM_ID);
+ if (nodeId !=3D null)
+ {
+ return (NodeData)cache.get(makeIdFqn(nodeId), ITEM_DATA);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(String identifier) throws RepositoryExcepti=
on, IllegalStateException
+ {
+ return (ItemData)cache.get(makeIdFqn(identifier), ITEM_DATA);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getReferencesData(String nodeIdentifier) thro=
ws RepositoryException,
+ IllegalStateException, UnsupportedOperationException
+ {
+ // TODO refs impl
+ return new ArrayList();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rename(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+ // TODO move Node to a new position at the tree,
+ // but prev location was in prev DELETE.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(NodeData data) throws RepositoryException, Unsupport=
edOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+
+ // TODO it's put anyway.. but with check?
+ Object prev =3D cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, dat=
a.getIdentifier());
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Node was deleted (tree)");
+ }
+
+ prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Node was deleted (items)");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void update(PropertyData data) throws RepositoryException, Unsup=
portedOperationException,
+ InvalidItemStateException, IllegalStateException
+ {
+ startBatch();
+
+ // TODO it's put anyway.. but with check?
+ Fqn parentFqn =3D makeParentFqn(data.getQPath());
+ Object prev =3D cache.put(parentFqn, data.getQPath().getName().getAs=
String(), data.getIdentifier());
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Property was deleted (tree)");
+ }
+
+ prev =3D cache.put(makeIdFqn(data.getIdentifier()), ITEM_DATA, data);
+ if (prev =3D=3D null)
+ {
+ throw new IllegalStateException("Property was deleted (items)");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws IllegalStateException, RepositoryException
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("commit " + batchStarted);
+ }
+
+ // end batch
+ if (batchStarted)
+ {
+ this.cache.endBatch(true); // treePrint(treeRoot);
+ batchStarted =3D false;
+ }
+ else
+ {
+ // TODO
+ LOG.warn("Commit call without changes made.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws IllegalStateException, RepositoryException
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("rollback " + batchStarted);
+ }
+
+ // rollback batch
+ if (batchStarted)
+ {
+ this.cache.endBatch(false);
+ batchStarted =3D false;
+ }
+ else
+ {
+ // TODO
+ LOG.warn("Rollback call without changes made.");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isOpened()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void close() throws IllegalStateException, RepositoryException
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Start batching.
+ */
+ private void startBatch()
+ {
+ if (!batchStarted)
+ {
+ batchStarted =3D true;
+ this.cache.startBatch();
+ }
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageCo=
nnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatfo=
rm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-04 14=
:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java 2009-11-04 16=
:05:15 UTC (rev 470)
@@ -1,41 +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 3 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;
-
-
-/**
- * Created by The eXo Platform SAS.
- * =
- * Date: 30.10.2009
- *
- * @author Peter N=
edonosko =
- * @version $Id$
- */
-public class ExoJCRCacheLoaderTest extends JBossCacheStorageConnectionTest
-{
-
- @Override
- protected void initJBCConfig()
- {
- jbcConfig =3D "conf/standalone/test-jbosscache-config-exoloader.xml";
- }
-
- =
- =
-}
Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatfor=
m/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java (from=
rev 468, jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoaderTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java 2009-11-0=
4 16:05:15 UTC (rev 470)
@@ -0,0 +1,41 @@
+/*
+ * 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 3 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;
+
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 30.10.2009
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+public class ExoJCRTreeCacheLoaderTest extends JBossCacheTreeStorageConnec=
tionTest
+{
+
+ @Override
+ protected void initJBCConfig()
+ {
+ jbcConfig =3D "conf/standalone/test-jbosscache-config-exoloader.xml";
+ }
+
+ =
+ =
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTe=
st.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatfo=
rm/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 200=
9-11-04 14:57:59 UTC (rev 469)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 200=
9-11-04 16:05:15 UTC (rev 470)
@@ -1,685 +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.
- */
-/*
- * 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 junit.framework.TestCase;
-
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS.
- * =
- * Date: 25.10.2009
- *
- * @author Peter N=
edonosko =
- * @version $Id$
- */
-public class JBossCacheStorageConnectionTest extends TestCase
-{
-
- protected JBossCacheStorageConnection conn;
-
- protected Cache cache;
-
- protected Node tree;
-
- protected Node items;
- =
- protected String jbcConfig; =
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // JBossCache =
- initJBCConfig();
- =
- cache =3D new DefaultCacheFactory().createCach=
e(jbcConfig);
-
- Node cacheRoot =3D cache.getRoot();
- //Node wsRoot =3D cacheRoot.addChild(Fqn.fromE=
lements("repo", "ws"));
-
- // prepare cache structures
- tree =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
- items =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS)=
);
-
- // run cache
- cache.create();
- cache.start();
-
- // JCR connection
- conn =3D new JBossCacheStorageConnection(cache, tree, items);
- }
- =
- protected void initJBCConfig() {
- jbcConfig =3D "conf/standalone/test-jbosscache-config-jdbcloader.xml=
";
- }
-
- /**
- * {@inheritDoc}
- */
- protected void tearDown() throws Exception
- {
-
- cache.stop();
- cache.destroy();
-
- super.tearDown();
- }
-
- private void treePrint(Node node)
- {
- for (Node child : node.getChildren())
- {
- System.out.println(child.toString());
- for (Serializable key : child.getKeys())
- {
- System.out.println("\t" + key + "=3D" + child.get(key));
- }
- if (!child.isLeaf())
- {
- treePrint(child);
- }
- }
- }
-
- private Fqn makeFqn(Node root, QPath node=
Path)
- {
- QPathEntry[] path =3D nodePath.getEntries();
- String[] fqns =3D new String[path.length];
-
- for (int i =3D 0; i < path.length; i++)
- {
- fqns[i] =3D path[i].getAsString(true);
- }
-
- return Fqn.fromRelativeFqn(root.getFqn(), Fqn.fromElements(fqns));
- }
-
- public void testAddNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
-
- // check in tree
- treePrint(tree);
-
- // get root node ([]:1)
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertNotNull("Node expected", rootNode);
-
- assertEquals("Childs expected", 2, rootNode.getChildren().size());
-
- for (Node child : rootNode.getChildren())
- {
- String nodeName =3D child.getFqn().getLastElementAsString();
- String nodeId =3D (String)child.get(JBossCacheStorageConnection.I=
TEM_ID);
- if (nodeName.equals(node1path.getEntries()[node1path.getEntries()=
.length - 1].getAsString(true)))
- {
- assertEquals("Node id wrong", node1id, nodeId);
- }
- else if (nodeName
- .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_S=
YSTEM_PATH.getEntries().length - 1]
- .getAsString(true)))
- {
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
- }
- else
- {
- fail("Wrong Node name " + nodeName);
- }
- }
-
- // check in items
- treePrint(items);
-
- Node itemsNode =3D items.getChild(Fqn.fromElem=
ents(node1id));
- assertNotNull("Node item data should exists", itemsNode);
-
- Object dataObject =3D itemsNode.get(JBossCacheStorageConnection.ITEM=
_DATA);
- assertTrue("Node item data is not a Node", dataObject instanceof Nod=
eData);
-
- NodeData data =3D (NodeData)dataObject;
- assertEquals("Node id wrong", node1id, data.getIdentifier());
- assertEquals("Node path wrong", node1path, data.getQPath());
- }
-
- public void testAddProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/jcr:primaryType)
- String propId1 =3D "1";
- QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
- TransientPropertyData propData1 =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValue1 =3D "Property value #1";
- propData1.setValue(new TransientValueData(propValue1));
- conn.add(propData1);
-
- // add property (/jcr:mixinTypes)
- String propId2 =3D "2";
- QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
- TransientPropertyData propData2 =3D new TransientPropertyData(propPa=
th2, propId2, 1, 1, Constants.ROOT_UUID, false);
- String propValue2 =3D "Property value #2";
- propData2.setValue(new TransientValueData(propValue2));
- conn.add(propData2);
-
- // check in tree
- treePrint(tree);
-
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size(=
));
-
- String pid1 =3D (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAs=
String());
- assertNotNull("Property ID should exists", pid1);
- assertEquals("Property ID wrong", propId1, pid1);
-
- String pid2 =3D (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsS=
tring());
- assertNotNull("Property ID should exists", pid2);
- assertEquals("Property ID wrong", propId2, pid2);
-
- // TODO check order
- int index =3D 0;
- for (Serializable key : rootNode.getKeys())
- {
- //System.out.println(key);
- //index++;
- }
-
- // check in items
- treePrint(items);
-
- Node itemsProp1 =3D items.getChild(Fqn.fromEle=
ments(propId1));
- Object data1Object =3D itemsProp1.get(JBossCacheStorageConnection.IT=
EM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object insta=
nceof PropertyData);
-
- PropertyData data1 =3D (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValue1, new String(data1.ge=
tValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
-
- Node itemsProp2 =3D items.getChild(Fqn.fromEle=
ments(propId2));
- Object data2Object =3D itemsProp2.get(JBossCacheStorageConnection.IT=
EM_DATA);
- assertNotNull("Property item data should exists", data2Object);
- assertTrue("Property item data is not a Property", data2Object insta=
nceof PropertyData);
-
- PropertyData data2 =3D (PropertyData)data2Object;
- assertEquals("Property id wrong", propId2, data2.getIdentifier());
- assertEquals("Property path wrong", propPath2, data2.getQPath());
- assertEquals("Property Value wrong", propValue2, new String(data2.ge=
tValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
- }
-
- public void testDeleteNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
-
- // get root node ([]:1)
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Number of childs wrong", 2, rootNode.getChildren().siz=
e());
-
- // delete /node
- conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.N=
T_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- Node node =3D
- rootNode.getChild(Fqn
- .fromElements(node1path.getEntries()[node1path.getEntries().le=
ngth - 1].getAsString(true)));
-
- assertNull("Node should be deleted", node);
-
- assertEquals("Childs expected", 1, rootNode.getChildren().size());
-
- Node child =3D rootNode.getChildren().iterator=
().next();
- assertEquals("Node name wrong",
- Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.=
getEntries().length - 1].getAsString(true),
- child.getFqn().getLastElementAsString());
-
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.g=
et(JBossCacheStorageConnection.ITEM_ID));
-
- // check in items
- treePrint(items);
-
- assertNull("Node item data should not exists", items.getChild(Fqn.fr=
omElements(node1id)));
- assertNotNull("Node item data should exists", items.getChild(Fqn.fro=
mElements(Constants.SYSTEM_UUID)));
- }
-
- public void testDeleteProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/jcr:primaryType)
- String propId1 =3D "1";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_PRIMARYTYPE), propId1,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 =3D "2";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_MIXINTYPES), propId2,
- 1, 1, Constants.ROOT_UUID, false));
-
- // get root node ([]:1)
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- // delete /jcr:primaryType
- conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.=
ROOT_PATH, Constants.JCR_PRIMARYTYPE),
- propId1, 1, 1, Constants.ROOT_UUID, false));
-
- // check in tree
- treePrint(tree);
-
- assertEquals("Number of childs wrong", 2, rootNode.getKeys().size());
-
- assertNull("Property should be deleted", rootNode.get(Constants.JCR_=
PRIMARYTYPE.getAsString()));
-
- assertNotNull("Property should exists", rootNode.get(Constants.JCR_M=
IXINTYPES.getAsString()));
-
- // check in items
- treePrint(items);
-
- assertNull("Property item data should not exists", items.getChild(Fq=
n.fromElements(propId1)));
- assertNotNull("Property item data should exists", items.getChild(Fqn=
.fromElements(propId2)));
- }
-
- public void testUpdateNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // get root node ([]:1)
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- // update /node (order number)
- int nodeOrderNumb =3D 1;
- conn.update(new TransientNodeData(node1path, node1id, 1, Constants.N=
T_UNSTRUCTURED, new InternalQName[0],
- nodeOrderNumb, Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- Node node =3D
- rootNode.getChild(Fqn
- .fromElements(node1path.getEntries()[node1path.getEntries().le=
ngth - 1].getAsString(true)));
-
- assertNotNull("Node should exists", node);
- assertEquals("Child expected", 1, rootNode.getChildren().size());
-
- // check in items
- treePrint(items);
-
- Node itemNode =3D items.getChild(Fqn.fromEleme=
nts(node1id));
- assertNotNull("Node item data should exists", itemNode);
-
- Object dataObject =3D itemNode.get(JBossCacheStorageConnection.ITEM_=
DATA);
- assertTrue("Node item data should be a NodeData", dataObject instanc=
eof NodeData);
- assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIde=
ntifier());
- assertEquals("Node path wrong", node1path, ((NodeData)dataObject).ge=
tQPath());
- assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)da=
taObject).getOrderNumber());
- }
-
- public void testUpdateProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/prop1)
- String propId1 =3D "1";
- QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
- TransientPropertyData propData1 =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValue1 =3D "Property value #1";
- propData1.setValue(new TransientValueData(propValue1));
- conn.add(propData1);
-
- // update property (/prop1) with new value
- TransientPropertyData propDataU =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValueU =3D "Updated Property value #1";
- propDataU.setValue(new TransientValueData(propValueU));
- conn.update(propDataU);
-
- // check in tree
- treePrint(tree);
-
- Node rootNode =3D
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size(=
));
-
- String pid =3D (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsS=
tring());
- assertEquals("Property ID wrong", propId1, pid);
-
- // check in items
- treePrint(items);
-
- Node itemsProp1 =3D items.getChild(Fqn.fromEle=
ments(propId1));
- Object data1Object =3D itemsProp1.get(JBossCacheStorageConnection.IT=
EM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object insta=
nceof PropertyData);
-
- PropertyData data1 =3D (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValueU, new String(data1.ge=
tValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
- }
-
- public void testGetNodeByName() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
-
- // check =
- ItemData nodeItem =3D
- conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Const=
ants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new Acces=
sControlList()),
- node1path.getEntries()[node1path.getEntries().length - 1]);
-
- assertTrue("Node expected", nodeItem.isNode());
- assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
- assertEquals("Node path wrong", node1path, nodeItem.getQPath());
- }
-
- public void testGetPropertyByName() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/jcr:primaryType)
- String propId1 =3D "1";
- QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
- conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constan=
ts.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 =3D "2";
- QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
- conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constan=
ts.ROOT_UUID, false));
-
- // check =
- ItemData propItem =3D
- conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Const=
ants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new Acces=
sControlList()),
- propPath1.getEntries()[propPath1.getEntries().length - 1]);
-
- assertFalse("Proeprty expected", propItem.isNode());
- assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
- assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
- }
-
- public void testGetNodeById() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
-
- // check =
- ItemData nodeItem =3D conn.getItemData(node1id);
-
- assertTrue("Node expected", nodeItem.isNode());
- assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
- assertEquals("Node path wrong", node1path, nodeItem.getQPath());
- }
-
- public void testGetPropertyById() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/jcr:primaryType)
- String propId1 =3D "1";
- QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
- conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constan=
ts.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 =3D "2";
- QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
- conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constan=
ts.ROOT_UUID, false));
-
- // check =
- ItemData propItem =3D conn.getItemData(propId1);
-
- assertFalse("Proeprty expected", propItem.isNode());
- assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
- assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
- }
-
- public void testGetChildNodes() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add node (/node)
- String node1id =3D "1";
- QPath node1path =3D QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
-
- // check in tree
- treePrint(tree);
-
- List childs =3D
- conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH,=
Constants.ROOT_UUID, 1,
- Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.=
ROOT_PARENT_UUID, new AccessControlList()));
-
- assertEquals("Childs amount wrong", 2, childs.size());
-
- for (NodeData child : childs)
- {
- if (child.getQPath().equals(node1path))
- {
- assertEquals("Node id wrong", node1id, child.getIdentifier());
- }
- else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
- {
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.get=
Identifier());
- }
- else
- {
- fail("Wrong Node found");
- }
- }
- }
-
- public void testGetChildProperties() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
-
- // add property (/jcr:primaryType)
- String propId1 =3D "1";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_PRIMARYTYPE), propId1,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 =3D "2";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_MIXINTYPES), propId2,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/a)
- String propId3 =3D "3";
- InternalQName propName3 =3D InternalQName.parse("[]a");
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, propName3), propId3, 1, 1,
- Constants.ROOT_UUID, false));
-
- // add property (/b)
- String propId4 =3D "4";
- InternalQName propName4 =3D InternalQName.parse("[]b");
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, propName4), propId4, 1, 1,
- Constants.ROOT_UUID, false));
-
- // check
- treePrint(tree);
-
- List childs =3D
- conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_=
PATH, Constants.ROOT_UUID, 1,
- Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.=
ROOT_PARENT_UUID, new AccessControlList()));
-
- assertEquals("Childs amount wrong", 4, childs.size());
-
- for (PropertyData child : childs)
- {
- if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
- {
- assertEquals("Property id wrong", propId1, child.getIdentifier=
());
- }
- else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYP=
ES))
- {
- assertEquals("Property id wrong", propId2, child.getIdentifier=
());
- }
- else if (child.getQPath().getName().equals(propName3))
- {
- assertEquals("Property id wrong", propId3, child.getIdentifier=
());
- }
- else if (child.getQPath().getName().equals(propName4))
- {
- assertEquals("Property id wrong", propId4, child.getIdentifier=
());
- }
- else
- {
- fail("Wrong Property found");
- }
- }
- }
-
-}
Copied: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatfor=
m/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.=
java (from rev 468, jcr/branches/1.12.0-JBC/component/core/src/test/java/or=
g/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnect=
ionTest.java)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java=
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java=
2009-11-04 16:05:15 UTC (rev 470)
@@ -0,0 +1,685 @@
+/*
+ * 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.
+ */
+/*
+ * 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 junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ * Date: 25.10.2009
+ *
+ * @author Peter N=
edonosko =
+ * @version $Id$
+ */
+public class JBossCacheTreeStorageConnectionTest extends TestCase
+{
+
+ protected JBossCacheTreeStorageConnection conn;
+
+ protected Cache cache;
+
+ protected Node tree;
+
+ protected Node items;
+ =
+ protected String jbcConfig; =
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // JBossCache =
+ initJBCConfig();
+ =
+ cache =3D new DefaultCacheFactory().createCach=
e(jbcConfig);
+
+ Node cacheRoot =3D cache.getRoot();
+ //Node wsRoot =3D cacheRoot.addChild(Fqn.fromE=
lements("repo", "ws"));
+
+ // prepare cache structures
+ tree =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.TREE));
+ items =3D cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.ITEMS)=
);
+
+ // run cache
+ cache.create();
+ cache.start();
+
+ // JCR connection
+ conn =3D new JBossCacheTreeStorageConnection(cache, tree, items);
+ }
+ =
+ protected void initJBCConfig() {
+ jbcConfig =3D "conf/standalone/test-jbosscache-config-jdbcloader.xml=
";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void tearDown() throws Exception
+ {
+
+ cache.stop();
+ cache.destroy();
+
+ super.tearDown();
+ }
+
+ private void treePrint(Node node)
+ {
+ for (Node child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=3D" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
+ private Fqn makeFqn(Node root, QPath node=
Path)
+ {
+ QPathEntry[] path =3D nodePath.getEntries();
+ String[] fqns =3D new String[path.length];
+
+ for (int i =3D 0; i < path.length; i++)
+ {
+ fqns[i] =3D path[i].getAsString(true);
+ }
+
+ return Fqn.fromRelativeFqn(root.getFqn(), Fqn.fromElements(fqns));
+ }
+
+ public void testAddNode() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
+
+ // check in tree
+ treePrint(tree);
+
+ // get root node ([]:1)
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertNotNull("Node expected", rootNode);
+
+ assertEquals("Childs expected", 2, rootNode.getChildren().size());
+
+ for (Node child : rootNode.getChildren())
+ {
+ String nodeName =3D child.getFqn().getLastElementAsString();
+ String nodeId =3D (String)child.get(JBossCacheStorageConnection.I=
TEM_ID);
+ if (nodeName.equals(node1path.getEntries()[node1path.getEntries()=
.length - 1].getAsString(true)))
+ {
+ assertEquals("Node id wrong", node1id, nodeId);
+ }
+ else if (nodeName
+ .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_S=
YSTEM_PATH.getEntries().length - 1]
+ .getAsString(true)))
+ {
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
+ }
+ else
+ {
+ fail("Wrong Node name " + nodeName);
+ }
+ }
+
+ // check in items
+ treePrint(items);
+
+ Node itemsNode =3D items.getChild(Fqn.fromElem=
ents(node1id));
+ assertNotNull("Node item data should exists", itemsNode);
+
+ Object dataObject =3D itemsNode.get(JBossCacheStorageConnection.ITEM=
_DATA);
+ assertTrue("Node item data is not a Node", dataObject instanceof Nod=
eData);
+
+ NodeData data =3D (NodeData)dataObject;
+ assertEquals("Node id wrong", node1id, data.getIdentifier());
+ assertEquals("Node path wrong", node1path, data.getQPath());
+ }
+
+ public void testAddProperty() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 =3D "1";
+ QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
+ TransientPropertyData propData1 =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
+ String propValue1 =3D "Property value #1";
+ propData1.setValue(new TransientValueData(propValue1));
+ conn.add(propData1);
+
+ // add property (/jcr:mixinTypes)
+ String propId2 =3D "2";
+ QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
+ TransientPropertyData propData2 =3D new TransientPropertyData(propPa=
th2, propId2, 1, 1, Constants.ROOT_UUID, false);
+ String propValue2 =3D "Property value #2";
+ propData2.setValue(new TransientValueData(propValue2));
+ conn.add(propData2);
+
+ // check in tree
+ treePrint(tree);
+
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size(=
));
+
+ String pid1 =3D (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAs=
String());
+ assertNotNull("Property ID should exists", pid1);
+ assertEquals("Property ID wrong", propId1, pid1);
+
+ String pid2 =3D (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsS=
tring());
+ assertNotNull("Property ID should exists", pid2);
+ assertEquals("Property ID wrong", propId2, pid2);
+
+ // TODO check order
+ int index =3D 0;
+ for (Serializable key : rootNode.getKeys())
+ {
+ //System.out.println(key);
+ //index++;
+ }
+
+ // check in items
+ treePrint(items);
+
+ Node itemsProp1 =3D items.getChild(Fqn.fromEle=
ments(propId1));
+ Object data1Object =3D itemsProp1.get(JBossCacheStorageConnection.IT=
EM_DATA);
+ assertNotNull("Property item data should exists", data1Object);
+ assertTrue("Property item data is not a Property", data1Object insta=
nceof PropertyData);
+
+ PropertyData data1 =3D (PropertyData)data1Object;
+ assertEquals("Property id wrong", propId1, data1.getIdentifier());
+ assertEquals("Property path wrong", propPath1, data1.getQPath());
+ assertEquals("Property Value wrong", propValue1, new String(data1.ge=
tValues().get(0).getAsByteArray(),
+ Constants.DEFAULT_ENCODING));
+
+ Node itemsProp2 =3D items.getChild(Fqn.fromEle=
ments(propId2));
+ Object data2Object =3D itemsProp2.get(JBossCacheStorageConnection.IT=
EM_DATA);
+ assertNotNull("Property item data should exists", data2Object);
+ assertTrue("Property item data is not a Property", data2Object insta=
nceof PropertyData);
+
+ PropertyData data2 =3D (PropertyData)data2Object;
+ assertEquals("Property id wrong", propId2, data2.getIdentifier());
+ assertEquals("Property path wrong", propPath2, data2.getQPath());
+ assertEquals("Property Value wrong", propValue2, new String(data2.ge=
tValues().get(0).getAsByteArray(),
+ Constants.DEFAULT_ENCODING));
+ }
+
+ public void testDeleteNode() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
+
+ // get root node ([]:1)
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertEquals("Number of childs wrong", 2, rootNode.getChildren().siz=
e());
+
+ // delete /node
+ conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.N=
T_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // check in tree
+ treePrint(tree);
+
+ Node node =3D
+ rootNode.getChild(Fqn
+ .fromElements(node1path.getEntries()[node1path.getEntries().le=
ngth - 1].getAsString(true)));
+
+ assertNull("Node should be deleted", node);
+
+ assertEquals("Childs expected", 1, rootNode.getChildren().size());
+
+ Node child =3D rootNode.getChildren().iterator=
().next();
+ assertEquals("Node name wrong",
+ Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.=
getEntries().length - 1].getAsString(true),
+ child.getFqn().getLastElementAsString());
+
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.g=
et(JBossCacheStorageConnection.ITEM_ID));
+
+ // check in items
+ treePrint(items);
+
+ assertNull("Node item data should not exists", items.getChild(Fqn.fr=
omElements(node1id)));
+ assertNotNull("Node item data should exists", items.getChild(Fqn.fro=
mElements(Constants.SYSTEM_UUID)));
+ }
+
+ public void testDeleteProperty() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 =3D "1";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 =3D "2";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_MIXINTYPES), propId2,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // get root node ([]:1)
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ // delete /jcr:primaryType
+ conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.=
ROOT_PATH, Constants.JCR_PRIMARYTYPE),
+ propId1, 1, 1, Constants.ROOT_UUID, false));
+
+ // check in tree
+ treePrint(tree);
+
+ assertEquals("Number of childs wrong", 2, rootNode.getKeys().size());
+
+ assertNull("Property should be deleted", rootNode.get(Constants.JCR_=
PRIMARYTYPE.getAsString()));
+
+ assertNotNull("Property should exists", rootNode.get(Constants.JCR_M=
IXINTYPES.getAsString()));
+
+ // check in items
+ treePrint(items);
+
+ assertNull("Property item data should not exists", items.getChild(Fq=
n.fromElements(propId1)));
+ assertNotNull("Property item data should exists", items.getChild(Fqn=
.fromElements(propId2)));
+ }
+
+ public void testUpdateNode() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // get root node ([]:1)
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ // update /node (order number)
+ int nodeOrderNumb =3D 1;
+ conn.update(new TransientNodeData(node1path, node1id, 1, Constants.N=
T_UNSTRUCTURED, new InternalQName[0],
+ nodeOrderNumb, Constants.ROOT_UUID, new AccessControlList()));
+
+ // check in tree
+ treePrint(tree);
+
+ Node node =3D
+ rootNode.getChild(Fqn
+ .fromElements(node1path.getEntries()[node1path.getEntries().le=
ngth - 1].getAsString(true)));
+
+ assertNotNull("Node should exists", node);
+ assertEquals("Child expected", 1, rootNode.getChildren().size());
+
+ // check in items
+ treePrint(items);
+
+ Node itemNode =3D items.getChild(Fqn.fromEleme=
nts(node1id));
+ assertNotNull("Node item data should exists", itemNode);
+
+ Object dataObject =3D itemNode.get(JBossCacheStorageConnection.ITEM_=
DATA);
+ assertTrue("Node item data should be a NodeData", dataObject instanc=
eof NodeData);
+ assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIde=
ntifier());
+ assertEquals("Node path wrong", node1path, ((NodeData)dataObject).ge=
tQPath());
+ assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)da=
taObject).getOrderNumber());
+ }
+
+ public void testUpdateProperty() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/prop1)
+ String propId1 =3D "1";
+ QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
+ TransientPropertyData propData1 =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
+ String propValue1 =3D "Property value #1";
+ propData1.setValue(new TransientValueData(propValue1));
+ conn.add(propData1);
+
+ // update property (/prop1) with new value
+ TransientPropertyData propDataU =3D new TransientPropertyData(propPa=
th1, propId1, 1, 1, Constants.ROOT_UUID, false);
+ String propValueU =3D "Updated Property value #1";
+ propDataU.setValue(new TransientValueData(propValueU));
+ conn.update(propDataU);
+
+ // check in tree
+ treePrint(tree);
+
+ Node rootNode =3D
+ tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[C=
onstants.ROOT_PATH.getEntries().length - 1]
+ .getAsString(true)));
+
+ assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size(=
));
+
+ String pid =3D (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsS=
tring());
+ assertEquals("Property ID wrong", propId1, pid);
+
+ // check in items
+ treePrint(items);
+
+ Node itemsProp1 =3D items.getChild(Fqn.fromEle=
ments(propId1));
+ Object data1Object =3D itemsProp1.get(JBossCacheStorageConnection.IT=
EM_DATA);
+ assertNotNull("Property item data should exists", data1Object);
+ assertTrue("Property item data is not a Property", data1Object insta=
nceof PropertyData);
+
+ PropertyData data1 =3D (PropertyData)data1Object;
+ assertEquals("Property id wrong", propId1, data1.getIdentifier());
+ assertEquals("Property path wrong", propPath1, data1.getQPath());
+ assertEquals("Property Value wrong", propValueU, new String(data1.ge=
tValues().get(0).getAsByteArray(),
+ Constants.DEFAULT_ENCODING));
+ }
+
+ public void testGetNodeByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
+
+ // check =
+ ItemData nodeItem =3D
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Const=
ants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new Acces=
sControlList()),
+ node1path.getEntries()[node1path.getEntries().length - 1]);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyByName() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 =3D "1";
+ QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constan=
ts.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 =3D "2";
+ QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constan=
ts.ROOT_UUID, false));
+
+ // check =
+ ItemData propItem =3D
+ conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Const=
ants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new Acces=
sControlList()),
+ propPath1.getEntries()[propPath1.getEntries().length - 1]);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
+ public void testGetNodeById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
+
+ // check =
+ ItemData nodeItem =3D conn.getItemData(node1id);
+
+ assertTrue("Node expected", nodeItem.isNode());
+ assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
+ assertEquals("Node path wrong", node1path, nodeItem.getQPath());
+ }
+
+ public void testGetPropertyById() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 =3D "1";
+ QPath propPath1 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_PRIMARYTYPE);
+ conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constan=
ts.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 =3D "2";
+ QPath propPath2 =3D QPath.makeChildPath(Constants.ROOT_PATH, Constan=
ts.JCR_MIXINTYPES);
+ conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constan=
ts.ROOT_UUID, false));
+
+ // check =
+ ItemData propItem =3D conn.getItemData(propId1);
+
+ assertFalse("Proeprty expected", propItem.isNode());
+ assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
+ assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
+ }
+
+ public void testGetChildNodes() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add node (/node)
+ String node1id =3D "1";
+ QPath node1path =3D QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_U=
NSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.=
SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlLi=
st()));
+
+ // check in tree
+ treePrint(tree);
+
+ List childs =3D
+ conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH,=
Constants.ROOT_UUID, 1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.=
ROOT_PARENT_UUID, new AccessControlList()));
+
+ assertEquals("Childs amount wrong", 2, childs.size());
+
+ for (NodeData child : childs)
+ {
+ if (child.getQPath().equals(node1path))
+ {
+ assertEquals("Node id wrong", node1id, child.getIdentifier());
+ }
+ else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
+ {
+ assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.get=
Identifier());
+ }
+ else
+ {
+ fail("Wrong Node found");
+ }
+ }
+ }
+
+ public void testGetChildProperties() throws Exception
+ {
+ // TODO prepare using JCR WDC API (not a right way, JBC API better..=
. but read assumes the write works)
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_U=
UID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessCo=
ntrolList()));
+
+ // add property (/jcr:primaryType)
+ String propId1 =3D "1";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_PRIMARYTYPE), propId1,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/jcr:mixinTypes)
+ String propId2 =3D "2";
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, Constants.JCR_MIXINTYPES), propId2,
+ 1, 1, Constants.ROOT_UUID, false));
+
+ // add property (/a)
+ String propId3 =3D "3";
+ InternalQName propName3 =3D InternalQName.parse("[]a");
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, propName3), propId3, 1, 1,
+ Constants.ROOT_UUID, false));
+
+ // add property (/b)
+ String propId4 =3D "4";
+ InternalQName propName4 =3D InternalQName.parse("[]b");
+ conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROO=
T_PATH, propName4), propId4, 1, 1,
+ Constants.ROOT_UUID, false));
+
+ // check
+ treePrint(tree);
+
+ List childs =3D
+ conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_=
PATH, Constants.ROOT_UUID, 1,
+ Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.=
ROOT_PARENT_UUID, new AccessControlList()));
+
+ assertEquals("Childs amount wrong", 4, childs.size());
+
+ for (PropertyData child : childs)
+ {
+ if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
+ {
+ assertEquals("Property id wrong", propId1, child.getIdentifier=
());
+ }
+ else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYP=
ES))
+ {
+ assertEquals("Property id wrong", propId2, child.getIdentifier=
());
+ }
+ else if (child.getQPath().getName().equals(propName3))
+ {
+ assertEquals("Property id wrong", propId3, child.getIdentifier=
());
+ }
+ else if (child.getQPath().getName().equals(propName4))
+ {
+ assertEquals("Property id wrong", propId4, child.getIdentifier=
());
+ }
+ else
+ {
+ fail("Wrong Property found");
+ }
+ }
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageCo=
nnectionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
--===============7820944236690949556==--
From do-not-reply at jboss.org Wed Nov 4 11:11:40 2009
Content-Type: multipart/mixed; boundary="===============7629265361752837652=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r471 -
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/container.
Date: Wed, 04 Nov 2009 11:11:39 -0500
Message-ID: <200911041611.nA4GBdPf012431@svn01.web.mwc.hst.phx2.redhat.com>
--===============7629265361752837652==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 11:11:38 -0500 (Wed, 04 Nov 2009)
New Revision: 471
Modified:
kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/containe=
r/RootContainer.java
Log:
EXOJCR-223 Unnecessary message removed
Modified: kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/c=
ontainer/RootContainer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/RootContainer.java 2009-11-04 16:05:15 UTC (rev 470)
+++ kernel/trunk/exo.kernel.container/src/main/java/org/exoplatform/contain=
er/RootContainer.java 2009-11-04 16:11:38 UTC (rev 471)
@@ -428,7 +428,6 @@
else
{
booting =3D true;
- log.info("Booting root container with id " + RootContain=
er.class.hashCode() + "");
log.info("Building root container");
long time =3D -System.currentTimeMillis();
result =3D buildRootContainer();
--===============7629265361752837652==--
From do-not-reply at jboss.org Wed Nov 4 11:33:27 2009
Content-Type: multipart/mixed; boundary="===============3749620708128567051=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r472 -
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security.
Date: Wed, 04 Nov 2009 11:33:27 -0500
Message-ID: <200911041633.nA4GXRTA018804@svn01.web.mwc.hst.phx2.redhat.com>
--===============3749620708128567051==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 11:33:27 -0500 (Wed, 04 Nov 2009)
New Revision: 472
Modified:
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfor=
m/services/security/IdentityRegistry.java
Log:
EXOJCR-224 logging level changed
Modified: core/trunk/exo.core.component.security.core/src/main/java/org/exo=
platform/services/security/IdentityRegistry.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfo=
rm/services/security/IdentityRegistry.java 2009-11-04 16:11:38 UTC (rev 471)
+++ core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfo=
rm/services/security/IdentityRegistry.java 2009-11-04 16:33:27 UTC (rev 472)
@@ -73,7 +73,7 @@
}
catch (NullPointerException e)
{
- LOG.warn("Parameter " + INIT_PARAM_CONCURRENCY_LEVEL + " was not =
found in configuration, default "
+ LOG.info("Parameter " + INIT_PARAM_CONCURRENCY_LEVEL + " was not =
found in configuration, default "
+ DEFAULT_CONCURRENCY_LEVEL + "will be used.");
return DEFAULT_CONCURRENCY_LEVEL;
}
--===============3749620708128567051==--
From do-not-reply at jboss.org Wed Nov 4 11:39:06 2009
Content-Type: multipart/mixed; boundary="===============6454067229350227784=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r473 -
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatform/services/security.
Date: Wed, 04 Nov 2009 11:39:06 -0500
Message-ID: <200911041639.nA4Gd6I0020107@svn01.web.mwc.hst.phx2.redhat.com>
--===============6454067229350227784==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 11:39:05 -0500 (Wed, 04 Nov 2009)
New Revision: 473
Modified:
core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfor=
m/services/security/ConversationRegistry.java
Log:
EXOJCR-225 logging level changed
Modified: core/trunk/exo.core.component.security.core/src/main/java/org/exo=
platform/services/security/ConversationRegistry.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfo=
rm/services/security/ConversationRegistry.java 2009-11-04 16:33:27 UTC (rev=
472)
+++ core/trunk/exo.core.component.security.core/src/main/java/org/exoplatfo=
rm/services/security/ConversationRegistry.java 2009-11-04 16:39:05 UTC (rev=
473)
@@ -85,7 +85,7 @@
}
catch (NullPointerException e)
{
- LOG.warn("Parameter " + INIT_PARAM_CONCURRENCY_LEVEL + " was not =
found in configuration, default "
+ LOG.info("Parameter " + INIT_PARAM_CONCURRENCY_LEVEL + " was not =
found in configuration, default "
+ DEFAULT_CONCURRENCY_LEVEL + " will be used.");
return DEFAULT_CONCURRENCY_LEVEL;
}
--===============6454067229350227784==--
From do-not-reply at jboss.org Wed Nov 4 11:44:38 2009
Content-Type: multipart/mixed; boundary="===============1201467813624139154=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r474 -
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access.
Date: Wed, 04 Nov 2009 11:44:38 -0500
Message-ID: <200911041644.nA4Gicjj021300@svn01.web.mwc.hst.phx2.redhat.com>
--===============1201467813624139154==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: dkatayev
Date: 2009-11-04 11:44:38 -0500 (Wed, 04 Nov 2009)
New Revision: 474
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/core/access/BaseAuthenticator.java
Log:
EXOJCR-226 logging level changed
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/core/access/BaseAuthenticator.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/access/BaseAuthenticator.java 2009-11-04 16:39:05 UTC (rev 4=
73)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/core/access/BaseAuthenticator.java 2009-11-04 16:44:38 UTC (rev 4=
74)
@@ -64,7 +64,7 @@
=
if (state =3D=3D null)
{
- log.warn("No current identity found, ANONYMOUS one will be used");
+ log.debug("No current identity found, ANONYMOUS one will be used"=
);
return new ConversationState(new Identity(SystemIdentity.ANONIM, =
new HashSet()));
}
=
--===============1201467813624139154==--
From do-not-reply at jboss.org Wed Nov 4 11:52:10 2009
Content-Type: multipart/mixed; boundary="===============1093414821630362454=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r475 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Wed, 04 Nov 2009 11:52:10 -0500
Message-ID: <200911041652.nA4GqAX5023313@svn01.web.mwc.hst.phx2.redhat.com>
--===============1093414821630362454==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-04 11:52:09 -0500 (Wed, 04 Nov 2009)
New Revision: 475
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorage.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
Log:
EXOJCR-200: reorg for new storage arch
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-04 16:44:=
38 UTC (rev 474)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-04 16:52:=
09 UTC (rev 475)
@@ -59,16 +59,17 @@
=
public static final String ITEM_ID =3D "$id".intern();
=
- protected final Fqn namesRoot;
+ protected final Fqn treeRoot;
=
protected final Fqn itemsRoot;
=
- protected JBossCacheStorage(Fqn namesRoot, Fqn itemsRoo=
t)
+ protected JBossCacheStorage(Fqn treeRoot, Fqn itemsRoot)
{
- this.namesRoot =3D namesRoot;
+ this.treeRoot =3D treeRoot;
this.itemsRoot =3D itemsRoot;
}
=
+ @Deprecated
protected Fqn makeNodeFqn(QPath nodePath)
{
QPathEntry[] path =3D nodePath.getEntries();
@@ -79,9 +80,10 @@
fqns[i] =3D path[i].getAsString(true);
}
=
- return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
}
=
+ @Deprecated
protected Fqn makeParentFqn(QPath propertyPath)
{
QPathEntry[] path =3D propertyPath.getEntries();
@@ -93,9 +95,14 @@
fqns[i] =3D path[i].getAsString(true);
}
=
- return Fqn.fromRelativeFqn(namesRoot, Fqn.fromElements(fqns));
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
}
=
+ protected Fqn makeTreeFqn(String parentId, QPathEntry itemName)
+ {
+ return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(parentId, item=
Name.getAsString(true)));
+ }
+
protected Fqn makeIdFqn(String itemId)
{
return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(itemId));
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-04 16:44:38 UTC (rev 474)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11=
-04 16:52:09 UTC (rev 475)
@@ -43,8 +43,10 @@
* Date: 23.10.2009
*
* Cache contains several regions:
- * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id s=
tored.
- * Items map. /$ITEMS: Key=3DId, Value =3D ItemData.
+ * Items stored in /$ITEMS: one level ItemId, ItemData in attrs =
+ * Hierarchy in /$ITEMS: two level subtree,
+ * first ItemId (+attr=3DProperties Ids,ItemData),
+ * second JCR Node names with Node id in attr.
* References map ??? /$REFS: Key=3DNodeId, Value =3D PropertyId.
*
* @author Peter N=
edonosko =
@@ -57,10 +59,6 @@
=
private final Cache cache;
=
- //private final Node treeRoot;
-
- //private final Node itemsRoot;
-
/**
* Start batching flag. 'true' if batching was started, 'false' if bat=
ching is not start. =
*/
--===============1093414821630362454==--
From do-not-reply at jboss.org Fri Nov 6 04:36:42 2009
Content-Type: multipart/mixed; boundary="===============4279519825478849055=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r476 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Fri, 06 Nov 2009 04:36:42 -0500
Message-ID: <200911060936.nA69ag1N023542@svn01.web.mwc.hst.phx2.redhat.com>
--===============4279519825478849055==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2009-11-06 04:36:42 -0500 (Fri, 06 Nov 2009)
New Revision: 476
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was added.
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform=
/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 09:36:42 UTC (rev 476)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2003-2009 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
+/**
+ * Created by The eXo Platform SAS.
+ * =
+ *
+ * Date: 06.11.2009
+ * =
+ * @author Alex Re=
shetnyak
+ * @version $Id$
+ */
+public abstract class AbstractWriteOnlyCacheLoader
+ extends AbstractCacheLoader
+{
+ private IndividualCacheLoaderConfig config;
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean exists(Fqn arg0) throws Exception
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Map get(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'Map get(Fqn arg0)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getChildrenNames(Fqn arg0) throws Exception
+ {
+ return new HashSet();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IndividualCacheLoaderConfig getConfig()
+ {
+ return config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(Fqn arg0, Map arg1) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, M=
ap arg1))' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object put(Fqn arg0, Object arg1, Object arg2) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'put(Fqn arg0, O=
bject arg1, Object arg2)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'remove(Fqn arg0=
)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object remove(Fqn arg0, Object arg1) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'remove(Fqn arg0=
, Object arg1)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removeData(Fqn arg0) throws Exception
+ {
+ throw new WriteOnlyCacheLoaderException("The method 'removeData(Fqn =
arg0)' should not be called.");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setConfig(IndividualCacheLoaderConfig config)
+ {
+ this.config =3D config;
+ }
+ =
+ /**
+ * That method should be override in other loaders (indexer, lock, obse=
rvation). =
+ */
+ public abstract void put(List modifications) throws Excep=
tion ;
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheL=
oader.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform=
/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java =
(rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderException.java 2009-=
11-06 09:36:42 UTC (rev 476)
@@ -0,0 +1,48 @@
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+public class WriteOnlyCacheLoaderException
+ extends Exception
+{
+ /**
+ * Constructs an Exception without a message.
+ */
+ public WriteOnlyCacheLoaderException()
+ {
+ super();
+ }
+
+ /**
+ * Constructs an Exception with a detailed message.
+ * =
+ * @param Message
+ * The message associated with the exception.
+ */
+ public WriteOnlyCacheLoaderException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * Constructs an Exception with a detailed message and base exception.
+ * =
+ * @param Message
+ * The message associated with the exception.
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public WriteOnlyCacheLoaderException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * WriteOnlyCacheLoaderException constructor.
+ *
+ * @param cause
+ * Throwable, the base exception.
+ */
+ public WriteOnlyCacheLoaderException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/main/java/o=
rg/exoplatform/services/jcr/impl/storage/jbosscache/WriteOnlyCacheLoaderExc=
eption.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
--===============4279519825478849055==--
From do-not-reply at jboss.org Fri Nov 6 04:39:34 2009
Content-Type: multipart/mixed; boundary="===============8083035942384843767=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r477 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Fri, 06 Nov 2009 04:39:34 -0500
Message-ID: <200911060939.nA69dYBY023703@svn01.web.mwc.hst.phx2.redhat.com>
--===============8083035942384843767==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2009-11-06 04:39:33 -0500 (Fri, 06 Nov 2009)
New Revision: 477
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 09:36:42 UTC (rev 476)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 09:39:33 UTC (rev 477)
@@ -55,7 +55,7 @@
*/
public Map get(Fqn arg0) throws Exception
{
- throw new WriteOnlyCacheLoaderException("The method 'Map get(Fqn arg0)' should not be called.");
+ return Collections.emptyMap();
}
=
/**
--===============8083035942384843767==--
From do-not-reply at jboss.org Fri Nov 6 05:00:29 2009
Content-Type: multipart/mixed; boundary="===============0440635970000448506=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r478 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Fri, 06 Nov 2009 05:00:29 -0500
Message-ID: <200911061000.nA6A0TJa026527@svn01.web.mwc.hst.phx2.redhat.com>
--===============0440635970000448506==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2009-11-06 05:00:28 -0500 (Fri, 06 Nov 2009)
New Revision: 478
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 09:39:33 UTC (rev 477)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 10:00:28 UTC (rev 478)
@@ -63,7 +63,7 @@
*/
public Set getChildrenNames(Fqn arg0) throws Exception
{
- return new HashSet();
+ return null;
}
=
/**
--===============0440635970000448506==--
From do-not-reply at jboss.org Fri Nov 6 05:06:19 2009
Content-Type: multipart/mixed; boundary="===============9216259754656248168=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r479 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Fri, 06 Nov 2009 05:06:19 -0500
Message-ID: <200911061006.nA6A6JkO028189@svn01.web.mwc.hst.phx2.redhat.com>
--===============9216259754656248168==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: areshetnyak
Date: 2009-11-06 05:06:18 -0500 (Fri, 06 Nov 2009)
New Revision: 479
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
Log:
EXOJCR-201 : AbstractWriteOnlyCasheLoader was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 10:00:28 UTC (rev 478)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 10:06:18 UTC (rev 479)
@@ -16,9 +16,7 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
=
-import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -123,7 +121,7 @@
}
=
/**
- * That method should be override in other loaders (indexer, lock, obse=
rvation). =
+ * {@inheritDoc}
*/
public abstract void put(List modifications) throws Excep=
tion ;
=
--===============9216259754656248168==--
From do-not-reply at jboss.org Fri Nov 6 05:17:08 2009
Content-Type: multipart/mixed; boundary="===============6797996022200113941=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r480 -
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
Date: Fri, 06 Nov 2009 05:17:07 -0500
Message-ID: <200911061017.nA6AH7Uq029950@svn01.web.mwc.hst.phx2.redhat.com>
--===============6797996022200113941==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: pnedonosko
Date: 2009-11-06 05:17:07 -0500 (Fri, 06 Nov 2009)
New Revision: 480
Added:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorage.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/ser=
vices/jcr/impl/storage/jbosscache/JBossCacheWorkspaceDataContainer.java
Log:
EXOJCR-200: reorg for new storage arch
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 10:06:18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/AbstractWriteOnlyCacheLoader.java 2009-1=
1-06 10:17:07 UTC (rev 480)
@@ -16,16 +16,16 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
=
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Modification;
+import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
+import org.jboss.cache.loader.AbstractCacheLoader;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
=
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
-import org.jboss.cache.loader.AbstractCacheLoader;
-
/**
* Created by The eXo Platform SAS.
* =
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatfo=
rm/services/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-06 10:06:=
18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/ExoJCRCacheLoader.java 2009-11-06 10:17:=
07 UTC (rev 480)
@@ -1,322 +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.
- */
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.exoplatform.services.jcr.config.RepositoryConfigurationExceptio=
n;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfi=
g;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.loader.AbstractCacheLoader;
-
-/**
- * Created by The eXo Platform SAS.
- * =
- * Date: 31.10.2009
- *
- * @author Peter N=
edonosko =
- * @version $Id$
- */
-public class ExoJCRCacheLoader extends AbstractCacheLoader
-{
-
- private WorkspaceDataContainer dataContainer;
-
- /**
- * Init the loader DataContainer with given WorkspaceDataContainer inst=
ance.
- *
- * @param dataContainer WorkspaceDataContainer
- */
- @Inject
- public void initDataContainer(WorkspaceDataContainer dataContainer) thr=
ows RepositoryConfigurationException
- {
- if (this.dataContainer !=3D null)
- {
- throw new RepositoryConfigurationException("Cannot set WorkspaceD=
ataContainer twice");
- }
-
- this.dataContainer =3D dataContainer;
- }
-
- protected QPathEntry[] makeNodePath(Fqn nodeFqn) throws NumberF=
ormatException, IllegalNameException
- {
- List elements =3D nodeFqn.peekElements();
- QPathEntry[] path =3D new QPathEntry[elements.size()];
-
- for (int i =3D 0; i < elements.size(); i++)
- {
- path[i] =3D QPathEntry.parse(elements.get(i));
- }
-
- return path;
- }
-
- /**
- * {@inheritDoc}
- */
- public Map get(Fqn name) throws Exception
- {
-
- Map attrs =3D new LinkedHashMap();
- if (name.size() > 1)
- {
- if (name.get(1).equals(JBossCacheStorage.TREE))
- {
- // return Node
- if (name.size() > 3)
- {
- QPathEntry nodeName =3D QPathEntry.parse(name.getLastElemen=
tAsString());
-
- // 1) all subtree will be cached
- // 2) all subtree will be read from DB (with allprops) for =
only Ids.
- // The effective way DON NOT use calls to cache and use spe=
cial SQLs for Ids only read. =
- String parentId =3D (String)cache.get(name.getParent(), JBo=
ssCacheStorage.ITEM_ID);
-
- WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
- try
- {
- NodeData parent =3D (NodeData)conn.getItemData(parentId);
-
- ItemData item =3D conn.getItemData(parent, nodeName);
-
- // item Id
- attrs.put(JBossCacheStorage.ITEM_ID, item.getIdentifier(=
));
-
- // if Node (Property cannot due to logic of StorageConne=
ction) add props
- for (PropertyData prop : conn.getChildPropertiesData(par=
ent))
- {
- attrs.put(prop.getQPath().getName().getAsString(), pr=
op.getIdentifier());
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- // root Node (/$TREE/[]:1)
- attrs.put(JBossCacheStorage.ITEM_ID, Constants.ROOT_UUID);
- }
- }
- else if (name.get(1).equals(JBossCacheStorage.ITEMS))
- {
- // we have all data on thrid level =
- if (name.size() =3D=3D 3)
- {
- // return Node or Property
- String itemId =3D name.getLastElementAsString();
-
- WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
- try
- {
- attrs.put(JBossCacheStorage.ITEM_DATA, conn.getItemData(=
itemId));
- }
- finally
- {
- conn.close();
- }
- }
- }
- }
- return attrs;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean exists(Fqn name) throws Exception
- {
- // TODO do it with less cost
- return get(name) !=3D null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set> getChildrenNames(Fqn fqn) throws Exception
- {
- // return child nodes names
-
- Set childs =3D new LinkedHashSet();
- if (fqn.size() > 2)
- {
- if (fqn.get(2).equals(JBossCacheStorage.TREE))
- {
- // return Node
- if (fqn.size() > 3)
- {
- QPathEntry nodeName =3D QPathEntry.parse(fqn.getLastElement=
AsString());
-
- // TODO non effective, in this way 1) all subtree will be c=
ached
- // 2) all subtree will be read from DB (with allprops) for =
only Ids.
- // The effective way DON NOT use calls to cache and use spe=
cial SQLs for Ids only read. =
- String parentId =3D (String)cache.get(fqn.getParent(), JBos=
sCacheStorage.ITEM_ID);
-
- WorkspaceStorageConnection conn =3D dataContainer.openConne=
ction();
- try
- {
- NodeData parent =3D (NodeData)conn.getItemData(parentId);
-
- NodeData node =3D (NodeData)conn.getItemData(parent, nod=
eName);
-
- // get child nodes by parent Id
- for (NodeData prop : conn.getChildNodesData(node))
- {
- childs
- .add(node.getQPath().getEntries()[node.getQPath().=
getEntries().length - 1].getAsString(true));
- }
- }
- finally
- {
- conn.close();
- }
- }
- else
- {
- // root Node (/$TREE/[]:1)
- childs.add(Constants.ROOT_PATH.getEntries()[Constants.ROOT_=
PATH.getEntries().length - 1]
- .getAsString(true));
- }
- }
- else if (fqn.get(2).equals(JBossCacheStorage.ITEMS))
- {
- // we have all data on thrid level =
- if (fqn.size() =3D=3D 3)
- {
- // return all Nodes and Properties Ids
-
-// WorkspaceStorageConnection conn =3D dataContainer.openCon=
nection();
-// try
-// {
-// for (String itemId : conn.getAllItemIdentifiers())
-// {
-// childs.add(itemId);
-// }
-// }
-// finally
-// {
-// conn.close();
-// }
- }
- }
- }
- else if (fqn.equals(Fqn.ROOT))
- {
- childs.add(JBossCacheStorage.TREE);
- childs.add(JBossCacheStorage.ITEMS);
- }
- return childs;
- }
-
- /**
- * {@inheritDoc}
- */
- public IndividualCacheLoaderConfig getConfig()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object put(Fqn name, Object key, Object value) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(Fqn name, Map attributes) throws Except=
ion
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public Object remove(Fqn fqn, Object key) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove(Fqn fqn) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeData(Fqn fqn) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- public void setConfig(IndividualCacheLoaderConfig config)
- {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatf=
orm/services/jcr/impl/storage/jbosscache/JBossCacheStorage.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-06 10:06:=
18 UTC (rev 479)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/se=
rvices/jcr/impl/storage/jbosscache/JBossCacheStorage.java 2009-11-06 10:17:=
07 UTC (rev 480)
@@ -51,6 +51,7 @@
public abstract class JBossCacheStorage
{
=
+ @Deprecated
public static final String TREE =3D "$TREE".intern();
=
public static final String ITEMS =3D "$ITEMS".intern();
@@ -59,14 +60,24 @@
=
public static final String ITEM_ID =3D "$id".intern();
=
+ @Deprecated
protected final Fqn treeRoot;
=
protected final Fqn itemsRoot;
=
+ @Deprecated
protected JBossCacheStorage(Fqn treeRoot, Fqn itemsRoot)
{
+ this.itemsRoot =3D itemsRoot;
+ =
this.treeRoot =3D treeRoot;
+ }
+ =
+ protected JBossCacheStorage(Fqn itemsRoot)
+ {
this.itemsRoot =3D itemsRoot;
+ =
+ this.treeRoot =3D null;
}
=
@Deprecated
@@ -97,13 +108,26 @@
=
return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
}
-
- protected Fqn makeTreeFqn(String parentId, QPathEntry itemName)
+ =
+ /**
+ * Make Child Node Fqn, i.e. /IDxxx/NAMExxx.
+ *
+ * @param parentId String =
+ * @param itemName QPathEntry
+ * @return Fqn
+ */
+ protected Fqn makeChildNodeFqn(String parentId, QPathEntry item=
Name)
{
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(parentId, item=
Name.getAsString(true)));
+ return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromElements(parentId, ite=
mName.getAsString(true)));
}
=
- protected Fqn makeIdFqn(String itemId)
+ /**
+ * Make Item Fqn, i.e. /IDxxx.
+ *
+ * @param itemId String
+ * @return Fqn
+ */
+ protected Fqn