jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r464431 - in /jackrabbit/trunk/contrib/spi: jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ spi/src/main/java/org...
Date Mon, 16 Oct 2006 09:39:20 GMT
Author: angela
Date: Mon Oct 16 02:39:18 2006
New Revision: 464431

URL: http://svn.apache.org/viewvc?view=rev&rev=464431
Log:
work in progress

- reorder: wrong usage of OrderPatch
- reorder: missing check for 'before' being null
- reorder: affected-items in op. not consistent with modified items
- move: session.move must remember srcId 
- spi: add possibility to obtain sessionInfo for another workspace based on an existing sessionInfo.
- uriresolver: defensive check for type of ItemId

Modified:
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
    jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
    jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/SessionImpl.java
Mon Oct 16 02:39:18 2006
@@ -49,6 +49,7 @@
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.XASessionInfo;
 import org.apache.commons.collections.map.ReferenceMap;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -738,7 +739,14 @@
     //--------------------------------------------------------------------------
     SessionImpl switchWorkspace(String workspaceName) throws AccessDeniedException,
         NoSuchWorkspaceException, RepositoryException {
-        return new SessionImpl(sessionInfo, repository, config);
+        checkAccessibleWorkspace(workspaceName);
+        
+        SessionInfo info = config.getRepositoryService().obtain(sessionInfo, workspaceName);
+        if (info instanceof XASessionInfo) {
+            return new XASessionImpl((XASessionInfo) info, repository, config);
+        } else {
+            return new SessionImpl(info, repository, config);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/WorkspaceManager.java
Mon Oct 16 02:39:18 2006
@@ -678,7 +678,7 @@
         }
 
         public void visit(Move operation) throws LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
-            NodeId moveId = operation.getNodeState().getNodeId();
+            NodeId moveId = operation.getSourceId();
             NodeId destParentId = operation.getDestinationParentState().getNodeId();
             if (batch == null) {
                 events = service.move(sessionInfo, moveId, destParentId, operation.getDestinationName());
@@ -733,7 +733,10 @@
         public void visit(ReorderNodes operation) throws RepositoryException {
             NodeId parentId = operation.getParentState().getNodeId();
             NodeId insertId = operation.getInsertNode().getNodeId();
-            NodeId beforeId = operation.getBeforeNode().getNodeId();
+            NodeId beforeId = null;
+            if (operation.getBeforeNode() != null) {
+                beforeId = operation.getBeforeNode().getNodeId() ;
+            }
             batch.reorderNodes(parentId, insertId, beforeId);
         }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/Move.java
Mon Oct 16 02:39:18 2006
@@ -25,6 +25,7 @@
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.name.NamespaceResolver;
+import org.apache.jackrabbit.spi.NodeId;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -44,12 +45,14 @@
 
     private static Logger log = LoggerFactory.getLogger(Move.class);
 
+    private final NodeId srcId;
     private final NodeState srcState;
     private final NodeState srcParentState;
     private final NodeState destParentState;
     private final QName destName;
 
     private Move(NodeState srcNodeState, NodeState srcParentState, NodeState destParentState,
QName destName) {
+        this.srcId = (NodeId) srcNodeState.getId();
         this.srcState = srcNodeState;
         this.srcParentState = srcParentState;
         this.destParentState = destParentState;
@@ -70,7 +73,11 @@
     }
 
     //----------------------------------------< Access Operation Parameters >---
-    public NodeState getNodeState() {
+    public NodeId getSourceId() {
+        return srcId;
+    }
+
+    public NodeState getSourceState() {
         return srcState;
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/operation/ReorderNodes.java
Mon Oct 16 02:39:18 2006
@@ -41,10 +41,6 @@
         this.insert = insert;
         this.before = before;
         addAffectedItemState(parentState);
-        addAffectedItemState(insert);
-        if (before != null) {
-            addAffectedItemState(before);
-        }
     }
 
     //----------------------------------------------------------< Operation >---

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/NodeState.java
Mon Oct 16 02:39:18 2006
@@ -22,7 +22,6 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.name.MalformedPathException;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.Event;
@@ -58,22 +57,6 @@
     private static Logger log = LoggerFactory.getLogger(NodeState.class);
 
     /**
-     * A current element Path instance.
-     */
-    public static final Path CURRENT_PATH;
-
-    static {
-        try {
-            Path.PathBuilder builder = new Path.PathBuilder();
-            builder.addFirst(Path.CURRENT_ELEMENT);
-            CURRENT_PATH = builder.getPath();
-        } catch (MalformedPathException e) {
-            // path is always valid
-            throw new InternalError("unable to create path from '.'");
-        }
-    }
-
-    /**
      * the name of this node's primary type
      */
     private QName nodeTypeName;
@@ -565,71 +548,71 @@
         switch (event.getType()) {
             case Event.NODE_ADDED:
             case Event.PROPERTY_ADDED:
-                if (id.equals(event.getParentId())) {
-                    ItemId evId = event.getItemId();
-                    ItemState newState = null;
+                if (!id.equals(event.getParentId())) {
+                    // TODO: TOBEFIXED. this should never occur and indicates severe consistency
issue.
+                    throw new IllegalArgumentException("Event parent (" + event.getParentId()
+ ") does not match this state with id: " + id);
+                }
+                ItemId evId = event.getItemId();
+                ItemState newState = null;
 
-                    if (evId.denotesNode()) {
-                        QName name = event.getQPath().getNameElement().getName();
-                        int index = event.getQPath().getNameElement().getNormalizedIndex();
-                        String uuid = (((NodeId)evId).getPath() != null) ? null : ((NodeId)evId).getUUID();
-
-                        // add new childNodeEntry if it has not been added by
-                        // some earlier 'add' event
-                        // TODO: TOBEFIXED for SNSs
-                        ChildNodeEntry cne = getChildNodeEntry(name, index);
-                        if (cne == null || ((uuid == null) ? cne.getUUID() != null : !uuid.equals(cne.getUUID())))
{
-                            cne = childNodeEntries.add(name, uuid);
-                        }
-                        try {
-                            newState = cne.getNodeState();
-                        } catch (ItemStateException e) {
-                            log.error("Internal error", e);
-                        }
+                if (evId.denotesNode()) {
+                    QName name = event.getQPath().getNameElement().getName();
+                    int index = event.getQPath().getNameElement().getNormalizedIndex();
+                    String uuid = (((NodeId)evId).getPath() != null) ? null : ((NodeId)evId).getUUID();
+
+                    // add new childNodeEntry if it has not been added by
+                    // some earlier 'add' event
+                    // TODO: TOBEFIXED for SNSs
+                    ChildNodeEntry cne = getChildNodeEntry(name, index);
+                    if (cne == null || ((uuid == null) ? cne.getUUID() != null : !uuid.equals(cne.getUUID())))
{
+                        cne = childNodeEntries.add(name, uuid);
+                    }
+                    try {
+                        newState = cne.getNodeState();
+                    } catch (ItemStateException e) {
+                        log.error("Internal error", e);
+                    }
+                } else {
+                    QName pName = ((PropertyId) event.getItemId()).getQName();
+                    // create a new property reference if it has not been
+                    // added by some earlier 'add' event
+                    ChildPropertyEntry re;
+                    if (hasPropertyName(pName)) {
+                        re = (ChildPropertyEntry) properties.get(pName);
                     } else {
-                        QName pName = ((PropertyId) event.getItemId()).getQName();
-                        // create a new property reference if it has not been
-                        // added by some earlier 'add' event
-                        ChildPropertyEntry re;
-                        if (hasPropertyName(pName)) {
-                            re = (ChildPropertyEntry) properties.get(pName);
-                        } else {
-                            re = PropertyReference.create(this, pName, isf, idFactory);
-                            properties.put(pName, re);
-                        }
-                        try {
-                            newState = re.getPropertyState();
-                        } catch (ItemStateException e) {
-                            log.error("Internal error", e);
-                        }
-                        // make sure this state is up to date (uuid/mixins)
-                        refresh(pName, event.getType());
+                        re = PropertyReference.create(this, pName, isf, idFactory);
+                        properties.put(pName, re);
+                    }
+                    try {
+                        newState = re.getPropertyState();
+                    } catch (ItemStateException e) {
+                        log.error("Internal error", e);
                     }
+                    // make sure this state is up to date (uuid/mixins)
+                    refresh(pName, event.getType());
+                }
 
-                    // connect the added state from the transient layer to the
-                    // new workspaceState and make sure its data are updated.
-                    if (newState != null && changeLog != null) {
-                        for (Iterator it = changeLog.addedStates(); it.hasNext();) {
-                            ItemState added = (ItemState) it.next();
-                            if (added.hasOverlayedState()) {
-                                // already connected
-                                continue;
-                            }
-                            // TODO: TOBEFIXED. may fail (produce wrong results) for SNSs,
since currently events upon 'save' are not garantied to be 'local' changes only
-                            if (added.getId().equals(evId)) {
-                                added.connect(newState);
-                                added.merge();
-                                break;
-                            }
+                // connect the added state from the transient layer to the
+                // new workspaceState and make sure its data are updated.
+                if (newState != null && changeLog != null) {
+                    for (Iterator it = changeLog.addedStates(); it.hasNext();) {
+                        ItemState added = (ItemState) it.next();
+                        if (added.hasOverlayedState()) {
+                            // already connected
+                            continue;
+                        }
+                        // TODO: TOBEFIXED. may fail (produce wrong results) for SNSs, since
currently events upon 'save' are not garantied to be 'local' changes only
+                        // TODO: TOBEFIXED. equals to false if added-state is referenceable.
+                        if (added.getId().equals(evId)) {
+                            added.connect(newState);
+                            added.merge();
+                            break;
                         }
                     }
-                    // and let the transiently modified session state now, that
-                    // its workspace state has been touched.
-                    setStatus(Status.MODIFIED);
-                } else {
-                    // ILLEGAL
-                    throw new IllegalArgumentException("Illegal event type " + event.getType()
+ " for NodeState.");
                 }
+                // and let the transiently modified session state now, that
+                // its workspace state has been touched.
+                setStatus(Status.MODIFIED);
                 break;
 
             case Event.NODE_REMOVED:
@@ -779,25 +762,29 @@
 
                 Collection wspEntries = wspState.getChildNodeEntries();
                 // remove child entries, that are 'REMOVED' in the wsp layer
+                Set toRemove = new HashSet();
                 for (Iterator it = getChildNodeEntries().iterator(); it.hasNext();) {
                     ChildNodeEntry cne = (ChildNodeEntry) it.next();
                     if (cne.isAvailable()) {
                         try {
                             NodeState ns = cne.getNodeState();
                             if (ns.getStatus() == Status.REMOVED) {
-                                childNodeEntries.remove(cne.getName(), cne.getIndex());
+                                toRemove.add(cne);
                             }
                         } catch (ItemStateException e) {
                             // should not occur
                             log.error("Internal error while merging item node states.", e);
                         }
                     } else if (wspState.getChildNodeEntries(cne.getName()).isEmpty()) {
-                        childNodeEntries.remove(cne.getName(), cne.getIndex());
+                        toRemove.add(cne);
                     } // TODO: clean up same-named siblings
                 }
+                for (Iterator it = toRemove.iterator(); it.hasNext();) {
+                    ChildNodeEntry cne = (ChildNodeEntry) it.next();
+                    childNodeEntries.remove(cne.getName(), cne.getIndex());
+                }
 
                 // add missing child entries
-
                 for (Iterator it = wspEntries.iterator(); it.hasNext();) {
                     ChildNodeEntry wspEntry = (ChildNodeEntry) it.next();
                     List namedEntries = getChildNodeEntries(wspEntry.getName());
@@ -1168,6 +1155,7 @@
         }
         // mark both this and newParent modified
         markModified();
+        childState.markModified();
         newParent.markModified();
     }
 

Modified: jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
(original)
+++ jackrabbit/trunk/contrib/spi/jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/SessionItemStateManager.java
Mon Oct 16 02:39:18 2006
@@ -476,9 +476,8 @@
     public void visit(Move operation) throws LockException, ConstraintViolationException,
AccessDeniedException, ItemExistsException, UnsupportedRepositoryOperationException, VersionException,
RepositoryException {
 
         // retrieve states and assert they are modifiable
-        NodeState srcState = operation.getNodeState();
+        NodeState srcState = operation.getSourceState();
         NodeState srcParent = operation.getSourceParentState();
-
         NodeState destParent = operation.getDestinationParentState();
 
         // state validation: move-Source can be removed from old/added to new parent
@@ -556,7 +555,7 @@
                 EffectiveNodeType ent = validator.getEffectiveNodeType(nState);
                 QPropertyDefinition pd = ent.getApplicablePropertyDefinition(QName.JCR_MIXINTYPES,
PropertyType.NAME, true);
                 QValue[] mixinValue = QValue.create(nState.getMixinTypeNames());
-                int options = 0; // nothing to check
+                int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
                 addPropertyState(nState, pd.getQName(), pd.getRequiredType(), mixinValue,
pd, options);
             }
         } else {
@@ -568,7 +567,7 @@
             if (nState.hasPropertyName(QName.JCR_MIXINTYPES)) {
                 try {
                     PropertyState pState = nState.getPropertyState(QName.JCR_MIXINTYPES);
-                    int options = 0; // no checks required
+                    int options = ItemStateValidator.CHECK_LOCK | ItemStateValidator.CHECK_VERSIONING;
                     removeItemState(pState, options);
                 } catch (ItemStateException e) {
                     // should not occur, since existance has been asserted before

Modified: jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi/src/main/java/org/apache/jackrabbit/spi/RepositoryService.java
Mon Oct 16 02:39:18 2006
@@ -79,6 +79,20 @@
             throws LoginException, NoSuchWorkspaceException, RepositoryException;
 
     /**
+     * Returns a new <code>SessionInfo</code> for the given workspace name that
+     * will be used by other methods on the <code>RepositoryService</code>.
+     *
+     * @param sessionInfo for another workspace
+     * @return a <code>SessionInfo</code> if authentication was successful.
+     * @throws LoginException           if authentication of the user fails.
+     * @throws NoSuchWorkspaceException if the specified <code>workspaceName</code>
+     *                                  is not recognized.
+     * @throws RepositoryException      if an error occurs.
+     */
+    public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName)
+            throws LoginException, NoSuchWorkspaceException, RepositoryException;
+
+    /**
      * Indicates to the <code>RepositoryService</code>, that the given SessionInfo
      * will not be used any more.
      *

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Mon Oct 16 02:39:18 2006
@@ -65,6 +65,7 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.DavMethods;
+import org.apache.jackrabbit.webdav.ordering.OrderingConstants;
 import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
 import org.apache.jackrabbit.webdav.observation.EventType;
 import org.apache.jackrabbit.webdav.observation.Filter;
@@ -390,15 +391,27 @@
      *
      * @see RepositoryService#obtain(Credentials, String)
      */
-    public SessionInfo obtain(Credentials credentials, String workspaceName) throws LoginException,
NoSuchWorkspaceException, RepositoryException {
+    public SessionInfo obtain(Credentials credentials, String workspaceName)
+        throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        CredentialsWrapper dc = new CredentialsWrapper(credentials);
+        return obtain(dc, workspaceName);
+    }
+
+    public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName)
+        throws LoginException, NoSuchWorkspaceException, RepositoryException {
+        checkSessionInfo(sessionInfo);
+        return obtain(((SessionInfoImpl)sessionInfo).getCredentials(), workspaceName);
+    }
+
+    private SessionInfo obtain(CredentialsWrapper credentials, String workspaceName)
+        throws LoginException, NoSuchWorkspaceException, RepositoryException {
         // check if the workspace with the given name is accessible
         PropFindMethod method = null;
         try {
             DavPropertyNameSet nameSet = new DavPropertyNameSet();
             nameSet.add(DeltaVConstants.WORKSPACE);
             method = new PropFindMethod(uriResolver.getWorkspaceUri(workspaceName), nameSet,
DavConstants.DEPTH_0);
-            CredentialsWrapper dc = new CredentialsWrapper(credentials);
-            getClient(dc.getCredentials()).executeMethod(method);
+            getClient(credentials.getCredentials()).executeMethod(method);
 
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             if (responses.length != 1) {
@@ -412,7 +425,7 @@
                 if (!wspName.equals(workspaceName)) {
                     throw new LoginException("Login failed: Invalid workspace name " + workspaceName);
                 }
-                return new SessionInfoImpl(dc, workspaceName, new SubscriptionMgrImpl());
+                return new SessionInfoImpl(credentials, workspaceName, new SubscriptionMgrImpl());
             } else {
                 throw new LoginException("Login failed: Unknown workspace '" + workspaceName+
" '.");
             }
@@ -1787,13 +1800,20 @@
         public void reorderNodes(NodeId parentId, NodeId srcNodeId, NodeId beforeNodeId)
throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException,
ItemNotFoundException, LockException, AccessDeniedException, RepositoryException {
             checkConsumed();
             try {
+                String uri = getItemUri(parentId, sessionInfo);
                 String srcUri = getItemUri(srcNodeId, sessionInfo);
                 String srcSegment = Text.getName(srcUri, true);
-                String targetSegment = Text.getName(getItemUri(beforeNodeId, sessionInfo),
true);
-
-                String uri = getItemUri(parentId, sessionInfo);
-                OrderPatchMethod method = new OrderPatchMethod(uri, srcSegment, targetSegment,
true);
 
+                OrderPatchMethod method;
+                if (beforeNodeId == null) {
+                    // move src to the end
+                    method = new OrderPatchMethod(uri, OrderingConstants.ORDERING_TYPE_CUSTOM,
srcSegment, false);
+                } else {
+                    // insert src before the targetSegment
+                    String beforeUri = getItemUri(beforeNodeId, sessionInfo);
+                    String targetSegment = Text.getName(beforeUri, true);
+                    method = new OrderPatchMethod(uri, OrderingConstants.ORDERING_TYPE_CUSTOM,
srcSegment, targetSegment, true);
+                }
                 methods.add(method);
             } catch (IOException e) {
                 throw new RepositoryException(e);

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?view=diff&rev=464431&r1=464430&r2=464431
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
Mon Oct 16 02:39:18 2006
@@ -182,7 +182,10 @@
                        String workspaceName) throws RepositoryException {
         IdURICache cache = getCache(workspaceName);
         if (cache.containsUri(response.getHref())) {
-            return (NodeId) cache.getItemId(response.getHref());
+            ItemId id = cache.getItemId(response.getHref());
+            if (id.denotesNode()) {
+                return (NodeId) id;
+            }
         }
 
         NodeId nodeId;
@@ -223,19 +226,22 @@
                                String workspaceName) throws RepositoryException {
         IdURICache cache = getCache(workspaceName);
         if (cache.containsUri(response.getHref())) {
-            return (PropertyId) cache.getItemId(response.getHref());
-        } else {
-            try {
-                DavPropertySet propSet = response.getProperties(DavServletResponse.SC_OK);
-                QName name = NameFormat.parse(propSet.get(ItemResourceConstants.JCR_NAME).getValue().toString(),
nsResolver);
-                PropertyId propertyId = service.getIdFactory().createPropertyId(parentId,
name);
-
-                cache.add(response.getHref(), propertyId);
-                return propertyId;
-            } catch (BaseException e) {
-                throw new RepositoryException(e);
+            ItemId id = cache.getItemId(response.getHref());
+            if (!id.denotesNode()) {
+                return (PropertyId) id;
             }
         }
+
+        try {
+            DavPropertySet propSet = response.getProperties(DavServletResponse.SC_OK);
+            QName name = NameFormat.parse(propSet.get(ItemResourceConstants.JCR_NAME).getValue().toString(),
nsResolver);
+            PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, name);
+
+            cache.add(response.getHref(), propertyId);
+            return propertyId;
+        } catch (BaseException e) {
+            throw new RepositoryException(e);
+        }
     }
 
     //-------------------------------------------------------< URI resolver >---
@@ -270,40 +276,43 @@
         IdURICache cache = getCache(sessionInfo.getWorkspaceName());
         if (cache.containsUri(uri)) {
             // id has been accessed before and is cached
-            return (NodeId) cache.getItemId(uri);
-        } else {
-            // retrieve parentId from cache or by recursive calls
-            NodeId parentId;
-            if (uri.equals(getRootItemUri(sessionInfo.getWorkspaceName()))) {
-                parentId = null;
-            } else {
-                String parentUri = Text.getRelativeParent(uri, 1, true);
-                parentId = getNodeId(parentUri, sessionInfo);
+            ItemId id = cache.getItemId(uri);
+            if (id.denotesNode()) {
+                return (NodeId) id;
             }
+        }
 
-            DavPropertyNameSet nameSet = new DavPropertyNameSet();
-            nameSet.add(ItemResourceConstants.JCR_UUID);
-            nameSet.add(ItemResourceConstants.JCR_NAME);
-            nameSet.add(ItemResourceConstants.JCR_INDEX);
-            DavMethodBase method = null;
-            try {
-                method = new PropFindMethod(uri, nameSet, DavConstants.DEPTH_0);
-
-                service.getClient(sessionInfo).executeMethod(method);
-                MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
-                if (responses.length != 1) {
-                    throw new ItemNotFoundException("Unable to retrieve the node with id
" + uri);
-                }
-                return buildNodeId(parentId, responses[0], sessionInfo.getWorkspaceName());
+        // retrieve parentId from cache or by recursive calls
+        NodeId parentId;
+        if (uri.equals(getRootItemUri(sessionInfo.getWorkspaceName()))) {
+            parentId = null;
+        } else {
+            String parentUri = Text.getRelativeParent(uri, 1, true);
+            parentId = getNodeId(parentUri, sessionInfo);
+        }
 
-            } catch (IOException e) {
-                throw new RepositoryException(e);
-            } catch (DavException e) {
-                throw ExceptionConverter.generate(e);
-            } finally {
-                if (method != null) {
-                    method.releaseConnection();
-                }
+        DavPropertyNameSet nameSet = new DavPropertyNameSet();
+        nameSet.add(ItemResourceConstants.JCR_UUID);
+        nameSet.add(ItemResourceConstants.JCR_NAME);
+        nameSet.add(ItemResourceConstants.JCR_INDEX);
+        DavMethodBase method = null;
+        try {
+            method = new PropFindMethod(uri, nameSet, DavConstants.DEPTH_0);
+
+            service.getClient(sessionInfo).executeMethod(method);
+            MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
+            if (responses.length != 1) {
+                throw new ItemNotFoundException("Unable to retrieve the node with id " +
uri);
+            }
+            return buildNodeId(parentId, responses[0], sessionInfo.getWorkspaceName());
+
+        } catch (IOException e) {
+            throw new RepositoryException(e);
+        } catch (DavException e) {
+            throw ExceptionConverter.generate(e);
+        } finally {
+            if (method != null) {
+                method.releaseConnection();
             }
         }
     }
@@ -314,23 +323,26 @@
     public PropertyId getPropertyId(String uri, SessionInfo sessionInfo) throws RepositoryException
{
         IdURICache cache = getCache(sessionInfo.getWorkspaceName());
         if (cache.containsUri(uri)) {
-            return (PropertyId) cache.getItemId(uri);
-        } else {
-            // separate parent uri and property JCRName
-            String parentUri = Text.getRelativeParent(uri, 1, true);
-            // make sure propName is unescaped
-            String propName = Text.unescape(Text.getName(uri, true));
-            // retrieve parent node id
-            NodeId parentId = getNodeId(parentUri, sessionInfo);
-            // build property id
-            try {
-                PropertyId propertyId = service.getIdFactory().createPropertyId(parentId,
NameFormat.parse(propName, nsResolver));
-                cache.add(uri, propertyId);
-
-                return propertyId;
-            } catch (NameException e) {
-                throw new RepositoryException(e);
+            ItemId id = cache.getItemId(uri);
+            if (!id.denotesNode()) {
+                return (PropertyId) id;
             }
+        }
+
+        // separate parent uri and property JCRName
+        String parentUri = Text.getRelativeParent(uri, 1, true);
+        // make sure propName is unescaped
+        String propName = Text.unescape(Text.getName(uri, true));
+        // retrieve parent node id
+        NodeId parentId = getNodeId(parentUri, sessionInfo);
+        // build property id
+        try {
+            PropertyId propertyId = service.getIdFactory().createPropertyId(parentId, NameFormat.parse(propName,
nsResolver));
+            cache.add(uri, propertyId);
+
+            return propertyId;
+        } catch (NameException e) {
+            throw new RepositoryException(e);
         }
     }
 }



Mime
View raw message