jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1505942 - in /jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit: spi2dav/RepositoryServiceImpl.java spi2davex/RepositoryServiceImpl.java
Date Tue, 23 Jul 2013 09:02:24 GMT
Author: reschke
Date: Tue Jul 23 09:02:24 2013
New Revision: 1505942

URL: http://svn.apache.org/r1505942
Log:
JCR-3228: WebDav/DavEx remoting throws workspace mismatch exceptions when running on port
80

Modified:
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1505942&r1=1505941&r2=1505942&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Jul 23 09:02:24 2013
@@ -324,7 +324,7 @@ public class RepositoryServiceImpl imple
         this.itemInfoCacheSize = itemInfoCacheSize;
 
         try {
-            URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri+"/", true);
+            URI repositoryUri = computeRepositoryUri(uri);
             hostConfig = new HostConfiguration();
             hostConfig.setHost(repositoryUri);
 
@@ -2658,6 +2658,26 @@ public class RepositoryServiceImpl imple
     }
 
     /**
+     * Compute the repository URI (while dealing with trailing / and port number
+     * defaulting)
+     */
+    public static URI computeRepositoryUri(String uri) throws URIException {
+        URI repositoryUri = new URI((uri.endsWith("/")) ? uri : uri + "/", true);
+        // workaround for JCR-3228: normalize default port numbers because of
+        // the weak URI matching code elsewhere (the remote server is unlikely
+        // to include the port number in URIs when it's the default for the
+        // protocol)
+        boolean useDefaultPort = ("http".equalsIgnoreCase(repositoryUri.getScheme()) &&
repositoryUri.getPort() == 80)
+                || (("https".equalsIgnoreCase(repositoryUri.getScheme()) && repositoryUri.getPort()
== 443));
+        if (useDefaultPort) {
+            repositoryUri = new URI(repositoryUri.getScheme(), repositoryUri.getUserinfo(),
repositoryUri.getHost(), -1,
+                    repositoryUri.getPath(), repositoryUri.getQuery(), repositoryUri.getFragment());
+        }
+
+        return repositoryUri;
+    }
+
+    /**
      *
      * @param sessionInfo
      * @param reportDoc

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java?rev=1505942&r1=1505941&r2=1505942&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2davex/RepositoryServiceImpl.java
Tue Jul 23 09:02:24 2013
@@ -31,6 +31,8 @@ import javax.jcr.RepositoryException;
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.URI;
+import org.apache.commons.httpclient.URIException;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
 import org.apache.commons.httpclient.methods.multipart.Part;
@@ -190,7 +192,13 @@ public class RepositoryServiceImpl exten
         super(jcrServerURI, IdFactoryImpl.getInstance(), NameFactoryImpl.getInstance(),
                 PathFactoryImpl.getInstance(), new QValueFactoryImpl(), itemInfoCacheSize,
maximumHttpConnections);
 
-        this.jcrServerURI = jcrServerURI.endsWith("/") ? jcrServerURI : jcrServerURI + "/";
+        try {
+            URI repositoryUri = computeRepositoryUri(jcrServerURI);
+            this.jcrServerURI = repositoryUri.toString();
+        } catch (URIException e) {
+            throw new RepositoryException(e);
+        }
+
         this.defaultWorkspaceName = defaultWorkspaceName;
         if (batchReadConfig == null) {
             this.batchReadConfig = new BatchReadConfig() {



Mime
View raw message