jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r522969 - in /jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav: ExceptionConverter.java RepositoryServiceImpl.java URIResolverImpl.java
Date Tue, 27 Mar 2007 15:57:33 GMT
Author: angela
Date: Tue Mar 27 08:57:32 2007
New Revision: 522969

URL: http://svn.apache.org/viewvc?view=rev&rev=522969
Log:
ImportXML: uuidbehavior not transported

Modified:
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java?view=diff&rev=522969&r1=522968&r2=522969
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/ExceptionConverter.java
Tue Mar 27 08:57:32 2007
@@ -19,7 +19,11 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.client.methods.DavMethod;
+import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
+import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.commons.httpclient.methods.PutMethod;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 import org.w3c.dom.Element;
@@ -42,6 +46,10 @@
     private ExceptionConverter() {}
 
     static RepositoryException generate(DavException davExc) throws RepositoryException {
+        return generate(davExc, null);
+    }
+
+    static RepositoryException generate(DavException davExc, DavMethod method) throws RepositoryException
{
         String msg = davExc.getMessage();
         if (davExc.hasErrorCondition()) {
             try {
@@ -74,7 +82,16 @@
         // make sure an exception is generated
         switch (davExc.getErrorCode()) {
             // TODO: mapping DAV_error to jcr-exception is ambiguous. to be improved
-            case DavServletResponse.SC_NOT_FOUND : return new ItemNotFoundException(msg);
+            case DavServletResponse.SC_NOT_FOUND :
+                if (method != null && (method instanceof DeleteMethod ||
+                                       method instanceof MkColMethod ||
+                                       method instanceof PutMethod)) {
+                    // target item has probably while transient changes have
+                    // been made.
+                    throw new InvalidItemStateException(msg);
+                } else {
+                    return new ItemNotFoundException(msg);
+                }
             case DavServletResponse.SC_LOCKED : return new LockException(msg);
             case DavServletResponse.SC_METHOD_NOT_ALLOWED : return new ConstraintViolationException(msg);
             case DavServletResponse.SC_CONFLICT : return new InvalidItemStateException(msg);

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?view=diff&rev=522969&r1=522968&r2=522969
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Mar 27 08:57:32 2007
@@ -929,13 +929,16 @@
             batchImpl.dispose();
             return;
         }
+
+        DavMethod method = null;
         try {
             HttpClient client = batchImpl.start();
             boolean success = false;
+
             try {
                 Iterator it = batchImpl.methods();
                 while (it.hasNext()) {
-                    DavMethod method = (DavMethod) it.next();
+                    method = (DavMethod) it.next();
                     initMethod(method, batchImpl, true);
 
                     client.executeMethod(method);
@@ -952,7 +955,7 @@
         } catch (IOException e) {
             throw new RepositoryException(e);
         } catch (DavException e) {
-            throw ExceptionConverter.generate(e);
+            throw ExceptionConverter.generate(e, method);
         } finally {
             batchImpl.dispose();
         }
@@ -966,6 +969,7 @@
         QName nodeName = new QName(QName.NS_DEFAULT_URI, UUID.randomUUID().toString());
         String uri = getItemUri(parentId, nodeName, sessionInfo);
         MkColMethod method = new MkColMethod(uri);
+        method.addRequestHeader(ItemResourceConstants.IMPORT_UUID_BEHAVIOR, Integer.valueOf(uuidBehaviour).toString());
         method.setRequestEntity(new InputStreamRequestEntity(xmlStream, "text/xml"));
         execute(method, sessionInfo);
     }
@@ -1249,7 +1253,6 @@
             }
 
             PropPatchMethod method = new PropPatchMethod(getItemUri(nodeId, sessionInfo),
changeList);
-            // TODO: ev. evaluate response ??? change return type of RepositoryService.resolveMergeConflict()?
             execute(method, sessionInfo);
         } catch (IOException e) {
             throw new RepositoryException(e);
@@ -1759,14 +1762,17 @@
 
         private HttpClient start() throws RepositoryException {
             checkConsumed();
+            String uri = getItemUri(targetId, sessionInfo);
             try {
-                String uri = getItemUri(targetId, sessionInfo);
                 // start special 'lock'
                 LockMethod method = new LockMethod(uri, TransactionConstants.LOCAL, TransactionConstants.TRANSACTION,
null, DavConstants.INFINITE_TIMEOUT, true);
                 initMethod(method, sessionInfo, true);
 
                 HttpClient client = getClient(sessionInfo);
                 client.executeMethod(method);
+                if (method.getStatusCode() == DavServletResponse.SC_PRECONDITION_FAILED)
{
+                    throw new InvalidItemStateException("Unable to persist transient changes.");
+                }
                 method.checkSuccess();
 
                 batchId = method.getLockToken();
@@ -1783,7 +1789,6 @@
             checkConsumed();
 
             String uri = getItemUri(targetId, sessionInfo);
-
             UnLockMethod method = null;
             try {
                 // make sure the lock initially created is removed again on the

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java?view=diff&rev=522969&r1=522968&r2=522969
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/URIResolverImpl.java
Tue Mar 27 08:57:32 2007
@@ -104,8 +104,8 @@
         return getWorkspaceUri(workspaceName) + Text.escapePath(ItemResourceConstants.ROOT_ITEM_RESOURCEPATH);
     }
 
-    String getItemUri(ItemId itemId, String workspaceName,
-                      SessionInfo sessionInfo) throws RepositoryException {
+    String getItemUri(ItemId itemId, String workspaceName, SessionInfo sessionInfo)
+            throws RepositoryException {
         IdURICache cache = getCache(workspaceName);
         // check if uri is available from cache
         if (cache.containsItemId(itemId)) {



Mime
View raw message