jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1461613 - in /jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav: IdURICache.java URIResolverImpl.java
Date Wed, 27 Mar 2013 14:40:57 GMT
Author: reschke
Date: Wed Mar 27 14:40:57 2013
New Revision: 1461613

URL: http://svn.apache.org/r1461613
Log:
JCR-3549: URIResolverImpl needs to handle absolute paths in addition to absolute URIs

Modified:
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java?rev=1461613&r1=1461612&r2=1461613&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
Wed Mar 27 14:40:57 2013
@@ -71,7 +71,7 @@ class IdURICache {
 
     public void add(String uri, ItemId itemId) {
         if (!uri.startsWith(workspaceUri)) {
-            throw new IllegalArgumentException("Workspace missmatch.");
+            throw new IllegalArgumentException("Workspace mismatch: '" + uri + "' not under
'" + workspaceUri + "'");
         }
         String cleanUri = getCleanUri(uri);
         uriToIdCache.put(cleanUri, itemId);

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?rev=1461613&r1=1461612&r2=1461613&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
Wed Mar 27 14:40:57 2013
@@ -45,6 +45,7 @@ import org.w3c.dom.Document;
 import javax.jcr.ItemNotFoundException;
 import javax.jcr.RepositoryException;
 import java.io.IOException;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -125,8 +126,9 @@ class URIResolverImpl implements URIReso
 
                         MultiStatus ms = rm.getResponseBodyAsMultiStatus();
                         if (ms.getResponses().length == 1) {
-                            uriBuffer.append(ms.getResponses()[0].getHref());
-                            cache.add(ms.getResponses()[0].getHref(), uuidId);
+                            String absoluteUri = resolve(wspUri, ms.getResponses()[0].getHref());
+                            uriBuffer.append(absoluteUri);
+                            cache.add(absoluteUri, uuidId);
                         } else {
                             throw new ItemNotFoundException("Cannot identify item with uniqueID
" + uniqueID);
                         }
@@ -135,6 +137,8 @@ class URIResolverImpl implements URIReso
                         throw new RepositoryException(e.getMessage());
                     } catch (DavException e) {
                         throw ExceptionConverter.generate(e);
+                    } catch (URISyntaxException e) {
+                        throw new RepositoryException(e.getMessage());
                     } finally {
                         if (rm != null) {
                             rm.releaseConnection();
@@ -161,6 +165,15 @@ class URIResolverImpl implements URIReso
         }
     }
 
+    /**
+     * Resolve the given href obtained from multistatus against base URI
+     */
+    private static String resolve(String wspUri, String href) throws URISyntaxException {
+        java.net.URI base = new java.net.URI(wspUri);
+        java.net.URI rel = new java.net.URI(href);
+        return base.resolve(rel).toASCIIString();
+    }
+
     NodeId buildNodeId(NodeId parentId, MultiStatusResponse response,
                        String workspaceName, NamePathResolver resolver) throws RepositoryException
{
         IdURICache cache = getCache(workspaceName);



Mime
View raw message