jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r385540 [1/3] - in /incubator/jackrabbit/trunk/jcr-server: server/src/java/org/apache/jackrabbit/server/jcr/ server/src/java/org/apache/jackrabbit/webdav/jcr/ server/src/java/org/apache/jackrabbit/webdav/jcr/observation/ server/src/java/org...
Date Mon, 13 Mar 2006 13:07:07 GMT
Author: angela
Date: Mon Mar 13 05:07:02 2006
New Revision: 385540

URL: http://svn.apache.org/viewcvs?rev=385540&view=rev
Log:
JCR-337 - Remove jcr dependency from dav-library
JCR-343 - Report#init limits the Report interface to DeltaV compliant resources
JCR-340 - ValuesProperty missing property type information
JCR-342 - DavResource#getDavSession() missing
JCR-344 - DeltaVResource lists MKWORKSPACE in the method constant.
JCR-345 - DavException does not allow to specify an exception cause

Added:
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java   (with props)
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/AbstractJcrReport.java   (with props)
Modified:
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavLocatorFactoryImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionItemCollection.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ExportViewReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateByUuidReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/LocateCorrespondingNodeReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/NodeTypesReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RegisteredNamespacesReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/RepositoryDescriptorsReport.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavResourceImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/DavSessionProviderImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/LocatorFactoryImpl.java
    incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/simple/ResourceFactoryImpl.java
    incubator/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/JCRWebdavServerServlet.java
    incubator/jackrabbit/trunk/jcr-server/webdav/project.properties
    incubator/jackrabbit/trunk/jcr-server/webdav/project.xml
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavException.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavLocatorFactory.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResource.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavResourceLocator.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/DavSession.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationConstants.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/ObservationResource.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionConstants.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/transaction/TransactionResource.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/LocateByHistoryReport.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/Report.java
    incubator/jackrabbit/trunk/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/VersionTreeReport.java

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/server/jcr/JCRWebdavServer.java Mon Mar 13 05:07:02 2006
@@ -17,11 +17,11 @@
 
 import org.apache.jackrabbit.server.SessionProvider;
 import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.DavServletRequest;
 import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavSessionProvider;
 import org.apache.jackrabbit.webdav.WebdavRequest;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.log4j.Logger;
 
@@ -98,30 +98,15 @@
     /**
      * Private inner class implementing the <code>DavSession</code> interface.
      */
