exo-jcr SVN: r3197 - kernel/branches.
by do-not-reply@jboss.org
Author: aheritier
Date: 2010-09-28 05:50:24 -0400 (Tue, 28 Sep 2010)
New Revision: 3197
Added:
kernel/branches/2.2.4-GA-perf/
Log:
[TESTFR-3] Create perf branch
Copied: kernel/branches/2.2.4-GA-perf (from rev 3196, kernel/tags/2.2.4-GA)
13 years, 7 months
exo-jcr SVN: r3196 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 2 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2010-09-28 05:21:26 -0400 (Tue, 28 Sep 2010)
New Revision: 3196
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-952 : committing changes related to EXOJCR-609 into the trunk (from former branches/1.14.x)
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2010 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.datamodel;
+
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.dataflow.ItemDataVisitor;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * This class is used to represent <code>null</code> value, it is designed to be used
+ * into the cache to represent missing value.
+ *
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
+ * @version $Id: NullNodeData.java 111 2010-11-11 11:11:11Z tolusha $
+ */
+public class NullNodeData implements NodeData
+{
+
+ private final String id;
+
+ private final String parentId;
+
+ private final QPath path;
+
+ public NullNodeData(NodeData parentData, QPathEntry name)
+ {
+ this.parentId = parentData.getIdentifier();
+ this.path = QPath.makeChildPath(parentData.getQPath(), name);
+ this.id = parentId + "$" + name.asString();
+ }
+
+ public NullNodeData(String id)
+ {
+ this.parentId = null;
+ this.path = new QPath(new QPathEntry[]{new QPathEntry(null, null, 0)});
+ this.id = id;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public AccessControlList getACL()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public InternalQName[] getMixinTypeNames()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getOrderNumber()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public InternalQName getPrimaryTypeName()
+ {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void accept(ItemDataVisitor visitor) throws RepositoryException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getIdentifier()
+ {
+ return id;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getParentIdentifier()
+ {
+ return parentId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPersistedVersion()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public QPath getQPath()
+ {
+ return path;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isNode()
+ {
+ return true;
+ }
+
+}
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-09-28 09:01:44 UTC (rev 3195)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
@@ -426,7 +427,7 @@
fixPropertyValues((PropertyData)data);
}
- return data;
+ return data instanceof NullNodeData ? null : data;
}
/**
@@ -435,10 +436,10 @@
@Override
public ItemData getItemData(String identifier) throws RepositoryException
{
- // 2. Try from cache
+ // 1. Try from cache
ItemData data = getCachedItemData(identifier);
- // 3. Try from container
+ // 2 Try from container
if (data == null)
{
final DataRequest request = new DataRequest(identifier);
@@ -468,7 +469,7 @@
fixPropertyValues((PropertyData)data);
}
- return data;
+ return data instanceof NullNodeData ? null : data;
}
/**
@@ -677,9 +678,9 @@
throws RepositoryException
{
ItemData data = super.getItemData(parentData, name, itemType);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ cache.put(data == null ? new NullNodeData(parentData, name) : data);
}
return data;
}
@@ -694,9 +695,16 @@
protected ItemData getPersistedItemData(String identifier) throws RepositoryException
{
ItemData data = super.getItemData(identifier);
- if (data != null && cache.isEnabled())
+ if (cache.isEnabled())
{
- cache.put(data);
+ if (data != null)
+ {
+ cache.put(data);
+ }
+ else if (identifier != null)
+ {
+ cache.put(new NullNodeData(identifier));
+ }
}
return data;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-09-28 09:01:44 UTC (rev 3195)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -257,7 +258,9 @@
return true;
}
else
+ {
return false;
+ }
}
}
@@ -455,7 +458,9 @@
{
ItemData item = ce.getValue().getItem();
if (item != null)
+ {
removeExpiredChilds(item);
+ }
citer.remove();
expiredCount++;
@@ -463,8 +468,10 @@
}
if (log.isDebugEnabled())
+ {
log.debug("Cleaner task done in " + (System.currentTimeMillis() - start) + "ms. Size " + sizeBefore
+ " -> " + cache.size() + ", " + expiredCount + " processed.");
+ }
}
catch (ConcurrentModificationException e)
{
@@ -483,9 +490,13 @@
catch (Throwable e)
{
if (log.isDebugEnabled())
+ {
log.error("Cleaner task error " + e, e);
+ }
else
+ {
log.error("Cleaner task error " + e + ". Will try next time.");
+ }
}
finally
{
@@ -494,8 +505,10 @@
}
else // skip if lock is used by another process
if (log.isDebugEnabled())
+ {
log.debug("Cleaner task skipped. Ceche in use by another process ["
+ String.valueOf(writeLock.getLockOwner()) + "]. Will try next time.");
+ }
}
/**
@@ -511,7 +524,9 @@
if (propertiesCache.remove(item.getIdentifier()) != null)
{
if (log.isDebugEnabled())
+ {
log.debug(name + ", removeExpiredChilds() propertiesCache.remove " + item.getIdentifier());
+ }
}
}
else
@@ -520,7 +535,9 @@
if (propertiesCache.remove(item.getParentIdentifier()) != null)
{
if (log.isDebugEnabled())
+ {
log.debug(name + ", removeExpiredChilds() propertiesCache.remove " + item.getParentIdentifier());
+ }
}
}
}
@@ -575,7 +592,9 @@
}
else // skip if previous in progress
if (log.isDebugEnabled())
+ {
log.debug("Cleaner task skipped. Previous one still runs. Will try next time.");
+ }
}
}
@@ -595,7 +614,9 @@
}
else // skip if previous in progress
if (log.isDebugEnabled())
+ {
log.debug("Statistic task skipped. Previous one still runs. Will try next time.");
+ }
}
}
@@ -807,6 +828,7 @@
totalGetTime);
if (showStatistic)
+ {
try
{
double rel =
@@ -829,6 +851,7 @@
{
LOG.warn("Show statistic log.info error " + e);
}
+ }
this.statistic = st;
@@ -938,12 +961,20 @@
if (enabled && item != null)
{
+ if (item instanceof NullNodeData)
+ {
+ // skip null values
+ return;
+ }
+
writeLock.lock();
try
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() " + item.getQPath().getAsString() + " " + item.getIdentifier()
+ " -- " + item);
+ }
putItem(item);
@@ -971,17 +1002,23 @@
for (int ci = 0; ci < cachedParentChilds.size(); ci++)
{
if (index == ci)
+ {
newChilds.add(nodeData); // place in new position
+ }
else
+ {
newChilds.add(cachedParentChilds.get(ci)); // copy
+ }
}
nodesCache.put(item.getParentIdentifier(), newChilds); // cache
// new
// list
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() update child node " + nodeData.getIdentifier()
+ " order #" + orderNumber);
+ }
}
else
{
@@ -989,8 +1026,10 @@
cachedParentChilds.set(index, nodeData); // replace at
// current position
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() update child node " + nodeData.getIdentifier()
+ " at index #" + index);
+ }
}
}
@@ -1000,13 +1039,17 @@
// add new to the end
List<NodeData> newChilds = new ArrayList<NodeData>(cachedParentChilds.size() + 1);
for (int ci = 0; ci < cachedParentChilds.size(); ci++)
+ {
newChilds.add(cachedParentChilds.get(ci));
+ }
newChilds.add(nodeData); // add
nodesCache.put(item.getParentIdentifier(), newChilds); // cache new list
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() add child node " + nodeData.getIdentifier());
+ }
}
}
}
@@ -1028,8 +1071,10 @@
// update already cached in list
cachedParentChilds.set(index, (PropertyData)item); // replace at current position
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() update child property " + item.getIdentifier()
+ " at index #" + index);
+ }
}
else if (index == -1)
@@ -1037,18 +1082,24 @@
// add new
List<PropertyData> newChilds = new ArrayList<PropertyData>(cachedParentChilds.size() + 1);
for (int ci = 0; ci < cachedParentChilds.size(); ci++)
+ {
newChilds.add(cachedParentChilds.get(ci));
+ }
newChilds.add((PropertyData)item);
propertiesCache.put(item.getParentIdentifier(), newChilds); // cache new list
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", put() add child property " + item.getIdentifier());
+ }
}
}
}
else
+ {
// if it's a props list with empty values, remove cached list
propertiesCache.remove(item.getParentIdentifier());
+ }
}
}
}
@@ -1071,7 +1122,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1104,8 +1155,10 @@
for (ItemData p : childItems)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", addChildProperties() " + p.getQPath().getAsString() + " "
+ p.getIdentifier() + " -- " + p);
+ }
putItem(p);
}
@@ -1122,7 +1175,9 @@
}
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", addChildProperties() <<< " + logInfo);
+ }
}
}
@@ -1133,7 +1188,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1173,7 +1228,9 @@
}
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", addChildPropertiesList() <<< " + logInfo);
+ }
}
}
@@ -1184,7 +1241,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1218,8 +1275,10 @@
for (ItemData n : childItems)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", addChildNodes() " + n.getQPath().getAsString() + " " + n.getIdentifier()
+ " -- " + n);
+ }
putItem(n);
}
@@ -1236,7 +1295,9 @@
}
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", addChildNodes() <<< " + logInfo);
+ }
}
}
@@ -1255,7 +1316,9 @@
if (enabled && item != null)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", remove() " + item.getQPath().getAsString() + " " + item.getIdentifier());
+ }
writeLock.lock();
try
@@ -1274,7 +1337,9 @@
removeChildNode(item.getParentIdentifier(), itemId);
}
else
+ {
removeChildProperty(item.getParentIdentifier(), itemId);
+ }
}
catch (Exception e)
{
@@ -1308,8 +1373,10 @@
{
// check if wasn't removed
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", getItem() " + identifier + " --> "
+ (c != null ? c.getQPath().getAsString() + " parent:" + c.getParentIdentifier() : "[null]"));
+ }
hits++;
return c;
@@ -1366,8 +1433,10 @@
if (v.getExpiredTime() > System.currentTimeMillis())
{
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", getItem() " + (c != null ? c.getQPath().getAsString() : "[null]") + " --> "
+ (c != null ? c.getIdentifier() + " parent:" + c.getParentIdentifier() : "[null]"));
+ }
hits++;
return c;
@@ -1438,9 +1507,13 @@
}
if (cn != null)
+ {
hits++;
+ }
else
+ {
miss++;
+ }
return cn;
}
catch (Exception e)
@@ -1491,9 +1564,13 @@
}
if (cn != null)
+ {
hits++;
+ }
else
+ {
miss++;
+ }
return cn != null ? cn.size() : -1;
}
catch (Exception e)
@@ -1550,7 +1627,9 @@
return cp;
}
else
+ {
miss++;
+ }
}
catch (Exception e)
{
@@ -1599,9 +1678,13 @@
}
if (cp != null)
+ {
hits++;
+ }
else
+ {
miss++;
+ }
return cp;
}
catch (Exception e)
@@ -1662,7 +1745,8 @@
{
writeLock.unlock();
}
- LOG.info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
+ LOG
+ .info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
}
/**
@@ -1679,8 +1763,10 @@
final CacheValue v2 =
cache.remove(new CacheQPath(item.getParentIdentifier(), item.getQPath(), ItemType.getItemType(item)));
if (v2 != null && !v2.getItem().getIdentifier().equals(itemId))
+ {
// same path but diff identifier node... phantom
removeItem(v2.getItem());
+ }
}
/**
@@ -1691,7 +1777,9 @@
protected void removeSiblings(final NodeData node)
{
if (node.getIdentifier().equals(Constants.ROOT_UUID))
+ {
return;
+ }
// remove child nodes of the item parent recursive
writeLock.lock();
@@ -1724,11 +1812,15 @@
}
}
else
+ {
citer.remove(); // remove empty C record
+ }
}
for (CacheId id : toRemove)
+ {
cache.remove(id);
+ }
toRemove.clear();
@@ -1748,7 +1840,9 @@
{
if (!enabled)
+ {
return;
+ }
ItemState prevState = null;
for (Iterator<ItemState> iter = changesLog.getAllStates().iterator(); iter.hasNext();)
@@ -1756,8 +1850,10 @@
ItemState state = iter.next();
ItemData item = state.getData();
if (LOG.isDebugEnabled())
+ {
LOG.debug(name + ", onSaveItems() " + ItemState.nameFromValue(state.getState()) + " "
+ item.getQPath().getAsString() + " " + item.getIdentifier() + " parent:" + item.getParentIdentifier());
+ }
try
{
@@ -1789,7 +1885,9 @@
// 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))
@@ -1885,7 +1983,9 @@
{
i.remove();
if (childProperties.size() <= 0)
+ {
propertiesCache.remove(parentIdentifier);
+ }
return cn;
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-09-28 09:01:44 UTC (rev 3195)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/BufferedJBossCache.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -163,6 +163,14 @@
this.local.set(local);
}
+ /**
+ * Returns current state.
+ */
+ public boolean isLocal()
+ {
+ return this.local.get();
+ }
+
public int getNumberOfNodes()
{
return ((CacheSPI<Serializable, Object>)parentCache).getNumberOfNodes();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-28 09:01:44 UTC (rev 3195)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -1,1250 +1,1343 @@
-/*
- * 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.dataflow.persistent.jbosscache;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.dataflow.ItemState;
-import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
-import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
-import org.exoplatform.services.jcr.datamodel.IllegalPathException;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.ItemType;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory;
-import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory.CacheType;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.exoplatform.services.transaction.TransactionService;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-import javax.transaction.TransactionManager;
-
-/**
- * Created by The eXo Platform SAS.<p/>
- *
- * Cache based on JBossCache.<p/>
- *
- * <ul>
- * <li>cache transparent: or item cached or not, we should not generate "not found" Exceptions </li>
- * <li>cache consists of next resident nodes:
- * <ul>
- * <li>/$ITEMS - stores items by Id (i.e. /$ITEMS/itemId)</li>
- * <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName.$ITEM_ID)</li>
- * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
- * (i.e. /$CHILD_NODES_LIST/parentId.lists = serialized Set<Object>)</li>
- * </ul>
- * </li>
- * <li>all child properties/nodes lists should be evicted from parent at same time
- * i.e. for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST we need customized eviction policy (EvictionActionPolicy) to evict
- * whole list on one of childs eviction
- * </li>
- * </ul>
- *
- * <p/>
- * Current state notes (subject of change):
- * <ul>
- * <li>cache implements WorkspaceStorageCache, without any stuff about references and locks</li>
- * <li>transaction style implemented via JBC barches, do with JTA (i.e. via exo's TransactionService + JBoss TM)</li>
- * <li>we need customized eviction policy (EvictionActionPolicy) for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST</li>
- * </ul>
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
- * @version $Id: JBossCacheWorkspaceStorageCache.java 13869 2008-05-05 08:40:10Z pnedonosko $
- */
-public class JBossCacheWorkspaceStorageCache implements WorkspaceStorageCache
-{
-
- private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JBossCacheWorkspaceStorageCache");
-
- public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
-
- public static final String JBOSSCACHE_EXPIRATION = "jbosscache-expiration-time";
-
- /**
- * Indicate whether the JBoss Cache instance used can be shared with other caches
- */
- public static final String JBOSSCACHE_SHAREABLE = "jbosscache-shareable";
-
- public static final Boolean JBOSSCACHE_SHAREABLE_DEFAULT = Boolean.FALSE;
-
- public static final long JBOSSCACHE_EXPIRATION_DEFAULT = 900000; // 15 minutes
-
- public static final String ITEMS = "$ITEMS".intern();
-
- public static final String CHILD_NODES = "$CHILD_NODES".intern();
-
- public static final String CHILD_PROPS = "$CHILD_PROPS".intern();
-
- public static final String CHILD_NODES_LIST = "$CHILD_NODES_LIST".intern();
-
- public static final String CHILD_PROPS_LIST = "$CHILD_PROPS_LIST".intern();
-
- public static final String LOCKS = "$LOCKS".intern();
-
- public static final String ITEM_DATA = "$data".intern();
-
- public static final String ITEM_ID = "$id".intern();
-
- public static final String ITEM_LIST = "$lists".intern();
-
- protected final BufferedJBossCache cache;
-
- protected final Fqn<String> itemsRoot;
-
- protected final Fqn<String> childNodes;
-
- protected final Fqn<String> childProps;
-
- protected final Fqn<String> childNodesList;
-
- protected final Fqn<String> childPropsList;
-
- protected final Fqn<String> rootFqn;
-
- /**
- * Node order comparator for getChildNodes().
- */
- class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
- {
-
- /**
- * {@inheritDoc}
- */
- public int compare(NodeData n1, NodeData n2)
- {
- return n1.getOrderNumber() - n2.getOrderNumber();
- }
- }
-
- class ChildItemsIterator<T extends ItemData> implements Iterator<T>
- {
-
- final Iterator<Object> childs;
-
- final String parentId;
-
- final Fqn<String> root;
-
- T next;
-
- ChildItemsIterator(Fqn<String> root, String parentId)
- {
- this.parentId = parentId;
- this.root = root;
-
- Fqn<String> parentFqn = makeChildListFqn(root, parentId);
- Node<Serializable, Object> parent = cache.getNode(parentFqn);
- if (parent != null)
- {
- this.childs = cache.getChildrenNames(parentFqn).iterator();
- fetchNext();
- }
- else
- {
- this.childs = null;
- this.next = null;
- }
- }
-
- protected void fetchNext()
- {
- if (childs.hasNext())
- {
- // traverse to the first existing or the end of childs
- T n = null;
- do
- {
- String itemId = (String)cache.get(makeChildFqn(root, parentId, (String)childs.next()), ITEM_ID);
- if (itemId != null)
- {
- n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
- }
- }
- while (n == null && childs.hasNext());
- next = n;
- }
- else
- {
- next = null;
- }
- }
-
- public boolean hasNext()
- {
- return next != null;
- }
-
- public T next()
- {
- if (next == null)
- {
- throw new NoSuchElementException();
- }
-
- final T current = next;
- fetchNext();
- return current;
- }
-
- public void remove()
- {
- throw new IllegalArgumentException("Not implemented");
- }
- }
-
- class ChildNodesIterator<N extends NodeData> extends ChildItemsIterator<N>
- {
- ChildNodesIterator(String parentId)
- {
- super(childNodes, parentId);
- }
-
- @Override
- public N next()
- {
- return super.next();
- }
- }
-
- class ChildPropertiesIterator<P extends PropertyData> extends ChildItemsIterator<P>
- {
-
- ChildPropertiesIterator(String parentId)
- {
- super(childProps, parentId);
- }
-
- @Override
- public P next()
- {
- return super.next();
- }
- }
-
- /**
- * Cache constructor with eXo TransactionService support.
- *
- * @param wsConfig WorkspaceEntry workspace config
- * @param transactionService TransactionService external transaction service
- * @throws RepositoryException if error of initialization
- * @throws RepositoryConfigurationException if error of configuration
- */
- public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, TransactionService transactionService,
- ConfigurationManager cfm) throws RepositoryException, RepositoryConfigurationException
- {
- if (wsConfig.getCache() == null)
- {
- throw new RepositoryConfigurationException("Cache configuration not found");
- }
-
- // create cache using custom factory
- ExoJBossCacheFactory<Serializable, Object> factory;
-
- if (transactionService != null)
- {
- factory = new ExoJBossCacheFactory<Serializable, Object>(cfm, transactionService.getTransactionManager());
- }
- else
- {
- factory = new ExoJBossCacheFactory<Serializable, Object>(cfm);
- }
-
- // create parent JBossCache instance
- Cache<Serializable, Object> parentCache = factory.createCache(wsConfig.getCache());
- // get all eviction configurations
- List<EvictionRegionConfig> evictionConfigurations =
- parentCache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs();
- // append and default eviction configuration, since it is not present in region configurations
- evictionConfigurations.add(parentCache.getConfiguration().getEvictionConfig().getDefaultEvictionRegionConfig());
-
- boolean useExpiration = false;
- // looking over all eviction configurations till the end or till some expiration algorithm subclass not found.
- for (EvictionRegionConfig evictionRegionConfig : evictionConfigurations)
- {
- if (evictionRegionConfig.getEvictionAlgorithmConfig() instanceof ExpirationAlgorithmConfig)
- {
- // force set expiration key to default value in all Expiration configurations (if any)
- ((ExpirationAlgorithmConfig)evictionRegionConfig.getEvictionAlgorithmConfig())
- .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
- useExpiration = true;
- }
- }
-
- if (useExpiration)
- {
- LOG.info("Using BufferedJBossCache compatible with Expiration algorithm.");
- }
-
- this.rootFqn = Fqn.fromElements(wsConfig.getUniqueName());
- parentCache =
- ExoJBossCacheFactory.getUniqueInstance(CacheType.JCR_CACHE, rootFqn, parentCache, wsConfig.getCache()
- .getParameterBoolean(JBOSSCACHE_SHAREABLE, JBOSSCACHE_SHAREABLE_DEFAULT).booleanValue());
-
- // if expiration is used, set appropriate factory with with timeout set via configuration (or default one 15minutes)
- this.cache =
- new BufferedJBossCache(parentCache, useExpiration, wsConfig.getCache().getParameterTime(JBOSSCACHE_EXPIRATION,
- JBOSSCACHE_EXPIRATION_DEFAULT));
-
- this.itemsRoot = Fqn.fromRelativeElements(rootFqn, ITEMS);
- this.childNodes = Fqn.fromRelativeElements(rootFqn, CHILD_NODES);
- this.childProps = Fqn.fromRelativeElements(rootFqn, CHILD_PROPS);
- this.childNodesList = Fqn.fromRelativeElements(rootFqn, CHILD_NODES_LIST);
- this.childPropsList = Fqn.fromRelativeElements(rootFqn, CHILD_PROPS_LIST);
-
- this.cache.create();
- this.cache.start();
-
- createResidentNode(childNodes);
- createResidentNode(childNodesList);
- createResidentNode(childProps);
- createResidentNode(childPropsList);
- createResidentNode(itemsRoot);
- }
-
- /**
- * Cache constructor with JBossCache JTA transaction support.
- *
- * @param wsConfig WorkspaceEntry workspace config
- * @throws RepositoryException if error of initialization
- * @throws RepositoryConfigurationException if error of configuration
- */
- public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager cfm)
- throws RepositoryException, RepositoryConfigurationException
- {
- this(wsConfig, null, cfm);
- }
-
- /**
- * Checks if node with give FQN not exists and creates resident node.
- * @param fqn
- */
- protected void createResidentNode(Fqn fqn)
- {
- Node<Serializable, Object> cacheRoot = cache.getRoot();
- if (!cacheRoot.hasChild(fqn))
- {
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cacheRoot.addChild(fqn).setResident(true);
- }
- else
- {
- cache.getNode(fqn).setResident(true);
- }
-
- }
-
- protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
- {
- if (wsConfig.getCache() != null)
- {
- return wsConfig.getCache().getParameterValue(JBOSSCACHE_CONFIG);
- }
- else
- {
- throw new RepositoryConfigurationException("Cache configuration not found");
- }
- }
-
- /**
- * Return TransactionManager used by JBossCache backing the JCR cache.
- *
- * @return TransactionManager
- */
- public TransactionManager getTransactionManager()
- {
- return cache.getTransactionManager();
- }
-
- /**
- * {@inheritDoc}
- */
- public void put(ItemData item)
- {
- boolean inTransaction = cache.isTransactionActive();
- try
- {
- if (!inTransaction)
- {
- cache.beginTransaction();
- }
- cache.setLocal(true);
- if (item.isNode())
- {
- putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
- }
- else
- {
- putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
- }
- }
- finally
- {
- cache.setLocal(false);
- if (!inTransaction)
- {
- cache.commitTransaction();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void remove(ItemData item)
- {
- removeItem(item);
- }
-
- /**
- * {@inheritDoc}
- */
- public void onSaveItems(final ItemStateChangesLog itemStates)
- {
- // if something happen we will rollback changes
- boolean rollback = true;
- try
- {
- cache.beginTransaction();
- for (ItemState state : itemStates.getAllStates())
- {
- if (state.isAdded())
- {
- if (state.isPersisted())
- {
- putItem(state.getData());
- }
- }
- else if (state.isUpdated())
- {
- if (state.isPersisted())
- {
- // There was a problem with removing a list of samename siblings in on transaction,
- // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.
- ItemData prevItem = putItemInBufferedCache(state.getData());
- if (prevItem != null && state.isNode())
- {
- // nodes reordered, if previous is null it's InvalidItemState case
- updateInBuffer((NodeData)state.getData(), (NodeData)prevItem);
- }
- }
- }
- else if (state.isDeleted())
- {
- removeItem(state.getData());
- }
- else if (state.isRenamed())
- {
- putItem(state.getData());
- }
- else if (state.isMixinChanged())
- {
- if (state.isPersisted())
- {
- // update subtree ACLs
- updateMixin((NodeData)state.getData());
- }
- }
- }
- cache.commitTransaction();
- rollback = false;
- }
- finally
- {
- if (rollback)
- {
- cache.rollbackTransaction();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void addChildNodes(NodeData parent, List<NodeData> childs)
- {
- boolean inTransaction = cache.isTransactionActive();
- try
- {
-
- if (!inTransaction)
- {
- cache.beginTransaction();
- }
-
- cache.setLocal(true);
- // remove previous all (to be sure about consistency)
- cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
-
- if (childs.size() > 0)
- {
- Set<Object> set = new HashSet<Object>();
- for (NodeData child : childs)
- {
- putNode(child, ModifyChildOption.NOT_MODIFY);
- set.add(child.getIdentifier());
- }
- cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, set);
- }
- else
- {
- // cache fact of empty childs list
- cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
- }
- }
- finally
- {
- cache.setLocal(false);
- if (!inTransaction)
- {
- cache.commitTransaction();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void addChildProperties(NodeData parent, List<PropertyData> childs)
- {
- boolean inTransaction = cache.isTransactionActive();
- try
- {
- if (!inTransaction)
- {
- cache.beginTransaction();
- }
- cache.setLocal(true);
- // remove previous all (to be sure about consistency)
- cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
- if (childs.size() > 0)
- {
- // add all new
- Set<Object> set = new HashSet<Object>();
- for (PropertyData child : childs)
- {
- putProperty(child, ModifyChildOption.NOT_MODIFY);
- set.add(child.getIdentifier());
- }
- cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, set);
-
- }
- else
- {
- LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
- }
- }
- finally
- {
- cache.setLocal(false);
- if (!inTransaction)
- {
- cache.commitTransaction();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
- {
- // TODO not implemented, will force read from DB
- // try
- // {
- // cache.beginTransaction();
- // cache.setLocal(true);
- //
- // }
- // finally
- // {
- // cache.setLocal(false);
- // cache.commitTransaction();
- // }
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData get(String parentId, QPathEntry name)
- {
- return get(parentId, name, ItemType.UNKNOWN);
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData get(String parentId, QPathEntry name, ItemType itemType)
- {
- String itemId = null;
- if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
- {
- // try as node first
- itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
- }
-
- if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemId == null)
- {
- // try as property
- itemId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
- }
-
- if (itemId != null)
- {
- return get(itemId);
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData get(String id)
- {
- return (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<NodeData> getChildNodes(final NodeData parent)
- {
- // get list of children uuids
- final Set<Object> set =
- (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
- if (set != null)
- {
- final List<NodeData> childs = new ArrayList<NodeData>();
-
- for (Object child : set)
- {
- NodeData node = (NodeData)cache.get(makeItemFqn((String)child), ITEM_DATA);
- if (node == null)
- {
- return null;
- }
-
- childs.add(node);
- }
-
- // order children by orderNumber, as HashSet returns children in other order
- Collections.sort(childs, new NodesOrderComparator<NodeData>());
-
- return childs;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public int getChildNodesCount(NodeData parent)
- {
- // get list of children uuids
- final Set<Object> set =
- (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
-
- return set != null ? set.size() : -1;
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getChildProperties(NodeData parent)
- {
- return getChildProps(parent.getIdentifier(), true);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> listChildProperties(NodeData parent)
- {
- return getChildProps(parent.getIdentifier(), false);
- }
-
- /**
- * Internal get child properties.
- *
- * @param parentId String
- * @param withValue boolean, if true only "full" Propeties can be returned
- * @return List of PropertyData
- */
- protected List<PropertyData> getChildProps(String parentId, boolean withValue)
- {
- // get set of property uuids
- final Set<Object> set = (Set<Object>)cache.get(makeChildListFqn(childPropsList, parentId), ITEM_LIST);
- if (set != null)
- {
- final List<PropertyData> childs = new ArrayList<PropertyData>();
-
- for (Object child : set)
- {
- PropertyData prop = (PropertyData)cache.get(makeItemFqn((String)child), ITEM_DATA);
- if (prop == null)
- {
- return null;
- }
- if (withValue && prop.getValues().size() <= 0)
- {
- // don't return list of empty-valued props (but listChildProperties() can)
- return null;
- }
- childs.add(prop);
- }
- return childs;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public long getSize()
- {
- // Total number of JBC nodes in the cache - the total amount of resident nodes
- return numNodes(cache.getNode(rootFqn)) - 6;
- }
-
- /**
- * Evaluates the total amount of sub-nodes that the given node contains
- */
- private static long numNodes(Node<Serializable, Object> n)
- {
- long count = 1;// for n
- if (n != null)
- {
- for (Node<Serializable, Object> child : n.getChildren())
- {
- count += numNodes(child);
- }
- }
- return count;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isEnabled()
- {
- return true;
- }
-
- // non-public members
-
- /**
- * Make Item absolute Fqn, i.e. /$ITEMS/itemID.
- *
- * @param itemId String
- * @return Fqn
- */
- protected Fqn<String> makeItemFqn(String itemId)
- {
- return Fqn.fromRelativeElements(itemsRoot, itemId);
- }
-
- /**
- * Make child Item absolute Fqn, i.e. /root/parentId/childName.
- *
- * @param root Fqn
- * @param parentId String
- * @param childName QPathEntry
- * @return Fqn
- */
- protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, QPathEntry childName)
- {
- return Fqn.fromRelativeElements(root, parentId, childName.getAsString(true));
- }
-
- /**
- * Make child Item absolute Fqn, i.e. /root/parentId/childName.
- *
- * @param root Fqn
- * @param parentId String
- * @param childName String
- * @return Fqn
- */
- protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, String childName)
- {
- return Fqn.fromRelativeElements(root, parentId, childName);
- }
-
- /**
- * Make child node parent absolute Fqn, i.e. /root/itemId.
- *
- * @param root Fqn
- * @param parentId String
- * @return Fqn
- */
- protected Fqn<String> makeChildListFqn(Fqn<String> root, String parentId)
- {
- return Fqn.fromRelativeElements(root, parentId);
- }
-
- /**
- * Internal put Item.
- *
- * @param item ItemData, new data to put in the cache
- * @return ItemData, previous data or null
- */
- protected ItemData putItem(ItemData item)
- {
- if (item.isNode())
- {
- return putNode((NodeData)item, ModifyChildOption.MODIFY);
- }
- else
- {
- return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
- }
- }
-
- protected ItemData putItemInBufferedCache(ItemData item)
- {
- if (item.isNode())
- {
- return putNodeInBufferedCache((NodeData)item, ModifyChildOption.MODIFY);
- }
- else
- {
- return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
- }
-
- }
-
- /**
- * Internal put Node.
- *
- * @param node, NodeData, new data to put in the cache
- * @return NodeData, previous data or null
- */
- protected ItemData putNode(NodeData node, ModifyChildOption modifyListsOfChild)
- {
- // if not a root node
- if (node.getParentIdentifier() != null)
- {
- // add in CHILD_NODES
- cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
- {
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
- .getIdentifier());
- }
-
- }
- // add in ITEMS
- return (ItemData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- }
-
- protected ItemData putNodeInBufferedCache(NodeData node, ModifyChildOption modifyListsOfChild)
- {
- // if not a root node
- if (node.getParentIdentifier() != null)
- {
- // add in CHILD_NODES
- cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
- {
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
- .getIdentifier());
- }
- }
- // add in ITEMS
- return (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- }
-
- /**
- * Internal put Property.
- *
- * @param node, PropertyData, new data to put in the cache
- * @return PropertyData, previous data or null
- */
- protected PropertyData putProperty(PropertyData prop, ModifyChildOption modifyListsOfChild)
- {
- // add in CHILD_PROPS
- cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
- .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
- // if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
- .getParentIdentifier())) != null)
- || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
- {
- cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
- }
- // add in ITEMS
- return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop);
- }
-
- protected void removeItem(ItemData item)
- {
- if (item.isNode())
- {
- if (item.getParentIdentifier() != null)
- {
- // if not a root node
-
- // remove from CHILD_NODES of parent
- cache.removeNode(makeChildFqn(childNodes, item.getParentIdentifier(), item.getQPath().getEntries()[item
- .getQPath().getEntries().length - 1]));
-
- // remove from CHILD_NODES_LIST of parent
- cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
- .getIdentifier());
-
- // remove from CHILD_NODES as parent
- cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
-
- // remove from CHILD_NODES_LIST as parent
- cache.removeNode(makeChildListFqn(childNodesList, item.getIdentifier()));
-
- // remove from CHILD_PROPS as parent
- cache.removeNode(makeChildListFqn(childProps, item.getIdentifier()));
-
- // remove from CHILD_PROPS_LIST as parent
- cache.removeNode(makeChildListFqn(childPropsList, item.getIdentifier()));
- }
- }
- else
- {
- // remove from CHILD_PROPS
- cache.removeNode(makeChildFqn(childProps, item.getParentIdentifier(), item.getQPath().getEntries()[item
- .getQPath().getEntries().length - 1]));
-
- // remove from CHILD_PROPS_LIST
- cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
- .getIdentifier());
- }
- // remove from ITEMS
- cache.removeNode(makeItemFqn(item.getIdentifier()));
- }
-
- /**
- * Update Node's mixin and ACL.
- *
- * @param node NodeData
- */
- protected void updateMixin(NodeData node)
- {
- NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- if (prevData != null)
- {
- // do update ACL if needed
- if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
- {
- updateChildsACL(node.getIdentifier(), node.getACL());
- }
- }
- else if (LOG.isDebugEnabled())
- {
- LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
- }
- }
-
- /**
- * Update Node hierachy in case of same-name siblings reorder.
- * Assumes the new (updated) nodes already putted in the cache. Previous name of updated nodes will be calculated
- * and that node will be deleted (if has same id as the new node). Childs paths will be updated to a new node path.
- *
- * @param node NodeData
- * @param prevNode NodeData
- */
- protected void update(final NodeData node, final NodeData prevNode)
- {
- // get previously cached NodeData and using its name remove child on the parent
- Fqn<String> prevFqn =
- makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
- .getEntries().length - 1]);
- if (node.getIdentifier().equals(cache.get(prevFqn, ITEM_ID)))
- {
- // it's same-name siblings re-ordering, delete previous child
- if (!cache.removeNode(prevFqn) && LOG.isDebugEnabled())
- {
- LOG.debug("Node not extists as a child but update asked " + node.getQPath().getAsString());
- }
- }
-
- // update childs paths if index changed
- int nodeIndex = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getIndex();
- int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
- if (nodeIndex != prevNodeIndex)
- {
- updateTreePath(node.getIdentifier(), node.getQPath(), null); // don't change ACL, it's same parent
- }
- }
-
- /**
- * This method duplicate update method, except using getFromBuffer inside.
- *
- * @param node NodeData
- * @param prevNode NodeData
- */
- protected void updateInBuffer(final NodeData node, final NodeData prevNode)
- {
- // get previously cached NodeData and using its name remove child on the parent
- Fqn<String> prevFqn =
- makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
- .getEntries().length - 1]);
- if (node.getIdentifier().equals(cache.getFromBuffer(prevFqn, ITEM_ID)))
- {
- // it's same-name siblings re-ordering, delete previous child
- if (!cache.removeNode(prevFqn) && LOG.isDebugEnabled())
- {
- LOG.debug("Node not extists as a child but update asked " + node.getQPath().getAsString());
- }
- }
-
- // update childs paths if index changed
- int nodeIndex = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getIndex();
- int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
- if (nodeIndex != prevNodeIndex)
- {
- // its a samename reordering
- updateTreePath(prevNode.getQPath(), node.getQPath(), null); // don't change ACL, it's same parent
- }
- }
-
- /**
- * Check all items in cache - is it descendant of prevRootPath, and update path according newRootPath.
- *
- * @param prevRootPath
- * @param newRootPath
- * @param acl
- */
- protected void updateTreePath(final QPath prevRootPath, final QPath newRootPath, final AccessControlList acl)
- {
- boolean inheritACL = acl != null;
-
- // check all ITEMS in cache
- Node<Serializable, Object> items = cache.getNode(itemsRoot);
- Set<Object> childrenNames = items.getChildrenNames();
- Iterator<Object> namesIt = childrenNames.iterator();
-
- while (namesIt.hasNext())
- {
- String id = (String)namesIt.next();
- ItemData data = (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
-
- // check is this descendant of prevRootPath
- QPath nodeQPath = data.getQPath();
- if (nodeQPath.isDescendantOf(prevRootPath))
- {
-
- //make relative path
- QPathEntry[] relativePath = null;
- try
- {
- relativePath = nodeQPath.getRelPath(nodeQPath.getDepth() - prevRootPath.getDepth());
- }
- catch (IllegalPathException e)
- {
- // Do nothing. Never happens.
- }
-
- // make new path - no matter node or property
- QPath newPath = QPath.makeChildPath(newRootPath, relativePath);
-
- if (data.isNode())
- {
- // update node
-
- NodeData prevNode = (NodeData)data;
-
- TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
- .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
- // update this node
- cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
- }
- else
- {
- //update property
-
- PropertyData prevProp = (PropertyData)data;
-
- if (inheritACL
- && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
- .equals(Constants.EXO_OWNER)))
- {
- inheritACL = false;
- }
-
- TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
- .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
- cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
- }
- }
- }
- }
-
- /**
- * Update Nodes tree with new path.
- *
- * @param parentId String - root node id of JCR subtree.
- * @param rootPath QPath
- * @param acl AccessControlList
- */
- protected void updateTreePath(final String parentId, final QPath rootPath, final AccessControlList acl)
- {
- boolean inheritACL = acl != null;
-
- // update properties
- for (Iterator<PropertyData> iter = new ChildPropertiesIterator<PropertyData>(parentId); iter.hasNext();)
- {
- PropertyData prevProp = iter.next();
-
- if (inheritACL
- && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
- .equals(Constants.EXO_OWNER)))
- {
- inheritACL = false;
- }
- // recreate with new path for child Props only
- QPath newPath =
- QPath
- .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
- TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
- .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
- cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
- }
-
- // update child nodes
- for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
- {
- NodeData prevNode = iter.next();
- // recreate with new path for child Nodes only
- QPath newPath =
- QPath
- .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
- TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
- .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
- // update this node
- cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
- // update childs recursive
- updateTreePath(newNode.getIdentifier(), newNode.getQPath(), inheritACL ? acl : null);
- }
- }
-
- /**
- * Update child Nodes ACLs.
- *
- * @param parentId String - root node id of JCR subtree.
- * @param acl AccessControlList
- */
- protected void updateChildsACL(final String parentId, final AccessControlList acl)
- {
- for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
- {
- NodeData prevNode = iter.next();
- // is ACL changes on this node (i.e. ACL inheritance brokes)
- for (InternalQName mixin : prevNode.getMixinTypeNames())
- {
- if (mixin.equals(Constants.EXO_PRIVILEGEABLE) || mixin.equals(Constants.EXO_OWNEABLE))
- {
- continue;
- }
- }
- // recreate with new path for child Nodes only
- TransientNodeData newNode =
- new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), acl);
- // update this node
- cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
- // update childs recursive
- updateChildsACL(newNode.getIdentifier(), acl);
- }
- }
-
- public void beginTransaction()
- {
- cache.beginTransaction();
- }
-
- public void commitTransaction()
- {
- cache.commitTransaction();
- }
-
- public void rollbackTransaction()
- {
- cache.rollbackTransaction();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isTXAware()
- {
- return true;
- }
-
- /**
- * <li>NOT_MODIFY - node(property) is not added to the parent's list (no persistent changes performed, cache used as cache)</li>
- * <li>MODIFY - node(property) is added to the parent's list if parent in the cache (new item is added to persistent, add to list if it is present)</li>
- * <li>FORCE_MODIFY - node(property) is added to the parent's list anyway (when list is read from DB, forcing write)</li>
- */
- private enum ModifyChildOption {
- NOT_MODIFY, MODIFY, FORCE_MODIFY
- }
-
-}
+/*
+ * 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.dataflow.persistent.jbosscache;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
+import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
+import org.exoplatform.services.jcr.datamodel.IllegalPathException;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory;
+import org.exoplatform.services.jcr.jbosscache.ExoJBossCacheFactory.CacheType;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.transaction.TransactionService;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.eviction.ExpirationAlgorithmConfig;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+import javax.transaction.TransactionManager;
+
+/**
+ * Created by The eXo Platform SAS.<p/>
+ *
+ * Cache based on JBossCache.<p/>
+ *
+ * <ul>
+ * <li>cache transparent: or item cached or not, we should not generate "not found" Exceptions </li>
+ * <li>cache consists of next resident nodes:
+ * <ul>
+ * <li>/$ITEMS - stores items by Id (i.e. /$ITEMS/itemId)</li>
+ * <li>/$CHILD_NODES, /$CHILD_PROPS - stores items by parentId and name (i.e. /$CHILD_NODES/parentId/childName.$ITEM_ID)</li>
+ * <li>/$CHILD_NODES_LIST, /$CHILD_PROPS_LIST - stores child list by parentId and child Id
+ * (i.e. /$CHILD_NODES_LIST/parentId.lists = serialized Set<Object>)</li>
+ * </ul>
+ * </li>
+ * <li>all child properties/nodes lists should be evicted from parent at same time
+ * i.e. for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST we need customized eviction policy (EvictionActionPolicy) to evict
+ * whole list on one of childs eviction
+ * </li>
+ * </ul>
+ *
+ * <p/>
+ * Current state notes (subject of change):
+ * <ul>
+ * <li>cache implements WorkspaceStorageCache, without any stuff about references and locks</li>
+ * <li>transaction style implemented via JBC barches, do with JTA (i.e. via exo's TransactionService + JBoss TM)</li>
+ * <li>we need customized eviction policy (EvictionActionPolicy) for /$CHILD_NODES_LIST, /$CHILD_PROPS_LIST</li>
+ * </ul>
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com">Peter Nedonosko</a>
+ * @version $Id: JBossCacheWorkspaceStorageCache.java 13869 2008-05-05 08:40:10Z pnedonosko $
+ */
+public class JBossCacheWorkspaceStorageCache implements WorkspaceStorageCache
+{
+
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JBossCacheWorkspaceStorageCache");
+
+ public static final String JBOSSCACHE_CONFIG = "jbosscache-configuration";
+
+ public static final String JBOSSCACHE_EXPIRATION = "jbosscache-expiration-time";
+
+ /**
+ * Indicate whether the JBoss Cache instance used can be shared with other caches
+ */
+ public static final String JBOSSCACHE_SHAREABLE = "jbosscache-shareable";
+
+ public static final Boolean JBOSSCACHE_SHAREABLE_DEFAULT = Boolean.FALSE;
+
+ public static final long JBOSSCACHE_EXPIRATION_DEFAULT = 900000; // 15 minutes
+
+ public static final String ITEMS = "$ITEMS".intern();
+
+ public static final String NULL_ITEMS = "$NULL_ITEMS".intern();
+
+ public static final String CHILD_NODES = "$CHILD_NODES".intern();
+
+ public static final String CHILD_PROPS = "$CHILD_PROPS".intern();
+
+ public static final String CHILD_NODES_LIST = "$CHILD_NODES_LIST".intern();
+
+ public static final String CHILD_PROPS_LIST = "$CHILD_PROPS_LIST".intern();
+
+ public static final String LOCKS = "$LOCKS".intern();
+
+ public static final String ITEM_DATA = "$data".intern();
+
+ public static final String ITEM_ID = "$id".intern();
+
+ public static final String ITEM_LIST = "$lists".intern();
+
+ protected final BufferedJBossCache cache;
+
+ protected final Fqn<String> itemsRoot;
+
+ protected final Fqn<String> nullItemsRoot;
+
+ protected final Fqn<String> childNodes;
+
+ protected final Fqn<String> childProps;
+
+ protected final Fqn<String> childNodesList;
+
+ protected final Fqn<String> childPropsList;
+
+ protected final Fqn<String> rootFqn;
+
+ /**
+ * Node order comparator for getChildNodes().
+ */
+ class NodesOrderComparator<N extends NodeData> implements Comparator<NodeData>
+ {
+
+ /**
+ * {@inheritDoc}
+ */
+ public int compare(NodeData n1, NodeData n2)
+ {
+ return n1.getOrderNumber() - n2.getOrderNumber();
+ }
+ }
+
+ class ChildItemsIterator<T extends ItemData> implements Iterator<T>
+ {
+
+ final Iterator<Object> childs;
+
+ final String parentId;
+
+ final Fqn<String> root;
+
+ T next;
+
+ ChildItemsIterator(Fqn<String> root, String parentId)
+ {
+ this.parentId = parentId;
+ this.root = root;
+
+ Fqn<String> parentFqn = makeChildListFqn(root, parentId);
+ Node<Serializable, Object> parent = cache.getNode(parentFqn);
+ if (parent != null)
+ {
+ this.childs = cache.getChildrenNames(parentFqn).iterator();
+ fetchNext();
+ }
+ else
+ {
+ this.childs = null;
+ this.next = null;
+ }
+ }
+
+ protected void fetchNext()
+ {
+ if (childs.hasNext())
+ {
+ // traverse to the first existing or the end of childs
+ T n = null;
+ do
+ {
+ String itemId = (String)cache.get(makeChildFqn(root, parentId, (String)childs.next()), ITEM_ID);
+ if (itemId != null)
+ {
+ n = (T)cache.get(makeItemFqn(itemId), ITEM_DATA);
+ }
+ }
+ while (n == null && childs.hasNext());
+ next = n;
+ }
+ else
+ {
+ next = null;
+ }
+ }
+
+ public boolean hasNext()
+ {
+ return next != null;
+ }
+
+ public T next()
+ {
+ if (next == null)
+ {
+ throw new NoSuchElementException();
+ }
+
+ final T current = next;
+ fetchNext();
+ return current;
+ }
+
+ public void remove()
+ {
+ throw new IllegalArgumentException("Not implemented");
+ }
+ }
+
+ class ChildNodesIterator<N extends NodeData> extends ChildItemsIterator<N>
+ {
+ ChildNodesIterator(String parentId)
+ {
+ super(childNodes, parentId);
+ }
+
+ @Override
+ public N next()
+ {
+ return super.next();
+ }
+ }
+
+ class ChildPropertiesIterator<P extends PropertyData> extends ChildItemsIterator<P>
+ {
+
+ ChildPropertiesIterator(String parentId)
+ {
+ super(childProps, parentId);
+ }
+
+ @Override
+ public P next()
+ {
+ return super.next();
+ }
+ }
+
+ /**
+ * Cache constructor with eXo TransactionService support.
+ *
+ * @param wsConfig WorkspaceEntry workspace config
+ * @param transactionService TransactionService external transaction service
+ * @throws RepositoryException if error of initialization
+ * @throws RepositoryConfigurationException if error of configuration
+ */
+ public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, TransactionService transactionService,
+ ConfigurationManager cfm) throws RepositoryException, RepositoryConfigurationException
+ {
+ if (wsConfig.getCache() == null)
+ {
+ throw new RepositoryConfigurationException("Cache configuration not found");
+ }
+
+ // create cache using custom factory
+ ExoJBossCacheFactory<Serializable, Object> factory;
+
+ if (transactionService != null)
+ {
+ factory = new ExoJBossCacheFactory<Serializable, Object>(cfm, transactionService.getTransactionManager());
+ }
+ else
+ {
+ factory = new ExoJBossCacheFactory<Serializable, Object>(cfm);
+ }
+
+ // create parent JBossCache instance
+ Cache<Serializable, Object> parentCache = factory.createCache(wsConfig.getCache());
+ // get all eviction configurations
+ List<EvictionRegionConfig> evictionConfigurations =
+ parentCache.getConfiguration().getEvictionConfig().getEvictionRegionConfigs();
+ // append and default eviction configuration, since it is not present in region configurations
+ evictionConfigurations.add(parentCache.getConfiguration().getEvictionConfig().getDefaultEvictionRegionConfig());
+
+ boolean useExpiration = false;
+ // looking over all eviction configurations till the end or till some expiration algorithm subclass not found.
+ for (EvictionRegionConfig evictionRegionConfig : evictionConfigurations)
+ {
+ if (evictionRegionConfig.getEvictionAlgorithmConfig() instanceof ExpirationAlgorithmConfig)
+ {
+ // force set expiration key to default value in all Expiration configurations (if any)
+ ((ExpirationAlgorithmConfig)evictionRegionConfig.getEvictionAlgorithmConfig())
+ .setExpirationKeyName(ExpirationAlgorithmConfig.EXPIRATION_KEY);
+ useExpiration = true;
+ }
+ }
+
+ if (useExpiration)
+ {
+ LOG.info("Using BufferedJBossCache compatible with Expiration algorithm.");
+ }
+
+ this.rootFqn = Fqn.fromElements(wsConfig.getUniqueName());
+ parentCache =
+ ExoJBossCacheFactory.getUniqueInstance(CacheType.JCR_CACHE, rootFqn, parentCache, wsConfig.getCache()
+ .getParameterBoolean(JBOSSCACHE_SHAREABLE, JBOSSCACHE_SHAREABLE_DEFAULT).booleanValue());
+
+ // if expiration is used, set appropriate factory with with timeout set via configuration (or default one 15minutes)
+ this.cache =
+ new BufferedJBossCache(parentCache, useExpiration, wsConfig.getCache().getParameterTime(JBOSSCACHE_EXPIRATION,
+ JBOSSCACHE_EXPIRATION_DEFAULT));
+
+ this.itemsRoot = Fqn.fromRelativeElements(rootFqn, ITEMS);
+ this.nullItemsRoot = Fqn.fromElements(NULL_ITEMS);
+ this.childNodes = Fqn.fromRelativeElements(rootFqn, CHILD_NODES);
+ this.childProps = Fqn.fromRelativeElements(rootFqn, CHILD_PROPS);
+ this.childNodesList = Fqn.fromRelativeElements(rootFqn, CHILD_NODES_LIST);
+ this.childPropsList = Fqn.fromRelativeElements(rootFqn, CHILD_PROPS_LIST);
+
+ this.cache.create();
+ this.cache.start();
+
+ createResidentNode(childNodes);
+ createResidentNode(childNodesList);
+ createResidentNode(childProps);
+ createResidentNode(childPropsList);
+ createResidentNode(itemsRoot);
+ createResidentNode(nullItemsRoot);
+ }
+
+ /**
+ * Cache constructor with JBossCache JTA transaction support.
+ *
+ * @param wsConfig WorkspaceEntry workspace config
+ * @throws RepositoryException if error of initialization
+ * @throws RepositoryConfigurationException if error of configuration
+ */
+ public JBossCacheWorkspaceStorageCache(WorkspaceEntry wsConfig, ConfigurationManager cfm)
+ throws RepositoryException, RepositoryConfigurationException
+ {
+ this(wsConfig, null, cfm);
+ }
+
+ /**
+ * Checks if node with give FQN not exists and creates resident node.
+ * @param fqn
+ */
+ protected void createResidentNode(Fqn fqn)
+ {
+ Node<Serializable, Object> cacheRoot = cache.getRoot();
+ if (!cacheRoot.hasChild(fqn))
+ {
+ cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
+ cacheRoot.addChild(fqn).setResident(true);
+ }
+ else
+ {
+ cache.getNode(fqn).setResident(true);
+ }
+
+ }
+
+ protected static String readJBCConfig(final WorkspaceEntry wsConfig) throws RepositoryConfigurationException
+ {
+ if (wsConfig.getCache() != null)
+ {
+ return wsConfig.getCache().getParameterValue(JBOSSCACHE_CONFIG);
+ }
+ else
+ {
+ throw new RepositoryConfigurationException("Cache configuration not found");
+ }
+ }
+
+ /**
+ * Return TransactionManager used by JBossCache backing the JCR cache.
+ *
+ * @return TransactionManager
+ */
+ public TransactionManager getTransactionManager()
+ {
+ return cache.getTransactionManager();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void put(ItemData item)
+ {
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+ if (!inTransaction)
+ {
+ cache.beginTransaction();
+ }
+ cache.setLocal(true);
+
+ if (item instanceof NullNodeData)
+ {
+ putNullNode((NullNodeData)item);
+ }
+ else
+ {
+ if (item.isNode())
+ {
+ putNode((NodeData)item, ModifyChildOption.NOT_MODIFY);
+ }
+ else
+ {
+ putProperty((PropertyData)item, ModifyChildOption.NOT_MODIFY);
+ }
+ }
+ }
+ finally
+ {
+ cache.setLocal(false);
+ if (!inTransaction)
+ {
+ cache.commitTransaction();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove(ItemData item)
+ {
+ removeItem(item);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onSaveItems(final ItemStateChangesLog itemStates)
+ {
+ // if something happen we will rollback changes
+ boolean rollback = true;
+ try
+ {
+ cache.beginTransaction();
+ for (ItemState state : itemStates.getAllStates())
+ {
+ if (state.isAdded())
+ {
+ if (state.isPersisted())
+ {
+ putItem(state.getData());
+ }
+ }
+ else if (state.isUpdated())
+ {
+ if (state.isPersisted())
+ {
+ // There was a problem with removing a list of samename siblings in on transaction,
+ // so putItemInBufferedCache(..) and updateInBufferedCache(..) used instead put(..) and update (..) methods.
+ ItemData prevItem = putItemInBufferedCache(state.getData());
+ if (prevItem != null && state.isNode())
+ {
+ // nodes reordered, if previous is null it's InvalidItemState case
+ updateInBuffer((NodeData)state.getData(), (NodeData)prevItem);
+ }
+ }
+ }
+ else if (state.isDeleted())
+ {
+ removeItem(state.getData());
+ }
+ else if (state.isRenamed())
+ {
+ putItem(state.getData());
+ }
+ else if (state.isMixinChanged())
+ {
+ if (state.isPersisted())
+ {
+ // update subtree ACLs
+ updateMixin((NodeData)state.getData());
+ }
+ }
+ }
+ cache.commitTransaction();
+ rollback = false;
+ }
+ finally
+ {
+ if (rollback)
+ {
+ cache.rollbackTransaction();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addChildNodes(NodeData parent, List<NodeData> childs)
+ {
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+
+ if (!inTransaction)
+ {
+ cache.beginTransaction();
+ }
+
+ cache.setLocal(true);
+ // remove previous all (to be sure about consistency)
+ cache.removeNode(makeChildListFqn(childNodesList, parent.getIdentifier()));
+
+ if (childs.size() > 0)
+ {
+ Set<Object> set = new HashSet<Object>();
+ for (NodeData child : childs)
+ {
+ putNode(child, ModifyChildOption.NOT_MODIFY);
+ set.add(child.getIdentifier());
+ }
+ cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, set);
+ }
+ else
+ {
+ // cache fact of empty childs list
+ cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST, new HashSet<Object>());
+ }
+ }
+ finally
+ {
+ cache.setLocal(false);
+ if (!inTransaction)
+ {
+ cache.commitTransaction();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addChildProperties(NodeData parent, List<PropertyData> childs)
+ {
+ boolean inTransaction = cache.isTransactionActive();
+ try
+ {
+ if (!inTransaction)
+ {
+ cache.beginTransaction();
+ }
+ cache.setLocal(true);
+ // remove previous all (to be sure about consistency)
+ cache.removeNode(makeChildListFqn(childPropsList, parent.getIdentifier()));
+ if (childs.size() > 0)
+ {
+ // add all new
+ Set<Object> set = new HashSet<Object>();
+ for (PropertyData child : childs)
+ {
+ putProperty(child, ModifyChildOption.NOT_MODIFY);
+ set.add(child.getIdentifier());
+ }
+ cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()), ITEM_LIST, set);
+
+ }
+ else
+ {
+ LOG.warn("Empty properties list cached " + (parent != null ? parent.getQPath().getAsString() : parent));
+ }
+ }
+ finally
+ {
+ cache.setLocal(false);
+ if (!inTransaction)
+ {
+ cache.commitTransaction();
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addChildPropertiesList(NodeData parent, List<PropertyData> childProperties)
+ {
+ // TODO not implemented, will force read from DB
+ // try
+ // {
+ // cache.beginTransaction();
+ // cache.setLocal(true);
+ //
+ // }
+ // finally
+ // {
+ // cache.setLocal(false);
+ // cache.commitTransaction();
+ // }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData get(String parentId, QPathEntry name)
+ {
+ return get(parentId, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData get(String parentId, QPathEntry name, ItemType itemType)
+ {
+ String itemId = null;
+ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+ {
+ // try as node first
+ itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
+ }
+
+ if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemId == null)
+ {
+ // try as property
+ itemId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
+ }
+
+ if (itemId != null)
+ {
+ return getFromCacheById(itemId);
+ }
+
+ return (ItemData)cache.get(makeNullItemFqn(parentId + "$" + name.getAsString(true)), ITEM_DATA);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData get(String id)
+ {
+ ItemData data = getFromCacheById(id);
+
+ return data != null ? data : (ItemData)cache.get(makeNullItemFqn(id), ITEM_DATA);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<NodeData> getChildNodes(final NodeData parent)
+ {
+ // get list of children uuids
+ final Set<Object> set =
+ (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
+ if (set != null)
+ {
+ final List<NodeData> childs = new ArrayList<NodeData>();
+
+ for (Object child : set)
+ {
+ NodeData node = (NodeData)cache.get(makeItemFqn((String)child), ITEM_DATA);
+ if (node == null)
+ {
+ return null;
+ }
+
+ childs.add(node);
+ }
+
+ // order children by orderNumber, as HashSet returns children in other order
+ Collections.sort(childs, new NodesOrderComparator<NodeData>());
+
+ return childs;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getChildNodesCount(NodeData parent)
+ {
+ // get list of children uuids
+ final Set<Object> set =
+ (Set<Object>)cache.get(makeChildListFqn(childNodesList, parent.getIdentifier()), ITEM_LIST);
+
+ return set != null ? set.size() : -1;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> getChildProperties(NodeData parent)
+ {
+ return getChildProps(parent.getIdentifier(), true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List<PropertyData> listChildProperties(NodeData parent)
+ {
+ return getChildProps(parent.getIdentifier(), false);
+ }
+
+ /**
+ * Internal get child properties.
+ *
+ * @param parentId String
+ * @param withValue boolean, if true only "full" Propeties can be returned
+ * @return List of PropertyData
+ */
+ protected List<PropertyData> getChildProps(String parentId, boolean withValue)
+ {
+ // get set of property uuids
+ final Set<Object> set = (Set<Object>)cache.get(makeChildListFqn(childPropsList, parentId), ITEM_LIST);
+ if (set != null)
+ {
+ final List<PropertyData> childs = new ArrayList<PropertyData>();
+
+ for (Object child : set)
+ {
+ PropertyData prop = (PropertyData)cache.get(makeItemFqn((String)child), ITEM_DATA);
+ if (prop == null)
+ {
+ return null;
+ }
+ if (withValue && prop.getValues().size() <= 0)
+ {
+ // don't return list of empty-valued props (but listChildProperties() can)
+ return null;
+ }
+ childs.add(prop);
+ }
+ return childs;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getSize()
+ {
+ // Total number of JBC nodes in the cache - the total amount of resident nodes
+ return numNodes(cache.getNode(rootFqn)) - 6;
+ }
+
+ /**
+ * Evaluates the total amount of sub-nodes that the given node contains
+ */
+ private static long numNodes(Node<Serializable, Object> n)
+ {
+ long count = 1;// for n
+ if (n != null)
+ {
+ for (Node<Serializable, Object> child : n.getChildren())
+ {
+ count += numNodes(child);
+ }
+ }
+ return count;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEnabled()
+ {
+ return true;
+ }
+
+ // non-public members
+
+ /**
+ * Make Item absolute Fqn, i.e. /$ITEMS/itemID.
+ *
+ * @param itemId String
+ * @return Fqn
+ */
+ protected Fqn<String> makeItemFqn(String itemId)
+ {
+ return Fqn.fromRelativeElements(itemsRoot, itemId);
+ }
+
+ /**
+ * Make Item absolute Fqn, i.e. /$NULL_ITEMS/itemID.
+ *
+ * @param itemId String
+ * @return Fqn
+ */
+ protected Fqn<String> makeNullItemFqn(String itemId)
+ {
+ return Fqn.fromRelativeElements(nullItemsRoot, itemId);
+ }
+
+ /**
+ * Make child Item absolute Fqn, i.e. /root/parentId/childName.
+ *
+ * @param root Fqn
+ * @param parentId String
+ * @param childName QPathEntry
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, QPathEntry childName)
+ {
+ return Fqn.fromRelativeElements(root, parentId, childName.getAsString(true));
+ }
+
+ /**
+ * Make child Item absolute Fqn, i.e. /root/parentId/childName.
+ *
+ * @param root Fqn
+ * @param parentId String
+ * @param childName String
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildFqn(Fqn<String> root, String parentId, String childName)
+ {
+ return Fqn.fromRelativeElements(root, parentId, childName);
+ }
+
+ /**
+ * Make child node parent absolute Fqn, i.e. /root/itemId.
+ *
+ * @param root Fqn
+ * @param parentId String
+ * @return Fqn
+ */
+ protected Fqn<String> makeChildListFqn(Fqn<String> root, String parentId)
+ {
+ return Fqn.fromRelativeElements(root, parentId);
+ }
+
+ /**
+ * Gets item data from cache by item identifier.
+ */
+ protected ItemData getFromCacheById(String id)
+ {
+ return (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
+ }
+
+ /**
+ * Internal put Item.
+ *
+ * @param item ItemData, new data to put in the cache
+ * @return ItemData, previous data or null
+ */
+ protected ItemData putItem(ItemData item)
+ {
+ if (item.isNode())
+ {
+ return putNode((NodeData)item, ModifyChildOption.MODIFY);
+ }
+ else
+ {
+ return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
+ }
+ }
+
+ protected ItemData putItemInBufferedCache(ItemData item)
+ {
+ if (item.isNode())
+ {
+ return putNodeInBufferedCache((NodeData)item, ModifyChildOption.MODIFY);
+ }
+ else
+ {
+ return putProperty((PropertyData)item, ModifyChildOption.MODIFY);
+ }
+
+ }
+
+ /**
+ * Internal put Node.
+ *
+ * @param node, NodeData, new data to put in the cache
+ * @return NodeData, previous data or null
+ */
+ protected ItemData putNode(NodeData node, ModifyChildOption modifyListsOfChild)
+ {
+
+ // remove possible NullNodeData from cache
+ boolean local = cache.isLocal();
+ cache.setLocal(false);
+
+ removeNullNode(node);
+
+ cache.setLocal(local);
+
+ // if not a root node
+ if (node.getParentIdentifier() != null)
+ {
+ // add in CHILD_NODES
+ cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ // if MODIFY and List present OR FORCE_MODIFY, then write
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
+ .getParentIdentifier())) != null)
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
+ .getIdentifier());
+ }
+
+ }
+ // add in ITEMS
+ return (ItemData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ }
+
+ /**
+ * Internal put NullNode.
+ *
+ * @param node, NodeData, new data to put in the cache
+ * @return ItemData, previous data or null
+ */
+ protected ItemData putNullNode(NullNodeData node)
+ {
+ return (ItemData)cache.put(makeNullItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ }
+
+ /**
+ * Removes NullNode from cache.
+ *
+ * @param item
+ * that possible has corresponding NullNode in cache
+ *
+ */
+ protected void removeNullNode(ItemData item)
+ {
+ Fqn<String> fqn = makeNullItemFqn(item.getIdentifier());
+ if ((NullNodeData)cache.get(fqn, ITEM_DATA) != null)
+ {
+ cache.removeNode(fqn);
+ }
+
+ fqn =
+ makeNullItemFqn(item.getParentIdentifier() + "$"
+ + item.getQPath().getEntries()[item.getQPath().getEntries().length - 1].getAsString(true));
+ if (cache.get(fqn, ITEM_DATA) != null)
+ {
+ cache.removeNode(fqn);
+ }
+ }
+
+ protected ItemData putNodeInBufferedCache(NodeData node, ModifyChildOption modifyListsOfChild)
+ {
+ // if not a root node
+ if (node.getParentIdentifier() != null)
+ {
+ // add in CHILD_NODES
+ cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ // if MODIFY and List present OR FORCE_MODIFY, then write
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
+ .getParentIdentifier())) != null)
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
+ .getIdentifier());
+ }
+ }
+ // add in ITEMS
+ return (ItemData)cache.putInBuffer(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ }
+
+ /**
+ * Internal put Property.
+ *
+ * @param node, PropertyData, new data to put in the cache
+ * @return PropertyData, previous data or null
+ */
+ protected PropertyData putProperty(PropertyData prop, ModifyChildOption modifyListsOfChild)
+ {
+
+ // remove possible NullNodeData from cache
+ boolean local = cache.isLocal();
+ cache.setLocal(false);
+
+ removeNullNode(prop);
+
+ cache.setLocal(local);
+
+ // add in CHILD_PROPS
+ cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
+ .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
+ // if MODIFY and List present OR FORCE_MODIFY, then write
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
+ .getParentIdentifier())) != null)
+ || modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
+ {
+ cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
+ }
+
+ ItemData result =
+ get(prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]);
+
+ // add in ITEMS
+ return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA, prop);
+ }
+
+ protected void removeItem(ItemData item)
+ {
+ if (item.isNode())
+ {
+ if (item.getParentIdentifier() != null)
+ {
+ // if not a root node
+
+ // remove from CHILD_NODES of parent
+ cache.removeNode(makeChildFqn(childNodes, item.getParentIdentifier(), item.getQPath().getEntries()[item
+ .getQPath().getEntries().length - 1]));
+
+ // remove from CHILD_NODES_LIST of parent
+ cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
+
+ // remove from CHILD_NODES as parent
+ cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
+
+ // remove from CHILD_NODES_LIST as parent
+ cache.removeNode(makeChildListFqn(childNodesList, item.getIdentifier()));
+
+ // remove from CHILD_PROPS as parent
+ cache.removeNode(makeChildListFqn(childProps, item.getIdentifier()));
+
+ // remove from CHILD_PROPS_LIST as parent
+ cache.removeNode(makeChildListFqn(childPropsList, item.getIdentifier()));
+ }
+ }
+ else
+ {
+ // remove from CHILD_PROPS
+ cache.removeNode(makeChildFqn(childProps, item.getParentIdentifier(), item.getQPath().getEntries()[item
+ .getQPath().getEntries().length - 1]));
+
+ // remove from CHILD_PROPS_LIST
+ cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
+ .getIdentifier());
+ }
+ // remove from ITEMS
+ cache.removeNode(makeItemFqn(item.getIdentifier()));
+ }
+
+ /**
+ * Update Node's mixin and ACL.
+ *
+ * @param node NodeData
+ */
+ protected void updateMixin(NodeData node)
+ {
+ NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
+ if (prevData != null)
+ {
+ // do update ACL if needed
+ if (prevData.getACL() == null || !prevData.getACL().equals(node.getACL()))
+ {
+ updateChildsACL(node.getIdentifier(), node.getACL());
+ }
+ }
+ else if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Previous NodeData not found for mixin update " + node.getQPath().getAsString());
+ }
+ }
+
+ /**
+ * Update Node hierachy in case of same-name siblings reorder.
+ * Assumes the new (updated) nodes already putted in the cache. Previous name of updated nodes will be calculated
+ * and that node will be deleted (if has same id as the new node). Childs paths will be updated to a new node path.
+ *
+ * @param node NodeData
+ * @param prevNode NodeData
+ */
+ protected void update(final NodeData node, final NodeData prevNode)
+ {
+ // get previously cached NodeData and using its name remove child on the parent
+ Fqn<String> prevFqn =
+ makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
+ .getEntries().length - 1]);
+ if (node.getIdentifier().equals(cache.get(prevFqn, ITEM_ID)))
+ {
+ // it's same-name siblings re-ordering, delete previous child
+ if (!cache.removeNode(prevFqn) && LOG.isDebugEnabled())
+ {
+ LOG.debug("Node not extists as a child but update asked " + node.getQPath().getAsString());
+ }
+ }
+
+ // update childs paths if index changed
+ int nodeIndex = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getIndex();
+ int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
+ if (nodeIndex != prevNodeIndex)
+ {
+ updateTreePath(node.getIdentifier(), node.getQPath(), null); // don't change ACL, it's same parent
+ }
+ }
+
+ /**
+ * This method duplicate update method, except using getFromBuffer inside.
+ *
+ * @param node NodeData
+ * @param prevNode NodeData
+ */
+ protected void updateInBuffer(final NodeData node, final NodeData prevNode)
+ {
+ // get previously cached NodeData and using its name remove child on the parent
+ Fqn<String> prevFqn =
+ makeChildFqn(childNodes, node.getParentIdentifier(), prevNode.getQPath().getEntries()[prevNode.getQPath()
+ .getEntries().length - 1]);
+ if (node.getIdentifier().equals(cache.getFromBuffer(prevFqn, ITEM_ID)))
+ {
+ // it's same-name siblings re-ordering, delete previous child
+ if (!cache.removeNode(prevFqn) && LOG.isDebugEnabled())
+ {
+ LOG.debug("Node not extists as a child but update asked " + node.getQPath().getAsString());
+ }
+ }
+
+ // update childs paths if index changed
+ int nodeIndex = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1].getIndex();
+ int prevNodeIndex = prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1].getIndex();
+ if (nodeIndex != prevNodeIndex)
+ {
+ // its a samename reordering
+ updateTreePath(prevNode.getQPath(), node.getQPath(), null); // don't change ACL, it's same parent
+ }
+ }
+
+ /**
+ * Check all items in cache - is it descendant of prevRootPath, and update path according newRootPath.
+ *
+ * @param prevRootPath
+ * @param newRootPath
+ * @param acl
+ */
+ protected void updateTreePath(final QPath prevRootPath, final QPath newRootPath, final AccessControlList acl)
+ {
+ boolean inheritACL = acl != null;
+
+ // check all ITEMS in cache
+ Node<Serializable, Object> items = cache.getNode(itemsRoot);
+ Set<Object> childrenNames = items.getChildrenNames();
+ Iterator<Object> namesIt = childrenNames.iterator();
+
+ while (namesIt.hasNext())
+ {
+ String id = (String)namesIt.next();
+ ItemData data = (ItemData)cache.get(makeItemFqn(id), ITEM_DATA);
+
+ // check is this descendant of prevRootPath
+ QPath nodeQPath = data.getQPath();
+ if (nodeQPath.isDescendantOf(prevRootPath))
+ {
+
+ //make relative path
+ QPathEntry[] relativePath = null;
+ try
+ {
+ relativePath = nodeQPath.getRelPath(nodeQPath.getDepth() - prevRootPath.getDepth());
+ }
+ catch (IllegalPathException e)
+ {
+ // Do nothing. Never happens.
+ }
+
+ // make new path - no matter node or property
+ QPath newPath = QPath.makeChildPath(newRootPath, relativePath);
+
+ if (data.isNode())
+ {
+ // update node
+
+ NodeData prevNode = (NodeData)data;
+
+ TransientNodeData newNode =
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
+ .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ // update this node
+ cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
+ }
+ else
+ {
+ //update property
+
+ PropertyData prevProp = (PropertyData)data;
+
+ if (inheritACL
+ && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
+ .equals(Constants.EXO_OWNER)))
+ {
+ inheritACL = false;
+ }
+
+ TransientPropertyData newProp =
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
+ .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
+ }
+ }
+ }
+ }
+
+ /**
+ * Update Nodes tree with new path.
+ *
+ * @param parentId String - root node id of JCR subtree.
+ * @param rootPath QPath
+ * @param acl AccessControlList
+ */
+ protected void updateTreePath(final String parentId, final QPath rootPath, final AccessControlList acl)
+ {
+ boolean inheritACL = acl != null;
+
+ // update properties
+ for (Iterator<PropertyData> iter = new ChildPropertiesIterator<PropertyData>(parentId); iter.hasNext();)
+ {
+ PropertyData prevProp = iter.next();
+
+ if (inheritACL
+ && (prevProp.getQPath().getName().equals(Constants.EXO_PERMISSIONS) || prevProp.getQPath().getName()
+ .equals(Constants.EXO_OWNER)))
+ {
+ inheritACL = false;
+ }
+ // recreate with new path for child Props only
+ QPath newPath =
+ QPath
+ .makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
+ TransientPropertyData newProp =
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
+ .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
+ }
+
+ // update child nodes
+ for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
+ {
+ NodeData prevNode = iter.next();
+ // recreate with new path for child Nodes only
+ QPath newPath =
+ QPath
+ .makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
+ TransientNodeData newNode =
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
+ .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ // update this node
+ cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
+ // update childs recursive
+ updateTreePath(newNode.getIdentifier(), newNode.getQPath(), inheritACL ? acl : null);
+ }
+ }
+
+ /**
+ * Update child Nodes ACLs.
+ *
+ * @param parentId String - root node id of JCR subtree.
+ * @param acl AccessControlList
+ */
+ protected void updateChildsACL(final String parentId, final AccessControlList acl)
+ {
+ for (Iterator<NodeData> iter = new ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
+ {
+ NodeData prevNode = iter.next();
+ // is ACL changes on this node (i.e. ACL inheritance brokes)
+ for (InternalQName mixin : prevNode.getMixinTypeNames())
+ {
+ if (mixin.equals(Constants.EXO_PRIVILEGEABLE) || mixin.equals(Constants.EXO_OWNEABLE))
+ {
+ continue;
+ }
+ }
+ // recreate with new path for child Nodes only
+ TransientNodeData newNode =
+ new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
+ .getParentIdentifier(), acl);
+ // update this node
+ cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
+ // update childs recursive
+ updateChildsACL(newNode.getIdentifier(), acl);
+ }
+ }
+
+ public void beginTransaction()
+ {
+ cache.beginTransaction();
+ }
+
+ public void commitTransaction()
+ {
+ cache.commitTransaction();
+ }
+
+ public void rollbackTransaction()
+ {
+ cache.rollbackTransaction();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTXAware()
+ {
+ return true;
+ }
+
+ /**
+ * <li>NOT_MODIFY - node(property) is not added to the parent's list (no persistent changes performed, cache used as cache)</li>
+ * <li>MODIFY - node(property) is added to the parent's list if parent in the cache (new item is added to persistent, add to list if it is present)</li>
+ * <li>FORCE_MODIFY - node(property) is added to the parent's list anyway (when list is read from DB, forcing write)</li>
+ */
+ private enum ModifyChildOption {
+ NOT_MODIFY, MODIFY, FORCE_MODIFY
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-09-28 09:01:44 UTC (rev 3195)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-09-28 09:21:26 UTC (rev 3196)
@@ -25,7 +25,9 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.NullNodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
@@ -143,7 +145,8 @@
public void testGetItemDataByNodeDataNQPathEntry() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ final NodeData nodeData =
+ new PersistedNodeData("getItemData", new QPath(new QPathEntry[]{}), null, 0, 1, null, null, null);
assertEquals(0, con.getItemDataByNodeDataNQPathEntryCalls.get());
MyTask task = new MyTask()
{
13 years, 7 months
exo-jcr SVN: r3195 - in jcr/trunk/applications: exo.jcr.applications.jetty and 1 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-28 05:01:44 -0400 (Tue, 28 Sep 2010)
New Revision: 3195
Modified:
jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml
jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml
jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml
Log:
EXOJCR-981: remove timestamp from jar names in application bundle
Modified: jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml 2010-09-28 08:03:48 UTC (rev 3194)
+++ jcr/trunk/applications/exo.jcr.applications.backupconsole/src/main/assemblies/binary-assembly.xml 2010-09-28 09:01:44 UTC (rev 3195)
@@ -33,6 +33,7 @@
</files>
<dependencySets>
<dependencySet>
+ <outputFileNameMapping>${artifact.artifactId}-${artifact.baseVersion}.${artifact.extension}</outputFileNameMapping>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<scope>compile</scope>
Modified: jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml 2010-09-28 08:03:48 UTC (rev 3194)
+++ jcr/trunk/applications/exo.jcr.applications.jetty/pom.xml 2010-09-28 09:01:44 UTC (rev 3195)
@@ -93,6 +93,20 @@
<copy todir="${exo.projects.directory.working}/exo-jetty" verbose="false" overwrite="true">
<fileset dir="${exo.projects.directory.dependencies}/${exo.projects.app.jetty.version}" />
</copy>
+ <!-- Removing timestamps from SNAPSHOT jars-->
+ <move todir="${basedir}/target/lib-binary.dir/">
+ <fileset dir="${basedir}/target/lib-binary.dir/">
+ <include name="**/*.jar"/>
+ </fileset>
+ <mapper>
+ <firstmatchmapper>
+ <!-- If a timestamped SNAPSHOT is used -->
+ <regexpmapper from="(.*)-([0-9]+(.[0-9]+)*-(.*))-([0-9]{8}.[0-9]{6})-([0-9]+).jar" to="\1-${project.version}.jar" casesensitive="no"/>
+ <!-- By default keep the name -->
+ <flattenmapper/>
+ </firstmatchmapper>
+ </mapper>
+ </move>
<delete dir="${exo.projects.directory.working}/exo-jetty/etc" includeEmptyDirs="true" quiet="yes" />
<delete dir="${exo.projects.directory.working}/exo-jetty/contexts" includeEmptyDirs="true" quiet="yes" />
<delete dir="${exo.projects.directory.working}/exo-jetty/webapps" includeEmptyDirs="true" quiet="yes" />
Modified: jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml
===================================================================
--- jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml 2010-09-28 08:03:48 UTC (rev 3194)
+++ jcr/trunk/applications/exo.jcr.applications.tomcat/pom.xml 2010-09-28 09:01:44 UTC (rev 3195)
@@ -98,6 +98,20 @@
<copy todir="${exo.projects.directory.working}/exo-tomcat" verbose="false" overwrite="true">
<fileset dir="${exo.projects.directory.dependencies}/${exo.projects.app.tomcat.version}" />
</copy>
+ <!-- Removing timestamps from SNAPSHOT jars-->
+ <move todir="${basedir}/target/lib-binary.dir/">
+ <fileset dir="${basedir}/target/lib-binary.dir/">
+ <include name="**/*.jar"/>
+ </fileset>
+ <mapper>
+ <firstmatchmapper>
+ <!-- If a timestamped SNAPSHOT is used -->
+ <regexpmapper from="(.*)-([0-9]+(.[0-9]+)*-(.*))-([0-9]{8}.[0-9]{6})-([0-9]+).jar" to="\1-${project.version}.jar" casesensitive="no"/>
+ <!-- By default keep the name -->
+ <flattenmapper/>
+ </firstmatchmapper>
+ </mapper>
+ </move>
<copy todir="${exo.projects.directory.working}/exo-tomcat/lib/" verbose="true" overwrite="true">
<fileset dir="${basedir}/target/lib-binary.dir/" excludes="**/*.war" />
</copy>
13 years, 7 months
exo-jcr SVN: r3194 - in jcr/trunk: exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-28 04:03:48 -0400 (Tue, 28 Sep 2010)
New Revision: 3194
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml
Log:
EXOJCR-939: fix doc and comments
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java 2010-09-28 07:19:57 UTC (rev 3193)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java 2010-09-28 08:03:48 UTC (rev 3194)
@@ -46,8 +46,8 @@
protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBCleanerService");
/**
- * Remove workspace data.
- * Tables will be removed in case of multiDB, or only record will be removed in case of singleDb.
+ * Clean workspace data from database.
+ * Tables will be removed in case of multiDB, and only records will be removed in case of singleDB.
*
* @param wsEntry
* workspace configuration
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml 2010-09-28 07:19:57 UTC (rev 3193)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/jcr/db-cleaner-service.xml 2010-09-28 08:03:48 UTC (rev 3194)
@@ -1,128 +1,93 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter id="JCR.DBCleanerService">
- <?dbhtml filename="ch-db-cleaner-service.html"?>
-
- <title>DBCleanerService</title>
-
- <section>
- <title>API</title>
-
- <para>There is two methods of DBCleanerService:</para>
-
- <table>
- <title>API</title>
-
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>public static void removeWorkspaceData(WorkspaceEntry
- wsConfig) </entry>
-
- <entry>If workspace is multiDB - drops JCR_SITEM,JCR_SVALUE,
- JCR_SREF tables, otherwise, it removes all rows of this
- workspace.</entry>
- </row>
-
- <row>
- <entry>public static void removeRepositoryData(RepositoryEntry
- repoConfig)</entry>
-
- <entry>Removes data of all worksapces of this repository.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section>
- <title>How it works</title>
-
- <para>removeWorkspaceData takes workspaces configs from RepositoryEntry
- and clean each workspace using removeRepositoryData.</para>
-
- <para>Lets see removeWorkspaceData in detail:<itemizedlist>
- <listitem>
- <para>at first, it ejects workspace name (aka container name), data
- source of databse, and and deside is workspase multiDB or
- singleDB;</para>
- </listitem>
-
- <listitem>
- <para>than it deside which script must be used to remove (databse
- dialect and isMultiDb used);</para>
- </listitem>
-
- <listitem>
- <para>than this script is parsed to list of queries, and executed in
- order of occurance;</para>
- </listitem>
- </itemizedlist></para>
- </section>
-
- <section>
- <title>Scripts in detail</title>
-
- <para>Single and Multi DB scripts examples</para>
-
- <para>In case of: dbDialect = "MySQL" and isMultiDB="true", will use
- "conf/storage/cleanup/jcr-mjdbc.mysql.sql"</para>
-
- <programlisting>DROP TABLE JCR_MREF;
-DROP TABLE JCR_MVALUE;
-DROP TABLE JCR_MITEM;</programlisting>
-
- <para>In case of: dbDialect = "PgSQL" and isMultiDB="false", will use
- "conf/storage/cleanup/jcr-sjdbc.pgsql.sql"</para>
-
- <programlisting>delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
-delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
-delete from JCR_SITEM where CONTAINER_NAME=?;</programlisting>
-
- <note>
- <para>"?" will be replased with container name on execution.</para>
- </note>
-
- <para>But what is the strage coment is in
- "conf/storage/cleanup/jcr-sjdbc.sql" ?</para>
-
- <programlisting>delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
-delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
-delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?;
-/*$CLEAN_JCR_SITEM_DEFAULT*/;</programlisting>
-
- <para><emphasis role="bold">/*$CLEAN_JCR_SITEM_DEFAULT*/</emphasis> - some
- database may throw constraint violaion exception according to
- JCR_FK_SITEM_PARENT FOREIGN KEY in case of ordinary "" delete from
- JCR_SITEM where CONTAINER_NAME=? query. So there is special method, that
- will be executed on /*$CLEAN_JCR_SITEM_DEFAULT*/. It a bit slowly, but
- safe.</para>
-
- <note>
- <para>"conf/storage/cleanup/jcr-sjdbc.sql" or
- "conf/storage/cleanup/jcr-mjdbc.sql" are used if dialect is not
- recognized.</para>
- </note>
- </section>
-
- <section>
- <title>Few words in addition</title>
-
- <itemizedlist>
- <listitem>
- <para>DBCleanerService is static, so all you need is config to
- execute;</para>
- </listitem>
-
- <listitem>
- <para>code that executes DBCleanerService must have
- JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION;</para>
- </listitem>
-
- <listitem>
- <para>you can update scripts for your needs.</para>
- </listitem>
- </itemizedlist>
- </section>
-</chapter>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="JCR.DBCleanerService">
+ <?dbhtml filename="ch-db-cleaner-service.html"?>
+
+ <title>DBCleanerService</title>
+
+ <section>
+ <title>API</title>
+
+ <para>It is special service for removing data from database.</para>
+
+ <note>
+ <para>Code that invokes methods of DBCleanerService must have
+ JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION permission;</para>
+ </note>
+
+ <para>There are two methods of DBCleanerService:</para>
+
+ <table>
+ <title>API</title>
+
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>public void cleanWorkspaceData(WorkspaceEntry
+ wsEntry)</entry>
+
+ <entry>Clean workspace data from database. Tables will be removed
+ in case of multiDB, and only records will be removed in case of
+ singleDB.</entry>
+ </row>
+
+ <row>
+ <entry>public void cleanRepositoryData(RepositoryEntry
+ repoEntry)</entry>
+
+ <entry>Cleanup repository data from database.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ <section>
+ <title>How it works</title>
+
+ <para>cleanRepositoryData takes workspaces configs from RepositoryEntry
+ and clean each workspace using cleanWorkspaceData method.</para>
+
+ <para>Lets see cleanWorkspaceData in detail:<itemizedlist>
+ <listitem>
+ <para>at first, it resolves container name (workspace name),
+ database dialect, data source and isMultiDB parameter;</para>
+ </listitem>
+
+ <listitem>
+ <para>then based on database dialect creates instanse of database
+ cleaner (implements DBCleaner interface) and invokes clean()
+ method;</para>
+ </listitem>
+ </itemizedlist></para>
+ </section>
+
+ <section>
+ <title>Scripts in detail</title>
+
+ <para>Single and Multi DB scripts examples</para>
+
+ <para>In case of isMultiDB="true", will use:</para>
+
+ <programlisting>DROP TABLE JCR_MREF;
+DROP TABLE JCR_MVALUE;
+DROP TABLE JCR_MITEM;</programlisting>
+
+ <para>In case of isMultiDB="false", will use:</para>
+
+ <programlisting>delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?);
+delete from JCR_SITEM where CONTAINER_NAME=?;</programlisting>
+
+ <note>
+ <para>"?" will be replased with container name on execution.</para>
+ </note>
+
+ <para>But some database do not support cascade delete or need special
+ sittings, so query "delete from JCR_SITEM where CONTAINER_NAME=?" may
+ causes constraint violation exception. In such case will be used deleting
+ like visitor does. First traverse to the bottom of the tree and then go up
+ to the root and perform deleting children. </para>
+ </section>
+</chapter>
13 years, 7 months
exo-jcr SVN: r3193 - jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-28 03:19:57 -0400 (Tue, 28 Sep 2010)
New Revision: 3193
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java
Log:
EXOJCR-939: set svn:keywords for added files
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -22,7 +22,7 @@
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: DBCleanerService.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public interface DBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -18,7 +18,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: DBCleanerException.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class DBCleanerException extends Exception
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -36,7 +36,7 @@
* DBCleanerService deliver tools for clean workspace or repository data from database.
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: DBCleanerService.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public class DBCleanerService
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -20,7 +20,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: HSQLSingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class HSQLSingleDBCleaner extends SingleDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -21,7 +21,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: IngresSQLMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class IngresSQLMultiDBCleaner extends MultiDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -25,7 +25,7 @@
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: IngresSQLDBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public class IngresSQLSingleDBCleaner extends SingleDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -39,7 +39,7 @@
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: JDBCConfiguration.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public class JDBCConfiguration
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -20,7 +20,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: MultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class MultiDBCleaner extends WorkspaceDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -20,7 +20,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: MySQLSingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class MySQLSingleDBCleaner extends SingleDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -22,7 +22,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: OracleMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class OracleMultiDBCleaner extends MultiDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -26,7 +26,7 @@
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: OracleDBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public class OracleSingleDBCleaner extends SingleDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -21,7 +21,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: PgSQLMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class PgSQLMultiDBCleaner extends MultiDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -25,7 +25,7 @@
* <br/>Date:
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: PgSQLDBCLeaner.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public class PgSQLSingleDBCleaner extends SingleDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -22,7 +22,7 @@
/**
* @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
- * @version $Id: SingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ * @version $Id$
*/
public class SingleDBCleaner extends WorkspaceDBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java 2010-09-28 07:19:57 UTC (rev 3193)
@@ -34,7 +34,7 @@
* The goal of this class is removing workspace data from database.
*
* @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: DBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ * @version $Id$
*/
public abstract class WorkspaceDBCleaner implements DBCleaner
{
Property changes on: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java
___________________________________________________________________
Name: svn:keywords
+ Id
13 years, 7 months
exo-jcr SVN: r3192 - in jcr/trunk/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner and 3 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-28 03:16:29 -0400 (Tue, 28 Sep 2010)
New Revision: 3192
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java
Removed:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerException.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/IngresSQLDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/JDBCConfiguration.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/OracleDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/PgSQLDBCleaner.java
jcr/trunk/exo.jcr.component.core/src/main/resources/conf/storage/cleanup/
Modified:
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/util/jdbc/TestDBCleanerService.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java
Log:
EXOJCR-939: refactoring
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleaner.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,433 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
-import org.exoplatform.services.jcr.impl.util.SecurityHelper;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * The goal of this class is remove workspace data from database.
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: DBCleaner.java 111 2008-11-11 11:11:11Z serg $
- */
-public class DBCleaner
-{
- public final String CLEAN_JCR_SITEM_AS_DEFAULT = "/*$CLEAN_JCR_SITEM_DEFAULT*/";
-
- protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBCleaner");
-
- protected final int MAX_IDS_RETURNED = 100;
-
- protected String GET_CHILD_IDS;
-
- protected String REMOVE_ITEMS;
-
- protected final String containerName;
-
- protected final Pattern dbObjectNamePattern;
-
- protected final Connection connection;
-
- protected String[] scripts;
-
- protected final boolean isMultiDB;
-
- /**
- * Constructor.
- *
- * @param containerName - container name (a.k.a workspace name)
- * @param connection - connection to database where workspace tables is placed
- * @param inputStream - inputStream from script file
- * @param isMultiDB - isMultiDB
- * @throws IOException - if exception occures on parsing script file input stream
- */
- public DBCleaner(String containerName, Connection connection, InputStream inputStream, boolean isMultiDB)
- throws IOException
- {
- this.dbObjectNamePattern = Pattern.compile(DBInitializer.SQL_OBJECTNAME, Pattern.CASE_INSENSITIVE);
- this.connection = connection;
- // parse script
- this.scripts = readScriptResource(inputStream);
- this.containerName = containerName;
- this.isMultiDB = isMultiDB;
- prepareQueries();
- }
-
- protected void prepareQueries()
- {
- GET_CHILD_IDS =
- "select ID from JCR_SITEM where CONTAINER_NAME=? and ID not in(select PARENT_ID from JCR_SITEM where CONTAINER_NAME=?)";
-
- REMOVE_ITEMS = "delete from JCR_SITEM where ID in( ? )";
- }
-
- /**
- * Remove workspace data from database.
- * <ul>
- * <li>If workspace uses multiDB data source - tables associated with this workspace
- * will be dropped.
- * <li>If workspace uses singleDB data source - all records of this workspace will
- * be removed.
- * </ul>
- *
- * <p>Connection used by this method will be closed at final.
- *
- * @throws DBCleanerException - if exception during data cleanup occures.
- */
- public void cleanWorkspace() throws DBCleanerException
- {
- SecurityManager security = System.getSecurityManager();
- if (security != null)
- {
- security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
- }
-
- String sql = null;
- Statement st = null;
- try
- {
- connection.setAutoCommit(false);
- st = connection.createStatement();
- for (String scr : scripts)
- {
- String s = cleanWhitespaces(scr.trim());
- if (s.length() > 0)
- {
- if (!canExecuteQuery(connection, sql = s))
- {
- // table from query not found , so try drop other
- continue;
- }
-
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Execute script: \n[" + sql + "]");
- }
- executeQuery(st, sql);
- }
- }
-
- connection.commit();
- }
- catch (SQLException e)
- {
- try
- {
- connection.rollback();
- }
- catch (SQLException rollbackException)
- {
- LOG.error("Can not rollback changes after exception " + e.getMessage(), rollbackException);
- }
- throw new DBCleanerException(e.getMessage(), e);
- }
- finally
- {
- if (st != null)
- {
- try
- {
- st.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the Statement: " + e);
- }
- }
-
- try
- {
- connection.close();
- }
- catch (SQLException e)
- {
- LOG.error("Error of a connection closing. " + e, e);
- }
- }
- }
-
- /**
- * The default implementation of remove rows from JCR_SITEM table.
- * Some database do not support cascade delete, or need special sittings, so
- * query "delete from JCR_SITEM where CONTAINER_NAME=?" may cause constraint violation exception.
- * This method takes a leafs (child nodes/properties) and remove them till, no one record is left.
- *
- * @throws SQLException - SQL exception.
- */
- protected void clearItemsByDefault(Connection connection, String containerName) throws SQLException
- {
- // Remove only child nodes in cycle, till all nodes will be removed.
- // Such algorithm used to avoid any constraint violation exception related to foreign key.
- PreparedStatement getChildItems = null;
- final Statement removeItems = connection.createStatement();
-
- try
- {
- getChildItems = connection.prepareStatement(GET_CHILD_IDS);
- getChildItems.setString(1, containerName);
- getChildItems.setString(2, containerName);
-
- getChildItems.setMaxRows(MAX_IDS_RETURNED);
-
- do
- {
- final PreparedStatement getChildIds = getChildItems;
- ResultSet result =
- (ResultSet)SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- return getChildIds.executeQuery();
- }
- });
-
- StringBuilder childListBuilder = new StringBuilder();
- if (result.next())
- {
- childListBuilder.append("'" + result.getString(1) + "'");
- }
- else
- {
- break;
- }
- while (result.next())
- {
- childListBuilder.append(" , '" + result.getString(1) + "'");
- }
- // now remove nodes;
- final String q = REMOVE_ITEMS.replace("?", childListBuilder.toString());
- SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- removeItems.executeUpdate(q);
- return null;
- }
- });
- }
- while (true);
- }
- finally
- {
- if (getChildItems != null)
- {
- getChildItems.close();
- getChildItems = null;
- }
- if (removeItems != null)
- {
- removeItems.close();
- }
- }
- }
-
- /**
- * Check can we safely execute query.
- * If tables used in query does not exists ,we can not execute query.
- */
- protected boolean canExecuteQuery(Connection conn, String sql) throws SQLException
- {
- if (!isMultiDB && sql.equalsIgnoreCase(CLEAN_JCR_SITEM_AS_DEFAULT))
- {
- // check queries used in clearItemsByDefault
- if (!canExecuteQuery(conn, GET_CHILD_IDS))
- {
- return false;
- }
- if (!canExecuteQuery(conn, REMOVE_ITEMS))
- {
- return false;
- }
- return true;
- }
- else
- {
- Matcher tMatcher = dbObjectNamePattern.matcher(sql);
- while (tMatcher.find())
- {
- // got table name
- String tableName = sql.substring(tMatcher.start(), tMatcher.end());
- if (!isTableExists(conn, tableName))
- {
- LOG.error("Table [" + tableName + "] from query [" + sql
- + "] was not found. So query will not be executed , but will try execute next one.");
- return false;
- }
- }
- return true;
- }
- }
-
- /**
- * Cleans redundant whitespaces from query.
- */
- protected String cleanWhitespaces(String string)
- {
- if (string != null)
- {
- char[] cc = string.toCharArray();
- for (int ci = cc.length - 1; ci > 0; ci--)
- {
- if (Character.isWhitespace(cc[ci]))
- {
- cc[ci] = ' ';
- }
- }
- return new String(cc);
- }
- return string;
- }
-
- /**
- * Execute query.
- */
- protected void executeQuery(final Statement statement, String sql) throws SQLException
- {
- if (!isMultiDB && sql.equalsIgnoreCase(CLEAN_JCR_SITEM_AS_DEFAULT))
- {
- clearItemsByDefault(statement.getConnection(), containerName);
- }
- else
- {
- // in case of singleDB query - check query for "?" mask and replace it with containerName
- final String q = (containerName != null) ? sql.replace("?", "'" + containerName + "'") : sql;
- //super.executeQuery(statement, q);
- SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
- {
- public Object run() throws Exception
- {
- statement.executeUpdate(q);
- return null;
- }
- });
- }
- }
-
- protected boolean isTableExists(Connection conn, String tableName) throws SQLException
- {
- ResultSet trs = conn.getMetaData().getTables(null, null, tableName, null);
- try
- {
- boolean res = false;
- while (trs.next())
- {
- res = true; // check for columns/table type matching etc.
- }
- return res;
- }
- finally
- {
- try
- {
- trs.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the ResultSet: " + e);
- }
- }
- }
-
- /**
- * Extracts SQL queries from script file input stream.
- */
- protected String[] readScriptResource(final InputStream is) throws IOException
- {
- //extract string
- PrivilegedAction<InputStreamReader> actionGetReader = new PrivilegedAction<InputStreamReader>()
- {
- public InputStreamReader run()
- {
- return new InputStreamReader(is);
- }
- };
- InputStreamReader isr = AccessController.doPrivileged(actionGetReader);
-
- String script = null;
- try
- {
- StringBuilder sbuff = new StringBuilder();
- char[] buff = new char[is.available()];
- int r = 0;
- while ((r = isr.read(buff)) > 0)
- {
- sbuff.append(buff, 0, r);
- }
-
- script = sbuff.toString();
- }
- finally
- {
- try
- {
- is.close();
- }
- catch (IOException e)
- {
- }
- }
-
- // parse scripts
- String[] scripts = null;
- if (script.startsWith(DBInitializer.SQL_DELIMITER_COMMENT_PREFIX))
- {
- // read custom prefix
- try
- {
- String s = script.substring(DBInitializer.SQL_DELIMITER_COMMENT_PREFIX.length());
- int endOfDelimIndex = s.indexOf("*/");
- String delim = s.substring(0, endOfDelimIndex).trim();
- s = s.substring(endOfDelimIndex + 2).trim();
- scripts = s.split(delim);
- }
- catch (IndexOutOfBoundsException e)
- {
- LOG.warn("Error of parse SQL-script file. Invalid DELIMITER configuration. Valid format is '"
- + DBInitializer.SQL_DELIMITER_COMMENT_PREFIX
- + "XXX*/' at begin of the SQL-script file, where XXX - DELIMITER string." + " Spaces will be trimed. ",
- e);
- LOG.info("Using DELIMITER:[" + DBInitializer.SQL_DELIMITER + "]");
- scripts = script.split(DBInitializer.SQL_DELIMITER);
- }
- }
- else
- {
- scripts = script.split(DBInitializer.SQL_DELIMITER);
- }
- return scripts;
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerException.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerException.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerException.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,9 +0,0 @@
-package org.exoplatform.services.jcr.impl.util.jdbc;
-
-public class DBCleanerException extends Exception
-{
- public DBCleanerException(String message, Throwable e)
- {
- super(message, e);
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/DBCleanerService.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import javax.jcr.RepositoryException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-/**
- * DBCleanerService deliver tools for clean workspace or repository data from database.
- *
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: DBCleanerService.java 111 2008-11-11 11:11:11Z serg $
- */
-public class DBCleanerService
-{
- protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBCleanerService");
-
- /**
- * Remove workspace data.
- * Tables will be removed in case of multiDB, or only record will be removed in case of singleDb.
- *
- * @param wsConfig - workspace configuration.
- * @throws RepositoryConfigurationException - exception on parsing workspace configuration
- * @throws NamingException - exception on parsing workspace configuration or getting DataSource
- * @throws RepositoryException - exception on parsing workspace configuration or data cleanup
- * @throws IOException - exception on parsing workspace configuration
- */
- public static void removeWorkspaceData(WorkspaceEntry wsConfig) throws RepositoryConfigurationException,
- NamingException, RepositoryException, IOException
- {
- JDBCConfiguration wsJDBCConfig = new JDBCConfiguration(wsConfig);
-
- DataSource ds = (DataSource)new InitialContext().lookup(wsJDBCConfig.getDbSourceName());
- Connection conn = null;
- try
- {
- conn =
- ds != null ? ds.getConnection() : (wsJDBCConfig.getDbUserName() != null ? DriverManager.getConnection(
- wsJDBCConfig.getDbUrl(), wsJDBCConfig.getDbUserName(), wsJDBCConfig.getDbPassword()) : DriverManager
- .getConnection(wsJDBCConfig.getDbUrl()));
- }
- catch (SQLException e)
- {
- String err =
- "Error of JDBC connection open. SQLException: " + e.getMessage() + ", SQLState: " + e.getSQLState()
- + ", VendorError: " + e.getErrorCode();
- throw new RepositoryException(err, e);
- }
-
- String dbDialect = wsJDBCConfig.getDbDialect();
- final String sqlPath = getScriptPath(dbDialect, wsJDBCConfig.isMultiDb());
- PrivilegedAction<InputStream> action = new PrivilegedAction<InputStream>()
- {
- public InputStream run()
- {
- return this.getClass().getResourceAsStream(sqlPath);
- }
- };
- InputStream is = AccessController.doPrivileged(action);
-
- DBCleaner cleaner;
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
- {
- LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
- cleaner = new OracleDBCleaner(wsJDBCConfig.getContainerName(), conn, is, wsJDBCConfig.isMultiDb());
- }
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
- {
- cleaner = new OracleDBCleaner(wsJDBCConfig.getContainerName(), conn, is, wsJDBCConfig.isMultiDb());
- }
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
- {
- cleaner = new PgSQLDBCleaner(wsJDBCConfig.getContainerName(), conn, is, wsJDBCConfig.isMultiDb());
- }
- else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
- {
- cleaner = new IngresSQLDBCleaner(wsJDBCConfig.getContainerName(), conn, is, wsJDBCConfig.isMultiDb());
- }
- else
- {
- //use default DBCleaner
- cleaner = new DBCleaner(wsJDBCConfig.getContainerName(), conn, is, wsJDBCConfig.isMultiDb());
- }
-
- // clean workspace
- try
- {
- cleaner.cleanWorkspace();
- }
- catch (DBCleanerException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- }
-
- /**
- * Cleanup repository data from database.
- *
- * @param repoConfig - repository configuration
- * @throws RepositoryConfigurationException - exception on parsing workspace configuration
- * @throws NamingException - exception on parsing workspace configuration or getting DataSource
- * @throws RepositoryException - exception on parsing workspace configuration or data cleanup
- * @throws IOException - exception on parsing workspace configuration
- */
- public static void removeRepositoryData(RepositoryEntry repoConfig) throws RepositoryConfigurationException,
- NamingException, RepositoryException, IOException
- {
- for (WorkspaceEntry wsEntry : repoConfig.getWorkspaceEntries())
- {
- removeWorkspaceData(wsEntry);
- }
- }
-
- /**
- * Make a path to scripts file according to used database dialect.
- * @param dbDialect - database dialect
- * @param multiDb - is multi db
- * @return Path to script file
- */
- private static String getScriptPath(String dbDialect, boolean multiDb)
- {
- String sqlPath = "/conf/storage/cleanup/jcr-" + (multiDb ? "m" : "s");
- if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI)
- {
- LOG.warn(DBConstants.DB_DIALECT_ORACLEOCI + " dialect is experimental!");
- sqlPath = sqlPath + "jdbc.ora.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_ORACLE)
- {
- sqlPath = sqlPath + "jdbc.ora.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
- {
- sqlPath = sqlPath + "jdbc.pgsql.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL)
- {
- sqlPath = sqlPath + "jdbc.mysql.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
- {
- sqlPath = sqlPath + "jdbc.mysql-utf8.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_MSSQL)
- {
- sqlPath = sqlPath + "jdbc.mssql.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2)
- {
- sqlPath = sqlPath + "jdbc.db2.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_DB2V8)
- {
- sqlPath = sqlPath + "jdbc.db2v8.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_SYBASE)
- {
- sqlPath = sqlPath + "jdbc.sybase.sql";
- }
- else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
- {
- sqlPath = sqlPath + "jdbc.sql";
- }
- else
- {
- // generic, DB_HSQLDB
- sqlPath = sqlPath + "jdbc.sql";
- }
- return sqlPath;
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/IngresSQLDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/IngresSQLDBCleaner.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/IngresSQLDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: IngresSQLDBCleaner.java 111 2008-11-11 11:11:11Z serg $
- */
-public class IngresSQLDBCleaner extends DBCleaner
-{
- /**
- * Constructor.
- */
- public IngresSQLDBCleaner(String containerName, Connection connection, InputStream inputStream, boolean isMultiDB)
- throws IOException
- {
- super(containerName, connection, inputStream, isMultiDB);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isTableExists(Connection conn, String tableName) throws SQLException
- {
- return super.isTableExists(conn, tableName.toUpperCase().toLowerCase());
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/JDBCConfiguration.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/JDBCConfiguration.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/JDBCConfiguration.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-import javax.jcr.RepositoryException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: JDBCConfiguration.java 111 2008-11-11 11:11:11Z serg $
- */
-public class JDBCConfiguration
-{
-
- protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JDBCConfiguration");
-
- public final static String SOURCE_NAME = "source-name";
-
- public final static String MULTIDB = "multi-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";
-
- public final static String DB_DRIVER = "driverClassName";
-
- public final static String DB_URL = "url";
-
- public final static String DB_USERNAME = "username";
-
- public final static String DB_PASSWORD = "password";
-
- public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
-
- protected final String containerName;
-
- protected final String dbSourceName;
-
- protected final boolean multiDb;
-
- protected final String dbDriver;
-
- protected final String dbDialect;
-
- protected final String dbUrl;
-
- protected final String dbUserName;
-
- protected final String dbPassword;
-
- public JDBCConfiguration(WorkspaceEntry wsConfig) throws RepositoryConfigurationException, NamingException,
- RepositoryException, IOException
- {
- this.containerName = wsConfig.getName();
- this.multiDb = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
-
- // ------------- Database config ------------------
- String pDbDialect = null;
- try
- {
- pDbDialect = validateDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
- }
- catch (RepositoryConfigurationException e)
- {
- pDbDialect = DBConstants.DB_DIALECT_GENERIC;
- }
-
- 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!
- }
- 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 + "'");
-
- if (pDbDialect == DBConstants.DB_DIALECT_GENERIC || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(pDbDialect))
- {
- // try to detect via JDBC metadata
- Connection jdbcConn = null;
- try
- {
- jdbcConn =
- dbUserName != null ? DriverManager.getConnection(dbUrl, dbUserName, dbPassword) : DriverManager
- .getConnection(dbUrl);
-
- this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
- {
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
- }
- }
- else
- {
- this.dbDialect = pDbDialect;
- }
- }
- else
- {
- this.dbDriver = null;
- this.dbUrl = null;
- this.dbUserName = null;
- this.dbPassword = null;
-
- 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 (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
- {
- // try to detect via JDBC metadata
- DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
- if (ds != null)
- {
- Connection jdbcConn = null;
- try
- {
- jdbcConn = ds.getConnection();
- this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- finally
- {
- if (jdbcConn != null)
- {
- try
- {
- jdbcConn.close();
- }
- catch (SQLException e)
- {
- throw new RepositoryException(e);
- }
- }
- }
- }
- else
- {
- throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
- }
- }
- else
- {
- this.dbDialect = pDbDialect;
- }
- }
- LOG.info("Using a dialect '" + this.dbDialect + "'");
- }
-
- public String getContainerName()
- {
- return containerName;
- }
-
- public String getDbSourceName()
- {
- return dbSourceName;
- }
-
- public boolean isMultiDb()
- {
- return multiDb;
- }
-
- public String getDbDriver()
- {
- return dbDriver;
- }
-
- public String getDbDialect()
- {
- return dbDialect;
- }
-
- public String getDbUrl()
- {
- return dbUrl;
- }
-
- public String getDbUserName()
- {
- return dbUserName;
- }
-
- public String getDbPassword()
- {
- return dbPassword;
- }
-
- protected String validateDialect(String confParam)
- {
- for (String dbType : DBConstants.DB_DIALECTS)
- {
- if (dbType.equalsIgnoreCase(confParam))
- {
- return dbType;
- }
- }
-
- return DBConstants.DB_DIALECT_GENERIC; // by default
- }
-
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/OracleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/OracleDBCleaner.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/OracleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: OracleDBCleaner.java 111 2008-11-11 11:11:11Z serg $
- */
-public class OracleDBCleaner extends DBCleaner
-{
-
- /**
- * Constructor.
- */
- public OracleDBCleaner(String containerName, Connection connection, InputStream inputStream, boolean isMultiDB)
- throws IOException
- {
- super(containerName, connection, inputStream, isMultiDB);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isTableExists(Connection conn, String tableName) throws SQLException
- {
- Statement st = null;
- try
- {
- st = conn.createStatement();
- st.executeUpdate("SELECT 1 FROM " + tableName);
- return true;
- }
- catch (SQLException e)
- {
- // check: ORA-00942: table or view does not exist
- if (e.getMessage().indexOf("ORA-00942") >= 0)
- return false;
- throw e;
- }
- finally
- {
- if (st != null)
- {
- try
- {
- st.close();
- }
- catch (SQLException e)
- {
- LOG.error("Can't close the Statement: " + e);
- }
- }
- }
- }
-}
Deleted: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/PgSQLDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/PgSQLDBCleaner.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/PgSQLDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2003-2010 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.util.jdbc;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: PgSQLDBCLeaner.java 111 2008-11-11 11:11:11Z serg $
- */
-public class PgSQLDBCleaner extends DBCleaner
-{
- /**
- * Constructor.
- */
- public PgSQLDBCleaner(String containerName, Connection connection, InputStream inputStream, boolean isMultiDB)
- throws IOException
- {
- super(containerName, connection, inputStream, isMultiDB);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isTableExists(Connection conn, String tableName) throws SQLException
- {
- return super.isTableExists(conn, tableName.toUpperCase().toLowerCase());
- }
-}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanHelper.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.util.SecurityHelper;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.security.PrivilegedExceptionAction;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class DBCleanHelper
+{
+
+ /**
+ * Logger.
+ */
+ protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBCleanHelper");
+
+ /**
+ * SELECT_ITEMS.
+ */
+ private final String SELECT_ITEMS = "select ID from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ /**
+ * REMOVE_ITEMS.
+ */
+ private final String REMOVE_ITEMS = "delete from JCR_SITEM where I_CLASS=1 and CONTAINER_NAME=? and PARENT_ID=?";
+
+ /**
+ * Container name.
+ */
+ protected final String containerName;
+
+ /**
+ * Connection to database.
+ */
+ protected final Connection connection;
+
+ /**
+ * DBCleanerHelper constructor.
+ */
+ public DBCleanHelper(String containerName, Connection connection)
+ {
+ this.connection = connection;
+ this.containerName = containerName;
+ }
+
+ /**
+ * Removing rows from JCR_SITEM table. Some database do not support cascade delete,
+ * or need special sittings, so query "delete from JCR_SITEM where CONTAINER_NAME=?"
+ * may cause constraint violation exception. In such case will be used deleting like
+ * visitor does. First traverse to the bottom of the tree and then go up to the root
+ * and perform deleting children.
+ *
+ * @throws SQLException
+ * SQL exception.
+ */
+ public void clean() throws DBCleanerException
+ {
+ try
+ {
+ connection.setAutoCommit(false);
+
+ recursiveClean(Constants.ROOT_PARENT_UUID);
+
+ connection.commit();
+ }
+ catch (SQLException e)
+ {
+ try
+ {
+ connection.rollback();
+ }
+ catch (SQLException rollbackException)
+ {
+ LOG.error("Can not rollback changes after exception " + e.getMessage(), rollbackException);
+ }
+ throw new DBCleanerException(e.getMessage(), e);
+ }
+ }
+
+ private void recursiveClean(String parentID) throws SQLException
+ {
+ PreparedStatement selectItems = null;
+ PreparedStatement removeItems = null;
+ ResultSet result = null;
+
+ try
+ {
+ selectItems = connection.prepareStatement(SELECT_ITEMS);
+ selectItems.setString(1, containerName);
+ selectItems.setString(2, parentID);
+
+ final PreparedStatement selectStatement = selectItems;
+ result = (ResultSet)SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ return selectStatement.executeQuery();
+ }
+ });
+
+ // recursive traversing to the bottom of the tree
+ if (result.next())
+ {
+ do
+ {
+ recursiveClean(result.getString(1));
+ }
+ while (result.next());
+
+ // go up to the root and remove all nodes
+ removeItems = connection.prepareStatement(REMOVE_ITEMS);
+ removeItems.setString(1, containerName);
+ removeItems.setString(2, parentID);
+
+ final PreparedStatement deleteStatement = removeItems;
+ SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ deleteStatement.executeUpdate();
+ return null;
+ }
+ });
+ }
+ }
+ finally
+ {
+ if (selectItems != null)
+ {
+ selectItems.close();
+ }
+
+ if (removeItems != null)
+ {
+ removeItems.close();
+ }
+
+ if (result != null)
+ {
+ result.close();
+ }
+ }
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: DBCleanerService.java 111 2008-11-11 11:11:11Z serg $
+ */
+public interface DBCleaner
+{
+
+ /**
+ * Clean data from DB storage.
+ *
+ * @throws DBCleanerException
+ * if any exception is occurred
+ */
+ void clean() throws DBCleanerException;
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerException.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: DBCleanerException.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class DBCleanerException extends Exception
+{
+
+ /**
+ * Constructor DBCleanerException.
+ *
+ * @param message
+ * error message
+ * @param e
+ * caused exception
+ */
+ public DBCleanerException(String message, Exception e)
+ {
+ super(message, e);
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/DBCleanerService.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+/**
+ * DBCleanerService deliver tools for clean workspace or repository data from database.
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: DBCleanerService.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class DBCleanerService
+{
+ /**
+ * Logger.
+ */
+ protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.DBCleanerService");
+
+ /**
+ * Remove workspace data.
+ * Tables will be removed in case of multiDB, or only record will be removed in case of singleDb.
+ *
+ * @param wsEntry
+ * workspace configuration
+ * @throws DBCleanerException
+ * if any exception is occurred
+ */
+ public void cleanWorkspaceData(WorkspaceEntry wsEntry) throws DBCleanerException
+ {
+ String sourceName;
+ try
+ {
+ sourceName = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.SOURCE_NAME);
+ if (sourceName == null)
+ {
+ throw new RepositoryConfigurationException("Parameter " + JDBCWorkspaceDataContainer.SOURCE_NAME
+ + " not found in workspace configuration " + wsEntry.getName());
+ }
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanerException("Can't define " + JDBCWorkspaceDataContainer.SOURCE_NAME + " parameter", e);
+ }
+
+ boolean isMultiDb;
+ try
+ {
+ String multiDb = wsEntry.getContainer().getParameterValue(JDBCWorkspaceDataContainer.MULTIDB);
+ if (multiDb == null)
+ {
+ throw new RepositoryConfigurationException("Parameter " + JDBCWorkspaceDataContainer.MULTIDB
+ + " not found in workspace configuration " + wsEntry.getName());
+ }
+
+ isMultiDb = Boolean.parseBoolean(multiDb);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ throw new DBCleanerException("Can't define " + JDBCWorkspaceDataContainer.MULTIDB + " parameter", e);
+ }
+
+ DataSource ds;
+ try
+ {
+ ds = (DataSource)new InitialContext().lookup(sourceName);
+ }
+ catch (NamingException e)
+ {
+ throw new DBCleanerException("Can't define data source " + sourceName, e);
+ }
+
+ Connection conn = null;
+ try
+ {
+ conn = ds.getConnection();
+ }
+ catch (SQLException e)
+ {
+ throw new DBCleanerException("Can't open JDBC connection", e);
+ }
+
+ String dbDialect;
+ try
+ {
+ dbDialect = DialectDetecter.detect(conn.getMetaData());
+ }
+ catch (SQLException e)
+ {
+ throw new DBCleanerException("Can't define DB dialect", e);
+ }
+
+ DBCleaner dbCleaner;
+ if (isMultiDb)
+ {
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI || dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ {
+ dbCleaner = new OracleMultiDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ {
+ dbCleaner = new PgSQLMultiDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ {
+ dbCleaner = new IngresSQLMultiDBCleaner(wsEntry.getName(), conn);
+ }
+ else
+ {
+ dbCleaner = new MultiDBCleaner(wsEntry.getName(), conn);
+ }
+ }
+ else
+ {
+ if (dbDialect == DBConstants.DB_DIALECT_ORACLEOCI || dbDialect == DBConstants.DB_DIALECT_ORACLE)
+ {
+ dbCleaner = new OracleSingleDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_PGSQL)
+ {
+ dbCleaner = new PgSQLSingleDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_INGRES)
+ {
+ dbCleaner = new IngresSQLSingleDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_HSQLDB)
+ {
+ dbCleaner = new HSQLSingleDBCleaner(wsEntry.getName(), conn);
+ }
+ else if (dbDialect == DBConstants.DB_DIALECT_MYSQL || dbDialect == DBConstants.DB_DIALECT_MYSQL_UTF8)
+ {
+ dbCleaner = new MySQLSingleDBCleaner(wsEntry.getName(), conn);
+ }
+ else
+ {
+ dbCleaner = new SingleDBCleaner(wsEntry.getName(), conn);
+ }
+ }
+
+ // clean data
+ dbCleaner.clean();
+ }
+
+ /**
+ * Cleanup repository data from database.
+ *
+ * @param repoEntry
+ * repository configuration
+ * @throws DBCleanerException
+ * if any exception is occurred
+ */
+ public void cleanRepositoryData(RepositoryEntry repoEntry) throws DBCleanerException
+ {
+ for (WorkspaceEntry wsEntry : repoEntry.getWorkspaceEntries())
+ {
+ cleanWorkspaceData(wsEntry);
+ }
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/HSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: HSQLSingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class HSQLSingleDBCleaner extends SingleDBCleaner
+{
+
+ /**
+ * HSQLSingleDBCleaner constructor.
+ */
+ public HSQLSingleDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection, true);
+
+ this.scripts =
+ new String[]{
+ "delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?"};
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: IngresSQLMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class IngresSQLMultiDBCleaner extends MultiDBCleaner
+{
+
+ /**
+ * IngresSQLMultiDBCleaner constructor.
+ */
+ public IngresSQLMultiDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ return super.isTableExists(conn, tableName.toLowerCase());
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/IngresSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: IngresSQLDBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class IngresSQLSingleDBCleaner extends SingleDBCleaner
+{
+ /**
+ * IngresSQLSingleDBCleaner constructor.
+ */
+ public IngresSQLSingleDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ return super.isTableExists(conn, tableName.toLowerCase());
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/JDBCConfiguration.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,289 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+import javax.jcr.RepositoryException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: JDBCConfiguration.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class JDBCConfiguration
+{
+
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JDBCConfiguration");
+
+ public final static String SOURCE_NAME = "source-name";
+
+ public final static String MULTIDB = "multi-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";
+
+ public final static String DB_DRIVER = "driverClassName";
+
+ public final static String DB_URL = "url";
+
+ public final static String DB_USERNAME = "username";
+
+ public final static String DB_PASSWORD = "password";
+
+ public final static String DB_FORCE_QUERY_HINTS = "force.query.hints";
+
+ protected final String containerName;
+
+ protected final String dbSourceName;
+
+ protected final boolean multiDb;
+
+ protected final String dbDriver;
+
+ protected final String dbDialect;
+
+ protected final String dbUrl;
+
+ protected final String dbUserName;
+
+ protected final String dbPassword;
+
+ public JDBCConfiguration(WorkspaceEntry wsConfig) throws RepositoryConfigurationException, NamingException,
+ RepositoryException, IOException
+ {
+ this.containerName = wsConfig.getName();
+ this.multiDb = Boolean.parseBoolean(wsConfig.getContainer().getParameterValue(MULTIDB));
+
+ // ------------- Database config ------------------
+ String pDbDialect = null;
+ try
+ {
+ pDbDialect = validateDialect(wsConfig.getContainer().getParameterValue(DB_DIALECT));
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ pDbDialect = DBConstants.DB_DIALECT_GENERIC;
+ }
+
+ 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!
+ }
+ 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 + "'");
+
+ if (pDbDialect == DBConstants.DB_DIALECT_GENERIC || DBConstants.DB_DIALECT_AUTO.equalsIgnoreCase(pDbDialect))
+ {
+ // try to detect via JDBC metadata
+ Connection jdbcConn = null;
+ try
+ {
+ jdbcConn =
+ dbUserName != null ? DriverManager.getConnection(dbUrl, dbUserName, dbPassword) : DriverManager
+ .getConnection(dbUrl);
+
+ this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ if (jdbcConn != null)
+ {
+ try
+ {
+ jdbcConn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+ }
+ else
+ {
+ this.dbDialect = pDbDialect;
+ }
+ }
+ else
+ {
+ this.dbDriver = null;
+ this.dbUrl = null;
+ this.dbUserName = null;
+ this.dbPassword = null;
+
+ 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 (pDbDialect == DBConstants.DB_DIALECT_GENERIC)
+ {
+ // try to detect via JDBC metadata
+ DataSource ds = (DataSource)new InitialContext().lookup(dbSourceName);
+ if (ds != null)
+ {
+ Connection jdbcConn = null;
+ try
+ {
+ jdbcConn = ds.getConnection();
+ this.dbDialect = DialectDetecter.detect(jdbcConn.getMetaData());
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ finally
+ {
+ if (jdbcConn != null)
+ {
+ try
+ {
+ jdbcConn.close();
+ }
+ catch (SQLException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+ }
+ }
+ else
+ {
+ throw new RepositoryException("Datasource '" + dbSourceName + "' is not bound in this context.");
+ }
+ }
+ else
+ {
+ this.dbDialect = pDbDialect;
+ }
+ }
+ LOG.info("Using a dialect '" + this.dbDialect + "'");
+ }
+
+ public String getContainerName()
+ {
+ return containerName;
+ }
+
+ public String getDbSourceName()
+ {
+ return dbSourceName;
+ }
+
+ public boolean isMultiDb()
+ {
+ return multiDb;
+ }
+
+ public String getDbDriver()
+ {
+ return dbDriver;
+ }
+
+ public String getDbDialect()
+ {
+ return dbDialect;
+ }
+
+ public String getDbUrl()
+ {
+ return dbUrl;
+ }
+
+ public String getDbUserName()
+ {
+ return dbUserName;
+ }
+
+ public String getDbPassword()
+ {
+ return dbPassword;
+ }
+
+ protected String validateDialect(String confParam)
+ {
+ for (String dbType : DBConstants.DB_DIALECTS)
+ {
+ if (dbType.equalsIgnoreCase(confParam))
+ {
+ return dbType;
+ }
+ }
+
+ return DBConstants.DB_DIALECT_GENERIC; // by default
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: MultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class MultiDBCleaner extends WorkspaceDBCleaner
+{
+
+ /**
+ * MultiDBCleaner constructor.
+ */
+ public MultiDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+
+ this.scripts = new String[]{"DROP TABLE JCR_MREF", "DROP TABLE JCR_MVALUE", "DROP TABLE JCR_MITEM"};
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/MySQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: MySQLSingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class MySQLSingleDBCleaner extends SingleDBCleaner
+{
+
+ /**
+ * MySQLSingleDBCleaner constructor.
+ */
+ public MySQLSingleDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection, true);
+
+ this.scripts =
+ new String[]{
+ "delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SITEM where I_CLASS=2 and CONTAINER_NAME=?"};
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2003-2010 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
+ *
+ */
+package org.exoplatform.services.jcr.impl.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: OracleMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class OracleMultiDBCleaner extends MultiDBCleaner
+{
+
+ /**
+ * Constructor OracleMultiDBCleaner.
+ */
+ public OracleMultiDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ Statement st = null;
+ try
+ {
+ st = conn.createStatement();
+ st.executeUpdate("SELECT 1 FROM " + tableName);
+ return true;
+ }
+ catch (SQLException e)
+ {
+ // check: ORA-00942: table or view does not exist
+ if (e.getMessage().indexOf("ORA-00942") >= 0)
+ return false;
+ throw e;
+ }
+ finally
+ {
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/OracleSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: OracleDBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class OracleSingleDBCleaner extends SingleDBCleaner
+{
+
+ /**
+ * OracleSingleDBCleaner constructor.
+ */
+ public OracleSingleDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ Statement st = null;
+ try
+ {
+ st = conn.createStatement();
+ st.executeUpdate("SELECT 1 FROM " + tableName);
+ return true;
+ }
+ catch (SQLException e)
+ {
+ // check: ORA-00942: table or view does not exist
+ if (e.getMessage().indexOf("ORA-00942") >= 0)
+ return false;
+ throw e;
+ }
+ finally
+ {
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+ }
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLMultiDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: PgSQLMultiDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class PgSQLMultiDBCleaner extends MultiDBCleaner
+{
+
+ /**
+ * Constructor PgSQLMultiDBCleaner.
+ */
+ public PgSQLMultiDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ return super.isTableExists(conn, tableName.toLowerCase());
+ }
+
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/PgSQLSingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date:
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: PgSQLDBCLeaner.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class PgSQLSingleDBCleaner extends SingleDBCleaner
+{
+ /**
+ * PgSQLSingleDBCleaner constructor.
+ */
+ public PgSQLSingleDBCleaner(String containerName, Connection connection)
+ {
+ super(containerName, connection);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ return super.isTableExists(conn, tableName.toLowerCase());
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/SingleDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+/**
+ * @author <a href="mailto:anatoliy.bazko@gmail.com">Anatoliy Bazko</a>
+ * @version $Id: SingleDBCleaner.java 34360 2009-07-22 23:58:59Z tolusha $
+ */
+public class SingleDBCleaner extends WorkspaceDBCleaner
+{
+
+ /**
+ * Indicates if need to use clean helper.
+ */
+ protected final boolean postHelpClean;
+
+ /**
+ * DB clean helper.
+ */
+ protected final DBCleanHelper dbCleanHelper;
+
+ /**
+ * SingleDBCleaner constructor.
+ */
+ public SingleDBCleaner(String containerName, Connection connection)
+ {
+ this(containerName, connection, false);
+ }
+
+ /**
+ * SingleDBCleaner constructor.
+ */
+ public SingleDBCleaner(String containerName, Connection connection, boolean postHelpClean)
+ {
+ super(containerName, connection);
+
+ this.postHelpClean = postHelpClean;
+ this.dbCleanHelper = new DBCleanHelper(containerName, connection);
+ this.scripts =
+ new String[]{
+ "delete from JCR_SVALUE where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SVALUE.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SREF where exists(select * from JCR_SITEM where JCR_SITEM.ID=JCR_SREF.PROPERTY_ID and JCR_SITEM.CONTAINER_NAME=?)",
+ "delete from JCR_SITEM where CONTAINER_NAME=?"};
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void clean() throws DBCleanerException
+ {
+ try
+ {
+ super.clean();
+
+ if (postHelpClean)
+ {
+ dbCleanHelper.clean();
+ }
+ }
+ finally
+ {
+ super.closeConnection();
+ }
+ }
+
+ /**
+ * {@inheritDoc}}
+ */
+ @Override
+ protected void closeConnection()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void executeQuery(Statement statement, String sql) throws SQLException
+ {
+ final String q = (containerName != null) ? sql.replace("?", "'" + containerName + "'") : sql;
+ super.executeQuery(statement, q);
+ }
+}
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/jdbc/cleaner/WorkspaceDBCleaner.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2003-2010 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.util.jdbc.cleaner;
+
+import org.exoplatform.services.jcr.core.security.JCRRuntimePermissions;
+import org.exoplatform.services.jcr.impl.util.SecurityHelper;
+import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.security.PrivilegedExceptionAction;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * The goal of this class is removing workspace data from database.
+ *
+ * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
+ * @version $Id: DBCleaner.java 111 2008-11-11 11:11:11Z serg $
+ */
+public abstract class WorkspaceDBCleaner implements DBCleaner
+{
+ /**
+ * Logger.
+ */
+ protected final static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.WorkspaceDBCleaner");
+
+ /**
+ * Container name.
+ */
+ protected final String containerName;
+
+ /**
+ * Connection to database.
+ */
+ protected final Connection connection;
+
+ /**
+ * SQL scripts for data cleaning.
+ */
+ protected String[] scripts;
+
+ /**
+ * Pattern for JCR tables.
+ */
+ protected final Pattern dbObjectNamePattern;
+
+ /**
+ * WorkspaceDBCleaner constructor.
+ *
+ * @param containerName
+ * container name (workspace name)
+ * @param connection
+ * connection to database where workspace tables is placed
+ */
+ public WorkspaceDBCleaner(String containerName, Connection connection)
+ {
+ this.dbObjectNamePattern = Pattern.compile(DBInitializer.SQL_OBJECTNAME, Pattern.CASE_INSENSITIVE);
+ this.connection = connection;
+ this.containerName = containerName;
+ }
+
+ /**
+ * Remove workspace data from database used specified queries.
+ * <p>Connection used by this method will be closed at final.
+ *
+ * @throws DBCleanerException
+ * if exception during data cleanup occurred
+ */
+ public void clean() throws DBCleanerException
+ {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null)
+ {
+ security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
+ }
+
+ String sql = null;
+ Statement st = null;
+ try
+ {
+ connection.setAutoCommit(false);
+ st = connection.createStatement();
+ for (String scr : scripts)
+ {
+ String s = cleanWhitespaces(scr.trim());
+ if (s.length() > 0)
+ {
+ if (!canExecuteQuery(sql = s))
+ {
+ // table from query not found , so try drop other
+ continue;
+ }
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Execute script: \n[" + sql + "]");
+ }
+ executeQuery(st, sql);
+ }
+ }
+
+ connection.commit();
+ }
+ catch (SQLException e)
+ {
+ try
+ {
+ connection.rollback();
+ }
+ catch (SQLException rollbackException)
+ {
+ LOG.error("Can not rollback changes after exception " + e.getMessage(), rollbackException);
+ }
+ throw new DBCleanerException(e.getMessage(), e);
+ }
+ finally
+ {
+ if (st != null)
+ {
+ try
+ {
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the Statement: " + e);
+ }
+ }
+
+ closeConnection();
+ }
+ }
+
+ /**
+ * Close connection.
+ *
+ * @throws SQLException
+ */
+ protected void closeConnection()
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Error of a connection closing. " + e, e);
+ }
+ }
+
+ /**
+ * Check if we can execute query.
+ * If tables used in query does not exists, we can not execute query.
+ */
+ protected boolean canExecuteQuery(String sql) throws SQLException
+ {
+ Matcher tMatcher = dbObjectNamePattern.matcher(sql);
+ while (tMatcher.find())
+ {
+ // get table name
+ String tableName = sql.substring(tMatcher.start(), tMatcher.end());
+ if (!isTableExists(connection, tableName))
+ {
+ LOG.error("Table [" + tableName + "] from query [" + sql
+ + "] was not found. So query will not be executed.");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Execute query.
+ */
+ protected void executeQuery(final Statement statement, final String sql) throws SQLException
+ {
+ SecurityHelper.doPriviledgedSQLExceptionAction(new PrivilegedExceptionAction<Object>()
+ {
+ public Object run() throws Exception
+ {
+ statement.executeUpdate(sql);
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Indicates if table exists or not.
+ */
+ protected boolean isTableExists(Connection conn, String tableName) throws SQLException
+ {
+ ResultSet trs = conn.getMetaData().getTables(null, null, tableName, null);
+ try
+ {
+ boolean res = false;
+ while (trs.next())
+ {
+ res = true; // check for columns/table type matching etc.
+ }
+ return res;
+ }
+ finally
+ {
+ try
+ {
+ trs.close();
+ }
+ catch (SQLException e)
+ {
+ LOG.error("Can't close the ResultSet: " + e);
+ }
+ }
+ }
+
+ /**
+ * Cleans redundant whitespaces from query.
+ */
+ private String cleanWhitespaces(String string)
+ {
+ if (string != null)
+ {
+ char[] cc = string.toCharArray();
+ for (int ci = cc.length - 1; ci > 0; ci--)
+ {
+ if (Character.isWhitespace(cc[ci]))
+ {
+ cc[ci] = ' ';
+ }
+ }
+ return new String(cc);
+ }
+ return string;
+ }
+
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/util/jdbc/TestDBCleanerService.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/util/jdbc/TestDBCleanerService.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/util/jdbc/TestDBCleanerService.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.exoplatform.services.jcr.impl.util.jdbc.cleaner.DBCleanerService;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.jcr.util.TesterConfigurationHelper;
@@ -69,6 +70,7 @@
wsEntry = (WorkspaceEntry)session.getContainer().getComponentInstanceOfType(WorkspaceEntry.class);
}
+ @Override
public void tearDown() throws Exception
{
// drop any table
@@ -170,7 +172,7 @@
assertTrue(res.next());
// remove repository;
- DBCleanerService.removeRepositoryData(repositoryEntry);
+ new DBCleanerService().cleanRepositoryData(repositoryEntry);
// check - does JCR_SITEM become empty
try
@@ -213,7 +215,7 @@
assertTrue(res.next());
// remove repository content
- DBCleanerService.removeRepositoryData(repositoryEntry);
+ new DBCleanerService().cleanRepositoryData(repositoryEntry);
// check - does JCR_SITEM become empty
res = statement.executeQuery("select * from JCR_SITEM where ID='" + wsName + id + "'");
@@ -249,7 +251,7 @@
assertTrue(res.next());
// remove workspace data from database
- DBCleanerService.removeWorkspaceData(repositoryEntry.getWorkspaceEntries().get(0));
+ new DBCleanerService().cleanWorkspaceData(repositoryEntry.getWorkspaceEntries().get(0));
// check - does JCR_SITEM become empty
try
@@ -306,7 +308,7 @@
assertTrue(res.next());
// remove workspace data from database
- DBCleanerService.removeWorkspaceData(workspaceEntry);
+ new DBCleanerService().cleanWorkspaceData(workspaceEntry);
// check - does JCR_SITEM become empty
res = statement.executeQuery("select * from JCR_SITEM where ID='" + workspaceEntry.getName() + id + "'");
@@ -328,8 +330,8 @@
repositoryEntry.setDefaultWorkspaceName(repositoryName + "ws");
WorkspaceEntry workspaceEntry =
- helper.getNewWs(repositoryName + "ws", true, DS_NAME, "target/temp/values/" + IdGenerator.generate(), wsEntry
- .getContainer(), false);
+ helper.getNewWs(repositoryName + "ws", true, DS_NAME, "target/temp/values/" + IdGenerator.generate(),
+ wsEntry.getContainer(), false);
repositoryEntry.addWorkspace(workspaceEntry);
@@ -351,8 +353,8 @@
repositoryEntry.setDefaultWorkspaceName(repositoryName + "ws");
WorkspaceEntry workspaceEntry =
- helper.getNewWs(repositoryName + "ws", false, DS_NAME, "target/temp/values/" + IdGenerator.generate(), wsEntry
- .getContainer(), false);
+ helper.getNewWs(repositoryName + "ws", false, DS_NAME, "target/temp/values/" + IdGenerator.generate(),
+ wsEntry.getContainer(), false);
repositoryEntry.addWorkspace(workspaceEntry);
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java 2010-09-27 09:20:22 UTC (rev 3191)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/util/TesterConfigurationHelper.java 2010-09-28 07:16:29 UTC (rev 3192)
@@ -134,7 +134,7 @@
List params = new ArrayList();
- params.add(new SimpleParameterEntry("sourceName", dsName));
+ params.add(new SimpleParameterEntry("source-name", dsName));
params.add(new SimpleParameterEntry("db-type", "generic"));
params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
params.add(new SimpleParameterEntry("update-storage", "true"));
13 years, 7 months
exo-jcr SVN: r3191 - jcr/tags/1.14.0-Beta02.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-27 05:20:22 -0400 (Mon, 27 Sep 2010)
New Revision: 3191
Added:
jcr/tags/1.14.0-Beta02/readme.txt
Log:
EXOJCR-959: add release notes
Added: jcr/tags/1.14.0-Beta02/readme.txt
===================================================================
--- jcr/tags/1.14.0-Beta02/readme.txt (rev 0)
+++ jcr/tags/1.14.0-Beta02/readme.txt 2010-09-27 09:20:22 UTC (rev 3191)
@@ -0,0 +1,452 @@
+JCR 1.14.0-Beta02 release notes
+===========================
+
+eXoPlatform Java Content Repository (JSR-170) implementation and Extension services with clustering support.
+
+Features of 1.14.0-Beta02
+
+- Jetty support
+- Apache Tika support
+- MS Office 2007 content and meta data extraction support
+- Management "dav:isreadonly" property to control behavior of Microsoft Webfolders extension
+- Moving file(s) between workspaces through FTP
+- Decouple event name from listener name in ListenerService
+- One JBC cache instance per PortalContainer/StandaloneContainer
+- Determination property type and is multi parameter during import
+- Allow to disable a given PortalContainer
+- JobSchedulerServiceImpl support multi portal containers
+- JobSchedulerServiceImpl avoids launching jobs that rely on non started services in JBoss AS
+
+Changes of 1.14.0-Beta02
+====================
+
+Bug
+ * [EXOJCR-688] - Some entries in the eXo JCR cache are not evicted properly
+ * [EXOJCR-843] - Exceptions after importing file with version history
+ * [EXOJCR-849] - "Permission denied" on client side, when trying to move file(s) to another workspace through FTP
+ * [EXOJCR-856] - Problems while recopying same files via webdav
+ * [EXOJCR-865] - Data corrupt after restore a node which has been imported with version history
+ * [EXOJCR-878] - WebDAV doesn't work with nt:file
+ * [EXOJCR-879] - TestCaching.testNotModifiedSince failed in same cases
+ * [EXOJCR-882] - TestCaching fails on Windows XP SP 2 with Russian locale
+ * [EXOJCR-888] - The problems with restore version node
+ * [EXOJCR-890] - JSON framework don't work with beans created in groovy
+ * [EXOJCR-891] - Snaphosts IDs make the applications build improperly
+ * [EXOJCR-897] - Add registration required node types in single DB confg for test TestImport.
+ * [EXOJCR-908] - Used wrong delimiter during parsing permission value
+ * [EXOJCR-909] - In LDAPService, InitialContext is not safely closed in authenticate method
+ * [EXOJCR-912] - Unable to convert the JCR documentation to pdf
+ * [EXOJCR-916] - Duplicate instantiation of some services
+ * [EXOJCR-921] - Workspace.copy(srcWS, srcAbsPath, destAbsPath) can not copy root child to another workspace root child
+ * [EXOJCR-922] - MapResourceBundle.resolveDependencies() throw java.lang.StackOverflowError
+ * [EXOJCR-924] - Unable to coerce 'Event' into a LONG: java.lang.NumberFormatException: For input string: "Event"
+ * [EXOJCR-933] - Determine property type from nodetype definition in DocumentViewImport for version history.
+ * [EXOJCR-936] - Avoid converting binary value to String in tests
+ * [EXOJCR-954] - Can't get property of a node if it has a child node with the same name with the property
+ * [EXOJCR-964] - User logged-out and cannot login after some inactivity
+
+Feature Request
+ * [EXOJCR-749] - Make eXo JCR rely on Apache Tika
+ * [EXOJCR-771] - Jetty Support
+ * [EXOJCR-776] - Implement the method toString for the main classes of JCR for debugging purpose
+ * [EXOJCR-842] - Allow to disable a given PortalContainer
+ * [EXOJCR-880] - Determine property is multi or single value from nodetype definition in import.
+ * [EXOJCR-886] - Update the document handler to manage MS Office 2007 meta data extraction (docx, ...)
+ * [EXOJCR-934] - Decouple event name from listener name in ListenerService.
+ * [EXOJCR-935] - Add "dav:isreadonly" property management
+ * [EXOJCR-942] - Reply on JBC regions to avoid having too many JBC instances
+ * [EXOJCR-943] - Make JBC implementation of eXo Cache replies on JBC regions to avoid having too many JBC instances
+ * [EXOJCR-950] - Prevent the JobSchedulerServiceImpl to launch jobs that rely on non started services in JBoss AS
+ * [EXOJCR-951] - Make the JobSchedulerServiceImpl support multi portal containers
+
+Task
+ * [EXOJCR-752] - Avoid to load into the memory the full content of a document while extracting the metadata and the text content
+ * [EXOJCR-755] - Study the extensibility of Apache Tika
+ * [EXOJCR-910] - Resynchronize the doc of JCR 1.12 with the trunk
+ * [EXOJCR-917] - core.packaging.module.js error when in deploy phase
+ * [EXOJCR-919] - maxVolatileTime should be checked on checkFlush()
+ * [EXOJCR-927] - Add "application/x-groovy+html" to HTMLDocumentReader and "application/x-jaxrs+groovy" to TextPlainDocumentReader
+ * [EXOJCR-957] - Remove organization nodetypes from projects where it not used
+ * [EXOJCR-962] - [DOC]Make JBC implementation of eXo Cache replies on JBC regions to avoid having too many JBC instances
+
+Sub-task
+ * [EXOJCR-892] - Remove Fake Chapters
+ * [EXOJCR-893] - Apply the structure of PLF
+ * [EXOJCR-940] - Created special method for remove workspace without checking of system workspace
+ * [EXOJCR-941] - Create special method for remove repository without checking of default-repository
+
+
+Changes of 1.14.0-Beta01
+====================
+
+Bug
+ * [EXOJCR-564] - Cannot use the old Hibernate org service in Gate In
+ * [EXOJCR-570] - AddNamespacePlugin registers namespaces after repostiory start
+ * [EXOJCR-638] - get mixin types through the NodeTypeUtil class
+ * [EXOJCR-662] - Processing SQLException may cause infinite loop.
+ * [EXOJCR-667] - Temporary spooled file can be not found on save
+ * [EXOJCR-698] - URL encoding in SEARCH and PROPFIND responces differs.
+ * [EXOJCR-699] - DAILY TESTS are going too long
+ * [EXOJCR-713] - org.exoplatform.services.rest.impl.RequestDispatcher must return readable messages if resource not found or HTTP method is not allowed for resource
+ * [EXOJCR-754] - JDBC Statements left open : Use of Datasources instead of DBCP and C3P0 pools
+ * [EXOJCR-763] - Reordering samename sibling nodes does not update path of child nodes
+ * [EXOJCR-766] - QPath isDescendantOf returns wrong result on samename siblings
+ * [EXOJCR-768] - A session should not be useable after a logout
+ * [EXOJCR-774] - If-Modified-Since doesn't seem to be well managed in the Wevdav Component
+ * [EXOJCR-781] - LockManagerImpl should call InitialContextInitializer.recall
+ * [EXOJCR-784] - DOC : wrong examples in profiles section
+ * [EXOJCR-785] - Parameter maxVolatileTime is not working correctly
+ * [EXOJCR-788] - Inconsistency issue cans occur on default portal container parameters
+ * [EXOJCR-794] - Field "CONFIG" in the table "JCR_CONFIG" is too short on MySql
+ * [EXOJCR-795] - Unexpected behavior of the method PortalContainer.isScopeValid()
+ * [EXOJCR-796] - Data corruption
+ * [EXOJCR-804] - "No such file or directory" exception for value storage when using MySQL or Postgres DB in WCM demo 2.0
+ * [EXOJCR-805] - Can not search user with keyword that contain special character
+ * [EXOJCR-806] - Problems while copying "ftp-ftp"
+ * [EXOJCR-810] - TestRemoveFromValueStorage failed in configuration without ValueStorage
+ * [EXOJCR-812] - InitialContextBinder.bind should be thread-safe
+ * [EXOJCR-813] - ItemImpl.getParent method must return session pooled parent
+ * [EXOJCR-817] - max-buffer-size from configuration should be use to TransientValueData in import (docview and sysview)
+ * [EXOJCR-819] - HTTPBackupAgent doesn't provide information about last successfully restored repositories if restore was launched in synchronous mode
+ * [EXOJCR-825] - Problems with functional testing - multi, value-storage is turned off
+ * [EXOJCR-835] - TestMultiDbJDBCConnection and TestSingleDbJDBCConnection must drop also JCR_xCONTAINER table on tearDown
+ * [EXOJCR-837] - FUNCTIONAL testing jcr.ext - TestBackupManager in error
+ * [EXOJCR-840] - java.util.ConcurrentModificationException on org.exoplatform.services.jcr.ext.hierarchy.impl.NewUserListener.processUserStructure
+ * [EXOJCR-844] - JCR inside application server is not started due to missing component
+ * [EXOJCR-857] - Exception during PROPFIND request if some property content "%" and after not hex chracters
+ * [EXOJCR-859] - Random failed tests during building jcr
+
+Feature Request
+ * [EXOJCR-156] - Disable deleting of the workspace which is set as system
+ * [EXOJCR-157] - Disable deleting of the repository which is set as default
+ * [EXOJCR-190] - Support returning directly Collection<T> for MediaType.APPLICATION_JSON
+ * [EXOJCR-230] - Refactore and move in main part of exo.ws.rest.core project class AbstractResourceTest
+ * [EXOJCR-311] - Make broadcasting of events of ListenerService asynchronous
+ * [EXOJCR-420] - Check if the ItemReferencePool of the SessionDataManager can be implemented with WeakValueHashMap instead of a WeakHashMap
+ * [EXOJCR-482] - Be able to load a class stored in another groovy file
+ * [EXOJCR-498] - Provide more details when a JCR query is invalid
+ * [EXOJCR-517] - filter to authenticate a signed request from gadgets
+ * [EXOJCR-609] - Allow to keep missing values into the JCR Cache
+ * [EXOJCR-626] - H2 Database support
+ * [EXOJCR-634] - Upload of a file with special characters like " ' " in filename is not supported by the FTPservice
+ * [EXOJCR-635] - Avoid unneccesary checks in persistence
+ * [EXOJCR-745] - Allow cascading imports in configuration files
+ * [EXOJCR-750] - JCR path management improvement
+ * [EXOJCR-782] - No longer force extension developers to redefine the whole dependencies list
+ * [EXOJCR-786] - The method that registers plugins should be overloadable
+ * [EXOJCR-793] - Make possible to configure permissions for Groovy REST services when the SecurityManager is instaled
+ * [EXOJCR-797] - Unable see error message from ProxyService if remote server does not provide Content-Type header.
+ * [EXOJCR-822] - Make implementation of MethodInvokerFilter which can disable access to methods of RESTful services to any users except services deployer
+ * [EXOJCR-823] - Make possible to provide optional attributes for RESTful resources
+ * [EXOJCR-824] - Make expiring mechanism for temporary "under development" services
+ * [EXOJCR-864] - Add method GroovyScript2RestLoader.load with the same signature as it is in 1.12.x
+
+Patch
+ * [EXOJCR-772] - SharedStateLoginModule does swallow an exception during login phase
+
+Task
+ * [EXOJCR-392] - Siblings reordering may update not all the child-items in cache
+ * [EXOJCR-542] - Improve error message concerning a missing "Query Manager Factory"
+ * [EXOJCR-618] - BufferedJBossCache Optimisation: research how to use internal ChangeList as non-persistent cache inside opened transaction
+ * [EXOJCR-689] - Standartize eXo JCR docnmentation projects description.
+ * [EXOJCR-691] - Fix your missing dependencies
+ * [EXOJCR-746] - Remove CommunicationService
+ * [EXOJCR-756] - Make JCR core work properly when the Security Manager is installed
+ * [EXOJCR-764] - Fix the security issue about the JCR System Session
+ * [EXOJCR-767] - Prevent unauthorized access to the method ConversationState.setCurrent(ConverstionState state)
+ * [EXOJCR-770] - Prevent modification of user's identity without required permissions
+ * [EXOJCR-775] - Rework RESTRegistryService for using current repository only. Rewove repository name from PathParam.
+ * [EXOJCR-777] - Prevent modifications of ConversationState's attributes without required permissions
+ * [EXOJCR-778] - Protect the main methods of a repository since they are critical
+ * [EXOJCR-779] - Provide current ConversationState for anonymous user also.
+ * [EXOJCR-780] - Move org.exoplatform.services.jcr.access.SystemIdentity class from exo.jcr.core exo.kernel or exo.core
+ * [EXOJCR-783] - Use cached table for HSLQLDB tables
+ * [EXOJCR-791] - SwapFile and SpoolFile tests
+ * [EXOJCR-807] - Port the article Groovy Scripts as REST Services
+ * [EXOJCR-808] - For Sybase DB "check-sns-new-connection" should be set to false by default
+ * [EXOJCR-809] - OrganizationService's tests should not be excluded
+ * [EXOJCR-815] - Document how to use AS Managed DataSource
+ * [EXOJCR-845] - Remove exo:audit* nodetypes from configuration.
+
+Sub-task
+ * [EXOJCR-627] - Investigate use of in-memory databases for in-memory JCR
+ * [EXOJCR-742] - Port Workspace Data Container articles into docbook
+ * [EXOJCR-757] - Training on Java Security
+ * [EXOJCR-758] - Implement it
+ * [EXOJCR-759] - Test it
+ * [EXOJCR-790] - OS depended paths in policy files for tests.
+ * [EXOJCR-798] - Cluster testing security support
+ * [EXOJCR-799] - MySQL & PostgreSQL tesing problem with security enabled
+ * [EXOJCR-851] - Searching users with special characters in name does not work properly
+ * [EXOJCR-862] - Check Property.getStream() method
+ * [EXOJCR-863] - Check VersionHistory.removeVersionLabel() & VersionHistory.addVersionLabel()
+
+
+
+Changes of 1.12.2-GA
+====================
+
+Bug
+ * [EXOJCR-497] - JCR serialization test wrong logic with CASable storage
+ * [EXOJCR-730] - Restored repository not accessible after restart Tomcat
+ * [EXOJCR-731] - Deploy error (500 - Unexpected error. null) of REST Service with annotation inheritance.
+ * [EXOJCR-735] - JCR repositories created in runtime is not available after eXo Social restart
+ * [EXOJCR-736] - Problems with anonymous entrance on FTP and NPE
+ * [EXOJCR-743] - InitialContextBinder bind twice same datasource in some case
+ * [EXOJCR-762] - Check whether the repository with the given name doesn't exists before starting restore from backup
+
+Feature Request
+ * [EXOJCR-640] - Migrate to newer version of Apache PDFBox ( and FontBox ) if possible;
+
+Task
+ * [EXOJCR-596] - Upload eXoJCR documentation on jboss.org
+ * [EXOJCR-668] - Validate format of the default values of the property definition during the nodetype registration
+ * [EXOJCR-738] - Search does not work with source in CDATA tag in XML document
+ * [EXOJCR-740] - Constrains ranges are not used in NodeTypeImpl.canSetProperty() validation
+ * [EXOJCR-741] - Backupconsole build improvements
+ * [EXOJCR-765] - Use StringBuilder instead of String concatenation in MSExcelDocumentReader.getContentAsText
+ * [EXOJCR-681] - Decreasing perfomance while running WebdavReadWriteTest tests several times in row
+
+
+
+Changes of 1.12.2-CR1
+=====================
+
+Bug
+ * [EXOJCR-175] - Problems with HTTPBackupAgent - Cyrillic symbols aren't showing after restore
+ * [EXOJCR-683] - java.io.IOException: Socket read failed on heavy loaded WebdavAddBLOBTest benchmark test
+ * [EXOJCR-697] - SQL search by date doesn't work
+ * [EXOJCR-698] - URL encoding in SEARCH and PROPFIND responces differs.
+ * [EXOJCR-700] - Problem in user search with MySql and PostgresDB
+ * [EXOJCR-704] - JCR testuite hangs on sybase
+ * [EXOJCR-708] - Problem with full text searching in text files with non-latin content.
+ * [EXOJCR-712] - Concurrent service creation leads to duplicate service instantiation
+ * [EXOJCR-724] - Bad URL in the error message when a component cannot be instantiated
+ * [EXOJCR-726] - Improper conversion of jboss.server.config.url system property value into File (spaces in filename problem)
+ * [EXOJCR-729] - The FileNotFoundException in restore workspace over BackupWorkspaceinitializer
+ * [EXOJCR-734] - The binary values was not stored in incremental backup.
+
+Feature Request
+ * [EXOJCR-705] - Expose listeners in OrganizationService
+ * [EXOJCR-707] - Check repository management operations on thread safety
+ * [EXOJCR-718] - Allow to get the complete configuration at runtime
+ * [EXOJCR-719] - Better debugging of components loaded
+ * [EXOJCR-721] - Add possibility to use customized GroovyClassLoader in org.exoplatform.services.script.groovy.GroovyScriptInstantiator
+ * [EXOJCR-722] - Make it possible to use other then org.exoplatform.services.rest.impl.method.DefaultMethodInvoker
+
+Task
+ * [EXOJCR-354] - Invoke post read after permissions check
+ * [EXOJCR-663] - Make possibility extends classes RequestDispatcher and ResourceBinder.
+ * [EXOJCR-691] - Fix your missing dependencies
+ * [EXOJCR-692] - Find the reason why the method of type Node.hasNodes is much slower since beta5
+ * [EXOJCR-694] - Change JBC dependencies to use 3.2.4.GA
+ * [EXOJCR-696] - Reduce the concurrency Level in the JBoss Cache Config
+ * [EXOJCR-711] - Misleading error message appears when the external settings cannot be found
+ * [EXOJCR-714] - Improve the usability of the ContainerLifecyclePlugin
+ * [EXOJCR-715] - Ensure that the ExoContainer is fully ThreadSafe
+ * [EXOJCR-716] - Prevent the JobSchedulerServiceImpl to launch jobs that rely on non started services
+ * [EXOJCR-717] - Add to RestRegistryService method without repositoryName in PathParam, insted use current repository. Methods with repositoryName in PathParam marks as Deprecated.
+ * [EXOJCR-720] - Make possibility extends classe GroovyScript2RestLoader
+ * [EXOJCR-723] - JCR Statistics: Describe the arguments of the methods exposed through JMX
+ * [EXOJCR-728] - implementing RequestLifecycle for REST services
+
+
+Changes of 1.12.1-GA
+=====================
+
+Bug
+ * [EXOJCR-612] - JBoss Cache Implementation for the Cache Service test TestAbstractExoCache fails
+ * [EXOJCR-638] - get mixin types through the NodeTypeUtil class
+ * [EXOJCR-661] - Cannot access to the MBeans through the JConsole in Standalone mode
+ * [EXOJCR-662] - Processing SQLException may cause infinite loop.
+ * [EXOJCR-664] - org.exoplatform.services.jcr.impl.storage.value.fs.TestFileIOChannel.testConcurrentRead fail with MSSQL and DB2
+ * [EXOJCR-667] - Temporary spooled file can be not found on save
+ * [EXOJCR-671] - ConcurrentModificationException in FileCleaner with heavy load
+ * [EXOJCR-672] - An eXoCache clear should be local
+ * [EXOJCR-687] - Some JCR parameters that are time parameter are retrieved as number instead of time
+
+Feature Request
+ * [EXOJCR-498] - Provide more details when a JCR query is invalid
+ * [EXOJCR-634] - Upload of a file with special characters like " ' " in filename is not supported by the FTPservice
+ * [EXOJCR-645] - Add ExtHttpHeaders.JAXRS_BODY_PROVIDED header for unhandled exception in REST services and set error message to body responce
+
+Task
+ * [EXOJCR-578] - Use Fisheye in SCM urls used in maven
+ * [EXOJCR-611] - Provide a way to collect statistics around the JCR API accesses
+ * [EXOJCR-639] - Find the reason why the methods of type Property.setValue are much slower since beta5
+ * [EXOJCR-685] - Change JBC dependencies to use 3.2.3.GA
+ * [EXOJCR-689] - Standartize eXo JCR docnmentation projects description.
+ * [EXOJCR-690] - Apply changes in the eXo JCR project in order to be able to publish artifacts in the nexus of JBoss
+ * [EXOJCR-545] - Checking performance on SearchNodesByPropertyTest
+ * [EXOJCR-643] - Improve the performances of the lucene indexing in a cluster by removing contention for read operations
+
+
+Changes of 1.12.1-CR1
+=====================
+
+Bug
+ * [EXOJCR-256] - There are server errors "500 Internal Server Error:" during creation repository or workspace by RestRepositoryService
+ * [EXOJCR-348] - Test problem: TestCleanableFileStreamValueData failed
+ * [EXOJCR-519] - DAILY TESTS are going too long (avg time=5hours)
+ * [EXOJCR-531] - Problems with Lock operations
+ * [EXOJCR-546] - TESTING: Performance testing problems. LockUnlockOwnNodeTest - TPS fell down
+ * [EXOJCR-548] - problem with import & export node
+ * [EXOJCR-555] - NPE with cache eviction at startup
+ * [EXOJCR-557] - Problem while uploading *.pdf to WebDAV server using Mac OS Finder
+ * [EXOJCR-558] - Files uploaded by Mac OS finder are displayed with size "0"
+ * [EXOJCR-559] - Problems with daily performance testing - on PostgreSQL 8.2.9
+ * [EXOJCR-567] - The REST servlet dump errors when the client cut the socket too early should be only a debug log
+ * [EXOJCR-572] - Can not create workspace with default configuration of lock manager
+ * [EXOJCR-581] - Listing the directory in TreeFile may return null during race condition, causing NPE.
+ * [EXOJCR-584] - User's research is case sensitive
+ * [EXOJCR-586] - Missed slf4j dependency for jcr applications on tomcat AS
+ * [EXOJCR-587] - session.save() throws NPE after node reordering
+ * [EXOJCR-588] - Tests errors in eXo XML Processing Services on MACOS
+ * [EXOJCR-591] - Problem with ObservationManager
+ * [EXOJCR-599] - deadlock during dashboard editing
+ * [EXOJCR-600] - Concurrency problem (java.util.HashMap.put called from CacheableLockManagerImpl.getSessionLockManager(CacheableLockManagerImpl.java:473))
+ * [EXOJCR-601] - gatein sample extension should not be required
+ * [EXOJCR-602] - StackOverflow on JsonGeneratorImpl
+ * [EXOJCR-603] - impossible to change user password
+ * [EXOJCR-607] - Sybase Issue with GateIn
+ * [EXOJCR-608] - XaSessionImpl as XA resource should be unique per user, workspace and repository
+ * [EXOJCR-614] - Node.getReferences fail in some cases
+ * [EXOJCR-615] - Need check nodedata to avoid exception in method NodeImpl.isNodeType(String).
+ * [EXOJCR-619] - Log record forging (Security Issue)
+ * [EXOJCR-621] - Conflict between symlink feature and Jbosscache
+ * [EXOJCR-623] - Unable to get a version of document using WebDAV (HTTP Response 404 returned).
+ * [EXOJCR-633] - Problems with manual testing - tomcat-server on ftp -.IndexOutOfBoundsException
+
+Feature Request
+ * [EXOJCR-549] - Backup and Restore of a whole Repository
+ * [EXOJCR-571] - Change PersitedValueDataReader/Writer
+ * [EXOJCR-573] - Create database and bind DataSource in runtime
+ * [EXOJCR-582] - DB script modification for oracle11 compatibility
+ * [EXOJCR-585] - Allow to get statistics on Database Access without using a Profiler
+ * [EXOJCR-616] - Remove repository container from repositoryContainers map when repository container start fail.
+ * [EXOJCR-617] - Map environment parameters for all String fields in Repository configuration
+
+Task
+ * [EXOJCR-150] - Ftp client tests failute
+ * [EXOJCR-250] - Add human readable message in case Workspace creation error via HTTPBackupAgent
+ * [EXOJCR-393] - Create indexer load test
+ * [EXOJCR-523] - Upgrade to JBoss Cache 3.2.3.GA
+ * [EXOJCR-550] - Bind slf4j-log4j and log4j dependencies onto the test phase of the various modules of JCR
+ * [EXOJCR-552] - Allow to Test eXo JCR 1.12 on EC2
+ * [EXOJCR-575] - Remove unused PairChangesLog class
+ * [EXOJCR-589] - Limit network traffic and thread blocking for the Lucene Indexer in a cluster
+ * [EXOJCR-590] - DO NOT exclude tests from a parent pom
+ * [EXOJCR-598] - Allow to disable the hints used for the Complex Queries on oracle
+ * [EXOJCR-605] - Normalize logging categories
+ * [EXOJCR-631] - Find a reason, why functional tests fails under Tornado.MySQL with "Cannot create PoolableConnectionFactory (Too many connections)" message.
+ * [EXOJCR-632] - svn: File 'jcr.packaging.module/1.12.0-CP01/jcr.packaging.module-1.12.0-CP01.js' has inconsistent newlines
+
+
+Features of eXoJCR 1.12 comparing to 1.11
+=========================================
+
+- Repository clustering based on JBossCache and JBoss Transactions.
+- Lazy-load option for child nodes and properties read, improved items dataflow for read/write operations
+- Alternative data container optimized for read operations (consuming less database queries)
+- Database dialect can be autodetected (if not pointed in the configuration)
+- Support for Values large of 2GiB
+- Portal container configuration improvements (default definitions, link and externaly loaded parameters)
+- Concurrency improvements for Session registry and Values stroage
+- Concurrency improvements for XA transactions support (Repository login and logout faster now)
+- Improved serach based on Lucene 2.4
+- Support of MySQL/InnoDB database for multi-language content
+- Standalone container can use configuration stored in JBossAS server configuration directory by default
+- WebDAV server update-policy can be configured to different versioning behaviour
+- Lot of WebDAV server bugfixes
+- HTTP (RESTful) Backup agent with concole client
+- HTTP (RESTful) Repository management service
+- Support of Java6 and Java5 runtime and development environment
+
+Since version of 1.12 eXoJCR available under LGPL license (version 2.1).
+
+eXoJCR 1.12 tested in on the databases:
+ MySQL 5.1 MYSQL Connector/J 5.1.8
+ Oracle DB 10g (10.2.0.1) Oracle 10g (10.2.0.1)
+ PostgresSQL 8.3.7 JDBC4 Driver, Version 8.3-605
+ DB2 9,7 IBM Data Server Driver for JDBC and SQLJ (JCC Driver) Version: 9.1 (fixpack 3a)
+ MS SQL Server 2005 SP3 JDBC Driver 2.0
+ MS SQL Server 2008 SP1 JDBC Driver 2.0
+ Sybase 15.0.2 JConnect v6.0.5 (Build 26564 / 11 Jun 2009)
+
+
+Release includes:
+* eXo Kernel 2.3.0-Beta02
+* eXo Core 2.4.0-Beta02
+* eXo WS 2.2.0-Beta02
+* eXo JCR 1.14.0-Beta02
+
+Find all 1.14 task on JIRA:
+https://jira.jboss.org/jira/browse/EXOJCR
+
+1.14.0-Beta02 tasks:
+https://jira.jboss.org/browse/EXOJCR/fixforversion/12315071
+
+
+JCR Samples
+===========
+
+1. Start Up (Tomcat)
+ Tomcat 6 bundled can be started by executing the following commands:
+
+ $CATALINA_HOME\bin\eXo.bat run (Windows)
+
+ $CATALINA_HOME/bin/eXo.sh run (Unix)
+
+2. After startup, the sample applications will be available by visiting:
+
+ http://localhost:8080/browser - Simple JCR browser
+ Browse the JCR repository that was started with Tomcat
+ http://localhost:8080/fckeditor - FCK editor sample
+ Edits the sample node using FCKEditor and browse it JCR browser
+ http://localhost:8080/rest/jcr/repository/production - WebDAV service,
+ Open in Microsoft Explorer, File-Open-OpenAsWebFolder with url http://localhost:8080/rest/jcr/repository/production
+ Add/read/remove files there and browse it in the JCR browser or FTP.
+ User name/password: root/exo
+ ftp://localhost:2121 - FTP server
+ Open the repository in FTP client and browse the JCR repository started with Tomcat as FTP content,
+ add/read/remove files there and browse it in the JCR browser or WebDAV.
+
+EAR deploy
+==========
+
+eXo JCR was tested under JBoss-5.1.0.GA application server
+
+JBoss-5.1.0.GA
+
+ 1. Configuration
+
+ * Copy jcr.ear into $jboss_home/server/default/deploy
+ * Create $jboss_home/server/default/conf/exo-conf folder if it doesn't exist.
+ * Put exo-configuration.xml into $jboss_home/server/default/conf/exo-conf/exo-configuration.xml
+ * Configure JAAS by inserting XML fragment shown below into $jboss_home/server/default/conf/login-config.xml
+
+---------
+<application-policy name="exo-domain">
+ <authentication>
+ <login-module code="org.exoplatform.services.security.j2ee.JbossLoginModule" flag="required"></login-module>
+ </authentication>
+ </application-policy>
+---------
+
+ 2. Start Up
+
+ Execute
+ * bin/run.bat on Windows
+ or
+ * bin/run.sh on Unix
+
+Resources
+=========
+
+ Company site http://www.exoplatform.com
+ Documentation wiki http://wiki.exoplatform.org
+ Community JIRA https://jira.jboss.org/jira/browse/EXOJCR, http://jira.exoplatform.org
+ Comminity site http://www.exoplatform.org
+ Community forum http://www.exoplatform.com/portal/public/en/forum
+ JavaDoc site http://docs.exoplatform.org
+
\ No newline at end of file
13 years, 7 months
exo-jcr SVN: r3190 - docs-style/trunk.
by do-not-reply@jboss.org
Author: aheritier
Date: 2010-09-24 16:20:16 -0400 (Fri, 24 Sep 2010)
New Revision: 3190
Modified:
docs-style/trunk/pom.xml
Log:
Upgrade to latest Foundation parent release
Modified: docs-style/trunk/pom.xml
===================================================================
--- docs-style/trunk/pom.xml 2010-09-24 20:18:11 UTC (rev 3189)
+++ docs-style/trunk/pom.xml 2010-09-24 20:20:16 UTC (rev 3190)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.exoplatform</groupId>
<artifactId>foundation-parent</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>7</version>
</parent>
<groupId>org.exoplatform.doc</groupId>
13 years, 7 months
exo-jcr SVN: r3189 - junit.framework/trunk.
by do-not-reply@jboss.org
Author: aheritier
Date: 2010-09-24 16:18:11 -0400 (Fri, 24 Sep 2010)
New Revision: 3189
Modified:
junit.framework/trunk/pom.xml
Log:
Upgrade to latest Foundation parent release
Modified: junit.framework/trunk/pom.xml
===================================================================
--- junit.framework/trunk/pom.xml 2010-09-24 08:54:04 UTC (rev 3188)
+++ junit.framework/trunk/pom.xml 2010-09-24 20:18:11 UTC (rev 3189)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.exoplatform</groupId>
<artifactId>foundation-parent</artifactId>
- <version>6-SNAPSHOT</version>
+ <version>7</version>
</parent>
<groupId>org.exoplatform.tool</groupId>
13 years, 7 months
exo-jcr SVN: r3188 - in jcr/branches/1.12.x/exo.jcr.component.core/src: main/java/org/exoplatform/services/jcr/dataflow/persistent and 25 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-09-24 04:54:04 -0400 (Fri, 24 Sep 2010)
New Revision: 3188
Added:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java
Modified:
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractItemDefinitionAccessProvider.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedFieldSortComparator.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheQPath.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/version/VersionHistoryDataHelper.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/VersionHistoryRemover.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestLinkedCacheMultithread.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/StorageUpdateTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java
jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/TestFrozenNodeInitializer.java
Log:
JCR-1449: possibility to get property of a node if it has a child node with the same name with the property
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemDataConsumer.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.dataflow;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -44,14 +45,31 @@
/**
* Find Item by parent (id) and name (with path index).
*
- * @param parent NodeData
- * @param name QPathEntry
+ * @param parent
+ * NodeData
+ * @param name
+ * item name
* @return ItemData, data by parent and name
* @throws RepositoryException
*/
+ @Deprecated
ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException;
/**
+ * Find Item by parent (id) and name (with path index) of define type.
+ *
+ * @param parent
+ * NodeData
+ * @param name
+ * item name
+ * @param itemType
+ * itemType
+ * @return ItemData, data by parent and name
+ * @throws RepositoryException
+ */
+ ItemData getItemData(NodeData parent, QPathEntry name, ItemType itemType) throws RepositoryException;
+
+ /**
* Find Item by identifier.
*
* @param String identifier
@@ -73,7 +91,7 @@
* @return int, child nodes count
*/
int getChildNodesCount(NodeData parent) throws RepositoryException;
-
+
/**
* Get child Properties of the parent node.
*
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/TransactionChangesLog.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -18,8 +18,8 @@
*/
package org.exoplatform.services.jcr.dataflow;
-import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
@@ -139,14 +139,15 @@
return null;
}
- public ItemState getItemState(NodeData parentData, QPathEntry name)
+ public ItemState getItemState(NodeData parentData, QPathEntry name, ItemType itemType)
{
List<ItemState> allStates = getAllStates();
for (int i = allStates.size() - 1; i >= 0; i--)
{
ItemState state = allStates.get(i);
if (state.getData().getParentIdentifier().equals(parentData.getIdentifier())
- && state.getData().getQPath().getEntries()[state.getData().getQPath().getEntries().length - 1].isSame(name))
+ && state.getData().getQPath().getEntries()[state.getData().getQPath().getEntries().length - 1].isSame(name)
+ && itemType.isSuitableFor(state.getData()))
return state;
}
return null;
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/WorkspaceStorageCache.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.dataflow.persistent;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -44,12 +45,28 @@
* Get item by parent identifier and name +index.
*
* @param parentIdentifier
- * @param path
- * @return itemData by parent Identifier and item name with index or null if not found
+ * parent identifier
+ * @param name
+ * item name
+ * @return itemData by parent Identifier and item name with index or null in other case
*/
+ @Deprecated
ItemData get(String parentIdentifier, QPathEntry name);
/**
+ * Get item by parent identifier and name +index of define type.
+ *
+ * @param parentIdentifier
+ * parent identifier
+ * @param name
+ * item name
+ * @param itemType
+ * item type
+ * @return itemData by parent Identifier and item name with index of define type or null in other case
+ */
+ ItemData get(String parentIdentifier, QPathEntry name, ItemType itemType);
+
+ /**
* Get item by identifier.
*
* @param identifier
Added: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java (rev 0)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ItemType.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -0,0 +1,34 @@
+package org.exoplatform.services.jcr.datamodel;
+
+
+/**
+ * Class contains enumerated item types. Is used in methods to indicate what need exactly get: node or property.
+ */
+public enum ItemType {
+ UNKNOWN, NODE, PROPERTY;
+
+ /**
+ * Indicate if item type suit for ItemData.
+ *
+ * @param itemData
+ * ItemData
+ * @return true if item type is UNKNOWN type or the same as ItemData and false in other case
+ */
+ public boolean isSuitableFor(ItemData itemData)
+ {
+ boolean isNode = itemData.isNode();
+ return this == UNKNOWN || this == NODE && isNode || this == PROPERTY && !isNode;
+ }
+
+ /**
+ * Return item type based on ItemData.
+ *
+ * @param itemData
+ * item data
+ * @return ItemType
+ */
+ public static ItemType getItemType(ItemData itemData)
+ {
+ return itemData.isNode() ? ItemType.NODE : ItemType.PROPERTY;
+ }
+}
\ No newline at end of file
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.datamodel.Identifier;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -369,7 +370,8 @@
if (ntManager.isNodeType(Constants.MIX_VERSIONABLE, node.getPrimaryTypeName(), node.getMixinTypeNames()))
{
- ItemData vhpd = dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1));
+ ItemData vhpd =
+ dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1), ItemType.PROPERTY);
if (vhpd != null && !vhpd.isNode())
{
try
@@ -416,7 +418,8 @@
int version;
PropertyImpl prevProp;
PropertyDefinitionDatas defs;
- ItemImpl prevItem = dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true);
+ ItemImpl prevItem =
+ dataManager.getItem(parentNode.nodeData(), new QPathEntry(propertyName, 0), true, ItemType.PROPERTY);
NodeTypeDataManager ntm = session.getWorkspace().getNodeTypesHolder();
NodeData parentData = (NodeData)parentNode.getData();
@@ -429,8 +432,8 @@
{
// new property null values;
TransientPropertyData nullData =
- new TransientPropertyData(qpath, identifier, version, PropertyType.UNDEFINED, parentNode
- .getInternalIdentifier(), isMultiValue);
+ new TransientPropertyData(qpath, identifier, version, PropertyType.UNDEFINED,
+ parentNode.getInternalIdentifier(), isMultiValue);
PropertyImpl nullProperty = new PropertyImpl(nullData, session);
nullProperty.invalidate();
return nullProperty;
@@ -633,8 +636,8 @@
NodeData refNode = (NodeData)changedItem.getData();
// Check referential integrity (remove of mix:referenceable node)
- if (ntManager.isNodeType(Constants.MIX_REFERENCEABLE, refNode.getPrimaryTypeName(), refNode
- .getMixinTypeNames()))
+ if (ntManager.isNodeType(Constants.MIX_REFERENCEABLE, refNode.getPrimaryTypeName(),
+ refNode.getMixinTypeNames()))
{
// mix:referenceable
@@ -951,8 +954,8 @@
throws RepositoryException
{
ValueConstraintsMatcher constraints =
- new ValueConstraintsMatcher(def.getValueConstraints(), session.getLocationFactory(), session
- .getTransientNodesManager(), session.getWorkspace().getNodeTypesHolder());
+ new ValueConstraintsMatcher(def.getValueConstraints(), session.getLocationFactory(),
+ session.getTransientNodesManager(), session.getWorkspace().getNodeTypesHolder());
for (ValueData value : newValues)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceDataPersister.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -31,6 +31,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -185,7 +186,8 @@
}
PlainChangesLogImpl plainChangesLogImpl = new PlainChangesLogImpl();
- ItemData prefData = dataManager.getItemData(nsRoot, new QPathEntry(new InternalQName("", prefix), 0));
+ ItemData prefData =
+ dataManager.getItemData(nsRoot, new QPathEntry(new InternalQName("", prefix), 0), ItemType.NODE);
if (prefData != null && prefData.isNode())
{
@@ -220,12 +222,14 @@
if (jcrSystem != null)
{
NodeData exoNamespaces =
- (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1));
+ (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1),
+ ItemType.NODE);
if (exoNamespaces == null)
{
initStorage(jcrSystem, !repConfig.getAccessControl().equals(AccessControlPolicy.DISABLE));
this.nsRoot =
- (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1));
+ (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1),
+ ItemType.NODE);
}
else
{
@@ -264,7 +268,8 @@
{
NodeData jcrSystem = (NodeData)dataManager.getItemData(Constants.SYSTEM_UUID);
if (jcrSystem != null)
- this.nsRoot = (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1));
+ this.nsRoot =
+ (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.EXO_NAMESPACES, 1), ItemType.NODE);
else
throw new RepositoryException(
"/jcr:system is not found. Possible the workspace is not initialized properly");
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -36,6 +36,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -250,7 +251,8 @@
+ itemPath.getAsString(false));
ItemImpl parentItem =
- dataManager.getItem(nodeData(), itemPath.makeParentPath().getInternalPath().getEntries(), false);
+ dataManager.getItem(nodeData(), itemPath.makeParentPath().getInternalPath().getEntries(), false,
+ ItemType.UNKNOWN);
if (parentItem == null)
throw new PathNotFoundException("Parent not found for " + itemPath.getAsString(true));
@@ -262,8 +264,8 @@
// find node type
NodeDefinitionData nodeDef =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(name, nodeData().getPrimaryTypeName(),
- nodeData().getMixinTypeNames());
+ session.getWorkspace().getNodeTypesHolder()
+ .getChildNodeDefinition(name, nodeData().getPrimaryTypeName(), nodeData().getMixinTypeNames());
if (nodeDef == null)
throw new ConstraintViolationException("Can not define node type for " + name.getAsString());
@@ -298,7 +300,8 @@
+ itemPath.getAsString(false));
ItemImpl parentItem =
- dataManager.getItem(nodeData(), itemPath.makeParentPath().getInternalPath().getEntries(), false);
+ dataManager.getItem(nodeData(), itemPath.makeParentPath().getInternalPath().getEntries(), false,
+ ItemType.UNKNOWN);
if (parentItem == null)
throw new PathNotFoundException("Parent not found for " + itemPath.getAsString(true));
@@ -376,7 +379,8 @@
if (vancestor != null)
{
PropertyData isCheckedOut =
- (PropertyData)dataManager.getItemData(vancestor, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 1));
+ (PropertyData)dataManager.getItemData(vancestor, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 1),
+ ItemType.PROPERTY);
try
{
return ValueDataConvertor.readBoolean(isCheckedOut.getValues().get(0));
@@ -464,8 +468,8 @@
new TransientValueData(true))));
ValueData baseVersion =
- ((PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_BASEVERSION, 0))).getValues()
- .get(0);
+ ((PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_BASEVERSION, 0),
+ ItemType.PROPERTY)).getValues().get(0);
changesLog.add(ItemState.createUpdatedState(updatePropertyData(Constants.JCR_PREDECESSORS, baseVersion)));
@@ -547,7 +551,8 @@
values.add(new TransientValueData(type.getName()));
PropertyData prop =
- (PropertyData)dataManager.getItemData(((NodeData)getData()), new QPathEntry(Constants.JCR_MIXINTYPES, 0));
+ (PropertyData)dataManager.getItemData(((NodeData)getData()), new QPathEntry(Constants.JCR_MIXINTYPES, 0),
+ ItemType.PROPERTY);
ItemState state;
if (prop != null)
@@ -677,7 +682,8 @@
throw new UnsupportedRepositoryOperationException("Node is not versionable " + getPath());
PropertyData bvProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_BASEVERSION, 1));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_BASEVERSION, 1),
+ ItemType.PROPERTY);
try
{
return (Version)session.getNodeByUUID(ValueDataConvertor.readString(bvProp.getValues().get(0)));
@@ -721,9 +727,9 @@
NodeData ancestor = (NodeData)dataManager.getItemData(Constants.ROOT_UUID);
for (int i = 1; i < myPath.getDepth(); i++)
{
- ancestor = (NodeData)dataManager.getItemData(ancestor, myPath.getEntries()[i]);
- if (corrSession.getWorkspace().getNodeTypesHolder().isNodeType(Constants.MIX_REFERENCEABLE,
- ancestor.getPrimaryTypeName(), ancestor.getMixinTypeNames()))
+ ancestor = (NodeData)dataManager.getItemData(ancestor, myPath.getEntries()[i], ItemType.NODE);
+ if (corrSession.getWorkspace().getNodeTypesHolder()
+ .isNodeType(Constants.MIX_REFERENCEABLE, ancestor.getPrimaryTypeName(), ancestor.getMixinTypeNames()))
{
NodeData corrAncestor = (NodeData)corrDataManager.getItemData(ancestor.getIdentifier());
if (corrAncestor == null)
@@ -731,7 +737,8 @@
+ ancestor.getQPath().getAsString() + " in " + corrSession.getWorkspace().getName());
NodeData corrNode =
- (NodeData)corrDataManager.getItemData(corrAncestor, myPath.getRelPath(myPath.getDepth() - i));
+ (NodeData)corrDataManager.getItemData(corrAncestor, myPath.getRelPath(myPath.getDepth() - i),
+ ItemType.NODE);
if (corrNode != null)
return corrNode;
}
@@ -787,8 +794,8 @@
new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, false,
new InternalQName[]{requiredName}, null, true);
this.nodeDefinition =
- new NodeDefinitionImpl(ntData, nodeTypesHolder, nodeTypeManager, sysLocFactory, session
- .getValueFactory(), session.getTransientNodesManager());
+ new NodeDefinitionImpl(ntData, nodeTypesHolder, nodeTypeManager, sysLocFactory,
+ session.getValueFactory(), session.getTransientNodesManager());
}
}
else
@@ -797,8 +804,8 @@
NodeData parent = (NodeData)dataManager.getItemData(getParentIdentifier());
this.definition =
- nodeTypesHolder.getChildNodeDefinition(getInternalName(), parent.getPrimaryTypeName(), parent
- .getMixinTypeNames());
+ nodeTypesHolder.getChildNodeDefinition(getInternalName(), parent.getPrimaryTypeName(),
+ parent.getMixinTypeNames());
if (definition == null)
{
@@ -814,8 +821,8 @@
}
nodeDefinition =
- new NodeDefinitionImpl(definition, nodeTypesHolder, nodeTypeManager, sysLocFactory, session
- .getValueFactory(), session.getTransientNodesManager());
+ new NodeDefinitionImpl(definition, nodeTypesHolder, nodeTypeManager, sysLocFactory,
+ session.getValueFactory(), session.getTransientNodesManager());
}
}
@@ -905,7 +912,7 @@
JCRPath itemPath = locationFactory.parseRelPath(relPath);
- ItemImpl node = dataManager.getItem(nodeData(), itemPath.getInternalPath().getEntries(), true);
+ ItemImpl node = dataManager.getItem(nodeData(), itemPath.getInternalPath().getEntries(), true, ItemType.NODE);
if (node == null || !node.isNode())
{
throw new PathNotFoundException("Node not found " + (isRoot() ? "" : getLocation().getAsString(false)) + "/"
@@ -1049,7 +1056,8 @@
{
if (ntData.getPrimaryItemName() != null)
{
- Item primaryItem = dataManager.getItem(nodeData(), new QPathEntry(ntData.getPrimaryItemName(), 0), true);
+ Item primaryItem =
+ dataManager.getItem(nodeData(), new QPathEntry(ntData.getPrimaryItemName(), 0), true, ItemType.UNKNOWN);
if (primaryItem != null)
return primaryItem;
@@ -1195,7 +1203,7 @@
if (LOG.isDebugEnabled())
LOG.debug("getProperty() " + getLocation().getAsString(false) + " " + relPath);
- ItemImpl prop = dataManager.getItem(nodeData(), itemPath.getInternalPath().getEntries(), true);
+ ItemImpl prop = dataManager.getItem(nodeData(), itemPath.getInternalPath().getEntries(), true, ItemType.PROPERTY);
if (prop == null || prop.isNode())
throw new PathNotFoundException("Property not found " + itemPath.getAsString(false));
@@ -1287,7 +1295,7 @@
JCRPath itemPath = locationFactory.parseRelPath(relPath);
- ItemData node = dataManager.getItemData(nodeData(), itemPath.getInternalPath().getEntries());
+ ItemData node = dataManager.getItemData(nodeData(), itemPath.getInternalPath().getEntries(), ItemType.NODE);
return node != null && node.isNode();
}
@@ -1323,7 +1331,7 @@
JCRPath itemPath = locationFactory.parseRelPath(relPath);
- ItemData prop = dataManager.getItemData(nodeData(), itemPath.getInternalPath().getEntries());
+ ItemData prop = dataManager.getItemData(nodeData(), itemPath.getInternalPath().getEntries(), ItemType.PROPERTY);
return prop != null && !prop.isNode();
}
@@ -1382,8 +1390,8 @@
{
checkValid();
- return session.getWorkspace().getNodeTypesHolder().isNodeType(qName, nodeData().getPrimaryTypeName(),
- nodeData().getMixinTypeNames());
+ return session.getWorkspace().getNodeTypesHolder()
+ .isNodeType(qName, nodeData().getPrimaryTypeName(), nodeData().getMixinTypeNames());
}
/**
@@ -1472,8 +1480,8 @@
}
this.definition =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
- parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+ session.getWorkspace().getNodeTypesHolder()
+ .getChildNodeDefinition(getInternalName(), parent.getPrimaryTypeName(), parent.getMixinTypeNames());
if (definition == null)
{
@@ -1670,7 +1678,8 @@
session.getActionHandler().preRemoveMixin(this, name);
PropertyData propData =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MIXINTYPES, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MIXINTYPES, 0),
+ ItemType.PROPERTY);
// create new property data with new values
TransientPropertyData prop =
@@ -1699,7 +1708,7 @@
for (PropertyDefinitionData pd : ntmanager.getAllPropertyDefinitions(removedName))
{
- ItemData p = dataManager.getItemData(nodeData(), new QPathEntry(pd.getName(), 1));
+ ItemData p = dataManager.getItemData(nodeData(), new QPathEntry(pd.getName(), 1), ItemType.PROPERTY);
if (p != null && !p.isNode())
// remove it
dataManager.delete(p, ancestorToSave);
@@ -1707,7 +1716,7 @@
for (NodeDefinitionData nd : ntmanager.getAllChildNodeDefinitions(removedName))
{
- ItemData n = dataManager.getItemData(nodeData(), new QPathEntry(nd.getName(), 1));
+ ItemData n = dataManager.getItemData(nodeData(), new QPathEntry(nd.getName(), 1), ItemType.NODE);
if (n != null && n.isNode())
{
// remove node with subtree
@@ -1837,7 +1846,9 @@
throw new VersionException("It is illegal to call restore() on jcr:rootVersion");
QPath destPath = locationFactory.parseRelPath(relPath).getInternalPath();
- NodeImpl destParent = (NodeImpl)dataManager.getItem(nodeData(), destPath.makeParentPath().getEntries(), false);
+ NodeImpl destParent =
+ (NodeImpl)dataManager.getItem(nodeData(), destPath.makeParentPath().getEntries(), false, ItemType.NODE);
+
if (destParent == null)
throw new PathNotFoundException("Parent not found for " + relPath);
@@ -1846,7 +1857,7 @@
NodeImpl destNode =
(NodeImpl)dataManager.getItem(destParent.nodeData(),
- new QPathEntry(destPath.getName(), destPath.getIndex()), false);
+ new QPathEntry(destPath.getName(), destPath.getIndex()), false, ItemType.NODE);
if (destNode != null)
{
@@ -1996,8 +2007,8 @@
checkValid();
- return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(), valueFactory
- .createValue(value), false, PropertyType.UNDEFINED);
+ return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(),
+ valueFactory.createValue(value), false, PropertyType.UNDEFINED);
}
@@ -2036,8 +2047,8 @@
checkValid();
- return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(), valueFactory
- .createValue(value), false, PropertyType.UNDEFINED);
+ return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(),
+ valueFactory.createValue(value), false, PropertyType.UNDEFINED);
}
@@ -2064,8 +2075,8 @@
checkValid();
- return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(), valueFactory
- .createValue(value), false, PropertyType.UNDEFINED);
+ return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(),
+ valueFactory.createValue(value), false, PropertyType.UNDEFINED);
}
@@ -2078,8 +2089,8 @@
checkValid();
- return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(), valueFactory.createValue(
- value, type), false, type);
+ return doUpdateProperty(this, locationFactory.parseJCRName(name).getInternalName(),
+ valueFactory.createValue(value, type), false, type);
}
/**
@@ -2244,7 +2255,7 @@
NodeData thisParent = (NodeData)session.getTransientNodesManager().getItemData(getParentIdentifier());
QPathEntry[] qpath = getInternalPath().getEntries();
- NodeData thisNew = (NodeData)pmanager.getItemData(thisParent, qpath[qpath.length - 1]);
+ NodeData thisNew = (NodeData)pmanager.getItemData(thisParent, qpath[qpath.length - 1], ItemType.NODE);
// reload node impl with old uuid to a new one data
session.getTransientNodesManager().getItemsPool().reload(getInternalIdentifier(), thisNew);
}
@@ -2276,8 +2287,8 @@
}
// Check if node is not protected
NodeDefinitionData childNodeDefinition =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(name, nodeData().getPrimaryTypeName(),
- nodeData().getMixinTypeNames());
+ session.getWorkspace().getNodeTypesHolder()
+ .getChildNodeDefinition(name, nodeData().getPrimaryTypeName(), nodeData().getMixinTypeNames());
if (childNodeDefinition == null)
throw new ConstraintViolationException("Can't find child node definition for "
+ sysLocFactory.createJCRName(name).getAsString() + " in " + getPath());
@@ -2318,7 +2329,8 @@
}
PropertyData vhProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_VERSIONHISTORY, 1));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
+ ItemType.PROPERTY);
if (vhProp == null)
throw new UnsupportedRepositoryOperationException("Node does not have jcr:versionHistory " + getPath());
@@ -2479,16 +2491,16 @@
QPath.makeChildPath(newData.getQPath().makeParentPath(), newData.getQPath().getName(), sameNameIndex);
newData =
- new TransientNodeData(siblingPath, newData.getIdentifier(), newData.getPersistedVersion(), newData
- .getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(), newData
- .getACL());
+ new TransientNodeData(siblingPath, newData.getIdentifier(), newData.getPersistedVersion(),
+ newData.getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(),
+ newData.getACL());
}
else
{
newData =
new TransientNodeData(newData.getQPath(), newData.getIdentifier(), newData.getPersistedVersion(),
- newData.getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(), newData
- .getACL());
+ newData.getPrimaryTypeName(), newData.getMixinTypeNames(), j, newData.getParentIdentifier(),
+ newData.getACL());
}
/*
@@ -2536,11 +2548,13 @@
PlainChangesLog changesLog =
new PlainChangesLogImpl(new ArrayList<ItemState>(), session.getId(), ExtendedEvent.UNLOCK);
- ItemData lockOwner = dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKOWNER, 0));
+ ItemData lockOwner =
+ dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKOWNER, 0), ItemType.PROPERTY);
changesLog.add(ItemState.createDeletedState(lockOwner));
- ItemData lockIsDeep = dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKISDEEP, 0));
+ ItemData lockIsDeep =
+ dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_LOCKISDEEP, 0), ItemType.PROPERTY);
changesLog.add(ItemState.createDeletedState(lockIsDeep));
@@ -2555,7 +2569,8 @@
protected PropertyImpl property(InternalQName name) throws IllegalPathException, PathNotFoundException,
RepositoryException
{
- PropertyImpl prop = (PropertyImpl)dataManager.getItem(nodeData(), new QPathEntry(name, 1), false);
+ PropertyImpl prop =
+ (PropertyImpl)dataManager.getItem(nodeData(), new QPathEntry(name, 1), false, ItemType.PROPERTY);
if (prop == null || prop.isNode())
throw new PathNotFoundException("Property not found " + name);
return prop;
@@ -2580,7 +2595,8 @@
protected PropertyData updatePropertyData(InternalQName name, List<ValueData> values) throws RepositoryException
{
- PropertyData existed = (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(name, 0));
+ PropertyData existed =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(name, 0), ItemType.PROPERTY);
if (existed == null)
{
@@ -2594,8 +2610,9 @@
}
TransientPropertyData tdata =
- new TransientPropertyData(QPath.makeChildPath(getInternalPath(), name), existed.getIdentifier(), existed
- .getPersistedVersion(), existed.getType(), existed.getParentIdentifier(), existed.isMultiValued(), values);
+ new TransientPropertyData(QPath.makeChildPath(getInternalPath(), name), existed.getIdentifier(),
+ existed.getPersistedVersion(), existed.getType(), existed.getParentIdentifier(), existed.isMultiValued(),
+ values);
return tdata;
}
@@ -2603,15 +2620,17 @@
protected PropertyData updatePropertyData(InternalQName name, ValueData value) throws RepositoryException
{
- PropertyData existed = (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(name, 0));
+ PropertyData existed =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(name, 0), ItemType.PROPERTY);
if (existed == null)
throw new RepositoryException("Property data is not found " + name.getAsString() + " for node "
+ nodeData().getQPath().getAsString());
TransientPropertyData tdata =
- new TransientPropertyData(QPath.makeChildPath(getInternalPath(), name), existed.getIdentifier(), existed
- .getPersistedVersion(), existed.getType(), existed.getParentIdentifier(), existed.isMultiValued(), value);
+ new TransientPropertyData(QPath.makeChildPath(getInternalPath(), name), existed.getIdentifier(),
+ existed.getPersistedVersion(), existed.getType(), existed.getParentIdentifier(), existed.isMultiValued(),
+ value);
return tdata;
}
@@ -2658,7 +2677,8 @@
EntityCollection res = new EntityCollection();
TransientPropertyData mergeFailed =
- (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MERGEFAILED, 0));
+ (TransientPropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MERGEFAILED, 0),
+ ItemType.PROPERTY);
List<ValueData> mergeFailedRefs = new ArrayList<ValueData>();
int state = 0;
@@ -2672,9 +2692,9 @@
}
mergeFailed =
- new TransientPropertyData(mergeFailed.getQPath(), mergeFailed.getIdentifier(), mergeFailed
- .getPersistedVersion(), mergeFailed.getType(), mergeFailed.getParentIdentifier(), mergeFailed
- .isMultiValued(), mergeFailedRefs);
+ new TransientPropertyData(mergeFailed.getQPath(), mergeFailed.getIdentifier(),
+ mergeFailed.getPersistedVersion(), mergeFailed.getType(), mergeFailed.getParentIdentifier(),
+ mergeFailed.isMultiValued(), mergeFailedRefs);
state = ItemState.UPDATED;
}
@@ -2728,20 +2748,20 @@
{
NodeDefinitionData def =
- session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(nameToAdd, parentNode.getPrimaryTypeName(),
- parentNode.getMixinTypeNames());
+ session.getWorkspace().getNodeTypesHolder()
+ .getChildNodeDefinition(nameToAdd, parentNode.getPrimaryTypeName(), parentNode.getMixinTypeNames());
boolean allowSns = def.isAllowsSameNameSiblings();
int ind = 1;
- NodeData sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ NodeData sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind), ItemType.NODE);
while (sibling != null)
{
if (allowSns)
{
ind++;
- sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind));
+ sibling = (NodeData)dataManager.getItemData(parentNode, new QPathEntry(nameToAdd, ind), ItemType.NODE);
}
else
{
@@ -2787,8 +2807,8 @@
// create new nodedata, [PN] fix of use index as persisted version
NodeData nodeData =
- new TransientNodeData(path, identifier, -1, primaryTypeName, mixinTypeNames, orderNum, parentNode
- .getInternalIdentifier(), acl);
+ new TransientNodeData(path, identifier, -1, primaryTypeName, mixinTypeNames, orderNum,
+ parentNode.getInternalIdentifier(), acl);
// Create new Node
ItemState state = ItemState.createAddedState(nodeData, false);
@@ -2819,7 +2839,7 @@
{
try
{
- ItemData pdata = dataManager.getItemData(nodeData(), new QPathEntry(name, 1));
+ ItemData pdata = dataManager.getItemData(nodeData(), new QPathEntry(name, 1), ItemType.PROPERTY);
if (pdata != null && !pdata.isNode())
return true;
@@ -2834,7 +2854,8 @@
{
PropertyData mergeFailed =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MERGEFAILED, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_MERGEFAILED, 0),
+ ItemType.PROPERTY);
if (mergeFailed == null)
return;
@@ -2869,9 +2890,10 @@
// to jcr:predecessors (with doneMerge) or just removed from
// jcr:mergeFailed (with cancelMerge) the jcr:mergeFailed
// property is automatically remove
- changesLog.add(ItemState.createDeletedState(new TransientPropertyData(mergeFailed.getQPath(), mergeFailed
- .getIdentifier(), mergeFailed.getPersistedVersion(), mergeFailed.getType(), mergeFailed
- .getParentIdentifier(), mergeFailed.isMultiValued(), mergeFailed.getValues()), true));
+ changesLog.add(ItemState.createDeletedState(
+ new TransientPropertyData(mergeFailed.getQPath(), mergeFailed.getIdentifier(), mergeFailed
+ .getPersistedVersion(), mergeFailed.getType(), mergeFailed.getParentIdentifier(), mergeFailed
+ .isMultiValued(), mergeFailed.getValues()), true));
}
}
@@ -2879,9 +2901,9 @@
{
NodeData nodeData = (NodeData)data;
data =
- new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
- .getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(), nodeData
- .getParentIdentifier(), acl);
+ new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(),
+ nodeData.getPrimaryTypeName(), nodeData.getMixinTypeNames(), nodeData.getOrderNumber(),
+ nodeData.getParentIdentifier(), acl);
}
private void updateMixin(List<InternalQName> newMixin) throws RepositoryException
@@ -2892,8 +2914,9 @@
NodeData nodeData = (NodeData)data;
data =
- new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(), nodeData
- .getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(), nodeData.getACL());
+ new TransientNodeData(nodeData.getQPath(), nodeData.getIdentifier(), nodeData.getPersistedVersion(),
+ nodeData.getPrimaryTypeName(), mixins, nodeData.getOrderNumber(), nodeData.getParentIdentifier(),
+ nodeData.getACL());
// ((TransientNodeData)data).setMixinTypeNames(mixins);
@@ -2913,7 +2936,8 @@
}
PropertyData permProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.EXO_PERMISSIONS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.EXO_PERMISSIONS, 0),
+ ItemType.PROPERTY);
permProp =
new TransientPropertyData(permProp.getQPath(), permProp.getIdentifier(), permProp.getPersistedVersion(),
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -29,6 +29,7 @@
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -157,9 +158,15 @@
QPathEntry[] relPathEntries = path.getRelPath(path.getDepth());
- return getItemData(parent, relPathEntries);
+ return getItemData(parent, relPathEntries, ItemType.UNKNOWN);
}
+ @Deprecated
+ public ItemData getItemData(NodeData parent, QPathEntry[] relPathEntries) throws RepositoryException
+ {
+ return getItemData(parent, relPathEntries, ItemType.UNKNOWN);
+ }
+
/**
* Return item data by parent NodeDada and relPathEntries If relpath is JCRPath.THIS_RELPATH = '.'
* it return itself
@@ -167,15 +174,25 @@
* @param parent
* @param relPath
* - array of QPathEntry which represents the relation path to the searched item
+ * @param itemType
+ * - item type
* @return existed item data or null if not found
* @throws RepositoryException
*/
- public ItemData getItemData(NodeData parent, QPathEntry[] relPathEntries) throws RepositoryException
+ public ItemData getItemData(NodeData parent, QPathEntry[] relPathEntries, ItemType itemType)
+ throws RepositoryException
{
ItemData item = parent;
for (int i = 0; i < relPathEntries.length; i++)
{
- item = getItemData(parent, relPathEntries[i]);
+ if (i == relPathEntries.length - 1)
+ {
+ item = getItemData(parent, relPathEntries[i], itemType);
+ }
+ else
+ {
+ item = getItemData(parent, relPathEntries[i], ItemType.UNKNOWN);
+ }
if (item == null)
{
@@ -199,6 +216,14 @@
*/
public ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
{
+ return getItemData(parent, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parent, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
if (name.getName().equals(JCRPath.PARENT_RELPATH) && name.getNamespace().equals(Constants.NS_DEFAULT_URI))
{
if (parent.getIdentifier().equals(Constants.ROOT_UUID))
@@ -214,11 +239,11 @@
ItemData data = null;
// 1. Try in transient changes
- ItemState state = changesLog.getItemState(parent, name);
+ ItemState state = changesLog.getItemState(parent, name, itemType);
if (state == null)
{
// 2. Try from txdatamanager
- data = transactionableManager.getItemData(parent, name);
+ data = transactionableManager.getItemData(parent, name, itemType);
}
else if (!state.isDeleted())
{
@@ -252,6 +277,12 @@
return data;
}
+ @Deprecated
+ public ItemImpl getItem(NodeData parent, QPathEntry name, boolean pool) throws RepositoryException
+ {
+ return getItem(parent, name, pool, ItemType.UNKNOWN);
+ }
+
/**
* Return Item by parent NodeDada and the name of searched item.
*
@@ -259,12 +290,15 @@
* - parent of the searched item
* @param name
* - item name
+ * @param itemType
+ * - item type
* @param pool
* - indicates does the item fall in pool
* @return existed item or null if not found
* @throws RepositoryException
*/
- public ItemImpl getItem(NodeData parent, QPathEntry name, boolean pool) throws RepositoryException
+ public ItemImpl getItem(NodeData parent, QPathEntry name, boolean pool, ItemType itemType)
+ throws RepositoryException
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
@@ -275,7 +309,7 @@
ItemImpl item = null;
try
{
- return item = readItem(getItemData(parent, name), pool);
+ return item = readItem(getItemData(parent, name, itemType), pool);
}
finally
{
@@ -288,6 +322,12 @@
}
}
+ @Deprecated
+ public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool) throws RepositoryException
+ {
+ return getItem(parent, relPath, pool, ItemType.UNKNOWN);
+ }
+
/**
* Return Item by parent NodeDada and array of QPathEntry which represent a relative path to the
* searched item
@@ -298,10 +338,13 @@
* - array of QPathEntry which represents the relation path to the searched item
* @param pool
* - indicates does the item fall in pool
+ * @param itemType
+ * - item type
* @return existed item or null if not found
* @throws RepositoryException
*/
- public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool) throws RepositoryException
+ public ItemImpl getItem(NodeData parent, QPathEntry[] relPath, boolean pool, ItemType itemType)
+ throws RepositoryException
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
@@ -317,7 +360,7 @@
ItemImpl item = null;
try
{
- return item = readItem(getItemData(parent, relPath), pool);
+ return item = readItem(getItemData(parent, relPath, itemType), pool);
}
finally
{
@@ -848,7 +891,14 @@
QPathEntry[] relPathEntries = path.getRelPath(path.getDepth());
for (int i = 0; i < relPathEntries.length; i++)
{
- item = getItemData(parent, relPathEntries[i]);
+ if (i == relPathEntries.length - 1)
+ {
+ item = getItemData(parent, relPathEntries[i], ItemType.NODE);
+ }
+ else
+ {
+ item = getItemData(parent, relPathEntries[i], ItemType.UNKNOWN);
+ }
if (item == null)
{
@@ -896,7 +946,7 @@
try
{
- ItemData item = getItemData(parent, name);
+ ItemData item = getItemData(parent, name, ItemType.NODE);
if (item != null && item.isNode())
{
// node ACL
@@ -996,8 +1046,8 @@
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;
@@ -1140,7 +1190,7 @@
// We can't remove this VH now.
return;
} // else -- if we has a references in workspace where the VH is being
- // deleted we can remove VH now.
+ // deleted we can remove VH now.
}
}
finally
@@ -1179,7 +1229,7 @@
NodeData nextSibling =
(NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause.getQPath()
- .getIndex() + 1));
+ .getIndex() + 1), ItemType.NODE);
String reindexedId = null;
// repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
@@ -1211,7 +1261,7 @@
// next...
nextSibling =
(NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath().getName(),
- nextSibling.getQPath().getIndex() + 1));
+ nextSibling.getQPath().getIndex() + 1), ItemType.NODE);
}
return changes;
@@ -1530,12 +1580,11 @@
{
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)
+ if (getItemData(nData, new QPathEntry(itemDefinitionData.getName(), 0), ItemType.UNKNOWN) == null)
{
throw new ConstraintViolationException("Mandatory item " + itemDefinitionData.getName()
+ " not found. Node [" + nData.getQPath().getAsString() + " primary type: "
@@ -1592,7 +1641,7 @@
{
ItemData persisted =
transactionableManager.getItemData(parent, rstate.getData().getQPath().getEntries()[rstate.getData()
- .getQPath().getEntries().length - 1]);
+ .getQPath().getEntries().length - 1], ItemType.getItemType(rstate.getData()));
if (persisted != null)
{
@@ -1629,7 +1678,8 @@
if (parent != null)
{
QPathEntry[] path = item.getQPath().getEntries();
- persisted = transactionableManager.getItemData(parent, path[path.length - 1]);
+ persisted =
+ transactionableManager.getItemData(parent, path[path.length - 1], ItemType.getItemType(item));
} // else, the item has an invalid state, will be throwed on save
}
@@ -1649,7 +1699,9 @@
if (parent != null)
{
QPathEntry[] path = pooled.getData().getQPath().getEntries();
- persisted = transactionableManager.getItemData(parent, path[path.length - 1]);
+ persisted =
+ transactionableManager.getItemData(parent, path[path.length - 1],
+ ItemType.getItemType(pooled.getData()));
} // else, the item has an invalid state, will be throwed on save
}
if (persisted != null)
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -28,11 +28,12 @@
import org.exoplatform.services.jcr.core.SessionLifecycleListener;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.lock.SessionLockManager;
import org.exoplatform.services.jcr.impl.core.lock.WorkspaceLockManager;
-import org.exoplatform.services.jcr.impl.core.lock.SessionLockManager;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeImpl;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerImpl;
import org.exoplatform.services.jcr.impl.core.observation.ObservationManagerRegistry;
@@ -745,7 +746,7 @@
ConversationState newState =
new ConversationState(new Identity(name, userState.getIdentity().getMemberships(), userState.getIdentity()
.getRoles()));
- return (Session)sessionFactory.createSession(newState);
+ return sessionFactory.createSession(newState);
}
@@ -871,13 +872,13 @@
+ destAbsPath);
}
- destParentNode.validateChildNode(destNodePath.getName().getInternalName(), ((NodeTypeImpl)srcNode
- .getPrimaryNodeType()).getQName());
+ destParentNode.validateChildNode(destNodePath.getName().getInternalName(),
+ ((NodeTypeImpl)srcNode.getPrimaryNodeType()).getQName());
// Check for node with destAbsPath name in session
NodeImpl destNode =
(NodeImpl)dataManager.getItem((NodeData)destParentNode.getData(), new QPathEntry(destNodePath
- .getInternalPath().getName(), 0), false);
+ .getInternalPath().getName(), 0), false, ItemType.NODE);
if (destNode != null)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeImpl;
@@ -190,7 +191,7 @@
NodeImpl destNode =
(NodeImpl)session.getTransientNodesManager().getItem((NodeData)destParentNode.getData(),
- new QPathEntry(destNodePath.getInternalPath().getName(), 0), false);
+ new QPathEntry(destNodePath.getInternalPath().getName(), 0), false, ItemType.NODE);
if (destNode != null)
{
@@ -412,7 +413,7 @@
// Check for node with destAbsPath name in session
NodeImpl destNode =
(NodeImpl)session.getTransientNodesManager().getItem((NodeData)destParentNode.getData(),
- new QPathEntry(destNodePath.getInternalPath().getName(), 0), false);
+ new QPathEntry(destNodePath.getInternalPath().getName(), 0), false, ItemType.NODE);
if (destNode != null)
{
@@ -499,7 +500,7 @@
// Check for node with destAbsPath name in session
NodeImpl destNode =
(NodeImpl)session.getTransientNodesManager().getItem((NodeData)destParentNode.getData(),
- new QPathEntry(destNodePath.getInternalPath().getName(), 0), false);
+ new QPathEntry(destNodePath.getInternalPath().getName(), 0), false, ItemType.NODE);
ItemState changesItemState = null;
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -182,7 +183,8 @@
if (lockedNodeData != null)
{
PropertyData dataLockIsDeep =
- (PropertyData)dataManager.getItemData(lockedNodeData, new QPathEntry(Constants.JCR_LOCKISDEEP, 0));
+ (PropertyData)dataManager.getItemData(lockedNodeData, new QPathEntry(Constants.JCR_LOCKISDEEP, 0),
+ ItemType.PROPERTY);
if (dataLockIsDeep != null)
{
@@ -192,7 +194,8 @@
}
PropertyData dataLockOwner =
- (PropertyData)dataManager.getItemData(lockedNodeData, new QPathEntry(Constants.JCR_LOCKOWNER, 0));
+ (PropertyData)dataManager.getItemData(lockedNodeData, new QPathEntry(Constants.JCR_LOCKOWNER, 0),
+ ItemType.PROPERTY);
if (dataLockOwner != null)
plainChangesLog.add(ItemState.createDeletedState(new TransientPropertyData(QPath.makeChildPath(
lockedNodeData.getQPath(), Constants.JCR_LOCKOWNER), dataLockOwner.getIdentifier(), 0,
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -37,6 +37,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -703,12 +704,14 @@
new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1),
+ ItemType.PROPERTY));
changesLog.add(ItemState.createDeletedState(lockOwner));
ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1),
+ ItemType.PROPERTY));
changesLog.add(ItemState.createDeletedState(lockIsDeep));
// lock probably removed by other thread
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -36,6 +36,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -1056,7 +1057,8 @@
new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1),
+ ItemType.PROPERTY));
//TODO EXOJCR-412, should be refactored in future.
//Skip removing, because that lock was removed in other node of cluster.
@@ -1068,7 +1070,8 @@
changesLog.add(ItemState.createDeletedState(lockOwner));
ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1),
+ ItemType.PROPERTY));
//TODO EXOJCR-412, should be refactored in future.
//Skip removing, because that lock was removed in other node of cluster.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -35,6 +35,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -895,7 +896,7 @@
List<LockData> locksData = new ArrayList<LockData>();
for (String nodeId : nodesId)
{
- LockData lockData = (LockData)cache.get(makeLockFqn((String)nodeId), LOCK_DATA);
+ LockData lockData = (LockData)cache.get(makeLockFqn(nodeId), LOCK_DATA);
if (lockData != null)
{
locksData.add(lockData);
@@ -949,7 +950,8 @@
new PlainChangesLogImpl(new ArrayList<ItemState>(), SystemIdentity.SYSTEM, ExtendedEvent.UNLOCK);
ItemData lockOwner =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKOWNER, 1),
+ ItemType.PROPERTY));
//TODO EXOJCR-412, should be refactored in future.
//Skip removing, because that lock was removed in other node of cluster.
@@ -961,7 +963,8 @@
changesLog.add(ItemState.createDeletedState(lockOwner));
ItemData lockIsDeep =
- copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1)));
+ copyItemData((PropertyData)dataManager.getItemData(nData, new QPathEntry(Constants.JCR_LOCKISDEEP, 1),
+ ItemType.PROPERTY));
//TODO EXOJCR-412, should be refactored in future.
//Skip removing, because that lock was removed in other node of cluster.
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -29,6 +29,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
@@ -117,13 +118,13 @@
{
final ItemData pdata =
avoidCheckExistedChildItems ? null : targetDataManager.getItemData(parent, new QPathEntry(
- ndef.getName(), 0));
+ ndef.getName(), 0), ItemType.NODE);
if (pdata == null && !addedNodes.contains(ndef.getName()) || pdata != null && !pdata.isNode())
{
final TransientNodeData childNodeData =
- TransientNodeData.createNodeData(parent, ndef.getName(), ndef.getDefaultPrimaryType(), IdGenerator
- .generate());
+ TransientNodeData.createNodeData(parent, ndef.getName(), ndef.getDefaultPrimaryType(),
+ IdGenerator.generate());
changes.add(ItemState.createAddedState(childNodeData, false));
changes.addAll(makeAutoCreatedItems(childNodeData, childNodeData.getPrimaryTypeName(),
targetDataManager, owner).getAllStates());
@@ -162,7 +163,7 @@
final ItemData pdata =
avoidCheckExistedChildItems ? null : targetDataManager.getItemData(parent, new QPathEntry(
- pdef.getName(), 0));
+ pdef.getName(), 0), ItemType.PROPERTY);
if (pdata == null && !addedProperties.contains(pdef.getName()) || pdata != null && pdata.isNode())
{
@@ -171,8 +172,8 @@
if (listAutoCreateValue != null)
{
final TransientPropertyData propertyData =
- TransientPropertyData.createPropertyData(parent, pdef.getName(), pdef.getRequiredType(), pdef
- .isMultiple(), listAutoCreateValue);
+ TransientPropertyData.createPropertyData(parent, pdef.getName(), pdef.getRequiredType(),
+ pdef.isMultiple(), listAutoCreateValue);
changes.add(ItemState.createAddedState(propertyData));
addedProperties.add(pdef.getName());
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -700,7 +701,8 @@
// update primary type
final PropertyData item =
- (PropertyData)this.dataManager.getItemData(nodeData, new QPathEntry(Constants.JCR_PRIMARYTYPE, 1));
+ (PropertyData)this.dataManager.getItemData(nodeData, new QPathEntry(Constants.JCR_PRIMARYTYPE, 1),
+ ItemType.PROPERTY);
final TransientPropertyData primaryTypeData =
new TransientPropertyData(item.getQPath(), item.getIdentifier(), item.getPersistedVersion(), item.getType(),
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractItemDefinitionAccessProvider.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractItemDefinitionAccessProvider.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/AbstractItemDefinitionAccessProvider.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -71,7 +72,7 @@
protected List<ValueData> loadPropertyValues(NodeData parentNode, InternalQName propertyName)
throws RepositoryException
{
- ItemData property = dataManager.getItemData(parentNode, new QPathEntry(propertyName, 1));
+ ItemData property = dataManager.getItemData(parentNode, new QPathEntry(propertyName, 1), ItemType.PROPERTY);
if (property != null)
{
if (property.isNode())
@@ -344,8 +345,8 @@
writeBoolean(changesLog, itemDefinition, Constants.JCR_MANDATORY, nodeDefinitionData.isMandatory());
- writeString(changesLog, itemDefinition, Constants.JCR_ONPARENTVERSION, OnParentVersionAction
- .nameFromValue(nodeDefinitionData.getOnParentVersion()));
+ writeString(changesLog, itemDefinition, Constants.JCR_ONPARENTVERSION,
+ OnParentVersionAction.nameFromValue(nodeDefinitionData.getOnParentVersion()));
}
protected void writeName(PlainChangesLog changesLog, NodeData parentNode, InternalQName propertyName,
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -37,6 +37,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
@@ -139,7 +140,8 @@
return false;
}
- NodeData nodeTypeData = (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
+ NodeData nodeTypeData =
+ (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1), ItemType.NODE);
return nodeTypeData != null;
}
@@ -274,7 +276,7 @@
validatate();
NodeData nodeTypeData =
- (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeType.getName(), 1));
+ (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeType.getName(), 1), ItemType.NODE);
ItemDataRemoveVisitor removeVisitor = new ItemDataRemoveVisitor(dataManager, nodeTypeStorageRoot.getQPath());
nodeTypeData.accept(removeVisitor);
@@ -293,7 +295,8 @@
if (jcrSystem != null)
{
NodeData jcrNodetypes =
- (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.JCR_NODETYPES, 1));
+ (NodeData)dataManager.getItemData(jcrSystem, new QPathEntry(Constants.JCR_NODETYPES, 1),
+ ItemType.NODE);
if (jcrNodetypes == null)
{
this.nodeTypeStorageRoot = initNodetypesRoot(jcrSystem, addACL);
@@ -331,7 +334,7 @@
return null;
}
//Searching nodeType root
- ItemData nodeType = dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1));
+ ItemData nodeType = dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeName, 1), ItemType.NODE);
if (nodeType == null)
throw new NoSuchNodeTypeException("Node type definition " + nodeTypeName.getAsString() + "not found");
if (!nodeType.isNode())
@@ -395,7 +398,8 @@
}
// remove first
NodeData removeNodeTypeData =
- (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeData.getName(), 1));
+ (NodeData)dataManager.getItemData(nodeTypeStorageRoot, new QPathEntry(nodeTypeData.getName(), 1),
+ ItemType.NODE);
if (removeNodeTypeData != null)
{
ItemDataRemoveVisitor removeVisitor =
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
@@ -75,6 +76,7 @@
this.affectedNodes = affectedNodes;
}
+ @Override
public PlainChangesLog compare(NodeTypeData registeredNodeType, NodeDefinitionData[] ancestorDefinition,
NodeDefinitionData[] recipientDefinition) throws ConstraintViolationException, RepositoryException
{
@@ -114,7 +116,8 @@
{
for (NodeData nodeData : nodesData)
{
- ItemData child = dataConsumer.getItemData(nodeData, new QPathEntry(nodeDefinitionData.getName(), 0));
+ ItemData child =
+ dataConsumer.getItemData(nodeData, new QPathEntry(nodeDefinitionData.getName(), 0), ItemType.NODE);
if (child == null || !child.isNode())
{
throw new ConstraintViolationException("Fail to add mandatory and not auto-created "
@@ -153,8 +156,8 @@
{
for (int i = 0; i < requiredPrimaryTypes.length; i++)
{
- if (!nodeTypeDataManager.isNodeType(requiredPrimaryTypes[i], child.getPrimaryTypeName(), child
- .getMixinTypeNames()))
+ if (!nodeTypeDataManager.isNodeType(requiredPrimaryTypes[i], child.getPrimaryTypeName(),
+ child.getMixinTypeNames()))
{
StringBuffer buffer = new StringBuffer();
buffer.append("Fail to change ");
@@ -189,8 +192,8 @@
{
for (int i = 0; i < requiredPrimaryTypes.length; i++)
{
- if (!nodeTypeDataManager.isNodeType(requiredPrimaryTypes[i], child.getPrimaryTypeName(), child
- .getMixinTypeNames()))
+ if (!nodeTypeDataManager.isNodeType(requiredPrimaryTypes[i], child.getPrimaryTypeName(),
+ child.getMixinTypeNames()))
{
StringBuffer buffer = new StringBuffer();
buffer.append("Fail to change ");
@@ -388,7 +391,8 @@
{
ItemData child =
- dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0));
+ dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0),
+ ItemType.NODE);
if (child == null || !child.isNode())
{
String message =
@@ -410,7 +414,8 @@
{
ItemData child =
- dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0));
+ dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0),
+ ItemType.NODE);
if (child == null || !child.isNode())
{
String message =
@@ -423,8 +428,8 @@
}
}
}
- if (!Arrays.deepEquals(ancestorDefinitionData.getRequiredPrimaryTypes(), recipientDefinitionData
- .getRequiredPrimaryTypes()))
+ if (!Arrays.deepEquals(ancestorDefinitionData.getRequiredPrimaryTypes(),
+ recipientDefinitionData.getRequiredPrimaryTypes()))
{
checkRequiredPrimaryType(registeredNodeType, nodesData, ancestorDefinitionData.getRequiredPrimaryTypes(),
recipientDefinitionData, allRecipientDefinition);
@@ -483,7 +488,8 @@
for (NodeData nodeData : nodesData)
{
ItemData child =
- dataConsumer.getItemData(nodeData, new QPathEntry(removeNodeDefinitionData.getName(), 0));
+ dataConsumer.getItemData(nodeData, new QPathEntry(removeNodeDefinitionData.getName(), 0),
+ ItemType.NODE);
if (child != null && child.isNode())
{
throw new ConstraintViolationException("Can't remove node definition "
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -84,6 +85,7 @@
this.locationFactory = locationFactory;
}
+ @Override
public PlainChangesLog compare(NodeTypeData registeredNodeType, PropertyDefinitionData[] ancestorDefinition,
PropertyDefinitionData[] recipientDefinition) throws RepositoryException
{
@@ -158,7 +160,8 @@
else
{
PropertyData propertyData =
- (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0));
+ (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0),
+ ItemType.PROPERTY);
if (propertyData.getValues().size() > 1)
{
throw new ConstraintViolationException("Can't change property definition "
@@ -275,7 +278,8 @@
else
{
PropertyData propertyData =
- (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0));
+ (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0),
+ ItemType.PROPERTY);
if (recipientDefinitionData.getRequiredType() != PropertyType.UNDEFINED
&& propertyData.getType() != recipientDefinitionData.getRequiredType())
{
@@ -329,7 +333,8 @@
else
{
PropertyData propertyData =
- (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0));
+ (PropertyData)dataConsumer.getItemData(nodeData, new QPathEntry(recipientDefinitionData.getName(), 0),
+ ItemType.PROPERTY);
checkValueConstraints(recipientDefinitionData, propertyData);
}
}
@@ -388,7 +393,8 @@
&& newPropertyDefinitionData.isAutoCreated())
{
ItemData pdata =
- dataConsumer.getItemData(nodeData, new QPathEntry(newPropertyDefinitionData.getName(), 0));
+ dataConsumer.getItemData(nodeData, new QPathEntry(newPropertyDefinitionData.getName(), 0),
+ ItemType.UNKNOWN);
if (pdata == null || (pdata != null && pdata.isNode()))
{
PlainChangesLog autoCreatedChanges =
@@ -521,8 +527,8 @@
checkRequiredType(registeredNodeType, recipientDefinitionData, allRecipientDefinition, nodesData);
}
// ValueConstraints
- if (!Arrays.deepEquals(ancestorDefinitionData.getValueConstraints(), recipientDefinitionData
- .getValueConstraints()))
+ if (!Arrays.deepEquals(ancestorDefinitionData.getValueConstraints(),
+ recipientDefinitionData.getValueConstraints()))
{
checkValueConstraints(registeredNodeType, recipientDefinitionData, allRecipientDefinition, nodesData);
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -408,7 +409,7 @@
else
{
cne = new ArrayList<NodeData>();
- ItemData item = ism.getItemData(nodeState, currentName);
+ ItemData item = ism.getItemData(nodeState, currentName, ItemType.NODE);
if (item != null && item.isNode())
{
cne.add((NodeData)item);
@@ -501,7 +502,7 @@
for (Iterator it = nodeStates.iterator(); it.hasNext();)
{
NodeData state = (NodeData)it.next();
- ItemData prop = ism.getItemData(state, new QPathEntry(propertyName, 1));
+ ItemData prop = ism.getItemData(state, new QPathEntry(propertyName, 1), ItemType.PROPERTY);
if (prop != null && !prop.isNode())
{
propStates.add(prop);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -20,9 +20,9 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.BooleanClause.Occur;
import org.exoplatform.commons.utils.ISO8601;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
@@ -30,6 +30,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -760,6 +761,7 @@
final int[] transform = new int[]{TransformConstants.TRANSFORM_NONE};
node.acceptOperands(new DefaultQueryNodeVisitor()
{
+ @Override
public Object visit(PropertyFunctionQueryNode node, Object data)
{
if (node.getFunctionName().equals(PropertyFunctionQueryNode.LOWER_CASE))
@@ -1030,7 +1032,7 @@
ItemData item = parent;
for (int i = 0; i < relPathEntries.length; i++)
{
- item = sharedItemMgr.getItemData(parent, relPathEntries[i]);
+ item = sharedItemMgr.getItemData(parent, relPathEntries[i], ItemType.UNKNOWN);
if (item == null)
break;
@@ -1333,6 +1335,6 @@
values.add(literal);
log.debug("Using literal " + literal + " as is.");
}
- return (String[])values.toArray(new String[values.size()]);
+ return values.toArray(new String[values.size()]);
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.core.value.ExtendedValue;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -292,7 +293,8 @@
// seems nt:file found, try for nt:resource props
PropertyData pmime =
- (PropertyData)stateProvider.getItemData(node, new QPathEntry(Constants.JCR_MIMETYPE, 0));
+ (PropertyData)stateProvider.getItemData(node, new QPathEntry(Constants.JCR_MIMETYPE, 0),
+ ItemType.PROPERTY);
if (pmime != null)
{
// ok, have a reader
@@ -300,7 +302,7 @@
// otherwise read prop with values from DM
PropertyData propData =
prop.getValues().size() > 0 ? prop : ((PropertyData)stateProvider.getItemData(node, new QPathEntry(
- Constants.JCR_DATA, 0)));
+ Constants.JCR_DATA, 0), ItemType.PROPERTY));
// index if have jcr:mimeType sibling for this binary property only
try
@@ -315,7 +317,8 @@
// check the jcr:encoding property
PropertyData encProp =
- (PropertyData)stateProvider.getItemData(node, new QPathEntry(Constants.JCR_ENCODING, 0));
+ (PropertyData)stateProvider.getItemData(node, new QPathEntry(Constants.JCR_ENCODING, 0),
+ ItemType.PROPERTY);
if (encProp != null)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedFieldSortComparator.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedFieldSortComparator.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SharedFieldSortComparator.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -16,13 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.ScoreDoc;
@@ -33,6 +26,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -42,6 +36,13 @@
import org.exoplatform.services.jcr.impl.core.JCRPath;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
/**
* Implements a <code>SortComparator</code> which knows how to sort on a lucene
* field that contains values for multiple properties.
@@ -96,6 +97,7 @@
* @return a <code>ScoreDocComparator</code> for the
* @throws IOException if an error occurs while reading from the index.
*/
+ @Override
public ScoreDocComparator newComparator(IndexReader reader, String relPath) throws IOException
{
@@ -126,6 +128,7 @@
/**
* @throws UnsupportedOperationException always.
*/
+ @Override
protected Comparable getComparable(String termtext)
{
throw new UnsupportedOperationException();
@@ -317,7 +320,7 @@
ItemData parent = ism.getItemData(uuid);
if (!parent.isNode())
throw new InvalidItemStateException();
- ItemData property = getItemData((NodeData)parent, relPath);
+ ItemData property = getItemData((NodeData)parent, relPath, ItemType.PROPERTY);
if (property != null)
{
if (property.isNode())
@@ -339,7 +342,7 @@
}
}
- private ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
+ private ItemData getItemData(NodeData parent, QPathEntry name, ItemType itemType) throws RepositoryException
{
if (name.getName().equals(JCRPath.PARENT_RELPATH) && name.getNamespace().equals(Constants.NS_DEFAULT_URI))
{
@@ -349,19 +352,26 @@
return ism.getItemData(parent.getParentIdentifier());
}
- return ism.getItemData(parent, name);
+ return ism.getItemData(parent, name, itemType);
}
- private ItemData getItemData(NodeData parent, QPath relPath) throws RepositoryException
+ private ItemData getItemData(NodeData parent, QPath relPath, ItemType itemType) throws RepositoryException
{
- QPathEntry[] relPathEntries =relPath.getEntries(); //relPath.getRelPath(relPath.getDepth());
+ QPathEntry[] relPathEntries = relPath.getEntries(); //relPath.getRelPath(relPath.getDepth());
ItemData item = parent;
for (int i = 0; i < relPathEntries.length; i++)
{
- item = getItemData(parent, relPathEntries[i]);
+ if (i == relPathEntries.length - 1)
+ {
+ item = getItemData(parent, relPathEntries[i], itemType);
+ }
+ else
+ {
+ item = getItemData(parent, relPathEntries[i], ItemType.UNKNOWN);
+ }
if (item == null)
break;
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/FrozenNodeInitializer.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -271,8 +272,8 @@
false, new TransientValueData(Constants.NT_VERSIONEDCHILD));
ValueData vh =
- ((PropertyData)dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 0)))
- .getValues().get(0);
+ ((PropertyData)dataManager.getItemData(node, new QPathEntry(Constants.JCR_VERSIONHISTORY, 0),
+ ItemType.PROPERTY)).getValues().get(0);
PropertyData pd =
TransientPropertyData.createPropertyData(frozenNode, Constants.JCR_CHILDVERSIONHISTORY,
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.DataManager;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -112,6 +113,7 @@
mergeSession.getAccessManager(), mergeSession.getUserState());
}
+ @Override
protected void validateReferential(NodeData node) throws RepositoryException
{
// no REFERENCE validation here
@@ -299,7 +301,8 @@
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
PropertyData isCheckedOutProperty =
- (PropertyData)mergeDataManager.getItemData(mergeNode, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 0));
+ (PropertyData)mergeDataManager.getItemData(mergeNode, new QPathEntry(Constants.JCR_ISCHECKEDOUT, 0),
+ ItemType.PROPERTY);
try
{
@@ -361,9 +364,9 @@
QPath mergePath = mergeNode.getQPath();
TransientNodeData mergedNode =
- new TransientNodeData(mergePath, mergeNode.getIdentifier(), mergeNode.getPersistedVersion(), corrNode
- .getPrimaryTypeName(), corrNode.getMixinTypeNames(), mergeNode.getOrderNumber(), mergeNode
- .getParentIdentifier(), mergeNode.getACL());
+ new TransientNodeData(mergePath, mergeNode.getIdentifier(), mergeNode.getPersistedVersion(),
+ corrNode.getPrimaryTypeName(), corrNode.getMixinTypeNames(), mergeNode.getOrderNumber(),
+ mergeNode.getParentIdentifier(), mergeNode.getACL());
if (!mergeNode.getIdentifier().equals(corrNode.getIdentifier()))
{
@@ -393,8 +396,8 @@
for (PropertyData cp : mergeChildProps)
{
TransientPropertyData existed =
- new TransientPropertyData(cp.getQPath(), cp.getIdentifier(), cp.getPersistedVersion(), cp.getType(), cp
- .getParentIdentifier(), cp.isMultiValued(), copyValues(cp));
+ new TransientPropertyData(cp.getQPath(), cp.getIdentifier(), cp.getPersistedVersion(), cp.getType(),
+ cp.getParentIdentifier(), cp.isMultiValued(), copyValues(cp));
changes.add(new ItemState(existed, ItemState.DELETED, true, mergedNode.getQPath(), true));
existedProps.put(existed.getQPath().getName(), existed);
@@ -405,8 +408,8 @@
PropertyData existed = existedProps.get(cp.getQPath().getName());
TransientPropertyData mcp =
new TransientPropertyData(QPath.makeChildPath(mergePath, cp.getQPath().getName()), existed != null
- ? existed.getIdentifier() : cp.getIdentifier(), existed != null ? existed.getPersistedVersion() : cp
- .getPersistedVersion(), cp.getType(), mergedNode.getIdentifier(), cp.isMultiValued(), copyValues(cp));
+ ? existed.getIdentifier() : cp.getIdentifier(), existed != null ? existed.getPersistedVersion()
+ : cp.getPersistedVersion(), cp.getType(), mergedNode.getIdentifier(), cp.isMultiValued(), copyValues(cp));
changes.add(new ItemState(mcp, ItemState.ADDED, true, mergedNode.getQPath(), true));
}
@@ -462,7 +465,7 @@
SessionDataManager dmanager = session.getTransientNodesManager();
PropertyData bvProperty =
- (PropertyData)dmanager.getItemData(node, new QPathEntry(Constants.JCR_BASEVERSION, 0));
+ (PropertyData)dmanager.getItemData(node, new QPathEntry(Constants.JCR_BASEVERSION, 0), ItemType.PROPERTY);
try
{
@@ -486,8 +489,8 @@
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
NodeTypeDataManager mergeNtManager = mergeSession.getWorkspace().getNodeTypesHolder();
- if (mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeNode.getPrimaryTypeName(), mergeNode
- .getMixinTypeNames()))
+ if (mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeNode.getPrimaryTypeName(),
+ mergeNode.getMixinTypeNames()))
{
// by UUID
return (NodeData)corrDataManager.getItemData(mergeNode.getIdentifier());
@@ -499,15 +502,15 @@
final QPath ancesstorPath = mergePath.makeAncestorPath(i);
NodeData mergeAncestor = (NodeData)mergeDataManager.getItemData(ancesstorPath);
if (mergeAncestor != null
- && mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeAncestor.getPrimaryTypeName(), mergeAncestor
- .getMixinTypeNames()))
+ && mergeNtManager.isNodeType(Constants.MIX_REFERENCEABLE, mergeAncestor.getPrimaryTypeName(),
+ mergeAncestor.getMixinTypeNames()))
{
NodeData corrAncestor = (NodeData)corrDataManager.getItemData(mergeAncestor.getIdentifier());
if (corrAncestor != null)
{
QPathEntry[] relPathEntries = mergePath.getRelPath(mergePath.getDepth() - i);
- return (NodeData)corrDataManager.getItemData(corrAncestor, relPathEntries);
+ return (NodeData)corrDataManager.getItemData(corrAncestor, relPathEntries, ItemType.NODE);
}
}
}
@@ -523,7 +526,8 @@
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
PropertyData predecessorsProperty =
- (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY);
if (predecessorsProperty != null)
for (ValueData pv : predecessorsProperty.getValues())
@@ -568,7 +572,8 @@
SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager();
PropertyData successorsProperty =
- (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0),
+ ItemType.PROPERTY);
if (successorsProperty != null)
for (ValueData sv : successorsProperty.getValues())
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataRestoreVisitor.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -127,6 +128,7 @@
userSession.getUserState());
}
+ @Override
protected void validateReferential(NodeData node) throws RepositoryException
{
// no REFERENCE validation here
@@ -221,7 +223,7 @@
log.debug("Restore: " + nodePath.getAsString() + ", removeExisting=" + removeExisting);
PropertyData frozenIdentifier =
- (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENUUID, 1));
+ (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENUUID, 1), ItemType.PROPERTY);
String fidentifier = null;
NodeData existing = null;
@@ -275,6 +277,7 @@
.getAccessManager(), userSession.getUserState());
}
+ @Override
protected boolean isRemoveDescendant(ItemData item) throws RepositoryException
{
return item.getQPath().isDescendantOf(removedRoot.getQPath())
@@ -310,10 +313,12 @@
}
PropertyData frozenPrimaryType =
- (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENPRIMARYTYPE, 0));
+ (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENPRIMARYTYPE, 0),
+ ItemType.PROPERTY);
PropertyData frozenMixinTypes =
- (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENMIXINTYPES, 0));
+ (PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_FROZENMIXINTYPES, 0),
+ ItemType.PROPERTY);
InternalQName[] mixins = null;
if (frozenMixinTypes != null)
@@ -422,7 +427,7 @@
String vhIdentifier =
new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(
- Constants.JCR_CHILDVERSIONHISTORY, 0))).getValues().get(0).getAsByteArray());
+ Constants.JCR_CHILDVERSIONHISTORY, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());
NodeData cHistory = null;
if ((cHistory = (NodeData)dataManager.getItemData(vhIdentifier)) == null)
@@ -446,7 +451,7 @@
{
versionableIdentifier =
new String(((PropertyData)dataManager.getItemData(childHistory, new QPathEntry(
- Constants.JCR_VERSIONABLEUUID, 0))).getValues().get(0).getAsByteArray());
+ Constants.JCR_VERSIONABLEUUID, 0), ItemType.PROPERTY)).getValues().get(0).getAsByteArray());
}
catch (IOException e)
@@ -477,7 +482,8 @@
// not found, gets last version (by time of creation) and restore it
NodeData lastVersionData = childHistory.getLastVersionData();
NodeData cvFrozen =
- (NodeData)dataManager.getItemData(lastVersionData, new QPathEntry(Constants.JCR_FROZENNODE, 1));
+ (NodeData)dataManager.getItemData(lastVersionData, new QPathEntry(Constants.JCR_FROZENNODE, 1),
+ ItemType.NODE);
ItemDataRestoreVisitor restoreVisitor =
new ItemDataRestoreVisitor(currentNode(), qname, childHistory, userSession, removeExisting, changes);
@@ -524,8 +530,8 @@
try
{
jcrUuid =
- new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_UUID, 0)))
- .getValues().get(0).getAsByteArray());
+ new String(((PropertyData)dataManager.getItemData(frozen, new QPathEntry(Constants.JCR_UUID, 0),
+ ItemType.PROPERTY)).getValues().get(0).getAsByteArray());
}
catch (IOException e)
@@ -540,7 +546,7 @@
// try to use existing node uuid, otherwise to generate one new
existing =
(NodeData)dataManager.getItemData(currentNode(), new QPathEntry(frozen.getQPath().getName(), frozen
- .getQPath().getIndex()));
+ .getQPath().getIndex()), ItemType.NODE);
if (existing != null)
{
jcrUuid = existing.getIdentifier();
@@ -595,7 +601,8 @@
{
// current C in the workspace will be left unchanged,
NodeData existed =
- (NodeData)dataManager.getItemData(currentNode(), new QPathEntry(frozen.getQPath().getName(), 0));
+ (NodeData)dataManager.getItemData(currentNode(), new QPathEntry(frozen.getQPath().getName(), 0),
+ ItemType.NODE);
if (existed != null)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -108,7 +109,8 @@
checkValid();
PropertyData versionableUuid =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_VERSIONABLEUUID, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_VERSIONABLEUUID, 0),
+ ItemType.PROPERTY);
if (versionableUuid != null)
try
@@ -136,7 +138,8 @@
checkValid();
VersionImpl version =
- (VersionImpl)dataManager.getItem(nodeData(), new QPathEntry(Constants.JCR_ROOTVERSION, 0), true);
+ (VersionImpl)dataManager
+ .getItem(nodeData(), new QPathEntry(Constants.JCR_ROOTVERSION, 0), true, ItemType.NODE);
if (version == null)
throw new VersionException("There are no root version in the version history " + getPath());
@@ -182,7 +185,8 @@
JCRName jcrVersionName = locationFactory.parseJCRName(versionName);
VersionImpl version =
- (VersionImpl)dataManager.getItem(nodeData(), new QPathEntry(jcrVersionName.getInternalName(), 1), pool);
+ (VersionImpl)dataManager.getItem(nodeData(), new QPathEntry(jcrVersionName.getInternalName(), 1), pool,
+ ItemType.NODE);
if (version == null)
throw new VersionException("There are no version with name '" + versionName + "' in the version history "
+ getPath());
@@ -340,13 +344,13 @@
// and point successor to predecessor directly
PropertyData successorsData =
- (PropertyData)dataManager
- .getItemData((NodeData)version.getData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)dataManager.getItemData((NodeData)version.getData(),
+ new QPathEntry(Constants.JCR_SUCCESSORS, 0), ItemType.PROPERTY);
// jcr:predecessors
PropertyData predecessorsData =
(PropertyData)dataManager.getItemData((NodeData)version.getData(), new QPathEntry(Constants.JCR_PREDECESSORS,
- 0));
+ 0), ItemType.PROPERTY);
try
{
@@ -516,7 +520,8 @@
InternalQName labelQName = jcrLabelName.getInternalName();
PropertyData vldata =
- (PropertyData)dataManager.getItemData(getData().getVersionLabelsData(), new QPathEntry(labelQName, 0));
+ (PropertyData)dataManager.getItemData(getData().getVersionLabelsData(), new QPathEntry(labelQName, 0),
+ ItemType.PROPERTY);
if (vldata != null)
{
@@ -567,8 +572,8 @@
// A reference to V is added to the jcr:successors property of
// each of the versions identified in Vs jcr:predecessors property.
List<ValueData> predecessors =
- ((PropertyData)dataManager.getItemData(versionableNodeData, new QPathEntry(Constants.JCR_PREDECESSORS, 0)))
- .getValues();
+ ((PropertyData)dataManager.getItemData(versionableNodeData, new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY)).getValues();
List<ValueData> predecessorsNew = new ArrayList<ValueData>();
for (ValueData predecessorValue : predecessors)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.Identifier;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -80,7 +81,8 @@
{
checkValid();
- PropertyData pdata = (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_CREATED, 0));
+ PropertyData pdata =
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_CREATED, 0), ItemType.PROPERTY);
if (pdata == null)
{
@@ -99,7 +101,8 @@
checkValid();
PropertyData successorsData =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0),
+ ItemType.PROPERTY);
if (successorsData == null)
{
@@ -138,7 +141,8 @@
checkValid();
PropertyData predecessorsData =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY);
if (predecessorsData == null)
{
@@ -178,7 +182,8 @@
ValueData successorRef = new TransientValueData(new Identifier(successorIdentifier));
PropertyData successorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0),
+ ItemType.PROPERTY);
if (successorsProp == null)
{
@@ -222,7 +227,8 @@
ValueData predeccessorRef = new TransientValueData(new Identifier(predeccessorIdentifier));
PropertyData predeccessorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY);
if (predeccessorsProp == null)
{
@@ -263,7 +269,8 @@
void removeSuccessor(String successorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
PropertyData successorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0),
+ ItemType.PROPERTY);
if (successorsProp != null)
{
List<ValueData> newSuccessors = new ArrayList<ValueData>();
@@ -302,7 +309,8 @@
{
PropertyData successorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_SUCCESSORS, 0),
+ ItemType.PROPERTY);
if (successorsProp != null)
{
@@ -342,7 +350,8 @@
void removePredecessor(String predecessorIdentifier, PlainChangesLog changesLog) throws RepositoryException
{
PropertyData predeccessorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY);
if (predeccessorsProp != null)
{
@@ -382,7 +391,8 @@
{
PropertyData predeccessorsProp =
- (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0));
+ (PropertyData)dataManager.getItemData(nodeData(), new QPathEntry(Constants.JCR_PREDECESSORS, 0),
+ ItemType.PROPERTY);
if (predeccessorsProp != null)
{
@@ -448,7 +458,8 @@
DataManager dmanager = restoreSession.getTransientNodesManager().getTransactManager();
- NodeData frozenData = (NodeData)dmanager.getItemData(nodeData(), new QPathEntry(Constants.JCR_FROZENNODE, 1));
+ NodeData frozenData =
+ (NodeData)dmanager.getItemData(nodeData(), new QPathEntry(Constants.JCR_FROZENNODE, 1), ItemType.NODE);
ItemDataRestoreVisitor restoreVisitor =
new ItemDataRestoreVisitor(destParent, name, historyData, restoreSession, removeExisting, delegatedLog);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/ACLInheritanceSupportedWorkspaceDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -101,16 +102,16 @@
{
// use parent ACL
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
- .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
+ node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), parent.getACL());
}
else
{
// use nearest ancestor ACL... case of get by id
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
- .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
+ node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), getNearestACAncestorAcl(node));
}
}
@@ -120,9 +121,9 @@
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
- .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
- new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
+ node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ node.getParentIdentifier(), new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
}
else if (!acl.hasOwner())
{
@@ -130,9 +131,9 @@
AccessControlList ancestorAcl = getNearestACAncestorAcl(node);
node =
- new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
- .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
- new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
+ new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
+ node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
+ node.getParentIdentifier(), new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
}
}
@@ -167,7 +168,15 @@
*/
public ItemData getItemData(NodeData parent, QPathEntry name) throws RepositoryException
{
- final ItemData item = persistentManager.getItemData(parent, name);
+ return getItemData(parent, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parent, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
+ final ItemData item = persistentManager.getItemData(parent, name, itemType);
return item != null && item.isNode() ? initACL(parent, (NodeData)item) : item;
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheQPath.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheQPath.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheQPath.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -18,6 +18,7 @@
*/
package org.exoplatform.services.jcr.impl.dataflow.persistent;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
@@ -68,37 +69,42 @@
private final String key;
+ private final ItemType itemType;
+
/**
* For CPath will be stored in cache C
*/
- CacheQPath(String parentId, QPath path)
+ CacheQPath(String parentId, QPath path, ItemType itemType)
{
this.parentId = parentId;
this.path = path;
- this.key = key(this.parentId, this.path.getEntries());
+ this.itemType = itemType;
+ this.key = key(this.parentId, this.path.getEntries(), this.itemType);
}
/**
* For CPath will be searched in cache C
*/
- CacheQPath(String parentId, QPathEntry name)
+ CacheQPath(String parentId, QPathEntry name, ItemType itemType)
{
this.parentId = parentId;
this.path = null;
- this.key = key(this.parentId, name);
+ this.itemType = itemType;
+ this.key = key(this.parentId, name, this.itemType);
}
- protected String key(final String parentId, final QPathEntry[] pathEntries)
+ protected String key(final String parentId, final QPathEntry[] pathEntries, ItemType itemType)
{
- return key(parentId, pathEntries[pathEntries.length - 1]);
+ return key(parentId, pathEntries[pathEntries.length - 1], itemType);
}
- protected String key(final String parentId, final QPathEntry name)
+ protected String key(final String parentId, final QPathEntry name, ItemType itemType)
{
StringBuilder sk = new StringBuilder();
// sk.append(BASE); for strong hash code, skip it when equals uses String.equals
sk.append(parentId != null ? parentId : Constants.ROOT_PARENT_UUID);
sk.append(name.getAsString(true));
+ sk.append(itemType.toString());
return sk.toString();
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -21,6 +21,7 @@
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -337,6 +338,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public int getChildNodesCount(NodeData parent) throws RepositoryException
{
if (cache.isEnabled())
@@ -354,6 +356,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<NodeData> getChildNodesData(NodeData nodeData) throws RepositoryException
{
return getChildNodesData(nodeData, false);
@@ -362,6 +365,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws RepositoryException
{
List<PropertyData> childs = getChildPropertiesData(nodeData, false);
@@ -378,9 +382,18 @@
*/
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
+
// 1. Try from cache
- ItemData data = getCachedItemData(parentData, name);
+ ItemData data = getCachedItemData(parentData, name, itemType);
// 2. Try from container
if (data == null)
@@ -392,10 +405,10 @@
request.start();
// Try first to get the value from the cache since a
// request could have been launched just before
- data = getCachedItemData(parentData, name);
+ data = getCachedItemData(parentData, name, itemType);
if (data == null)
{
- data = getPersistedItemData(parentData, name);
+ data = getPersistedItemData(parentData, name, itemType);
}
else if (!data.isNode())
{
@@ -418,6 +431,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public ItemData getItemData(String identifier) throws RepositoryException
{
// 2. Try from cache
@@ -459,6 +473,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> getReferencesData(String identifier, boolean skipVersionStorage)
throws RepositoryException
{
@@ -468,6 +483,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public List<PropertyData> listChildPropertiesData(NodeData nodeData) throws RepositoryException
{
return listChildPropertiesData(nodeData, false);
@@ -501,13 +517,16 @@
* parent
* @param name
* Item name
+ * @param itemType
+ * item type
* @return ItemData
* @throws RepositoryException
* error
*/
- protected ItemData getCachedItemData(NodeData parentData, QPathEntry name) throws RepositoryException
+ protected ItemData getCachedItemData(NodeData parentData, QPathEntry name, ItemType itemType)
+ throws RepositoryException
{
- return cache.get(parentData.getIdentifier(), name);
+ return cache.get(parentData.getIdentifier(), name, itemType);
}
/**
@@ -647,13 +666,16 @@
* parent
* @param name
* Item name
+ * @param itemType
+ * item type
* @return ItemData
* @throws RepositoryException
* error
*/
- protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name) throws RepositoryException
+ protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name, ItemType itemType)
+ throws RepositoryException
{
- ItemData data = super.getItemData(parentData, name);
+ ItemData data = super.getItemData(parentData, name, itemType);
if (data != null && cache.isEnabled())
{
cache.put(data);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.dataflow.ItemStateChangesLog;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -41,10 +42,10 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Timer;
import java.util.TimerTask;
import java.util.WeakHashMap;
-import java.util.Map.Entry;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.ReentrantLock;
@@ -882,11 +883,30 @@
*/
public ItemData get(final String parentId, final QPathEntry name)
{
+ return get(parentId, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData get(final String parentId, final QPathEntry name, ItemType itemType)
+ {
if (enabled && parentId != null && name != null)
{
try
{
- return getItem(parentId, name);
+ ItemData itemData = null;
+ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+ {
+ itemData = getItem(parentId, name, ItemType.NODE);
+ }
+
+ if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemData == null)
+ {
+ itemData = getItem(parentId, name, ItemType.PROPERTY);
+ }
+
+ return itemData;
}
catch (Exception e)
{
@@ -906,9 +926,8 @@
protected void putItem(final ItemData data)
{
cache.put(new CacheId(data.getIdentifier()), new CacheValue(data, System.currentTimeMillis() + liveTime));
- cache.put(new CacheQPath(data.getParentIdentifier(), data.getQPath()), new CacheValue(data, System
- .currentTimeMillis()
- + liveTime));
+ cache.put(new CacheQPath(data.getParentIdentifier(), data.getQPath(), ItemType.getItemType(data)),
+ new CacheValue(data, System.currentTimeMillis() + liveTime));
}
/**
@@ -1052,7 +1071,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1114,7 +1133,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1165,7 +1184,7 @@
{
if (enabled && parentData != null && childItems != null)
{ // TODO don't check parentData !=
- // null && childItems != null
+ // null && childItems != null
String logInfo = null;
if (LOG.isDebugEnabled())
@@ -1303,7 +1322,7 @@
cache.remove(k);
// remove by parentId + path
- cache.remove(new CacheQPath(c.getParentIdentifier(), c.getQPath()));
+ cache.remove(new CacheQPath(c.getParentIdentifier(), c.getQPath(), ItemType.getItemType(c)));
// remove cached child lists
if (c.isNode())
@@ -1333,12 +1352,12 @@
* @param key
* a InternalQPath path of item cached
*/
- protected ItemData getItem(final String parentUuid, final QPathEntry qname)
+ protected ItemData getItem(final String parentUuid, final QPathEntry qname, ItemType itemType)
{
long start = System.currentTimeMillis();
try
{
- final CacheQPath k = new CacheQPath(parentUuid, qname);
+ final CacheQPath k = new CacheQPath(parentUuid, qname, itemType);
final CacheValue v = cache.get(k);
if (v != null)
{
@@ -1643,8 +1662,7 @@
{
writeLock.unlock();
}
- LOG
- .info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
+ LOG.info(name + " : set liveTime=" + liveTime + "ms. New value will be applied to items cached from this moment.");
}
/**
@@ -1658,7 +1676,8 @@
cache.remove(new CacheId(itemId));
- final CacheValue v2 = cache.remove(new CacheQPath(item.getParentIdentifier(), item.getQPath()));
+ final CacheValue v2 =
+ cache.remove(new CacheQPath(item.getParentIdentifier(), item.getQPath(), ItemType.getItemType(item)));
if (v2 != null && !v2.getItem().getIdentifier().equals(itemId))
// same path but diff identifier node... phantom
removeItem(v2.getItem());
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -26,6 +26,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -126,18 +127,26 @@
/**
* {@inheritDoc}
*/
- @Override
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
if (parentData != null)
{
final QPath ipath = QPath.makeChildPath(parentData.getQPath(), name);
if (isSystemDescendant(ipath) && !this.equals(versionDataManager))
{
- return versionDataManager.getItemData(parentData, name);
+ return versionDataManager.getItemData(parentData, name, itemType);
}
}
- return super.getItemData(parentData, name);
+ return super.getItemData(parentData, name, itemType);
}
/**
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -33,6 +33,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -229,7 +230,7 @@
// if it's different container instances
? systemDataContainer.equals(dataContainer) && thisConnection != null
// but container confugrations are same and non-system connnection open
- // reuse this connection as system
+ // reuse this connection as system
? systemDataContainer.reuseConnection(thisConnection)
// or open one new system
: systemDataContainer.openConnection()
@@ -251,7 +252,7 @@
// if it's different container instances
? dataContainer.equals(systemDataContainer) && systemConnection != null
// but container confugrations are same and system connnection open
- // reuse system connection as this
+ // reuse system connection as this
? dataContainer.reuseConnection(systemConnection)
// or open one new
: dataContainer.openConnection()
@@ -290,9 +291,9 @@
{
NodeData prevData = (NodeData)prevState.getData();
newData =
- new PersistedNodeData(prevData.getIdentifier(), prevData.getQPath(), prevData
- .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getOrderNumber(), prevData
- .getPrimaryTypeName(), prevData.getMixinTypeNames(), prevData.getACL());
+ new PersistedNodeData(prevData.getIdentifier(), prevData.getQPath(),
+ prevData.getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getOrderNumber(),
+ prevData.getPrimaryTypeName(), prevData.getMixinTypeNames(), prevData.getACL());
}
else
{
@@ -344,16 +345,16 @@
}
newData =
- new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
- .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
- .isMultiValued(), values);
+ new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(),
+ prevData.getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(),
+ prevData.isMultiValued(), values);
}
else
{
newData =
- new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(), prevData
- .getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(), prevData
- .isMultiValued(), null);
+ new PersistedPropertyData(prevData.getIdentifier(), prevData.getQPath(),
+ prevData.getParentIdentifier(), prevData.getPersistedVersion() + 1, prevData.getType(),
+ prevData.isMultiValued(), null);
}
}
}
@@ -577,7 +578,9 @@
NodeData parent = (NodeData)acon.getItemData(node.getParentIdentifier());
QPathEntry myName = node.getQPath().getEntries()[node.getQPath().getEntries().length - 1];
ItemData sibling =
- acon.getItemData(parent, new QPathEntry(myName.getNamespace(), myName.getName(), myName.getIndex() - 1));
+ acon.getItemData(parent, new QPathEntry(myName.getNamespace(), myName.getName(), myName.getIndex() - 1),
+ ItemType.NODE);
+
if (sibling == null || !sibling.isNode())
{
throw new InvalidItemStateException("Node can't be saved " + node.getQPath().getAsString()
@@ -798,10 +801,19 @@
*/
public ItemData getItemData(final NodeData parentData, final QPathEntry name) throws RepositoryException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(final NodeData parentData, final QPathEntry name, ItemType itemType)
+ throws RepositoryException
+ {
final WorkspaceStorageConnection con = dataContainer.openConnection();
try
{
- return con.getItemData(parentData, name);
+ return con.getItemData(parentData, name, itemType);
}
finally
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -28,6 +28,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -592,11 +593,23 @@
*/
public ItemData get(String parentId, QPathEntry name)
{
+ return get(parentId, name, ItemType.UNKNOWN);
+ }
- // get as node first
- String itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
- if (itemId == null)
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData get(String parentId, QPathEntry name, ItemType itemType)
+ {
+ String itemId = null;
+ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
{
+ // try as node first
+ itemId = (String)cache.get(makeChildFqn(childNodes, parentId, name), ITEM_ID);
+ }
+
+ if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemId == null)
+ {
// try as property
itemId = (String)cache.get(makeChildFqn(childProps, parentId, name), ITEM_ID);
}
@@ -827,15 +840,16 @@
if (node.getParentIdentifier() != null)
{
// add in CHILD_NODES
- cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ cache.put(
+ makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList,
+ node.getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
- .getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST,
+ node.getIdentifier());
}
}
@@ -849,15 +863,16 @@
if (node.getParentIdentifier() != null)
{
// add in CHILD_NODES
- cache.put(makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
- .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
+ cache.put(
+ makeChildFqn(childNodes, node.getParentIdentifier(), node.getQPath().getEntries()[node.getQPath()
+ .getEntries().length - 1]), ITEM_ID, node.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childNodesList,
+ node.getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
- cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST, node
- .getIdentifier());
+ cache.addToList(makeChildListFqn(childNodesList, node.getParentIdentifier()), ITEM_LIST,
+ node.getIdentifier());
}
}
// add in ITEMS
@@ -873,11 +888,12 @@
protected PropertyData putProperty(PropertyData prop, ModifyChildOption modifyListsOfChild)
{
// add in CHILD_PROPS
- cache.put(makeChildFqn(childProps, prop.getParentIdentifier(), prop.getQPath().getEntries()[prop.getQPath()
- .getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
+ cache.put(
+ makeChildFqn(childProps, prop.getParentIdentifier(),
+ prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]), ITEM_ID, prop.getIdentifier());
// if MODIFY and List present OR FORCE_MODIFY, then write
- if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList, prop
- .getParentIdentifier())) != null)
+ if ((modifyListsOfChild == ModifyChildOption.MODIFY && cache.getNode(makeChildListFqn(childPropsList,
+ prop.getParentIdentifier())) != null)
|| modifyListsOfChild == ModifyChildOption.FORCE_MODIFY)
{
cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()), ITEM_LIST, prop.getIdentifier());
@@ -899,8 +915,8 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_NODES_LIST of parent
- cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST, item
- .getIdentifier());
+ cache.removeFromList(makeChildListFqn(childNodesList, item.getParentIdentifier()), ITEM_LIST,
+ item.getIdentifier());
// remove from CHILD_NODES as parent
cache.removeNode(makeChildListFqn(childNodes, item.getIdentifier()));
@@ -922,8 +938,8 @@
.getQPath().getEntries().length - 1]));
// remove from CHILD_PROPS_LIST
- cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST, item
- .getIdentifier());
+ cache.removeFromList(makeChildListFqn(childPropsList, item.getParentIdentifier()), ITEM_LIST,
+ item.getIdentifier());
}
// remove from ITEMS
cache.removeNode(makeItemFqn(item.getIdentifier()));
@@ -1061,9 +1077,9 @@
NodeData prevNode = (NodeData)data;
TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
- .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(),
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
+ prevNode.getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
}
@@ -1081,8 +1097,8 @@
}
TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
- .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(),
+ prevProp.getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
}
}
@@ -1116,8 +1132,8 @@
QPath
.makeChildPath(rootPath, prevProp.getQPath().getEntries()[prevProp.getQPath().getEntries().length - 1]);
TransientPropertyData newProp =
- new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(), prevProp
- .getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
+ new TransientPropertyData(newPath, prevProp.getIdentifier(), prevProp.getPersistedVersion(),
+ prevProp.getType(), prevProp.getParentIdentifier(), prevProp.isMultiValued(), prevProp.getValues());
cache.put(makeItemFqn(newProp.getIdentifier()), ITEM_DATA, newProp);
}
@@ -1130,9 +1146,9 @@
QPath
.makeChildPath(rootPath, prevNode.getQPath().getEntries()[prevNode.getQPath().getEntries().length - 1]);
TransientNodeData newNode =
- new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(), prevNode
- .getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
+ new TransientNodeData(newPath, prevNode.getIdentifier(), prevNode.getPersistedVersion(),
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
+ prevNode.getParentIdentifier(), inheritACL ? acl : prevNode.getACL()); // TODO check ACL
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
// update childs recursive
@@ -1162,8 +1178,8 @@
// recreate with new path for child Nodes only
TransientNodeData newNode =
new TransientNodeData(prevNode.getQPath(), prevNode.getIdentifier(), prevNode.getPersistedVersion(),
- prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(), prevNode
- .getParentIdentifier(), acl);
+ prevNode.getPrimaryTypeName(), prevNode.getMixinTypeNames(), prevNode.getOrderNumber(),
+ prevNode.getParentIdentifier(), acl);
// update this node
cache.put(makeItemFqn(newNode.getIdentifier()), ITEM_DATA, newNode);
// update childs recursive
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/LocalWorkspaceStorageDataManagerProxy.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -104,12 +105,20 @@
*/
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
- return copyItemData(storageDataManager.getItemData(parentData, name));
+ return getItemData(parentData, name, ItemType.UNKNOWN);
}
/**
* {@inheritDoc}
*/
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
+ return copyItemData(storageDataManager.getItemData(parentData, name, itemType));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(String identifier) throws RepositoryException
{
return copyItemData(storageDataManager.getItemData(identifier));
@@ -186,8 +195,8 @@
+ node.getIdentifier());
}
- return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
- .getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(), acl);
+ return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
+ node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(), acl);
}
// else - property
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/SessionChangesLog.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -299,13 +300,29 @@
* Get ItemState by parent and item name.
*
* @param parentData
+ * parent
* @param name
+ * item name
+ * @param itemType
+ * item type
* @return
* @throws IllegalPathException
*/
- public ItemState getItemState(NodeData parentData, QPathEntry name) throws IllegalPathException
+ public ItemState getItemState(NodeData parentData, QPathEntry name, ItemType itemType) throws IllegalPathException
{
- return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name));
+ if (itemType != ItemType.UNKNOWN)
+ {
+ return index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, itemType));
+ }
+ else
+ {
+ ItemState state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.NODE));
+ if (state == null)
+ {
+ state = index.get(new ParentIDQPathBasedKey(parentData.getIdentifier(), name, ItemType.PROPERTY));
+ }
+ return state;
+ }
}
/**
@@ -718,6 +735,8 @@
*/
private final String parentIdentifier;
+ private final ItemType itemType;
+
/**
* KeyParentUUIDQPath constructor.
*
@@ -728,6 +747,7 @@
{
this.name = item.getData().getQPath().getEntries()[item.getData().getQPath().getEntries().length - 1];
this.parentIdentifier = item.getData().getParentIdentifier();
+ this.itemType = ItemType.getItemType(item.getData());
}
/**
@@ -738,10 +758,11 @@
* @param name
* item name
*/
- ParentIDQPathBasedKey(String parentIdentifier, QPathEntry name)
+ ParentIDQPathBasedKey(String parentIdentifier, QPathEntry name, ItemType itemType)
{
this.name = name;
this.parentIdentifier = parentIdentifier;
+ this.itemType = itemType;
}
/**
@@ -756,6 +777,7 @@
result = prime * result + name.getNamespace().hashCode();
result = prime * result + name.getIndex();
result = prime * result + (parentIdentifier == null ? 0 : parentIdentifier.hashCode());
+ result = prime * result + itemType.ordinal();
return result;
}
@@ -782,6 +804,7 @@
else if (!name.getName().equals(other.name.getName())
|| !name.getNamespace().equals(other.name.getNamespace()) || name.getIndex() != other.name.getIndex())
return false;
+
if (parentIdentifier == null)
{
if (other.parentIdentifier != null)
@@ -789,6 +812,15 @@
}
else if (!parentIdentifier.equals(other.parentIdentifier))
return false;
+
+ if (itemType == null)
+ {
+ if (other.itemType != null)
+ return false;
+ }
+ else if (!itemType.equals(other.itemType))
+ return false;
+
return true;
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/session/TransactionableDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.dataflow.SharedDataManager;
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -214,10 +215,18 @@
*/
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException
+ {
ItemData data = null;
if (txStarted())
{
- ItemState state = transactionLog.getItemState(parentData, name);
+ ItemState state = transactionLog.getItemState(parentData, name, itemType);
if (state != null)
{
data = state.getData();
@@ -229,7 +238,7 @@
}
else
{
- return storageDataManager.getItemData(parentData, name);
+ return storageDataManager.getItemData(parentData, name, itemType);
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/version/VersionHistoryDataHelper.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/version/VersionHistoryDataHelper.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/version/VersionHistoryDataHelper.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -24,6 +24,7 @@
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.Identifier;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -139,7 +140,8 @@
NodeData vData = (NodeData)dataManager.getItemData(getIdentifier());
- NodeData rootVersion = (NodeData)dataManager.getItemData(vData, new QPathEntry(Constants.JCR_ROOTVERSION, 0));
+ NodeData rootVersion =
+ (NodeData)dataManager.getItemData(vData, new QPathEntry(Constants.JCR_ROOTVERSION, 0), ItemType.NODE);
List<NodeData> vChilds = new ArrayList<NodeData>();
@@ -165,7 +167,8 @@
for (NodeData vd : versionsData)
{
- PropertyData createdData = (PropertyData)dataManager.getItemData(vd, new QPathEntry(Constants.JCR_CREATED, 0));
+ PropertyData createdData =
+ (PropertyData)dataManager.getItemData(vd, new QPathEntry(Constants.JCR_CREATED, 0), ItemType.PROPERTY);
if (createdData == null)
throw new VersionException("jcr:created is not found, version: " + vd.getQPath().getAsString());
@@ -191,12 +194,12 @@
public NodeData getVersionData(InternalQName versionQName) throws VersionException, RepositoryException
{
- return (NodeData)dataManager.getItemData(this, new QPathEntry(versionQName, 0));
+ return (NodeData)dataManager.getItemData(this, new QPathEntry(versionQName, 0), ItemType.NODE);
}
public NodeData getVersionLabelsData() throws VersionException, RepositoryException
{
- return (NodeData)dataManager.getItemData(this, new QPathEntry(Constants.JCR_VERSIONLABELS, 0));
+ return (NodeData)dataManager.getItemData(this, new QPathEntry(Constants.JCR_VERSIONLABELS, 0), ItemType.NODE);
}
public List<PropertyData> getVersionLabels() throws VersionException, RepositoryException
@@ -242,7 +245,7 @@
NodeData rootItem = (NodeData)dataManager.getItemData(Constants.SYSTEM_UUID);
NodeData versionStorageData =
- (NodeData)dataManager.getItemData(rootItem, new QPathEntry(Constants.JCR_VERSIONSTORAGE, 1)); // Constants
+ (NodeData)dataManager.getItemData(rootItem, new QPathEntry(Constants.JCR_VERSIONSTORAGE, 1), ItemType.NODE); // Constants
// Make versionStorageData transient
if (!(versionStorageData instanceof TransientNodeData))
versionStorageData =
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryStorageConnection.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -19,12 +19,12 @@
package org.exoplatform.services.jcr.impl.storage.inmemory;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.core.JCRPath;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
@@ -64,13 +64,37 @@
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
{
- return getItemData(QPath.makeChildPath(parentData.getQPath(), name));
+ return getItemData(parentData, name, ItemType.UNKNOWN);
}
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
+ ItemData itemData = null;
+ QPath qPath = QPath.makeChildPath(parentData.getQPath(), name);
+
+ if (itemType == ItemType.NODE || itemType == ItemType.UNKNOWN)
+ {
+ itemData = (ItemData)items.get(new MapKey(qPath, ItemType.NODE));
+ }
+ if (itemType == ItemType.PROPERTY || itemType == ItemType.UNKNOWN && itemData == null)
+ {
+ itemData = (ItemData)items.get(new MapKey(qPath, ItemType.PROPERTY));
+ }
+
+ return itemData;
+ }
+
public ItemData getItemData(QPath qPath) throws RepositoryException, IllegalStateException
{
log.debug("InmemoryContainer finding " + qPath.getAsString());
- Object o = items.get(qPath.getAsString());
+
+ Object o = items.get(new MapKey(qPath, ItemType.NODE));
+ if (o == null)
+ {
+ o = items.get(new MapKey(qPath, ItemType.PROPERTY));
+ }
+
log.debug("InmemoryContainer FOUND " + qPath.getAsString() + " " + o);
return (ItemData)o;
}
@@ -141,11 +165,11 @@
IllegalStateException
{
- if (items.get(item.getQPath().getAsString()) != null)
+ if (items.get(new MapKey(item.getQPath(), ItemType.getItemType(item))) != null)
throw new ItemExistsException("WorkspaceContainerImpl.add(Item) item '" + item.getQPath().getAsString()
+ "' already exists!");
- items.put(item.getQPath().getAsString(), item);
+ items.put(new MapKey(item.getQPath(), ItemType.getItemType(item)), item);
log.debug("InmemoryContainer added node " + item.getQPath().getAsString());
Iterator props = getChildProperties(item).iterator();
while (props.hasNext())
@@ -162,7 +186,7 @@
public void add(PropertyData prop) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
- items.put(prop.getQPath().getAsString(), prop);
+ items.put(new MapKey(prop.getQPath(), ItemType.getItemType(prop)), prop);
log.debug("InmemoryContainer added property " + prop.getQPath().getAsString());
}
@@ -181,21 +205,21 @@
public void update(PropertyData item) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
- items.put(item.getQPath().getAsString(), item);
+ items.put(new MapKey(item.getQPath(), ItemType.getItemType(item)), item);
log.debug("InmemoryContainer updated " + item);
}
public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
- items.remove(data.getQPath().getAsString());
+ items.remove(new MapKey(data.getQPath(), ItemType.getItemType(data)));
log.debug("InmemoryContainer removed " + data.getQPath().getAsString());
}
public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
- items.remove(data.getQPath().getAsString());
+ items.remove(new MapKey(data.getQPath(), ItemType.getItemType(data)));
log.debug("InmemoryContainer removed " + data.getQPath().getAsString());
}
@@ -232,8 +256,8 @@
Iterator i = items.keySet().iterator();
while (i.hasNext())
{
- JCRPath d = (JCRPath)i.next();
- str += d.getInternalPath() + "\n";
+ MapKey d = (MapKey)i.next();
+ str += d.getQPath().getAsString() + '\t' + d.getItemType().toString() + "\n";
}
return str;
}
@@ -245,4 +269,54 @@
}
+ class MapKey
+ {
+
+ private final QPath path;
+
+ private final String key;
+
+ private final ItemType itemType;
+
+ MapKey(QPath path, ItemType itemType)
+ {
+ this.path = path;
+ this.itemType = itemType;
+ this.key = key(this.path, this.itemType);
+ }
+
+ protected String key(final QPath path, ItemType itemType)
+ {
+ StringBuilder sk = new StringBuilder();
+ sk.append(path.getAsString());
+ sk.append(itemType.toString());
+
+ return sk.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (key.hashCode() == obj.hashCode() && obj instanceof MapKey)
+ return key.equals(((MapKey)obj).key);
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return key.hashCode();
+ }
+
+ QPath getQPath()
+ {
+ return path;
+ }
+
+ ItemType getItemType()
+ {
+ return itemType;
+ }
+ }
+
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCStorageConnection.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -82,6 +83,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void writeStreamedValue(File file, ValueData value) throws IOException
{
super.writeStreamedValue(file, value);
@@ -716,7 +718,7 @@
if (LOG.isDebugEnabled())
{
LOG.debug("Node deleted " + data.getQPath().getAsString() + ", " + data.getIdentifier() + ", "
- + ((NodeData)data).getPrimaryTypeName().getAsString());
+ + (data).getPrimaryTypeName().getAsString());
}
}
@@ -758,12 +760,8 @@
if (LOG.isDebugEnabled())
{
- LOG.debug("Property deleted "
- + data.getQPath().getAsString()
- + ", "
- + data.getIdentifier()
- + (((PropertyData)data).getValues() != null ? ", values count: "
- + ((PropertyData)data).getValues().size() : ", NULL data"));
+ LOG.debug("Property deleted " + data.getQPath().getAsString() + ", " + data.getIdentifier()
+ + ((data).getValues() != null ? ", values count: " + (data).getValues().size() : ", NULL data"));
}
}
@@ -1045,16 +1043,27 @@
return getItemByIdentifier(getInternalId(identifier));
}
+ /**
+ * {@inheritDoc}
+ */
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
if (parentData != null)
{
- return getItemByName(parentData, getInternalId(parentData.getIdentifier()), name);
+ return getItemByName(parentData, getInternalId(parentData.getIdentifier()), name, itemType);
}
// it's a root node
- return getItemByName(null, null, name);
+ return getItemByName(null, null, name, itemType);
}
/**
@@ -1117,8 +1126,8 @@
if (valueRecord.next())
{
String storageId = valueRecord.getString(COLUMN_VSTORAGE_DESC);
- return valueRecord.wasNull() ? readValueData(cid, orderNumb, persistedVersion, valueRecord
- .getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb, storageId);
+ return valueRecord.wasNull() ? readValueData(cid, orderNumb, persistedVersion,
+ valueRecord.getBinaryStream(COLUMN_VDATA)) : readValueData(propertyId, orderNumb, storageId);
}
return null;
@@ -1203,30 +1212,43 @@
* - parent container internal id (depends on Multi/Single DB)
* @param name
* - item name
+ * @param itemType
+ * - item type
* @return - ItemData instance
* @throws RepositoryException
* Repository error
* @throws IllegalStateException
* if connection is closed
*/
- protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name) throws RepositoryException,
- IllegalStateException
+ protected ItemData getItemByName(NodeData parent, String parentId, QPathEntry name, ItemType itemType)
+ throws RepositoryException, IllegalStateException
{
checkIfOpened();
try
{
- ResultSet item = findItemByName(parentId, name.getAsString(), name.getIndex());
+ ResultSet item = null;
try
{
- if (item.next())
- return itemData(parent.getQPath(), item, item.getInt(COLUMN_CLASS), parent.getACL());
+ item = findItemByName(parentId, name.getAsString(), name.getIndex());
+ while (item.next())
+ {
+ int columnClass = item.getInt(COLUMN_CLASS);
+ if (itemType == ItemType.UNKNOWN || columnClass == itemType.ordinal())
+ {
+ return itemData(parent.getQPath(), item, columnClass, parent.getACL());
+ }
+ }
+
return null;
}
finally
{
try
{
- item.close();
+ if (item != null)
+ {
+ item.close();
+ }
}
catch (SQLException e)
{
@@ -2002,8 +2024,8 @@
{
// use permissions from existed parent
acl =
- new AccessControlList(readACLOwner(cid), parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(readACLOwner(cid), parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
}
else
{
@@ -2037,8 +2059,8 @@
if (parentACL != null)
// construct ACL from existed parent ACL
acl =
- new AccessControlList(parentACL.getOwner(), parentACL.hasPermissions() ? parentACL
- .getPermissionEntries() : null);
+ new AccessControlList(parentACL.getOwner(), parentACL.hasPermissions()
+ ? parentACL.getPermissionEntries() : null);
else
// have to search nearest ancestor owner and permissions in ACL manager
// acl = traverseACL(cpid);
@@ -2212,8 +2234,8 @@
final int orderNum = valueRecords.getInt(COLUMN_VORDERNUM);
final String storageId = valueRecords.getString(COLUMN_VSTORAGE_DESC);
ValueData vdata =
- valueRecords.wasNull() ? readValueData(cid, orderNum, cversion, valueRecords
- .getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum, storageId);
+ valueRecords.wasNull() ? readValueData(cid, orderNum, cversion,
+ valueRecords.getBinaryStream(COLUMN_VDATA)) : readValueData(identifier, orderNum, storageId);
data.add(vdata);
}
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLExceptionHandler.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.storage.JCRInvalidItemStateException;
@@ -180,7 +181,9 @@
throw ownException;
}
- me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()));
+ me =
+ conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()),
+ ItemType.getItemType(item));
if (me != null)
{
message += "Item already exists in storage: " + itemInfo;
@@ -261,7 +264,9 @@
throw ownException;
}
- me = conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()));
+ me =
+ conn.getItemData(parent, new QPathEntry(item.getQPath().getName(), item.getQPath().getIndex()),
+ ItemType.getItemType(item));
if (me != null)
{
message += "Item already exists in storage: " + itemInfo;
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/statistics/StatisticsJDBCStorageConnection.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -17,6 +17,7 @@
package org.exoplatform.services.jcr.impl.storage.jdbc.statistics;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -40,7 +41,7 @@
* Created by The eXo Platform SAS
* Author : Nicolas Filotto
* nicolas.filotto(a)exoplatform.com
- * 26 f�vr. 2010
+ * 26 f�vr. 2010
*/
public class StatisticsJDBCStorageConnection implements WorkspaceStorageConnection
{
@@ -204,7 +205,6 @@
}
}
-
/**
* The nested {@link WorkspaceStorageConnection}
*/
@@ -384,15 +384,24 @@
}
/**
- * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getItemData(org.exoplatform.services.jcr.datamodel.NodeData, org.exoplatform.services.jcr.datamodel.QPathEntry)
+ * {@inheritDoc}
*/
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
Statistics s = ALL_STATISTICS.get(GET_ITEM_DATA_BY_NODE_DATA_NQ_PATH_ENTRY_DESCR);
try
{
s.begin();
- return wcs.getItemData(parentData, name);
+ return wcs.getItemData(parentData, name, itemType);
}
finally
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/VersionHistoryRemover.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/VersionHistoryRemover.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/VersionHistoryRemover.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -217,7 +218,8 @@
if (ntManager.isNodeType(Constants.NT_VERSIONEDCHILD, vhnode.getPrimaryTypeName(), vhnode.getMixinTypeNames()))
{
PropertyData property =
- (PropertyData)dataManager.getItemData(nodeData, new QPathEntry(Constants.JCR_CHILDVERSIONHISTORY, 1));
+ (PropertyData)dataManager.getItemData(nodeData, new QPathEntry(Constants.JCR_CHILDVERSIONHISTORY, 1),
+ ItemType.PROPERTY);
if (property == null)
throw new RepositoryException("Property " + Constants.JCR_CHILDVERSIONHISTORY.getAsString()
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -31,6 +31,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -228,7 +229,7 @@
ItemData sameNameNode = null;
try
{
- sameNameNode = dataConsumer.getItemData(parentData, new QPathEntry(name, 0));
+ sameNameNode = dataConsumer.getItemData(parentData, new QPathEntry(name, 0), ItemType.NODE);
}
catch (PathNotFoundException e)
{
@@ -723,7 +724,8 @@
try
{
PropertyData vhpd =
- (PropertyData)dataConsumer.getItemData(mixVersionableNode, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1));
+ (PropertyData)dataConsumer.getItemData(mixVersionableNode, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1),
+ ItemType.PROPERTY);
try
{
String vhID = new String(vhpd.getValues().get(0).getAsByteArray());
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceStorageConnection.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -19,6 +19,7 @@
package org.exoplatform.services.jcr.storage;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -63,9 +64,30 @@
* @throws IllegalStateException
* if connection is closed
*/
+ @Deprecated
ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException;
/**
+ * Reads <code>ItemData</code> from the storage using item's parent and name relative the parent
+ * location of define type.
+ *
+ * @param parentData
+ * - the item's parent NodeData
+ * @param name
+ * - item's path entry (QName + index)
+ * @param itemType
+ * item type
+ * @return - stored ItemData wich has exact the same path Entry (name+index) inside the parent; or
+ * null if not such an item data found
+ * @throws RepositoryException
+ * if some exception occured
+ * @throws IllegalStateException
+ * if connection is closed
+ */
+ ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException;
+
+ /**
* Reads <code>ItemData</code> from the storage by item identifier.
*
* @param identifier
@@ -93,7 +115,7 @@
* if connection is closed
*/
List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException;
-
+
/**
* Reads count of <code>parent<code/> child nodes.
*
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestGetNode.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
+import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
/**
@@ -48,4 +49,17 @@
}
}
+ public void testGetNodeAndPropertyWithSameName() throws Exception
+ {
+ String sameName = "sameName";
+ Node rootNode = session.getRootNode();
+ Node aNode = rootNode.addNode("a");
+ aNode.addNode(sameName);
+ aNode.setProperty(sameName, "aa");
+ session.save();
+
+ assertNotNull(aNode.getProperty(sameName));
+ assertNotNull(aNode.getNode(sameName));
+ }
+
}
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/TestSessionDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -34,8 +35,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.Node;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
@@ -314,7 +313,7 @@
{
// get non-existent data by getItemData(NodeData parent, QPathEntry name)
assertNull(modificationManager.getItemData((NodeData)((NodeImpl)root).getData(), new QPathEntry("",
- "testgetitemNode", 0)));
+ "testgetitemNode", 0), ItemType.NODE));
// get non-existent data by ItemData getItemData(QPath path)
assertNull(modificationManager.getItemData(QPath.makeChildPath(((NodeImpl)root).getData().getQPath(),
new InternalQName("", "testgetitemNode"))));
@@ -323,7 +322,7 @@
// get data by getItemData(NodeData parent, QPathEntry name)
assertNotNull(modificationManager.getItemData((NodeData)((NodeImpl)root).getData(), new QPathEntry("",
- "testgetitemNode", 0)));
+ "testgetitemNode", 0), ItemType.NODE));
// get data by ItemData getItemData(QPath path)
assertNotNull(modificationManager.getItemData(QPath.makeChildPath(((NodeImpl)root).getData().getQPath(),
new InternalQName("", "testgetitemNode"))));
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -23,6 +23,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -90,6 +91,7 @@
{
Thread thread = new Thread()
{
+ @Override
public void run()
{
try
@@ -147,7 +149,7 @@
{
public void execute() throws Exception
{
- ItemData item = cwdm.getItemData(nodeData, new QPathEntry("http://www.foo.com", "foo", 0));
+ ItemData item = cwdm.getItemData(nodeData, new QPathEntry("http://www.foo.com", "foo", 0), ItemType.NODE);
assertNotNull(item);
}
};
@@ -308,9 +310,19 @@
public ItemData get(String parentIdentifier, QPathEntry name)
{
- return itemData;
+ return get(parentIdentifier, name, ItemType.UNKNOWN);
}
+ public ItemData get(String parentIdentifier, QPathEntry name, ItemType itemType)
+ {
+ if (itemData != null && itemType.isSuitableFor(itemData))
+ {
+ return itemData;
+ }
+
+ return null;
+ }
+
public ItemData get(String identifier)
{
return itemData;
@@ -426,8 +438,8 @@
getChildPropertiesDataCalls.incrementAndGet();
return Arrays
.asList((PropertyData)new PersistedPropertyData("getChildPropertiesData", null, null, 0,
- PropertyType.STRING, false, Arrays
- .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ PropertyType.STRING, false,
+ Arrays.asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
}
public AtomicInteger getItemDataByNodeDataNQPathEntryCalls = new AtomicInteger();
@@ -435,8 +447,19 @@
public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException,
IllegalStateException
{
+ return getItemData(parentData, name, ItemType.UNKNOWN);
+ }
+
+ public ItemData getItemData(NodeData parentData, QPathEntry name, ItemType itemType) throws RepositoryException,
+ IllegalStateException
+ {
getItemDataByNodeDataNQPathEntryCalls.incrementAndGet();
- return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ if (itemType != ItemType.PROPERTY)
+ {
+ return new PersistedNodeData("getItemData", null, null, 0, 1, null, null, null);
+ }
+
+ return null;
}
public AtomicInteger getItemDataByIdCalls = new AtomicInteger();
@@ -471,8 +494,8 @@
listChildPropertiesDataCalls.incrementAndGet();
return Arrays
.asList((PropertyData)new PersistedPropertyData("listChildPropertiesData", null, null, 0,
- PropertyType.STRING, false, Arrays
- .asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
+ PropertyType.STRING, false,
+ Arrays.asList((ValueData)new ByteArrayPersistedValueData(1, "foo".getBytes()))));
}
public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestLinkedCacheMultithread.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestLinkedCacheMultithread.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestLinkedCacheMultithread.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -79,6 +80,7 @@
super.setName(name);
}
+ @Override
public void run()
{
// log.info("START");
@@ -99,7 +101,7 @@
// by parent + name
NodeData n =
(NodeData)cache.get(rndNode.getParentIdentifier(), rndNode.getQPath().getEntries()[rndNode
- .getQPath().getEntries().length - 1]);
+ .getQPath().getEntries().length - 1], ItemType.NODE);
if (n != null)
assertEquals(rndNode.getIdentifier(), n.getIdentifier());
}
@@ -142,6 +144,7 @@
super.setName(name);
}
+ @Override
public void run()
{
// log.info("START");
@@ -229,6 +232,7 @@
super.setName(name);
}
+ @Override
public void run()
{
// log.info("START");
@@ -280,6 +284,7 @@
this.timeout = timeout;
}
+ @Override
public void run()
{
synchronized (cache)
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspaceStorageCacheBaseCase.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -141,6 +142,7 @@
private WorkspaceStorageCache cache;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -251,15 +253,15 @@
throw e;
}
assertEquals("Cached node " + nodeData1.getQPath().getAsString() + " is not equals", cache.get(rootUuid,
- nodePath1.getEntries()[nodePath1.getEntries().length - 1]), nodeData1);
+ nodePath1.getEntries()[nodePath1.getEntries().length - 1], ItemType.NODE), nodeData1);
assertEquals("Cached node " + nodeData2.getQPath().getAsString() + " is not equals", cache.get(rootUuid,
- nodePath2.getEntries()[nodePath2.getEntries().length - 1]), nodeData2);
+ nodePath2.getEntries()[nodePath2.getEntries().length - 1], ItemType.NODE), nodeData2);
assertEquals("Cached node " + nodeData1.getIdentifier() + " is not equals", cache.get(nodeUuid1), nodeData1);
assertEquals("Cached node " + nodeData2.getIdentifier() + " is not equals", cache.get(nodeUuid2), nodeData2);
assertEquals("Cached property " + propertyPath12.getAsString() + " is not equals", cache.get(nodeUuid1,
- propertyPath12.getEntries()[propertyPath12.getEntries().length - 1]), propertyData12);
+ propertyPath12.getEntries()[propertyPath12.getEntries().length - 1], ItemType.PROPERTY), propertyData12);
assertEquals("Cached property " + propertyData12.getIdentifier() + " is not equals", cache.get(propertyUuid12),
propertyData12);
}
@@ -300,21 +302,21 @@
}
// prev stuff
assertEquals("Cached " + nodeData1.getQPath().getAsString() + " is not equals", cache.get(rootUuid, nodePath1
- .getEntries()[nodePath1.getEntries().length - 1]), nodeData1);
+ .getEntries()[nodePath1.getEntries().length - 1], ItemType.NODE), nodeData1);
assertEquals("Cached " + nodeData2.getQPath().getAsString() + " is not equals", cache.get(rootUuid, nodePath2
- .getEntries()[nodePath2.getEntries().length - 1]), nodeData2);
+ .getEntries()[nodePath2.getEntries().length - 1], ItemType.NODE), nodeData2);
assertEquals("Cached " + propertyData12.getQPath().getAsString() + " is not equals", cache.get(nodeUuid1,
- propertyPath12.getEntries()[propertyPath12.getEntries().length - 1]), propertyData12);
+ propertyPath12.getEntries()[propertyPath12.getEntries().length - 1], ItemType.PROPERTY), propertyData12);
// childs...
// nodes
assertEquals("Cached child node " + nodeData31.getQPath().getAsString() + " is not equals", cache.get(nodeUuid3,
- nodePath31.getEntries()[nodePath31.getEntries().length - 1]), nodeData31);
+ nodePath31.getEntries()[nodePath31.getEntries().length - 1], ItemType.NODE), nodeData31);
assertEquals("Cached child node " + nodeData31.getIdentifier() + " is not equals", cache.get(nodeUuid31),
nodeData31);
assertEquals("Cached child node " + nodeData32.getQPath().getAsString() + " is not equals", cache.get(nodeUuid3,
- nodePath32.getEntries()[nodePath32.getEntries().length - 1]), nodeData32);
+ nodePath32.getEntries()[nodePath32.getEntries().length - 1], ItemType.NODE), nodeData32);
assertEquals("Cached child node " + nodeData32.getIdentifier() + " is not equals", cache.get(nodeUuid32),
nodeData32);
@@ -327,20 +329,24 @@
// props
assertEquals("Cached child property " + propertyData11.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1]), propertyData11);
+ nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData11);
assertEquals("Cached child property " + propertyData11.getIdentifier() + " is not equals", cache
.get(propertyUuid11), propertyData11);
assertEquals("Cached child property " + propertyData12.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1]), propertyData12);
+ nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData12);
assertEquals("Cached child property " + propertyData12.getIdentifier() + " is not equals", cache
.get(propertyUuid12), propertyData12);
assertEquals("Cached child property " + propertyData21.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1]), propertyData21);
+ nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData21);
assertEquals("Cached child property " + propertyData21.getIdentifier() + " is not equals", cache
.get(propertyUuid21), propertyData21);
assertEquals("Cached child property " + propertyData22.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1]), propertyData22);
+ nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData22);
assertEquals("Cached child property " + propertyData22.getIdentifier() + " is not equals", cache
.get(propertyUuid22), propertyData22);
@@ -393,20 +399,24 @@
}
// props, prev stuff
assertEquals("Cached child property " + propertyData11.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1]), propertyData11);
+ nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData11);
assertEquals("Cached child property " + propertyData11.getIdentifier() + " is not equals", cache
.get(propertyUuid11), propertyData11);
assertEquals("Cached child property " + propertyData12.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1]), propertyData12);
+ nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData12);
assertEquals("Cached child property " + propertyData12.getIdentifier() + " is not equals", cache
.get(propertyUuid12), propertyData12);
assertEquals("Cached child property " + propertyData21.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1]), propertyData21);
+ nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData21);
assertEquals("Cached child property " + propertyData21.getIdentifier() + " is not equals", cache
.get(propertyUuid21), propertyData21);
assertEquals("Cached child property " + propertyData22.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1]), propertyData22);
+ nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData22);
assertEquals("Cached child property " + propertyData22.getIdentifier() + " is not equals", cache
.get(propertyUuid22), propertyData22);
@@ -429,22 +439,25 @@
// check
assertEquals("Cached child property " + propertyData11.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1]), propertyData11);
+ nodeUuid1, propertyPath11.getEntries()[propertyPath11.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData11);
assertEquals("Cached child property " + propertyData11.getIdentifier() + " is not equals", cache
.get(propertyUuid11), propertyData11);
// here
assertNull("Child property " + propertyData12.getQPath().getAsString() + " is not in the cache", cache.get(
- nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1]));
+ nodeUuid1, propertyPath12.getEntries()[propertyPath12.getEntries().length - 1], ItemType.PROPERTY));
assertNull("Child property " + propertyData12.getQPath().getAsString() + " is not in the cache", cache
.get(propertyUuid12));
assertEquals("Cached child property " + propertyData21.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1]), propertyData21);
+ nodeUuid2, propertyPath21.getEntries()[propertyPath21.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData21);
assertEquals("Cached child property " + propertyData21.getIdentifier() + " is not equals", cache
.get(propertyUuid21), propertyData21);
assertEquals("Cached child property " + propertyData22.getQPath().getAsString() + " is not equals", cache.get(
- nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1]), propertyData22);
+ nodeUuid2, propertyPath22.getEntries()[propertyPath22.getEntries().length - 1], ItemType.PROPERTY),
+ propertyData22);
assertEquals("Cached child property " + propertyData22.getIdentifier() + " is not equals", cache
.get(propertyUuid22), propertyData22);
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCHWDCTest.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -27,6 +27,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -36,7 +37,6 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
import org.exoplatform.services.jcr.impl.dataflow.session.TransactionableDataManager;
-import org.exoplatform.services.jcr.impl.dataflow.session.WorkspaceStorageDataManagerProxy;
import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -142,7 +142,7 @@
con = wdContainer.openConnection();
try
{
- NodeData storedNode = (NodeData)con.getItemData(rootData, new QPathEntry(nodeName, 1));
+ NodeData storedNode = (NodeData)con.getItemData(rootData, new QPathEntry(nodeName, 1), ItemType.NODE);
assertEquals(path, storedNode.getQPath());
}
catch (Exception e)
@@ -211,7 +211,7 @@
// get
try
{
- NodeData storedNode = (NodeData)wdm.getItemData(rootData, new QPathEntry(nodeName, 1));
+ NodeData storedNode = (NodeData)wdm.getItemData(rootData, new QPathEntry(nodeName, 1), ItemType.NODE);
assertEquals(path, storedNode.getQPath());
}
catch (Exception e)
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCStorageConnectionTest.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -28,6 +28,7 @@
import org.exoplatform.services.jcr.dataflow.TransactionChangesLog;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -98,7 +99,7 @@
testRoot =
(NodeData)dataManager.getItemData(root,
- troot.getQPath().getEntries()[troot.getQPath().getEntries().length - 1]);
+ troot.getQPath().getEntries()[troot.getQPath().getEntries().length - 1], ItemType.NODE);
assertNotNull("Can't find test root node " + troot.getQPath().getAsString(), testRoot);
}
@@ -135,7 +136,8 @@
{
NodeData troot =
- (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1));
+ (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1),
+ ItemType.NODE);
assertEquals("Inherited acl should be here", root.getACL().getOwner(), troot.getACL().getOwner());
}
@@ -160,7 +162,8 @@
// test
NodeData troot =
- (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1));
+ (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1),
+ ItemType.NODE);
assertEquals("Owner is not valid", "exo", troot.getACL().getOwner());
}
@@ -192,7 +195,8 @@
// test
NodeData troot =
- (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1));
+ (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1),
+ ItemType.NODE);
List<String> iperms = troot.getACL().getPermissions(SystemIdentity.ANY);
assertEquals("Wrong permission for " + SystemIdentity.ANY, 1, iperms.size());
@@ -242,7 +246,8 @@
// test
NodeData troot =
- (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1));
+ (NodeData)dataManager.getItemData(root, new QPathEntry(InternalQName.parse("[]jdbcStorageConnectionTest"), 1),
+ ItemType.NODE);
assertEquals("Owner is not valid", "exo", troot.getACL().getOwner());
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/StorageUpdateTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/StorageUpdateTest.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/StorageUpdateTest.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -21,6 +21,7 @@
import org.exoplatform.container.ExoContainer;
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -71,6 +72,7 @@
private boolean isDefaultWsMultiDb;
+ @Override
public void setUp() throws Exception
{
super.setUp();
@@ -155,7 +157,8 @@
(NodeData)session.getTransientNodesManager().getTransactManager()
.getItemData(jcrUuid.getParentIdentifier());
QPathEntry[] qentry = bugData.getQPath().getEntries();
- PropertyData persistedBugData = (PropertyData)conn.getItemData(parent, qentry[qentry.length - 1]);
+ PropertyData persistedBugData =
+ (PropertyData)conn.getItemData(parent, qentry[qentry.length - 1], ItemType.PROPERTY);
log.info("node_V node BUG uuid: " + node_V.getUUID() + ", jcr:uuid: "
+ new String(persistedBugData.getValues().get(0).getAsByteArray()));
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/fs/TestJCRVSReadWrite.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -284,13 +285,20 @@
}
// copied from SessionDataManager
- protected ItemData getItemData(DataManager manager, NodeData parent, QPathEntry[] relPathEntries)
+ protected ItemData getItemData(DataManager manager, NodeData parent, QPathEntry[] relPathEntries, ItemType itemType)
throws RepositoryException
{
ItemData item = parent;
for (int i = 0; i < relPathEntries.length; i++)
{
- item = manager.getItemData(parent, relPathEntries[i]);
+ if (i == relPathEntries.length - 1)
+ {
+ item = manager.getItemData(parent, relPathEntries[i], itemType);
+ }
+ else
+ {
+ item = manager.getItemData(parent, relPathEntries[i], ItemType.UNKNOWN);
+ }
if (item == null)
break;
@@ -356,7 +364,7 @@
Set<QPathEntry[]> caseProps = new HashSet<QPathEntry[]>(props);
for (QPathEntry[] prop : caseProps)
{
- PropertyData p = (PropertyData)getItemData(manager, parent, prop);
+ PropertyData p = (PropertyData)getItemData(manager, parent, prop, ItemType.PROPERTY);
List<ValueData> vals = p.getValues();
for (int i = 0; i < vals.size(); i++)
{
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/storage/jdbc/SQLBenchmarkTest.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -1,14 +1,5 @@
package org.exoplatform.services.jcr.impl.storage.jdbc;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
import org.exoplatform.container.StandaloneContainer;
import org.exoplatform.services.jcr.BaseStandaloneTest;
import org.exoplatform.services.jcr.RepositoryService;
@@ -17,6 +8,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedPropertyData;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -27,6 +19,15 @@
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.RepositoryException;
+
/*
* Copyright (C) 2003-2009 eXo Platform SAS.
*
@@ -55,21 +56,21 @@
*/
public class SQLBenchmarkTest
{
-/*
- static
- {
- try
+ /*
+ static
{
- Class.forName("com.jdbmonitor.MonitorDriver");
- System.out.println("Driver Loaded");
+ try
+ {
+ Class.forName("com.jdbmonitor.MonitorDriver");
+ System.out.println("Driver Loaded");
+ }
+ catch (ClassNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+
}
- catch (ClassNotFoundException e)
- {
- e.printStackTrace();
- }
-
- }
-*/
+ */
/**
* @param args
*/
@@ -307,7 +308,7 @@
{
public ItemData execute(Object... args) throws Exception
{
- return getItemData((WorkspaceDataContainer)args[0], (NodeData)args[1], (QPathEntry)args[2]);
+ return getItemData((WorkspaceDataContainer)args[0], (NodeData)args[1], (QPathEntry)args[2], ItemType.NODE);
}
};
@@ -553,13 +554,13 @@
return true;
}
- public static ItemData getItemData(WorkspaceDataContainer dataContainer, NodeData parentData, QPathEntry name)
- throws RepositoryException, IllegalStateException
+ public static ItemData getItemData(WorkspaceDataContainer dataContainer, NodeData parentData, QPathEntry name,
+ ItemType itemType) throws RepositoryException, IllegalStateException
{
final WorkspaceStorageConnection con = dataContainer.openConnection();
try
{
- return con.getItemData(parentData, name);
+ return con.getItemData(parentData, name, itemType);
}
finally
{
@@ -675,6 +676,7 @@
{
Thread t = new Thread()
{
+ @Override
public void run()
{
try
Modified: jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/TestFrozenNodeInitializer.java
===================================================================
--- jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/TestFrozenNodeInitializer.java 2010-09-24 08:33:48 UTC (rev 3187)
+++ jcr/branches/1.12.x/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/version/TestFrozenNodeInitializer.java 2010-09-24 08:54:04 UTC (rev 3188)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.persistent.PersistedNodeData;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
+import org.exoplatform.services.jcr.datamodel.ItemType;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -217,7 +218,7 @@
PropertyData vh =
(PropertyData)session.getTransientNodesManager().getItemData((NodeData)state.getData(),
- new QPathEntry(Constants.JCR_VERSIONHISTORY, 0));
+ new QPathEntry(Constants.JCR_VERSIONHISTORY, 0), ItemType.PROPERTY);
String vhUuid = new String(vh.getValues().get(0).getAsByteArray());
13 years, 7 months