jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r472821 - in /jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav: EventBundleImpl.java EventImpl.java EventIteratorImpl.java ExceptionConverter.java IdURICache.java RepositoryServiceImpl.java URIResolverImpl.java
Date Thu, 09 Nov 2006 09:11:57 GMT
Author: angela
Date: Thu Nov  9 01:11:55 2006
New Revision: 472821

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

- missing escaping of item name when building uri.
- let RS parse the eventdiscovery. don't pass sessioninfo and resolvers
  to the various event related classes.
- removing of id/uri-cache entries must remove the corresponding
  entry in the other cache as well.

Modified:
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventBundleImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventIteratorImpl.java
    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/IdURICache.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/EventBundleImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventBundleImpl.java?view=diff&rev=472821&r1=472820&r2=472821
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventBundleImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventBundleImpl.java
Thu Nov  9 01:11:55 2006
@@ -18,10 +18,9 @@
 
 import org.apache.jackrabbit.spi.EventBundle;
 import org.apache.jackrabbit.spi.EventIterator;
-import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
-import org.w3c.dom.Element;
+
+import java.util.Collection;
 
 /**
  * <code>EventBundleImpl</code> implements a bundle of events. The individual
@@ -29,46 +28,35 @@
  */
 class EventBundleImpl implements EventBundle, ObservationConstants {
 
-    static final EventBundle EMPTY = new EventBundleImpl(null, null, null) {
-        public EventIterator getEvents() {
-            return IteratorHelper.EMPTY;
-        }
-    };
-
-    private final Element eventBundleElement;
-
-    private final URIResolver uriResolver;
-
-    private final SessionInfo sessionInfo;
+    static final EventBundle EMPTY = new EventBundleImpl();
 
+    private final Collection events;
     private final boolean isLocal;
 
+    private EventBundleImpl() {
+        events = null;
+        isLocal = false;
+    }
     /**
      * Creates a new event bundle.
      *
-     * @param eventBundleElement
-     * @param uriResolver
-     * @param sessionInfo
+     * @param events
+     * @param isLocal
      */
-    EventBundleImpl(Element eventBundleElement,
-                    URIResolver uriResolver,
-                    SessionInfo sessionInfo) {
-        this.eventBundleElement = eventBundleElement;
-        this.uriResolver = uriResolver;
-        this.sessionInfo = sessionInfo;
-        String value = null;
-        if (eventBundleElement != null) {
-            value = DomUtil.getAttribute(eventBundleElement,
-                        XML_EVENT_IS_LOCAL, NAMESPACE);
-        }
-        this.isLocal = (value != null) ? Boolean.valueOf(value).booleanValue() : false;
+    EventBundleImpl(Collection events, boolean isLocal) {
+        this.events = events;
+        this.isLocal = isLocal;
     }
 
     /**
      * @inheritDoc
      */
     public EventIterator getEvents() {
-        return new EventIteratorImpl(eventBundleElement, uriResolver, sessionInfo);
+        if (events == null || events.isEmpty()) {
+            return IteratorHelper.EMPTY;
+        } else {
+            return new EventIteratorImpl(events);
+        }
     }
 
     /**

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java?view=diff&rev=472821&r1=472820&r2=472821
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventImpl.java
Thu Nov  9 01:11:55 2006
@@ -21,21 +21,12 @@
 import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.name.QName;
-import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
-import org.apache.jackrabbit.webdav.observation.EventType;
-import org.apache.jackrabbit.webdav.observation.DefaultEventType;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.jcr.observation.SubscriptionImpl;
-import org.apache.jackrabbit.util.Text;
 import org.w3c.dom.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.RepositoryException;
-
 /**
  * <code>EventImpl</code>...
  */
@@ -43,30 +34,21 @@
 
     private static Logger log = LoggerFactory.getLogger(EventImpl.class);
 
-    private final Element eventElement;
+    private final ItemId eventId;
     private final int type;
+    private final Path eventPath;
+    private final NodeId parentId;
 
-    private final SessionInfo sessionInfo;
-    private final URIResolver uriResolver;
+    private final Element eventElement;
 
-    private final String href;
-    private final Path qPath;
+    public EventImpl(ItemId eventId, Path eventPath, NodeId parentId, int eventType,
+                     Element eventElement) {
+        this.eventId = eventId;
+        this.eventPath = eventPath;
+        this.parentId = parentId;
+        type = getSpiEventType(eventType);
 
-    public EventImpl(Element eventElement, URIResolver uriResolver,
-                     SessionInfo sessionInfo) throws RepositoryException, DavException {
         this.eventElement = eventElement;
-        this.uriResolver = uriResolver;
-        this.sessionInfo = sessionInfo;
-
-        Element typeEl = DomUtil.getChildElement(eventElement, XML_EVENTTYPE, NAMESPACE);
-        EventType[] et = DefaultEventType.createFromXml(typeEl);
-        if (et.length == 0 || et.length > 1) {
-            throw new IllegalArgumentException("Ambigous event type definition: expected
one single eventtype.");
-        }
-        type = getSpiEventType(SubscriptionImpl.getJcrEventType(et[0]));
-
-        href = DomUtil.getChildTextTrim(eventElement, DavConstants.XML_HREF, DavConstants.NAMESPACE);
-        qPath = uriResolver.getQPath(href, sessionInfo);
     }
 
     public int getType() {
@@ -74,34 +56,15 @@
     }
 
     public Path getQPath() {
-        return qPath;
+        return eventPath;
     }
 
     public ItemId getItemId() {
-        try {
-            if (type == Event.NODE_ADDED || type == Event.NODE_REMOVED) {
-                return uriResolver.getNodeId(href, sessionInfo);
-            } else {
-                return uriResolver.getPropertyId(href, sessionInfo);
-            }
-        } catch (RepositoryException e) {
-            // should never occur
-            log.error("Internal error, while building id of Event.", e);
-            // TODO: check
-            throw new IllegalStateException();
-        }
+        return eventId;
     }
 
     public NodeId getParentId() {
-        try {
-            String parentHref = Text.getRelativeParent(href, 1, true);
-            return uriResolver.getNodeId(parentHref, sessionInfo);
-        } catch (RepositoryException e) {
-            // should never occur
-            log.error("Internal error, while building parentId of Event.", e);
-            // TODO: check
-            throw new IllegalStateException();
-        }
+        return parentId;
     }
 
     public String getUUID() {

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventIteratorImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventIteratorImpl.java?view=diff&rev=472821&r1=472820&r2=472821
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventIteratorImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/EventIteratorImpl.java
Thu Nov  9 01:11:55 2006
@@ -15,19 +15,14 @@
 */
 package org.apache.jackrabbit.spi2dav;
 
-import org.apache.jackrabbit.webdav.xml.ElementIterator;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
-import org.apache.jackrabbit.webdav.observation.ObservationConstants;
-import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.spi.EventIterator;
-import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.Event;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
-import org.w3c.dom.Element;
 
-import javax.jcr.RepositoryException;
 import java.util.NoSuchElementException;
+import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * <code>EventIteratorImpl</code>...
@@ -36,18 +31,13 @@
 
     private static Logger log = LoggerFactory.getLogger(EventIteratorImpl.class);
 
-    private final SessionInfo sessionInfo;
-    private final URIResolver uriResolver;
-    private ElementIterator eventElementIterator;
+    private Iterator eventIterator;
 
     private Event next;
     private long pos;
 
-    public EventIteratorImpl(Element eventBundleElement, URIResolver uriResolver, SessionInfo
sessionInfo) {
-
-        this.sessionInfo = sessionInfo;
-        this.uriResolver = uriResolver;
-        this.eventElementIterator = DomUtil.getChildren(eventBundleElement, ObservationConstants.XML_EVENT,
ObservationConstants.NAMESPACE);
+    public EventIteratorImpl(Collection events) {
+        this.eventIterator = events.iterator();
         retrieveNextEvent();
     }
 
@@ -90,15 +80,11 @@
     //------------------------------------------------------------< private >---
     private void retrieveNextEvent() {
         next = null;
-        if (eventElementIterator != null) {
-            while (next == null && eventElementIterator.hasNext()) {
-                Element evElem = eventElementIterator.nextElement();
-                try {
-                    next = new EventImpl(evElem, uriResolver, sessionInfo);
-                } catch (RepositoryException e) {
-                    log.error("Unexpected error while creating event.", e);
-                } catch (DavException e) {
-                    log.error("Unexpected error while creating event.", e);
+        if (eventIterator != null) {
+            while (next == null && eventIterator.hasNext()) {
+                Object o = eventIterator.next();
+                if (o instanceof Event) {
+                    next = (Event)o;
                 }
             }
         }

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=472821&r1=472820&r2=472821
==============================================================================
--- 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
Thu Nov  9 01:11:55 2006
@@ -26,6 +26,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.InvalidItemStateException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
 import java.lang.reflect.Constructor;
@@ -72,9 +73,11 @@
 
         // 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_LOCKED : return new LockException(msg);
             case DavServletResponse.SC_METHOD_NOT_ALLOWED : return new ConstraintViolationException(msg);
+            case DavServletResponse.SC_CONFLICT : return new InvalidItemStateException(msg);
             default: return new RepositoryException(msg);
         }
     }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java?view=diff&rev=472821&r1=472820&r2=472821
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdURICache.java
Thu Nov  9 01:11:55 2006
@@ -68,11 +68,17 @@
     public void remove(String uri) {
         String cleanUri = getCleanUri(uri);
         Object itemId = uriToIdCache.remove(cleanUri);
+        if (itemId != null) {
+            idToUriCache.remove(itemId);
+        }
         log.debug("Removed: ItemId = " + itemId + " URI = " + cleanUri);
     }
 
     public void remove(ItemId itemId) {
         Object uri = idToUriCache.remove(itemId);
+        if (uri != null) {
+            uriToIdCache.remove(uri);
+        }
         log.debug("Removed: ItemId = " + itemId + " URI = " + uri);
     }
 

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=472821&r1=472820&r2=472821
==============================================================================
--- 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
Thu Nov  9 01:11:55 2006
@@ -70,6 +70,7 @@
 import org.apache.jackrabbit.webdav.observation.EventType;
 import org.apache.jackrabbit.webdav.observation.EventDiscovery;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
+import org.apache.jackrabbit.webdav.observation.DefaultEventType;
 import org.apache.jackrabbit.webdav.security.SecurityConstants;
 import org.apache.jackrabbit.webdav.security.CurrentUserPrivilegeSetProperty;
 import org.apache.jackrabbit.webdav.security.Privilege;
@@ -97,6 +98,7 @@
 import org.apache.jackrabbit.name.NoPrefixDeclaredException;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.name.NameFormat;
+import org.apache.jackrabbit.name.Path;
 import org.apache.jackrabbit.spi.Batch;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.SessionInfo;
@@ -114,6 +116,7 @@
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.LockInfo;
 import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.Event;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.value.ValueFormat;
@@ -239,9 +242,17 @@
         }
     }
 
+    private static void initMethod(DavMethod method, BatchImpl batchImpl, boolean addIfHeader)
{
+        initMethod(method, batchImpl.sessionInfo,  addIfHeader);
+
+        // add batchId as separate header
+        CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID,
batchImpl.batchId);
+        method.setRequestHeader(ch.getHeaderName(), ch.getHeaderValue());
+    }
+
     private static boolean isSameResource(String requestURI, MultiStatusResponse response)
{
         String href = response.getHref();
-        if (href.endsWith("/")) {
+        if (href.endsWith("/") && !requestURI.endsWith("/")) {
             href = href.substring(0, href.length() - 1);
         }
         return requestURI.equals(href);
@@ -309,7 +320,7 @@
         // TODO: build specific subscrUri
         // TODO: check if 'all event' subscription is ok
         String subscrUri = uriResolver.getRootItemUri(sessionInfo.getWorkspaceName());
-        String subscrId = subscribe(subscrUri, S_INFO, null, sessionInfo);
+        String subscrId = subscribe(subscrUri, S_INFO, null, sessionInfo, null);
         try {
             if (isLockMethod(method)) {
                 initMethod(method, sessionInfo, false);
@@ -794,10 +805,7 @@
                 Iterator it = batchImpl.methods();
                 while (it.hasNext()) {
                     DavMethod method = (DavMethod) it.next();
-                    initMethod(method, batchImpl.sessionInfo, true);
-                    // add batchId as separate header
-                    CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID,
batchImpl.batchId);
-                    method.setRequestHeader(ch.getHeaderName(), ch.getHeaderValue());
+                    initMethod(method, batchImpl, true);
 
                     client.executeMethod(method);
                     method.checkSuccess();
@@ -883,6 +891,8 @@
         try {
             String uri = getItemUri(nodeId, sessionInfo);
             method = new PropFindMethod(uri, nameSet, DEPTH_0);
+            // TODO: not correct. pass tokens in order avoid new session to be created TOBEFIXED
+            initMethod(method, sessionInfo, true);
 
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();
@@ -1162,7 +1172,7 @@
         String subscriptionId = sessionInfoImpl.getSubscriptionId();
         if (subscriptionId == null) {
             SubscriptionInfo subscriptionInfo = new SubscriptionInfo(ALL_EVENTS, true, DavConstants.UNDEFINED_TIMEOUT);
-            subscriptionId = subscribe(rootUri, subscriptionInfo, null, sessionInfo);
+            subscriptionId = subscribe(rootUri, subscriptionInfo, null, sessionInfo, null);
             log.debug("Subscribed on server for session info " + sessionInfo);
             sessionInfoImpl.setSubscriptionId(subscriptionId);
         }
@@ -1170,7 +1180,9 @@
         return poll(rootUri, subscriptionId, sessionInfo);
     }
 
-    private String subscribe(String uri, SubscriptionInfo subscriptionInfo, String subscriptionId,
SessionInfo sessionInfo) throws RepositoryException {
+    private String subscribe(String uri, SubscriptionInfo subscriptionInfo,
+                             String subscriptionId, SessionInfo sessionInfo,
+                             String batchId) throws RepositoryException {
         SubscribeMethod method = null;
         try {
             if (subscriptionId != null) {
@@ -1178,6 +1190,13 @@
             } else {
                 method = new SubscribeMethod(uri, subscriptionInfo);
             }
+
+            if (batchId != null) {
+                // add batchId as separate header
+                CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID,
batchId);
+                method.setRequestHeader(ch.getHeaderName(), ch.getHeaderValue());
+            }
+
             getClient(sessionInfo).executeMethod(method);
             method.checkSuccess();
             return method.getSubscriptionId();
@@ -1227,7 +1246,11 @@
                         ObservationConstants.NAMESPACE);
                 List bundles = new ArrayList();
                 while (it.hasNext()) {
-                    bundles.add(new EventBundleImpl(it.nextElement(), uriResolver, sessionInfo));
+                    Element bundleElement = it.nextElement();
+                    String value = DomUtil.getAttribute(bundleElement, ObservationConstants.XML_EVENT_IS_LOCAL,
NAMESPACE);
+                    boolean isLocal = (value != null) ? Boolean.valueOf(value).booleanValue()
: false;
+
+                    bundles.add(new EventBundleImpl(buildEventList(bundleElement, sessionInfo),
isLocal));
                 }
                 events = (EventBundle[]) bundles.toArray(new EventBundle[bundles.size()]);
             }
@@ -1243,6 +1266,60 @@
         }
     }
 
+    private List buildEventList(Element bundleElement, SessionInfo sessionInfo) {
+        List events = new ArrayList();
+        ElementIterator eventElementIterator = DomUtil.getChildren(bundleElement, ObservationConstants.XML_EVENT,
ObservationConstants.NAMESPACE);
+        while (eventElementIterator.hasNext()) {
+            Element evElem = eventElementIterator.nextElement();
+            Element typeEl = DomUtil.getChildElement(evElem, ObservationConstants.XML_EVENTTYPE,
ObservationConstants.NAMESPACE);
+            EventType[] et = DefaultEventType.createFromXml(typeEl);
+            if (et.length == 0 || et.length > 1) {
+                // should not occur.
+                log.error("Ambigous event type definition: expected one single eventtype.");
+                continue;
+            }
+
+            String href = DomUtil.getChildTextTrim(evElem, DavConstants.XML_HREF, DavConstants.NAMESPACE);
+
+            int type;
+            Path eventPath;
+            try {
+                type = SubscriptionImpl.getJcrEventType(et[0]);
+                eventPath = uriResolver.getQPath(href, sessionInfo);
+            } catch (DavException e) {
+                // should not occur
+                log.error("Internal error while building Event", e);
+                continue;
+            } catch (RepositoryException e) {
+                // should not occur
+                log.error("Internal error while building Event", e);
+                continue;
+            }
+
+            ItemId eventId = null;
+            try {
+                if (type == Event.NODE_ADDED || type == Event.NODE_REMOVED) {
+                    eventId = uriResolver.getNodeId(href, sessionInfo);
+                } else {
+                    eventId = uriResolver.getPropertyId(href, sessionInfo);
+                }
+            } catch (RepositoryException e) {
+                log.warn("Unable to build event itemId: ", e);
+            }
+            String parentHref = Text.getRelativeParent(href, 1, true);
+            NodeId parentId = null;
+            try {
+                parentId = uriResolver.getNodeId(parentHref, sessionInfo);
+            } catch (RepositoryException e) {
+                log.warn("Unable to build event parentId: ", e);
+            }
+
+            events.add(new EventImpl(eventId, eventPath, parentId, type, evElem));
+        }
+
+        return events;
+    }
+
     /**
      * @see RepositoryService#getRegisteredNamespaces(SessionInfo)
      */
@@ -1440,7 +1517,7 @@
                 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, false);
+                initMethod(method, sessionInfo, true);
 
                 HttpClient client = getClient(sessionInfo);
                 client.executeMethod(method);
@@ -1450,7 +1527,7 @@
 
                 // register subscription
                 String subscrUri = (targetId.denotesNode() ? uri : getItemUri(((PropertyId)
targetId).getParentId(), sessionInfo));
-                subscriptionId = subscribe(subscrUri, S_INFO, null, sessionInfo);
+                subscriptionId = subscribe(subscrUri, S_INFO, null, sessionInfo, batchId);
                 return client;
             } catch (IOException e) {
                 throw new RepositoryException(e);
@@ -1470,12 +1547,8 @@
                 // make sure the lock initially created is removed again on the
                 // server, asking the server to persist the modifications
                 method = new UnLockMethod(uri, batchId);
-                // todo: check if 'initmethod' would work (ev. conflict with TxId header).
-                String[] locktokens = sessionInfo.getLockTokens();
-                if (locktokens != null && locktokens.length > 0) {
-                    IfHeader ifH = new IfHeader(locktokens);
-                    method.setRequestHeader(ifH.getHeaderName(), ifH.getHeaderValue());
-                }
+                initMethod(method, sessionInfo, true);
+
                 // in contrast to standard UNLOCK, the tx-unlock provides a
                 // request body.
                 method.setRequestBody(new TransactionInfo(commit));

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=472821&r1=472820&r2=472821
==============================================================================
--- 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
Thu Nov  9 01:11:55 2006
@@ -238,6 +238,12 @@
         }
     }
 
+    void clearCacheEntries(ItemId itemId, SessionInfo sessionInfo) {
+        IdURICache cache = getCache(sessionInfo.getWorkspaceName());
+        if (cache.containsItemId(itemId)) {
+            cache.remove(itemId);
+        }
+    }
     //-------------------------------------------------------< URI resolver >---
     /**
      * @inheritDoc
@@ -254,7 +260,7 @@
         try {
             return PathFormat.parse(Text.unescape(jcrPath), nsResolver);
         } catch (MalformedPathException e) {
-            throw new RepositoryException();
+            throw new RepositoryException(e);
         }
     }
 



Mime
View raw message