jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r159798 [1/2] - in incubator/jackrabbit/trunk/contrib/jcr-server: client/src/java/org/apache/jackrabbit/client/ server/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/server/simple/dav/ server/src/java/org/apache/jackrabbit/server/simple/dav/lock/ server/src/java/org/apache/jackrabbit/webdav/spi/ server/src/java/org/apache/jackrabbit/webdav/spi/property/ server/src/java/org/apache/jackrabbit/webdav/spi/version/ server/src/java/org/apache/jackrabbit/webdav/spi/version/report/ webapp/src/webapp/WEB-INF/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/property/ webdav/src/java/org/apache/jackrabbit/webdav/util/
Date Sat, 02 Apr 2005 19:27:06 GMT
Author: tripod
Date: Sat Apr  2 11:27:01 2005
New Revision: 159798

URL: http://svn.apache.org/viewcvs?view=rev&rev=159798
Log:
- comitting latest changes from angela
- adding configuration for authorization header behaviour

Modified:
    incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/RepositoryAccessServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/ResourceFactoryImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/JcrDavException.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionHistoryItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java
    incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/report/NodeTypesReport.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
    incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/util/Text.java

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/RepositoryAccessServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/RepositoryAccessServlet.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/RepositoryAccessServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/client/src/java/org/apache/jackrabbit/client/RepositoryAccessServlet.java Sat Apr  2 11:27:01 2005
@@ -54,6 +54,9 @@
     /** the 'rmi-uri' init parameter */
     public final static String INIT_PARAM_RMI_URI = "rmi-uri";
 
+    /** the 'missing-auth-mapping' init parameter */
+    public final static String INIT_PARAM_MISSING_AUTH_MAPPING = "missing-auth-mapping";
+
     /** Authorization header name */
     private static final String HEADER_AUTHORIZATION = "Authorization";
 
@@ -66,6 +69,8 @@
 
     private static Repository repository;
 
+    private static String missingAuthMapping;
+
     /**
      * Initializes this servlet
      *
@@ -77,6 +82,9 @@
 	initJNDI();
 	initRMI();
 	initRepository();
+        missingAuthMapping = getServletConfig().getInitParameter(INIT_PARAM_MISSING_AUTH_MAPPING);
+        log.info("  " + INIT_PARAM_MISSING_AUTH_MAPPING + " = " + missingAuthMapping);
+
 	log.info("RepositoryAccessServlet initialized.");
     }
 
@@ -205,18 +213,31 @@
     /**
      * Build a {@link Credentials} object for the given authorization header.
      * The creds may be used to login to the repository. If the specified header
-     * string is <code>null</code> or not of the required format, <code>null</code>
-     * is returned.
+     * string is <code>null</code> or not of the required format the behaviour
+     * depends on the {@link #INIT_PARAM_MISSING_AUTH_MAPPING} param:<br>
+     * <ul>
+     * <li> if this init-param is missing, a LoginException is thrown.
+     *      This is suiteable for clients (eg. webdav clients) for with
+     *      sending a proper authorization header is not possible, if the
+     *      server never send a 401.
+     * <li> if this init-param is present, but with an empty value,
+     *      null-credentials are returned, thus forcing an null login
+     *      on the repository
+     * <li> if this init-param has a 'user:password' value, the respective
+     *      simple credentials are generated.
+     * </ul>
      *
      * @param authHeader Authorization header as present in the Http request
      * @return credentials or <code>null</code>.
      * @throws ServletException If an IOException occured while decoding the
      * Authorization header.
+     * @throws LoginException if no suitable auth header and missing-auth-mapping
+     * is not present
      * @see #getRepository()
      * @see #login(HttpServletRequest)
      */
     public static Credentials getCredentialsFromHeader(String authHeader)
