Author: pnedonosko
Date: 2009-12-30 10:03:09 -0500 (Wed, 30 Dec 2009)
New Revision: 1260
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
Log:
EXOJCR-359: rework of ItemImpl gets (decrease NodeImpl/propertyImpl creation). not
finished - lazy getNodes todoed
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/ValueData.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -30,7 +30,6 @@
*/
public interface ValueData
{
-
/**
* Return Value order number.
*
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -797,6 +797,7 @@
* @throws RepositoryException
* if errors occurs
*/
+ @Deprecated
abstract void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws
RepositoryException;
/**
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -156,21 +156,17 @@
*
* @param data
* Node data
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
+ * @param parent parent NodeData
* @param session
* Session
* @throws RepositoryException
* if error occurs during the Node data loading
*/
- public NodeImpl(NodeData data, InternalQName parentPrimaryTypeName, InternalQName[]
parentMixinTypeNames,
- SessionImpl session) throws RepositoryException
+ public NodeImpl(NodeData data, NodeData parent, SessionImpl session) throws
RepositoryException
{
super(data, session);
this.sysLocFactory = session.getSystemLocationFactory();
- loadData(data, parentPrimaryTypeName, parentMixinTypeNames);
+ loadNodeData(data, parent);
}
/**
@@ -1013,8 +1009,7 @@
checkValid();
try
{
- return new NodeIteratorOnDemand(childNodesData(), dataManager,
nodeData().getPrimaryTypeName(), nodeData()
- .getMixinTypeNames());
+ return new NodeIteratorOnDemand(childNodesData(), dataManager, nodeData());
}
finally
{
@@ -1369,93 +1364,72 @@
public void loadData(ItemData data) throws RepositoryException,
InvalidItemStateException,
ConstraintViolationException
{
-
- if (data == null)
- throw new InvalidItemStateException("Data is null for " +
this.getPath()
- + " Probably was deleted by another session and can not be loaded from
container ");
-
- if (!data.isNode())
- throw new RepositoryException("Load data failed: Node expected");
-
- NodeData nodeData = (NodeData)data;
-
- // TODO do we need this three checks here?
- if (nodeData.getPrimaryTypeName() == null)
- throw new RepositoryException("Load data: NodeData has no primaryTypeName.
Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]") + " " + nodeData);
-
- if (nodeData.getMixinTypeNames() == null)
- throw new RepositoryException("Load data: NodeData has no mixinTypeNames.
Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]"));
-
- if (nodeData.getACL() == null)
- throw new RepositoryException("ACL is NULL " +
nodeData.getQPath().getAsString());
-
- this.data = nodeData;
- this.qpath = nodeData.getQPath();
- this.location = null;
-
- initDefinition();
+ loadNodeData(data, null);
}
- /**
- * Loads data.
- *
- * @param data
- * source item data for load
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- * @throws RepositoryException
- * if error occurs
- */
- private void loadData(ItemData data, InternalQName parentPrimaryTypeName,
InternalQName[] parentMixinTypeNames)
- throws RepositoryException, InvalidItemStateException,
ConstraintViolationException
+ private void loadNodeData(ItemData data, NodeData parent) throws RepositoryException,
InvalidItemStateException,
+ ConstraintViolationException
{
-
if (data == null)
+ {
throw new InvalidItemStateException("Data is null for " +
this.getPath()
+ " Probably was deleted by another session and can not be loaded from
container ");
+ }
- if (!data.isNode())
- throw new RepositoryException("Load data failed: Node expected");
+ if (data.isNode())
+ {
+ NodeData nodeData = (NodeData)data;
- NodeData nodeData = (NodeData)data;
+ // TODO do we need this three checks here?
+ if (nodeData.getPrimaryTypeName() == null)
+ {
+ throw new RepositoryException("Load data: NodeData has no
primaryTypeName. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]") + " "
+ + nodeData);
+ }
- // TODO do we need this three checks here?
- if (nodeData.getPrimaryTypeName() == null)
- throw new RepositoryException("Load data: NodeData has no primaryTypeName.
Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]") + " " + nodeData);
+ if (nodeData.getMixinTypeNames() == null)
+ {
+ throw new RepositoryException("Load data: NodeData has no
mixinTypeNames. Null value found. "
+ + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]"));
+ }
- if (nodeData.getMixinTypeNames() == null)
- throw new RepositoryException("Load data: NodeData has no mixinTypeNames.
Null value found. "
- + (nodeData.getQPath() != null ? nodeData.getQPath().getAsString() :
"[null path node]"));
+ if (nodeData.getACL() == null)
+ {
+ throw new RepositoryException("ACL is NULL " +
nodeData.getQPath().getAsString());
+ }
- if (nodeData.getACL() == null)
- throw new RepositoryException("ACL is NULL " +
nodeData.getQPath().getAsString());
+ this.data = nodeData;
+ this.qpath = nodeData.getQPath();
+ this.location = null;
- this.data = nodeData;
- this.qpath = nodeData.getQPath();
- this.location = null;
-
- initDefinition(parentPrimaryTypeName, parentMixinTypeNames);
+ initDefinition(parent);
+ }
+ else
+ {
+ throw new RepositoryException("Load data failed: Node expected");
+ }
}
/**
* {@inheritDoc}
*/
@Override
+ @Deprecated
public void loadData(ItemData data, ItemDefinitionData itemDefinitionData) throws
RepositoryException,
InvalidItemStateException, ConstraintViolationException
{
if (data == null)
+ {
throw new InvalidItemStateException("Data is null for " +
this.getPath()
+ " Probably was deleted by another session and can not be loaded from
container ");
+ }
if (!data.isNode())
+ {
throw new RepositoryException("Load data failed: Node expected");
+ }
NodeData nodeData = (NodeData)data;
@@ -1478,6 +1452,41 @@
}
/**
+ * Init NodeDefinition.
+ *
+ * @param parent NodeData
+ * @throws RepositoryException
+ * if error occurs
+ * @throws ConstraintViolationException
+ * if definition not found
+ */
+ private void initDefinition(NodeData parent) throws RepositoryException,
ConstraintViolationException
+ {
+ if (this.isRoot())
+ {
+ // root - no parent
+ this.definition =
+ new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT,
true,
+ new InternalQName[]{Constants.NT_BASE}, null, false);
+ return;
+ }
+
+ if (parent == null)
+ {
+ parent = (NodeData)dataManager.getItemData(getParentIdentifier());
+ }
+
+ this.definition =
+
session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
+ parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+
+ if (definition == null)
+ {
+ throw new ConstraintViolationException("Node definition not found for
" + getPath());
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
public ItemDefinitionData getItemDefinitionData()
@@ -2571,12 +2580,12 @@
* @throws AccessDeniedException
* if Nodes cannot be listed due to permissions on this Node
*/
- private List childNodesData() throws RepositoryException, AccessDeniedException
+ private List<Object> childNodesData() throws RepositoryException,
AccessDeniedException
{
List<NodeData> storedNodes = dataManager.getChildNodesData(nodeData());
Collections.sort(storedNodes, new NodeDataOrderComparator());
- List<Object> results = new ArrayList(storedNodes.size());
+ List<Object> results = new ArrayList<Object>(storedNodes.size());
Iterator<NodeData> it = storedNodes.iterator();
while (it.hasNext())
@@ -2836,68 +2845,6 @@
return false;
}
- /**
- * Init NodeDefinition.
- *
- * @throws RepositoryException
- * if error occurs
- * @throws ConstraintViolationException
- * if definition not found
- */
- private void initDefinition() throws RepositoryException,
ConstraintViolationException
- {
-
- if (this.isRoot())
- { // root - no parent
- this.definition =
- new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT,
true,
- new InternalQName[]{Constants.NT_BASE}, null, false);
- return;
- }
-
- NodeData parent = (NodeData)dataManager.getItemData(getParentIdentifier());
-
- this.definition =
-
session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
- parent.getPrimaryTypeName(), parent.getMixinTypeNames());
-
- if (definition == null)
- throw new ConstraintViolationException("Node definition not found for
" + getPath());
- }
-
- /**
- * Init NodeDefinition.
- *
- * @param parentPrimaryTypeName
- * parent primary type name
- * @param parentMixinTypeNames
- * parent mixin type names
- *
- * @throws RepositoryException
- * if error occurs
- * @throws ConstraintViolationException
- * if definition not found
- */
- private void initDefinition(InternalQName parentPrimaryTypeName, InternalQName[]
parentMixinTypeNames)
- throws RepositoryException, ConstraintViolationException
- {
-
- if (this.isRoot())
- { // root - no parent
- this.definition =
- new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT,
true,
- new InternalQName[]{Constants.NT_BASE}, null, false);
- return;
- }
-
- this.definition =
-
session.getWorkspace().getNodeTypesHolder().getChildNodeDefinition(getInternalName(),
parentPrimaryTypeName,
- parentMixinTypeNames);
-
- if (definition == null)
- throw new ConstraintViolationException("Node definition not found for
" + getPath());
- }
-
private void removeMergeFailed(Version version, PlainChangesLog changesLog) throws
RepositoryException
{
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -187,12 +187,8 @@
return item;
}
- /*
- * (non-Javadoc)
- * @see
- * org.exoplatform.services.jcr.dataflow.ItemDataConsumer#getItemData(org.
- * exoplatform.services .jcr.datamodel.NodeData,
- * org.exoplatform.services.jcr.datamodel.QPathEntry)
+ /**
+ * {@inheritDoc}
*/
public ItemData getItemData(NodeData parent, QPathEntry name) throws
RepositoryException
{
@@ -261,35 +257,23 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + parent.getQPath().getAsString() + " +
" + name.getAsString() + " ) >>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(parent, name);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied "
- + QPath.makeChildPath(parent.getQPath(), name).getAsString() + " for
" + session.getUserID()
- + " (get item by path)");
- }
-
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(parent, name), pool);
}
finally
{
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + parent.getQPath().getAsString() + " +
" + name.getAsString() + ") --> "
+ (item != null ? item.getPath() : "null") + "
<<<<< " + ((System.currentTimeMillis() - start) / 1000d)
+ "sec");
+ }
}
}
@@ -322,23 +306,7 @@
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(parent, relPath);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied "
- +
session.getLocationFactory().createJCRPath(QPath.makeChildPath(parent.getQPath(),
relPath))
- .getAsString(false) + " for " + session.getUserID() + "
(get item by path)");
- }
-
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(parent, relPath), pool);
}
finally
{
@@ -370,32 +338,81 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItem(" + path.getAsString() + " )
>>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(path);
- if (itemData == null)
- return null;
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
+ return item = readItem(getItemData(path), pool);
+ }
+ finally
+ {
+ if (log.isDebugEnabled())
{
- throw new AccessDeniedException("Access denied " +
path.getAsString() + " for " + session.getUserID()
- + " (get item by path)");
+ log.debug("getItem(" + path.getAsString() + ") --> " +
(item != null ? item.getPath() : "null") + " <<<<< "
+ + ((System.currentTimeMillis() - start) / 1000d) + "sec");
}
+ }
+ }
- if (pool)
- return itemsPool.get(item);
+ /**
+ * Read ItemImpl of given ItemData.
+ * Will call postRead Action and check permissions.
+ *
+ * @param itemData ItemData
+ * @param pool boolean, if true will reload pooled ItemImpl
+ * @return ItemImpl
+ * @throws RepositoryException if errro occurs
+ */
+ protected ItemImpl readItem(ItemData itemData, boolean pool) throws
RepositoryException
+ {
+ return readItem(itemData, pool, true);
+ }
+ /**
+ * Read ItemImpl of given ItemData.
+ *
+ * @param itemData ItemData
+ * @param pool boolean, if true will reload pooled ItemImpl
+ * @param jcrAPI, boolean if true will call postRead Action and check permissions
+ * @return ItemImpl
+ * @throws RepositoryException if errro occurs
+ */
+ protected ItemImpl readItem(ItemData itemData, boolean pool, boolean jcrAPI) throws
RepositoryException
+ {
+ if (itemData != null)
+ {
+ ItemImpl item;
+ ItemImpl pooledItem;
+ if (pool && (pooledItem = itemsPool.get(itemData)) != null)
+ {
+ // use pooled & reloaded
+ item = pooledItem;
+ }
+ else
+ {
+ // create new
+ item = itemFactory.createItem(itemData);
+ }
+
+ if (jcrAPI)
+ {
+ // TODO post read will be logically to call after the permissions check
+ session.getActionHandler().postRead(item);
+ if (!item.hasPermission(PermissionType.READ))
+ {
+ throw new AccessDeniedException("Access denied " +
itemData.getQPath().getAsString() + " for "
+ + session.getUserID());
+ }
+ }
+
return item;
}
- finally
+ else
{
- if (log.isDebugEnabled())
- log.debug("getItem(" + path.getAsString() + ") --> " +
(item != null ? item.getPath() : "null") + " <<<<< "
- + ((System.currentTimeMillis() - start) / 1000d) + "sec");
+ return null;
}
}
@@ -413,32 +430,22 @@
{
long start = System.currentTimeMillis();
if (log.isDebugEnabled())
+ {
log.debug("getItemByIdentifier(" + identifier + " )
>>>>>");
+ }
ItemImpl item = null;
try
{
- ItemData itemData = getItemData(identifier);
- if (itemData == null)
- return null;
-
- item = itemFactory.createItem(itemData);
- session.getActionHandler().postRead(item);
- if (!item.hasPermission(PermissionType.READ))
- {
- throw new AccessDeniedException("Access denied, item with id : " +
item.getPath()
- + " (get item by id), user " + session.getUserID() + " has
no privileges on reading");
- }
- if (pool)
- return itemsPool.get(item);
-
- return item;
+ return item = readItem(getItemData(identifier), pool);
}
finally
{
if (log.isDebugEnabled())
+ {
log.debug("getItemByIdentifier(" + identifier + ") -->
" + (item != null ? item.getPath() : "null")
+ " <<<<< " + ((System.currentTimeMillis() -
start) / 1000d) + "sec");
+ }
}
}
@@ -534,17 +541,24 @@
if (accessManager.hasPermission(parent.getACL(), new
String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- PropertyImpl item = null;
+ PropertyImpl item;
ItemState state = changesLog.getItemState(identifier);
if (state != null)
{
- if (state.isDeleted()) // skip deleted
+ if (state.isDeleted())
+ {
+ // skip deleted
continue;
+ }
- item = (PropertyImpl)itemFactory.createItem(state.getData());
+ item = (PropertyImpl)readItem(state.getData(), true, false);
+ // TODO item = (PropertyImpl)itemFactory.createItem(state.getData());
}
else
- item = (PropertyImpl)itemFactory.createItem(data);
+ {
+ item = (PropertyImpl)readItem(data, true, false);
+ // TODO item = (PropertyImpl)itemFactory.createItem(data);
+ }
refs.add(item);
session.getActionHandler().postRead(item);
@@ -582,15 +596,15 @@
for (int i = 0, length = nodeDatas.size(); i < length; i++)
{
NodeData data = nodeDatas.get(i);
- NodeImpl item = itemFactory.createNode(data, parent.getPrimaryTypeName(),
parent.getMixinTypeNames());
-
- session.getActionHandler().postRead(item);
-
if (accessManager.hasPermission(data.getACL(), new
String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- if (pool)
- item = (NodeImpl)itemsPool.get(item);
+ //NodeImpl item = itemFactory.createNode(data,
parent.getPrimaryTypeName(), parent.getMixinTypeNames());
+ NodeImpl item = (NodeImpl) readItem(data, pool, false);
+ session.getActionHandler().postRead(item);
+
+ //TODO if (pool)
+ // item = (NodeImpl)itemsPool.get(item);
nodes.add(item);
}
@@ -633,13 +647,15 @@
for (int i = 0, length = propDatas.size(); i < length; i++)
{
PropertyData data = propDatas.get(i);
- ItemImpl item = itemFactory.createItem(data);
- session.getActionHandler().postRead(item);
+ //ItemImpl item = itemFactory.createItem(data);
if (accessManager.hasPermission(parent.getACL(), new
String[]{PermissionType.READ}, session.getUserState()
.getIdentity()))
{
- if (pool)
- item = itemsPool.get(item);
+ // TODO if (pool)
+ // item = itemsPool.get(item);
+ ItemImpl item = readItem(data, pool, false);
+ session.getActionHandler().postRead(item);
+
props.add((PropertyImpl)item);
}
}
@@ -823,11 +839,15 @@
{
ItemData ri = getItemData(item.getInternalIdentifier());
if (ri != null)
+ {
itemsPool.reload(ri);
+ }
else
+ {
// the item is invalid, case of version restore - the item from non
// current version
item.invalidate();
+ }
invalidated.add(item);
}
@@ -1021,7 +1041,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
@@ -1117,12 +1137,7 @@
changesLog.add(itemState);
- ItemImpl item = itemFactory.createItem(itemState.getData());
-
- if (pool)
- item = itemsPool.get(item);
-
- return item;
+ return readItem(itemState.getData(), pool, false);
}
/**
@@ -1407,11 +1422,13 @@
* @throws RepositoryException
* if errors is occurs
*/
- public NodeImpl wrapNodeData(NodeData data, InternalQName parentPrimaryTypeName,
InternalQName[] parentMixinTypeNames)
+ public NodeImpl wrapNodeData(NodeData data, NodeData parent)
throws RepositoryException
{
- NodeImpl item = itemFactory.createNode(data, parentPrimaryTypeName,
parentMixinTypeNames);
- session.getActionHandler().postRead(item);
+
+ NodeImpl node = itemFactory.createNode(data, parent);
+ //NodeImpl node = (NodeImpl)itemsPool.get(data);
+ session.getActionHandler().postRead(node);
NodeImpl pooledItem = (NodeImpl)itemsPool.getItem(data.getIdentifier());
if (pooledItem == null)
@@ -1419,17 +1436,18 @@
NodeData pooledData = (NodeData)itemsPool.getData(data.getIdentifier());
if (pooledData != null)
{
- item.loadData(pooledData);
+ node.loadData(pooledData);
}
- item = (NodeImpl)itemsPool.get(item);
+ // TODO
+ node = (NodeImpl)itemsPool.get(node);
}
else
{
- item = pooledItem;
+ node = pooledItem;
}
- return item;
+ return node;
}
/**
@@ -1880,6 +1898,7 @@
* @return the item
* @throws RepositoryException
*/
+ @Deprecated
ItemImpl get(ItemImpl newItem) throws RepositoryException
{
String identifier = newItem.getInternalIdentifier();
@@ -1896,7 +1915,34 @@
item.loadData(newItem.getData(), newItem.getItemDefinitionData());
return item;
}
+ }
+ /**
+ * Get ItemImpl from the pool using given data.
+ *
+ * @param newData ItemData
+ * @return ItemImpl item
+ * @throws RepositoryException
+ */
+ ItemImpl get(final ItemData newData) throws RepositoryException
+ {
+ final String identifier = newData.getIdentifier();
+ ItemImpl item = items.get(identifier);
+ if (item != null)
+ {
+ item.loadData(newData);
+ }
+ else
+ {
+// ItemData preloaded = datas.remove(identifier);
+// item =
+// itemFactory.createItem(preloaded != null
+// && preloaded.getPersistedVersion() >
newData.getPersistedVersion() ? preloaded : newData);
+ datas.remove(identifier);
+ item = itemFactory.createItem(newData);
+ items.put(item.getInternalIdentifier(), item);
+ }
+ return item;
}
/**
@@ -2080,10 +2126,9 @@
return node;
}
- private NodeImpl createNode(NodeData data, InternalQName parentPrimaryTypeName,
- InternalQName[] parentMixinTypeNames) throws RepositoryException
+ private NodeImpl createNode(NodeData data, NodeData parent) throws
RepositoryException
{
- NodeImpl node = new NodeImpl(data, parentPrimaryTypeName, parentMixinTypeNames,
session);
+ NodeImpl node = new NodeImpl(data, parent, session);
if (data.getPrimaryTypeName().equals(Constants.NT_VERSION))
{
return new VersionImpl(data, session);
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/VersionHistoryImpl.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -87,7 +87,6 @@
public void loadData(ItemData vhData) throws RepositoryException,
InvalidItemStateException,
ConstraintViolationException
{
-
super.loadData(new VersionHistoryDataHelper((NodeData)vhData,
session.getTransientNodesManager()
.getTransactManager(), session.getWorkspace().getNodeTypesHolder()));
}
@@ -360,7 +359,7 @@
{// V2's successor
if (successorsData != null)
{// to redirect V2's successor
- // case of VH graph merge
+ // case of VH graph merge
for (ValueData svalue : successorsData.getValues())
{
predecessor.removeAddSuccessor(version.getInternalIdentifier(),
@@ -619,7 +618,7 @@
{
LOG.debug("Before frozen visitor: " + changesLog.dump());
}
-
+
versionableNodeData.accept(visitor);
}
Modified:
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java
===================================================================
---
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2009-12-30
14:47:45 UTC (rev 1259)
+++
jcr/branches/1.12.0-OPT/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/util/NodeIteratorOnDemand.java 2009-12-30
15:03:09 UTC (rev 1260)
@@ -43,16 +43,14 @@
{
protected static Log log = ExoLogger.getLogger("jcr.NodeIteratorOnDemand");
- private Iterator iter;
+ private final Iterator iter;
- private List list;
+ private final List list;
- private SessionDataManager dataManager;
+ private final SessionDataManager dataManager;
- private InternalQName parentPrimaryTypeName;
+ private final NodeData parent;
- private InternalQName[] parentMixinTypeNames;
-
private int pos;
/**
@@ -68,8 +66,7 @@
* @param dataManager
* session data manager
*/
- public NodeIteratorOnDemand(List list, SessionDataManager dataManager, InternalQName
parentPrimaryTypeName,
- InternalQName[] parentMixinTypeNames)
+ public NodeIteratorOnDemand(List list, SessionDataManager dataManager, NodeData
parent)
{
if (list == null)
this.list = new ArrayList();
@@ -77,8 +74,7 @@
this.list = list;
this.dataManager = dataManager;
- this.parentPrimaryTypeName = parentPrimaryTypeName;
- this.parentMixinTypeNames = parentMixinTypeNames;
+ this.parent = parent;
this.iter = list.iterator();
this.pos = 0;
@@ -165,7 +161,7 @@
{
try
{
- list.set(pos, dataManager.wrapNodeData((NodeData)item, parentPrimaryTypeName,
parentMixinTypeNames));
+ list.set(pos, dataManager.wrapNodeData((NodeData)item, parent));
}
catch (RepositoryException e)
{