jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r698837 - in /jackrabbit/branches/1.4/jackrabbit-jcr-server/src: main/java/org/apache/jackrabbit/webdav/jcr/ main/java/org/apache/jackrabbit/webdav/jcr/search/ main/java/org/apache/jackrabbit/webdav/simple/ test/ test/java/ test/java/org/ t...
Date Thu, 25 Sep 2008 06:51:17 GMT
Author: angela
Date: Wed Sep 24 23:51:16 2008
New Revision: 698837

URL: http://svn.apache.org/viewvc?rev=698837&view=rev
Log:
prepare release for jackrabbit-jcr-server_1.4.1 
merge fixes from trunk for   
  [JCR-1300] Improve performance for large binary properties
  [JCR-1319] NullPointerException when accessing the SimpleWebdav ...
  [JCR-1345] ClassCastException when updating properties using WebDAV
  [JCR-1392] Exception not thrown where it appears it should have been
  [JCR-1401] Removing-nodes with unexpected nodetype
  [JCR-1679] Dir with same name as repository has incorrect behavior
  [JCR-1678] NullPointerException in constructor of JcrDavException 

Added:
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
      - copied unchanged from r687316, jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrValueType.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrDavExceptionTest.java
      - copied unchanged from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/jcr/JcrDavExceptionTest.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/simple/
      - copied from r677895, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/simple/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplExTest.java
      - copied unchanged from r677895, jackrabbit/trunk/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplExTest.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/resources/
      - copied from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/resources/
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/test/resources/log4j.properties
      - copied unchanged from r677893, jackrabbit/trunk/jackrabbit-jcr-server/src/test/resources/log4j.properties
Modified:
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplEx.java
    jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
Wed Sep 24 23:51:16 2008
@@ -81,6 +81,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
@@ -403,8 +405,28 @@
                 if (in == null) {
                     // PUT: not possible without request body
                     throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Cannot create
a new non-collection resource without request body.");
+                }
+                // PUT : create new or overwrite existing property.
+                String ct = inputContext.getContentType();
+                int type = JcrValueType.typeFromContentType(ct);
+                if (type != PropertyType.UNDEFINED) {
+                    // no need to create value/values property. instead
+                    // prop-value can be retrieved directly:
+                    int pos = ct.indexOf(';');
+                    String charSet = (pos > -1) ? ct.substring(pos) : "UTF-8";
+                    if (type == PropertyType.BINARY) {
+                        n.setProperty(memberName, inputContext.getInputStream());
+                    } else {
+                        BufferedReader r = new BufferedReader(new InputStreamReader(inputContext.getInputStream(),
charSet));
+                        String line;
+                        StringBuffer value = new StringBuffer();
+                        while ((line = r.readLine()) != null) {
+                            value.append(line);
+                        }
+                        n.setProperty(memberName, value.toString(), type);
+                    }
                 } else {
-                    // PUT : create new or overwrite existing property.
+                    // try to parse the request body into a 'values' property.
                     tmpFile = File.createTempFile(TMP_PREFIX + Text.escape(memberName), null,
null);
                     FileOutputStream out = new FileOutputStream(tmpFile);
                     IOUtil.spool(in, out);

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
Wed Sep 24 23:51:16 2008
@@ -302,14 +302,14 @@
 
                 // set the content type
                 String contentType;
-                if (!isMultiple()) {
-                    contentType = (type == PropertyType.BINARY) ? "application/octet-stream"
: "text/plain";
+                if (isMultiple()) {
+                    contentType = IOUtil.buildContentType("text/xml","utf-8");
                 } else {
-                    contentType = "text/xml";
+                    contentType = IOUtil.buildContentType(JcrValueType.contentTypeFromType(type),
"utf-8");
+
                 }
                 properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType));
 
