exo-jcr SVN: r34 - jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent.
by do-not-reply@jboss.org
Author: skabashnyuk
Date: 2009-08-28 05:49:00 -0400 (Fri, 28 Aug 2009)
New Revision: 34
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
Log:
EXOJCR-12 : port from 1.11.x
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2009-08-28 09:28:31 UTC (rev 33)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2009-08-28 09:49:00 UTC (rev 34)
@@ -1722,16 +1722,60 @@
}
else if (state.isUpdated())
{
- // UPDATE occurs on reordered (no subtree!) and merged nodes (for each merged-updated)
- if (item.isNode() && prevState != null)
+ // UPDATE occurs on reordered (no subtree!) and merged nodes (for each
+ // merged-updated)
+ if (item.isNode())
{
- // play only for reorder, UPDATE goes after DELETE of same path item
- // we have to unload node and its parent child nodes to be loaded
- // back from the persistence
- if (prevState.isDeleted()
- && prevState.getData().getParentIdentifier().equals(item.getParentIdentifier()))
- removeSiblings((NodeData) item);
+ if (prevState != null)
+ {
+ // play only for reorder, UPDATE goes after DELETE of same path
+ // item
+ // we have to unload node and its parent child nodes to be loaded
+ // back from the persistence
+ if (prevState.isDeleted()
+ && prevState.getData().getParentIdentifier().equals(item.getParentIdentifier()))
+ removeSiblings((NodeData)item);
+ }
}
+ else if (item.getQPath().getName().equals(Constants.EXO_PERMISSIONS))
+ {
+ // TODO JCR-1117 place to put workaround for JCR cache
+ // exo:permissions updated
+ // get parent Node
+
+ // check if parent is mix:privilegeable
+ ItemData parent = get(item.getParentIdentifier());
+ // delete parent
+ remove(parent);
+ // traverse itemCache
+
+ Iterator<CacheValue> cacheIterator = cache.values().iterator();
+ while (cacheIterator.hasNext())
+ {
+ ItemData cachedItem = cacheIterator.next().getItem();
+ if (cachedItem.isNode())
+ {
+ if (cachedItem.getQPath().isDescendantOf(parent.getQPath()))
+ {
+ cacheIterator.remove();
+ }
+ }
+ }
+
+ // traverse child node Cache
+ Iterator<List<NodeData>> childNodesIterator = nodesCache.values().iterator();
+ while (childNodesIterator.hasNext())
+ {
+ List<NodeData> list = childNodesIterator.next();
+ if (list != null && list.size() > 0)
+ {
+ if (list.get(0).getQPath().isDescendantOf(parent.getQPath()))
+ {
+ childNodesIterator.remove();
+ }
+ }
+ }
+ }
put(item);
}
else if (state.isMixinChanged())
16 years, 8 months
exo-jcr SVN: r33 - jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-08-28 05:28:31 -0400 (Fri, 28 Aug 2009)
New Revision: 33
Modified:
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java
Log:
EXOJCR-2: JCR-1174 merged.
Modified: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java 2009-08-28 09:05:55 UTC (rev 32)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/hierarchy/impl/NodeHierarchyCreatorImpl.java 2009-08-28 09:28:31 UTC (rev 33)
@@ -238,6 +238,7 @@
getSession(sessionProvider, currentRepo, currentRepo.getConfiguration().getDefaultWorkspaceName());
Node rootNode = session.getRootNode();
String publicApplication = getJcrPath(PUBLIC_APPLICATION);
+ session.logout();
return rootNode.getNode(publicApplication.substring(1, publicApplication.length()));
}
@@ -258,6 +259,10 @@
userNode = usersNode.addNode(userName);
usersNode.save();
}
+ finally
+ {
+ session.logout();
+ }
return userNode;
}
16 years, 8 months
exo-jcr SVN: r32 - in jcr/trunk/component: ext/src/test/java/org/exoplatform/services/jcr/ext/replication and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-08-28 05:05:55 -0400 (Fri, 28 Aug 2009)
New Revision: 32
Added:
jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationDocumentViewImportTest.java
jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationSysViewImportTest.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
Log:
EXOJCR-8 : Add tests and fixed problem with WorkspaceImpl.importXML.
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2009-08-28 08:14:13 UTC (rev 31)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2009-08-28 09:05:55 UTC (rev 32)
@@ -79,6 +79,7 @@
public abstract class BaseXmlImporter
implements ContentImporter
{
+ private static final String SESSION_ID = "00base0xml0importer0session0id00";
protected final AccessManager accessManager;
@@ -133,7 +134,7 @@
this.currentWorkspaceName = currentWorkspaceName;
this.tree = new Stack<NodeData>();
this.tree.push(parent);
- this.changesLog = new PlainChangesLogImpl();
+ this.changesLog = new PlainChangesLogImpl(SESSION_ID);
this.ancestorToSave = ancestorToSave;
this.isNeedReloadAncestorToSave = false;
}
Added: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationDocumentViewImportTest.java
===================================================================
--- jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationDocumentViewImportTest.java (rev 0)
+++ jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationDocumentViewImportTest.java 2009-08-28 09:05:55 UTC (rev 32)
@@ -0,0 +1,88 @@
+/*
+ * 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.ext.replication;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import javax.jcr.Node;
+
+/**
+ * Created by The eXo Platform SAS Author : Alex Reshetnyak alex.reshetnyak(a)exoplatform.com.ua
+ * 21.08.2009 10:59:36
+ *
+ * @version $Id: ReplicationDocumentViewImportTest.java 25.08.2009 10:49:36 rainfox
+ */
+
+public class ReplicationDocumentViewImportTest
+ extends BaseReplicationTest
+{
+ public void testDocumentViewImportOverSession() throws Exception
+ {
+ Node nl1 = root.addNode("s_doc_view_node_l1");
+ nl1.addNode("s_doc_view_node_l2");
+ root.save();
+
+ File f = File.createTempFile("s_doc_view", ".xml");
+ f.deleteOnExit();
+
+ // export
+ session.exportDocumentView(nl1.getPath(), new FileOutputStream(f), false, false);
+
+ Node parentImportPath = root.addNode("s_imported_doc_view_node");
+ root.save();
+
+ //import
+ session.importXML(parentImportPath.getPath(), new FileInputStream(f), 0);
+ session.save();
+
+ Thread.sleep(5 * 1000);
+
+ // check
+ root.getNode("s_imported_doc_view_node").getNode("s_doc_view_node_l1").getNode("s_doc_view_node_l2");
+ root2.getNode("s_imported_doc_view_node").getNode("s_doc_view_node_l1").getNode("s_doc_view_node_l2");
+ }
+
+ public void testDocumentViewImportOverWorksapce() throws Exception
+ {
+ Node nl1 = root.addNode("w_doc_view_node_l1");
+ nl1.addNode("w_doc_view_node_l2");
+ root.save();
+
+ File f = File.createTempFile("w_doc_view", ".xml");
+ f.deleteOnExit();
+
+ // export
+ session.exportDocumentView(nl1.getPath(), new FileOutputStream(f), false, false);
+
+ Node parentImportPath = root.addNode("w_imported_doc_view_node");
+ root.save();
+
+ //import
+ session.getWorkspace().importXML(parentImportPath.getPath(), new FileInputStream(f), 0);
+ session.save();
+
+ Thread.sleep(5 * 1000);
+
+ // check
+ root.getNode("w_imported_doc_view_node").getNode("w_doc_view_node_l1").getNode("w_doc_view_node_l2");
+ root2.getNode("w_imported_doc_view_node").getNode("w_doc_view_node_l1").getNode("w_doc_view_node_l2");
+ }
+}
Property changes on: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationDocumentViewImportTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationSysViewImportTest.java
===================================================================
--- jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationSysViewImportTest.java (rev 0)
+++ jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationSysViewImportTest.java 2009-08-28 09:05:55 UTC (rev 32)
@@ -0,0 +1,89 @@
+/*
+ * 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.ext.replication;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import javax.jcr.Node;
+
+/**
+ * Created by The eXo Platform SAS Author : Alex Reshetnyak alex.reshetnyak(a)exoplatform.com.ua
+ * 21.08.2009 10:59:36
+ *
+ * @version $Id: ReplicationSysViewImportTest.java 25.08.2009 10:49:36 rainfox
+ */
+
+public class ReplicationSysViewImportTest
+ extends BaseReplicationTest
+{
+
+ public void testSysViewImportOverSession() throws Exception
+ {
+ Node nl1 = root.addNode("s_sys_view_node_l1");
+ nl1.addNode("s_sys_view_node_l2");
+ root.save();
+
+ File f = File.createTempFile("s_sys_view", ".xml");
+ f.deleteOnExit();
+
+ // export
+ session.exportSystemView(nl1.getPath(), new FileOutputStream(f), false, false);
+
+ Node parentImportPath = root.addNode("s_imported_sys_view_node");
+ root.save();
+
+ //import
+ session.importXML(parentImportPath.getPath(), new FileInputStream(f), 0);
+ root.save();
+
+ Thread.sleep(5 * 1000);
+
+ // check
+ root.getNode("s_imported_sys_view_node").getNode("s_sys_view_node_l1").getNode("s_sys_view_node_l2");
+ root2.getNode("s_imported_sys_view_node").getNode("s_sys_view_node_l1").getNode("s_sys_view_node_l2");
+ }
+
+ public void testSysViewImportOverWorkspace() throws Exception
+ {
+ Node nl1 = root.addNode("w_sys_view_node_l1");
+ nl1.addNode("w_sys_view_node_l2");
+ root.save();
+
+ File f = File.createTempFile("w_sys_view", ".xml");
+ f.deleteOnExit();
+
+ // export
+ session.exportSystemView(nl1.getPath(), new FileOutputStream(f), false, false);
+
+ Node parentImportPath = root.addNode("w_imported_sys_view_node");
+ root.save();
+
+ //import
+ session.getWorkspace().importXML(parentImportPath.getPath(), new FileInputStream(f), 0);
+ root.save();
+
+ Thread.sleep(5 * 1000);
+
+ // check
+ root.getNode("w_imported_sys_view_node").getNode("w_sys_view_node_l1").getNode("w_sys_view_node_l2");
+ root2.getNode("w_imported_sys_view_node").getNode("w_sys_view_node_l1").getNode("w_sys_view_node_l2");
+ }
+}
Property changes on: jcr/trunk/component/ext/src/test/java/org/exoplatform/services/jcr/ext/replication/ReplicationSysViewImportTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r31 - in jcr/trunk/component/core/src: test/java/org/exoplatform/services/jcr/impl/core and 1 other directory.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-08-28 04:14:13 -0400 (Fri, 28 Aug 2009)
New Revision: 31
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
Log:
EXOJCR-2: JCR-1094 merging.
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-08-28 08:07:58 UTC (rev 30)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-08-28 08:14:13 UTC (rev 31)
@@ -71,8 +71,7 @@
* @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov </a>
* @version $Id: SessionDataManager.java 14590 2008-05-22 08:51:29Z pnedonosko $
*/
-public class SessionDataManager
- implements ItemDataConsumer
+public class SessionDataManager implements ItemDataConsumer
{
public static final int MERGE_NODES = 1;
@@ -149,7 +148,7 @@
public ItemData getItemData(QPath path) throws RepositoryException
{
- NodeData parent = (NodeData) getItemData(Constants.ROOT_UUID);
+ NodeData parent = (NodeData)getItemData(Constants.ROOT_UUID);
if (path.equals(Constants.ROOT_PATH))
return parent;
@@ -180,7 +179,7 @@
break;
if (item.isNode())
- parent = (NodeData) item;
+ parent = (NodeData)item;
else if (i < relPathEntries.length - 1)
throw new IllegalPathException("Path can not contains a property as the intermediate element");
}
@@ -198,7 +197,10 @@
{
if (name.getName().equals(JCRPath.PARENT_RELPATH) && name.getNamespace().equals(Constants.NS_DEFAULT_URI))
{
- return getItemData(parent.getParentIdentifier());
+ if (parent.getIdentifier().equals(Constants.ROOT_UUID))
+ return null;
+ else
+ return getItemData(parent.getParentIdentifier());
}
ItemData data = null;
@@ -272,8 +274,8 @@
if (!item.hasPermission(PermissionType.READ))
{
throw new AccessDeniedException("Access denied "
- + QPath.makeChildPath(parent.getQPath(), name).getAsString() + " for " + session.getUserID()
- + " (get item by path)");
+ + QPath.makeChildPath(parent.getQPath(), name).getAsString() + " for " + session.getUserID()
+ + " (get item by path)");
}
if (pool)
@@ -285,8 +287,8 @@
{
if (log.isDebugEnabled())
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + name.getAsString() + ") --> "
- + (item != null ? item.getPath() : "null") + " <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ + "sec");
}
}
@@ -328,8 +330,8 @@
if (!item.hasPermission(PermissionType.READ))
{
throw new AccessDeniedException("Access denied "
- + session.getLocationFactory().createJCRPath(QPath.makeChildPath(parent.getQPath(), relPath))
- .getAsString(false) + " for " + session.getUserID() + " (get item by path)");
+ + session.getLocationFactory().createJCRPath(QPath.makeChildPath(parent.getQPath(), relPath))
+ .getAsString(false) + " for " + session.getUserID() + " (get item by path)");
}
if (pool)
@@ -347,8 +349,8 @@
debugPath += rp.getAsString();
}
log.debug("getItem(" + parent.getQPath().getAsString() + " + " + debugPath + ") --> "
- + (item != null ? item.getPath() : "null") + " <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + (item != null ? item.getPath() : "null") + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ + "sec");
}
}
}
@@ -380,7 +382,7 @@
if (!item.hasPermission(PermissionType.READ))
{
throw new AccessDeniedException("Access denied " + path.getAsString() + " for " + session.getUserID()
- + " (get item by path)");
+ + " (get item by path)");
}
if (pool)
@@ -392,7 +394,7 @@
{
if (log.isDebugEnabled())
log.debug("getItem(" + path.getAsString() + ") --> " + (item != null ? item.getPath() : "null") + " <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -424,7 +426,7 @@
if (!item.hasPermission(PermissionType.READ))
{
throw new AccessDeniedException("Access denied, item with id : " + item.getPath()
- + " (get item by id), user " + session.getUserID() + " has no privileges on reading");
+ + " (get item by id), user " + session.getUserID() + " has no privileges on reading");
}
if (pool)
return itemsPool.get(item);
@@ -435,7 +437,7 @@
{
if (log.isDebugEnabled())
log.debug("getItemByIdentifier(" + identifier + ") --> " + (item != null ? item.getPath() : "null")
- + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + " <<<<< " + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -495,7 +497,7 @@
if (item.isNode())
{
// this node and child changes only
- Collection<ItemState> nodeChanges = changesLog.getLastModifyStates((NodeData) item);
+ Collection<ItemState> nodeChanges = changesLog.getLastModifyStates((NodeData)item);
return nodeChanges.size() > 0;
}
@@ -530,7 +532,7 @@
{
// check for permission for read
// [PN] 21.12.07 use item data
- NodeData parent = (NodeData) getItemData(data.getParentIdentifier());
+ NodeData parent = (NodeData)getItemData(data.getParentIdentifier());
// skip not permitted
if (accessManager.hasPermission(parent.getACL(), PermissionType.READ, session.getUserState().getIdentity()))
{
@@ -541,10 +543,10 @@
if (state.isDeleted()) // skip deleted
continue;
- item = (PropertyImpl) itemFactory.createItem(state.getData());
+ item = (PropertyImpl)itemFactory.createItem(state.getData());
}
else
- item = (PropertyImpl) itemFactory.createItem(data);
+ item = (PropertyImpl)itemFactory.createItem(data);
refs.add(item);
session.getActionHandler().postRead(item);
@@ -588,7 +590,7 @@
if (accessManager.hasPermission(data.getACL(), PermissionType.READ, session.getUserState().getIdentity()))
{
if (pool)
- item = (NodeImpl) itemsPool.get(item);
+ item = (NodeImpl)itemsPool.get(item);
nodes.add(item);
}
@@ -599,7 +601,7 @@
{
if (log.isDebugEnabled())
log.debug("getChildNodes(" + parent.getQPath().getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -617,7 +619,7 @@
* if it's no permissions for childs listing
*/
public List<PropertyImpl> getChildProperties(NodeData parent, boolean pool) throws RepositoryException,
- AccessDeniedException
+ AccessDeniedException
{
long start = System.currentTimeMillis();
@@ -635,7 +637,7 @@
{
if (pool)
item = itemsPool.get(item);
- props.add((PropertyImpl) item);
+ props.add((PropertyImpl)item);
}
}
return props;
@@ -644,7 +646,7 @@
{
if (log.isDebugEnabled())
log.debug("getChildProperties(" + parent.getQPath().getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -659,13 +661,13 @@
try
{
- return (List<NodeData>) merge(parent, transactionableManager, false, MERGE_NODES);
+ return (List<NodeData>)merge(parent, transactionableManager, false, MERGE_NODES);
}
finally
{
if (log.isDebugEnabled())
log.debug("getChildNodesData(" + parent.getQPath().getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -683,13 +685,13 @@
try
{
- return (List<PropertyData>) merge(parent, transactionableManager, false, MERGE_PROPS);
+ return (List<PropertyData>)merge(parent, transactionableManager, false, MERGE_PROPS);
}
finally
{
if (log.isDebugEnabled())
log.debug("getChildPropertiesData(" + parent.getQPath().getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -707,13 +709,13 @@
try
{
- return (List<PropertyData>) mergeList(parent, transactionableManager, false, MERGE_PROPS);
+ return (List<PropertyData>)mergeList(parent, transactionableManager, false, MERGE_PROPS);
}
finally
{
if (log.isDebugEnabled())
log.debug("listChildPropertiesData(" + parent.getQPath().getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -734,7 +736,7 @@
try
{
- NodeData parent = (NodeData) getItemData(Constants.ROOT_UUID);
+ NodeData parent = (NodeData)getItemData(Constants.ROOT_UUID);
if (path.equals(Constants.ROOT_PATH))
return parent.getACL();
@@ -748,14 +750,14 @@
break;
if (item.isNode())
- parent = (NodeData) item;
+ parent = (NodeData)item;
else if (i < relPathEntries.length - 1)
throw new IllegalPathException("Get ACL. Path can not contains a property as the intermediate element");
}
if (item != null && item.isNode())
// node ACL
- return ((NodeData) item).getACL();
+ return ((NodeData)item).getACL();
else
// item not found or it's a property - return parent ACL
return parent.getACL();
@@ -764,7 +766,7 @@
{
if (log.isDebugEnabled())
log.debug("getACL(" + path.getAsString() + ") <<<<< " + ((System.currentTimeMillis() - start) / 1000d)
- + "sec");
+ + "sec");
}
}
@@ -779,7 +781,7 @@
ItemData item = getItemData(parent, name);
if (item != null && item.isNode())
// node ACL
- return ((NodeData) item).getACL();
+ return ((NodeData)item).getACL();
else
// item not found or it's a property - return parent ACL
return parent.getACL();
@@ -788,7 +790,7 @@
{
if (log.isDebugEnabled())
log.debug("getACL(" + parent.getQPath().getAsString() + " + " + name.getAsString() + ") <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
}
@@ -798,7 +800,7 @@
for (ItemImpl item : pooledItems)
{
if (item.getInternalPath().isDescendantOf(fromItem.getQPath())
- || item.getInternalPath().equals(fromItem.getQPath()))
+ || item.getInternalPath().equals(fromItem.getQPath()))
{
ItemData ri = getItemData(item.getInternalIdentifier());
if (ri != null)
@@ -846,15 +848,15 @@
boolean fireEvent = !isNew(itemData.getIdentifier());
- NodeTypeManagerImpl ntManager = (NodeTypeManagerImpl) session.getWorkspace().getNodeTypeManager();
+ NodeTypeManagerImpl ntManager = (NodeTypeManagerImpl)session.getWorkspace().getNodeTypeManager();
// if node mix:versionable vs will be removed from Item.remove method.
boolean checkRemoveChildVersionStorages = false;
if (itemData.isNode())
{
checkRemoveChildVersionStorages =
- !session.getWorkspace().getNodeTypesHolder().isNodeType(Constants.NT_VERSIONHISTORY,
- ((NodeData) itemData).getPrimaryTypeName());
+ !session.getWorkspace().getNodeTypesHolder().isNodeType(Constants.NT_VERSIONHISTORY,
+ ((NodeData)itemData).getPrimaryTypeName());
}
boolean rootAdded = false;
@@ -866,13 +868,13 @@
// if subnode contains JCR_VERSIONHISTORY property
// we should remove version storage manually
if (checkRemoveChildVersionStorages && !data.isNode()
- && Constants.JCR_VERSIONHISTORY.equals(data.getQPath().getName()))
+ && Constants.JCR_VERSIONHISTORY.equals(data.getQPath().getName()))
{
try
{
- PropertyData vhPropertyData = (PropertyData) getItemData(data.getIdentifier());
+ PropertyData vhPropertyData = (PropertyData)getItemData(data.getIdentifier());
removeVersionHistory(new String(vhPropertyData.getValues().get(0).getAsByteArray()), null,
- ancestorToSave);
+ ancestorToSave);
}
catch (IllegalStateException e)
{
@@ -921,7 +923,7 @@
// log.info(changesLog.dump())
if (itemData.isNode())
// 8 reindex same-name siblings
- changesLog.addAll(reindexSameNameSiblings((NodeData) itemData, this));
+ changesLog.addAll(reindexSameNameSiblings((NodeData)itemData, this));
}
/**
@@ -933,10 +935,10 @@
* @throws VersionException
*/
public void removeVersionHistory(String vhID, QPath containingHistory, QPath ancestorToSave)
- throws RepositoryException, ConstraintViolationException, VersionException
+ throws RepositoryException, ConstraintViolationException, VersionException
{
- NodeData vhnode = (NodeData) getItemData(vhID);
+ NodeData vhnode = (NodeData)getItemData(vhID);
if (vhnode == null)
{
@@ -950,18 +952,17 @@
return;
throw new RepositoryException("Version history is not found. UUID: " + vhID
- + ". Context item (ancestor to save) " + ancestorToSave.getAsString());
+ + ". Context item (ancestor to save) " + ancestorToSave.getAsString());
}
// mix:versionable
// we have to be sure that any versionable node somewhere in repository
// doesn't refers to a VH of the node being deleted.
- RepositoryImpl rep = (RepositoryImpl) session.getRepository();
+ RepositoryImpl rep = (RepositoryImpl)session.getRepository();
for (String wsName : rep.getWorkspaceNames())
{
SessionImpl wsSession =
- session.getWorkspace().getName().equals(wsName) ? session : (SessionImpl) rep
- .getSystemSession(wsName);
+ session.getWorkspace().getName().equals(wsName) ? session : (SessionImpl)rep.getSystemSession(wsName);
try
{
for (PropertyData sref : wsSession.getTransientNodesManager().getReferencesData(vhID, false))
@@ -972,7 +973,7 @@
if (sref.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH))
{
if (!sref.getQPath().isDescendantOf(vhnode.getQPath())
- && (containingHistory != null ? !sref.getQPath().isDescendantOf(containingHistory) : true))
+ && (containingHistory != null ? !sref.getQPath().isDescendantOf(containingHistory) : true))
// has a reference to the VH in version storage,
// it's a REFERENCE property jcr:childVersionHistory of
// nt:versionedChild
@@ -1001,8 +1002,8 @@
// remove child versions from VH (if found)
ChildVersionRemoveVisitor cvremover =
- new ChildVersionRemoveVisitor(session.getTransientNodesManager(), session.getWorkspace()
- .getNodeTypesHolder(), vhnode.getQPath(), ancestorToSave);
+ new ChildVersionRemoveVisitor(session.getTransientNodesManager(), session.getWorkspace().getNodeTypesHolder(),
+ vhnode.getQPath(), ancestorToSave);
vhnode.accept(cvremover);
// remove VH
@@ -1017,20 +1018,20 @@
* , a node caused reindexing, i.e. deleted or moved node.
*/
protected List<ItemState> reindexSameNameSiblings(NodeData cause, ItemDataConsumer dataManager)
- throws RepositoryException
+ throws RepositoryException
{
List<ItemState> changes = new ArrayList<ItemState>();
- NodeData parentNodeData = (NodeData) dataManager.getItemData(cause.getParentIdentifier());
+ NodeData parentNodeData = (NodeData)dataManager.getItemData(cause.getParentIdentifier());
TransientNodeData nextSibling =
- (TransientNodeData) dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(),
- cause.getQPath().getIndex() + 1));
+ (TransientNodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause
+ .getQPath().getIndex() + 1));
String reindexedId = null;
// repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
// reindexed
while (nextSibling != null && !nextSibling.getIdentifier().equals(cause.getIdentifier())
- && !nextSibling.getIdentifier().equals(reindexedId))
+ && !nextSibling.getIdentifier().equals(reindexedId))
{
// update with new index
NodeData reindexed = nextSibling.cloneAsSibling(nextSibling.getQPath().getIndex() - 1);
@@ -1047,8 +1048,8 @@
// next...
nextSibling =
- (TransientNodeData) dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath()
- .getName(), nextSibling.getQPath().getIndex() + 1));
+ (TransientNodeData)dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath().getName(),
+ nextSibling.getQPath().getIndex() + 1));
}
return changes;
@@ -1093,7 +1094,7 @@
* @throws InvalidItemStateException
*/
public void commit(QPath path) throws RepositoryException, AccessDeniedException, ReferentialIntegrityException,
- InvalidItemStateException, ItemExistsException
+ InvalidItemStateException, ItemExistsException
{
// validate all, throw an exception if validation failed
@@ -1156,14 +1157,14 @@
* @see org.exoplatform.services.jcr.dataflow.ItemDataConsumer#getReferencesData(java.lang.String)
*/
public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
- throws RepositoryException
+ throws RepositoryException
{
// simple locate now
List<PropertyData> persisted = transactionableManager.getReferencesData(identifier, skipVersionStorage);
List<PropertyData> sessionTransient = new ArrayList<PropertyData>();
for (PropertyData p : persisted)
{
- sessionTransient.add((PropertyData) p);
+ sessionTransient.add((PropertyData)p);
}
return sessionTransient;
}
@@ -1194,10 +1195,10 @@
// If no permissions in the list throw exception.
if (itemState.isDescendantOf(path))
{
- if (((NodeData) itemState.getData()).getACL().getPermissionsSize() < 1)
+ if (((NodeData)itemState.getData()).getACL().getPermissionsSize() < 1)
{
throw new RepositoryException("Node " + itemState.getData().getQPath().getAsString()
- + " has wrong formed ACL.");
+ + " has wrong formed ACL.");
}
}
}
@@ -1213,8 +1214,8 @@
if (path.isDescendantOf(itemState.getAncestorToSave()))
{
throw new ConstraintViolationException(path.getAsString()
- + " is the same or descendant of either Session.move()'s destination or source node only "
- + path.getAsString());
+ + " is the same or descendant of either Session.move()'s destination or source node only "
+ + path.getAsString());
}
}
}
@@ -1232,11 +1233,11 @@
NodeData node;
if (changedItem.getData().isNode())
{
- node = ((NodeData) changedItem.getData());
+ node = ((NodeData)changedItem.getData());
}
else
{
- node = (NodeData) getItemData(changedItem.getData().getParentIdentifier());
+ node = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
if (node == null)
return; // parent was deleted
}
@@ -1256,7 +1257,7 @@
*/
private void validateAccessPermissions(ItemState changedItem) throws RepositoryException, AccessDeniedException
{
- NodeData parent = (NodeData) getItemData(changedItem.getData().getParentIdentifier());
+ NodeData parent = (NodeData)getItemData(changedItem.getData().getParentIdentifier());
if (parent != null)
{
@@ -1264,10 +1265,10 @@
if (changedItem.isDeleted())
{
if (!accessManager.hasPermission(parent.getACL(), PermissionType.REMOVE, session.getUserState()
- .getIdentity()))
+ .getIdentity()))
throw new AccessDeniedException("Access denied: REMOVE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
- + " item owner " + parent.getACL().getOwner());
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ + parent.getACL().getOwner());
}
else if (changedItem.getData().isNode())
{
@@ -1275,11 +1276,11 @@
if (changedItem.isAdded())
{
if (!accessManager.hasPermission(parent.getACL(), PermissionType.ADD_NODE, session.getUserState()
- .getIdentity()))
+ .getIdentity()))
{
throw new AccessDeniedException("Access denied: ADD_NODE "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
- + " item owner " + parent.getACL().getOwner());
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ + parent.getACL().getOwner());
}
}
}
@@ -1287,10 +1288,10 @@
{
// add or update property
if (!accessManager.hasPermission(parent.getACL(), PermissionType.SET_PROPERTY, session.getUserState()
- .getIdentity()))
+ .getIdentity()))
throw new AccessDeniedException("Access denied: SET_PROPERTY "
- + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID()
- + " item owner " + parent.getACL().getOwner());
+ + changedItem.getData().getQPath().getAsString() + " for: " + session.getUserID() + " item owner "
+ + parent.getACL().getOwner());
}
} // else - parent not found, deleted in this session or from another
}
@@ -1305,12 +1306,12 @@
private void validateMandatoryItem(ItemState changedItem) throws ConstraintViolationException, AccessDeniedException
{
if (changedItem.getData().isNode() && changedItem.isAdded()
- && !changesLog.getItemState(changedItem.getData().getQPath()).isDeleted())
+ && !changesLog.getItemState(changedItem.getData().getQPath()).isDeleted())
{
// Node not in delete state. It might be a wrong
if (!changesLog.getItemState(changedItem.getData().getIdentifier()).isDeleted())
{
- NodeData nData = (NodeData) changedItem.getData();
+ NodeData nData = (NodeData)changedItem.getData();
try
{
validateMandatoryChildren(nData);
@@ -1332,19 +1333,19 @@
}
public void validateMandatoryChildren(NodeData nData) throws ConstraintViolationException, AccessDeniedException,
- RepositoryException
+ RepositoryException
{
Collection<ItemDefinitionData> mandatoryItemDefs =
- session.getWorkspace().getNodeTypesHolder().getManadatoryItemDefs(nData.getPrimaryTypeName(),
- nData.getMixinTypeNames());
+ session.getWorkspace().getNodeTypesHolder().getManadatoryItemDefs(nData.getPrimaryTypeName(),
+ nData.getMixinTypeNames());
for (ItemDefinitionData itemDefinitionData : mandatoryItemDefs)
{
if (getItemData(nData, new QPathEntry(itemDefinitionData.getName(), 0)) == null)
throw new ConstraintViolationException("Mandatory item " + itemDefinitionData.getName()
- + " not found. Node [" + nData.getQPath().getAsString() + " primary type: "
- + nData.getPrimaryTypeName().getAsString() + "]");
+ + " not found. Node [" + nData.getQPath().getAsString() + " primary type: "
+ + nData.getPrimaryTypeName().getAsString() + "]");
}
}
@@ -1374,31 +1375,29 @@
if (rstate == null)
{
exceptions +=
- "Can't find removed item " + removed.getLocation().getAsString(false)
- + " in changes for rollback.\n";
+ "Can't find removed item " + removed.getLocation().getAsString(false) + " in changes for rollback.\n";
continue;
}
if (rstate.getState() == ItemState.RENAMED)
{
// find DELETED
- rstate = changes.findItemState(rstate.getData().getIdentifier(), false, new int[]
- {ItemState.DELETED});
+ rstate = changes.findItemState(rstate.getData().getIdentifier(), false, new int[]{ItemState.DELETED});
if (rstate == null)
{
exceptions +=
- "Can't find removed item (of move operation) " + removed.getLocation().getAsString(false)
- + " in changes for rollback.\n";
+ "Can't find removed item (of move operation) " + removed.getLocation().getAsString(false)
+ + " in changes for rollback.\n";
continue;
}
}
- NodeData parent = (NodeData) transactionableManager.getItemData(rstate.getData().getParentIdentifier());
+ NodeData parent = (NodeData)transactionableManager.getItemData(rstate.getData().getParentIdentifier());
if (parent != null)
{
ItemData persisted =
- transactionableManager.getItemData(parent, rstate.getData().getQPath().getEntries()[rstate
- .getData().getQPath().getEntries().length - 1]);
+ transactionableManager.getItemData(parent, rstate.getData().getQPath().getEntries()[rstate.getData()
+ .getQPath().getEntries().length - 1]);
if (persisted != null)
// reload item data
@@ -1425,7 +1424,7 @@
if (persisted == null)
{
// ...try by path
- NodeData parent = (NodeData) transactionableManager.getItemData(item.getParentIdentifier());
+ NodeData parent = (NodeData)transactionableManager.getItemData(item.getParentIdentifier());
if (parent != null)
{
QPathEntry[] path = item.getQPath().getEntries();
@@ -1445,7 +1444,7 @@
if (persisted == null)
{
// ...try by path
- NodeData parent = (NodeData) transactionableManager.getItemData(pooled.getParentIdentifier());
+ NodeData parent = (NodeData)transactionableManager.getItemData(pooled.getParentIdentifier());
if (parent != null)
{
QPathEntry[] path = pooled.getData().getQPath().getEntries();
@@ -1461,8 +1460,8 @@
else
{
throw new InvalidItemStateException(
- "An item is transient only or removed (either by this session or another) "
- + session.getLocationFactory().createJCRPath(item.getQPath()).getAsString(false));
+ "An item is transient only or removed (either by this session or another) "
+ + session.getLocationFactory().createJCRPath(item.getQPath()).getAsString(false));
}
}
}
@@ -1495,7 +1494,7 @@
* @return
*/
protected List<? extends ItemData> merge(ItemData rootData, DataManager dataManager, boolean deep, int action)
- throws RepositoryException
+ throws RepositoryException
{
// 1 get all transient descendants
List<ItemState> transientDescendants = new ArrayList<ItemState>();
@@ -1538,7 +1537,7 @@
* @throws RepositoryException
*/
protected List<? extends ItemData> mergeList(ItemData rootData, DataManager dataManager, boolean deep, int action)
- throws RepositoryException
+ throws RepositoryException
{
// 1 get all transient descendants
@@ -1581,15 +1580,14 @@
* @throws RepositoryException
*/
private void traverseStoredDescendants(ItemData parent, DataManager dataManager, boolean deep, int action,
- Map<String, ItemData> ret, boolean listOnly, List<ItemState> transientDescendants)
- throws RepositoryException
+ Map<String, ItemData> ret, boolean listOnly, List<ItemState> transientDescendants) throws RepositoryException
{
if (parent.isNode())
{
if (action != MERGE_PROPS)
{
- List<NodeData> childNodes = dataManager.getChildNodesData((NodeData) parent);
+ List<NodeData> childNodes = dataManager.getChildNodesData((NodeData)parent);
for (NodeData childNode : childNodes)
{
ret.put(childNode.getIdentifier(), childNode);
@@ -1605,15 +1603,15 @@
if (action != MERGE_NODES)
{
List<PropertyData> childProps =
- listOnly ? dataManager.listChildPropertiesData((NodeData) parent) : dataManager
- .getChildPropertiesData((NodeData) parent);
+ listOnly ? dataManager.listChildPropertiesData((NodeData)parent) : dataManager
+ .getChildPropertiesData((NodeData)parent);
outer : for (PropertyData childProp : childProps)
{
for (ItemState transientState : transientDescendants)
{
if (!transientState.isNode() && !transientState.isDeleted()
- && transientState.getData().getQPath().getDepth() == childProp.getQPath().getDepth()
- && transientState.getData().getQPath().getName().equals(childProp.getQPath().getName()))
+ && transientState.getData().getQPath().getDepth() == childProp.getQPath().getDepth()
+ && transientState.getData().getQPath().getName().equals(childProp.getQPath().getName()))
{
continue outer;
}
@@ -1637,7 +1635,7 @@
* @throws RepositoryException
*/
private void traverseTransientDescendants(ItemData parent, boolean deep, int action, List<ItemState> ret)
- throws RepositoryException
+ throws RepositoryException
{
if (parent.isNode())
@@ -1651,7 +1649,7 @@
if (log.isDebugEnabled())
log.debug("Traverse transient (N) " + childNode.getData().getQPath().getAsString() + " "
- + ItemState.nameFromValue(childNode.getState()));
+ + ItemState.nameFromValue(childNode.getState()));
if (deep)
traverseTransientDescendants(childNode.getData(), deep, action, ret);
@@ -1768,7 +1766,7 @@
for (NodeImpl node : nodes)
{
String id = node.getInternalIdentifier();
- NodeImpl pooled = (NodeImpl) items.get(id);
+ NodeImpl pooled = (NodeImpl)items.get(id);
if (pooled == null)
{
items.put(id, node);
@@ -1797,7 +1795,7 @@
for (PropertyImpl prop : props)
{
String id = prop.getInternalIdentifier();
- PropertyImpl pooled = (PropertyImpl) items.get(id);
+ PropertyImpl pooled = (PropertyImpl)items.get(id);
if (pooled == null)
{
items.put(id, prop);
@@ -1838,8 +1836,8 @@
for (ItemImpl item : items.values())
{
str +=
- (item.isNode() ? "Node\t\t" : "Property\t") + "\t" + item.isValid() + "\t" + item.isNew() + "\t"
- + item.getInternalIdentifier() + "\t" + item.getPath() + "\n";
+ (item.isNode() ? "Node\t\t" : "Property\t") + "\t" + item.isValid() + "\t" + item.isNew() + "\t"
+ + item.getInternalIdentifier() + "\t" + item.getPath() + "\n";
}
return str;
@@ -1856,7 +1854,7 @@
{
if (data.isNode())
- return createNode((NodeData) data);
+ return createNode((NodeData)data);
else
return createProperty(data);
}
@@ -1885,8 +1883,7 @@
/**
* Class helps on to sort nodes on deleting
*/
- private class PathSorter
- implements Comparator<ItemState>
+ private class PathSorter implements Comparator<ItemState>
{
public int compare(final ItemState i1, final ItemState i2)
Added: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java (rev 0)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java 2009-08-28 08:14:13 UTC (rev 31)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.core;
+
+import javax.jcr.PathNotFoundException;
+
+import org.exoplatform.services.jcr.JcrImplBaseTest;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id: TestGetNode.java 111 2009-11-11 11:11:11Z tolusha $
+ */
+public class TestGetNode extends JcrImplBaseTest
+{
+
+ // Reproduces the issue described in http://jira.exoplatform.org/browse/JCR-1094
+ public void testGetNode() throws Exception
+ {
+ try
+ {
+ root.getNode("..");
+ fail("Exception should be thrown");
+ }
+ catch (PathNotFoundException e)
+ {
+ }
+ catch (Exception e)
+ {
+ fail("Exception should not be thrown");
+ }
+ }
+
+}
Property changes on: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 8 months
exo-jcr SVN: r30 - in jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server: bean and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-08-28 04:07:58 -0400 (Fri, 28 Aug 2009)
New Revision: 30
Removed:
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/RestoreBean.java
Modified:
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
Log:
EXOJCR-7 : The bean of currently started backup was returned in HTTPBackupAgent.
Modified: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2009-08-28 08:00:58 UTC (rev 29)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2009-08-28 08:07:58 UTC (rev 30)
@@ -245,6 +245,7 @@
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
@Path("/start/{repo}/{ws}")
public Response start(BackupConfigBean bConfigBeen, @PathParam("repo") String repository,
@@ -272,9 +273,11 @@
validateWorkspaceName(repository, workspace);
validateOneBackupInstants(repository, workspace);
- backupManager.startBackup(config);
+ BackupChain chain = backupManager.startBackup(config);
- return Response.ok().build();
+ ShortInfo shortInfo = new ShortInfo(ShortInfo.CURRENT, chain);
+
+ return Response.ok(shortInfo).cacheControl(noCache).build();
}
catch (NoSuchWorkspaceException e)
{
@@ -327,7 +330,8 @@
log.error("Can not start backup", exception);
- return Response.status(status).entity("Can not start backup : " + failMessage).type(MediaType.TEXT_PLAIN).build();
+ return Response.status(status).entity("Can not start backup : " + failMessage).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
/**
Deleted: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/RestoreBean.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/RestoreBean.java 2009-08-28 08:00:58 UTC (rev 29)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/RestoreBean.java 2009-08-28 08:07:58 UTC (rev 30)
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.ext.backup.server.bean;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>
- * Date: 26.03.2009
- *
- * @author <a href="mailto:alex.reshetnyak@exoplatform.com.ua">Alex Reshetnyak</a>
- * @version $Id: RestoreBeen.java 111 2008-11-11 11:11:11Z rainf0x $
- */
-public class RestoreBean
-{
-
- /**
- * The backup identifier.
- */
- String backupId;
-
- /**
- * The workspace configuration.
- */
- String workspaceConfig;
-
- /**
- * RestoreBeen constructor.
- *
- */
- public RestoreBean()
- {
- }
-
- /**
- * RestoreBeen constructor.
- *
- * @param backupId
- * String, the backup identifier
- * @param workspaceConfig
- * the workspace configuration
- */
- public RestoreBean(String backupId, String workspaceConfig)
- {
- this.backupId = backupId;
- this.workspaceConfig = workspaceConfig;
- }
-
- /**
- * getBackupId.
- *
- * @return String return the backup identifier
- */
- public String getBackupId()
- {
- return backupId;
- }
-
- /**
- * setBackupId.
- *
- * @param backupId
- * String, the backup identifier
- */
- public void setBackupId(String backupId)
- {
- this.backupId = backupId;
- }
-
- /**
- * getWorkspaceConfig.
- *
- * @return String return the workspace configuration
- */
- public String getWorkspaceConfig()
- {
- return workspaceConfig;
- }
-
- /**
- * setWorkspaceConfig.
- *
- * @param workspaceConfig
- * String, the workspace configuration
- */
- public void setWorkspaceConfig(String workspaceConfig)
- {
- this.workspaceConfig = workspaceConfig;
- }
-}
16 years, 8 months
exo-jcr SVN: r29 - jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-08-28 04:00:58 -0400 (Fri, 28 Aug 2009)
New Revision: 29
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
Log:
EXOJCR-11: Merging fixes for JCR-1171(Read values are not removed in some cases).
Added: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java (rev 0)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java 2009-08-28 08:00:58 UTC (rev 29)
@@ -0,0 +1,187 @@
+/*
+ * 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.value.fs;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.Value;
+
+import org.exoplatform.services.jcr.BaseStandaloneTest;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.core.PropertyImpl;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.storage.value.ValueIOChannel;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+/**
+ * Created by The eXo Platform SAS. <br/>
+ * Test to reproduce bug when values from value storages are not removed in some
+ * cases.
+ *
+ * @author Nikolay Zamosenchuk
+ * @version $Id: $
+ */
+public class TestRemoveFromValueStorage extends BaseStandaloneTest
+{
+
+ private Node testRoot;
+
+ private Property prop = null;
+
+ private Value[] values;
+
+ private int largeCount = 5;
+
+ private int smallCount = 5;
+
+ private int largeValueSize = 1024 * 1024 * 2;
+
+ private int smallValueSize = 1000 * 1024;
+
+ private SessionImpl my_session;
+
+ private Node my_root;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ // This test uses special workspace ("ws3"), with complex value storage. So
+ // we need to login into another workspace.
+ my_session = (SessionImpl)repository.login(credentials, "ws3");
+ my_root = my_session.getRootNode();
+
+ // creating property with binary values.
+ testRoot = my_root.addNode("TestRoot");
+
+ values = new Value[largeCount + smallCount];
+
+ // creating large one's
+ for (int i = 0; i < largeCount; i++)
+ {
+ // 2M will be stored in first value storage
+ byte[] largeValue = new byte[largeValueSize];
+ Random generator = new Random();
+ generator.nextBytes(largeValue);
+ values[smallCount + i] =
+ testRoot.getSession().getValueFactory().createValue(new ByteArrayInputStream(largeValue));
+ }
+
+ // creating small one's
+ for (int i = 0; i < smallCount; i++)
+ {
+ // 1000K will be stored in second value storage
+ byte[] smallValue = new byte[smallValueSize];
+ Random generator = new Random();
+ generator.nextBytes(smallValue);
+ values[i] = testRoot.getSession().getValueFactory().createValue(new ByteArrayInputStream(smallValue));
+ }
+ if (values.length == 1)
+ {
+ prop = testRoot.setProperty("binaryProperty", values[0]);
+ }
+ else
+ {
+ prop = testRoot.setProperty("binaryProperty", values);
+ }
+ my_session.save();
+ }
+
+ public void testRemoveValue() throws Exception
+ {
+ // reading values directly from value storage
+ PropertyImpl propertyImpl = (PropertyImpl)prop;
+ ValueStoragePluginProvider storageProvider =
+ (ValueStoragePluginProvider)my_session.getContainer().getComponentInstanceOfType(
+ ValueStoragePluginProvider.class);
+
+ String propertyId = propertyImpl.getInternalIdentifier();
+ int count = prop.getValues().length;
+ Map<Integer, FileIOChannel> channels = new HashMap<Integer, FileIOChannel>();
+
+ for (int i = 0; i < count; i++)
+ {
+ ValueIOChannel channel = storageProvider.getApplicableChannel((PropertyData)propertyImpl.getData(), i);
+ if (channel != null)
+ {
+ channels.put(i, (FileIOChannel)channel);
+ }
+ }
+
+ for (int i = 0; i < count; i++)
+ {
+ try
+ {
+ channels.get(i).read(propertyId, i, 2100 * 1024);
+ }
+ catch (Exception e)
+ {
+ fail("Poperty value " + i + " can't be read!");
+ }
+ }
+
+ prop.remove();
+ my_session.save();
+
+ // checking whether values are still in value storage.
+ for (int i = 0; i < count; i++)
+ {
+ try
+ {
+ // TreeFileIOChannel always returns a File. But if this file doesn't
+ // really exists is size is 0.
+ File value = channels.get(i).getFile(propertyId, i);
+ if (value.length() == 0)
+ {
+ throw new Exception("");
+ }
+ fail("Poperty value still can be found in value-storage but should have been already deleted!");
+ }
+ catch (Exception e)
+ {
+ // ok
+ }
+ }
+
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (my_session != null)
+ {
+ testRoot.remove();
+ my_session.logout();
+ }
+ super.tearDown();
+ }
+
+ @Override
+ protected String getRepositoryName()
+ {
+ return repository.getName();
+ }
+
+}
Property changes on: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/value/fs/TestRemoveFromValueStorage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 8 months
exo-jcr SVN: r28 - jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-08-28 03:56:49 -0400 (Fri, 28 Aug 2009)
New Revision: 28
Modified:
jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
Log:
EXOJCR-6 : Disable caching of response in HTTPBackupAgent.
Modified: jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2009-08-28 07:47:54 UTC (rev 27)
+++ jcr/trunk/component/ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2009-08-28 07:56:49 UTC (rev 28)
@@ -59,6 +59,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -73,11 +74,12 @@
*/
@Path("/jcr-backup/")
-public class HTTPBackupAgent implements ResourceContainer
+public class HTTPBackupAgent
+ implements ResourceContainer
{
/**
- * Definition the constants to ReplicationTestService.
+ * Definition the constants.
*/
public static final class Constants
{
@@ -184,6 +186,18 @@
private static Log log = ExoLogger.getLogger("ext.HTTPBackupAgent");
/**
+ * To disable cache control.
+ */
+ private static final CacheControl noCache;
+
+ static
+ {
+ noCache = new CacheControl();
+ noCache.setNoCache(true);
+ noCache.setNoStore(true);
+ }
+
+ /**
* The repository service.
*/
private RepositoryService repositoryService;
@@ -209,7 +223,7 @@
* the ThreadLocalSessionProviderService
*/
public HTTPBackupAgent(RepositoryService repoService, BackupManager backupManager,
- ThreadLocalSessionProviderService sessionProviderService)
+ ThreadLocalSessionProviderService sessionProviderService)
{
this.repositoryService = repoService;
this.backupManager = backupManager;
@@ -234,7 +248,7 @@
@RolesAllowed("administrators")
@Path("/start/{repo}/{ws}")
public Response start(BackupConfigBean bConfigBeen, @PathParam("repo") String repository,
- @PathParam("ws") String workspace)
+ @PathParam("ws") String workspace)
{
String failMessage;
Response.Status status;
@@ -331,7 +345,7 @@
@RolesAllowed("administrators")
@Path("/drop-workspace/{repo}/{ws}/{force-session-close}")
public Response dropWorkspace(@PathParam("repo") String repository, @PathParam("ws") String workspace,
- @PathParam("force-session-close") Boolean forceSessionClose)
+ @PathParam("force-session-close") Boolean forceSessionClose)
{
String failMessage;
@@ -346,10 +360,10 @@
if (forceSessionClose)
forceCloseSession(repository, workspace);
- RepositoryImpl repositoryImpl = (RepositoryImpl)repositoryService.getRepository(repository);
+ RepositoryImpl repositoryImpl = (RepositoryImpl) repositoryService.getRepository(repository);
repositoryImpl.removeWorkspace(workspace);
- return Response.ok().build();
+ return Response.ok().cacheControl(noCache).build();
}
catch (RepositoryException e)
@@ -374,8 +388,9 @@
log.error("Can not drop the workspace '" + "/" + repository + "/" + workspace + "'", exception);
return Response.status(status).entity(
- "Can not drop the workspace '" + "/" + repository + "/" + workspace + "' : " + failMessage).type(
- MediaType.TEXT_PLAIN).build();
+ "Can not drop the workspace '" + "/" + repository + "/" + workspace + "' : " + failMessage).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+
}
/**
@@ -418,7 +433,7 @@
backupManager.restore(backupChainLog, repository, wEntry, true);
- return Response.ok().build();
+ return Response.ok().cacheControl(noCache).build();
}
catch (WorkspaceRestoreExeption e)
{
@@ -452,11 +467,12 @@
}
log.error("Can not start restore the workspace '" + "/" + repository + "/" + wEntry.getName()
- + "' from backup log with id '" + backupId + "'", exception);
+ + "' from backup log with id '" + backupId + "'", exception);
return Response.status(status).entity(
- "Can not start restore the workspace '" + "/" + repository + "/" + wEntry.getName()
- + "' from backup log with id '" + backupId + "' : " + failMessage).type(MediaType.TEXT_PLAIN).build();
+ "Can not start restore the workspace '" + "/" + repository + "/" + wEntry.getName()
+ + "' from backup log with id '" + backupId + "' : " + failMessage).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
/**
@@ -467,6 +483,7 @@
* @return Response return the response
*/
@GET
+ @Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
@Path("/stop/{id}")
public Response stop(@PathParam("id") String backupId)
@@ -484,7 +501,19 @@
else
throw new BackupNotFoundException("No active backup with id '" + backupId + "'");
- return Response.ok().build();
+ ShortInfo shortInfo = null;
+ for (BackupChainLog chainLog : backupManager.getBackupsLogs())
+ if (backupId.equals(chainLog.getBackupId()))
+ {
+ shortInfo = new ShortInfo(ShortInfo.COMPLETED, chainLog);
+ System.out.println();
+ break;
+ }
+
+ if (shortInfo == null)
+ throw new BackupNotFoundException("No completed backup with id '" + backupId + "'");
+
+ return Response.ok(shortInfo).cacheControl(noCache).build();
}
catch (BackupNotFoundException e)
{
@@ -501,7 +530,8 @@
log.error("Can not stop backup", exception);
- return Response.status(status).entity("Can not stop backup : " + failMessage).type(MediaType.TEXT_PLAIN).build();
+ return Response.status(status).entity("Can not stop backup : " + failMessage).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
/**
@@ -518,17 +548,19 @@
try
{
BackupServiceInfoBean infoBeen =
- new BackupServiceInfoBean(backupManager.getFullBackupType(), backupManager.getIncrementalBackupType(),
- backupManager.getBackupDirectory().getAbsolutePath(), backupManager.getDefaultIncrementalJobPeriod());
+ new BackupServiceInfoBean(backupManager.getFullBackupType(),
+ backupManager.getIncrementalBackupType(), backupManager.getBackupDirectory()
+ .getAbsolutePath(), backupManager.getDefaultIncrementalJobPeriod());
- return Response.ok(infoBeen).build();
+ return Response.ok(infoBeen).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about backup service", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about backup service : " + e.getMessage()).type(MediaType.TEXT_PLAIN).build();
+ "Can not get information about backup service : " + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
}
@@ -556,15 +588,15 @@
ShortInfoList shortInfoList = new ShortInfoList(list);
- return Response.ok(shortInfoList).build();
+ return Response.ok(shortInfoList).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about current or completed backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
- .build();
+ "Can not get information about current or completed backups" + e.getMessage()).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -588,7 +620,7 @@
if (current != null)
{
DetailedInfo info = new DetailedInfo(DetailedInfo.CURRENT, current);
- return Response.ok(info).build();
+ return Response.ok(info).cacheControl(noCache).build();
}
BackupChainLog completed = null;
@@ -600,19 +632,19 @@
if (completed != null)
{
DetailedInfo info = new DetailedInfo(DetailedInfo.COMPLETED, completed);
- return Response.ok(info).build();
+ return Response.ok(info).cacheControl(noCache).build();
}
return Response.status(Response.Status.NOT_FOUND).entity("No current or completed backup with 'id' " + id)
- .type(MediaType.TEXT_PLAIN).build();
+ .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about current or completed backup with 'id' " + id, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backup with 'id' " + id + " : " + e.getMessage()).type(
- MediaType.TEXT_PLAIN).build();
+ "Can not get information about current or completed backup with 'id' " + id + " : " + e.getMessage())
+ .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -636,14 +668,15 @@
ShortInfoList shortInfoList = new ShortInfoList(list);
- return Response.ok(shortInfoList).build();
+ return Response.ok(shortInfoList).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about current backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current backups" + e.getMessage()).type(MediaType.TEXT_PLAIN).build();
+ "Can not get information about current backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
}
@@ -668,14 +701,15 @@
ShortInfoList list = new ShortInfoList(completedList);
- return Response.ok(list).build();
+ return Response.ok(list).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about completed backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN).build();
+ "Can not get information about completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
}
@@ -703,7 +737,7 @@
for (BackupChain chain : backupManager.getCurrentBackups())
{
if (repository.equals(chain.getBackupConfig().getRepository())
- && workspace.equals(chain.getBackupConfig().getWorkspace()))
+ && workspace.equals(chain.getBackupConfig().getWorkspace()))
{
list.add(new ShortInfo(ShortInfo.CURRENT, chain));
}
@@ -712,8 +746,8 @@
for (BackupChainLog chainLog : backupManager.getBackupsLogs())
{
if (backupManager.findBackup(chainLog.getBackupId()) == null
- && repository.equals(chainLog.getBackupConfig().getRepository())
- && workspace.equals(chainLog.getBackupConfig().getWorkspace()))
+ && repository.equals(chainLog.getBackupConfig().getRepository())
+ && workspace.equals(chainLog.getBackupConfig().getWorkspace()))
{
list.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
}
@@ -721,15 +755,15 @@
ShortInfoList shortInfoList = new ShortInfoList(list);
- return Response.ok(shortInfoList).build();
+ return Response.ok(shortInfoList).cacheControl(noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about current or completed backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
- .build();
+ "Can not get information about current or completed backups" + e.getMessage()).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -756,30 +790,32 @@
if (restoreJob != null)
{
DetailedInfoEx info =
- new DetailedInfoEx(DetailedInfo.RESTORE, restoreJob.getBackupChainLog(), restoreJob.getStartTime(),
- restoreJob.getEndTime(), restoreJob.getStateRestore(), restoreJob.getRepositoryName(), restoreJob
- .getWorkspaceName(),
+ new DetailedInfoEx(DetailedInfo.RESTORE, restoreJob.getBackupChainLog(),
+ restoreJob.getStartTime(), restoreJob.getEndTime(), restoreJob.getStateRestore(),
+ restoreJob.getRepositoryName(), restoreJob.getWorkspaceName(),
- restoreJob.getWorkspaceEntry(), restoreJob.getRestoreException() == null ? "" : restoreJob
- .getRestoreException().getMessage());
+ restoreJob.getWorkspaceEntry(), restoreJob.getRestoreException() == null ? ""
+ : restoreJob.getRestoreException().getMessage());
- return Response.ok(info).build();
+ return Response.ok(info).cacheControl(noCache).build();
}
else
{
return Response.status(Response.Status.NOT_FOUND).entity(
- "No resrore for workspace /" + repository + "/" + workspace + "'").type(MediaType.TEXT_PLAIN).build();
+ "No resrore for workspace /" + repository + "/" + workspace + "'").type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
}
catch (Throwable e)
{
log.error(
- "Can not get information about current restore for workspace /" + repository + "/" + workspace + "'", e);
+ "Can not get information about current restore for workspace /" + repository + "/" + workspace + "'",
+ e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current restore for workspace /" + repository + "/" + workspace + "' : "
- + e.getMessage()).type(MediaType.TEXT_PLAIN).build();
+ "Can not get information about current restore for workspace /" + repository + "/" + workspace
+ + "' : " + e.getMessage()).type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -808,7 +844,7 @@
for (JobWorkspaceRestore unJob : jobs)
{
if (unJob.getRepositoryName().equals(job.getRepositoryName())
- && unJob.getWorkspaceName().equals(job.getWorkspaceName()))
+ && unJob.getWorkspaceName().equals(job.getWorkspaceName()))
isUnique = false;
}
@@ -821,12 +857,12 @@
for (JobWorkspaceRestore job : jobs)
{
ShortInfo info =
- new ShortInfo(ShortInfo.RESTORE, job.getBackupChainLog(), job.getStartTime(), job.getEndTime(), job
- .getStateRestore(), job.getRepositoryName(), job.getWorkspaceName());
+ new ShortInfo(ShortInfo.RESTORE, job.getBackupChainLog(), job.getStartTime(), job.getEndTime(),
+ job.getStateRestore(), job.getRepositoryName(), job.getWorkspaceName());
list.add(info);
}
- return Response.ok(new ShortInfoList(list)).build();
+ return Response.ok(new ShortInfoList(list)).cacheControl(noCache).build();
}
catch (Throwable e)
@@ -834,7 +870,8 @@
log.error("Can not get information about current restores.", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current restores : " + e.getMessage()).type(MediaType.TEXT_PLAIN).build();
+ "Can not get information about current restores : " + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
}
}
@@ -852,19 +889,20 @@
try
{
String defaultWorkspaceName =
- repositoryService.getDefaultRepository().getConfiguration().getDefaultWorkspaceName();
+ repositoryService.getDefaultRepository().getConfiguration().getDefaultWorkspaceName();
for (WorkspaceEntry wEntry : repositoryService.getDefaultRepository().getConfiguration().getWorkspaceEntries())
if (defaultWorkspaceName.equals(wEntry.getName()))
- return Response.ok(wEntry).build();
+ return Response.ok(wEntry).cacheControl(noCache).build();
return Response.status(Response.Status.NOT_FOUND).entity("Can not get default workspace configuration.").type(
- MediaType.TEXT_PLAIN).build();
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
catch (Throwable e)
{
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get default workspace configuration.").type(MediaType.TEXT_PLAIN).build();
+ "Can not get default workspace configuration.").type(MediaType.TEXT_PLAIN).cacheControl(noCache)
+ .build();
}
}
@@ -879,7 +917,7 @@
* will be generated the exception RepositoryException
*/
private void validateRepositoryName(String repositoryName) throws RepositoryException,
- RepositoryConfigurationException
+ RepositoryConfigurationException
{
repositoryService.getRepository(repositoryName);
}
@@ -901,16 +939,16 @@
* will be generated the exception LoginException
*/
private void validateWorkspaceName(String repositoryName, String workspaceName) throws LoginException,
- NoSuchWorkspaceException, RepositoryException, RepositoryConfigurationException
+ NoSuchWorkspaceException, RepositoryException, RepositoryConfigurationException
{
Session ses =
- sessionProviderService.getSessionProvider(null).getSession(workspaceName,
- repositoryService.getRepository(repositoryName));
+ sessionProviderService.getSessionProvider(null).getSession(workspaceName,
+ repositoryService.getRepository(repositoryName));
ses.logout();
}
private boolean isWorkspaceExist(String repositoryName, String workspaceName) throws RepositoryException,
- RepositoryConfigurationException
+ RepositoryConfigurationException
{
for (String workspace : repositoryService.getRepository(repositoryName).getWorkspaceNames())
{
@@ -940,7 +978,7 @@
if (bch != null)
throw new WorkspaceRestoreExeption("The backup is already working on workspace '" + "/" + repositoryName + "/"
- + workspaceName + "'");
+ + workspaceName + "'");
}
/**
@@ -958,11 +996,11 @@
for (JobWorkspaceRestore job : backupManager.getRestores())
if (repositoryName.equals(job.getRepositoryName())
- && workspaceName.endsWith(job.getWorkspaceName())
- && (job.getStateRestore() == JobWorkspaceRestore.RESTORE_INITIALIZED || job.getStateRestore() == JobWorkspaceRestore.RESTORE_STARTED))
+ && workspaceName.endsWith(job.getWorkspaceName())
+ && (job.getStateRestore() == JobWorkspaceRestore.RESTORE_INITIALIZED || job.getStateRestore() == JobWorkspaceRestore.RESTORE_STARTED))
{
throw new WorkspaceRestoreExeption("The workspace '" + "/" + repositoryName + "/" + workspaceName
- + "' is already restoring.");
+ + "' is already restoring.");
}
}
@@ -980,12 +1018,12 @@
* will be generate RepositoryException
*/
private int forceCloseSession(String repositoryName, String workspaceName) throws RepositoryException,
- RepositoryConfigurationException
+ RepositoryConfigurationException
{
ManageableRepository mr = repositoryService.getRepository(repositoryName);
WorkspaceContainerFacade wc = mr.getWorkspaceContainer(workspaceName);
- SessionRegistry sessionRegistry = (SessionRegistry)wc.getComponent(SessionRegistry.class);
+ SessionRegistry sessionRegistry = (SessionRegistry) wc.getComponent(SessionRegistry.class);
return sessionRegistry.closeSessions(workspaceName);
}
16 years, 8 months
exo-jcr SVN: r27 - in jcr/trunk/component/core/src: test/java/conf/standalone and 1 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-08-28 03:47:54 -0400 (Fri, 28 Aug 2009)
New Revision: 27
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java
jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config-sjdbc.xml
jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config.xml
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java
Log:
EXOJCR-11: Merging fixes for JCR-1171(Read values are not removed in some cases) and also JCR-1175 (Empty string is not valid path).
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java 2009-08-28 07:09:44 UTC (rev 26)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java 2009-08-28 07:47:54 UTC (rev 27)
@@ -234,7 +234,7 @@
}
path.addEntry(namespaces.getNamespaceURIByPrefix(prefix), someName, prefix, index);
- return (JCRPath.PathElement) path.getName();
+ return (JCRPath.PathElement)path.getName();
}
catch (Exception e)
@@ -246,7 +246,7 @@
private JCRPath parseNames(String path, boolean absolute) throws RepositoryException
{
- if (path == null)
+ if ((path == null) || (path.equals("")))
{
throw new RepositoryException("Illegal relPath " + path);
}
@@ -309,7 +309,7 @@
}
return !((ch == '\t') || (ch == '\n') || (ch == '\f') || (ch == '\r') || (ch == ' ') || (ch == '/')
- || (ch == ':') || (ch == '[') || (ch == ']') || (ch == '\'') || (ch == '\"') || (ch == '*'));
+ || (ch == ':') || (ch == '[') || (ch == ']') || (ch == '\'') || (ch == '\"') || (ch == '*'));
}
private boolean isSimpleString(String str)
@@ -343,11 +343,11 @@
char ch0 = str.charAt(0);
char ch1 = str.charAt(1);
return (((ch0 == '.') && (isNonspace(str, ch1) && (ch1 != '.')))
- || ((isNonspace(str, ch0) && (ch0 != '.')) && (ch1 == '.')) || ((isNonspace(str, ch0) && (ch0 != '.')) && (isNonspace(
- str, ch1) && (ch1 != '.'))));
+ || ((isNonspace(str, ch0) && (ch0 != '.')) && (ch1 == '.')) || ((isNonspace(str, ch0) && (ch0 != '.')) && (isNonspace(
+ str, ch1) && (ch1 != '.'))));
default :
return isNonspace(str, str.charAt(0)) && isSimpleString(str.substring(1, strLen - 1))
- && isNonspace(str, str.charAt(strLen - 1));
+ && isNonspace(str, str.charAt(strLen - 1));
}
}
@@ -365,13 +365,13 @@
return isNonspace(str, str.charAt(0)) && isNonspace(str, str.charAt(1));
default :
return isNonspace(str, str.charAt(0)) && isSimpleString(str.substring(1, strLen - 1))
- && isNonspace(str, str.charAt(strLen - 1));
+ && isNonspace(str, str.charAt(strLen - 1));
}
}
private boolean isValidName(String str, boolean prefixed)
{
return (prefixed ? isLocalName(str) : isSimpleName(str) || str.equals(JCRPath.THIS_RELPATH)
- || str.equals(JCRPath.PARENT_RELPATH) || str.equals("*"));
+ || str.equals(JCRPath.PARENT_RELPATH) || str.equals("*"));
}
}
Modified: jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config-sjdbc.xml
===================================================================
--- jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config-sjdbc.xml 2009-08-28 07:09:44 UTC (rev 26)
+++ jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config-sjdbc.xml 2009-08-28 07:47:54 UTC (rev 27)
@@ -169,6 +169,79 @@
</properties>
</query-handler>
</workspace>
+
+ <workspace name="ws3">
+ <!-- for system storage -->
+ <container
+ class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr3" />
+ <property name="dialect" value="hsqldb" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/ws3" />
+ </properties>
+ <value-storages>
+ <!--
+ This storage is used to check whether properties are removed
+ correctly from each value-storage in case of complex value storage.
+ (TestRemoveFromValueStorage.java)
+ -->
+ <value-storage id="ws3_big"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3_big" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" min-value-size="1024K" />
+ </filters>
+ </value-storage>
+ <value-storage id="ws3"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3" />
+ <property name="digest-algo" value="MD5" />
+ <property name="vcas-type"
+ value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl" />
+ <property name="jdbc-source-name" value="jdbcjcr" />
+ <property name="jdbc-dialect" value="hsqldb" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
+ class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <cache enabled="true"
+ class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
+ class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index/db1/ws3" />
+ <property name="synonymprovider-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
+ <property name="synonymprovider-config-path" value="../../synonyms.properties" />
+ <property name="support-highlighting" value="true" />
+ <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
+ <property name="query-class"
+ value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
+ </properties>
+ </query-handler>
+ </workspace>
</workspaces>
</repository>
Modified: jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config.xml
===================================================================
--- jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config.xml 2009-08-28 07:09:44 UTC (rev 26)
+++ jcr/trunk/component/core/src/test/java/conf/standalone/test-jcr-config.xml 2009-08-28 07:47:54 UTC (rev 27)
@@ -63,7 +63,8 @@
<property name="restore-path" value="./sv_export_root.xml" />
<property name="restore-path" value="./src/test/resources/import-export/restore_db1_ws1.xml" />
</properties>
- </initializer -->
+ </initializer
+-->
<cache enabled="true" class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
<properties>
<property name="max-size" value="2k" />
@@ -172,6 +173,79 @@
</properties>
</query-handler>
</workspace>
+
+ <workspace name="ws3">
+ <!-- for system storage -->
+ <container
+ class="org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer">
+ <properties>
+ <property name="source-name" value="jdbcjcr3" />
+ <property name="dialect" value="hsqldb" />
+ <property name="multi-db" value="true" />
+ <property name="update-storage" value="false" />
+ <property name="max-buffer-size" value="200k" />
+ <property name="swap-directory" value="target/temp/swap/ws3" />
+ </properties>
+ <value-storages>
+ <!--
+ This storage is used to check whether properties are removed
+ correctly from each value-storage
+ (TestRemoveFromValueStorage.java)
+ -->
+ <value-storage id="ws3_big"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3_big" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" min-value-size="1024K" />
+ </filters>
+ </value-storage>
+ <value-storage id="ws3"
+ class="org.exoplatform.services.jcr.impl.storage.value.fs.CASableTreeFileValueStorage">
+ <properties>
+ <property name="path" value="target/temp/values/ws3" />
+ <property name="digest-algo" value="MD5" />
+ <property name="vcas-type"
+ value="org.exoplatform.services.jcr.impl.storage.value.cas.JDBCValueContentAddressStorageImpl" />
+ <property name="jdbc-source-name" value="jdbcjcr" />
+ <property name="jdbc-dialect" value="hsqldb" />
+ </properties>
+ <filters>
+ <filter property-type="Binary" />
+ </filters>
+ </value-storage>
+ </value-storages>
+ </container>
+ <initializer
+ class="org.exoplatform.services.jcr.impl.core.ScratchWorkspaceInitializer">
+ <properties>
+ <property name="root-nodetype" value="nt:unstructured" />
+ </properties>
+ </initializer>
+ <cache enabled="true"
+ class="org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl">
+ <properties>
+ <property name="max-size" value="2k" />
+ <property name="live-time" value="20m" />
+ </properties>
+ </cache>
+ <query-handler
+ class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
+ <properties>
+ <property name="index-dir" value="target/temp/index/db1/ws3" />
+ <property name="synonymprovider-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.PropertiesSynonymProvider" />
+ <property name="synonymprovider-config-path" value="../../synonyms.properties" />
+ <property name="support-highlighting" value="true" />
+ <property name="indexing-configuration-path" value="../../indexing-configuration.xml" />
+ <property name="query-class"
+ value="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
+ <property name="spellchecker-class"
+ value="org.exoplatform.services.jcr.impl.core.query.lucene.spell.LuceneSpellChecker$FiveSecondsRefreshInterval" />
+ </properties>
+ </query-handler>
+ </workspace>
</workspaces>
</repository>
Modified: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java 2009-08-28 07:09:44 UTC (rev 26)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/TestLocationFactory.java 2009-08-28 07:47:54 UTC (rev 27)
@@ -48,7 +48,7 @@
{"..", "jcr:ig[2]/aaa", "v/d/...", "/path", "/vv/fff", "ff", "/", "..", "|fff"};
private static String testJCRPathInvalid[] =
- {"/.:./uuu", "/ ", "/./xml:name[0]", "xxx//fff", "//", " sdfas/"};
+ {"/.:./uuu", "/ ", "/./xml:name[0]", "xxx//fff", "//", " sdfas/", ""};
private LocationFactory factory;
16 years, 8 months
exo-jcr SVN: r26 - jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-08-28 03:09:44 -0400 (Fri, 28 Aug 2009)
New Revision: 26
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
Log:
EXOJCR-2 Sources migration to JBoss SVN
Added: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java 2009-08-28 07:09:44 UTC (rev 26)
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import java.io.File;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+import javax.sql.DataSource;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 26.08.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class HSQLDBConnectionFactory extends GenericConnectionFactory {
+
+ /**
+ * HSQLDBConnectionFactory constructor.
+ *
+ * @param dataSource
+ * - DataSource
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ */
+ public HSQLDBConnectionFactory(DataSource dataSource,
+ String containerName,
+ boolean multiDb,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) {
+
+ super(dataSource,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
+
+ /**
+ * HSQLDBConnectionFactory constructor.
+ *
+ *@param dataSource
+ * - DataSource
+ * @param dbDriver
+ * - JDBC Driver
+ * @param dbUrl
+ * - JDBC URL
+ * @param dbUserName
+ * - database username
+ * @param dbPassword
+ * - database user password
+ * @param containerName
+ * - Container name (see configuration)
+ * @param multiDb
+ * - multidatabase state flag
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ * @throws RepositoryException
+ * if error eccurs
+ */
+ public HSQLDBConnectionFactory(String dbDriver,
+ String dbUrl,
+ String dbUserName,
+ String dbPassword,
+ String containerName,
+ boolean multiDb,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) throws RepositoryException {
+
+ super(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException {
+ try {
+
+ if (multiDb) {
+ return new HSQLDBMultiDbJDBCConnection(getJdbcConnection(readOnly),
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
+
+ return new HSQLDBSingleDbJDBCConnection(getJdbcConnection(readOnly),
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+
+ } catch (SQLException e) {
+ throw new RepositoryException(e);
+ }
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java 2009-08-28 07:09:44 UTC (rev 26)
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 26.08.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class HSQLDBMultiDbJDBCConnection extends MultiDbJDBCConnection {
+
+ /**
+ * HSQLDB Multidatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, shoudl be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName
+ * Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider
+ * External Value Storages provider
+ * @param maxBufferSize
+ * Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * Swap directory File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public HSQLDBMultiDbJDBCConnection(Connection dbConnection,
+ boolean readOnly,
+ String containerName,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) throws SQLException {
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException {
+
+ super.prepareQueries();
+ FIND_PROPERTY_BY_NAME = "select V.DATA"
+ + " from JCR_MITEM I, JCR_MVALUE V"
+ + " where I.PARENT_ID=? and I.I_CLASS=2 and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+ FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=1"
+ + " order by N_ORDER_NUM";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where PARENT_ID=? and I_CLASS=2"
+ + " order by ID";
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBMultiDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java (rev 0)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java 2009-08-28 07:09:44 UTC (rev 26)
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.exoplatform.services.jcr.impl.util.io.FileCleaner;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 26.08.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class HSQLDBSingleDbJDBCConnection extends SingleDbJDBCConnection {
+
+ /**
+ * HSQLDB Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection
+ * JDBC connection, shoudl be opened before
+ * @param readOnly
+ * boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName
+ * Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider
+ * External Value Storages provider
+ * @param maxBufferSize
+ * Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * Swap directory File (see configuration)
+ * @param swapCleaner
+ * Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ *
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public HSQLDBSingleDbJDBCConnection(Connection dbConnection,
+ boolean readOnly,
+ String containerName,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) throws SQLException {
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected final void prepareQueries() throws SQLException {
+
+ super.prepareQueries();
+
+ FIND_ITEM_BY_NAME = "select * from JCR_SITEM"
+ + " where PARENT_ID=? and CONTAINER_NAME=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+ FIND_PROPERTY_BY_NAME = "select V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.PARENT_ID=? and I.I_CLASS=2 and I.CONTAINER_NAME=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+ FIND_NODES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where PARENT_ID=? and I_CLASS=1 and CONTAINER_NAME=?" + " order by N_ORDER_NUM";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where PARENT_ID=? and I_CLASS=2 and CONTAINER_NAME=?" + " order by ID";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
+
+ findItemByName.setString(1, parentId);
+ findItemByName.setString(2, containerName);
+ findItemByName.setString(3, name);
+ findItemByName.setInt(4, index);
+ return findItemByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
+
+ findPropertyByName.setString(1, parentCid);
+ findPropertyByName.setString(2, containerName);
+ findPropertyByName.setString(3, name);
+ return findPropertyByName.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
+
+ findNodesByParentId.setString(1, parentCid);
+ findNodesByParentId.setString(2, containerName);
+ return findNodesByParentId.executeQuery();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
+
+ findPropertiesByParentId.setString(1, parentCid);
+ findPropertiesByParentId.setString(2, containerName);
+ return findPropertiesByParentId.executeQuery();
+ }
+}
Property changes on: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/HSQLDBSingleDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 8 months
exo-jcr SVN: r25 - in jcr/trunk/component/core/src: main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db and 3 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2009-08-28 02:54:41 -0400 (Fri, 28 Aug 2009)
New Revision: 25
Added:
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml
jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml
Log:
EXOJCR-2 Sources migration to JBoss SVN
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2009-08-28 06:34:31 UTC (rev 24)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
package org.exoplatform.services.jcr.impl.storage.jdbc;
@@ -33,6 +31,7 @@
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.impl.storage.WorkspaceDataContainerBase;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.GenericConnectionFactory;
+import org.exoplatform.services.jcr.impl.storage.jdbc.db.HSQLDBConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.MySQLConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.OracleConnectionFactory;
import org.exoplatform.services.jcr.impl.storage.jdbc.db.WorkspaceStorageConnectionFactory;
@@ -56,726 +55,723 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id:GenericWorkspaceDataContainer.java 13433 2007-03-15 16:07:23Z peterit $
*/
-public class JDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements Startable
-{
+public class JDBCWorkspaceDataContainer extends WorkspaceDataContainerBase implements Startable {
- protected static final Log LOG = ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
+ protected static final Log LOG = ExoLogger.getLogger("jcr.JDBCWorkspaceDataContainer");
- //configuration params
+ //configuration params
- public final static String SOURCE_NAME = "source-name";
+ public final static String SOURCE_NAME = "source-name";
- public final static String MULTIDB = "multi-db";
+ public final static String MULTIDB = "multi-db";
- public final static String SINGLEDB = "single-db";
+ public final static String SINGLEDB = "single-db";
- /**
- * Describe which type of RDBMS will be used (DB creation metadata etc.)
- */
- public final static String DB_DIALECT = "dialect";
+ /**
+ * Describe which type of RDBMS will be used (DB creation metadata etc.)
+ */
+ public final static String DB_DIALECT = "dialect";
- public final static String DB_DRIVER = "driverClassName";
+ public final static String DB_DRIVER = "driverClassName";
- public final static String DB_URL = "url";
+ public final static String DB_URL = "url";
- public final static String DB_USERNAME = "username";
+ public final static String DB_USERNAME = "username";
- public final static String DB_PASSWORD = "password";
+ public final static String DB_PASSWORD = "password";
- protected final String containerName;
+ protected final String containerName;
- protected final String dbSourceName;
+ protected final String dbSourceName;
- protected final boolean multiDb;
+ protected final boolean multiDb;
- protected final String dbDriver;
+ protected final String dbDriver;
- protected final String dbDialect;
+ protected final String dbDialect;
- protected final String dbUrl;
+ protected final String dbUrl;
- protected final String dbUserName;
+ protected final String dbUserName;
- protected final String dbPassword;
+ protected final String dbPassword;
- protected final ValueStoragePluginProvider valueStorageProvider;
+ protected final ValueStoragePluginProvider valueStorageProvider;
- protected String storageVersion;
+ protected String storageVersion;
- protected int maxBufferSize;
+ protected int maxBufferSize;
- protected File swapDirectory;
+ protected File swapDirectory;
- protected FileCleaner swapCleaner;
+ protected FileCleaner swapCleaner;
- protected GenericConnectionFactory connFactory;
+ protected GenericConnectionFactory connFactory;
- /**
- * Shared connection factory.
- *
- * Issued to share JDBC connection between system and regular workspace in case of same database
- * used for storage.
- *
- */
- class SharedConnectionFactory extends GenericConnectionFactory
- {
+ /**
+ * Shared connection factory.
+ *
+ * Issued to share JDBC connection between system and regular workspace in case of same database
+ * used for storage.
+ *
+ */
+ class SharedConnectionFactory extends GenericConnectionFactory {
- /**
- * JDBC connection.
- */
- final private Connection connection;
+ /**
+ * JDBC connection.
+ */
+ final private Connection connection;
- /**
- * SharedConnectionFactory constructor.
- *
- * @param connection
- * JDBC - connection
- * @param containerName
- * - container name
- * @param multiDb
- * - multidatabase status
- * @param valueStorageProvider
- * - external Value Storages provider
- * @param maxBufferSize
- * - Maximum buffer size (see configuration)
- * @param swapDirectory
- * - Swap directory (see configuration)
- * @param swapCleaner
- * - Swap cleaner (internal FileCleaner).
- */
- SharedConnectionFactory(Connection connection, String containerName, boolean multiDb,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- {
+ /**
+ * SharedConnectionFactory constructor.
+ *
+ * @param connection
+ * JDBC - connection
+ * @param containerName
+ * - container name
+ * @param multiDb
+ * - multidatabase status
+ * @param valueStorageProvider
+ * - external Value Storages provider
+ * @param maxBufferSize
+ * - Maximum buffer size (see configuration)
+ * @param swapDirectory
+ * - Swap directory (see configuration)
+ * @param swapCleaner
+ * - Swap cleaner (internal FileCleaner).
+ */
+ SharedConnectionFactory(Connection connection,
+ String containerName,
+ boolean multiDb,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) {
- super(null, null, null, null, null, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ super(null,
+ null,
+ null,
+ null,
+ null,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- this.connection = connection;
- }
+ this.connection = connection;
+ }
- /**
- * {@inheritDoc}
- */
- public Connection getJdbcConnection() throws RepositoryException
- {
- return connection;
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Connection getJdbcConnection() throws RepositoryException {
+ return connection;
+ }
+ }
- /**
- * Constructor with value storage plugins.
- *
- * @param wsConfig
- * Workspace configuration
- * @param valueStrorageProvider
- * External Value Stprages provider
- * @throws RepositoryConfigurationException
- * if Repository configuration is wrong
- * @throws NamingException
- * if JNDI exception (on DataSource lookup)
- */
- public JDBCWorkspaceDataContainer(WorkspaceEntry wsConfig, RepositoryEntry repConfig,
- InitialContextInitializer contextInit, ValueStoragePluginProvider valueStorageProvider)
- throws RepositoryConfigurationException, NamingException, RepositoryException, IOException
- {
+ /**
+ * Constructor with value storage plugins.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param valueStrorageProvider
+ * External Value Stprages provider
+ * @throws RepositoryConfigurationException
+ * if Repository configuration is wrong
+ * @throws NamingException
+ * if JNDI exception (on DataSource lookup)
+ */
+ public JDBCWorkspaceDataContainer(WorkspaceEntry wsConfig,
+ RepositoryEntry repConfig,
+ InitialContextInitializer contextInit,
+ ValueStoragePluginProvider valueStorageProvider) throws RepositoryConfigurationException,
+ NamingException,
+ RepositoryException,
+ IOException {
- checkIntegrity(wsConfig, repConfig);
+ checkIntegrity(wsConfig, repConfig);
- this.containerName = wsConfig.getName();
- this.multiDb = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- this.valueStorageProvider = valueStorageProvider;
+ this.containerName = wsConfig.getName();
+ this.multiDb = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ this.valueStorageProvider = valueStorageProvider;
- // ------------- Database config ------------------
- String pDbDialect = null;
- try
- {
- pDbDialect = detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
- LOG.info("Using a dialect '" + pDbDialect + "'");
- }
- catch (RepositoryConfigurationException e)
- {
- LOG.info("Using a default dialect '" + DBConstants.DB_DIALECT_GENERIC + "'");
- pDbDialect = DBConstants.DB_DIALECT_GENERIC;
- }
- this.dbDialect = pDbDialect;
+ // ------------- Database config ------------------
+ String pDbDialect = null;
+ try {
+ pDbDialect = detectDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
+ LOG.info("Using a dialect '" + pDbDialect + "'");
+ } catch (RepositoryConfigurationException e) {
+ LOG.info("Using a default dialect '" + DBConstants.DB_DIALECT_GENERIC + "'");
+ pDbDialect = DBConstants.DB_DIALECT_GENERIC;
+ }
+ this.dbDialect = pDbDialect;
- String pDbDriver = null;
- String pDbUrl = null;
- String pDbUserName = null;
- String pDbPassword = null;
- try
- {
- pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
+ String pDbDriver = null;
+ String pDbUrl = null;
+ String pDbUserName = null;
+ String pDbPassword = null;
+ try {
+ pDbDriver = wsConfig.getContainer().getParameterValue(DB_DRIVER);
- // username/passwd may not pesent
- try
- {
- pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
- pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
- }
- catch (RepositoryConfigurationException e)
- {
- pDbUserName = pDbPassword = null;
- }
-
- pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
+ // username/passwd may not pesent
+ try {
+ pDbUserName = wsConfig.getContainer().getParameterValue(DB_USERNAME);
+ pDbPassword = wsConfig.getContainer().getParameterValue(DB_PASSWORD);
+ } catch (RepositoryConfigurationException e) {
+ pDbUserName = pDbPassword = null;
}
- catch (RepositoryConfigurationException e)
- {
- }
- if (pDbUrl != null)
- {
- this.dbDriver = pDbDriver;
- this.dbUrl = pDbUrl;
- this.dbUserName = pDbUserName;
- this.dbPassword = pDbPassword;
- this.dbSourceName = null;
- LOG.info("Connect to JCR database as user '" + this.dbUserName + "'");
- }
- else
- {
- this.dbDriver = null;
- this.dbUrl = null;
- this.dbUserName = null;
- this.dbPassword = null;
+ pDbUrl = wsConfig.getContainer().getParameterValue(DB_URL); // last here!
+ } catch (RepositoryConfigurationException e) {
+ }
- String sn;
- try
- {
- sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
- }
- catch (RepositoryConfigurationException e)
- {
- sn = wsConfig.getContainer().getParameterValue("sourceName"); // TODO for backward comp,
- // remove in rel.2.0
- }
- this.dbSourceName = sn;
- }
+ if (pDbUrl != null) {
+ this.dbDriver = pDbDriver;
+ this.dbUrl = pDbUrl;
+ this.dbUserName = pDbUserName;
+ this.dbPassword = pDbPassword;
+ this.dbSourceName = null;
+ LOG.info("Connect to JCR database as user '" + this.dbUserName + "'");
+ } else {
+ this.dbDriver = null;
+ this.dbUrl = null;
+ this.dbUserName = null;
+ this.dbPassword = null;
- // ------------- Values swap config ------------------
- try
- {
- this.maxBufferSize = wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ String sn;
+ try {
+ sn = wsConfig.getContainer().getParameterValue(SOURCE_NAME);
+ } catch (RepositoryConfigurationException e) {
+ sn = wsConfig.getContainer().getParameterValue("sourceName"); // TODO for backward comp,
+ // remove in rel.2.0
}
- catch (RepositoryConfigurationException e)
- {
- this.maxBufferSize = DEF_MAXBUFFERSIZE;
- }
+ this.dbSourceName = sn;
+ }
- try
- {
- String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
- this.swapDirectory = new File(sdParam);
- }
- catch (RepositoryConfigurationException e1)
- {
- this.swapDirectory = new File(DEF_SWAPDIR);
- }
- if (!swapDirectory.exists())
- swapDirectory.mkdirs();
+ // ------------- Values swap config ------------------
+ try {
+ this.maxBufferSize = wsConfig.getContainer().getParameterInteger(MAXBUFFERSIZE_PROP);
+ } catch (RepositoryConfigurationException e) {
+ this.maxBufferSize = DEF_MAXBUFFERSIZE;
+ }
- this.swapCleaner = new FileCleaner(false);
+ try {
+ String sdParam = wsConfig.getContainer().getParameterValue(SWAPDIR_PROP);
+ this.swapDirectory = new File(sdParam);
+ } catch (RepositoryConfigurationException e1) {
+ this.swapDirectory = new File(DEF_SWAPDIR);
+ }
+ if (!swapDirectory.exists())
+ swapDirectory.mkdirs();
- initDatabase();
+ this.swapCleaner = new FileCleaner(false);
- String suParam = null;
- boolean enableStorageUpdate = false;
- try
- {
- suParam = wsConfig.getContainer().getParameterValue("update-storage");
- enableStorageUpdate = Boolean.parseBoolean(suParam);
- }
- catch (RepositoryConfigurationException e)
- {
- if (LOG.isDebugEnabled())
- LOG.debug("update-storage parameter is not set " + dbSourceName);
- }
+ initDatabase();
- this.storageVersion =
- StorageUpdateManager.checkVersion(dbSourceName, this.connFactory.getJdbcConnection(), multiDb,
- enableStorageUpdate);
+ String suParam = null;
+ boolean enableStorageUpdate = false;
+ try {
+ suParam = wsConfig.getContainer().getParameterValue("update-storage");
+ enableStorageUpdate = Boolean.parseBoolean(suParam);
+ } catch (RepositoryConfigurationException e) {
+ if (LOG.isDebugEnabled())
+ LOG.debug("update-storage parameter is not set " + dbSourceName);
+ }
- LOG.info(getInfo());
- }
+ this.storageVersion = StorageUpdateManager.checkVersion(dbSourceName,
+ this.connFactory.getJdbcConnection(),
+ multiDb,
+ enableStorageUpdate);
- /**
- * Prepare sefault connection factory.
- *
- * @return GenericConnectionFactory
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- */
- protected GenericConnectionFactory defaultConnectionFactory() throws NamingException, RepositoryException
- {
- // by default
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- return new GenericConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
+ LOG.info(getInfo());
+ }
- throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
- }
+ /**
+ * Prepare sefault connection factory.
+ *
+ * @return GenericConnectionFactory
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ */
+ protected GenericConnectionFactory defaultConnectionFactory() throws NamingException,
+ RepositoryException {
+ // by default
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ return new GenericConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- return new GenericConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ }
- /**
- * Prepare default DB initializer.
- *
- * @param sqlPath
- * - path to SQL script (database creation script)
- * @return DBInitializer instance
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on Storage error
- * @throws IOException
- * on I/O error
- */
- protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException, RepositoryException,
- IOException
- {
- return new DBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
+ return new GenericConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * Checks if DataSources used in right manner.
- *
- * @param wsConfig
- * Workspace configuration
- * @param repConfig
- * Repository configuration
- * @throws RepositoryConfigurationException
- * in case of configuration errors
- */
- protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig)
- throws RepositoryConfigurationException
- {
- boolean isMulti;
- for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries())
- {
- if (wsEntry.getName().equals(wsConfig.getName())
- || !wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
- || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
- continue;
+ /**
+ * Prepare default DB initializer.
+ *
+ * @param sqlPath
+ * - path to SQL script (database creation script)
+ * @return DBInitializer instance
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on Storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected DBInitializer defaultDBInitializer(String sqlPath) throws NamingException,
+ RepositoryException,
+ IOException {
+ return new DBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
- // MULTIDB
- if (!wsEntry.getContainer().getParameterValue(MULTIDB).equals(
- wsConfig.getContainer().getParameterValue(MULTIDB)))
- {
- throw new RepositoryConfigurationException("All workspaces must be " + MULTIDB + " or " + SINGLEDB
- + ". But " + wsEntry.getName() + "- multi-db=" + wsEntry.getContainer().getParameterValue(MULTIDB)
- + " and " + wsConfig.getName() + "- multi-db=" + wsConfig.getContainer().getParameterValue(MULTIDB));
- }
+ /**
+ * Checks if DataSources used in right manner.
+ *
+ * @param wsConfig
+ * Workspace configuration
+ * @param repConfig
+ * Repository configuration
+ * @throws RepositoryConfigurationException
+ * in case of configuration errors
+ */
+ protected void checkIntegrity(WorkspaceEntry wsConfig, RepositoryEntry repConfig) throws RepositoryConfigurationException {
+ boolean isMulti;
+ for (WorkspaceEntry wsEntry : repConfig.getWorkspaceEntries()) {
+ if (wsEntry.getName().equals(wsConfig.getName())
+ || !wsEntry.getContainer().getType().equals(wsConfig.getContainer().getType())
+ || !wsEntry.getContainer().getType().equals(this.getClass().getName()))
+ continue;
- isMulti = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+ // MULTIDB
+ if (!wsEntry.getContainer()
+ .getParameterValue(MULTIDB)
+ .equals(wsConfig.getContainer().getParameterValue(MULTIDB))) {
+ throw new RepositoryConfigurationException("All workspaces must be " + MULTIDB + " or "
+ + SINGLEDB + ". But " + wsEntry.getName() + "- multi-db="
+ + wsEntry.getContainer().getParameterValue(MULTIDB) + " and " + wsConfig.getName()
+ + "- multi-db=" + wsConfig.getContainer().getParameterValue(MULTIDB));
+ }
- // source name
- String wsSourceName = null;
- String newWsSourceName = null;
- try
- {
- wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
- newWsSourceName = wsConfig.getContainer().getParameterValue("sourceName");
- }
- catch (RepositoryConfigurationException e)
- {
- }
+ isMulti = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
- if (wsSourceName != null && newWsSourceName != null)
- {
- if (isMulti)
- {
- if (wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName " + wsSourceName + " alredy in use in "
- + wsEntry.getName() + ". SourceName must be different in " + MULTIDB
- + ". Check configuration for " + wsConfig.getName());
- }
- }
- else
- {
- if (!wsSourceName.equals(newWsSourceName))
- {
- throw new RepositoryConfigurationException("SourceName must be equals in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
- }
- }
- continue;
- }
+ // source name
+ String wsSourceName = null;
+ String newWsSourceName = null;
+ try {
+ wsSourceName = wsEntry.getContainer().getParameterValue("sourceName");
+ newWsSourceName = wsConfig.getContainer().getParameterValue("sourceName");
+ } catch (RepositoryConfigurationException e) {
+ }
- // db-url
- String wsUri = null;
- String newWsUri = null;
- try
- {
- wsUri = wsEntry.getContainer().getParameterValue("db-url");
- newWsUri = wsConfig.getContainer().getParameterValue("db-url");
- }
- catch (RepositoryConfigurationException e)
- {
- }
+ if (wsSourceName != null && newWsSourceName != null) {
+ if (isMulti) {
+ if (wsSourceName.equals(newWsSourceName)) {
+ throw new RepositoryConfigurationException("SourceName " + wsSourceName
+ + " alredy in use in " + wsEntry.getName() + ". SourceName must be different in "
+ + MULTIDB + ". Check configuration for " + wsConfig.getName());
+ }
+ } else {
+ if (!wsSourceName.equals(newWsSourceName)) {
+ throw new RepositoryConfigurationException("SourceName must be equals in " + SINGLEDB
+ + " " + "repository." + " Check " + wsEntry.getName() + " and "
+ + wsConfig.getName());
+ }
+ }
+ continue;
+ }
- if (wsUri != null && newWsUri != null)
- {
- if (isMulti)
- {
- if (wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url " + wsUri + " alredy in use in "
- + wsEntry.getName() + ". db-url must be different in " + MULTIDB + ". Check configuration for "
- + wsConfig.getName());
-
- }
- }
- else
- {
- if (!wsUri.equals(newWsUri))
- {
- throw new RepositoryConfigurationException("db-url must be equals in " + SINGLEDB + " "
- + "repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
- }
- }
- }
+ // db-url
+ String wsUri = null;
+ String newWsUri = null;
+ try {
+ wsUri = wsEntry.getContainer().getParameterValue("db-url");
+ newWsUri = wsConfig.getContainer().getParameterValue("db-url");
+ } catch (RepositoryConfigurationException e) {
}
- }
- /**
- * Init storage database.
- *
- * @throws NamingException
- * on JNDI error
- * @throws RepositoryException
- * on storage error
- * @throws IOException
- * on I/O error
- */
- protected void initDatabase() throws NamingException, RepositoryException, IOException
- {
+ if (wsUri != null && newWsUri != null) {
+ if (isMulti) {
+ if (wsUri.equals(newWsUri)) {
+ throw new RepositoryConfigurationException("db-url " + wsUri + " alredy in use in "
+ + wsEntry.getName() + ". db-url must be different in " + MULTIDB
+ + ". Check configuration for " + wsConfig.getName());
- DBInitializer dbInitilizer = null;
- String sqlPath = null;
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
- {
- LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
- // sample of connection factory customization
- if (dbSourceName != null)
- this.connFactory = defaultConnectionFactory();
- else
- this.connFactory =
- new OracleConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
-
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
-
- // a particular db initializer may be configured here too
- dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
+ }
+ } else {
+ if (!wsUri.equals(newWsUri)) {
+ throw new RepositoryConfigurationException("db-url must be equals in " + SINGLEDB + " "
+ + "repository." + " Check " + wsEntry.getName() + " and " + wsConfig.getName());
+ }
+ }
}
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
- dbInitilizer = new OracleDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
- dbInitilizer = new PgSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
- {
- // [PN] 28.06.07
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ }
+ }
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
- {
- // [PN] 13.07.08
- if (dbSourceName != null)
- {
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- this.connFactory =
- new MySQLConnectionFactory(ds, containerName, multiDb, valueStorageProvider, maxBufferSize,
- swapDirectory, swapCleaner);
- else
- throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
- }
- else
- this.connFactory =
- new MySQLConnectionFactory(dbDriver, dbUrl, dbUserName, dbPassword, containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ /**
+ * Init storage database.
+ *
+ * @throws NamingException
+ * on JNDI error
+ * @throws RepositoryException
+ * on storage error
+ * @throws IOException
+ * on I/O error
+ */
+ protected void initDatabase() throws NamingException, RepositoryException, IOException {
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DERBY)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
- {
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
- // using Postgres initializer
- dbInitilizer =
- new IngresSQLDBInitializer(containerName, this.connFactory.getJdbcConnection(), sqlPath, multiDb);
- }
+ DBInitializer dbInitilizer = null;
+ String sqlPath = null;
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI) {
+ LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
+ // sample of connection factory customization
+ if (dbSourceName != null)
+ this.connFactory = defaultConnectionFactory();
else
- {
- // generic, DB_HSQLDB
- this.connFactory = defaultConnectionFactory();
- sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
- dbInitilizer = defaultDBInitializer(sqlPath);
- }
+ this.connFactory = new OracleConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- // database type
- try
- {
- dbInitilizer.init();
- }
- catch (DBInitializerException e)
- {
- LOG.error("Error of init db " + e, e);
- }
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
- /**
- * Return ConnectionFactory.
- *
- * @return WorkspaceStorageConnectionFactory connection
- */
- protected GenericConnectionFactory getConnectionFactory()
- {
- return connFactory;
- }
+ // a particular db initializer may be configured here too
+ dbInitilizer = new OracleDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_ORACLE) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ora.sql";
+ dbInitilizer = new OracleDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_PGSQL) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.pgsql.sql";
+ dbInitilizer = new PgSQLDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL) {
+ // [PN] 28.06.07
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new MySQLConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new MySQLConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- protected String detectDialect(String confParam)
- {
- for (String dbType : DBConstants.DB_DIALECTS)
- {
- if (dbType.equalsIgnoreCase(confParam))
- return dbType;
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8) {
+ // [PN] 13.07.08
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new MySQLConnectionFactory(ds,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new MySQLConnectionFactory(dbDriver,
+ dbUrl,
+ dbUserName,
+ dbPassword,
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- return DBConstants.DB_DIALECT_GENERIC; // by default
- }
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mysql-utf8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_MSSQL) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.mssql.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DERBY) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.derby.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DB2) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_DB2V8) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.db2v8.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_SYBASE) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sybase.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else if (dbDialect == DBConstants.DB_DIALECT_INGRES) {
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.ingres.sql";
+ // using Postgres initializer
+ dbInitilizer = new IngresSQLDBInitializer(containerName,
+ this.connFactory.getJdbcConnection(),
+ sqlPath,
+ multiDb);
+ } else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB) {
+ if (dbSourceName != null) {
+ DataSource ds = (DataSource) new InitialContext()
+ .lookup(dbSourceName);
+ if (ds != null)
+ this.connFactory = new HSQLDBConnectionFactory(ds,
+ containerName, multiDb, valueStorageProvider,
+ maxBufferSize, swapDirectory, swapCleaner);
+ else
+ throw new RepositoryException("Datasource '" + dbSourceName
+ + "' is not bound in this context.");
+ } else
+ this.connFactory = new HSQLDBConnectionFactory(dbDriver, dbUrl,
+ dbUserName, dbPassword, containerName, multiDb,
+ valueStorageProvider, maxBufferSize, swapDirectory,
+ swapCleaner);
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ } else {
+ // generic, DB_HSQLDB
+ this.connFactory = defaultConnectionFactory();
+ sqlPath = "/conf/storage/jcr-" + (multiDb ? "m" : "s") + "jdbc.sql";
+ dbInitilizer = defaultDBInitializer(sqlPath);
+ }
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection() throws RepositoryException
- {
+ // database type
+ try {
+ dbInitilizer.init();
+ } catch (DBInitializerException e) {
+ LOG.error("Error of init db " + e, e);
+ }
+ }
- return connFactory.openConnection();
- }
+ /**
+ * Return ConnectionFactory.
+ *
+ * @return WorkspaceStorageConnectionFactory connection
+ */
+ protected GenericConnectionFactory getConnectionFactory() {
+ return connFactory;
+ }
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException
- {
+ protected String detectDialect(String confParam) {
+ for (String dbType : DBConstants.DB_DIALECTS) {
+ if (dbType.equalsIgnoreCase(confParam))
+ return dbType;
+ }
- return connFactory.openConnection(readOnly);
- }
+ return DBConstants.DB_DIALECT_GENERIC; // by default
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection()
+ throws RepositoryException {
- /**
- * {@inheritDoc}
- */
- public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException
- {
+ return connFactory.openConnection();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection openConnection(boolean readOnly) throws RepositoryException {
- if (original instanceof JDBCStorageConnection)
- {
- WorkspaceStorageConnectionFactory cFactory =
- new SharedConnectionFactory(((JDBCStorageConnection)original).getJdbcConnection(), containerName, multiDb,
- valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
+ return connFactory.openConnection(readOnly);
+ }
- return cFactory.openConnection();
- }
- else
- {
- return openConnection();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws RepositoryException {
- /**
- * {@inheritDoc}
- */
- public String getName()
- {
- return containerName;
- }
+ if (original instanceof JDBCStorageConnection) {
+ WorkspaceStorageConnectionFactory cFactory = new SharedConnectionFactory(((JDBCStorageConnection) original).getJdbcConnection(),
+ containerName,
+ multiDb,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
- /**
- * {@inheritDoc}
- */
- public String getInfo()
- {
- String str =
- "JDBC based JCR Workspace Data container \n" + "container name: " + containerName + " \n"
- + "data source JNDI name: " + dbSourceName + "\n" + "is multi database: " + multiDb + "\n"
- + "storage version: " + storageVersion + "\n" + "value storage provider: " + valueStorageProvider + "\n"
- + "max buffer size (bytes): " + maxBufferSize + "\n" + "swap directory path: "
- + swapDirectory.getAbsolutePath();
- return str;
- }
+ return cFactory.openConnection();
+ } else {
+ return openConnection();
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public String getStorageVersion()
- {
- return storageVersion;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ return containerName;
+ }
- /**
- * {@inheritDoc}
- */
- public void start()
- {
- this.swapCleaner.start();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String getInfo() {
+ String str = "JDBC based JCR Workspace Data container \n" + "container name: " + containerName
+ + " \n" + "data source JNDI name: " + dbSourceName + "\n" + "is multi database: " + multiDb
+ + "\n" + "storage version: " + storageVersion + "\n" + "value storage provider: "
+ + valueStorageProvider + "\n" + "max buffer size (bytes): " + maxBufferSize + "\n"
+ + "swap directory path: " + swapDirectory.getAbsolutePath();
+ return str;
+ }
- /**
- * {@inheritDoc}
- */
- public void stop()
- {
- this.swapCleaner.halt();
- this.swapCleaner.interrupt();
+ /**
+ * {@inheritDoc}
+ */
+ public String getStorageVersion() {
+ return storageVersion;
+ }
- // TODO HSQLDB Stop (debug)
- // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
- // dbDialect.equals(DB_DIALECT_HSQLDB)) {
- // // shutdown in-process HSQLDB database
- // System.out.println("Shutdown in-process HSQLDB database...");
- // try {
- // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
- // Connection jdbcConn = conn.getJdbcConnection();
- // String dbUrl = jdbcConn.getMetaData().getURL();
- // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
- // dbUrl.startsWith("jdbc:hsqldb:mem")) {
- // // yeah, there is in-process hsqldb, shutdown it now
- // jdbcConn.createStatement().execute("SHUTDOWN");
- // System.out.println("Shutdown in-process HSQLDB database... done.");
- // }
- // } catch (Throwable e) {
- // log.error("JDBC Data container stop error " + e);
- // e.printStackTrace();
- // }
- // }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void start() {
+ this.swapCleaner.start();
+ }
- /**
- * {@inheritDoc}
- */
- public boolean isSame(WorkspaceDataContainer another)
- {
- if (another == this)
- return true;
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() {
+ this.swapCleaner.halt();
+ this.swapCleaner.interrupt();
- if (another instanceof JDBCWorkspaceDataContainer)
- {
- JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer)another;
+ // TODO HSQLDB Stop (debug)
+ // if (dbDialect.equals(DB_DIALECT_GENERIC) ||
+ // dbDialect.equals(DB_DIALECT_HSQLDB)) {
+ // // shutdown in-process HSQLDB database
+ // System.out.println("Shutdown in-process HSQLDB database...");
+ // try {
+ // JDBCStorageConnection conn = (JDBCStorageConnection) openConnection();
+ // Connection jdbcConn = conn.getJdbcConnection();
+ // String dbUrl = jdbcConn.getMetaData().getURL();
+ // if (dbUrl.startsWith("jdbc:hsqldb:file") ||
+ // dbUrl.startsWith("jdbc:hsqldb:mem")) {
+ // // yeah, there is in-process hsqldb, shutdown it now
+ // jdbcConn.createStatement().execute("SHUTDOWN");
+ // System.out.println("Shutdown in-process HSQLDB database... done.");
+ // }
+ // } catch (Throwable e) {
+ // log.error("JDBC Data container stop error " + e);
+ // e.printStackTrace();
+ // }
+ // }
+ }
- if (getDbSourceName() != null)
- // by jndi ds name
- return getDbSourceName().equals(anotherJdbc.getDbSourceName());
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isSame(WorkspaceDataContainer another) {
+ if (another == this)
+ return true;
- // by db connection params
- return getDbDriver().equals(anotherJdbc.getDbDriver()) && getDbUrl().equals(anotherJdbc.getDbUrl())
- && getDbUserName().equals(anotherJdbc.getDbUserName());
- }
+ if (another instanceof JDBCWorkspaceDataContainer) {
+ JDBCWorkspaceDataContainer anotherJdbc = (JDBCWorkspaceDataContainer) another;
- return false;
- }
+ if (getDbSourceName() != null)
+ // by jndi ds name
+ return getDbSourceName().equals(anotherJdbc.getDbSourceName());
- /**
- * Used in <code>equals()</code>.
- *
- * @return DataSource name
- */
- protected String getDbSourceName()
- {
- return dbSourceName;
- }
+ // by db connection params
+ return getDbDriver().equals(anotherJdbc.getDbDriver()) && getDbUrl().equals(anotherJdbc.getDbUrl())
+ && getDbUserName().equals(anotherJdbc.getDbUserName());
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return JDBC driver
- */
- protected String getDbDriver()
- {
- return dbDriver;
- }
+ return false;
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database URL
- */
- protected String getDbUrl()
- {
- return dbUrl;
- }
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return DataSource name
+ */
+ protected String getDbSourceName() {
+ return dbSourceName;
+ }
- /**
- * Used in <code>equals()</code>.
- *
- * @return Database username
- */
- protected String getDbUserName()
- {
- return dbUserName;
- }
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return JDBC driver
+ */
+ protected String getDbDriver() {
+ return dbDriver;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database URL
+ */
+ protected String getDbUrl() {
+ return dbUrl;
+ }
+
+ /**
+ * Used in <code>equals()</code>.
+ *
+ * @return Database username
+ */
+ protected String getDbUserName() {
+ return dbUserName;
+ }
}
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-08-28 06:34:31 UTC (rev 24)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/MultiDbJDBCConnection.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
@@ -42,521 +40,494 @@
*
* Created by The eXo Platform SAS. </br>
*
- * Concrete JDBC based data container that uses "table-set per Workspace policy" i.e each JCR
- * Workspace storage is placed in dedicated DB.
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady Azarenkov</a>
- * @version $Id: MultiDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
+ * Azarenkov</a>
+ * @version $Id: MultiDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
+ * pnedonosko $
*/
-public class MultiDbJDBCConnection extends JDBCStorageConnection
-{
+public class MultiDbJDBCConnection extends JDBCStorageConnection {
- protected PreparedStatement findItemById;
+ protected PreparedStatement findItemById;
- protected PreparedStatement findItemByPath;
+ protected PreparedStatement findItemByPath;
- protected PreparedStatement findItemByName;
+ protected PreparedStatement findItemByName;
- protected PreparedStatement findChildPropertyByPath;
+ protected PreparedStatement findChildPropertyByPath;
- protected PreparedStatement findPropertyByName;
+ protected PreparedStatement findPropertyByName;
- protected PreparedStatement findDescendantNodes;
+ protected PreparedStatement findDescendantNodes;
- protected PreparedStatement findDescendantProperties;
+ protected PreparedStatement findDescendantProperties;
- protected PreparedStatement findReferences;
+ protected PreparedStatement findReferences;
- protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesByPropertyId;
- protected PreparedStatement findValuesDataByPropertyId;
+ protected PreparedStatement findValuesDataByPropertyId;
+
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+
+ @Deprecated
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+ protected PreparedStatement findNodesByParentId;
- @Deprecated
- protected PreparedStatement findValueByPropertyIdOrderNumber;
+ protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement insertNode;
- protected PreparedStatement findPropertiesByParentId;
+ protected PreparedStatement insertProperty;
- protected PreparedStatement insertNode;
+ protected PreparedStatement insertReference;
- protected PreparedStatement insertProperty;
+ protected PreparedStatement insertValue;
- protected PreparedStatement insertReference;
+ protected PreparedStatement updateItem;
- protected PreparedStatement insertValue;
+ protected PreparedStatement updateItemPath;
- protected PreparedStatement updateItem;
+ protected PreparedStatement updateNode;
- protected PreparedStatement updateItemPath;
+ protected PreparedStatement updateProperty;
- protected PreparedStatement updateNode;
+ protected PreparedStatement updateValue;
- protected PreparedStatement updateProperty;
+ protected PreparedStatement deleteItem;
- protected PreparedStatement updateValue;
+ protected PreparedStatement deleteNode;
- protected PreparedStatement deleteItem;
+ protected PreparedStatement deleteProperty;
- protected PreparedStatement deleteNode;
+ protected PreparedStatement deleteReference;
- protected PreparedStatement deleteProperty;
+ protected PreparedStatement deleteValue;
- protected PreparedStatement deleteReference;
+ protected PreparedStatement renameNode;
- protected PreparedStatement deleteValue;
+ /**
+ * Multidatabase JDBC Connection constructor.
+ *
+ * @param dbConnection JDBC connection, shoudl be opened before
+ * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider External Value Storages provider
+ * @param maxBufferSize Maximum buffer size (see configuration)
+ * @param swapDirectory Swap directory (see configuration)
+ * @param swapCleaner Swap cleaner (internal FileCleaner).
+ * @throws SQLException
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public MultiDbJDBCConnection(Connection dbConnection,
+ boolean readOnly,
+ String containerName,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) throws SQLException {
- protected PreparedStatement renameNode;
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * Multidatabase JDBC Connection constructor.
- *
- * @param dbConnection
- * JDBC connection, shoudl be opened before
- * @param readOnly
- * boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public MultiDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
+ /**
+ * {@inheritDoc}
+ */
+ protected String getIdentifier(final String internalId) {
+ return internalId;
+ }
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected String getInternalId(final String identifier) {
+ return identifier;
+ }
- /**
- * {@inheritDoc}
- */
- protected String getIdentifier(final String internalId)
- {
- return internalId;
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException {
+ JCR_PK_ITEM = "JCR_PK_MITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_NAME = "JCR_IDX_MITEM_PARENT_NAME";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_MVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_MREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
- /**
- * {@inheritDoc}
- */
- protected String getInternalId(final String identifier)
- {
- return identifier;
- }
+ FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
- JCR_PK_ITEM = "JCR_PK_MITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_MITEM_PARENT";
- JCR_IDX_ITEM_PARENT_NAME = "JCR_IDX_MITEM_PARENT_NAME";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_MITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_MVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_MVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_MVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_MREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_MREF_PROPERTY";
+ FIND_ITEM_BY_NAME = "select * from JCR_MITEM"
+ + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_ID = "select * from JCR_MITEM where ID=?";
+ FIND_PROPERTY_BY_NAME = "select V.DATA"
+ + " from JCR_MITEM I, JCR_MVALUE V"
+ + " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_ITEM_BY_NAME =
- "select * from JCR_MITEM" + " where PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+ FIND_REFERENCES = "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME"
+ + " from JCR_MREF R, JCR_MITEM P"
+ + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
- FIND_PROPERTY_BY_NAME =
- "select V.DATA" + " from JCR_MITEM I, JCR_MVALUE V"
- + " where I.I_CLASS=2 and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+ FIND_VALUES_BY_PROPERTYID = "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
- FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_MREF R, JCR_MITEM P"
- + " where R.NODE_ID=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=?";
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=? order by ORDER_NUM";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_MVALUE where PROPERTY_ID=?";
+ FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?"
+ + " order by N_ORDER_NUM";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_MVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?"
+ + " order by ID";
- FIND_NODES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=1 and PARENT_ID=?" + " order by N_ORDER_NUM";
+ INSERT_NODE = "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
+ + I_CLASS_NODE + ",?,?)";
+ INSERT_PROPERTY = "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
+ + I_CLASS_PROPERTY + ",?,?,?)";
- FIND_PROPERTIES_BY_PARENTID = "select * from JCR_MITEM" + " where I_CLASS=2 and PARENT_ID=?" + " order by ID";
+ INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
- INSERT_NODE =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_MITEM(ID, PARENT_ID, NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,"
- + I_CLASS_PROPERTY + ",?,?,?)";
+ RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX =?, N_ORDER_NUM =? where ID=?";
- INSERT_VALUE = "insert into JCR_MVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_MREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
+ UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
+ //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
- RENAME_NODE = "update JCR_MITEM set PARENT_ID=?, NAME =?, VERSION=?, I_INDEX =?, N_ORDER_NUM =? where ID=?";
+ DELETE_ITEM = "delete from JCR_MITEM where ID=?";
+ DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
+ DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
+ }
- UPDATE_NODE = "update JCR_MITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- UPDATE_PROPERTY = "update JCR_MITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_MVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
- DELETE_ITEM = "delete from JCR_MITEM where ID=?";
- DELETE_VALUE = "delete from JCR_MVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_MREF where PROPERTY_ID=?";
- }
+ insertNode.setString(1, data.getIdentifier());
+ insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID
+ : data.getParentIdentifier());
+ insertNode.setString(3, data.getQPath().getName().getAsString());
+ insertNode.setInt(4, data.getPersistedVersion());
+ insertNode.setInt(5, data.getQPath().getIndex());
+ insertNode.setInt(6, data.getOrderNumber());
+ return insertNode.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.clearParameters();
- insertNode.setString(1, data.getIdentifier());
- insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
- insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setInt(4, data.getPersistedVersion());
- insertNode.setInt(5, data.getQPath().getIndex());
- insertNode.setInt(6, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
+ insertProperty.setString(1, data.getIdentifier());
+ insertProperty.setString(2, data.getParentIdentifier());
+ insertProperty.setString(3, data.getQPath().getName().getAsString());
+ insertProperty.setInt(4, data.getPersistedVersion());
+ insertProperty.setInt(5, data.getQPath().getIndex());
+ insertProperty.setInt(6, data.getType());
+ insertProperty.setBoolean(7, data.isMultiValued());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
+ return insertProperty.executeUpdate();
+ }
- insertProperty.setString(1, data.getIdentifier());
- insertProperty.setString(2, data.getParentIdentifier());
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setInt(4, data.getPersistedVersion());
- insertProperty.setInt(5, data.getQPath().getIndex());
- insertProperty.setInt(6, data.getType());
- insertProperty.setBoolean(7, data.isMultiValued());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
- return insertProperty.executeUpdate();
- }
+ if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
+ LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
+ List<ValueData> values = data.getValues();
+ int added = 0;
+ for (int i = 0; i < values.size(); i++) {
+ ValueData vdata = values.get(i);
+ String refNodeIdentifier = ValueDataConvertor.readString(vdata);
- if (data.getQPath().getAsString().indexOf("versionableUuid") > 0)
- LOG.info("add ref versionableUuid " + data.getQPath().getAsString());
+ insertReference.setString(1, refNodeIdentifier);
+ insertReference.setString(2, data.getIdentifier());
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
- List<ValueData> values = data.getValues();
- int added = 0;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = ValueDataConvertor.readString(vdata);
+ return added;
+ }
- insertReference.setString(1, refNodeIdentifier);
- insertReference.setString(2, data.getIdentifier());
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyIdentifier) throws SQLException {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
- return added;
- }
+ deleteReference.setString(1, propertyIdentifier);
+ return deleteReference.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyIdentifier) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String identifier) throws SQLException {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
- deleteReference.setString(1, propertyIdentifier);
- return deleteReference.executeUpdate();
- }
+ deleteItem.setString(1, identifier);
+ return deleteItem.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String identifier) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier) throws SQLException {
+ if (updateNode == null)
+ updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ else
+ updateNode.clearParameters();
- deleteItem.setString(1, identifier);
- return deleteItem.executeUpdate();
- }
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, identifier);
+ return updateNode.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updateNodeByIdentifier(int version, int index, int orderNumb, String identifier) throws SQLException
- {
- if (updateNode == null)
- updateNode = dbConnection.prepareStatement(UPDATE_NODE);
- else
- updateNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String identifier) throws SQLException {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, identifier);
- return updateNode.executeUpdate();
- }
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, identifier);
+ return updateProperty.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updatePropertyByIdentifier(int version, int type, String identifier) throws SQLException
- {
- if (updateProperty == null)
- updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
- else
- updateProperty.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, identifier);
- return updateProperty.executeUpdate();
- }
+ findItemByName.setString(1, parentId);
+ findItemByName.setString(2, name);
+ findItemByName.setInt(3, index);
+ return findItemByName.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentId, String name) throws SQLException {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
- findItemByName.setString(1, parentId);
- findItemByName.setString(2, name);
- findItemByName.setInt(3, index);
- return findItemByName.executeQuery();
- }
+ findPropertyByName.setString(1, parentId);
+ findPropertyByName.setString(2, name);
+ return findPropertyByName.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findPropertyByName(String parentId, String name) throws SQLException
- {
- if (findPropertyByName == null)
- findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
- else
- findPropertyByName.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String identifier) throws SQLException {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
- findPropertyByName.setString(1, parentId);
- findPropertyByName.setString(2, name);
- return findPropertyByName.executeQuery();
- }
+ findItemById.setString(1, identifier);
+ return findItemById.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String identifier) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String nodeIdentifier) throws SQLException {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
- findItemById.setString(1, identifier);
- return findItemById.executeQuery();
- }
+ findReferences.setString(1, nodeIdentifier);
+ return findReferences.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String nodeIdentifier) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
- findReferences.setString(1, nodeIdentifier);
- return findReferences.executeQuery();
- }
+ findNodesByParentId.setString(1, parentIdentifier);
+ return findNodesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
- findNodesByParentId.setString(1, parentIdentifier);
- return findNodesByParentId.executeQuery();
- }
+ findPropertiesByParentId.setString(1, parentIdentifier);
+ return findPropertiesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentIdentifier) throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
+ // -------- values processing ------------
- findPropertiesByParentId.setString(1, parentIdentifier);
- return findPropertiesByParentId.executeQuery();
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int addValueData(String cid,
+ int orderNumber,
+ InputStream stream,
+ int streamLength,
+ String storageDesc) throws SQLException {
- // -------- values processing ------------
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
+ if (stream == null) {
+ // [PN] store vd reference to external storage etc.
+ insertValue.setNull(1, Types.BINARY);
+ insertValue.setString(4, storageDesc);
+ } else {
+ insertValue.setBinaryStream(1, stream, streamLength);
+ insertValue.setNull(4, Types.VARCHAR);
+ }
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int deleteValueData(String cid) throws SQLException {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException {
+ if (findValueByPropertyIdOrderNumber == null)
+ findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ else
+ findValueByPropertyIdOrderNumber.clearParameters();
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- else
- findValueByPropertyIdOrderNumber.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
+ renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID
+ : data.getParentIdentifier());
+ renameNode.setString(2, data.getQPath().getName().getAsString());
+ renameNode.setInt(3, data.getPersistedVersion());
+ renameNode.setInt(4, data.getQPath().getIndex());
+ renameNode.setInt(5, data.getOrderNumber());
+ renameNode.setString(6, data.getIdentifier());
+ return renameNode.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- else
- renameNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId = dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.clearParameters();
- renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : data
- .getParentIdentifier());
-
- renameNode.setString(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, data.getIdentifier());
- return renameNode.executeUpdate();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
- {
- if (findValuesStorageDescriptorsByPropertyId == null)
- findValuesStorageDescriptorsByPropertyId =
- dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
- else
- findValuesStorageDescriptorsByPropertyId.clearParameters();
-
- findValuesStorageDescriptorsByPropertyId.setString(1, cid);
- return findValuesStorageDescriptorsByPropertyId.executeQuery();
- }
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
}
Modified: jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-08-28 06:34:31 UTC (rev 24)
+++ jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/SingleDbJDBCConnection.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -1,20 +1,18 @@
/*
- * Copyright (C) 2009 eXo Platform SAS.
+ * Copyright (C) 2003-2007 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 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 software is distributed in the hope that it will be useful,
+ * 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
- * Lesser General Public License for more details.
+ * 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 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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
*/
package org.exoplatform.services.jcr.impl.storage.jdbc.db;
@@ -41,533 +39,505 @@
*
* Created by The eXo Platform SAS 27.04.2006
*
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id: SingleDbJDBCConnection.java 34801 2009-07-31 15:44:50Z dkatayev $
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
+ * Nedonosko</a>
+ * @version $Id: SingleDbJDBCConnection.java 20950 2008-10-06 14:23:07Z
+ * pnedonosko $
*/
-public class SingleDbJDBCConnection extends JDBCStorageConnection
-{
+public class SingleDbJDBCConnection extends JDBCStorageConnection {
- protected PreparedStatement findItemById;
+ protected PreparedStatement findItemById;
- protected PreparedStatement findItemByPath;
+ protected PreparedStatement findItemByPath;
- protected PreparedStatement findItemByName;
+ protected PreparedStatement findItemByName;
- protected PreparedStatement findChildPropertyByPath;
+ protected PreparedStatement findChildPropertyByPath;
- protected PreparedStatement findPropertyByName;
+ protected PreparedStatement findPropertyByName;
- protected PreparedStatement findDescendantNodes;
+ protected PreparedStatement findDescendantNodes;
- protected PreparedStatement findDescendantProperties;
+ protected PreparedStatement findDescendantProperties;
- protected PreparedStatement findReferences;
+ protected PreparedStatement findReferences;
- protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesByPropertyId;
+ protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
- protected PreparedStatement findValuesStorageDescriptorsByPropertyId;
+ protected PreparedStatement findValuesDataByPropertyId;
- protected PreparedStatement findValuesDataByPropertyId;
+ protected PreparedStatement findValueByPropertyIdOrderNumber;
- protected PreparedStatement findValueByPropertyIdOrderNumber;
+ protected PreparedStatement findNodesByParentId;
- protected PreparedStatement findNodesByParentId;
+ protected PreparedStatement findPropertiesByParentId;
- protected PreparedStatement findPropertiesByParentId;
+ protected PreparedStatement insertItem;
- protected PreparedStatement insertItem;
+ protected PreparedStatement insertNode;
- protected PreparedStatement insertNode;
+ protected PreparedStatement insertProperty;
- protected PreparedStatement insertProperty;
+ protected PreparedStatement insertReference;
- protected PreparedStatement insertReference;
+ protected PreparedStatement insertValue;
- protected PreparedStatement insertValue;
+ protected PreparedStatement updateItem;
- protected PreparedStatement updateItem;
+ protected PreparedStatement updateItemPath;
- protected PreparedStatement updateItemPath;
+ protected PreparedStatement updateNode;
- protected PreparedStatement updateNode;
+ protected PreparedStatement updateProperty;
- protected PreparedStatement updateProperty;
+ protected PreparedStatement updateValue;
+
+ protected PreparedStatement deleteItem;
- protected PreparedStatement updateValue;
+ protected PreparedStatement deleteNode;
- protected PreparedStatement deleteItem;
+ protected PreparedStatement deleteProperty;
- protected PreparedStatement deleteNode;
+ protected PreparedStatement deleteReference;
- protected PreparedStatement deleteProperty;
+ protected PreparedStatement deleteValue;
- protected PreparedStatement deleteReference;
+ protected PreparedStatement renameNode;
- protected PreparedStatement deleteValue;
+ /**
+ * Singledatabase JDBC Connection constructor.
+ *
+ * @param dbConnection JDBC connection, shoudl be opened before
+ * @param readOnly, boolean if true the dbConnection was marked as READ-ONLY.
+ * @param containerName Workspace Storage Container name (see configuration)
+ * @param valueStorageProvider External Value Storages provider
+ * @param maxBufferSize Maximum buffer size (see configuration)
+ * @param swapDirectory Swap directory (see configuration)
+ * @param swapCleaner Swap cleaner (internal FileCleaner).
+ * @throws SQLException in case of database error
+ * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
+ */
+ public SingleDbJDBCConnection(Connection dbConnection,
+ boolean readOnly,
+ String containerName,
+ ValueStoragePluginProvider valueStorageProvider,
+ int maxBufferSize,
+ File swapDirectory,
+ FileCleaner swapCleaner) throws SQLException {
- protected PreparedStatement renameNode;
+ super(dbConnection,
+ readOnly,
+ containerName,
+ valueStorageProvider,
+ maxBufferSize,
+ swapDirectory,
+ swapCleaner);
+ }
- /**
- * Singledatabase JDBC Connection constructor.
- *
- * @param dbConnection
- * JDBC connection, shoudl be opened before
- * @param readOnly
- * boolean if true the dbConnection was marked as READ-ONLY.
- * @param containerName
- * Workspace Storage Container name (see configuration)
- * @param valueStorageProvider
- * External Value Storages provider
- * @param maxBufferSize
- * Maximum buffer size (see configuration)
- * @param swapDirectory
- * Swap directory (see configuration)
- * @param swapCleaner
- * Swap cleaner (internal FileCleaner).
- * @throws SQLException
- * in case of database error
- *
- * @see org.exoplatform.services.jcr.impl.util.io.FileCleaner
- */
- public SingleDbJDBCConnection(Connection dbConnection, boolean readOnly, String containerName,
- ValueStoragePluginProvider valueStorageProvider, int maxBufferSize, File swapDirectory, FileCleaner swapCleaner)
- throws SQLException
- {
+ /**
+ * {@inheritDoc}
+ */
+ protected String getInternalId(final String identifier) {
+ return containerName + identifier;
+ }
- super(dbConnection, readOnly, containerName, valueStorageProvider, maxBufferSize, swapDirectory, swapCleaner);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected String getIdentifier(final String internalId) {
- /**
- * {@inheritDoc}
- */
- protected String getInternalId(final String identifier)
- {
- return containerName + identifier;
- }
+ if (internalId == null) // possible for root parent
+ return null;
- /**
- * {@inheritDoc}
- */
- protected String getIdentifier(final String internalId)
- {
+ return internalId.substring(containerName.length());
+ }
- if (internalId == null) // possible for root parent
- return null;
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void prepareQueries() throws SQLException {
- return internalId.substring(containerName.length());
- }
+ JCR_PK_ITEM = "JCR_PK_SITEM";
+ JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
+ JCR_IDX_ITEM_PARENT_NAME = "JCR_IDX_SITEM_PARENT_NAME";
+ JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
+ JCR_PK_VALUE = "JCR_PK_SVALUE";
+ JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
+ JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
+ JCR_PK_REF = "JCR_PK_SREF";
+ JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareQueries() throws SQLException
- {
+ FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
- JCR_PK_ITEM = "JCR_PK_SITEM";
- JCR_FK_ITEM_PARENT = "JCR_FK_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT = "JCR_IDX_SITEM_PARENT";
- JCR_IDX_ITEM_PARENT_NAME = "JCR_IDX_SITEM_PARENT_NAME";
- JCR_IDX_ITEM_PARENT_ID = "JCR_IDX_SITEM_PARENT_ID";
- JCR_PK_VALUE = "JCR_PK_SVALUE";
- JCR_FK_VALUE_PROPERTY = "JCR_FK_SVALUE_PROPERTY";
- JCR_IDX_VALUE_PROPERTY = "JCR_IDX_SVALUE_PROPERTY";
- JCR_PK_REF = "JCR_PK_SREF";
- JCR_IDX_REF_PROPERTY = "JCR_IDX_SREF_PROPERTY";
+ FIND_ITEM_BY_NAME = "select * from JCR_SITEM"
+ + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
- FIND_ITEM_BY_ID = "select * from JCR_SITEM where ID=?";
+ FIND_PROPERTY_BY_NAME = "select V.DATA"
+ + " from JCR_SITEM I, JCR_SVALUE V"
+ + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
- FIND_ITEM_BY_NAME =
- "select * from JCR_SITEM"
- + " where CONTAINER_NAME=? and PARENT_ID=? and NAME=? and I_INDEX=? order by I_CLASS, VERSION DESC";
+ FIND_REFERENCES = "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME"
+ + " from JCR_SREF R, JCR_SITEM P"
+ + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
- FIND_PROPERTY_BY_NAME =
- "select V.DATA"
- + " from JCR_SITEM I, JCR_SVALUE V"
- + " where I.I_CLASS=2 and I.CONTAINER_NAME=? and I.PARENT_ID=? and I.NAME=? and I.ID=V.PROPERTY_ID order by V.ORDER_NUM";
+ FIND_VALUES_BY_PROPERTYID = "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
- FIND_REFERENCES =
- "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME" + " from JCR_SREF R, JCR_SITEM P"
- + " where R.NODE_ID=? and P.CONTAINER_NAME=? and P.ID=R.PROPERTY_ID and P.I_CLASS=2";
+ FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
- FIND_VALUES_BY_PROPERTYID =
- "select PROPERTY_ID, ORDER_NUM, DATA, STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=? order by ORDER_NUM";
+ FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
- FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID = "select distinct STORAGE_DESC from JCR_SVALUE where PROPERTY_ID=?";
+ FIND_NODES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
- FIND_VALUE_BY_PROPERTYID_OREDERNUMB = "select DATA from JCR_SVALUE where PROPERTY_ID=? and ORDER_NUM=?";
+ FIND_PROPERTIES_BY_PARENTID = "select * from JCR_SITEM"
+ + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
- FIND_NODES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?" + " order by N_ORDER_NUM";
+ INSERT_NODE = "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
+ + I_CLASS_NODE + ",?,?)";
+ INSERT_PROPERTY = "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,?,"
+ + I_CLASS_PROPERTY + ",?,?,?)";
- FIND_PROPERTIES_BY_PARENTID =
- "select * from JCR_SITEM" + " where I_CLASS=2 and CONTAINER_NAME=? and PARENT_ID=?" + " order by ID";
+ INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
+ INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
- INSERT_NODE =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, N_ORDER_NUM) VALUES(?,?,?,?,?,"
- + I_CLASS_NODE + ",?,?)";
- INSERT_PROPERTY =
- "insert into JCR_SITEM(ID, PARENT_ID, NAME, CONTAINER_NAME, VERSION, I_CLASS, I_INDEX, P_TYPE, P_MULTIVALUED) VALUES(?,?,?,?,?,"
- + I_CLASS_PROPERTY + ",?,?,?)";
+ RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- INSERT_VALUE = "insert into JCR_SVALUE(DATA, ORDER_NUM, PROPERTY_ID, STORAGE_DESC) VALUES(?,?,?,?)";
- INSERT_REF = "insert into JCR_SREF(NODE_ID, PROPERTY_ID, ORDER_NUM) VALUES(?,?,?)";
+ UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
+ //UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
- RENAME_NODE = "update JCR_SITEM set PARENT_ID=?, NAME=?, VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
+ DELETE_ITEM = "delete from JCR_SITEM where ID=?";
+ DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
+ DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
+ }
- UPDATE_NODE = "update JCR_SITEM set VERSION=?, I_INDEX=?, N_ORDER_NUM=? where ID=?";
- UPDATE_PROPERTY = "update JCR_SITEM set VERSION=?, P_TYPE=? where ID=?";
- //UPDATE_VALUE = "update JCR_SVALUE set DATA=?, STORAGE_DESC=? where PROPERTY_ID=?, ORDER_NUM=?";
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addNodeRecord(NodeData data) throws SQLException {
+ if (insertNode == null)
+ insertNode = dbConnection.prepareStatement(INSERT_NODE);
+ else
+ insertNode.clearParameters();
- DELETE_ITEM = "delete from JCR_SITEM where ID=?";
- DELETE_VALUE = "delete from JCR_SVALUE where PROPERTY_ID=?";
- DELETE_REF = "delete from JCR_SREF where PROPERTY_ID=?";
- }
+ insertNode.setString(1, getInternalId(data.getIdentifier()));
+ // if root then parent identifier equals space string
+ insertNode.setString(2,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID
+ : getInternalId(data.getParentIdentifier()));
+ insertNode.setString(3, data.getQPath().getName().getAsString());
+ insertNode.setString(4, containerName);
+ insertNode.setInt(5, data.getPersistedVersion());
+ insertNode.setInt(6, data.getQPath().getIndex());
+ insertNode.setInt(7, data.getOrderNumber());
+ return insertNode.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addNodeRecord(NodeData data) throws SQLException
- {
- if (insertNode == null)
- insertNode = dbConnection.prepareStatement(INSERT_NODE);
- else
- insertNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addPropertyRecord(PropertyData data) throws SQLException {
+ if (insertProperty == null)
+ insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
+ else
+ insertProperty.clearParameters();
- insertNode.setString(1, getInternalId(data.getIdentifier()));
- // if root then parent identifier equals space string
- insertNode.setString(2, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- insertNode.setString(3, data.getQPath().getName().getAsString());
- insertNode.setString(4, containerName);
- insertNode.setInt(5, data.getPersistedVersion());
- insertNode.setInt(6, data.getQPath().getIndex());
- insertNode.setInt(7, data.getOrderNumber());
- return insertNode.executeUpdate();
- }
+ insertProperty.setString(1, getInternalId(data.getIdentifier()));
+ insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
+ insertProperty.setString(3, data.getQPath().getName().getAsString());
+ insertProperty.setString(4, containerName);
+ insertProperty.setInt(5, data.getPersistedVersion());
+ insertProperty.setInt(6, data.getQPath().getIndex());
+ insertProperty.setInt(7, data.getType());
+ insertProperty.setBoolean(8, data.isMultiValued());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addPropertyRecord(PropertyData data) throws SQLException
- {
- if (insertProperty == null)
- insertProperty = dbConnection.prepareStatement(INSERT_PROPERTY);
- else
- insertProperty.clearParameters();
+ return insertProperty.executeUpdate();
+ }
- insertProperty.setString(1, getInternalId(data.getIdentifier()));
- insertProperty.setString(2, getInternalId(data.getParentIdentifier()));
- insertProperty.setString(3, data.getQPath().getName().getAsString());
- insertProperty.setString(4, containerName);
- insertProperty.setInt(5, data.getPersistedVersion());
- insertProperty.setInt(6, data.getQPath().getIndex());
- insertProperty.setInt(7, data.getType());
- insertProperty.setBoolean(8, data.isMultiValued());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int addReference(PropertyData data) throws SQLException, IOException {
+ if (insertReference == null)
+ insertReference = dbConnection.prepareStatement(INSERT_REF);
+ else
+ insertReference.clearParameters();
- return insertProperty.executeUpdate();
- }
+ List<ValueData> values = data.getValues();
+ int added = 0;
+ for (int i = 0; i < values.size(); i++) {
+ ValueData vdata = values.get(i);
+ String refNodeIdentifier = new String(vdata.getAsByteArray());
- /**
- * {@inheritDoc}
- */
- @Override
- protected int addReference(PropertyData data) throws SQLException, IOException
- {
- if (insertReference == null)
- insertReference = dbConnection.prepareStatement(INSERT_REF);
- else
- insertReference.clearParameters();
+ insertReference.setString(1, getInternalId(refNodeIdentifier));
+ insertReference.setString(2, getInternalId(data.getIdentifier()));
+ insertReference.setInt(3, i);
+ added += insertReference.executeUpdate();
+ }
+ return added;
+ }
- List<ValueData> values = data.getValues();
- int added = 0;
- for (int i = 0; i < values.size(); i++)
- {
- ValueData vdata = values.get(i);
- String refNodeIdentifier = new String(vdata.getAsByteArray());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteReference(String propertyCid) throws SQLException {
+ if (deleteReference == null)
+ deleteReference = dbConnection.prepareStatement(DELETE_REF);
+ else
+ deleteReference.clearParameters();
- insertReference.setString(1, getInternalId(refNodeIdentifier));
- insertReference.setString(2, getInternalId(data.getIdentifier()));
- insertReference.setInt(3, i);
- added += insertReference.executeUpdate();
- }
- return added;
- }
+ deleteReference.setString(1, propertyCid);
+ return deleteReference.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteReference(String propertyCid) throws SQLException
- {
- if (deleteReference == null)
- deleteReference = dbConnection.prepareStatement(DELETE_REF);
- else
- deleteReference.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int deleteItemByIdentifier(String cid) throws SQLException {
+ if (deleteItem == null)
+ deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
+ else
+ deleteItem.clearParameters();
- deleteReference.setString(1, propertyCid);
- return deleteReference.executeUpdate();
- }
+ deleteItem.setString(1, cid);
+ return deleteItem.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int deleteItemByIdentifier(String cid) throws SQLException
- {
- if (deleteItem == null)
- deleteItem = dbConnection.prepareStatement(DELETE_ITEM);
- else
- deleteItem.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException {
+ if (findNodesByParentId == null)
+ findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
+ else
+ findNodesByParentId.clearParameters();
- deleteItem.setString(1, cid);
- return deleteItem.executeUpdate();
- }
+ findNodesByParentId.setString(1, containerName);
+ findNodesByParentId.setString(2, parentCid);
+ return findNodesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildNodesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findNodesByParentId == null)
- findNodesByParentId = dbConnection.prepareStatement(FIND_NODES_BY_PARENTID);
- else
- findNodesByParentId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException {
+ if (findPropertiesByParentId == null)
+ findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
+ else
+ findPropertiesByParentId.clearParameters();
- findNodesByParentId.setString(1, containerName);
- findNodesByParentId.setString(2, parentCid);
- return findNodesByParentId.executeQuery();
- }
+ findPropertiesByParentId.setString(1, containerName);
+ findPropertiesByParentId.setString(2, parentCid);
+ return findPropertiesByParentId.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findChildPropertiesByParentIdentifier(String parentCid) throws SQLException
- {
- if (findPropertiesByParentId == null)
- findPropertiesByParentId = dbConnection.prepareStatement(FIND_PROPERTIES_BY_PARENTID);
- else
- findPropertiesByParentId.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException {
+ if (findItemByName == null)
+ findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
+ else
+ findItemByName.clearParameters();
- findPropertiesByParentId.setString(1, containerName);
- findPropertiesByParentId.setString(2, parentCid);
- return findPropertiesByParentId.executeQuery();
- }
+ findItemByName.setString(1, containerName);
+ findItemByName.setString(2, parentId);
+ findItemByName.setString(3, name);
+ findItemByName.setInt(4, index);
+ return findItemByName.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByName(String parentId, String name, int index) throws SQLException
- {
- if (findItemByName == null)
- findItemByName = dbConnection.prepareStatement(FIND_ITEM_BY_NAME);
- else
- findItemByName.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException {
+ if (findPropertyByName == null)
+ findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
+ else
+ findPropertyByName.clearParameters();
- findItemByName.setString(1, containerName);
- findItemByName.setString(2, parentId);
- findItemByName.setString(3, name);
- findItemByName.setInt(4, index);
- return findItemByName.executeQuery();
- }
+ findPropertyByName.setString(1, containerName);
+ findPropertyByName.setString(2, parentCid);
+ findPropertyByName.setString(3, name);
+ return findPropertyByName.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findPropertyByName(String parentCid, String name) throws SQLException
- {
- if (findPropertyByName == null)
- findPropertyByName = dbConnection.prepareStatement(FIND_PROPERTY_BY_NAME);
- else
- findPropertyByName.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findItemByIdentifier(String cid) throws SQLException {
+ if (findItemById == null)
+ findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
+ else
+ findItemById.clearParameters();
- findPropertyByName.setString(1, containerName);
- findPropertyByName.setString(2, parentCid);
- findPropertyByName.setString(3, name);
- return findPropertyByName.executeQuery();
- }
+ findItemById.setString(1, cid);
+ return findItemById.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findItemByIdentifier(String cid) throws SQLException
- {
- if (findItemById == null)
- findItemById = dbConnection.prepareStatement(FIND_ITEM_BY_ID);
- else
- findItemById.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findReferences(String cid) throws SQLException {
+ if (findReferences == null)
+ findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
+ else
+ findReferences.clearParameters();
- findItemById.setString(1, cid);
- return findItemById.executeQuery();
- }
+ findReferences.setString(1, cid);
+ findReferences.setString(2, containerName);
+ return findReferences.executeQuery();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findReferences(String cid) throws SQLException
- {
- if (findReferences == null)
- findReferences = dbConnection.prepareStatement(FIND_REFERENCES);
- else
- findReferences.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException {
+ if (updateNode == null)
+ updateNode = dbConnection.prepareStatement(UPDATE_NODE);
+ else
+ updateNode.clearParameters();
- findReferences.setString(1, cid);
- findReferences.setString(2, containerName);
- return findReferences.executeQuery();
- }
+ updateNode.setInt(1, version);
+ updateNode.setInt(2, index);
+ updateNode.setInt(3, orderNumb);
+ updateNode.setString(4, cid);
+ return updateNode.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updateNodeByIdentifier(int version, int index, int orderNumb, String cid) throws SQLException
- {
- if (updateNode == null)
- updateNode = dbConnection.prepareStatement(UPDATE_NODE);
- else
- updateNode.clearParameters();
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException {
+ if (updateProperty == null)
+ updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
+ else
+ updateProperty.clearParameters();
- updateNode.setInt(1, version);
- updateNode.setInt(2, index);
- updateNode.setInt(3, orderNumb);
- updateNode.setString(4, cid);
- return updateNode.executeUpdate();
- }
+ updateProperty.setInt(1, version);
+ updateProperty.setInt(2, type);
+ updateProperty.setString(3, cid);
+ return updateProperty.executeUpdate();
+ }
- /**
- * {@inheritDoc}
- */
- @Override
- protected int updatePropertyByIdentifier(int version, int type, String cid) throws SQLException
- {
- if (updateProperty == null)
- updateProperty = dbConnection.prepareStatement(UPDATE_PROPERTY);
- else
- updateProperty.clearParameters();
+ // -------- values processing ------------
- updateProperty.setInt(1, version);
- updateProperty.setInt(2, type);
- updateProperty.setString(3, cid);
- return updateProperty.executeUpdate();
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int addValueData(String cid,
+ int orderNumber,
+ InputStream stream,
+ int streamLength,
+ String storageDesc) throws SQLException {
- // -------- values processing ------------
+ if (insertValue == null)
+ insertValue = dbConnection.prepareStatement(INSERT_VALUE);
+ else
+ insertValue.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int addValueData(String cid, int orderNumber, InputStream stream, int streamLength, String storageDesc)
- throws SQLException
- {
+ if (stream == null) {
+ // [PN] store vd reference to external storage etc.
+ insertValue.setNull(1, Types.BINARY);
+ insertValue.setString(4, storageDesc);
+ } else {
+ insertValue.setBinaryStream(1, stream, streamLength);
+ insertValue.setNull(4, Types.VARCHAR);
+ }
- if (insertValue == null)
- insertValue = dbConnection.prepareStatement(INSERT_VALUE);
- else
- insertValue.clearParameters();
+ insertValue.setInt(2, orderNumber);
+ insertValue.setString(3, cid);
+ return insertValue.executeUpdate();
+ }
- if (stream == null)
- {
- // [PN] store vd reference to external storage etc.
- insertValue.setNull(1, Types.BINARY);
- insertValue.setString(4, storageDesc);
- }
- else
- {
- insertValue.setBinaryStream(1, stream, streamLength);
- insertValue.setNull(4, Types.VARCHAR);
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected int deleteValueData(String cid) throws SQLException {
+ if (deleteValue == null)
+ deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
+ else
+ deleteValue.clearParameters();
- insertValue.setInt(2, orderNumber);
- insertValue.setString(3, cid);
- return insertValue.executeUpdate();
- }
+ deleteValue.setString(1, cid);
+ return deleteValue.executeUpdate();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ResultSet findValuesByPropertyId(String cid) throws SQLException {
+ if (findValuesByPropertyId == null)
+ findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
+ else
+ findValuesByPropertyId.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected int deleteValueData(String cid) throws SQLException
- {
- if (deleteValue == null)
- deleteValue = dbConnection.prepareStatement(DELETE_VALUE);
- else
- deleteValue.clearParameters();
+ findValuesByPropertyId.setString(1, cid);
+ return findValuesByPropertyId.executeQuery();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException {
+ if (findValuesStorageDescriptorsByPropertyId == null)
+ findValuesStorageDescriptorsByPropertyId = dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
+ else
+ findValuesStorageDescriptorsByPropertyId.clearParameters();
- deleteValue.setString(1, cid);
- return deleteValue.executeUpdate();
- }
+ findValuesStorageDescriptorsByPropertyId.setString(1, cid);
+ return findValuesStorageDescriptorsByPropertyId.executeQuery();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Deprecated
+ protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException {
+ if (findValueByPropertyIdOrderNumber == null)
+ findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
+ else
+ findValueByPropertyIdOrderNumber.clearParameters();
- /**
- * {@inheritDoc}
- */
- protected ResultSet findValuesByPropertyId(String cid) throws SQLException
- {
- if (findValuesByPropertyId == null)
- findValuesByPropertyId = dbConnection.prepareStatement(FIND_VALUES_BY_PROPERTYID);
- else
- findValuesByPropertyId.clearParameters();
+ findValueByPropertyIdOrderNumber.setString(1, cid);
+ findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
+ return findValueByPropertyIdOrderNumber.executeQuery();
+ }
+
- findValuesByPropertyId.setString(1, cid);
- return findValuesByPropertyId.executeQuery();
- }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int renameNode(NodeData data) throws SQLException {
+ if (renameNode == null)
+ renameNode = dbConnection.prepareStatement(RENAME_NODE);
+ else
+ renameNode.clearParameters();
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResultSet findValuesStorageDescriptorsByPropertyId(String cid) throws SQLException
- {
- if (findValuesStorageDescriptorsByPropertyId == null)
- findValuesStorageDescriptorsByPropertyId =
- dbConnection.prepareStatement(FIND_VALUES_VSTORAGE_DESC_BY_PROPERTYID);
- else
- findValuesStorageDescriptorsByPropertyId.clearParameters();
-
- findValuesStorageDescriptorsByPropertyId.setString(1, cid);
- return findValuesStorageDescriptorsByPropertyId.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- protected ResultSet findValueByPropertyIdOrderNumber(String cid, int orderNumb) throws SQLException
- {
- if (findValueByPropertyIdOrderNumber == null)
- findValueByPropertyIdOrderNumber = dbConnection.prepareStatement(FIND_VALUE_BY_PROPERTYID_OREDERNUMB);
- else
- findValueByPropertyIdOrderNumber.clearParameters();
-
- findValueByPropertyIdOrderNumber.setString(1, cid);
- findValueByPropertyIdOrderNumber.setInt(2, orderNumb);
- return findValueByPropertyIdOrderNumber.executeQuery();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected int renameNode(NodeData data) throws SQLException
- {
- if (renameNode == null)
- renameNode = dbConnection.prepareStatement(RENAME_NODE);
- else
- renameNode.clearParameters();
-
- renameNode.setString(1, data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID : getInternalId(data
- .getParentIdentifier()));
- renameNode.setString(2, data.getQPath().getName().getAsString());
- renameNode.setInt(3, data.getPersistedVersion());
- renameNode.setInt(4, data.getQPath().getIndex());
- renameNode.setInt(5, data.getOrderNumber());
- renameNode.setString(6, getInternalId(data.getIdentifier()));
- return renameNode.executeUpdate();
- }
+ renameNode.setString(1,
+ data.getParentIdentifier() == null ? Constants.ROOT_PARENT_UUID
+ : getInternalId(data.getParentIdentifier()));
+ renameNode.setString(2, data.getQPath().getName().getAsString());
+ renameNode.setInt(3, data.getPersistedVersion());
+ renameNode.setInt(4, data.getQPath().getIndex());
+ renameNode.setInt(5, data.getOrderNumber());
+ renameNode.setString(6, getInternalId(data.getIdentifier()));
+ return renameNode.executeUpdate();
+ }
}
Modified: jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml
===================================================================
--- jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml 2009-08-28 06:34:31 UTC (rev 24)
+++ jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration-sjdbc.xml 2009-08-28 06:54:41 UTC (rev 25)
@@ -1,316 +1,355 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
- <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
- <init-params>
- <value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>Log4J properties</description>
- <property name="log4j.rootLogger" value="INFO, stdout, file" />
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file"/>
- <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
- <property name="log4j.appender.stdout.threshold" value="INFO" />
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold" value="INFO"/>
- <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
- <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
- <property name="log4j.appender.file.File" value="target/jcr.log" />
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File" value="target/jcr.log"/>
- <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
- <!-- property name="log4j.category.jcr.DBInitializer" value="DEBUG"/ -->
-
- <!-- property name="log4j.category.jcr.SessionDataManager" value="DEBUG" />
- <property name="log4j.category.jcr.JDBCStorageConnection" value="DEBUG" />
- <property name="log4j.category.jcr.NodeImpl" value="DEBUG" / -->
-
- <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
- <!-- property name="log4j.category.database.DBSchemaCreator" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspaceDataReplicator" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.DBInitializer" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspacePersistentDataManager" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.SessionDataManager" value="DEBUG"/>
+ <property name="log4j.category.jcr.JDBCStorageConnection" value="DEBUG"/>
+ <property name="log4j.category.jcr.NodeImpl" value="DEBUG"/ -->
- </properties-param>
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
+ <!-- property name="log4j.category.database.DBSchemaCreator" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspaceDataReplicator" value="DEBUG"/ -->
- <!-- value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>SimpleLog properties</description>
- <property name="org.apache.commons.logging.simplelog.defaultlog" value="debug" />
- <property name="org.apache.commons.logging.simplelog.showdatetime" value="true" />
- </properties-param -->
-
- <!-- value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>jdk1.4 Logger properties</description>
- <property name="handlers" value="java.util.logging.ConsoleHandler" />
- <property name=".level" value="FINE" />
- <property name="java.util.logging.ConsoleHandler.level" value="FINE" />
- </properties-param -->
+ <!-- property name="log4j.category.jcr.WorkspacePersistentDataManager" value="DEBUG"/ -->
- </init-params>
- </component>
- <component>
+ </properties-param>
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>SimpleLog properties</description>
+ <property name="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
+ <property name="org.apache.commons.logging.simplelog.showdatetime" value="true"/>
+ </properties-param -->
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>jdk1.4 Logger properties</description>
+ <property name="handlers" value="java.util.logging.ConsoleHandler"/>
+ <property name=".level" value="FINE"/>
+ <property name="java.util.logging.ConsoleHandler.level" value="FINE"/>
+ </properties-param -->
+
+ </init-params>
+ </component>
+ <component>
<key>org.exoplatform.services.jcr.RepositoryService</key>
<type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
<component-plugins>
- <component-plugin>
+ <component-plugin>
<name>add.namespaces</name>
<set-method>addPlugin</set-method>
<type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
<init-params>
- <properties-param>
- <name>namespaces</name>
- <property name="test" value="http://www.apache.org/jackrabbit/test" />
- <property name="exojcrtest" value="http://www.exoplatform.org/jcr/test/1.0" />
- <property name="rma" value="http://www.rma.com/jcr/" />
- <property name="metadata" value="http://www.exoplatform.com/jcr/metadata/1.1/" />
- </properties-param>
+ <properties-param>
+ <name>namespaces</name>
+ <property name="test" value="http://www.apache.org/jackrabbit/test"/>
+ <property name="exojcrtest" value="http://www.exoplatform.org/jcr/test/1.0"/>
+ <property name="rma" value="http://www.rma.com/jcr/"/>
+ <property name="metadata" value="http://www.exoplatform.com/jcr/metadata/1.1/"/>
+ </properties-param>
</init-params>
- </component-plugin>
- <component-plugin>
- <name>add.nodeType</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
- <init-params>
- <values-param>
- <name>autoCreatedInNewRepository</name>
- <description>Node types configuration file</description>
- <value>jar:/conf/test/nodetypes-tck.xml</value>
- <value>jar:/conf/test/nodetypes-impl.xml</value>
- <value>jar:/conf/test/nodetypes-usecase.xml</value>
- <value>jar:/conf/test/nodetypes-config-extended.xml</value>
- </values-param>
- <values-param>
- <name>testInitNodeTypesRepository</name>
- <description>Node types configuration file for repository with name testInitNodeTypesRepository</description>
- <value>jar:/conf/test/nodetypes-test.xml</value>
- </values-param>
- <values-param>
- <name>testInitNodeTypesRepositoryTest2</name>
- <description>Node types configuration file for repository with name testInitNodeTypesRepositoryTest2</description>
- <value>jar:/conf/test/nodetypes-test2.xml</value>
- </values-param>
- </init-params>
- </component-plugin>
+ </component-plugin>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/test/nodetypes-tck.xml</value>
+ <value>jar:/conf/test/nodetypes-impl.xml</value>
+ <value>jar:/conf/test/nodetypes-usecase.xml</value>
+ <value>jar:/conf/test/nodetypes-config.xml</value>
+ <value>jar:/conf/test/nodetypes-config-extended.xml</value>
+ </values-param>
+ <values-param>
+ <name>testInitNodeTypesRepository</name>
+ <description>Node types configuration file for repository with name testInitNodeTypesRepository</description>
+ <value>jar:/conf/test/nodetypes-test.xml</value>
+ </values-param>
+ <values-param>
+ <name>testInitNodeTypesRepositoryTest2</name>
+ <description>Node types configuration file for repository with name testInitNodeTypesRepositoryTest2</description>
+ <value>jar:/conf/test/nodetypes-test2.xml</value>
+ </values-param>
+ </init-params>
+ </component-plugin>
</component-plugins>
- </component>
+ </component>
- <component>
- <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
- <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
- <init-params>
- <value-param>
- <name>conf-path</name>
- <description>JCR configuration file</description>
- <value>jar:/conf/standalone/test-jcr-config-sjdbc.xml</value>
- </value-param>
- </init-params>
- </component>
+ <component>
+ <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
+ <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ <init-params>
+ <value-param>
+ <name>conf-path</name>
+ <description>JCR configuration file</description>
+ <value>jar:/conf/standalone/test-jcr-config-sjdbc.xml</value>
+ </value-param>
+ </init-params>
+ </component>
- <component>
- <type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
- </component>
- <component>
- <key>org.exoplatform.services.security.Authenticator</key>
- <type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
- </component>
- <component>
+ <component>
+ <type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.security.Authenticator</key>
+ <type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
+ </component>
+
+ <component>
<type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
- </component>
+ </component>
- <component>
+ <component>
<key>org.exoplatform.services.transaction.TransactionService</key>
<type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
<init-params>
- <value-param>
- <name>timeout</name>
- <value>5</value>
- </value-param>
+ <value-param>
+ <name>timeout</name>
+ <value>5</value>
+ </value-param>
</init-params>
- </component>
+ </component>
- <external-component-plugins>
- <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
<component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtest</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
<component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcrtck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portaltck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <!-- Resource configuration for UserTransaction
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portaltck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <!-- Resource configuration for UserTransaction
use JOTM
-->
<component-plugin>
- <name>jotm.tx</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>UserTransaction</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.transaction.UserTransaction</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.objectweb.jotm.UserTransactionFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="jotm.timeout" value="60" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>repo</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="repositoryName" value="db1" />
- <!-- property name="containerConfig" value="exo-configuration.xml"/ -->
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>rmi.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>rmirepository</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="url" value="//localhost:9999/repository" />
- </properties-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
+ <name>jotm.tx</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.transaction.UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.objectweb.jotm.UserTransactionFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="jotm.timeout" value="60"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>repo</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="repositoryName" value="db1"/>
+ <!-- property name="containerConfig" value="exo-configuration.xml"/ -->
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>rmi.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>rmirepository</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="url" value="//localhost:9999/repository"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
- <remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
- <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
+ <remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
+ <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
</configuration>
Modified: jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml
===================================================================
--- jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml 2009-08-28 06:34:31 UTC (rev 24)
+++ jcr/trunk/component/core/src/test/java/conf/standalone/test-configuration.xml 2009-08-28 06:54:41 UTC (rev 25)
@@ -1,497 +1,541 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
+<configuration
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+ xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+ <component>
+ <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
+ <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <init-params>
+ <value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>Log4J properties</description>
+ <property name="log4j.rootLogger" value="INFO, stdout, file"/>
+
+ <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender"/>
+ <property name="log4j.appender.stdout.threshold" value="DEBUG"/>
+
+ <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.stdout.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
+
+ <property name="log4j.appender.file" value="org.apache.log4j.FileAppender"/>
+ <property name="log4j.appender.file.File" value="target/jcr.log"/>
+
+ <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout"/>
+ <property name="log4j.appender.file.layout.ConversionPattern"
+ value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n"/>
+
+ <property name="log4j.category.jcr.FileCleaner" value="DEBUG"/>
+
+ <!-- property name="log4j.category.jcr.JDBCStorageConnection" value="DEBUG"/>
+ <property name="log4j.category.jcr.NodeImpl" value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
+ <!-- property name="log4j.category.database.DBSchemaCreator" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspaceDataReplicator" value="DEBUG"/ -->
+
+ <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.WorkspacePersistentDataManager" value="DEBUG"/ -->
+ <!-- property name="log4j.category.jcr.SessionDataManager" value="DEBUG"/ -->
+ </properties-param>
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>SimpleLog properties</description>
+ <property name="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
+ <property name="org.apache.commons.logging.simplelog.showdatetime" value="true"/>
+ </properties-param -->
+
+ <!-- value-param>
+ <name>logger</name>
+ <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
+ </value-param>
+ <value-param>
+ <name>configurator</name>
+ <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
+ </value-param>
+ <properties-param>
+ <name>properties</name>
+ <description>jdk1.4 Logger properties</description>
+ <property name="handlers" value="java.util.logging.ConsoleHandler"/>
+ <property name=".level" value="FINE"/>
+ <property name="java.util.logging.ConsoleHandler.level" value="FINE"/>
+ </properties-param -->
+
+ </init-params>
+ </component>
- 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.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
- xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
- <component>
- <key>org.exoplatform.services.log.LogConfigurationInitializer</key>
- <type>org.exoplatform.services.log.LogConfigurationInitializer</type>
+ <component>
+ <key>org.exoplatform.services.jcr.RepositoryService</key>
+ <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
+ <component-plugins>
+ <component-plugin>
+ <name>add.namespaces</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
+ <init-params>
+ <properties-param>
+ <name>namespaces</name>
+ <property name="test" value="http://www.apache.org/jackrabbit/test"/>
+ <property name="exojcrtest" value="http://www.exoplatform.org/jcr/test/1.0"/>
+ <property name="rma" value="http://www.rma.com/jcr/"/>
+ <property name="metadata" value="http://www.exoplatform.com/jcr/metadata/1.1/"/>
+ <property name="dc" value="http://purl.org/dc/elements/1.1/"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>add.nodeType</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
+ <init-params>
+ <values-param>
+ <name>autoCreatedInNewRepository</name>
+ <description>Node types configuration file</description>
+ <value>jar:/conf/test/nodetypes-tck.xml</value>
+ <value>jar:/conf/test/nodetypes-impl.xml</value>
+ <value>jar:/conf/test/nodetypes-usecase.xml</value>
+ <value>jar:/conf/test/nodetypes-config.xml</value>
+ <value>jar:/conf/test/nodetypes-config-extended.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepository</name>
+ <description>
+ Node types configuration file for repository with name testInitNodeTypesRepository
+ </description>
+ <value>jar:/conf/test/nodetypes-test.xml</value>
+ </values-param>
+
+ <values-param>
+ <name>testInitNodeTypesRepositoryTest2</name>
+ <description>
+ Node types configuration file for repository with name testInitNodeTypesRepositoryTest2
+ </description>
+ <value>jar:/conf/test/nodetypes-test2.xml</value>
+ </values-param>
+
+ <!--values-param>
+ <name>testInitNodeTypesRepositoryTest3</name>
+ <description>Node types from ext. Needed bacause core starup earlie than ext</description>
+ <value>jar:/conf/test/nodetypes-test3_ext.xml</value>
+ </values-param-->
+
+ </init-params>
+ </component-plugin>
+ </component-plugins>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
+ <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ <init-params>
+ <value-param>
+ <name>conf-path</name>
+ <description>JCR configuration file</description>
+ <value>jar:/conf/standalone/test-jcr-config.xml</value>
+ </value-param>
+ <properties-param>
+ <name>working-conf</name>
+ <description>working-conf</description>
+ <property name="source-name" value="jdbcjcr"/>
+ <property name="dialect" value="hsqldb"/>
+ <property name="persister-class-name" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister"/>
+ </properties-param>
+ </init-params>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.security.Authenticator</key>
+ <type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
+ </component>
+
+ <component>
+ <type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
+ </component>
+
+ <component>
+ <key>org.exoplatform.services.transaction.TransactionService</key>
+ <type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ <init-params>
+ <value-param>
+ <name>timeout</name>
+ <value>5</value>
+ </value-param>
+ </init-params>
+ </component>
+
+ <external-component-plugins>
+ <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedLog4JLogger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.Log4JConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>Log4J properties</description>
- <property name="log4j.rootLogger" value="INFO, stdout, file" />
-
- <property name="log4j.appender.stdout" value="org.apache.log4j.ConsoleAppender" />
- <property name="log4j.appender.stdout.threshold" value="DEBUG" />
-
- <property name="log4j.appender.stdout.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.stdout.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
-
- <property name="log4j.appender.file" value="org.apache.log4j.FileAppender" />
- <property name="log4j.appender.file.File" value="target/jcr.log" />
-
- <property name="log4j.appender.file.layout" value="org.apache.log4j.PatternLayout" />
- <property name="log4j.appender.file.layout.ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L) %n" />
-
- <property name="log4j.category.jcr.FileCleaner" value="DEBUG" />
-
- <!-- property name="log4j.category.jcr.JDBCStorageConnection" value="DEBUG" / -->
- <!-- property name="log4j.category.jcr.NodeImpl" value="DEBUG" / -->
-
- <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
- <!-- property name="log4j.category.database.DBSchemaCreator" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspaceDataReplicator" value="DEBUG"/ -->
-
- <!-- property name="log4j.category.jcr.WorkspaceStorageCacheImpl" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.WorkspacePersistentDataManager" value="DEBUG"/ -->
- <!-- property name="log4j.category.jcr.SessionDataManager" value="DEBUG"/ -->
- </properties-param>
-
- <!-- value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedSimpleLog</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.SimpleLogConfigurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>SimpleLog properties</description>
- <property name="org.apache.commons.logging.simplelog.defaultlog" value="debug" />
- <property name="org.apache.commons.logging.simplelog.showdatetime" value="true" />
- </properties-param -->
-
- <!-- value-param>
- <name>logger</name>
- <value>org.exoplatform.services.log.impl.BufferedJdk14Logger</value>
- </value-param>
- <value-param>
- <name>configurator</name>
- <value>org.exoplatform.services.log.impl.Jdk14Configurator</value>
- </value-param>
- <properties-param>
- <name>properties</name>
- <description>jdk1.4 Logger properties</description>
- <property name="handlers" value="java.util.logging.ConsoleHandler" />
- <property name=".level" value="FINE" />
- <property name="java.util.logging.ConsoleHandler.level" value="FINE" />
- </properties-param -->
-
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <component>
- <key>org.exoplatform.services.jcr.RepositoryService</key>
- <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>
- <component-plugins>
- <component-plugin>
- <name>add.namespaces</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
- <init-params>
- <properties-param>
- <name>namespaces</name>
- <property name="test" value="http://www.apache.org/jackrabbit/test" />
- <property name="exojcrtest" value="http://www.exoplatform.org/jcr/test/1.0" />
- <property name="rma" value="http://www.rma.com/jcr/" />
- <property name="metadata" value="http://www.exoplatform.com/jcr/metadata/1.1/" />
- <property name="dc" value="http://purl.org/dc/elements/1.1/" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>add.nodeType</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
- <init-params>
- <values-param>
- <name>autoCreatedInNewRepository</name>
- <description>Node types configuration file</description>
- <value>jar:/conf/test/nodetypes-tck.xml</value>
- <value>jar:/conf/test/nodetypes-impl.xml</value>
- <value>jar:/conf/test/nodetypes-usecase.xml</value>
- <value>jar:/conf/test/nodetypes-config.xml</value>
- <value>jar:/conf/test/nodetypes-config-extended.xml</value>
- </values-param>
-
- <values-param>
- <name>testInitNodeTypesRepository</name>
- <description>Node types configuration file for repository with name testInitNodeTypesRepository</description>
- <value>jar:/conf/test/nodetypes-test.xml</value>
- </values-param>
-
- <values-param>
- <name>testInitNodeTypesRepositoryTest2</name>
- <description>Node types configuration file for repository with name testInitNodeTypesRepositoryTest2</description>
- <value>jar:/conf/test/nodetypes-test2.xml</value>
- </values-param>
-
- <!-- values-param>
- <name>testInitNodeTypesRepositoryTest3</name>
- <description>Node types from ext. Needed bacause core starup earlie than ext</description>
- <value>jar:/conf/test/nodetypes-test3_ext.xml</value>
- </values-param -->
-
- </init-params>
- </component-plugin>
- </component-plugins>
- </component>
-
- <component>
- <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
- <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>conf-path</name>
- <description>JCR configuration file</description>
- <value>jar:/conf/standalone/test-jcr-config.xml</value>
- </value-param>
- <properties-param>
- <name>working-conf</name>
- <description>working-conf</description>
- <property name="source-name" value="jdbcjcr" />
- <property name="dialect" value="hsqldb" />
- <property name="persister-class-name" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister" />
- </properties-param>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <component>
- <type>org.exoplatform.services.organization.impl.mock.DummyOrganizationService</type>
- </component>
-
- <component>
- <key>org.exoplatform.services.security.Authenticator</key>
- <type>org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl</type>
- </component>
-
- <component>
- <type>org.exoplatform.services.jcr.impl.ext.action.SessionActionCatalog</type>
- </component>
-
- <component>
- <key>org.exoplatform.services.transaction.TransactionService</key>
- <type>org.exoplatform.services.transaction.impl.jotm.TransactionServiceJotmImpl</type>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
<init-params>
- <value-param>
- <name>timeout</name>
- <value>5</value>
- </value-param>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr2"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
</init-params>
- </component>
-
- <external-component-plugins>
- <target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portal" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr1</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcrtck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/portaltck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr1tck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcrtck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2tck</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr2tck" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2export1</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export1" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.datasource</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>jdbcjcr2export2</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.sql.DataSource</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
- <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export2" />
- <property name="username" value="sa" />
- <property name="password" value="" />
- </properties-param>
- </init-params>
- </component-plugin>
- <!-- Resource configuration for UserTransaction use JOTM -->
- <component-plugin>
- <name>jotm.tx</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>UserTransaction</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.transaction.UserTransaction</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.objectweb.jotm.UserTransactionFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="jotm.timeout" value="60" />
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>bind.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>repo</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="repositoryName" value="db1" />
- <!-- property name="containerConfig" value="exo-configuration.xml"/ -->
- </properties-param>
- </init-params>
- </component-plugin>
- <component-plugin>
- <name>rmi.jcr</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.naming.BindReferencePlugin</type>
- <init-params>
- <value-param>
- <name>bind-name</name>
- <value>rmirepository</value>
- </value-param>
- <value-param>
- <name>class-name</name>
- <value>javax.jcr.Repository</value>
- </value-param>
- <value-param>
- <name>factory</name>
- <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
- </value-param>
- <properties-param>
- <name>ref-addresses</name>
- <description>ref-addresses</description>
- <property name="url" value="//localhost:9999/repository" />
- </properties-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-
- <remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
- <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr3</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr3"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtest</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcrtest"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcrtck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/portaltck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr1tck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcrtck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2tck</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jcr2tck"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export1</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export1"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcjcr2export2</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+ <property name="url" value="jdbc:hsqldb:file:target/temp/data/jdbcjcr2export2"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <!-- Resource configuration for UserTransaction
+ use JOTM
+ -->
+ <component-plugin>
+ <name>jotm.tx</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.transaction.UserTransaction</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.objectweb.jotm.UserTransactionFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="jotm.timeout" value="60"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>bind.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>repo</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.impl.jndi.BindableRepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="repositoryName" value="db1"/>
+ <!-- property name="containerConfig" value="exo-configuration.xml"/ -->
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ <component-plugin>
+ <name>rmi.jcr</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>rmirepository</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.jcr.Repository</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.exoplatform.services.jcr.rmi.RepositoryFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="url" value="//localhost:9999/repository"/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
+
+ <remove-configuration>org.exoplatform.services.scheduler.JobSchedulerService</remove-configuration>
+ <!--<import>jar:/conf/database-configuration.hsql.xml</import> -->
</configuration>
Added: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java (rev 0)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -0,0 +1,270 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc;
+
+import java.io.ByteArrayInputStream;
+import java.sql.*;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import org.exoplatform.services.jcr.JcrAPIBaseTest;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.init.DBInitializer;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+abstract public class JDBCConnectionTestBase extends JcrAPIBaseTest {
+
+ protected JDBCStorageConnection jdbcConn = null;
+ protected String tableType = null;
+ private Connection connect = null;
+
+ public void setUp(String scriptPath, boolean multiDB) throws Exception {
+
+ super.setUp();
+ new DBInitializer("ws3", getJNDIConnection(), scriptPath, multiDB)
+ .init();
+ }
+
+ protected void tearDown() throws Exception {
+
+ connect.close();
+ super.tearDown();
+ }
+
+ public Connection getJNDIConnection() throws Exception {
+
+ DataSource ds = (DataSource) new InitialContext().lookup("jdbcjcrtest");
+ connect = ds.getConnection();
+ return connect;
+ }
+
+ private NodeData setNode() throws Exception {
+ InternalQName[] iqn = { InternalQName.parse("[]DbJDBCConnectionTest") };
+ TransientNodeData tnd = new TransientNodeData(
+ Constants.JCR_NODETYPES_PATH, "Z", 9, Constants.SV_NODE_NAME,
+ iqn, 8, null, null);
+ return tnd;
+ }
+
+ private NodeData giveNodeForRename() throws Exception {
+
+ InternalQName[] iqn = { InternalQName.parse("[]DbJDBCConnectionTest") };
+ TransientNodeData tnd = new TransientNodeData(
+ Constants.JCR_NODETYPES_PATH, "B", 9, Constants.SV_NODE_NAME,
+ iqn, 8, null, null);
+ return tnd;
+ }
+
+ public void testAddNode() throws Exception {
+
+ jdbcConn.add(setNode());
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where N_ORDER_NUM=8");
+ rs.next();
+ assertEquals("[http://www.jcp.org/jcr/1.0]nodetypes", rs
+ .getString("NAME"));
+ }
+
+ public void testAddValueData() throws Exception {
+
+ byte data[] = { 5 };
+ ByteArrayInputStream bas = new ByteArrayInputStream(data);
+ jdbcConn.addValueData("C", 2, bas, 2, "J");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='C'");
+ rs.next();
+ assertEquals("05", rs.getString("DATA"));
+ }
+
+ public void testRenameNode() throws Exception {
+
+ jdbcConn.renameNode(giveNodeForRename());
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where N_ORDER_NUM=8");
+ rs.next();
+ assertEquals("[http://www.jcp.org/jcr/1.0]nodetypes", rs
+ .getString("NAME"));
+ }
+
+ public void testUpdateNodeByIdentifier() throws Exception {
+
+ jdbcConn.updateNodeByIdentifier(200923, 4512, 20, "B");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='B'");
+ rs.next();
+ assertEquals(20, rs.getInt("N_ORDER_NUM"));
+ }
+
+ public void testUpdatePropertyByIdentifier() throws Exception {
+
+ jdbcConn.updatePropertyByIdentifier(200923, 4512, "C");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='C'");
+ rs.next();
+ assertEquals(4512, rs.getInt("P_TYPE"));
+ }
+
+ public void testDeleteReference() throws Exception {
+
+ jdbcConn.deleteReference("A");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "REF"
+ + " where PROPERTY_ID='A'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testDeleteItemByIdentifier() throws Exception {
+
+ jdbcConn.deleteItemByIdentifier("C");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='C'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testDeleteValueData() throws Exception {
+
+ jdbcConn.deleteValueData("A");
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='A'");
+ assertEquals(false, rs.next());
+ }
+
+ public void testFindItemByIdentifier() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findItemByIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where ID='A'");
+ rs.next();
+ assertEquals(rsRemote.getString("PARENT_ID"), rs.getString("PARENT_ID"));
+ }
+
+ public void testFindPropertyByName() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findPropertyByName("A", "test1");
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select V.DATA from JCR_"
+ + tableType
+ + "ITEM I, JCR_"
+ + tableType
+ + "VALUE V "
+ + "where I.I_CLASS=2 and I.PARENT_ID='A' and I.NAME='test1' and I.ID=V.PROPERTY_ID order by V.ORDER_NUM");
+ rs.next();
+ assertEquals(rsRemote.getString("DATA"), rs.getString("DATA"));
+ }
+
+ public void testFindItemByName() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findItemByName("A", "test1", 1233);
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select * from JCR_"
+ + tableType
+ + "ITEM"
+ + " where PARENT_ID='A' and NAME='test1' and I_INDEX=1233 order by I_CLASS, VERSION DESC");
+ rs.next();
+ assertEquals(rsRemote.getString("ID"), rs.getString("ID"));
+ }
+
+ public void testFindChildNodesByParentIdentifier() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findChildNodesByParentIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from " + "JCR_" + tableType + "ITEM"
+ + " where I_CLASS=1 and PARENT_ID='A'");
+ rs.next();
+ assertEquals(rsRemote.getString("NAME"), rs.getString("NAME"));
+ }
+
+ public void testFindChildPropertiesByParentIdentifier() throws Exception {
+ ResultSet rsRemote = jdbcConn
+ .findChildPropertiesByParentIdentifier("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select * from JCR_" + tableType + "ITEM"
+ + " where I_CLASS=2 and PARENT_ID='A' order by ID");
+ rs.next();
+ assertEquals(rsRemote.getString("NAME"), rs.getString("NAME"));
+ }
+
+ public void testFindReferences() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findReferences("D");
+ rsRemote.next();
+ ResultSet rs = connect
+ .createStatement()
+ .executeQuery(
+ "select P.ID, P.PARENT_ID, P.VERSION, P.P_TYPE, P.P_MULTIVALUED, P.NAME"
+ + " from JCR_"
+ + tableType
+ + "REF R, JCR_"
+ + tableType
+ + "ITEM P"
+ + " where R.NODE_ID='D' and P.ID=R.PROPERTY_ID and P.I_CLASS=2");
+ rs.next();
+ assertEquals(rsRemote.getString("ID"), rs.getString("ID"));
+ }
+
+ public void testFindValuesByPropertyId() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findValuesByPropertyId("A");
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select PROPERTY_ID, ORDER_NUM, STORAGE_DESC from " + "JCR_"
+ + tableType + "VALUE"
+ + " where PROPERTY_ID='A' order by ORDER_NUM");
+ rs.next();
+ assertEquals(rsRemote.getString("STORAGE_DESC"), rs
+ .getString("STORAGE_DESC"));
+ }
+
+ public void testFindValueByPropertyIdOrderNumber() throws Exception {
+
+ ResultSet rsRemote = jdbcConn.findValueByPropertyIdOrderNumber("A", 16);
+ rsRemote.next();
+ ResultSet rs = connect.createStatement().executeQuery(
+ "select DATA from " + "JCR_" + tableType + "VALUE"
+ + " where PROPERTY_ID='A' and ORDER_NUM=16");
+ rs.next();
+ assertEquals(rsRemote.getString("DATA"), rs.getString("DATA"));
+ }
+}
Property changes on: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCConnectionTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java (rev 0)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import java.sql.*;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class TestMultiDbJDBCConnection extends JDBCConnectionTestBase {
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.BaseStandaloneTest#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp("/conf/storage/jcr-mjdbc.sql",true);
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('A','A','test1',20090525,2,1233,5,10,1)");
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('B','A','test2',20090625,1,1233,5,10,1)");
+ st.executeUpdate("insert into JCR_MITEM values"
+ + "('C','B','test3',20090825,1,1233,5,10,1)");
+ st
+ .executeUpdate("insert into JCR_MVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC) values"
+ + "('0xfa',16,'A','testConn')");
+ st
+ .executeUpdate("insert into JCR_MVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC) values"
+ + "('0xce',16,'B','testConn2')");
+ st.executeUpdate("insert into JCR_MREF values" + "('D','A',2)");
+ st.executeUpdate("insert into JCR_MREF values" + "('E','B',2)");
+ jdbcConn = new MultiDbJDBCConnection(getJNDIConnection(), false, "ws3", null, 10, null,
+ null);
+ tableType = "M";
+ st.close();
+ } catch (SQLException se) {
+
+ fail(se.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("drop table JCR_MREF");
+ st.executeUpdate("drop table JCR_MVALUE");
+ st.executeUpdate("drop table JCR_MITEM");
+ st.close();
+
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ super.tearDown();
+ }
+}
\ No newline at end of file
Property changes on: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestMultiDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
===================================================================
--- jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java (rev 0)
+++ jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java 2009-08-28 06:54:41 UTC (rev 25)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2003-2007 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.jcr.impl.storage.jdbc.db;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase;
+
+/**
+ * Created by The eXo Platform SAS
+ *
+ * 01.07.2009
+ *
+ * @author <a href="mailto:dezder@bk.ru">Denis Grebenyuk</a>
+ * @version $Id:$
+ */
+public class TestSingleDbJDBCConnection extends JDBCConnectionTestBase {
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.BaseStandaloneTest#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ super.setUp("/conf/storage/jcr-sjdbc.sql",false);
+ try {
+
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("insert into JCR_SITEM values"
+ + "('A','A','test1',20090525,'ws3',2,1233,1,10,5)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ + "('B','A','test2',20090625,'ws3',1,1233,5,10,4)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ + "('C','B','test3',20090825,'ws3',1,1233,5,10,2)");
+ st.executeUpdate("insert into JCR_SITEM values"
+ + "('ws3B','A','test4',2009525,'ws3',2,1233,1,10,5)");
+ st
+ .executeUpdate("insert into JCR_SVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC) values"
+ + "('0xfa',16,'A','testConn')");
+ st
+ .executeUpdate("insert into JCR_SVALUE(DATA,ORDER_NUM,PROPERTY_ID,STORAGE_DESC) values"
+ + "('0xce',16,'B','testConn2')");
+ st.executeUpdate("insert into JCR_SREF values" + "('D','A',2)");
+ st.executeUpdate("insert into JCR_SREF values" + "('E','B',2)");
+ st.close();
+ jdbcConn = new SingleDbJDBCConnection(getJNDIConnection(), false, "ws3", null,
+ 10, null, null);
+ tableType = "S";
+
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.exoplatform.services.jcr.impl.storage.jdbc.JDBCConnectionTestBase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+
+ try {
+ Statement st = getJNDIConnection().createStatement();
+ st.executeUpdate("drop table JCR_SREF");
+ st.executeUpdate("drop table JCR_SVALUE");
+ st.executeUpdate("drop table JCR_SITEM");
+ st.close();
+ } catch (SQLException se) {
+ fail(se.toString());
+ }
+ super.tearDown();
+ }
+}
\ No newline at end of file
Property changes on: jcr/trunk/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/db/TestSingleDbJDBCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 8 months