incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r629058 - in /incubator/sling/trunk/jcr: api/src/main/java/org/apache/sling/jcr/api/ jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/ jackrabbit-client/src/main/resources/OSGI-INF/metatype/ jackrabbit-server/src/main/...
Date Tue, 19 Feb 2008 10:35:42 GMT
Author: bdelacretaz
Date: Tue Feb 19 02:35:38 2008
New Revision: 629058

URL: http://svn.apache.org/viewvc?rev=629058&view=rev
Log:
SLING-256 - Use null for the workspace name in JCR calls if configured name is empty

Modified:
    incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
    incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java
    incubator/sling/trunk/jcr/jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/SlingClientRepository.java
    incubator/sling/trunk/jcr/jackrabbit-client/src/main/resources/OSGI-INF/metatype/metatype.properties
    incubator/sling/trunk/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/SlingServerRepository.java
    incubator/sling/trunk/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties
    incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
    incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java

Modified: incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
(original)
+++ incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/AbstractSlingRepository.java
Tue Feb 19 02:35:38 2008
@@ -52,7 +52,7 @@
  * respective component and metatype definitions by the maven-sling-plugin:
  *
  * <pre>
- *  scr.property value=&quot;default&quot; name=&quot;defaultWorkspace&quot;
+ *  scr.property value=&quot;&quot; name=&quot;defaultWorkspace&quot;
  *  scr.property value=&quot;anonymous&quot; name=&quot;anonymous.name&quot;
  *  scr.property value=&quot;anonymous&quot; name=&quot;anonymous.password&quot;
  *  scr.property value=&quot;admin&quot; name=&quot;admin.name&quot;
@@ -167,8 +167,13 @@
 
     /**
      * @see org.apache.sling.jcr.api.SlingRepository#getDefaultWorkspace()
+     * Declared final to make sure the SLING-256 rule is enforced. 
      */