-	    throws ServletException {
+	    throws ServletException, LoginException {
 	try {
 	    if (authHeader != null) {
 		String[] authStr = authHeader.split(" ");
@@ -230,7 +251,22 @@
 		    return new SimpleCredentials(userid, passwd.toCharArray());
 		}
 	    }
-	    return null;
+            // check special handling
+            if (missingAuthMapping == null) {
+                throw new LoginException();
+            } else if (missingAuthMapping.equals("")) {
+                return null;
+            } else {
+                int pos = missingAuthMapping.indexOf(':');
+                if (pos<0) {
+                    return new SimpleCredentials(missingAuthMapping, null);
+                } else {
+                    return new SimpleCredentials(
+                            missingAuthMapping.substring(0, pos),
+                            missingAuthMapping.substring(pos+1).toCharArray()
+                    );
+                }
+            }
 	} catch (IOException e) {
 	    throw new ServletException("Unable to decode authorization: " + e.toString());
 	}
@@ -248,14 +284,18 @@
      * @param request
      * @return  Session object obtained upon {@link Repository#login(javax.jcr.Credentials)}.
      * @throws ServletException
+     * @throws LoginException if credentials are invalid
      * @see #getRepository() in order to be able to login to a specific workspace.
      * @see #getCredentialsFromHeader(String) for a utility method to retrieve
      * credentials from the Authorization header string.
      */
-    public static Session login(HttpServletRequest request) throws ServletException {
+    public static Session login(HttpServletRequest request)
+            throws LoginException, ServletException {
         String authHeader = request.getHeader(HEADER_AUTHORIZATION);
 	try {
 	    return repository.login(getCredentialsFromHeader(authHeader));
+        } catch (LoginException e) {
+            throw e;
 	} catch (RepositoryException e) {
 	    throw new ServletException("Failed to login to the repository: " + e.toString());
 	}

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/project.xml Sat Apr  2 11:27:01 2005
@@ -42,7 +42,6 @@
                 <war.bundle>true</war.bundle>
             </properties>
         </dependency>
-
         <dependency>
             <groupId>jsr170</groupId>
             <artifactId>jcr</artifactId>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/AbstractWebdavServlet.java Sat Apr  2 11:27:01 2005
@@ -400,7 +400,8 @@
      * @param request
      * @return status code indicating whether the destination is valid.
      */
-    private int validateDestination(DavResource destResource, WebdavRequest request) {
+    private int validateDestination(DavResource destResource, WebdavRequest request)
+        throws DavException {
 
         String destHeader = request.getHeader(HEADER_DESTINATION);
         if (destHeader == null || "".equals(destHeader)){
@@ -417,8 +418,8 @@
                 if (!request.matchesIfHeader(destResource)) {
                     return DavServletResponse.SC_PRECONDITION_FAILED;
                 } else {
-                    // overwrite existing resource: its up to the webdavresource
-                    // object to deal with any delete prior to the copy/move
+                    // overwrite existing resource
+                    destResource.getCollection().removeMember(destResource);                    
                     status = DavServletResponse.SC_NO_CONTENT;
                 }
             } else {
@@ -450,6 +451,7 @@
             ActiveLock[] activeLocks = resource.getLocks();
             List lList = new ArrayList();
             for (int i = 0; i < activeLocks.length; i++) {
+                // todo: do not ignore etag
                 if (request.matchesIfHeader(resource.getHref(), activeLocks[i].getToken(), "")) {
                     lList.add(resource.refreshLock(lockInfo, activeLocks[i].getToken()));
                 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/JCRWebdavServer.java Sat Apr  2 11:27:01 2005
@@ -100,8 +100,11 @@
                 String workspaceName = request.getRequestLocator().getWorkspaceName();
 		Credentials creds = RepositoryAccessServlet.getCredentialsFromHeader(request.getHeader(DavConstants.HEADER_AUTHORIZATION));
                 session = repository.login(creds, workspaceName);
+            } catch (LoginException e) {
+                // LoginException results in UNAUTHORIZED,
+                throw new JcrDavException(e);
             } catch (RepositoryException e) {
-                // LoginException, RepositoryException both result in FORBIDDEN
+                // RepositoryException results in FORBIDDEN
                 throw new JcrDavException(e);
             } catch (ServletException e) {
 		throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/WebdavServlet.java Sat Apr  2 11:27:01 2005
@@ -159,6 +159,10 @@
 	    getDavSessionProvider().releaseSession(webdavRequest);
 
 	} catch (DavException e) {
+            // special handling for unauthorized, should be done nicer
+            if (e.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) {
+                response.setHeader("WWW-Authenticate", "Basic Realm=Jackrabbit");
+            }
 	    response.sendError(e.getErrorCode());
 	}
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavResourceImpl.java Sat Apr  2 11:27:01 2005
@@ -51,14 +51,16 @@
      * @param factory
      * @param session
      */
-    public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session) {
+    public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory,
+                           DavSession session)
+        throws RepositoryException {
         this.session = session;
         this.factory = factory;
         this.locator = locator;
         if (locator != null && locator.getResourcePath() != null) {
             try {
                 init(session.getRepositorySession().getItem(locator.getResourcePath()));
-            } catch (RepositoryException e) {
+            } catch (PathNotFoundException e) {
                 // ignore: exists field evaluates to false
             }
         }
@@ -299,6 +301,8 @@
     }
 
     /**
+     * Adds a new non-collection member to this resource.
+     *
      * @see DavResource#addMember(DavResource, InputStream)
      */
     public void addMember(DavResource member, InputStream in) throws DavException {
@@ -333,9 +337,6 @@
 		importFile(file, in, "application/octet-stream");
 	    }
             session.getRepositorySession().save();
-        } catch (ItemExistsException e) {
-            // according to RFC 2518: MKCOL only possible on non-existing/deleted resource
-            throw new JcrDavException(e, DavServletResponse.SC_METHOD_NOT_ALLOWED);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         } catch (IOException e) {
@@ -345,6 +346,7 @@
 
     /**
      * Imports a xml into the repository
+     *
      * @param parentNode
      * @param in
      * @param contentType
@@ -361,6 +363,7 @@
 
     /**
      * Imports a plain file to the repository
+     *
      * @param parentNode
      * @param in
      * @param contentType
@@ -376,6 +379,8 @@
     }
 
     /**
+     * Creates a new collection as member of this resource.
+     *
      * @see DavResource#addMember(DavResource)
      */
     public void addMember(DavResource member) throws DavException {
@@ -388,6 +393,8 @@
         try {
             node.addNode(member.getDisplayName(), "nt:folder");
             node.save();
+        } catch (ItemExistsException e) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -550,23 +557,21 @@
             throw new DavException(DavServletResponse.SC_NOT_FOUND);
         }
         /* since lock is always has infinite timeout >> no extra refresh needed
-        return a lockdiscovery with the lock-info and the default scope and type */
-        ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope());
+           return a lockdiscovery with the lock-info and the default scope and type */
+        ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE);
         if (lock == null) {
            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock present on resource " + getResourcePath());
-        } else if (lock.isLockedByToken(lockToken)) {
-            if (lock instanceof JcrActiveLock) {
-                try {
-                    // refresh JCR lock and return the original lock object.
-                    node.getLock().refresh();
-                } catch (RepositoryException e) {
-                    throw new JcrDavException(e);
-                }
-            } else {
-                lock = lockManager.refreshLock(lockInfo, lockToken, this);
+        }
+        
+        if (lock instanceof JcrActiveLock) {
+            try {
+                // refresh JCR lock and return the original lock object.
+                node.getLock().refresh();
+            } catch (RepositoryException e) {
+                throw new JcrDavException(e);
             }
         } else {
-            throw new DavException(DavServletResponse.SC_LOCKED);
+            lock = lockManager.refreshLock(lockInfo, lockToken, this);
         }
         return lock;
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/DavSessionProviderImpl.java Sat Apr  2 11:27:01 2005
@@ -34,25 +34,26 @@
      * Acquires a DavSession. Upon success, the WebdavRequest will
      * reference that session.
      *
-     * A session will not be available if credentials can not be found
-     * in the request (meaning that the  request has not been
-     * authenticated).
+     * A session will not be available if an exception is thrown.
      *
      * @param request
-     * @throws DavException if a problem occurred while obtaining the
-     * session
+     * @throws DavException if a problem occurred while obtaining the session
      * @see DavSessionProvider#acquireSession(org.apache.jackrabbit.webdav.WebdavRequest)
      */
     public void acquireSession(WebdavRequest request) throws DavException {
         try {
-            Credentials creds = RepositoryAccessServlet.getCredentialsFromHeader(request.getHeader(DavConstants.HEADER_AUTHORIZATION));
-            if (creds == null) {
-                // generate anonymous login to gain write access
-                creds = new SimpleCredentials("anonymous", "anonymous".toCharArray());
-            }
+            // extract credentials from the auth header. depending of the
+            // configuration of the RepositoryAccessServlet, this could also
+            // throw a login excetpion.
+            Credentials creds = RepositoryAccessServlet.getCredentialsFromHeader(
+                    request.getHeader(DavConstants.HEADER_AUTHORIZATION));
+
+            // login to repository
             Session repSession = RepositoryAccessServlet.getRepository().login(creds);
             DavSession ds = new DavSessionImpl(repSession);
             request.setDavSession(ds);
+        } catch (LoginException e) {
+	    throw new JcrDavException(e);
         } catch (RepositoryException e) {
 	    throw new JcrDavException(e);
 	} catch (ServletException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/ResourceFactoryImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/ResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/ResourceFactoryImpl.java Sat Apr  2 11:27:01 2005
@@ -17,8 +17,11 @@
 package org.apache.jackrabbit.server.simple.dav;
 
 import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.spi.JcrDavException;
 import org.apache.jackrabbit.webdav.lock.LockManager;
 
+import javax.jcr.RepositoryException;
+
 /**
  * ResourceFactoryImpl implements a simple DavResourceFactory
  */
@@ -36,8 +39,12 @@
     }
 
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
-        DavResource res = new DavResourceImpl(locator, this, session);
-        res.addLockManager(lockMgr);
-        return res;
+        try {
+            DavResource res = new DavResourceImpl(locator, this, session);
+            res.addLockManager(lockMgr);
+            return res;
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
     }
 }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/server/simple/dav/lock/SimpleLockManager.java Sat Apr  2 11:27:01 2005
@@ -115,7 +115,7 @@
 		}
 	    } else if (Text.isDescendant(resourcePath, key)) {
 		if (lockInfo.isDeep() || isInternalMember(resource, key)) {
-		    throw new DavException(DavServletResponse.SC_LOCKED, "Resource '" + resource.getResourcePath() + "' cannot be locked due to a lock present on a member resource '" + key + "'.");
+		    throw new DavException(DavServletResponse.SC_CONFLICT, "Resource '" + resource.getResourcePath() + "' cannot be locked due to a lock present on the member resource '" + key + "'.");
 		}
 
 	    }
@@ -140,7 +140,7 @@
     public ActiveLock refreshLock(LockInfo lockInfo, String lockToken, DavResource resource)
 	    throws DavException {
 	// timeout is always infinite > no test for expiration or adjusting timeout needed.
-	ActiveLock lock = (ActiveLock)locks.get(resource.getResourcePath());
+	ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE, resource);
 	if (lock == null) {
 	    throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
 	} else if (!lock.getToken().equals(lockToken)) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/AbstractItemResource.java Sat Apr  2 11:27:01 2005
@@ -49,18 +49,9 @@
      * @param locator
      * @param session
      */
-    AbstractItemResource(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
+    AbstractItemResource(DavResourceLocator locator, DavSession session, DavResourceFactory factory, Item item) {
         super(locator, session, factory);
-        Item repositoryItem = null;
-        if (locator != null) {
-            try {
-                repositoryItem = getRepositorySession().getItem(locator.getResourcePath());
-            } catch (RepositoryException e) {
-                // ignore: exists field evaluates to false
-                log.info(e.getMessage());
-            }
-        }
-        item = repositoryItem;
+        this.item = item;
     }
 
     //----------------------------------------------< DavResource interface >---

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DavResourceFactoryImpl.java Sat Apr  2 11:27:01 2005
@@ -72,51 +72,45 @@
                                       DavServletRequest request,
                                       DavServletResponse response) throws DavException {
 
-        DavResource resource = null;
         DavSession session = request.getDavSession();
 
+        DavResource resource;
         if (locator.isRootLocation()) {
             resource = new RootCollection(locator, session, this);
-        }
-
-        if (resource == null) {
+        } else {
             try {
                 resource = createResourceForItem(locator, session);
-            } catch (RepositoryException e) {
-                // create the default resources if no such item exists
-
-                // MKCOL request forces a collection-resource even if there already
-                // exists a repository-property with the given path. the MKCOL will
-                // in that particular case fail with a 405 (method not allowed).
-                if (DavMethods.getMethodCode(request.getMethod()) == DavMethods.DAV_MKCOL) {
-                    resource = new VersionControlledItemCollection(locator, session, this);
-                } else {
-                    resource = new DefaultItemResource(locator, session, this);
-                }
-            }
 
-            // if the created resource is version-controlled and the request
-            // contains a Label header, the corresponding Version must be used
-            // instead.
-            if (request instanceof DeltaVServletRequest && isVersionControlled(resource)) {
-                String labelHeader = ((DeltaVServletRequest)request).getLabel();
-                if (labelHeader != null && DavMethods.isMethodAffectedByLabel(request.getMethod())) {
-                    try {
+                /* if the created resource is version-controlled and the request
+                contains a Label header, the corresponding Version must be used
+                instead.*/
+                if (request instanceof DeltaVServletRequest && isVersionControlled(resource)) {
+                    String labelHeader = ((DeltaVServletRequest)request).getLabel();
+                    if (labelHeader != null && DavMethods.isMethodAffectedByLabel(request.getMethod())) {
                         Item item = session.getRepositorySession().getItem(locator.getResourcePath());
                         Version v = ((Node)item).getVersionHistory().getVersionByLabel(labelHeader);
                         DavResourceLocator vloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), v.getPath());
-                        resource =  new VersionItemCollection(vloc, session, this);
-                    } catch (RepositoryException e) {
-                        log.error("Failed to build version resource from "+locator.getHref(true)+" and label "+labelHeader);
-                        throw new JcrDavException(e);
+                        resource =  new VersionItemCollection(vloc, session, this, v);
                     }
                 }
+            } catch (PathNotFoundException e) {
+                /* item does not exist yet: create the default resources
+                Note: MKCOL request forces a collection-resource even if there already
+                exists a repository-property with the given path. the MKCOL will
+                in that particular case fail with a 405 (method not allowed).*/
+                if (DavMethods.getMethodCode(request.getMethod()) == DavMethods.DAV_MKCOL) {
+                    resource = new VersionControlledItemCollection(locator, session, this, null);
+                } else {
+                    resource = new DefaultItemResource(locator, session, this, null);
+                }
+            } catch (RepositoryException e) {
+                log.error("Failed to build resource from item '"+ locator.getResourcePath() + "'");
+                throw new JcrDavException(e);
             }
         }
 
         ((TransactionResource)resource).init(txMgr, ((TransactionDavServletRequest)request).getTransactionId());
         ((ObservationResource)resource).init(subsMgr);
-
         return resource;
     }
 
@@ -140,13 +134,13 @@
                 resource =  new RootCollection(locator, session, this);
             } else {
 		// todo: is this correct?
-		resource = new VersionControlledItemCollection(locator, session, this);
+		resource = new VersionControlledItemCollection(locator, session, this, null);
             }
         }
 
+        // todo: currently transactionId is set manually after creation > to be improved.
         resource.addLockManager(txMgr);
         ((ObservationResource)resource).init(subsMgr);
-
         return resource;
     }
 
@@ -167,16 +161,16 @@
         if (item.isNode()) {
             // create special resources for Version and VersionHistory
             if (item instanceof Version) {
-                resource = new VersionItemCollection(locator, session, this);
+                resource = new VersionItemCollection(locator, session, this, item);
             } else if (item instanceof VersionHistory) {
-                resource = new VersionHistoryItemCollection(locator, session, this);
+                resource = new VersionHistoryItemCollection(locator, session, this, item);
             } else if (ItemResourceConstants.ROOT_ITEM_PATH.equals(locator.getResourcePath())) {
-                resource =  new RootItemCollection(locator, session, this);
+                resource =  new RootItemCollection(locator, session, this, item);
             }  else{
-                resource = new VersionControlledItemCollection(locator, session, this);
+                resource = new VersionControlledItemCollection(locator, session, this, item);
             }
         } else {
-            resource = new DefaultItemResource(locator, session, this);
+            resource = new DefaultItemResource(locator, session, this, item);
         }
         return resource;
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemCollection.java Sat Apr  2 11:27:01 2005
@@ -47,8 +47,9 @@
      * @param locator
      * @param session
      */
-    protected DefaultItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    protected DefaultItemCollection(DavResourceLocator locator, DavSession session,
+                                    DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
         if (exists() && !(item instanceof Node)) {
             throw new IllegalArgumentException("A collection resource can not be constructed from a Property item.");
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/DefaultItemResource.java Sat Apr  2 11:27:01 2005
@@ -45,8 +45,9 @@
      * @param locator
      * @param session
      */
-    public DefaultItemResource(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    public DefaultItemResource(DavResourceLocator locator, DavSession session,
+                               DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
     }
 
     //----------------------------------------------< DavResource interface >---
@@ -108,7 +109,8 @@
             Property prop = (Property) item;
             int type = prop.getType();
             if (property.getName().equals(JCR_VALUE)) {
-                Value val = ValueHelper.convert(String.valueOf(property.getValue()), type);
+                String strVal = (property.getValue() != null) ? String.valueOf(property.getValue()) : "";
+                Value val = ValueHelper.deserialize(strVal, type, false);
                 prop.setValue(val);
             } else if (property.getName().equals(JCR_VALUES)) {
                 prop.setValue(new ValuesProperty(property).getValues(prop.getType()));
@@ -223,7 +225,7 @@
                     properties.add(new ValuesProperty(prop.getValues()));
                     properties.add(new LengthsProperty(prop.getLengths()));
                 } else {
-                    properties.add(new DefaultDavProperty(JCR_VALUE, prop.getString()));
+                    properties.add(new DefaultDavProperty(JCR_VALUE, ValueHelper.serialize(prop.getValue(), false)));
                     properties.add(new DefaultDavProperty(JCR_LENGTH, String.valueOf(prop.getLength())));
                 }
             } catch (RepositoryException e) {

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/JcrDavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/JcrDavException.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/JcrDavException.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/JcrDavException.java Sat Apr  2 11:27:01 2005
@@ -101,6 +101,10 @@
         this(e, DavServletResponse.SC_FORBIDDEN);
     }
 
+    public JcrDavException(LoginException e) {
+        this(e, DavServletResponse.SC_UNAUTHORIZED);
+    }
+
     public JcrDavException(UnsupportedRepositoryOperationException e) {
         this(e, DavServletResponse.SC_NOT_IMPLEMENTED);
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/RootItemCollection.java Sat Apr  2 11:27:01 2005
@@ -23,6 +23,7 @@
 
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.RepositoryException;
+import javax.jcr.Item;
 
 /**
  * <code>RootItemCollection</code> represents the root node of the underlaying
@@ -41,8 +42,9 @@
      * @param locator
      * @param session
      */
-    protected RootItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    protected RootItemCollection(DavResourceLocator locator, DavSession session,
+                                 DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
     }
 
     //----------------------------------------------< DavResource interface >---

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/VersionControlledItemCollection.java Sat Apr  2 11:27:01 2005
@@ -45,8 +45,10 @@
      * @param locator
      * @param session
      */
-    public VersionControlledItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    public VersionControlledItemCollection(DavResourceLocator locator,
+                                           DavSession session, DavResourceFactory factory,
+                                           Item item) {
+        super(locator, session, factory, item);
         if (exists() && !(item instanceof Node)) {
             throw new IllegalArgumentException("A collection resource can not be constructed from a Property item.");
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/property/ValuesProperty.java Sat Apr  2 11:27:01 2005
@@ -60,7 +60,7 @@
 		* comment etc.) is ignored. NO bad-request/conflict error is
 		* thrown.
 		*/
-		if (el instanceof Element && "value".equals(((Element)el).getName())) {
+		if (el instanceof Element && XML_VALUE.equals(((Element)el).getName())) {
 		    valueElements.add(el);
 		}
 	    }
@@ -85,7 +85,7 @@
 	Element[] propValue = new Element[values.length];
 	for (int i = 0; i < values.length; i++) {
 	    propValue[i] = new Element(XML_VALUE, ItemResourceConstants.NAMESPACE);
-	    propValue[i].addContent(values[i].getString());
+	    propValue[i].addContent(ValueHelper.serialize(values[i], false));
 	}
 	// finally set the value to the DavProperty
 	value = propValue;
@@ -103,7 +103,7 @@
 	Element[] propValue = (Element[])getValue();
 	Value[] values = new Value[propValue.length];
 	for (int i = 0; i < propValue.length; i++) {
-	    values[i] = ValueHelper.convert(propValue[i].getText(), propertyType);
+	    values[i] = ValueHelper.deserialize(propValue[i].getText(), propertyType, false);
 	}
 	return values;
     }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionControlledItemCollection.java Sat Apr  2 11:27:01 2005
@@ -47,8 +47,9 @@
      * @param locator
      * @param session
      */
-    public VersionControlledItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    public VersionControlledItemCollection(DavResourceLocator locator, DavSession session,
+                                           DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
         if (exists() && !(item instanceof Node)) {
             throw new IllegalArgumentException("A collection resource can not be constructed from a Property item.");
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionHistoryItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionHistoryItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionHistoryItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionHistoryItemCollection.java Sat Apr  2 11:27:01 2005
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.webdav.*;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Item;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
 import java.util.ArrayList;
@@ -45,8 +46,10 @@
      * @param session
      * @param factory
      */
-    public VersionHistoryItemCollection(DavResourceLocator resourcePath, DavSession session, DavResourceFactory factory) {
-        super(resourcePath, session, factory);
+    public VersionHistoryItemCollection(DavResourceLocator resourcePath,
+                                        DavSession session, DavResourceFactory factory,
+                                        Item item) {
+        super(resourcePath, session, factory, item);
         if (item == null || !(item instanceof VersionHistory)) {
             throw new IllegalArgumentException("VersionHistory item expected.");
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/VersionItemCollection.java Sat Apr  2 11:27:01 2005
@@ -48,8 +48,8 @@
      * @param session
      * @param factory
      */
-    public VersionItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
-        super(locator, session, factory);
+    public VersionItemCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
         if (item == null || !(item instanceof Version)) {
             throw new IllegalArgumentException("Version item expected.");
         }

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/report/NodeTypesReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/report/NodeTypesReport.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/report/NodeTypesReport.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/spi/version/report/NodeTypesReport.java Sat Apr  2 11:27:01 2005
@@ -28,6 +28,7 @@
 import org.apache.jackrabbit.core.util.IteratorHelper;
 import org.jdom.Document;
 import org.jdom.Element;
+import org.jdom.Namespace;
 
 import javax.jcr.nodetype.*;
 import javax.jcr.*;
@@ -60,7 +61,7 @@
      */
     public static final ReportType NODETYPES_REPORT = ReportType.register("nodetypes", NodeTypeConstants.NAMESPACE, NodeTypesReport.class);
 
-    private NodeTypeManager ntMgr;
+    private Session session;
     private ReportInfo info;
 
     /**
@@ -82,15 +83,11 @@
         if (resource == null) {
             throw new IllegalArgumentException("Resource must not be null.");
         }
-        try {
-            DavSession session = resource.getSession();
-            if (session == null || session.getRepositorySession() == null) {
-                throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the jcr:nodetypes report.");
-            }
-            ntMgr = session.getRepositorySession().getWorkspace().getNodeTypeManager();
-        } catch (RepositoryException e) {
-            log.error(e.getMessage());
+        DavSession session = resource.getSession();
+        if (session == null || session.getRepositorySession() == null) {
+            throw new IllegalArgumentException("The resource must provide a non-null session object in order to create the jcr:nodetypes report.");
         }
+        this.session = session.getRepositorySession();
     }
 
     /**
@@ -116,11 +113,19 @@
      * @see org.apache.jackrabbit.webdav.version.report.Report#toXml()
      */
     public Document toXml() throws DavException {
-        if (info == null || ntMgr == null) {
+        if (info == null || session == null) {
             throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running jcr:nodetypes report");
         }
         try {
             Element report = new Element(XML_NODETYPES);
+            // make sure all namespace declarations are present on the root element.
+            // since the nodetype-manager uses session-local jcr names, prefix/namespace
+            // pairs are retrieved from the session and not from the namespace registry.
+            String[] prefixes = session.getNamespacePrefixes();
+            for (int i = 0; i < prefixes.length; i++) {
+                report.addNamespaceDeclaration(Namespace.getNamespace(prefixes[i], session.getNamespaceURI(prefixes[i])));
+            }
+            // retrieve the requested nodetypes
             NodeTypeIterator ntIter = getNodeTypes();
             while (ntIter.hasNext()) {
                 NodeType nt = ntIter.nextNodeType();
@@ -177,6 +182,7 @@
      */
     private NodeTypeIterator getNodeTypes() throws RepositoryException, DavException {
         NodeTypeIterator ntIter = null;
+        NodeTypeManager ntMgr = session.getWorkspace().getNodeTypeManager();
         Iterator it = info.getReportElement().getChildren().iterator();
         while (it.hasNext() && ntIter == null) {
             Element elem = (Element) it.next();

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webapp/src/webapp/WEB-INF/web.xml Sat Apr  2 11:27:01 2005
@@ -8,62 +8,62 @@
     <!-- R E P O S I T O R Y   S T A R T U P  S E R V L E T                     -->
     <!-- ====================================================================== -->
     <servlet>
-	<servlet-name>RepositoryStartup</servlet-name>
+        <servlet-name>RepositoryStartup</servlet-name>
         <description>
-	    Repository servlet that starts the repository and registers it to JNDI ans RMI.
-	    If you already have the repository registered in this appservers JNDI context,
-	    or if its accessible via RMI, you do not need to use this servlet.
-	</description>
-	<servlet-class>org.apache.jackrabbit.server.RepositoryStartupServlet</servlet-class>
-
-	<init-param>
-	    <param-name>log4j-config</param-name>
-	    <param-value>/WEB-INF/repository/log4j.properties</param-value>
+            Repository servlet that starts the repository and registers it to JNDI ans RMI.
+            If you already have the repository registered in this appservers JNDI context,
+            or if its accessible via RMI, you do not need to use this servlet.
+        </description>
+        <servlet-class>org.apache.jackrabbit.server.RepositoryStartupServlet</servlet-class>
+
+        <init-param>
+            <param-name>log4j-config</param-name>
+            <param-value>/WEB-INF/repository/log4j.properties</param-value>
             <description>initial log4j configuration</description>
-	</init-param>
+        </init-param>
 
-	<init-param>
-	    <param-name>repository-config</param-name>
-	    <param-value>/WEB-INF/repository/repository.xml</param-value>
+        <init-param>
+            <param-name>repository-config</param-name>
+            <param-value>/WEB-INF/repository/repository.xml</param-value>
             <description>the repository config location</description>
-	</init-param>
+        </init-param>
 
-	<init-param>
-	    <param-name>repository-home</param-name>
-	    <param-value>jackrabbit/repository</param-value>
+        <init-param>
+            <param-name>repository-home</param-name>
+            <param-value>jackrabbit/repository</param-value>
             <description>the repository home</description>
-	</init-param>
+        </init-param>
 
-	<init-param>
-	    <param-name>repository-name</param-name>
-	    <param-value>jackrabbit.repository</param-value>
+        <init-param>
+            <param-name>repository-name</param-name>
+            <param-value>jackrabbit.repository</param-value>
             <description>Repository Name under which the repository is registered via JNDI/RMI</description>
-	</init-param>
+        </init-param>
 
-	<init-param>
-	    <param-name>rmi-port</param-name>
-	    <param-value>0</param-value>
+        <init-param>
+            <param-name>rmi-port</param-name>
+            <param-value>0</param-value>
             <description>
                 The RMI port for registering the repository in the RMI Registry.
                 If equals 0, the default port is used. Omit this parameter, to
                 disable RMI server completely.
             </description>
-	</init-param>
+        </init-param>
 
-	<!--
-	    JNDI environment variables for creating the initial context
-	    (all init parameters starting with java.naming.* will be added to the initial context environment).
+        <!--
+            JNDI environment variables for creating the initial context
+            (all init parameters starting with java.naming.* will be added to the initial context environment).
         -->
-	<init-param>
-	    <param-name>java.naming.provider.url</param-name>
-	    <param-value>http://www.apache.org/jackrabbit</param-value>
-	</init-param>
-	<init-param>
-	    <param-name>java.naming.factory.initial</param-name>
-	    <param-value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</param-value>
-	</init-param>
+        <init-param>
+            <param-name>java.naming.provider.url</param-name>
+            <param-value>http://www.apache.org/jackrabbit</param-value>
+        </init-param>
+        <init-param>
+            <param-name>java.naming.factory.initial</param-name>
+            <param-value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</param-value>
+        </init-param>
 
-	<load-on-startup>1</load-on-startup>
+        <load-on-startup>1</load-on-startup>
     </servlet>
 
 
@@ -71,99 +71,118 @@
     <!-- R E P O S I T O R Y   S E R V L E T                                    -->
     <!-- ====================================================================== -->
     <servlet>
-	<servlet-name>Repository</servlet-name>
+        <servlet-name>Repository</servlet-name>
         <description>
-	    This servlet provides other servlets and jsps a common way to access
-	    the repository. The repository can be accessed via JNDI, RMI or Webdav.
-	</description>
-	<servlet-class>org.apache.jackrabbit.client.RepositoryAccessServlet</servlet-class>
-
-	<init-param>
-	    <param-name>log4j-config</param-name>
-	    <param-value>/WEB-INF/repository/log4j.properties</param-value>
-	    <description>initial log4j configuration</description>
-	</init-param>
-
-	<init-param>
-	    <param-name>repository-name</param-name>
-	    <param-value>jackrabbit.repository</param-value>
-	    <description>Repository Name that is used to retrieve it via JNDI</description>
-	</init-param>
-
-	<!--
-	    JNDI environment variables for creating the initial context
-	    (all init parameters starting with java.naming.* will be added to the initial context environment).
+            This servlet provides other servlets and jsps a common way to access
+            the repository. The repository can be accessed via JNDI, RMI or Webdav.
+        </description>
+        <servlet-class>org.apache.jackrabbit.client.RepositoryAccessServlet</servlet-class>
+
+        <init-param>
+            <param-name>log4j-config</param-name>
+            <param-value>/WEB-INF/repository/log4j.properties</param-value>
+            <description>initial log4j configuration</description>
+        </init-param>
+
+        <init-param>
+            <param-name>repository-name</param-name>
+            <param-value>jackrabbit.repository</param-value>
+            <description>Repository Name that is used to retrieve it via JNDI</description>
+        </init-param>
+
+        <!--
+        <init-param>
+            <param-name>missing-auth-mapping</param-name>
+            <param-value>anonymous:anonymous</param-value>
+            <description>
+                Defines how a missing authorization header should be handled.
+                1) if this init-param is missing, a 401 response is generated.
+                   This is suiteable for clients (eg. webdav clients) for which
+                   sending a proper authorization header is not possible, if the
+                   server never sended a 401.
+                2) if this init-param is present, but with an empty value,
+                   null-credentials are returned, thus forcing an null login
+                   on the repository
+                3) if this init-param has a 'user:password' value, the respective
+                   simple credentials are generated.
+            </description>
+        </init-param>
+        -->
+
+        <!--
+            JNDI environment variables for creating the initial context
+            (all init parameters starting with java.naming.* will be added to the initial context environment).
+        -->
+        <init-param>
+            <param-name>java.naming.provider.url</param-name>
+            <param-value>http://www.apache.org/jackrabbit</param-value>
+        </init-param>
+        <init-param>
+            <param-name>java.naming.factory.initial</param-name>
+            <param-value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</param-value>
+        </init-param>
+
+        <!--
+            RMI url, if RMI remoting is needed
         -->
-	<init-param>
-	    <param-name>java.naming.provider.url</param-name>
-	    <param-value>http://www.apache.org/jackrabbit</param-value>
-	</init-param>
-	<init-param>
-	    <param-name>java.naming.factory.initial</param-name>
-	    <param-value>org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory</param-value>
-	</init-param>
-
-	<!--
-	    RMI url, if RMI remoting is needed
-	-->
-	<init-param>
-	    <param-name>rmi-uri</param-name>
-	    <param-value>///jackrabbit.repository</param-value>
+        <init-param>
+            <param-name>rmi-uri</param-name>
+            <param-value>///jackrabbit.repository</param-value>
             <description>The URI for the RMI connection.</description>
-	</init-param>
+        </init-param>
 
-	<load-on-startup>2</load-on-startup>
+        <load-on-startup>2</load-on-startup>
     </servlet>
 
     <!-- ====================================================================== -->
     <!-- W E B D A V  S E R V L E T                                              -->
     <!-- ====================================================================== -->
     <servlet>
-	<servlet-name>Webdav</servlet-name>
+        <servlet-name>Webdav</servlet-name>
         <description>
             The webdav servlet that connects HTTP request to the repository.
         </description>
         <servlet-class>org.apache.jackrabbit.server.simple.WebdavServlet</servlet-class>
 
-	<init-param>
+        <init-param>
             <param-name>resource-path-prefix</param-name>
             <param-value>/repository</param-value>
             <description>
-	    	defines the prefix for spooling resources out of the repository.
+                defines the prefix for spooling resources out of the repository.
             </description>
-	</init-param>
-	<load-on-startup>3</load-on-startup>
+        </init-param>
+        <load-on-startup>3</load-on-startup>
     </servlet>
 
     <!-- ====================================================================== -->
     <!-- W E B D A V  S E R V E R  S E R V L E T                                  -->
     <!-- ====================================================================== -->
     <servlet>
-	<servlet-name>JCRWebdavServer</servlet-name>
+        <servlet-name>JCRWebdavServer</servlet-name>
         <description>
             The webdav servlet that connects HTTP request to the repository.
         </description>
         <servlet-class>org.apache.jackrabbit.server.JCRWebdavServerServlet</servlet-class>
 
-	<init-param>
+        <init-param>
             <param-name>resource-path-prefix</param-name>
             <param-value>/server</param-value>
             <description>
-	    	defines the prefix for spooling resources out of the repository.
+                defines the prefix for spooling resources out of the repository.
             </description>
-	</init-param>
-	<load-on-startup>4</load-on-startup>
+        </init-param>
+        <load-on-startup>4</load-on-startup>
     </servlet>
 
     <!-- ====================================================================== -->
     <!-- S E R V L E T   M A P P I N G                                          -->
     <!-- ====================================================================== -->
     <servlet-mapping>
-	<servlet-name>Webdav</servlet-name>
-	<url-pattern>/repository/*</url-pattern>
+        <servlet-name>Webdav</servlet-name>
+        <url-pattern>/repository/*</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
-	<servlet-name>JCRWebdavServer</servlet-name>
-	<url-pattern>/server/*</url-pattern>
+        <servlet-name>JCRWebdavServer</servlet-name>
+        <url-pattern>/server/*</url-pattern>
     </servlet-mapping>
 </web-app>

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSessionProvider.java Sat Apr  2 11:27:01 2005
@@ -29,13 +29,10 @@
      * Acquires a DavSession. Upon success, the WebdavRequest will
      * reference that session.
      *
-     * A session will not be available if credentials can not be found
-     * in the request (meaning that the  request has not been
-     * authenticated).
+     * A session will not be available if an exception is thrown.
      *
      * @param request
-     * @throws DavException if a problem occurred while obtaining the
-     * session
+     * @throws DavException if a problem occurred while obtaining the session
      */
     public void acquireSession(WebdavRequest request) throws DavException;
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java Sat Apr  2 11:27:01 2005
@@ -466,7 +466,7 @@
         boolean isMatching = false;
         String lockToken = resource.getLock(Type.WRITE, Scope.EXCLUSIVE).getToken();
         if (lockToken != null) {
-            // TODO: strongETag is missing
+            // todo: do not ignore etag
             isMatching = matchesIfHeader(resource.getHref(), lockToken, "");
         } // else: lockToken is null >> the if-header will not match.
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java Sat Apr  2 11:27:01 2005
@@ -61,11 +61,17 @@
      * @see DavServletResponse#sendErrorResponse(org.apache.jackrabbit.webdav.DavException)
      */
     public void sendErrorResponse(DavException exception) throws IOException {
-        Element errorElem = exception.getError();
-        if (errorElem == null || errorElem.getChildren().size() == 0) {
+        // special handling for unauthorized, should be done nicer
+        if (exception.getErrorCode() == HttpServletResponse.SC_UNAUTHORIZED) {
+            httpResponse.setHeader("WWW-Authenticate", "Basic Realm=Jackrabbit Webdav Server");
             httpResponse.sendError(exception.getErrorCode(), exception.getStatusPhrase());
         } else {
-            sendXmlResponse(new Document(exception.getError()), exception.getErrorCode());
+            Element errorElem = exception.getError();
+            if (errorElem == null || errorElem.getChildren().size() == 0) {
+                httpResponse.sendError(exception.getErrorCode(), exception.getStatusPhrase());
+            } else {
+                sendXmlResponse(new Document(exception.getError()), exception.getErrorCode());
+            }
         }
     }
 

Modified: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java?view=diff&r1=159797&r2=159798
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java (original)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java Sat Apr  2 11:27:01 2005
@@ -78,22 +78,29 @@
      */
     public HrefProperty(DavProperty prop) {
         super(prop.getName(), prop.isProtected());
-        if (! (prop.getValue() instanceof List)) {
-            throw new IllegalArgumentException("Expected a property with a List value object.");
-        }
-        Iterator it = ((List)prop.getValue()).iterator();
         ArrayList hrefList = new ArrayList();
-        while (it.hasNext()) {
-            Object o = it.next();
-            if (o instanceof Element) {
-                String href = ((Element)o).getChildText(XML_HREF, NAMESPACE);
-                if (href != null) {
-                    hrefList.add(href);
+        Object val = prop.getValue();
+        if (val instanceof List) {
+            Iterator it = ((List)val).iterator();
+            while (it.hasNext()) {
+                Object o = it.next();
+                if (o instanceof Element) {
+                    String href = ((Element)o).getChildText(XML_HREF, NAMESPACE);
+                    if (href != null) {
+                        hrefList.add(href);
+                    } else {
+                        log.warn("Valid DAV:href element expected instead of " + o.toString());
+                    }
                 } else {
-                    log.warn("Valid DAV:href element expected instead of " + o.toString());
+                    log.warn("DAV: href element expected in the content of " + getName().toString());
                 }
+            }
+        } else if (val instanceof Element) {
+            String href = ((Element)val).getChildText(XML_HREF, NAMESPACE);
+            if (href != null) {
+                hrefList.add(href);
             } else {
-                log.warn("DAV: href element expected in the content of " + getName().toString());
+                log.warn("Valid DAV:href element expected instead of " + val.toString());
             }
         }
         value = (String[]) hrefList.toArray(new String[hrefList.size()]);



Mime
View raw message