jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r467911 - in /jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav: EventImpl.java ExceptionConverter.java IdFactoryImpl.java LockInfoImpl.java NodeInfoImpl.java RepositoryServiceImpl.java URIResolverImpl.java
Date Thu, 26 Oct 2006 08:25:03 GMT
Author: angela
Date: Thu Oct 26 01:25:02 2006
New Revision: 467911

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

- add 'isSessionScoped' to LockInfo and RepositoryService.lock
- add index to NodeInfo
- evaluate EventIds upon call to getId, getParentId
- convert Method-Not-Allowed to ConstraintViolation

Modified:
    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/ExceptionConverter.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java
    jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.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/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=467911&r1=467910&r2=467911
==============================================================================
--- 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 Oct 26 01:25:02 2006
@@ -22,7 +22,6 @@
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.name.QName;
 import org.apache.jackrabbit.spi.SessionInfo;
-import org.apache.jackrabbit.spi.PropertyId;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.observation.ObservationConstants;
 import org.apache.jackrabbit.webdav.observation.EventType;
@@ -46,13 +45,18 @@
 
     private final Element eventElement;
     private final int type;
-    private final ItemId itemId;
-    private final NodeId parentId;
+
+    private final SessionInfo sessionInfo;
+    private final URIResolver uriResolver;
+
+    private final String href;
     private final Path qPath;
 
     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);
@@ -61,16 +65,8 @@
         }
         type = getSpiEventType(SubscriptionImpl.getJcrEventType(et[0]));
 
-        String href = DomUtil.getChildTextTrim(eventElement, DavConstants.XML_HREF, DavConstants.NAMESPACE);
-        if (type == Event.NODE_ADDED || type == Event.NODE_REMOVED) {
-            itemId = uriResolver.getNodeId(href, sessionInfo);
-            String parentHref = Text.getRelativeParent(href, 1, true);
-            parentId = uriResolver.getNodeId(parentHref, sessionInfo);
-        } else {
-            itemId = uriResolver.getPropertyId(href, sessionInfo);
-            parentId = ((PropertyId)itemId).getParentId();
-        }
-        qPath = uriResolver.getQPath(Text.unescape(href), sessionInfo);
+        href = DomUtil.getChildTextTrim(eventElement, DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        qPath = uriResolver.getQPath(href, sessionInfo);
     }
 
     public int getType() {
@@ -82,15 +78,34 @@
     }
 
     public ItemId getItemId() {
-        return itemId;
+        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();
+        }
     }
 
     public NodeId getParentId() {
-        return parentId;
+        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();
+        }
     }
 
     public String getUUID() {
-        return itemId.getUUID();
+        return getItemId().getUUID();
     }
 
     public QName getPrimaryNodeTypeName() {

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=467911&r1=467910&r2=467911
==============================================================================
--- 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 Oct 26 01:25:02 2006
@@ -26,6 +26,7 @@
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.lock.LockException;
 import java.lang.reflect.Constructor;
 
@@ -73,6 +74,7 @@
         switch (davExc.getErrorCode()) {
             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);
             default: return new RepositoryException(msg);
         }
     }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java?view=diff&rev=467911&r1=467910&r2=467911
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/IdFactoryImpl.java
Thu Oct 26 01:25:02 2006
@@ -123,7 +123,7 @@
 
         boolean equals(ItemId other) {
             return (uuid == null) ? other.getUUID() == null : uuid.equals(other.getUUID())
-                && (path == null) ? other.getPath() == null : path.equals(other.getPath());
+                && ((path == null) ? other.getPath() == null : path.equals(other.getPath()));
         }
 
         /**

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java?view=diff&rev=467911&r1=467910&r2=467911
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/LockInfoImpl.java
Thu Oct 26 01:25:02 2006
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.webdav.lock.ActiveLock;
 import org.apache.jackrabbit.webdav.lock.Type;
 import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.spi.LockInfo;
 import org.apache.jackrabbit.spi.NodeId;
 import org.slf4j.LoggerFactory;
@@ -44,7 +45,8 @@
         Iterator it = activeLocks.iterator();
         while (it.hasNext()) {
             ActiveLock l = (ActiveLock) it.next();
-            if (l.getType() == Type.WRITE && l.getScope() == Scope.EXCLUSIVE) {
+            Scope sc = l.getScope();
+            if (l.getType() == Type.WRITE && (sc == Scope.EXCLUSIVE || sc == ItemResourceConstants.EXCLUSIVE_SESSION))
{
                 if (activeLock != null) {
                     throw new RepositoryException("Node " + nodeId + " contains multiple
exclusive write locks.");
                 } else {
@@ -73,5 +75,9 @@
 
     public boolean isDeep() {
         return activeLock.isDeep();
+    }
+
+    public boolean isSessionScoped() {
+        return activeLock.getScope() == ItemResourceConstants.EXCLUSIVE_SESSION;
     }
 }

Modified: jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java?view=diff&rev=467911&r1=467910&r2=467911
==============================================================================
--- jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java
(original)
+++ jackrabbit/trunk/contrib/spi/spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/NodeInfoImpl.java
Thu Oct 26 01:25:02 2006
@@ -48,6 +48,7 @@
 
     private final NodeId id;
     private final QName qName;
+    private final int index;
 
     private QName primaryNodeTypeName = null;
     private QName[] mixinNodeTypeNames = new QName[0];
@@ -85,6 +86,12 @@
             qName = (Path.ROOT_ELEMENT == el) ? QName.ROOT : el.getName();
         }
 
+        DavProperty indexProp = propSet.get(ItemResourceConstants.JCR_INDEX);
+        if (indexProp != null && indexProp.getValue() != null) {
+            index = Integer.parseInt(indexProp.getValue().toString());
+        } else {
+            index = Path.INDEX_DEFAULT;
+        }
 
         // retrieve properties
         try {
@@ -127,6 +134,10 @@
     //-----------------------------------------------------------< NodeInfo >---
     public NodeId getId() {
         return id;
+    }
+
+    public int getIndex() {
+        return index;
     }
 
     public QName getNodetype() {

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=467911&r1=467910&r2=467911
==============================================================================
--- 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 Oct 26 01:25:02 2006
@@ -906,12 +906,13 @@
     }
 
     /**
-     * @see RepositoryService#lock(SessionInfo, NodeId, boolean)
+     * @see RepositoryService#lock(SessionInfo, NodeId, boolean, boolean)
      */