-
                 // add jcr-specific resource properties
                 properties.add(new DefaultDavProperty(JCR_TYPE, PropertyType.nameFromValue(type)));
                 if (isMultiple()) {
@@ -319,9 +319,6 @@
                     properties.add(new ValuesProperty(prop.getValue()));
                     long length = prop.getLength();
                     properties.add(new DefaultDavProperty(JCR_LENGTH, String.valueOf(length),
true));
-                    if (prop.getLength() > IOUtil.UNDEFINED_LENGTH) {
-                        properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH,
String.valueOf(length)));
-                    }
                 }
             } catch (RepositoryException e) {
                 log.error("Failed to retrieve resource properties: "+e.getMessage());

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
Wed Sep 24 23:51:16 2008
@@ -44,7 +44,10 @@
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.version.VersionException;
-import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
 
 /**
  * <code>JcrDavException</code> extends the {@link DavException} in order to
@@ -54,8 +57,8 @@
 
     private static Logger log = LoggerFactory.getLogger(JcrDavException.class);
 
-    // mapping of Jcr exceptions to error codes.
-    private static HashMap codeMap = new HashMap();
+    // ordered mapping of Jcr exceptions to error codes.
+    private static Map codeMap = new LinkedHashMap(20);
     static {
         codeMap.put(AccessDeniedException.class, new Integer(DavServletResponse.SC_FORBIDDEN));
         codeMap.put(ConstraintViolationException.class, new Integer(DavServletResponse.SC_CONFLICT));
@@ -71,13 +74,30 @@
         codeMap.put(NoSuchWorkspaceException.class, new Integer(DavServletResponse.SC_CONFLICT));
         codeMap.put(PathNotFoundException.class, new Integer(DavServletResponse.SC_CONFLICT));
         codeMap.put(ReferentialIntegrityException.class, new Integer(DavServletResponse.SC_CONFLICT));
-        codeMap.put(RepositoryException.class, new Integer(DavServletResponse.SC_FORBIDDEN));
         codeMap.put(LoginException.class, new Integer(DavServletResponse.SC_UNAUTHORIZED));
         codeMap.put(UnsupportedRepositoryOperationException.class, new Integer(DavServletResponse.SC_NOT_IMPLEMENTED));
         codeMap.put(ValueFormatException.class, new Integer(DavServletResponse.SC_CONFLICT));
         codeMap.put(VersionException.class, new Integer(DavServletResponse.SC_CONFLICT));
+        codeMap.put(RepositoryException.class, new Integer(DavServletResponse.SC_FORBIDDEN));
     }
 
+    private static int lookupErrorCode(Class exceptionClass) {
+        Integer code = (Integer) codeMap.get(exceptionClass);
+        if (code == null) {
+            for (Iterator it = codeMap.keySet().iterator(); it.hasNext();) {
+                Class jcrExceptionClass = (Class) it.next();
+                if (jcrExceptionClass.isAssignableFrom(exceptionClass)) {
+                    code = (Integer) codeMap.get(jcrExceptionClass);
+                    break;
+                }
+            }
+            if (code == null) {
+                code = new Integer(DavServletResponse.SC_FORBIDDEN); // fallback
+            }
+        }
+        return code.intValue();
+    }
+    
     private Class exceptionClass;
 
     /**
@@ -108,7 +128,7 @@
      * @see JcrDavException#JcrDavException(Throwable, int)
      */
     public JcrDavException(RepositoryException cause) {
-        this(cause, ((Integer)codeMap.get(cause.getClass())).intValue());
+        this(cause, lookupErrorCode(cause.getClass()));
     }
 
     /**
@@ -136,4 +156,4 @@
         error.appendChild(excep);
         return error;
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/jcr/search/SearchResultProperty.java
Wed Sep 24 23:51:16 2008
@@ -93,7 +93,7 @@
         } else if (propValue instanceof Element) {
             parseColumnElement((Element)property.getValue(), colList, valList, valueFactory);
         } else {
-            new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column'
xml elements.");
+            throw new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column'
xml elements.");
         }
 
         columnNames = (String[]) colList.toArray(new String[colList.size()]);
@@ -209,4 +209,4 @@
         }
         return elem;
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplEx.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplEx.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImplEx.java
Wed Sep 24 23:51:16 2008
@@ -62,7 +62,7 @@
         if (repositoryPath == null) {
             throw new IllegalArgumentException("Cannot build resource path from 'null' repository
path");
         }
-        return (startsWithWorkspace(repositoryPath, wspPath)) ? repositoryPath : wspPath
+ repositoryPath;
+        return wspPath + repositoryPath;
     }
 
     private boolean startsWithWorkspace(String repositoryPath, String wspPath) {

Modified: jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java?rev=698837&r1=698836&r2=698837&view=diff
==============================================================================
--- jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
(original)
+++ jackrabbit/branches/1.4/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
Wed Sep 24 23:51:16 2008
@@ -137,13 +137,16 @@
             throws RepositoryException {
         Node node = null;
         try {
-            Item item = ((JcrDavSession)sessionImpl).getRepositorySession().getItem(locator.getRepositoryPath());
-            if (item instanceof Node) {
-                node = (Node)item;
-            } // else: item is a property -> return null
+            String repoPath = locator.getRepositoryPath();
+            if (repoPath != null) {
+                Session session = ((JcrDavSession)sessionImpl).getRepositorySession();
+                Item item = session.getItem(repoPath);
+                if (item instanceof Node) {
+                    node = (Node)item;
+                } // else: item is a property -> return null
+            }
         } catch (PathNotFoundException e) {
-            // item does not exist (yet) -> create null-resource
-            node = null;
+            // item does not exist (yet). return null -> create null-resource
         }
         return node;
     }
@@ -153,7 +156,7 @@
      *
      * @param locator
      * @param session
-     * @param request
+     * @param isCollection
      * @return
      * @throws DavException
      */
@@ -178,10 +181,11 @@
      * supports the versioning option different resources are created for
      * version, versionhistory and common nodes.
      *
+     * @param node
      * @param locator
-     * @param sessionImpl
-     * @return DavResource representing a repository item.
-     * @throws RepositoryException if {@link javax.jcr.Session#getItem(String)} fails.
+     * @param session
+     * @return
+     * @throws DavException
      */
     private DavResource createResource(Node node, DavResourceLocator locator,
                                        DavSession session) throws DavException {



Mime
View raw message