jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r711568 - in /jackrabbit/sandbox/spi: ./ client/src/test/java/org/apache/jackrabbit/client/ client/src/test/resources/ spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/
Date Wed, 05 Nov 2008 13:50:31 GMT
Author: angela
Date: Wed Nov  5 05:50:30 2008
New Revision: 711568

URL: http://svn.apache.org/viewvc?rev=711568&view=rev
Log:
JCR-1842: RepositoryService.obtain should allow to pass null workspaceName [...]



Modified:
    jackrabbit/sandbox/spi/README.txt
    jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
    jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties
    jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

Modified: jackrabbit/sandbox/spi/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/README.txt?rev=711568&r1=711567&r2=711568&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/README.txt (original)
+++ jackrabbit/sandbox/spi/README.txt Wed Nov  5 05:50:30 2008
@@ -63,8 +63,6 @@
    
    # adjust config for JCR2SPIRepositoryStub (SPI2DAV)
    org.apache.jackrabbit.jcr2spi.repository.url=http://<host>:<port>/jackrabbit/server/
-   org.apache.jackrabbit.jcr2spi.workspace.name=<default-workspace-name>
-
 
 
 Requirements

Modified: jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java?rev=711568&r1=711567&r2=711568&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
(original)
+++ jackrabbit/sandbox/spi/client/src/test/java/org/apache/jackrabbit/client/JCR2SPIRepositoryStub.java
Wed Nov  5 05:50:30 2008
@@ -46,11 +46,7 @@
      * Property for the repository url
      */
     public static final String PROP_REPOSITORY_URL = "org.apache.jackrabbit.jcr2spi.repository.url";
-    /**
-     * Property for the default workspace name
-     */
-    public static final String PROP_WORKSPACE_NAME = "org.apache.jackrabbit.jcr2spi.workspace.name";
-
+    
     static {
         PropertyConfigurator.configure(JCR2SPIRepositoryStub.class.getClassLoader().getResource("log4j.properties"));
     }
@@ -82,11 +78,6 @@
                     public RepositoryService getRepositoryService() {
                         return webdavRepoService;
                     }
-
-                    public String getDefaultWorkspaceName() {
-                        String name = environment.getProperty(PROP_WORKSPACE_NAME);
-                        return name;
-                    }
                 };
 
                 repository = RepositoryImpl.create(config);

Modified: jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties?rev=711568&r1=711567&r2=711568&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties (original)
+++ jackrabbit/sandbox/spi/client/src/test/resources/repositoryStubImpl.properties Wed Nov
 5 05:50:30 2008
@@ -38,8 +38,6 @@
 # config for JCR2SPIRepositoryStub (SPI2DAV)
 org.apache.jackrabbit.jcr2spi.repository.url=http://localhost:4302/jackrabbit/server/
 
-# name of the default workspace
-org.apache.jackrabbit.jcr2spi.workspace.name=default
 # alternative workspace used for update tests etc.
 org.apache.jackrabbit.jcr2spi.workspace2.name=test
 

Modified: jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=711568&r1=711567&r2=711568&view=diff
==============================================================================
--- jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/sandbox/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Wed Nov  5 05:50:30 2008
@@ -521,24 +521,38 @@
         SessionInfoImpl sessionInfo = new SessionInfoImpl(credentials, workspaceName);
         try {
             DavPropertyNameSet nameSet = new DavPropertyNameSet();
+            // for backwards compat. -> retrieve DAV:workspace if the newly
+            // added property (workspaceName) is not supported by the server.
             nameSet.add(DeltaVConstants.WORKSPACE);
+            nameSet.add(ItemResourceConstants.JCR_WORKSPACE_NAME);
+
             method = new PropFindMethod(uriResolver.getWorkspaceUri(workspaceName), nameSet,
DavConstants.DEPTH_0);
             getClient(sessionInfo).executeMethod(method);
 
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
             if (responses.length != 1) {
-                throw new LoginException("Login failed: Unknown workspace '" + workspaceName+
" '.");
+                throw new LoginException("Login failed: Unknown workspace '" + workspaceName+
"'.");
             }
 
+            boolean success = false;
             DavPropertySet props = responses[0].getProperties(DavServletResponse.SC_OK);
-            if (props.contains(DeltaVConstants.WORKSPACE)) {
+            if (props.contains(ItemResourceConstants.JCR_WORKSPACE_NAME)) {
+                String wspName = props.get(ItemResourceConstants.JCR_WORKSPACE_NAME).getValue().toString();
+                if (workspaceName == null) {
+                    // login with 'null' workspace name -> retrieve the effective
+                    // workspace name from the property and recreate the SessionInfo.
+                    sessionInfo = new SessionInfoImpl(credentials, wspName);
+                } else if (!wspName.equals(workspaceName)) {
+                    throw new LoginException("Login failed: Invalid workspace name '" + workspaceName
+ "'.");
+                }
+            } else if (props.contains(DeltaVConstants.WORKSPACE)) {
                 String wspHref = new HrefProperty(props.get(DeltaVConstants.WORKSPACE)).getHrefs().get(0).toString();
                 String wspName = Text.unescape(Text.getName(wspHref, true));
                 if (!wspName.equals(workspaceName)) {
                     throw new LoginException("Login failed: Invalid workspace name " + workspaceName);
                 }
             } else {
-                throw new LoginException("Login failed: Unknown workspace '" + workspaceName+
" '.");
+                throw new LoginException("Login failed: Unknown workspace '" + workspaceName+
"'.");
             }
         } catch (IOException e) {
             throw new RepositoryException(e.getMessage());
@@ -581,17 +595,17 @@
             method = new PropFindMethod(uriResolver.getRepositoryUri(), nameSet, DEPTH_1);
             getClient(sessionInfo).executeMethod(method);
             MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
-            Set ids = new HashSet();
+            Set wspNames = new HashSet();
             for (int i = 0; i < responses.length; i++) {
                 DavPropertySet props = responses[i].getProperties(DavServletResponse.SC_OK);
                 if (props.contains(DeltaVConstants.WORKSPACE)) {
                     HrefProperty hp = new HrefProperty(props.get(DeltaVConstants.WORKSPACE));
                     String wspHref = hp.getHrefs().get(0).toString();
-                    String id = Text.getName(wspHref, true);
-                    ids.add(id);
+                    String name = Text.unescape(Text.getName(wspHref, true));
+                    wspNames.add(name);
                 }
             }
-            return (String[]) ids.toArray(new String[ids.size()]);
+            return (String[]) wspNames.toArray(new String[wspNames.size()]);
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {



Mime
View raw message