You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2008/10/17 10:40:10 UTC
svn commit: r705512 - in /jackrabbit/branches/1.5: ./
jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/
jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/
jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2s...
Author: jukka
Date: Fri Oct 17 01:40:09 2008
New Revision: 705512
URL: http://svn.apache.org/viewvc?rev=705512&view=rev
Log:
1.5: Merged revisions 704933 and 705010 (JCR-1798, JCR-1809, and JCR-1784). Ignored revisions 704939 and 705010.
Modified:
jackrabbit/branches/1.5/ (props changed)
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java
jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/ObjectConverter.java
jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 17 01:40:09 2008
@@ -1,2 +1,2 @@
/jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemImpl.java Fri Oct 17 01:40:09 2008
@@ -251,7 +251,7 @@
// from the 'server'.
// Note, that with Observation-CacheBehaviour no manuel refresh
// is required. changes get pushed automatically.
- state.getHierarchyEntry().reload(true, true);
+ state.getHierarchyEntry().invalidate(true);
}
} else {
// check status of item state
@@ -413,7 +413,7 @@
// check status of this item for read operation
if (state.getStatus() == Status.INVALIDATED) {
// refresh to get current status from persistent storage
- state.getHierarchyEntry().reload(false, false);
+ state.getHierarchyEntry().reload(false);
}
// now check if valid
if (!state.isValid()) {
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java Fri Oct 17 01:40:09 2008
@@ -743,6 +743,12 @@
itemState = ((NodeImpl) version).getItemState();
} else {
Path p = getQPath(version.getPath());
+ Path parentPath = p.getAncestor(1);
+ HierarchyEntry parentEntry = getHierarchyManager().lookup(parentPath);
+ if (parentEntry != null) {
+ // make sure the parent entry is up to date
+ parentEntry.invalidate(false);
+ }
itemState = getHierarchyManager().getItemState(p);
}
return (NodeState) itemState;
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/ChildNodeEntriesImpl.java Fri Oct 17 01:40:09 2008
@@ -147,7 +147,7 @@
* resulting in inconsistent entries.
*
* @param childNodeInfos
- * @see HierarchyEntry#reload(boolean, boolean) that ignores items with
+ * @see HierarchyEntry#reload(boolean) that ignores items with
* pending changes.
* @see org.apache.jackrabbit.jcr2spi.operation.AddNode
* @see org.apache.jackrabbit.jcr2spi.operation.Move
@@ -165,7 +165,14 @@
ln = internalAddAfter(entry, ci.getIndex(), prevLN);
} else if (prevLN != null) {
// assert correct order of existing
- reorderAfter(ln, prevLN);
+ if (prevLN != ln) {
+ reorderAfter(ln, prevLN);
+ } else {
+ // there was an existing entry but it's the same as the one
+ // created/retrieved before. getting here indicates that
+ // the SPI implementation provided invalid childNodeInfos.
+ log.error("ChildInfo iterator contains multiple entries with the same name|index or uniqueID -> ignore ChildNodeInfo.");
+ }
}
prevLN = ln;
}
@@ -446,7 +453,7 @@
entriesByName.reorder(insertName, insertLN, position);
}
// reorder in linked list
- entries.reorderNode(insertLN, afterLN.getNextLinkNode());
+ entries.reorderNode(insertLN, currentAfter);
}
}
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntry.java Fri Oct 17 01:40:09 2008
@@ -110,10 +110,11 @@
public void setItemState(ItemState state);
/**
- * Invalidates the underlying <code>ItemState</code> if available. If the
- * <code>recursive</code> flag is true, the hierarchy is traverses and
- * {@link #invalidate(boolean)} is called on all child entries.<br>
- * Note, that in contrast to {@link HierarchyEntry#reload(boolean, boolean)}
+ * Invalidates the underlying <code>ItemState</code> if available and if it
+ * is not transiently modified. If the <code>recursive</code> flag is true,
+ * the hierarchy is traverses and {@link #invalidate(boolean)} is called on
+ * all child entries.<br>
+ * Note, that in contrast to {@link HierarchyEntry#reload(boolean)}
* this method only sets the status of this item state to {@link
* Status#INVALIDATED} and does not acutally update it with the persistent
* state in the repository.
@@ -131,15 +132,12 @@
/**
* Reloads this hierarchy entry and the corresponding ItemState, if this
- * entry has already been resolved. If '<code>keepChanges</code>' is true,
- * states with transient changes are left untouched in order to detect stale
- * item states. Otherwise this state gets its data reloaded from the
- * persistent storage. If '<code>recursive</code>' the complete hierarchy
- * below this entry is reloaded as well.
+ * entry has already been resolved. If '<code>recursive</code>' the complete
+ * hierarchy below this entry is reloaded as well.
*
- * @param keepChanges
+ * @param recursive
*/
- public void reload(boolean keepChanges, boolean recursive);
+ public void reload(boolean recursive);
/**
* Traverses the hierarchy and marks all available item states as transiently
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/HierarchyEntryImpl.java Fri Oct 17 01:40:09 2008
@@ -104,7 +104,7 @@
}
} else if (state.getStatus() == Status.INVALIDATED) {
// completely reload this entry, but don't reload recursively
- reload(false, false);
+ reload(false);
}
return state;
}
@@ -235,9 +235,11 @@
* @see HierarchyEntry#invalidate(boolean)
*/
public void invalidate(boolean recursive) {
- ItemState state = internalGetItemState();
- if (state != null) {
+ if (getStatus() == Status.EXISTING) {
+ ItemState state = internalGetItemState();
state.setStatus(Status.INVALIDATED);
+ } else {
+ log.debug("Skip invalidation for HierarchyEntry " + name + " with status " + Status.getName(getStatus()));
}
}
@@ -287,9 +289,9 @@
/**
* {@inheritDoc}
- * @see HierarchyEntry#reload(boolean, boolean)
+ * @see HierarchyEntry#reload(boolean)
*/
- public void reload(boolean keepChanges, boolean recursive) {
+ public void reload(boolean recursive) {
int status = getStatus();
if (status == Status._UNDEFINED_) {
// unresolved: entry will be loaded and validated upon resolution.
@@ -337,7 +339,7 @@
// if during recursive removal an invalidated entry is found, reload
// it in order to determine the current status.
if (state.getStatus() == Status.INVALIDATED) {
- reload(false, false);
+ reload(false);
}
switch (state.getStatus()) {
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/hierarchy/NodeEntryImpl.java Fri Oct 17 01:40:09 2008
@@ -190,11 +190,11 @@
* traversed and reloaded. Otherwise only this entry and the direct
* decendants are reloaded.
*
- * @see HierarchyEntry#reload(boolean, boolean)
+ * @see HierarchyEntry#reload(boolean)
*/
- public void reload(boolean keepChanges, boolean recursive) {
+ public void reload(boolean recursive) {
// reload this entry
- super.reload(keepChanges, recursive);
+ super.reload(recursive);
// reload all children unless 'recursive' is false and the reload above
// did not cause this entry to be removed -> therefore check status.
@@ -202,7 +202,7 @@
// recursivly reload all entries including props that are in the attic.
for (Iterator it = getAllChildEntries(true); it.hasNext();) {
HierarchyEntry ce = (HierarchyEntry) it.next();
- ce.reload(keepChanges, recursive);
+ ce.reload(recursive);
}
}
}
@@ -394,6 +394,12 @@
return entry.properties.get(name);
} else {
// no valid entry
+ // -> if cnes are complete -> assume that it doesn't exist.
+ // refresh will bring up new entries added in the mean time
+ // on the persistent layer.
+ if (entry.childNodeEntries.isComplete()) {
+ throw new PathNotFoundException(path.toString());
+ }
// -> check for moved child entry in node-attic
// -> check if child points to a removed/moved sns
List siblings = entry.childNodeEntries.get(name);
@@ -532,7 +538,7 @@
if (cne == null && loadIfNotFound
&& !containsAtticChild(entries, nodeName, index)
- && Status.NEW != getStatus()) {
+ && !childNodeEntries.isComplete()) {
PathFactory pf = factory.getPathFactory();
NodeId cId = factory.getIdFactory().createNodeId(getWorkspaceId(), pf.create(nodeName, index));
cne = loadNodeEntry(cId);
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/OpenScopedLockTest.java Fri Oct 17 01:40:09 2008
@@ -45,6 +45,10 @@
testRoot2.save();
Lock lock2 = lockedNode2.lock(false, isSessionScoped());
+
+ // force reloading of the testroot in order to be aware of the
+ // locked noded added by another session
+ testRootNode.refresh(false);
Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
try {
String lockToken = lock2.getLockToken();
Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/lock/SessionScopedLockTest.java Fri Oct 17 01:40:09 2008
@@ -61,6 +61,9 @@
lockedNode2.addMixin(mixLockable);
testRoot2.save();
+ // force reloading of the testroot in order to be aware of the
+ // locked noded added by another session
+ testRootNode.refresh(false);
Node n2 = (Node) superuser.getItem(lockedNode2.getPath());
// remove lock implicit by logout lock-holding session
Modified: jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/ObjectConverter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/ObjectConverter.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/ObjectConverter.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/ObjectConverter.java Fri Oct 17 01:40:09 2008
@@ -108,6 +108,16 @@
* Update the object
*
* @param session the JCR session
+ * @param objectNode The node to store the object
+ * @param object the object to update
+ * @throws ObjectContentManagerException when it is not possible to update the object
+ */
+ public void update(Session session, Node objectNode, Object object) throws ObjectContentManagerException;
+
+ /**
+ * Update the object
+ *
+ * @param session the JCR session
* @param parentNode The parent node used to store the new JCR element (object)
* @param nodeName The node name used to store the object
* @param object the object to update
Modified: jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java?rev=705512&r1=705511&r2=705512&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java (original)
+++ jackrabbit/branches/1.5/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java Fri Oct 17 01:40:09 2008
@@ -21,6 +21,7 @@
import java.util.Map;
import javax.jcr.Node;
+import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -64,6 +65,7 @@
*
* @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
* @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
+ * @author <a href='mailto:boni.g@bioimagene.com'>Boni Gopalan</a>
*/
public class ObjectConverterImpl implements ObjectConverter {
@@ -275,32 +277,21 @@
try {
ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(ReflectionUtils.getBeanClass(object));
Node objectNode = session.getNodeByUUID(uuId);
-
- checkNodeType(session, classDescriptor);
-
- checkCompatiblePrimaryNodeTypes(session, objectNode, classDescriptor, false);
-
- simpleFieldsHelp.storeSimpleFields(session, object, classDescriptor, objectNode);
- updateBeanFields(session, object, classDescriptor, objectNode);
- updateCollectionFields(session, object, classDescriptor, objectNode);
- simpleFieldsHelp.refreshUuidPath(session, classDescriptor, objectNode, object);
+ update(session, objectNode, object);
} catch (PathNotFoundException pnfe) {
throw new ObjectContentManagerException("Impossible to update the object with UUID: " + uuId , pnfe);
} catch (RepositoryException re) {
throw new org.apache.jackrabbit.ocm.exception.RepositoryException("Impossible to update the object with UUID: " + uuId, re);
}
}
-
-
+
/**
*
* @see org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter#update(javax.jcr.Session,
- * javax.jcr.Node, java.lang.String, java.lang.Object)
+ * javax.jcr.Node, java.lang.Object)
*/
- public void update(Session session, Node parentNode, String nodeName, Object object) {
- try {
+ public void update(Session session, Node objectNode, Object object) {
ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(ReflectionUtils.getBeanClass(object));
- Node objectNode = parentNode.getNode(nodeName);
checkNodeType(session, classDescriptor);
@@ -310,6 +301,19 @@
updateBeanFields(session, object, classDescriptor, objectNode);
updateCollectionFields(session, object, classDescriptor, objectNode);
simpleFieldsHelp.refreshUuidPath(session, classDescriptor, objectNode, object);
+ }
+
+
+ /**
+ *
+ * @see org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter#update(javax.jcr.Session,
+ * javax.jcr.Node, java.lang.String, java.lang.Object)
+ */
+ public void update(Session session, Node parentNode, String nodeName, Object object) {
+ try {
+ ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(ReflectionUtils.getBeanClass(object));
+ Node objectNode = getNode(parentNode,classDescriptor,nodeName,object);
+ update(session, objectNode, object);
} catch (PathNotFoundException pnfe) {
throw new ObjectContentManagerException("Impossible to update the object: " + nodeName + " at node : " + parentNode, pnfe);
} catch (RepositoryException re) {
@@ -319,6 +323,36 @@
}
/**
+ *
+ * @param parentNode the parent node at which to look for the node element.
+ * @param nodeName the node name to look for
+ * @param object the data.
+ * @param classDescriptor
+ * @return The child node we are interested in.
+ */
+ private Node getNode(Node parentNode, ClassDescriptor classDescriptor, String nodeName, Object object) throws RepositoryException{
+ if (parentNode == null) return null;
+ NodeIterator nodes = parentNode.getNodes(nodeName);
+ if (nodes.getSize() == 1) return nodes.nextNode();
+ if (classDescriptor.hasUUIdField()){
+ String uuidFieldName = classDescriptor.getUuidFieldDescriptor().getFieldName();
+ Object objUuid = ReflectionUtils.getNestedProperty(object, uuidFieldName);
+ String currentItemUuid = (objUuid == null) ? null : objUuid.toString();
+ if (currentItemUuid != null){
+ //The Node already exists so we need to update the existing node
+ //rather than to replace it.
+ return parentNode.getSession().getNodeByUUID(currentItemUuid);
+ }
+ else{
+ throw new NullPointerException("Cannot locate the node to update since there is no UUID provided even though, " + classDescriptor.getClassName() + " has been mapped with a UUID field , " + uuidFieldName );
+ }
+
+ }
+ return parentNode.getNode(nodeName);
+
+ }
+
+ /**
* @see org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter#getObject(javax.jcr.Session,
* java.lang.Class, java.lang.String)
*/