You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2006/10/04 11:13:19 UTC

svn commit: r452806 - in /jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav: RepositoryServiceImpl.java URIResolverImpl.java

Author: angela
Date: Wed Oct  4 02:13:18 2006
New Revision: 452806

URL: http://svn.apache.org/viewvc?view=rev&rev=452806
Log:
work in progress

- missing release of HTTP methods
- unsubscribe in order to retrieve batch events must be performed before the batch lock is released.
- getItemInfo should rather throw ItemNotFound instead of PathNotFound

Modified:
    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/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=452806&r1=452805&r2=452806
==============================================================================
--- 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 Wed Oct  4 02:13:18 2006
@@ -180,7 +180,7 @@
     }
     private static final SubscriptionInfo S_INFO = new SubscriptionInfo(ALL_EVENTS, true, DavConstants.INFINITE_TIMEOUT);
 
-    private static long POLL_INTERVAL = 30000;  // TODO: make configurable
+    private static long POLL_INTERVAL = 300000000;  // TODO: make configurable
 
     private final IdFactory idFactory;
     private final ValueFactory valueFactory;
@@ -604,7 +604,7 @@
     /**
      * @see RepositoryService#getNodeInfo(SessionInfo, NodeId)
      */
-    public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws PathNotFoundException, RepositoryException {
+    public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws ItemNotFoundException, RepositoryException {
         // set of properties to be retrieved
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(ItemResourceConstants.JCR_NAME);
@@ -687,7 +687,7 @@
     /**
      * @see RepositoryService#getPropertyInfo(SessionInfo, PropertyId)
      */
-    public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId) throws PathNotFoundException, RepositoryException {
+    public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId) throws ItemNotFoundException, RepositoryException {
         // set of Dav-properties to be retrieved
         DavPropertyNameSet nameSet = new DavPropertyNameSet();
         nameSet.add(ItemResourceConstants.JCR_NAME);
@@ -762,6 +762,7 @@
 
                     client.executeMethod(method);
                     method.checkSuccess();
+                    method.releaseConnection();
                 }
                 success = true;
             } finally {
@@ -1464,8 +1465,18 @@
 
         private EventIterator end(HttpClient client, boolean commit) throws RepositoryException {
             checkConsumed();
+
+            String uri = getItemUri(targetId, sessionInfo);
             try {
-                String uri = getItemUri(targetId, sessionInfo);
+                // first unsubscribe in order to retrieve the events
+                String subscrUri = (targetId.denotesNode() ? uri : getItemUri(((PropertyId) targetId).getParentId(), sessionInfo));
+                EventIterator events = poll(subscrUri, subscriptionId, sessionInfo);
+                unsubscribe(subscrUri, subscriptionId, sessionInfo);
+                return events;
+
+            } finally {
+                // make sure the lock initially created is removed again on the
+                // server.
                 UnLockMethod method = new UnLockMethod(uri, batchId);
                 // todo: check if 'initmethod' would work (ev. conflict with TxId header).
                 String[] locktokens = sessionInfo.getLockTokens();
@@ -1475,21 +1486,18 @@
                 }
                 // in contrast to standard UNLOCK, the tx-unlock provides a
                 // request body.
-                method.setRequestBody(new TransactionInfo(commit));
-
-                client.executeMethod(method);
-                method.checkSuccess();
-
-                // retrieve events && unsubscribe
-                String subscrUri = (targetId.denotesNode() ? uri : getItemUri(((PropertyId) targetId).getParentId(), sessionInfo));
-                EventIterator events = poll(subscrUri, subscriptionId, sessionInfo);
-                unsubscribe(subscrUri, subscriptionId, sessionInfo);
-
-                return events;
-            } catch (IOException e) {
-                throw new RepositoryException(e);
-            } catch (DavException e) {
-                throw ExceptionConverter.generate(e);
+                try {
+                    method.setRequestBody(new TransactionInfo(commit));
+                    client.executeMethod(method);
+                    method.checkSuccess();
+                } catch (IOException e) {
+                    throw new RepositoryException(e);
+                } catch (DavException e) {
+                    throw ExceptionConverter.generate(e);
+                } finally {
+                    // release UNLOCK method
+                    method.releaseConnection();
+                }
             }
         }
 

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=452806&r1=452805&r2=452806
==============================================================================
--- 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 Wed Oct  4 02:13:18 2006
@@ -128,9 +128,11 @@
                     // request locate-by-uuid report to build the uri
                     ReportInfo rInfo = new ReportInfo(LocateByUuidReport.LOCATE_BY_UUID_REPORT);
                     rInfo.setContentElement(DomUtil.hrefToXml(uuid, domFactory));
+
+                    ReportMethod rm = null;
                     try {
                         String wspUri = getWorkspaceUri(workspaceName);
-                        ReportMethod rm = new ReportMethod(wspUri, rInfo);
+                        rm = new ReportMethod(wspUri, rInfo);
 
                         service.getClient(sessionInfo).executeMethod(rm);
 
@@ -139,13 +141,17 @@
                             uriBuffer.append(ms.getResponses()[0].getHref());
                             cache.add(ms.getResponses()[0].getHref(), uuidId);
                         } else {
-                            throw new RepositoryException("Cannot identify item with uuid " + uuid);
+                            throw new ItemNotFoundException("Cannot identify item with uuid " + uuid);
                         }
 
                     } catch (IOException e) {
                         throw new RepositoryException(e.getMessage());
                     } catch (DavException e) {
                         throw ExceptionConverter.generate(e);
+                    } finally {
+                        if (rm != null) {
+                            rm.releaseConnection();
+                        }
                     }
                 }
             } else {