-    private class DavSessionImpl implements DavSession {
-
-        /** the underlying jcr session */
-        private final Session session;
+    private class DavSessionImpl extends JcrDavSession {
 
         /**
          * Private constructor.
          *
-         * @param request
-         * @throws DavException in case a {@link javax.jcr.LoginException} or {@link javax.jcr.RepositoryException} occurs.
+         * @param session
          */
-        private DavSessionImpl(DavServletRequest request) throws DavException {
-            try {
-                String workspaceName = request.getRequestLocator().getWorkspaceName();
-                session = sessionProvider.getSession(request, repository, workspaceName);
-            } catch (LoginException e) {
-                // LoginException results in UNAUTHORIZED,
-                throw new JcrDavException(e);
-            } catch (RepositoryException e) {
-                // RepositoryException results in FORBIDDEN
-                throw new JcrDavException(e);
-            } catch (ServletException e) {
-                throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            }
+        private DavSessionImpl(Session session) {
+            super(session);
         }
 
         /**
@@ -144,34 +129,6 @@
         public void removeReference(Object reference) {
             cache.removeReference(this, reference);
         }
-
-        /**
-         * @see DavSession#getRepositorySession()
-         */
-        public Session getRepositorySession() {
-            return session;
-        }
-
-        /**
-         * @see DavSession#addLockToken(String)
-         */
-        public void addLockToken(String token) {
-            session.addLockToken(token);
-        }
-
-        /**
-         * @see DavSession#getLockTokens()
-         */
-        public String[] getLockTokens() {
-            return session.getLockTokens();
-        }
-
-        /**
-         * @see DavSession#removeLockToken(String)
-         */
-        public void removeLockToken(String token) {
-            session.removeLockToken(token);
-        }
     }
 
     /**
@@ -212,11 +169,12 @@
             }
             // no cached session present -> create new one.
             if (session == null) {
-                session = new DavSessionImpl(request);
+                Session repSession = getRepositorySession(request);
+                session = new DavSessionImpl(repSession);
                 sessionMap.put(session, new HashSet());
-                log.info("login: User '" + session.getRepositorySession().getUserID() + "' logged in.");
+                log.info("login: User '" + repSession.getUserID() + "' logged in.");
             } else {
-                log.info("login: Retrieved cached session for user '" + session.getRepositorySession().getUserID() + "'");
+                log.info("login: Retrieved cached session for user '" + getUserID(session) + "'");
             }
             addReference(session, request);
             return session;
@@ -256,8 +214,15 @@
                 if (referenceSet.isEmpty()) {
                     log.info("No more references present on webdav session -> clean up.");
                     sessionMap.remove(session);
-                    sessionProvider.releaseSession(session.getRepositorySession());
-                    log.info("Login: User '" + session.getRepositorySession().getUserID() + "' logged out");
+                    try {
+                        Session repSession = DavSessionImpl.getRepositorySession(session);
+                        sessionProvider.releaseSession(repSession);
+                        log.info("Login: User '" + getUserID(session) + "' logged out");
+                    } catch (DavException e) {
+                        // should not occure, since we original built a DavSessionImpl
+                        // that wraps a repository session.
+                        log.error("Unexpected error: " + e.getMessage(), e.getCause());
+                    }
                 } else {
                     log.debug(referenceSet.size() + " references remaining on webdav session " + session);
                 }
@@ -289,6 +254,42 @@
          */
         private DavSession getSessionByReference(Object reference) {
             return (DavSession) referenceToSessionMap.get(reference);
+        }
+
+        /**
+         * Retrieve the {@link Session} object for the given request.
+         *
+         * @param request
+         * @return JCR session object used to build the <code>DavSession</code>
+         * @throws DavException
+         * @throws DavException in case a {@link javax.jcr.LoginException} or {@link javax.jcr.RepositoryException} occurs.
+         */
+        private Session getRepositorySession(WebdavRequest request) throws DavException {
+            try {
+                String workspaceName = request.getRequestLocator().getWorkspaceName();
+                return sessionProvider.getSession(request, repository, workspaceName);
+            } catch (LoginException e) {
+                // LoginException results in UNAUTHORIZED,
+                throw new JcrDavException(e);
+            } catch (RepositoryException e) {
+                // RepositoryException results in FORBIDDEN
+                throw new JcrDavException(e);
+            } catch (ServletException e) {
+                throw new DavException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            }
+        }
+
+        private String getUserID(DavSession session) {
+            try {
+                Session s = DavSessionImpl.getRepositorySession(session);
+                if (s != null) {
+                    return s.getUserID();
+                }
+            } catch (DavException e) {
+                log.error(e);
+            }
+            // fallback
+            return session.toString();
         }
     }
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractItemResource.java Mon Mar 13 05:07:02 2006
@@ -20,7 +20,6 @@
 import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
 import org.apache.jackrabbit.webdav.version.report.ReportType;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavException;
@@ -60,7 +59,8 @@
      * @param locator
      * @param session
      */
-    AbstractItemResource(DavResourceLocator locator, DavSession session, DavResourceFactory factory, Item item) {
+    AbstractItemResource(DavResourceLocator locator, JcrDavSession session,
+                         DavResourceFactory factory, Item item) {
         super(locator, session, factory);
         this.item = item;
 
@@ -156,8 +156,8 @@
         }
 
         try {
-            String itemPath = getLocator().getJcrPath();
-            String destItemPath = destination.getLocator().getJcrPath();
+            String itemPath = getLocator().getRepositoryPath();
+            String destItemPath = destination.getLocator().getRepositoryPath();
             if (getTransactionId() == null) {
                 // if not part of a transaction directely import on workspace
                 getRepositorySession().getWorkspace().move(itemPath, destItemPath);
@@ -199,8 +199,8 @@
         }
 
         try {
-            String itemPath = getLocator().getJcrPath();
-            String destItemPath = destination.getLocator().getJcrPath();
+            String itemPath = getLocator().getRepositoryPath();
+            String destItemPath = destination.getLocator().getRepositoryPath();
             Workspace workspace = getRepositorySession().getWorkspace();
             if (getLocator().isSameWorkspace(destination.getLocator())) {
                 workspace.copy(itemPath, destItemPath);

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/AbstractResource.java Mon Mar 13 05:07:02 2006
@@ -88,7 +88,7 @@
     private static Logger log = Logger.getLogger(AbstractResource.class);
 
     private final DavResourceLocator locator;
-    private final DavSession session;
+    private final JcrDavSession session;
     private final DavResourceFactory factory;
 
     private SubscriptionManager subsMgr;
@@ -108,11 +108,11 @@
      * @param locator
      * @param session
      */
-    AbstractResource(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
+    AbstractResource(DavResourceLocator locator, JcrDavSession session,
+                     DavResourceFactory factory) {
         if (session == null) {
-            throw new IllegalArgumentException("Creating AbstractItemResource: DavSession must not be null.");
+            throw new IllegalArgumentException("Creating AbstractItemResource: DavSession must not be null and must provide a JCR session.");
         }
-
         this.locator = locator;
         this.session = session;
         this.factory = factory;
@@ -161,7 +161,7 @@
      */
     void setModificationTime(long modificationTime) {
         if (modificationTime > IOUtil.UNDEFINED_TIME) {
-        this.modificationTime = modificationTime;
+            this.modificationTime = modificationTime;
             String lastModified = IOUtil.getLastModified(modificationTime);
             properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, lastModified));
         }
@@ -531,7 +531,7 @@
 
         if (supportedReports.isSupportedReport(reportInfo)) {
             Report report = ReportType.getType(reportInfo).createReport(this, reportInfo);
-                return report;
+            return report;
         } else {
             throw new DavException(DavServletResponse.SC_UNPROCESSABLE_ENTITY, "Unkown report "+ reportInfo.getReportName() +"requested.");
         }
@@ -591,7 +591,7 @@
         // create a new resource object
         try {
             DavResource res;
-            if (getRepositorySession().itemExists(loc.getJcrPath())) {
+            if (getRepositorySession().itemExists(loc.getRepositoryPath())) {
                 res = createResourceFromLocator(loc);
             } else {
                 throw new DavException(DavServletResponse.SC_NOT_FOUND);
@@ -608,7 +608,7 @@
      * @see org.apache.jackrabbit.webdav.search.SearchResource#getQueryGrammerSet()
      */
     public QueryGrammerSet getQueryGrammerSet() {
-        return new SearchResourceImpl(getLocator(), getSession()).getQueryGrammerSet();
+        return new SearchResourceImpl(getLocator(), session).getQueryGrammerSet();
     }
 
     /**
@@ -618,7 +618,7 @@
      * @see SearchResource#search(org.apache.jackrabbit.webdav.search.SearchInfo)
      */
     public MultiStatus search(SearchInfo sInfo) throws DavException {
-        return new SearchResourceImpl(getLocator(), getSession()).search(sInfo);
+        return new SearchResourceImpl(getLocator(), session).search(sInfo);
     }
     //--------------------------------------------------------------------------
     /**
@@ -723,7 +723,7 @@
      * @return repository session present in the {@link #session}.
      */
     protected Session getRepositorySession() {
-        return getSession().getRepositorySession();
+        return session.getRepositorySession();
     }
 
     /**

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavLocatorFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavLocatorFactoryImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavLocatorFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavLocatorFactoryImpl.java Mon Mar 13 05:07:02 2006
@@ -289,9 +289,9 @@
         /**
          * Returns the same as {@link #getResourcePath()}. No encoding is performed
          * at all.
-         * @see DavResourceLocator#getJcrPath()
+         * @see DavResourceLocator#getRepositoryPath()
          */
-        public String getJcrPath() {
+        public String getRepositoryPath() {
             return getResourcePath();
         }
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DavResourceFactoryImpl.java Mon Mar 13 05:07:02 2006
@@ -40,7 +40,6 @@
 import javax.jcr.Node;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
-import javax.jcr.Session;
 
 /**
  * <code>DavResourceFactoryImpl</code>...
@@ -82,8 +81,9 @@
     public DavResource createResource(DavResourceLocator locator,
                                       DavServletRequest request,
                                       DavServletResponse response) throws DavException {
+        JcrDavSession.checkImplementation(request.getDavSession());
+        JcrDavSession session = (JcrDavSession)request.getDavSession();
 
-        DavSession session = request.getDavSession();
         DavResource resource;
         if (locator.isRootLocation()) {
             resource = new RootCollection(locator, session, this);
@@ -135,16 +135,18 @@
      * root location}.
      */
     public DavResource createResource(DavResourceLocator locator, DavSession session) throws DavException {
+        JcrDavSession.checkImplementation(session);
+        JcrDavSession sessionImpl = (JcrDavSession)session;
         DavResource resource;
         try {
-            resource = createResourceForItem(locator, session);
+            resource = createResourceForItem(locator, sessionImpl);
         } catch (RepositoryException e) {
             log.info("Creating resource for non-existing repository item ...");
             if (locator.isRootLocation()) {
-                resource =  new RootCollection(locator, session, this);
+                resource =  new RootCollection(locator, sessionImpl, this);
             } else {
-		// todo: is this correct?
-		resource = new VersionControlledItemCollection(locator, session, this, null);
+                // todo: is this correct?
+                resource = new VersionControlledItemCollection(locator, sessionImpl, this, null);
             }
         }
 
@@ -161,33 +163,33 @@
      * unspecified nodes and finally property items.
      *
      * @param locator
-     * @param session
+     * @param sessionImpl
      * @return DavResource representing a repository item.
      * @throws RepositoryException if {@link javax.jcr.Session#getItem(String)} fails.
      */
-    private DavResource createResourceForItem(DavResourceLocator locator, DavSession session) throws RepositoryException {
+    private DavResource createResourceForItem(DavResourceLocator locator, JcrDavSession sessionImpl) throws RepositoryException, DavException {
         DavResource resource;
-        Item item = getItem(session, locator);
+        Item item = getItem(sessionImpl, locator);
         if (item.isNode()) {
             // create special resources for Version and VersionHistory
             if (item instanceof Version) {
-                resource = new VersionItemCollection(locator, session, this, item);
+                resource = new VersionItemCollection(locator, sessionImpl, this, item);
             } else if (item instanceof VersionHistory) {
-                resource = new VersionHistoryItemCollection(locator, session, this, item);
+                resource = new VersionHistoryItemCollection(locator, sessionImpl, this, item);
             } else if (ItemResourceConstants.ROOT_ITEM_PATH.equals(item.getPath())) {
-                resource =  new RootItemCollection(locator, session, this, item);
+                resource =  new RootItemCollection(locator, sessionImpl, this, item);
             }  else{
-                resource = new VersionControlledItemCollection(locator, session, this, item);
+                resource = new VersionControlledItemCollection(locator, sessionImpl, this, item);
             }
         } else {
-            resource = new DefaultItemResource(locator, session, this, item);
+            resource = new DefaultItemResource(locator, sessionImpl, this, item);
         }
         return resource;
     }
 
-    private Item getItem(DavSession davSession, DavResourceLocator locator) throws PathNotFoundException, RepositoryException {
-        Session s = davSession.getRepositorySession();
-        return s.getItem(locator.getJcrPath());
+    private Item getItem(JcrDavSession sessionImpl, DavResourceLocator locator)
+        throws PathNotFoundException, RepositoryException {
+        return sessionImpl.getRepositorySession().getItem(locator.getRepositoryPath());
     }
 
     /**

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemCollection.java Mon Mar 13 05:07:02 2006
@@ -25,7 +25,6 @@
 import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.lock.JcrActiveLock;
@@ -92,7 +91,8 @@
      * @param locator
      * @param session
      */
-    protected DefaultItemCollection(DavResourceLocator locator, DavSession session,
+    protected DefaultItemCollection(DavResourceLocator locator,
+                                    JcrDavSession session,
                                     DavResourceFactory factory, Item item) {
         super(locator, session, factory, item);
         if (exists() && !(item instanceof Node)) {
@@ -138,7 +138,7 @@
      */
     public InputStream getStream() {
         if (!initedProps)  {
-        initProperties();
+            initProperties();
         }
         if (content != null) {
             try {
@@ -329,8 +329,8 @@
         try {
             Node n = (Node) item;
             InputStream in = (inputContext != null) ? inputContext.getInputStream() : null;
-            String itemPath = getLocator().getJcrPath();
-            String memberName = getItemName(resource.getLocator().getJcrPath());
+            String itemPath = getLocator().getRepositoryPath();
+            String memberName = getItemName(resource.getLocator().getRepositoryPath());
             if (resource.isCollection()) {
                 if (in == null) {
                     // MKCOL without a request body, try if a default-primary-type is defined.
@@ -374,16 +374,16 @@
      */
     public DavResourceIterator getMembers() {
         ArrayList memberList = new ArrayList();
-	if (exists()) {
-	    try {
+        if (exists()) {
+            try {
                 Node n = (Node)item;
                 // add all node members
-		NodeIterator it = n.getNodes();
-		while (it.hasNext()) {
+                NodeIterator it = n.getNodes();
+                while (it.hasNext()) {
                     Node node = it.nextNode();
                     DavResourceLocator loc = getLocatorFromItem(node);
-		    memberList.add(createResourceFromLocator(loc));
-		}
+                    memberList.add(createResourceFromLocator(loc));
+                }
                 // add all property members
                 PropertyIterator propIt = n.getProperties();
                 while (propIt.hasNext()) {
@@ -391,15 +391,15 @@
                     DavResourceLocator loc = getLocatorFromItem(prop);
                     memberList.add(createResourceFromLocator(loc));
                 }
-	    } catch (RepositoryException e) {
-		// ignore
+            } catch (RepositoryException e) {
+                // ignore
                 log.error(e.getMessage());
-	    } catch (DavException e) {
+            } catch (DavException e) {
                 // should never occur.
                 log.error(e.getMessage());
             }
-	}
-	return new DavResourceIteratorImpl(memberList);
+        }
+        return new DavResourceIteratorImpl(memberList);
     }
 
     /**
@@ -414,7 +414,7 @@
     public void removeMember(DavResource member) throws DavException {
         Session session = getRepositorySession();
         try {
-            String itemPath = member.getLocator().getJcrPath();
+            String itemPath = member.getLocator().getRepositoryPath();
             if (!exists() || !session.itemExists(itemPath)) {
                 throw new DavException(DavServletResponse.SC_NOT_FOUND);
             }
@@ -740,7 +740,7 @@
      * <li>{@link ExportViewReport export view report}</li>
      * <li>{@link LocateCorrespondingNodeReport locate corresponding node report}</li>
      * </ul>
-     * 
+     *
      * @see org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty
      */
     protected void initSupportedReports() {
@@ -763,7 +763,7 @@
                 content = File.createTempFile(prefix, null, null);
                 content.deleteOnExit();
                 FileOutputStream out = new FileOutputStream(content);
-                getSession().getRepositorySession().exportSystemView(item.getPath(), out, false, true);
+                getRepositorySession().exportSystemView(item.getPath(), out, false, true);
                 out.close();
                 properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, new Long(content.length())));
                 properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, "text/xml"));
@@ -777,25 +777,25 @@
             Node n = (Node)item;
             // overwrite the default modificationtime if possible
             try {
-		if (n.hasProperty(JcrConstants.JCR_LASTMODIFIED)) {
+                if (n.hasProperty(JcrConstants.JCR_LASTMODIFIED)) {
                     setModificationTime(n.getProperty(JcrConstants.JCR_LASTMODIFIED).getLong());
-		}
-	    } catch (RepositoryException e) {
-		log.warn("Error while accessing jcr:lastModified property");
-	    }
+                }
+            } catch (RepositoryException e) {
+                log.warn("Error while accessing jcr:lastModified property");
+            }
             // overwrite the default creation date if possible
             try {
                 if (n.hasProperty(JcrConstants.JCR_CREATED)) {
                     long creationTime = n.getProperty(JcrConstants.JCR_CREATED).getValue().getLong();
                     properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE,
-                            DavConstants.creationDateFormat.format(new Date(creationTime))));
+                        DavConstants.creationDateFormat.format(new Date(creationTime))));
                 }
             } catch (RepositoryException e) {
                 log.warn("Error while accessing jcr:created property");
             }
 
             // add node-specific resource properties
-	    try {
+            try {
                 properties.add(new NodeTypeProperty(JCR_PRIMARYNODETYPE, n.getPrimaryNodeType(), false));
                 properties.add(new NodeTypeProperty(JCR_MIXINNODETYPES, n.getMixinNodeTypes(), false));
                 properties.add(new DefaultDavProperty(JCR_INDEX, new Integer(n.getIndex()), true));
@@ -860,4 +860,4 @@
         }
         addHrefProperty(name, (Item[]) l.toArray(new Item[l.size()]), isProtected);
     }
-}
\ No newline at end of file
+}

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Mon Mar 13 05:07:02 2006
@@ -15,7 +15,6 @@
  */
 package org.apache.jackrabbit.webdav.jcr;
 
-import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
@@ -23,7 +22,6 @@
 import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.property.LengthsProperty;
@@ -64,7 +62,7 @@
      * @param locator
      * @param session
      */
-    public DefaultItemResource(DavResourceLocator locator, DavSession session,
+    public DefaultItemResource(DavResourceLocator locator, JcrDavSession session,
                                DavResourceFactory factory, Item item) {
         super(locator, session, factory, item);
     }
@@ -137,18 +135,15 @@
         }
         try {
             Property prop = (Property) item;
-            int type = prop.getType();
+            int defaultType = prop.getType();
+            ValuesProperty vp = new ValuesProperty(property, defaultType);
             if (property.getName().equals(JCR_VALUE)) {
-                String strVal = (property.getValue() != null) ? String.valueOf(property.getValue()) : "";
-                Value val = ValueHelper.deserialize(strVal, type, false);
-                prop.setValue(val);
+                prop.setValue(vp.getJcrValue(vp.getValueType()));
             } else if (property.getName().equals(JCR_VALUES)) {
-                prop.setValue(new ValuesProperty(property).getValues(prop.getType()));
+                prop.setValue(vp.getJcrValues());
             } else {
                 throw new DavException(DavServletResponse.SC_CONFLICT);
             }
-        } catch (IllegalArgumentException e) {
-            throw new DavException(DavServletResponse.SC_BAD_REQUEST, e.getMessage());
         } catch (RepositoryException e) {
             throw new JcrDavException(e);
         }
@@ -279,7 +274,7 @@
                     properties.add(new ValuesProperty(prop.getValues()));
                     properties.add(new LengthsProperty(prop.getLengths()));
                 } else {
-                    properties.add(new DefaultDavProperty(JCR_VALUE, ValueHelper.serialize(prop.getValue(), false)));
+                    properties.add(new ValuesProperty(prop.getValue()));
                     properties.add(new DefaultDavProperty(JCR_LENGTH, String.valueOf(prop.getLength()), true));
                 }
             } catch (RepositoryException e) {

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java Mon Mar 13 05:07:02 2006
@@ -23,6 +23,8 @@
 import org.apache.jackrabbit.webdav.search.SearchResource;
 import org.apache.jackrabbit.webdav.observation.ObservationResource;
 
+import javax.jcr.PropertyType;
+
 /**
  * <code>ItemResourceConstants</code> provides constants for any resources
  * representing repository items.
@@ -57,6 +59,11 @@
     // xml element names
     public static final String XML_PRIMARYNODETYPE = "primarynodetype";
     public static final String XML_VALUE = "value";
+    /**
+     * 'type' attribute for the {@link #XML_VALUE value} element, reflecting the
+     * {@link PropertyType type} of the value being transported.
+     */
+    public static final String ATTR_VALUE_TYPE = "type";
     public static final String XML_LENGTH = "length";
     public static final String XML_EXCLUSIVE_SESSION_SCOPED = "exclusive-session-scoped";
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java Mon Mar 13 05:07:02 2006
@@ -78,19 +78,40 @@
 
     private Class exceptionClass;
 
-    public JcrDavException(Exception e, int errorCode) {
-        super(errorCode, e.getMessage());
-        exceptionClass = e.getClass();
+    /**
+     * Create a new <code>JcrDavException</code>.
+     *
+     * @param cause The original cause of this <code>DavException</code>. Note, that
+     * in contrast to {@link Throwable#Throwable(Throwable)}, {@link Throwable#Throwable(String, Throwable)} and
+     * {@link Throwable#initCause(Throwable)} the cause must not be <code>null</code>.
+     * @param errorCode Status code for the response.
+     * @throws NullPointerException if the given exception is <code>null</code>.
+     * @see DavException#DavException(int, String)
+     * @see DavException#DavException(int)
+     */
+    public JcrDavException(Throwable cause, int errorCode) {
+        super(errorCode, cause);
+        exceptionClass = cause.getClass();
         if (log.isDebugEnabled()) {
-            log.debug("Handling exception with error code " + errorCode, e);
+            log.debug("Handling exception with error code " + errorCode, cause);
         }
     }
 
-    public JcrDavException(RepositoryException e) {
-        this(e, ((Integer)codeMap.get(e.getClass())).intValue());
+    /**
+     * Same as {@link JcrDavException#JcrDavException(Throwable, int)} where the
+     * error code is retrieved from an internal mapping.
+     *
+     * @param cause Cause of this DavException
+     * @throws NullPointerException if the given exception is <code>null</code>.
+     * @see JcrDavException#JcrDavException(Throwable, int)
+     */
+    public JcrDavException(RepositoryException cause) {
+        this(cause, ((Integer)codeMap.get(cause.getClass())).intValue());
     }
 
     /**
+     * Always returns true.
+     *
      * @return true
      */
     public boolean hasErrorCondition() {
@@ -113,5 +134,4 @@
         error.appendChild(excep);
         return error;
     }
-
-}
+}
\ No newline at end of file

Added: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java?rev=385540&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java (added)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java Mon Mar 13 05:07:02 2006
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.webdav.jcr;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+
+import javax.jcr.Session;
+
+/**
+ * <code>JcrDavSession</code> specific base implementation of the
+ * <code>DavSession</code> interface, which simply wraps a {@link Session}
+ * object. This implementation adds a utility method that allows to
+ * {@link #getRepositorySession() unwrap} the underlying repository session.
+ * <br>
+ * Note, that in this basic implementation the following methods are simply
+ * forwarded to the corresponding call on <code>Session</code>:
+ * <ul>
+ * <li>{@link #getLockTokens()}         =&gt; {@link Session#getLockTokens()}</li>
+ * <li>{@link #addLockToken(String)}    =&gt; {@link Session#addLockToken(String)}</li>
+ * <li>{@link #removeLockToken(String)} =&gt; {@link Session#removeLockToken(String)}</li>
+ * </ul>
+ * Subclasses may overwrite or extend this behaviour.
+ */
+public abstract class JcrDavSession implements DavSession {
+
+    private static Logger log = Logger.getLogger(JcrDavSession.class);
+
+    /** the underlying jcr session */
+    private final Session session;
+
+    protected JcrDavSession(Session session) {
+        this.session = session;
+    }
+
+    /**
+     *
+     * @param davSession
+     * @throws DavException
+     */
+    public static void checkImplementation(DavSession davSession) throws DavException {
+        if (!(davSession instanceof JcrDavSession)) {
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "JCR specific DavSession expected. Found: " + davSession);
+        }
+    }
+
+    /**
+     *
+     * @param davSession
+     * @return
+     * @throws DavException
+     */
+    public static Session getRepositorySession(DavSession davSession) throws DavException {
+        checkImplementation(davSession);
+        return ((JcrDavSession)davSession).getRepositorySession();
+    }
+
+    /**
+     * Unwrap the {@link Session repository session} object.
+     *
+     * @return the session object wrapped by this <code>DavSession</code>
+     */
+    public Session getRepositorySession() {
+        return session;
+    }
+
+    //---------------------------------------------------------< DavSession >---
+    /**
+     *
+     * @param token
+     * @see DavSession#addLockToken(String)
+     */
+    public void addLockToken(String token) {
+        session.addLockToken(token);
+    }
+
+    /**
+     *
+     * @return
+     * @see DavSession#getLockTokens()
+     */
+    public String[] getLockTokens() {
+        return session.getLockTokens();
+    }
+
+    /**
+     *
+     * @param token
+     * @see DavSession#removeLockToken(String)
+     */
+    public void removeLockToken(String token) {
+        session.removeLockToken(token);
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavSession.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java Mon Mar 13 05:07:02 2006
@@ -22,7 +22,7 @@
 import org.apache.jackrabbit.webdav.DavResourceIteratorImpl;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.DavMethods;
 import org.apache.jackrabbit.webdav.io.InputContext;
 import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
 import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
@@ -53,7 +53,8 @@
      * @param locator
      * @param session
      */
-    protected RootCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
+    protected RootCollection(DavResourceLocator locator, JcrDavSession session,
+                             DavResourceFactory factory) {
         super(locator, session, factory);
         setModificationTime(new Date().getTime());
 
@@ -145,7 +146,7 @@
     public DavResourceIterator getMembers() {
         List memberList = new ArrayList();
         try {
-            String[] wsNames = getSession().getRepositorySession().getWorkspace().getAccessibleWorkspaceNames();
+            String[] wsNames = getRepositorySession().getWorkspace().getAccessibleWorkspaceNames();
             for (int i = 0; i < wsNames.length; i++) {
                 DavResourceLocator childLoc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), "/"+wsNames[i], ItemResourceConstants.ROOT_ITEM_PATH);
                 memberList.add(createResourceFromLocator(childLoc));

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java Mon Mar 13 05:07:02 2006
@@ -19,7 +19,6 @@
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceFactory;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.jcr.property.NamespacesProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
@@ -37,9 +36,8 @@
  * <code>RootItemCollection</code> represents the root node of the underlying
  * repository. However, the display name the name of the workspace is returned
  * the root node is located.
- *
- * @todo currently the jcr root node is the same for all workspace resources... this is wrong...
  */
+//todo currently the jcr root node is the same for all workspace resources... this is wrong...
 public class RootItemCollection extends VersionControlledItemCollection {
 
     private static Logger log = Logger.getLogger(RootItemCollection.class);
@@ -50,7 +48,7 @@
      * @param locator
      * @param session
      */
-    protected RootItemCollection(DavResourceLocator locator, DavSession session,
+    protected RootItemCollection(DavResourceLocator locator, JcrDavSession session,
                                  DavResourceFactory factory, Item item) {
         super(locator, session, factory, item);
     }
@@ -98,33 +96,33 @@
     public void setProperty(DavProperty property) throws DavException {
         if (JCR_NAMESPACES.equals(property.getName())) {
             NamespacesProperty nsp = new NamespacesProperty(property);
-                try {
+            try {
                 Properties changes = nsp.getNamespaces();
-                    NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
-                    String[] registeredPrefixes = nsReg.getPrefixes();
-                    for (int i = 0; i < registeredPrefixes.length; i++) {
-                        String prfx = registeredPrefixes[i];
+                NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
+                String[] registeredPrefixes = nsReg.getPrefixes();
+                for (int i = 0; i < registeredPrefixes.length; i++) {
+                    String prfx = registeredPrefixes[i];
                     if (!changes.containsKey(prfx)) {
-                            // prefix not present amongst the new values any more > unregister
-                            nsReg.unregisterNamespace(prfx);
+                        // prefix not present amongst the new values any more > unregister
+                        nsReg.unregisterNamespace(prfx);
                     } else if (changes.get(prfx).equals(nsReg.getURI(prfx))) {
-                            // present with same uri-value >> no action required
+                        // present with same uri-value >> no action required
                         changes.remove(prfx);
-                        }
                     }
+                }
 
-                    // try to register any prefix/uri pair that has a changed uri or
-                    // it has not been present before.
+                // try to register any prefix/uri pair that has a changed uri or
+                // it has not been present before.
                 Iterator prefixIt = changes.keySet().iterator();
-                    while (prefixIt.hasNext()) {
-                        String prefix = (String)prefixIt.next();
+                while (prefixIt.hasNext()) {
+                    String prefix = (String)prefixIt.next();
                     String uri = (String)changes.get(prefix);
-                        nsReg.registerNamespace(prefix, uri);
-                    }
-                } catch (RepositoryException e) {
-                    throw new JcrDavException(e);
+                    nsReg.registerNamespace(prefix, uri);
                 }
-            } else {
+            } catch (RepositoryException e) {
+                throw new JcrDavException(e);
+            }
+        } else {
             super.setProperty(property);
         }
     }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java Mon Mar 13 05:07:02 2006
@@ -22,7 +22,6 @@
 import org.apache.jackrabbit.webdav.DavResourceFactory;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
@@ -76,7 +75,8 @@
      * @param session
      */
     public VersionControlledItemCollection(DavResourceLocator locator,
-                                           DavSession session, DavResourceFactory factory,
+                                           JcrDavSession session,
+                                           DavResourceFactory factory,
                                            Item item) {
         super(locator, session, factory, item);
         if (exists() && !(item instanceof Node)) {
@@ -338,7 +338,7 @@
                 String[] hrefs = updateInfo.getVersionHref();
                 Version[] versions = new Version[hrefs.length];
                 for (int  i = 0; i < hrefs.length; i++) {
-                    String itemPath = getLocatorFromHref(hrefs[i]).getJcrPath();
+                    String itemPath = getLocatorFromHref(hrefs[i]).getRepositoryPath();
                     versions[i] = vh.getVersion(getItemName(itemPath));
                 }
                 if (versions.length == 1) {

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionImpl.java Mon Mar 13 05:07:02 2006
@@ -53,6 +53,36 @@
     private static Logger log = Logger.getLogger(SubscriptionImpl.class);
     private static final long DEFAULT_TIMEOUT = 300000; // 5 minutes
 
+    /**
+     * Element representing the 'nodeadded' event type.
+     * @see javax.jcr.observation.Event#NODE_ADDED
+     */
+    private static final String EVENT_NODEADDED = "nodeadded";
+
+    /**
+     * Element representing the 'noderemoved' event type.
+     * @see javax.jcr.observation.Event#NODE_REMOVED
+     */
+    private static final String EVENT_NODEREMOVED = "noderemoved";
+
+    /**
+     * Element representing the 'propertyadded' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_ADDED
+     */
+    private static final String EVENT_PROPERTYADDED = "propertyadded";
+
+    /**
+     * Element representing the 'propertyremoved' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_REMOVED
+     */
+    private static final String EVENT_PROPERTYREMOVED = "propertyremoved";
+
+    /**
+     * Element representing the 'propertychanged' event type.
+     * @see javax.jcr.observation.Event#PROPERTY_CHANGED
+     */
+    private static final String EVENT_PROPERTYCHANGED = "propertychanged";
+
     private SubscriptionInfo info;
     private long expirationTime;
 

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/observation/SubscriptionManagerImpl.java Mon Mar 13 05:07:02 2006
@@ -18,7 +18,6 @@
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.observation.EventDiscovery;
 import org.apache.jackrabbit.webdav.observation.ObservationResource;
@@ -26,9 +25,11 @@
 import org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery;
 import org.apache.jackrabbit.webdav.observation.SubscriptionInfo;
 import org.apache.jackrabbit.webdav.observation.SubscriptionManager;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.log4j.Logger;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.observation.ObservationManager;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -39,9 +40,8 @@
  * <code>SubscriptionManager</code> collects all subscriptions requested, handles
  * the subscription timeout and provides METHODS to discover subscriptions
  * present on a given resource as well as events for an specific subscription.
- *
- * @todo make sure all expired subscriptions are removed!
  */
+// todo: make sure all expired subscriptions are removed!
 public class SubscriptionManagerImpl implements SubscriptionManager {
 
     private static Logger log = Logger.getLogger(SubscriptionManager.class);
@@ -57,9 +57,9 @@
      * no subscriptions present.
      *
      * @param resource
-     * @todo is it correct to return subscriptions made by another session?
      */
     public SubscriptionDiscovery getSubscriptionDiscovery(ObservationResource resource) {
+        // todo: is it correct to return subscriptions made by another session?
         Subscription[] subsForResource = subscriptions.getByPath(resource.getLocator());
         return new SubscriptionDiscovery(subsForResource);
     }
@@ -79,20 +79,19 @@
             throws DavException {
 
         SubscriptionImpl subscription;
-        DavSession session = resource.getSession();
         if (subscriptionId == null) {
             // new subscription
             subscription = new SubscriptionImpl(info, resource);
-            registerSubscription(subscription, session);
+            registerSubscription(subscription, resource);
 
             // ajust references to this subscription
             subscriptions.put(subscription.getSubscriptionId(), subscription);
-            session.addReference(subscription.getSubscriptionId());
+            resource.getSession().addReference(subscription.getSubscriptionId());
         } else {
             // refresh/modify existing one
             subscription = validate(subscriptionId, resource);
             subscription.setInfo(info);
-            registerSubscription(subscription, session);
+            registerSubscription(subscription, resource);
         }
         return subscription;
     }
@@ -102,14 +101,15 @@
      * repository's observation manager.
      *
      * @param subscription
-     * @param session
+     * @param resource
      * @throws DavException
      */
-    private void registerSubscription(SubscriptionImpl subscription, DavSession session)
-            throws DavException {
+    private void registerSubscription(SubscriptionImpl subscription,
+                                      ObservationResource resource) throws DavException {
         try {
-            ObservationManager oMgr = session.getRepositorySession().getWorkspace().getObservationManager();
-            String itemPath = subscription.getLocator().getJcrPath();
+            Session session = getRepositorySession(resource);
+            ObservationManager oMgr = session.getWorkspace().getObservationManager();
+            String itemPath = subscription.getLocator().getRepositoryPath();
             oMgr.addEventListener(subscription, subscription.getEventTypes(),
                     itemPath, subscription.isDeep(),
                     subscription.getUuidFilters(),
@@ -134,26 +134,28 @@
             throws DavException {
 
         SubscriptionImpl subs = validate(subscriptionId, resource);
-        unregisterSubscription(subs, resource.getSession());
+        unregisterSubscription(subs, resource);
     }
 
     /**
      * Remove the event listener defined by the specified subscription from
-     * the repository's observation manager.
+     * the repository's observation manager and clean up the references present
+     * on the <code>DavSession</code>.
      *
      * @param subscription
-     * @param session
+     * @param resource
      * @throws DavException
      */
     private void unregisterSubscription(SubscriptionImpl subscription,
-                                        DavSession session) throws DavException {
+                                        ObservationResource resource) throws DavException {
         try {
-            session.getRepositorySession().getWorkspace().getObservationManager().removeEventListener(subscription);
+            Session session = getRepositorySession(resource);
+            session.getWorkspace().getObservationManager().removeEventListener(subscription);
             String sId = subscription.getSubscriptionId();
 
             // clean up any references
             subscriptions.remove(sId);
-            session.removeReference(sId);
+            resource.getSession().removeReference(sId);
 
         } catch (RepositoryException e) {
             log.error("Unable to remove eventlistener: "+e.getMessage());
@@ -199,13 +201,21 @@
                 throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Attempt to operate on subscription with invalid resource path.");
             }
             if (subs.isExpired()) {
-                unregisterSubscription(subs, resource.getSession());
+                unregisterSubscription(subs, resource);
                 throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Attempt to  operate on expired subscription.");
             }
             return subs;
         } else {
             throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Attempt to modify or to poll for non-existing subscription.");
         }
+    }
+
+    /**
+     * @param resource
+     * @return JCR session
+     */
+    private static Session getRepositorySession(ObservationResource resource) throws DavException {
+        return JcrDavSession.getRepositorySession(resource.getSession());
     }
 
     /**

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/property/ValuesProperty.java Mon Mar 13 05:07:02 2006
@@ -18,8 +18,11 @@
 
 import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
 import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
 import org.apache.jackrabbit.value.ValueHelper;
 import org.apache.log4j.Logger;
 import org.w3c.dom.Element;
@@ -45,62 +48,87 @@
     private final Value[] jcrValues;
 
     /**
+     * Create a new <code>ValuesProperty</code> from the given single {@link Value}.
+     *
+     * @param value Array of Value objects as obtained from the JCR property.
+     */
+    public ValuesProperty(Value value) {
+        super(JCR_VALUE, false);
+        // finally set the value to the DavProperty
+        jcrValues = (value == null) ? new Value[0] : new Value[] {value};
+    }
+
+    /**
      * Create a new <code>ValuesProperty</code> from the given {@link javax.jcr.Value Value
      * array}.
      *
      * @param values Array of Value objects as obtained from the JCR property.
      */
-    public ValuesProperty(Value[] values) throws ValueFormatException, RepositoryException {
-	super(JCR_VALUES, false);
-	// finally set the value to the DavProperty
-	jcrValues = values;
+    public ValuesProperty(Value[] values) {
+        super(JCR_VALUES, false);
+        // finally set the value to the DavProperty
+        jcrValues = (values == null) ? new Value[0] : values;
     }
-    
+
     /**
      * Wrap the specified <code>DavProperty</code> in a new <code>ValuesProperty</code>.
      *
      * @param property
+     * @param defaultType default type of the values to be deserialized. If however
+     * the {@link #XML_VALUE 'value'} elements provide a {@link #ATTR_VALUE_TYPE 'type'}
+     * attribute, the default value is ignored.
      */
-    public ValuesProperty(DavProperty property) throws RepositoryException {
-	super(JCR_VALUES, false);
+    public ValuesProperty(DavProperty property, int defaultType) throws RepositoryException, DavException {
+        super(property.getName(), false);
 
-	if (!JCR_VALUES.equals(property.getName())) {
-	    throw new IllegalArgumentException("ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
-	}
+        if (!(JCR_VALUES.equals(property.getName()) || JCR_VALUE.equals(getName()))) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName());
+        }
 
-	List valueElements = new ArrayList();
+        // retrieve jcr-values from child 'value'-element(s)
+        List valueElements = new ArrayList();
         Object propValue = property.getValue();
-        if (propValue != null) {
+        if (propValue == null) {
+            jcrValues = new Value[0];
+        } else { /* not null propValue */
             if (isValueElement(propValue)) {
                 valueElements.add(propValue);
             } else if (propValue instanceof List) {
-	    Iterator elemIt = ((List)property.getValue()).iterator();
-	    while (elemIt.hasNext()) {
-		Object el = elemIt.next();
-		/* make sure, only Elements with name 'value' are used for
-		* the 'value' field. any other content (other elements, text,
-		* comment etc.) is ignored. NO bad-request/conflict error is
-		* thrown.
-		*/
+                Iterator elemIt = ((List)property.getValue()).iterator();
+                while (elemIt.hasNext()) {
+                    Object el = elemIt.next();
+                    /* make sure, only Elements with name 'value' are used for
+                    * the 'value' field. any other content (other elements, text,
+                    * comment etc.) is ignored. NO bad-request/conflict error is
+                    * thrown.
+                    */
                     if (isValueElement(propValue)) {
-		    valueElements.add(el);
-		}
-	    }
+                        valueElements.add(el);
+                    }
+                }
+            }
+            /* fill the 'value' with the valid 'value' elements found before */
+            Element[] elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
+            jcrValues = new Value[elems.length];
+            for (int i = 0; i < elems.length; i++) {
+                String value = DomUtil.getText(elems[i]);
+                String typeStr = DomUtil.getAttribute(elems[i], ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE);
+                int type = (typeStr == null) ? defaultType : PropertyType.valueFromName(typeStr);
+                jcrValues[i] = ValueHelper.deserialize(value, type, false);
             }
         }
-	    /* fill the 'value' with the valid 'value' elements found before */
-        Element[] elems = (Element[])valueElements.toArray(new Element[valueElements.size()]);
-	jcrValues = new Value[elems.length];
-	for (int i = 0; i < elems.length; i++) {
-            String value = DomUtil.getText(elems[i]);
-	    jcrValues[i] = ValueHelper.deserialize(value, PropertyType.STRING, false);
-	}
-	}
+    }
 
     private static boolean isValueElement(Object obj) {
         return obj instanceof Element && XML_VALUE.equals(((Element)obj).getLocalName());
     }
 
+    private void checkPropertyName(DavPropertyName reqName) throws ValueFormatException {
+        if (!reqName.equals(getName())) {
+            throw new ValueFormatException("Attempt to retrieve mulitple values from single property '" + getName() + "'.");
+        }
+    }
+
     /**
      * Converts the value of this property to a {@link javax.jcr.Value value array}.
      *
@@ -108,12 +136,55 @@
      * @throws ValueFormatException if convertion of the internal jcr values to
      * the specified value type fails.
      */
-    public Value[] getValues(int propertyType) throws ValueFormatException {
+    public Value[] getJcrValues(int propertyType) throws ValueFormatException {
+        checkPropertyName(JCR_VALUES);
         Value[] vs = new Value[jcrValues.length];
         for (int i = 0; i < jcrValues.length; i++) {
             vs[i] = ValueHelper.convert(jcrValues[i], propertyType);
-	}
-	return jcrValues;
+        }
+        return jcrValues;
+    }
+
+    /**
+     * Returns the internal property value as jcr <code>Value</code> array
+     * 
+     * @return
+     */
+    public Value[] getJcrValues() throws ValueFormatException {
+        checkPropertyName(JCR_VALUES);
+        return jcrValues;
+    }
+
+    /**
+     *
+     * @param propertyType
+     * @return
+     * @throws ValueFormatException
+     */
+    public Value getJcrValue(int propertyType) throws ValueFormatException {
+        checkPropertyName(JCR_VALUE);
+        return (jcrValues.length == 0) ? null : ValueHelper.convert(jcrValues[0], propertyType);
+    }
+
+    /**
+     *
+     * @return
+     * @throws ValueFormatException
+     */
+    public Value getJcrValue() throws ValueFormatException {
+        checkPropertyName(JCR_VALUE);
+        return (jcrValues.length == 0) ? null : jcrValues[0];
+    }
+
+    /**
+     * Returns the type of the {@link Value value}s present in this property
+     * or {@link PropertyType#UNDEFINED} if no values are available.
+     *
+     * @return type of values or {@link PropertyType#UNDEFINED}
+     */
+    public int getValueType() {
+        // TODO: check if correct behaviour if values array is empty
+        return (jcrValues.length > 0) ? jcrValues[0].getType() : PropertyType.UNDEFINED;
     }
 
     /**
@@ -121,22 +192,30 @@
      * property.
      *
      * @return an array of {@link Value}s
-     * @see #getValues(int)
+     * @see #getJcrValues(int)
      */
     public Object getValue() {
-	return jcrValues;
+        return jcrValues;
     }
 
+    /**
+     *
+     * @param document
+     * @return
+     */
     public Element toXml(Document document) {
         Element elem = getName().toXml(document);
-        for (int i = 0; i < jcrValues.length; i++) {
-            try {
-                DomUtil.addChildElement(elem, XML_VALUE, ItemResourceConstants.NAMESPACE, jcrValues[i].getString());
-            } catch (RepositoryException e) {
-                log.error("Unexpected Error while converting jcr value to String: " + e.getMessage());
-    }
+        try {
+            for (int i = 0; i < jcrValues.length; i++) {
+                Value v = jcrValues[i];
+                String type = PropertyType.nameFromValue(v.getType());
+                Element xmlValue = DomUtil.createElement(document, XML_VALUE, ItemResourceConstants.NAMESPACE, v.getString());
+                DomUtil.setAttribute(xmlValue, ATTR_VALUE_TYPE, ItemResourceConstants.NAMESPACE, type);
+                elem.appendChild(xmlValue);
+            }
+        } catch (RepositoryException e) {
+            log.error("Unexpected Error while converting jcr value to String: " + e.getMessage());
         }
         return elem;
     }
-
 }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/search/SearchResourceImpl.java Mon Mar 13 05:07:02 2006
@@ -21,7 +21,7 @@
 import org.apache.jackrabbit.webdav.search.QueryGrammerSet;
 import org.apache.jackrabbit.webdav.search.SearchInfo;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
-import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.DavException;
@@ -38,6 +38,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Node;
 import javax.jcr.Value;
+import javax.jcr.Session;
 
 /**
  * <code>SearchResourceImpl</code>...
@@ -46,10 +47,10 @@
 
     private static Logger log = Logger.getLogger(SearchResourceImpl.class);
 
-    private final DavSession session;
+    private final JcrDavSession session;
     private final DavResourceLocator locator;
 
-    public SearchResourceImpl(DavResourceLocator locator, DavSession session) {
+    public SearchResourceImpl(DavResourceLocator locator, JcrDavSession session) {
         this.session = session;
         this.locator = locator;
     }
@@ -61,7 +62,7 @@
     public QueryGrammerSet getQueryGrammerSet()  {
         QueryGrammerSet qgs = new QueryGrammerSet();
         try {
-            QueryManager qMgr = session.getRepositorySession().getWorkspace().getQueryManager();
+            QueryManager qMgr = getRepositorySession().getWorkspace().getQueryManager();
             String[] langs = qMgr.getSupportedQueryLanguages();
             for (int i = 0; i < langs.length; i++) {
                 // todo: define proper namespace
@@ -111,11 +112,11 @@
     private Query getQuery(SearchInfo sInfo)
             throws InvalidQueryException, RepositoryException, DavException {
 
-        Node rootNode = session.getRepositorySession().getRootNode();
-        QueryManager qMgr = session.getRepositorySession().getWorkspace().getQueryManager();
+        Node rootNode = getRepositorySession().getRootNode();
+        QueryManager qMgr = getRepositorySession().getWorkspace().getQueryManager();
 
         // test if query is defined by requested repository node
-        String itemPath = locator.getJcrPath();
+        String itemPath = locator.getRepositoryPath();
         if (!rootNode.getPath().equals(itemPath)) {
             String qNodeRelPath = itemPath.substring(1);
             if (rootNode.hasNode(qNodeRelPath)) {
@@ -135,7 +136,7 @@
 
         /* test if resource path does not exist -> thus indicating that
         the query must be made persistent by calling Query.save(String) */
-        if (!session.getRepositorySession().itemExists(itemPath)) {
+        if (!getRepositorySession().itemExists(itemPath)) {
             try {
                 q.storeAsNode(itemPath);
             } catch (RepositoryException e) {
@@ -177,5 +178,12 @@
             ms.addResponse(resp);
         }
         return ms;
+    }
+
+    /**
+     * @return
+     */
+    private Session getRepositorySession() {
+        return session.getRepositorySession();
     }
 }

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/TxLockManagerImpl.java Mon Mar 13 05:07:02 2006
@@ -21,9 +21,9 @@
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
 import org.apache.jackrabbit.webdav.DavServletResponse;
-import org.apache.jackrabbit.webdav.DavSession;
 import org.apache.jackrabbit.webdav.WebdavResponse;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.lock.ActiveLock;
 import org.apache.jackrabbit.webdav.lock.LockInfo;
 import org.apache.jackrabbit.webdav.lock.LockManager;
@@ -40,6 +40,7 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Item;
 import javax.jcr.PathNotFoundException;
+import javax.jcr.Session;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
@@ -50,15 +51,15 @@
  * <code>TxLockManagerImpl</code> manages locks with locktype
  * '{@link TransactionConstants#TRANSACTION dcr:transaction}'.
  * <p/>
- * todo: removing all expired locks
- * todo: 'local' and 'global' are not accurate terms in the given context > replace
- * todo: the usage of the 'global' transaction is not according to the JTA specification,
- * which explicitely requires any transaction present on a servlet to be completed before
- * the service method returns. Starting/completing transactions on the session object,
- * which is possible with the jackrabbit implementation is a hack.
- * todo: review of this transaction part is therefore required. Is there a use-case
- * for those 'global' transactions at all...
  */
+ //todo: removing all expired locks
+ //todo: 'local' and 'global' are not accurate terms in the given context > replace
+ /*todo: the usage of the 'global' transaction is not according to the JTA specification,
+   which explicitely requires any transaction present on a servlet to be completed before
+   the service method returns. Starting/completing transactions on the session object,
+   which is possible with the jackrabbit implementation is a hack.*/
+ /*todo: review of this transaction part is therefore required. Is there a use-case
+   for those 'global' transactions at all...*/
 public class TxLockManagerImpl implements TxLockManager {
 
     private static Logger log = Logger.getLogger(TxLockManagerImpl.class);
@@ -233,6 +234,21 @@
     }
 
     /**
+     * Returns true if the given lock token belongs to a lock that applies to
+     * the given resource, false otherwise. The token may either be retrieved
+     * from the {@link DavConstants#HEADER_LOCK_TOKEN Lock-Token header} or
+     * from the {@link TransactionConstants#HEADER_TRANSACTIONID TransactionId header}.
+     *
+     * @param token
+     * @param resource
+     * @return
+     * @see LockManager#hasLock(String token, DavResource resource)
+     */
+    public boolean hasLock(String token, DavResource resource) {
+        return getLock(token, null, resource) != null;
+    }
+
+    /**
      * Return the lock applied to the given resource or <code>null</code>
      *
      * @param type
@@ -245,7 +261,7 @@
     public ActiveLock getLock(Type type, Scope scope, TransactionResource resource) {
         ActiveLock lock = null;
         if (TransactionConstants.TRANSACTION.equals(type)) {
-            String[] sessionTokens = resource.getSession().getRepositorySession().getLockTokens();
+            String[] sessionTokens = resource.getSession().getLockTokens();
             int i = 0;
             while (lock == null && i < sessionTokens.length) {
                 String lockToken = sessionTokens[i];
@@ -298,21 +314,6 @@
     }
 
     /**
-     * Returns true if the given lock token belongs to a lock that applies to
-     * the given resource, false otherwise. The token may either be retrieved
-     * from the {@link DavConstants#HEADER_LOCK_TOKEN Lock-Token header} or
-     * from the {@link TransactionConstants#HEADER_TRANSACTIONID TransactionId header}.
-     *
-     * @param token
-     * @param resource
-     * @return
-     * @see LockManager#hasLock(String token, DavResource resource)
-     */
-    public boolean hasLock(String token, DavResource resource) {
-        return getLock(token, null, resource) != null;
-    }
-
-    /**
      * Return the map that may contain a transaction lock for the given resource.
      * In case the resource provides a transactionId, the map must be a
      * repository transaction that is identified by the given id and which in
@@ -374,7 +375,7 @@
     private static void addReferences(Transaction tx, TransactionMap responsibleMap,
                                       TransactionResource resource) throws DavException {
         log.info("Adding transactionId '" + tx.getId() + "' as session lock token.");
-        resource.getSession().getRepositorySession().addLockToken(tx.getId());
+        getRepositorySession(resource).addLockToken(tx.getId());
 
         responsibleMap.put(tx.getId(), tx);
         resource.getSession().addReference(tx.getId());
@@ -390,11 +391,19 @@
     private static void removeReferences(Transaction tx, TransactionMap responsibleMap,
                                          TransactionResource resource) {
         log.info("Removing transactionId '" + tx.getId() + "' from session lock tokens.");
-        resource.getSession().getRepositorySession().removeLockToken(tx.getId());
+        resource.getSession().removeLockToken(tx.getId());
 
         responsibleMap.remove(tx.getId());
         resource.getSession().removeReference(tx.getId());
     }
+
+    /**
+     * @param resource
+     * @return JCR session
+     */
+    private static Session getRepositorySession(TransactionResource resource) throws DavException {
+        return JcrDavSession.getRepositorySession(resource.getSession());
+    }
     //------------------------------------------< inner classes, interfaces >---
     /**
      * Internal <code>Transaction</code> interface
@@ -522,7 +531,7 @@
         public void start(TransactionResource resource) throws DavException {
             try {
                 // make sure, the given resource represents an existing repository item
-                if (!resource.getSession().getRepositorySession().itemExists(getResourcePath())) {
+                if (!getRepositorySession(resource).itemExists(getResourcePath())) {
                     throw new DavException(DavServletResponse.SC_CONFLICT, "Unable to start local transaction: no repository item present at " + getResourcePath());
                 }
             } catch (RepositoryException e) {
@@ -547,10 +556,9 @@
             }
         }
 
-        private Item getItem(TransactionResource resource) throws PathNotFoundException, RepositoryException {
-            DavSession session = resource.getSession();
-            String itemPath = resource.getLocator().getJcrPath();
-            return session.getRepositorySession().getItem(itemPath);
+        private Item getItem(TransactionResource resource) throws PathNotFoundException, RepositoryException, DavException {
+            String itemPath = resource.getLocator().getRepositoryPath();
+            return getRepositorySession(resource).getItem(itemPath);
         }
 
         public Transaction put(String key, Transaction value) throws DavException {
@@ -605,10 +613,8 @@
         }
 
         private XAResource getXAResource(TransactionResource resource) throws DavException {
-/*
-
-            currently commented, since server should be jackrabbit independant
-
+            /*
+            // commented, since server should be jackrabbit independant
 	    Session session = resource.getSession().getRepositorySession();
 	    if (session instanceof XASession) {
 		return ((XASession)session).getXAResource();

Modified: incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java?rev=385540&r1=385539&r2=385540&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java (original)
+++ incubator/jackrabbit/trunk/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/version/VersionHistoryItemCollection.java Mon Mar 13 05:07:02 2006
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
 import org.apache.jackrabbit.webdav.jcr.JcrDavException;
 import org.apache.jackrabbit.webdav.jcr.DefaultItemCollection;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 import org.apache.jackrabbit.webdav.version.VersionHistoryResource;
 import org.apache.jackrabbit.webdav.version.VersionResource;
 import org.apache.jackrabbit.webdav.DavResourceLocator;
@@ -30,6 +31,7 @@
 import org.apache.jackrabbit.webdav.DavResource;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.apache.jackrabbit.webdav.jcr.JcrDavSession;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Item;
@@ -55,7 +57,8 @@
      * @param factory
      */
     public VersionHistoryItemCollection(DavResourceLocator resourcePath,
-                                        DavSession session, DavResourceFactory factory,
+                                        JcrDavSession session,
+                                        DavResourceFactory factory,
                                         Item item) {
         super(resourcePath, session, factory, item);
         if (item == null || !(item instanceof VersionHistory)) {
@@ -85,7 +88,7 @@
         if (exists()) {
             VersionHistory versionHistory = (VersionHistory) item;
             try {
-                versionHistory.removeVersion(getItemName(member.getLocator().getJcrPath()));
+                versionHistory.removeVersion(getItemName(member.getLocator().getRepositoryPath()));
             } catch (RepositoryException e) {
                 throw new JcrDavException(e);
             }



Mime
View raw message