Author: nfilotto
Date: 2010-04-01 10:59:21 -0400 (Thu, 01 Apr 2010)
New Revision: 2208
Removed:
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/JBossCacheWorkspaceStorageCache.java
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java
Log:
EXOJCR-609: Changes reverted need to be reviewed
Deleted:
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 2010-04-01
14:45:41 UTC (rev 2207)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/NullNodeData.java 2010-04-01
14:59:21 UTC (rev 2208)
@@ -1,131 +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.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.
- *
- * Created by The eXo Platform SAS
- * Author : Nicolas Filotto
- * nicolas.filotto(a)exoplatform.com
- * 31 mars 2010
- */
-public class NullNodeData implements NodeData
-{
- private final String id;
- private final String parentId;
- private final QPath path;
-
- public NullNodeData(String id)
- {
- this.id = id;
- this.path = new QPath(new QPathEntry[]{new QPathEntry(null, null, 0)});
- this.parentId = null;
- }
-
- public NullNodeData(NodeData parentData, QPathEntry name)
- {
- this.parentId = parentData.getIdentifier();
- this.path = QPath.makeChildPath(parentData.getQPath(), name);
- this.id = parentId + "$" + name.asString();
- }
-
- /**
- * {@inheritDoc}
- */
- public void accept(ItemDataVisitor visitor) throws RepositoryException
- {
- }
-
- /**
- * {@inheritDoc}
- */
- public String getIdentifier()
- {
- return id;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getParentIdentifier()
- {
- return parentId;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getPersistedVersion()
- {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public QPath getQPath()
- {
- return path;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isNode()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public AccessControlList getACL()
- {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public InternalQName[] getMixinTypeNames()
- {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getOrderNumber()
- {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- public InternalQName getPrimaryTypeName()
- {
- return null;
- }
-}
\ No newline at end of file
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-04-01
14:45:41 UTC (rev 2207)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-04-01
14:59:21 UTC (rev 2208)
@@ -22,7 +22,6 @@
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
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;
@@ -41,7 +40,7 @@
import javax.transaction.TransactionManager;
/**
- * Created by The eXo Platform SAS.
+ * Created by The eXo Platform SAS.
*
* <br/>
* Author : Peter Nedonosko peter.nedonosko(a)exoplatform.com.ua
@@ -95,7 +94,7 @@
* GET_LIST_PROPERTIES type.
*/
static private final int GET_LIST_PROPERTIES = 5;
-
+
/**
* Request type.
*/
@@ -282,7 +281,7 @@
* Items cache
* @param systemDataContainerHolder
* System Workspace data container (persistent level)
- * @param transactionService TransactionService
+ * @param transactionService TransactionService
*/
public CacheableWorkspaceDataManager(WorkspaceDataContainer dataContainer,
WorkspaceStorageCache cache,
SystemDataContainerHolder systemDataContainerHolder, TransactionService
transactionService)
@@ -338,7 +337,6 @@
/**
* {@inheritDoc}
*/
- @Override
public int getChildNodesCount(NodeData parent) throws RepositoryException
{
if (cache.isEnabled())
@@ -356,7 +354,6 @@
/**
* {@inheritDoc}
*/
- @Override
public List<NodeData> getChildNodesData(NodeData nodeData) throws
RepositoryException
{
return getChildNodesData(nodeData, false);
@@ -365,7 +362,6 @@
/**
* {@inheritDoc}
*/
- @Override
public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws
RepositoryException
{
List<PropertyData> childs = getChildPropertiesData(nodeData, false);
@@ -380,7 +376,6 @@
/**
* {@inheritDoc}
*/
- @Override
public ItemData getItemData(NodeData parentData, QPathEntry name) throws
RepositoryException
{
@@ -391,7 +386,7 @@
if (data == null)
{
final DataRequest request = new DataRequest(parentData.getIdentifier(), name);
-
+
try
{
request.start();
@@ -400,12 +395,12 @@
data = getCachedItemData(parentData, name);
if (data == null)
{
- data = getPersistedItemData(parentData, name);
+ data = getPersistedItemData(parentData, name);
}
else if (!data.isNode())
{
fixPropertyValues((PropertyData)data);
- }
+ }
}
finally
{
@@ -417,19 +412,14 @@
fixPropertyValues((PropertyData)data);
}
- return data instanceof NullNodeData ? null : data;
+ return data;
}
/**
* {@inheritDoc}
*/
- @Override
public ItemData getItemData(String identifier) throws RepositoryException
{
- if (identifier == null)
- {
- return null;
- }
// 2. Try from cache
ItemData data = getCachedItemData(identifier);
@@ -437,7 +427,7 @@
if (data == null)
{
final DataRequest request = new DataRequest(identifier);
-
+
try
{
request.start();
@@ -446,7 +436,7 @@
data = getCachedItemData(identifier);
if (data == null)
{
- data = getPersistedItemData(identifier);
+ data = getPersistedItemData(identifier);
}
else if (!data.isNode())
{
@@ -463,15 +453,14 @@
fixPropertyValues((PropertyData)data);
}
- return data instanceof NullNodeData ? null : data;
+ return data;
}
/**
* {@inheritDoc}
*/
- @Override
public List<PropertyData> getReferencesData(String identifier, boolean
skipVersionStorage)
- throws RepositoryException
+ throws RepositoryException
{
return super.getReferencesData(identifier, skipVersionStorage);
}
@@ -479,7 +468,6 @@
/**
* {@inheritDoc}
*/
- @Override
public List<PropertyData> listChildPropertiesData(NodeData nodeData) throws
RepositoryException
{
return listChildPropertiesData(nodeData, false);
@@ -498,7 +486,7 @@
}
else
{
- // save normaly
+ // save normaly
super.save(changesLog);
// notify listeners after storage commit
@@ -548,7 +536,7 @@
* Repository error
*/
protected List<NodeData> getChildNodesData(NodeData nodeData, boolean
forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<NodeData> childNodes = null;
@@ -605,7 +593,7 @@
* Repository error
*/
protected List<PropertyData> getChildPropertiesData(NodeData nodeData, boolean
forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<PropertyData> childProperties = null;
@@ -634,7 +622,8 @@
}
childProperties = super.getChildPropertiesData(nodeData);
- if (cache.isEnabled())
+ // TODO childProperties.size() > 0 for SDB
+ if (childProperties.size() > 0 && cache.isEnabled())
{
NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
@@ -665,9 +654,9 @@
protected ItemData getPersistedItemData(NodeData parentData, QPathEntry name) throws
RepositoryException
{
ItemData data = super.getItemData(parentData, name);
- if (cache.isEnabled())
+ if (data != null && cache.isEnabled())
{
- cache.put(data == null ? new NullNodeData(parentData, name) : data);
+ cache.put(data);
}
return data;
}
@@ -682,9 +671,9 @@
protected ItemData getPersistedItemData(String identifier) throws RepositoryException
{
ItemData data = super.getItemData(identifier);
- if (cache.isEnabled())
+ if (data != null && cache.isEnabled())
{
- cache.put(data == null ? new NullNodeData(identifier) : data);
+ cache.put(data);
}
return data;
}
@@ -701,7 +690,7 @@
* Repository error
*/
protected List<PropertyData> listChildPropertiesData(NodeData nodeData, boolean
forcePersistentRead)
- throws RepositoryException
+ throws RepositoryException
{
List<PropertyData> propertiesList;
@@ -729,7 +718,8 @@
}
}
propertiesList = super.listChildPropertiesData(nodeData);
- if (cache.isEnabled())
+ // TODO propertiesList.size() > 0 for SDB
+ if (propertiesList.size() > 0 && cache.isEnabled())
{
NodeData parentData = (NodeData)getItemData(nodeData.getIdentifier());
@@ -743,7 +733,7 @@
finally
{
request.done();
- }
+ }
}
protected boolean isTxAware()
@@ -792,10 +782,10 @@
* @param prop PropertyData, original Property data
* @return PropertyData
* @throws IllegalStateException
- * @throws RepositoryException
+ * @throws RepositoryException
*/
protected ValueData getPropertyValue(String propertyId, int orderNumb, int
persistedVersion)
- throws IllegalStateException, RepositoryException
+ throws IllegalStateException, RepositoryException
{
// TODO use interface not JDBC
JDBCStorageConnection conn =
(JDBCStorageConnection)dataContainer.openConnection();
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-04-01
14:45:41 UTC (rev 2207)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/LinkedWorkspaceStorageCacheImpl.java 2010-04-01
14:59:21 UTC (rev 2208)
@@ -26,7 +26,6 @@
import org.exoplatform.services.jcr.dataflow.persistent.WorkspaceStorageCache;
import org.exoplatform.services.jcr.datamodel.ItemData;
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;
@@ -905,12 +904,9 @@
protected void putItem(final ItemData data)
{
cache.put(new CacheId(data.getIdentifier()), new CacheValue(data,
System.currentTimeMillis() + liveTime));
- if (data.getParentIdentifier() != null || !(data instanceof NullNodeData))
- {
- cache.put(new CacheQPath(data.getParentIdentifier(), data.getQPath()), new
CacheValue(data, System
- .currentTimeMillis()
- + liveTime));
- }
+ cache.put(new CacheQPath(data.getParentIdentifier(), data.getQPath()), new
CacheValue(data, System
+ .currentTimeMillis()
+ + liveTime));
}
/**
@@ -933,11 +929,6 @@
// add child item data to list of childs of the parent
if (item.isNode())
{
- if (item instanceof NullNodeData)
- {
- // Skip null values
- return;
- }
// add child node
List<NodeData> cachedParentChilds =
nodesCache.get(item.getParentIdentifier());
if (cachedParentChilds != null)
@@ -1309,11 +1300,8 @@
{
cache.remove(k);
- if (c.getParentIdentifier() != null || !(c instanceof NullNodeData))
- {
- // remove by parentId + path
- cache.remove(new CacheQPath(c.getParentIdentifier(), c.getQPath()));
- }
+ // remove by parentId + path
+ cache.remove(new CacheQPath(c.getParentIdentifier(), c.getQPath()));
// remove cached child lists
if (c.isNode())
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-04-01
14:45:41 UTC (rev 2207)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/jbosscache/JBossCacheWorkspaceStorageCache.java 2010-04-01
14:59:21 UTC (rev 2208)
@@ -28,7 +28,6 @@
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.NullNodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
@@ -53,7 +52,6 @@
import java.util.Set;
import javax.jcr.RepositoryException;
-import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
/**
@@ -372,53 +370,12 @@
cache.setLocal(false);
if (!inTransaction)
{
- dedicatedTxCommit();
+ cache.commitTransaction();
}
}
}
/**
- * Allows to commit the cache changes in a dedicated XA Tx in order to avoid
potential
- * deadlocks
- */
- private void dedicatedTxCommit()
- {
- // Ensure that the commit is done in a dedicated tx to avoid deadlock due
- // to global XA Tx
- TransactionManager tm = getTransactionManager();
- Transaction tx = null;
- try
- {
- if (tm != null)
- {
- try
- {
- tx = tm.suspend();
- }
- catch (Exception e)
- {
- LOG.warn("Cannot suspend the current transaction", e);
- }
- }
- cache.commitTransaction();
- }
- finally
- {
- if (tx != null)
- {
- try
- {
- tm.resume(tx);
- }
- catch (Exception e)
- {
- LOG.warn("Cannot resume the current transaction", e);
- }
- }
- }
- }
-
- /**
* {@inheritDoc}
*/
public void remove(ItemData item)
@@ -519,7 +476,7 @@
else
{
// cache fact of empty childs list
- cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()),
ITEM_LIST, Collections.EMPTY_SET);
+ cache.put(makeChildListFqn(childNodesList, parent.getIdentifier()),
ITEM_LIST, new HashSet<Object>());
}
}
finally
@@ -527,7 +484,7 @@
cache.setLocal(false);
if (!inTransaction)
{
- dedicatedTxCommit();
+ cache.commitTransaction();
}
}
}
@@ -557,10 +514,11 @@
set.add(child.getIdentifier());
}
cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()),
ITEM_LIST, set);
+
}
else
{
- cache.put(makeChildListFqn(childPropsList, parent.getIdentifier()),
ITEM_LIST, Collections.EMPTY_SET);
+ LOG.warn("Empty properties list cached " + (parent != null ?
parent.getQPath().getAsString() : parent));
}
}
finally
@@ -568,7 +526,7 @@
cache.setLocal(false);
if (!inTransaction)
{
- dedicatedTxCommit();
+ cache.commitTransaction();
}
}
}
@@ -821,9 +779,9 @@
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 (!(node instanceof NullNodeData)
- && ((modifyListsOfChild == ModifyChildOption.MODIFY &&
cache.getNode(makeChildListFqn(childNodesList, node
- .getParentIdentifier())) != null) || modifyListsOfChild ==
ModifyChildOption.FORCE_MODIFY))
+ 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());
@@ -872,14 +830,6 @@
{
cache.addToList(makeChildListFqn(childPropsList, prop.getParentIdentifier()),
ITEM_LIST, prop.getIdentifier());
}
- ItemData result =
- get(prop.getParentIdentifier(),
prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]);
- if (result instanceof NullNodeData)
- {
- // Remove null value if exists
- cache.removeNode(makeChildFqn(childNodes, result.getParentIdentifier(),
prop.getQPath().getEntries()[prop.getQPath().getEntries().length - 1]));
- cache.removeNode(makeItemFqn(result.getIdentifier()));
- }
// add in ITEMS
return (PropertyData)cache.put(makeItemFqn(prop.getIdentifier()), ITEM_DATA,
prop);
}
@@ -934,12 +884,7 @@
*/
protected void updateMixin(NodeData node)
{
- Object oPrevValue = cache.put(makeItemFqn(node.getIdentifier()), ITEM_DATA, node);
- if (oPrevValue instanceof NullNodeData)
- {
- oPrevValue = null;
- }
- NodeData prevData = (NodeData)oPrevValue;
+ NodeData prevData = (NodeData)cache.put(makeItemFqn(node.getIdentifier()),
ITEM_DATA, node);
if (prevData != null)
{
// do update ACL if needed
@@ -1078,10 +1023,6 @@
for (Iterator<NodeData> iter = new
ChildNodesIterator<NodeData>(parentId); iter.hasNext();)
{
NodeData prevNode = iter.next();
- if (prevNode instanceof NullNodeData)
- {
- continue;
- }
// is ACL changes on this node (i.e. ACL inheritance brokes)
for (InternalQName mixin : prevNode.getMixinTypeNames())
{
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-04-01
14:45:41 UTC (rev 2207)
+++
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/dataflow/persistent/TestCacheableWorkspaceDataManager.java 2010-04-01
14:59:21 UTC (rev 2208)
@@ -25,7 +25,6 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.datamodel.ValueData;
import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
@@ -54,7 +53,6 @@
{
private static final int READER = 100;
-
private static final int TIMES = 20;
private CacheableWorkspaceDataManager cwdm;
@@ -63,12 +61,6 @@
private MyWorkspaceStorageConnection con;
- private CacheableWorkspaceDataManager cwdmEmpty;
-
- private WorkspaceDataContainer wdcEmpty;
-
- private MyWorkspaceStorageConnection conEmpty;
-
@Override
protected void setUp() throws Exception
{
@@ -77,11 +69,6 @@
this.wdc = new MyWorkspaceDataContainer(con);
this.cwdm =
new CacheableWorkspaceDataManager(wdc, new MyWorkspaceStorageCache(), new
SystemDataContainerHolder(wdc));
- this.conEmpty = new MyWorkspaceStorageConnection(true);
- this.wdcEmpty = new MyWorkspaceDataContainer(conEmpty);
- this.cwdmEmpty =
- new CacheableWorkspaceDataManager(wdcEmpty, new MyWorkspaceStorageCache(), new
SystemDataContainerHolder(
- wdcEmpty));
}
@Override
@@ -109,7 +96,7 @@
startSignal.await();
for (int i = 0; i < TIMES; i++)
{
- task.execute();
+ task.execute();
}
}
catch (Exception e)
@@ -133,9 +120,9 @@
e.printStackTrace();
}
throw errors.get(0);
- }
+ }
}
-
+
public void testGetItemById() throws Exception
{
assertEquals(0, con.getItemDataByIdCalls.get());
@@ -145,27 +132,15 @@
{
ItemData item = cwdm.getItemData("getItemData");
assertNotNull(item);
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getItemDataByIdCalls.get());
- assertEquals(0, conEmpty.getItemDataByIdCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- ItemData item = cwdmEmpty.getItemData("getItemData");
- assertNull(item);
- }
- };
- multiThreadingTest(task);
- assertEquals(1, conEmpty.getItemDataByIdCalls.get());
}
-
+
public void testGetItemDataByNodeDataNQPathEntry() throws Exception
{
- final NodeData nodeData =
- new PersistedNodeData("getItemData", new QPath(new QPathEntry[]{}),
null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getItemData", null,
null, 0, 1, null, null, null);
assertEquals(0, con.getItemDataByNodeDataNQPathEntryCalls.get());
MyTask task = new MyTask()
{
@@ -173,26 +148,15 @@
{
ItemData item = cwdm.getItemData(nodeData, new
QPathEntry("http://www.foo.com", "foo", 0));
assertNotNull(item);
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getItemDataByNodeDataNQPathEntryCalls.get());
- assertEquals(0, conEmpty.getItemDataByNodeDataNQPathEntryCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- ItemData item = cwdmEmpty.getItemData(nodeData, new
QPathEntry("http://www.foo.com", "foo", 0));
- assertNull(item);
- }
- };
- multiThreadingTest(task);
- assertEquals(1, conEmpty.getItemDataByNodeDataNQPathEntryCalls.get());
}
-
+
public void testGetChildPropertiesData() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildPropertiesData",
null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildPropertiesData",
null, null, 0, 1, null, null, null);
assertEquals(0, con.getChildPropertiesDataCalls.get());
MyTask task = new MyTask()
{
@@ -201,7 +165,7 @@
List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getChildPropertiesDataCalls.get());
@@ -212,38 +176,15 @@
List<PropertyData> properties = cwdm.getChildPropertiesData(nodeData,
true);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.getChildPropertiesDataCalls.get());
- assertEquals(0, conEmpty.getChildPropertiesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<PropertyData> properties =
cwdmEmpty.getChildPropertiesData(nodeData);
- assertNotNull(properties);
- assertTrue(properties.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1, conEmpty.getChildPropertiesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<PropertyData> properties =
cwdmEmpty.getChildPropertiesData(nodeData, true);
- assertNotNull(properties);
- assertTrue(properties.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1 + READER * TIMES, conEmpty.getChildPropertiesDataCalls.get());
}
-
+
public void testListChildPropertiesData() throws Exception
{
- final NodeData nodeData = new
PersistedNodeData("listChildPropertiesData", null, null, 0, 1, null, null,
null);
+ final NodeData nodeData = new
PersistedNodeData("listChildPropertiesData", null, null, 0, 1, null, null,
null);
assertEquals(0, con.listChildPropertiesDataCalls.get());
MyTask task = new MyTask()
{
@@ -252,7 +193,7 @@
List<PropertyData> properties =
cwdm.listChildPropertiesData(nodeData);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.listChildPropertiesDataCalls.get());
@@ -263,38 +204,15 @@
List<PropertyData> properties = cwdm.listChildPropertiesData(nodeData,
true);
assertNotNull(properties);
assertFalse(properties.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.listChildPropertiesDataCalls.get());
- assertEquals(0, conEmpty.listChildPropertiesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<PropertyData> properties =
cwdmEmpty.listChildPropertiesData(nodeData);
- assertNotNull(properties);
- assertTrue(properties.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1, conEmpty.listChildPropertiesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<PropertyData> properties =
cwdmEmpty.listChildPropertiesData(nodeData, true);
- assertNotNull(properties);
- assertTrue(properties.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1 + READER * TIMES, conEmpty.listChildPropertiesDataCalls.get());
}
-
+
public void testGetChildNodes() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildNodes", null,
null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildNodes", null,
null, 0, 1, null, null, null);
assertEquals(0, con.getChildNodesDataCalls.get());
MyTask task = new MyTask()
{
@@ -303,7 +221,7 @@
List<NodeData> nodes = cwdm.getChildNodesData(nodeData);
assertNotNull(nodes);
assertFalse(nodes.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1, con.getChildNodesDataCalls.get());
@@ -314,38 +232,15 @@
List<NodeData> nodes = cwdm.getChildNodesData(nodeData, true);
assertNotNull(nodes);
assertFalse(nodes.isEmpty());
- }
+ }
};
multiThreadingTest(task);
assertEquals(1 + READER * TIMES, con.getChildNodesDataCalls.get());
- assertEquals(0, conEmpty.getChildNodesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<NodeData> nodes = cwdmEmpty.getChildNodesData(nodeData);
- assertNotNull(nodes);
- assertTrue(nodes.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1, conEmpty.getChildNodesDataCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- List<NodeData> nodes = cwdmEmpty.getChildNodesData(nodeData, true);
- assertNotNull(nodes);
- assertTrue(nodes.isEmpty());
- }
- };
- multiThreadingTest(task);
- assertEquals(1 + READER * TIMES, conEmpty.getChildNodesDataCalls.get());
}
-
+
public void testGetChildNodesCount() throws Exception
{
- final NodeData nodeData = new PersistedNodeData("getChildNodesCount",
null, null, 0, 1, null, null, null);
+ final NodeData nodeData = new PersistedNodeData("getChildNodesCount",
null, null, 0, 1, null, null, null);
assertEquals(0, con.getChildNodesCountCalls.get());
MyTask task = new MyTask()
{
@@ -353,7 +248,7 @@
{
int result = cwdm.getChildNodesCount(nodeData);
assertEquals(1, result);
- }
+ }
};
multiThreadingTest(task);
assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
@@ -365,40 +260,17 @@
{
int result = cwdm.getChildNodesCount(nodeData);
assertEquals(1, result);
- }
+ }
};
multiThreadingTest(task);
assertEquals(READER * TIMES, con.getChildNodesCountCalls.get());
- assertEquals(0, conEmpty.getChildNodesCountCalls.get());
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- int result = cwdmEmpty.getChildNodesCount(nodeData);
- assertEquals(0, result);
- }
- };
- multiThreadingTest(task);
- assertEquals(READER * TIMES, conEmpty.getChildNodesCountCalls.get());
- // Add data to the cache
- cwdmEmpty.getChildNodesData(nodeData);
- task = new MyTask()
- {
- public void execute() throws Exception
- {
- int result = cwdmEmpty.getChildNodesCount(nodeData);
- assertEquals(0, result);
- }
- };
- multiThreadingTest(task);
- assertEquals(READER * TIMES, conEmpty.getChildNodesCountCalls.get());
}
private static interface MyTask
{
void execute() throws Exception;
}
-
+
private static class MyWorkspaceStorageCache implements WorkspaceStorageCache
{
@@ -493,21 +365,9 @@
}
- public static class MyWorkspaceStorageConnection implements
WorkspaceStorageConnection
+ private static class MyWorkspaceStorageConnection implements
WorkspaceStorageConnection
{
- public final boolean emptyResult;
-
- public MyWorkspaceStorageConnection()
- {
- this(false);
- }
-
- public MyWorkspaceStorageConnection(boolean emptyResult)
- {
- this.emptyResult = emptyResult;
- }
-
public void add(NodeData data) throws RepositoryException,
UnsupportedOperationException,
InvalidItemStateException, IllegalStateException
{
@@ -541,7 +401,7 @@
public int getChildNodesCount(NodeData parent) throws RepositoryException
{
getChildNodesCountCalls.incrementAndGet();
- return emptyResult ? 0 : 1;
+ return 1;
}
public AtomicInteger getChildNodesDataCalls = new AtomicInteger();
@@ -549,8 +409,7 @@
public List<NodeData> getChildNodesData(NodeData parent) throws
RepositoryException, IllegalStateException
{
getChildNodesDataCalls.incrementAndGet();
- return emptyResult ? new ArrayList<NodeData>() :
Arrays.asList((NodeData)new PersistedNodeData(
- "getChildNodesData", null, null, 0, 1, null, null, null));
+ return Arrays.asList((NodeData)new
PersistedNodeData("getChildNodesData", null, null, 0, 1, null, null, null));
}
public AtomicInteger getChildPropertiesDataCalls = new AtomicInteger();
@@ -559,9 +418,10 @@
IllegalStateException
{
getChildPropertiesDataCalls.incrementAndGet();
- return emptyResult ? new ArrayList<PropertyData>() :
Arrays.asList((PropertyData)new PersistedPropertyData(
- "getChildPropertiesData", null, null, 0, PropertyType.STRING,
false, Arrays
- .asList((ValueData)new ByteArrayPersistedValueData(1,
"foo".getBytes()))));
+ return Arrays
+ .asList((PropertyData)new
PersistedPropertyData("getChildPropertiesData", null, null, 0,
+ PropertyType.STRING, false, Arrays
+ .asList((ValueData)new ByteArrayPersistedValueData(1,
"foo".getBytes()))));
}
public AtomicInteger getItemDataByNodeDataNQPathEntryCalls = new AtomicInteger();
@@ -570,7 +430,7 @@
IllegalStateException
{
getItemDataByNodeDataNQPathEntryCalls.incrementAndGet();
- return emptyResult ? null : new PersistedNodeData("getItemData", null,
null, 0, 1, null, null, null);
+ return new PersistedNodeData("getItemData", null, null, 0, 1, null,
null, null);
}
public AtomicInteger getItemDataByIdCalls = new AtomicInteger();
@@ -578,8 +438,7 @@
public ItemData getItemData(String identifier) throws RepositoryException,
IllegalStateException
{
getItemDataByIdCalls.incrementAndGet();
- return emptyResult && identifier.equals("getItemData") ? null
: new PersistedNodeData("getItemData", null,
- null, 0, 1, null, null, null);
+ return new PersistedNodeData("getItemData", null, null, 0, 1, null,
null, null);
}
public AtomicInteger getReferencesDataCalls = new AtomicInteger();
@@ -604,9 +463,8 @@
IllegalStateException
{
listChildPropertiesDataCalls.incrementAndGet();
- return emptyResult ? new ArrayList<PropertyData>() :
Arrays.asList((PropertyData)new PersistedPropertyData(
- "listChildPropertiesData", null, null, 0, PropertyType.STRING,
false, Arrays
- .asList((ValueData)new ByteArrayPersistedValueData(1,
"foo".getBytes()))));
+ return Arrays.asList((PropertyData)new
PersistedPropertyData("listChildPropertiesData", null, null, 0,
PropertyType.STRING,
+ false, Arrays.asList((ValueData)new ByteArrayPersistedValueData(1,
"foo".getBytes()))));
}
public void rename(NodeData data) throws RepositoryException,
UnsupportedOperationException,