-    public String getDefaultWorkspace() {
+    public final String getDefaultWorkspace() {
+        if(defaultWorkspace == null || defaultWorkspace.trim().length() == 0) {
+            // SLING-256
+            return null;
+        }
         return this.defaultWorkspace;
     }
 
@@ -236,10 +241,13 @@
         }
 
         try {
+            getLog().log(LogService.LOG_DEBUG, 
+                    "Logging in to workspace '" + workspace + "'");
             return this.getPoolManager().login(credentials, workspace);
         } catch (NoSuchWorkspaceException nswe) {
             // if the desired workspace is the default workspace, try to create
-            if (workspace.equals(this.getDefaultWorkspace())
+            // (but not if using the repository-supplied default workspace)
+            if (workspace!=null && workspace.equals(this.getDefaultWorkspace())
                 && this.createWorkspace(workspace)) {
                 return this.getPoolManager().login(credentials, workspace);
             }

Modified: incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java
(original)
+++ incubator/sling/trunk/jcr/api/src/main/java/org/apache/sling/jcr/api/SlingRepository.java
Tue Feb 19 02:35:38 2008
@@ -39,6 +39,8 @@
 
     /**
      * Returns the default workspace to use on login.
+     * 
+     * @return null if the configured default workspace name is empty, SLING-256
      */
     String getDefaultWorkspace();
 

Modified: incubator/sling/trunk/jcr/jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/SlingClientRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/SlingClientRepository.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/SlingClientRepository.java
(original)
+++ incubator/sling/trunk/jcr/jackrabbit-client/src/main/java/org/apache/sling/jcr/jackrabbit/client/SlingClientRepository.java
Tue Feb 19 02:35:38 2008
@@ -42,7 +42,7 @@
  *
  * @scr.service
  *
- * @scr.property value="default" name="defaultWorkspace"
+ * @scr.property value="" name="defaultWorkspace"
  * @scr.property value="anonymous" name="anonymous.name"
  * @scr.property value="anonymous" name="anonymous.password"
  * @scr.property value="admin" name="admin.name"

Modified: incubator/sling/trunk/jcr/jackrabbit-client/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/jackrabbit-client/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/jackrabbit-client/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ incubator/sling/trunk/jcr/jackrabbit-client/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Feb 19 02:35:38 2008
@@ -52,7 +52,9 @@
 defaultWorkspace.name = Default Workspace
 defaultWorkspace.description = Name of the workspace to use by default if not \
  is given in any of the login methods. This name is used to implement the \
- SlingRepository.getDefaultWorkspace() method.
+ SlingRepository.getDefaultWorkspace() method. If this name is empty, a null \
+ value is used in JCR calls so that the default workspace provided by the \
+ JCR repository is used.
  
 home.name = Repository Home	
 home.description = Name of a filesystem directory in which to launch the \

Modified: incubator/sling/trunk/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/SlingServerRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/SlingServerRepository.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/SlingServerRepository.java
(original)
+++ incubator/sling/trunk/jcr/jackrabbit-server/src/main/java/org/apache/sling/jcr/jackrabbit/server/SlingServerRepository.java
Tue Feb 19 02:35:38 2008
@@ -49,7 +49,7 @@
  *
  * @scr.service
  *
- * @scr.property value="default" name="defaultWorkspace"
+ * @scr.property value="" name="defaultWorkspace"
  * @scr.property value="anonymous" name="anonymous.name"
  * @scr.property value="anonymous" name="anonymous.password"
  * @scr.property value="admin" name="admin.name"

Modified: incubator/sling/trunk/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ incubator/sling/trunk/jcr/jackrabbit-server/src/main/resources/OSGI-INF/metatype/metatype.properties
Tue Feb 19 02:35:38 2008
@@ -59,7 +59,9 @@
 defaultWorkspace.name = Default Workspace
 defaultWorkspace.description = Name of the workspace to use by default if not \
  is given in any of the login methods. This name is used to implement the \
- SlingRepository.getDefaultWorkspace() method.
+ SlingRepository.getDefaultWorkspace() method. If this name is empty, a null \
+ value is used in JCR calls so that the default workspace provided by the \
+ JCR repository is used.
  
 home.name = Repository Home	
 home.description = Name of a filesystem directory in which to launch the \

Modified: incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
(original)
+++ incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
Tue Feb 19 02:35:38 2008
@@ -488,8 +488,10 @@
         if (workspaceName == null) {
             workspaceName = getRepository().getDefaultWorkspace();
         }
-
+        
         synchronized (adminSessions) {
+            // HashMap allows null keys, so this should be ok even 
+            // with a null workspaceName
             Session adminSession = adminSessions.get(workspaceName);
             if (adminSession != null && adminSession.isLive()) {
                 return adminSession;

Modified: incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java?rev=629058&r1=629057&r2=629058&view=diff
==============================================================================
--- incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
(original)
+++ incubator/sling/trunk/jcr/webdav/src/main/java/org/apache/sling/jcr/webdav/SimpleWebDavServlet.java
Tue Feb 19 02:35:38 2008
@@ -69,15 +69,24 @@
     protected void service(HttpServletRequest request,
             HttpServletResponse response) throws ServletException, IOException {
         
-        // redirect to the default workspace if directly addressing the servlet
-        String pinfo = request.getPathInfo();
+        final String pinfo = request.getPathInfo();
+        
         if (pinfo == null || "/".equals(pinfo)) {
-            String uri = request.getRequestURI();
-            if (pinfo == null) {
-                uri += "/";
+            // redirect to the default workspace if directly addressing the servlet
+            // and if the default workspace name is not null (in which case we'd need
+            // to login to find out the actual workspace name, SLING-256)
+            if(repository.getDefaultWorkspace() == null) {
+                response.sendError(HttpServletResponse.SC_NOT_FOUND,
+                        "JCR workspace name required, please add it to the end of the URL"
+                        + " (for the Jackrabbit embedded repository the default name is 'default')
");
+            } else {
+                String uri = request.getRequestURI();
+                if (pinfo == null) {
+                    uri += "/";
+                }
+                uri += repository.getDefaultWorkspace();
+                response.sendRedirect(uri);
             }
-            uri += repository.getDefaultWorkspace();
-            response.sendRedirect(uri);
         }
         
         super.service(request, response);



Mime
View raw message