-    public EventIterator lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep) throws
UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException,
RepositoryException {
+    public EventIterator lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep, boolean
sessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException,
InvalidItemStateException, RepositoryException {
         try {
             String uri = getItemUri(nodeId, sessionInfo);
-            LockMethod method = new LockMethod(uri, Scope.EXCLUSIVE, Type.WRITE,
+            Scope scope = (sessionScoped) ? ItemResourceConstants.EXCLUSIVE_SESSION : Scope.EXCLUSIVE;
+            LockMethod method = new LockMethod(uri, scope, Type.WRITE,
                 sessionInfo.getUserID(), DavConstants.INFINITE_TIMEOUT, deep);
             EventIterator events = execute(method, sessionInfo);
 

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=467911&r1=467910&r2=467911
==============================================================================
--- 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 Oct 26 01:25:02 2006
@@ -125,7 +125,7 @@
                     // append uri of parent node, that is already cached
                     uriBuffer.append(cache.getUri(uuidId));
                 } else {
-                    // request locate-by-uuid report to build the uri
+                    // try to request locate-by-uuid report to build the uri
                     ReportInfo rInfo = new ReportInfo(LocateByUuidReport.LOCATE_BY_UUID_REPORT);
                     rInfo.setContentElement(DomUtil.hrefToXml(uuid, domFactory));
 
@@ -181,13 +181,7 @@
     NodeId buildNodeId(NodeId parentId, MultiStatusResponse response,
                        String workspaceName) throws RepositoryException {
         IdURICache cache = getCache(workspaceName);
-        if (cache.containsUri(response.getHref())) {
-            ItemId id = cache.getItemId(response.getHref());
-            if (id.denotesNode()) {
-                return (NodeId) id;
-            }
-        }
-
+        
         NodeId nodeId;
         DavPropertySet propSet = response.getProperties(DavServletResponse.SC_OK);
 
@@ -249,21 +243,16 @@
      * @inheritDoc
      */
     public Path getQPath(String uri, SessionInfo sessionInfo) throws RepositoryException
{
-        String repoUri = getRepositoryUri();
-        String wspUri = getWorkspaceUri(sessionInfo.getWorkspaceName());
+        String rootUri = getRootItemUri(sessionInfo.getWorkspaceName());
         String jcrPath;
-        if (uri.startsWith(wspUri)) {
-            jcrPath = uri.substring(wspUri.length());
-        } else if (uri.startsWith(repoUri)) {
-            jcrPath = uri.substring(repoUri.length());
-            // then cut workspace name
-            jcrPath = jcrPath.substring(jcrPath.indexOf('/', 1));
+        if (uri.startsWith(rootUri)) {
+            jcrPath = uri.substring(rootUri.length());
         } else {
             // todo: probably rather an error?
             jcrPath = uri;
         }
         try {
-            return PathFormat.parse(jcrPath, nsResolver);
+            return PathFormat.parse(Text.unescape(jcrPath), nsResolver);
         } catch (MalformedPathException e) {
             throw new RepositoryException();
         }



Mime
View raw message