jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r180346 [6/9] - in /incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/ client/src/java/org/apache/jackrabbit/client/ client/src/java/org/apache/jackrabbit/webdav/client/methods/ commons/ commons/src/ commons/src/java/ commons/src/java/org/ commons/src/java/org/apache/ commons/src/java/org/apache/jackrabbit/ commons/src/java/org/apache/jackrabbit/nodetype/ commons/src/java/org/apache/jackrabbit/nodetype/xml/ commons/src/java/org/apache/jackrabbit/util/ commons/src/java/org/apache/jackrabbit/util/uuid/ commons/src/java/org/apache/jackrabbit/value/ server/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/io/ server/src/java/org/apache/jackrabbit/server/jcr/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/webdav/jcr/ server/src/java/org/apache/jackrabbit/webdav/jcr/lock/ server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ server/src/java/org/apache/jackrabbit/webdav/jcr/observation/ server/src/java/org/apache/jackrabbit/webdav/jcr/property/ server/src/java/org/apache/jackrabbit/webdav/jcr/search/ server/src/java/org/apache/jackrabbit/webdav/jcr/transaction/ server/src/java/org/apache/jackrabbit/webdav/jcr/version/ server/src/java/org/apache/jackrabbit/webdav/jcr/version/report/ server/src/java/org/apache/jackrabbit/webdav/simple/ webapp/ webapp/src/java/ webapp/src/java/org/ webapp/src/java/org/apache/ webapp/src/java/org/apache/jackrabbit/ webapp/src/java/org/apache/jackrabbit/j2ee/ webapp/src/webapp/ webapp/src/webapp/WEB-INF/ webdav/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/jcr/ webdav/src/java/org/apache/jackrabbit/webdav/lock/ webdav/src/java/org/apache/jackrabbit/webdav/property/ webdav/src/java/org/apache/jackrabbit/webdav/util/ webdav/src/java/org/apache/jackrabbit/webdav/version/report/
Date Mon, 06 Jun 2005 17:36:13 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,252 @@
+/*
+ * 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.property.*;
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.jcr.property.ValuesProperty;
+import org.apache.jackrabbit.webdav.jcr.property.LengthsProperty;
+import org.apache.jackrabbit.webdav.lock.*;
+import org.apache.jackrabbit.value.ValueHelper;
+
+import javax.jcr.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * <code>DefaultItemResource</code> represents JCR property item.
+ *
+ * @see Property
+ */
+public class DefaultItemResource extends AbstractItemResource {
+
+    private static Logger log = Logger.getLogger(DefaultItemResource.class);
+
+    /**
+     * Create a new <code>DefaultItemResource</code>.
+     *
+     * @param locator
+     * @param session
+     */
+    public DefaultItemResource(DavResourceLocator locator, DavSession session,
+                               DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
+    }
+
+    //----------------------------------------------< DavResource interface >---
+    /**
+     * Returns false.
+     *
+     * @return false
+     * @see DavResource#isCollection()
+     */
+    public boolean isCollection() {
+        return false;
+    }
+
+    /**
+     * In case an underlaying repository {@link Property property} exists the following
+     * logic is applyed to obtain the stream:<ul>
+     * <li>Property is not multivalue: Return the {@link javax.jcr.Value#getStream()
+     * stream representation} of the property value.</li>
+     * <li>Property is multivalue: Return stream that provides the system view of
+     * that item.</li>
+     * </ul>
+     *
+     * @return
+     * @see DavResource#getStream()
+     */
+    public InputStream getStream() {
+        InputStream in = null;
+        if (exists()) {
+            try {
+                // NOTE: stream cannot be obtained for multivalue properties
+                if (!isMultiple()) {
+                    in = ((Property)item).getStream();
+                }
+            } catch (ValueFormatException e) {
+                // should not occur
+                log.error("Cannot obtain stream from resource: " + e.getMessage());
+            } catch (RepositoryException e) {
+                log.error("Cannot obtain stream from resource: " + e.getMessage());
+            }
+        }
+        return in;
+    }
+
+    /**
+     * Sets the given property. Note, that {@link #JCR_VALUE} and {@link #JCR_VALUES}
+     * are the only resource properties that are allowed to be modified. Any other
+     * property is read-only and will throw an exception ('Conflict').
+     *
+     * @param property
+     * @throws DavException
+     * @see DavResource#setProperty(org.apache.jackrabbit.webdav.property.DavProperty)
+     *
+     * todo: undo incomplete modifications...
+     */
+    public void setProperty(DavProperty property) throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        try {
+            Property prop = (Property) item;
+            int type = prop.getType();
+            if (property.getName().equals(JCR_VALUE)) {
+                String strVal = (property.getValue() != null) ? String.valueOf(property.getValue()) : "";
+                Value val = ValueHelper.deserialize(getRepositorySession().getValueFactory(), strVal, type, false);
+                prop.setValue(val);
+            } else if (property.getName().equals(JCR_VALUES)) {
+                prop.setValue(new ValuesProperty(property).getValues(getRepositorySession().getValueFactory(), prop.getType()));
+            } else {
+                throw new DavException(DavServletResponse.SC_CONFLICT);
+            }
+            complete();
+
+        } catch (IllegalArgumentException e) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, e.getMessage());
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Removing properties is not allowed, for a single-value JCR-property without
+     * a value does not exist. For multivalue properties an empty {@link Value values array}
+     * may be specified with by setting the {@link #JCR_VALUES 'values' webdav property}.
+     *
+     * @param propertyName
+     * @throws DavException
+     * @see org.apache.jackrabbit.webdav.DavResource#removeProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
+     */
+    public void removeProperty(DavPropertyName propertyName) throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        throw new DavException(DavServletResponse.SC_FORBIDDEN);
+    }
+
+    /**
+     * Method is not allowed.
+     *
+     * @see org.apache.jackrabbit.webdav.DavResource#addMember(org.apache.jackrabbit.webdav.DavResource, InputStream)
+     */
+    public void addMember(DavResource resource, InputStream in) throws DavException {
+        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot add members to a non-collection resource");
+    }
+
+    /**
+     * Method is not allowed.
+     *
+     * @see DavResource#addMember(DavResource)
+     */
+    public void addMember(DavResource resource) throws DavException {
+        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot add members to a non-collection resource");
+    }
+
+    /**
+     * Always returns an empty iterator for a non-collection resource might
+     * not have internal members.
+     *
+     * @return an empty iterator
+     * @see DavResource#getMembers()
+     */
+    public DavResourceIterator getMembers() {
+        log.warn("A non-collection resource never has internal members.");
+        return new DavResourceIteratorImpl(new ArrayList(0));
+    }
+
+    /**
+     * Method is not allowed.
+     *
+     * @see DavResource#removeMember(DavResource)
+     */
+    public void removeMember(DavResource member) throws DavException {
+        throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED, "Cannot remove members from a non-collection resource");
+    }
+
+    /**
+     * {@link javax.jcr.Property JCR properties} are locked if their
+     * parent node is locked; thus this method will always return the
+     * {@link ActiveLock lock} object from the collection this resource is
+     * internal member of.
+     *
+     * @param type
+     * @param scope
+     * @return lock present on this resource or <code>null</code> if this resource
+     * has no lock.
+     * @see DavResource#getLock(Type, Scope)
+     */
+    public ActiveLock getLock(Type type, Scope scope) {
+        if (Type.WRITE.equals(type)) {
+            return getCollection().getLock(type, scope);
+        } else {
+            return super.getLock(type, scope);
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * Add resource specific properties.
+     */
+    protected void initProperties() {
+        super.initProperties();
+        if (exists()) {
+            try {
+                Property prop = (Property)item;
+                int type = prop.getType();
+
+                // set the content type
+                String contentType;
+                if (!isMultiple()) {
+                    contentType = (type == PropertyType.BINARY) ? "application/octet-stream" : "text/plain";
+                    properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType));
+                } // else: no contenttype for multivalue properties
+
+                // add jcr-specific resource properties
+                properties.add(new DefaultDavProperty(JCR_TYPE, PropertyType.nameFromValue(type)));
+                if (isMultiple()) {
+                    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 DefaultDavProperty(JCR_LENGTH, String.valueOf(prop.getLength())));
+                }
+            } catch (RepositoryException e) {
+                log.error("Failed to retrieve resource properties: "+e.getMessage());
+            }
+        }
+    }
+
+    /**
+     * Returns true if the JCR Property represented by this resource is a multi
+     * value property. Note: if this resource does not exist or if the definition
+     * could not be retrieved false is returned.
+     *
+     * @return true if the underlaying resource is a multi value property.
+     */
+    private boolean isMultiple() {
+        try {
+            if (exists() && ((Property)item).getDefinition().isMultiple()) {
+                return true;
+            }
+        } catch (RepositoryException e) {
+            log.error("Error while retrieving property definition: " + e.getMessage());
+        }
+        return false;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/DefaultItemResource.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,128 @@
+/*
+ * 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.jdom.Namespace;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.search.SearchResource;
+import org.apache.jackrabbit.webdav.observation.ObservationResource;
+
+/**
+ * <code>ItemResourceConstants</code> provides constants for any resources
+ * representing repository items.
+ */
+public interface ItemResourceConstants {
+
+    /**
+     * Complience classes common to all item resources.
+     */
+    public static final String COMPLIANCE_CLASS = DavResource.COMPLIANCE_CLASS + ", " +ObservationResource.COMPLIANCE_CLASS + ", " + DeltaVResource.COMPLIANCE_CLASS;
+
+    /**
+     * Methods common to all item resources.
+     */
+    public static final String METHODS = DavResource.METHODS + ", " + ObservationResource.METHODS + ", " + SearchResource.METHODS + ", " +DeltaVResource.METHODS;
+
+    /**
+     * The resource path of the root-item-resource.
+     */
+    public static final String ROOT_ITEM_PATH = "/";
+
+    /**
+     * The version storage item resource path.
+     */
+    public static final String VERSIONSTORAGE_PATH = "/jcr:system/jcr:versionStorage";
+
+    /**
+     * The namespace for all jcr specific extensions.
+     */
+    public static final Namespace NAMESPACE = Namespace.getNamespace("jcr", "http://www.day.com/jcr/webdav/1.0");
+
+    // xml element names
+    public static final String XML_PRIMARYNODETYPE = "primarynodetype";
+    public static final String XML_VALUE = "value";
+    public static final String XML_LENGTH = "length";
+    public static final String XML_EXCLUSIVE_SESSION_SCOPED = "exclusive-session-scoped";
+
+    // xml elements used to reflect the workspaces ns-registry
+    // TODO: to be review...
+    public static final String XML_NAMESPACE = "namespace";
+    public static final String XML_PREFIX = "prefix";
+    public static final String XML_URI = "uri";
+
+    // xml elements used for repository-descritors report
+    public static final String XML_DESCRIPTOR = "descriptor";
+    public static final String XML_DESCRIPTORKEY = "descriptorkey";
+    public static final String XML_DESCRIPTORVALUE = "descriptorvalue";
+
+    /**
+     * Extension to the WebDAV 'exclusive' lock, that allows to distinguish
+     * the session-scoped and open-scoped locks on a JCR node.
+     *
+     * @see javax.jcr.Node#lock(boolean, boolean)
+     */
+    public static final Scope EXCLUSIVE_SESSION = Scope.create(XML_EXCLUSIVE_SESSION_SCOPED, NAMESPACE);
+
+    /**
+     * The 'removeexisting' element is not defined by RFC 3253. If it is present
+     * in the UPDATE request body, uuid conflicts should be solved by removing
+     * the existing nodes.
+     *
+     * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
+     * @see javax.jcr.Workspace#restore(javax.jcr.version.Version[], boolean)
+     * @see org.apache.jackrabbit.webdav.version.UpdateInfo
+     */
+    public static final String XML_REMOVEEXISTING = "removeexisting";
+
+    /**
+     * The 'relpath' element is not defined by RFC 3253. If it is present
+     * in the UPDATE request body, the server is forced to used the text contained
+     * as 'relPath' argument for the {@link javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
+     * Node.restore} call.
+     *
+     * @see javax.jcr.Node#restore(javax.jcr.version.Version, String, boolean)
+     * @see org.apache.jackrabbit.webdav.version.UpdateInfo
+     */
+    public static final String XML_RELPATH = "relpath";
+
+    // general property names
+    public static final DavPropertyName JCR_NAME = DavPropertyName.create("name", NAMESPACE);
+    public static final DavPropertyName JCR_PATH = DavPropertyName.create("path", NAMESPACE);
+    public static final DavPropertyName JCR_DEPTH = DavPropertyName.create("depth", NAMESPACE);
+    public static final DavPropertyName JCR_ISNEW = DavPropertyName.create("isnew", NAMESPACE);
+    public static final DavPropertyName JCR_ISMODIFIED = DavPropertyName.create("ismodified", NAMESPACE);
+
+    // property names used for resources representing jcr-nodes
+    public static final DavPropertyName JCR_PRIMARYNODETYPE = DavPropertyName.create(XML_PRIMARYNODETYPE, NAMESPACE);
+    public static final DavPropertyName JCR_MIXINNODETYPES = DavPropertyName.create("mixinnodetypes", NAMESPACE);
+    public static final DavPropertyName JCR_INDEX = DavPropertyName.create("index", NAMESPACE);
+    public static final DavPropertyName JCR_REFERENCES = DavPropertyName.create("references", NAMESPACE);
+    public static final DavPropertyName JCR_UUID = DavPropertyName.create("uuid", NAMESPACE);
+    public static final DavPropertyName JCR_PRIMARYITEM = DavPropertyName.create("primaryitem", NAMESPACE);
+
+    // property names used for resources representing jcr-properties
+    public static final DavPropertyName JCR_TYPE = DavPropertyName.create("type", NAMESPACE);
+    public static final DavPropertyName JCR_VALUE = DavPropertyName.create("value", NAMESPACE);
+    public static final DavPropertyName JCR_VALUES = DavPropertyName.create("values", NAMESPACE);
+    public static final DavPropertyName JCR_LENGTH = DavPropertyName.create("length", NAMESPACE);
+    public static final DavPropertyName JCR_LENGTHS = DavPropertyName.create("lengths", NAMESPACE);
+
+    // property names used for resource representing a workspace
+    public static final DavPropertyName JCR_NAMESPACES = DavPropertyName.create("namespaces", NAMESPACE);
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/ItemResourceConstants.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,134 @@
+/*
+ * 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.DavException;
+import org.apache.jackrabbit.webdav.DavServletResponse;
+import org.jdom.Element;
+
+import javax.jcr.*;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.*;
+
+/**
+ * <code>JcrDavException</code> extends the {@link DavException} in order to
+ * wrap various repository exceptions.
+ */
+public class JcrDavException extends DavException {
+
+    private static Logger log = Logger.getLogger(JcrDavException.class);
+
+    private Class exceptionClass;
+
+    public JcrDavException(Exception e, int errorCode) {
+        super(errorCode, e.getMessage());
+        exceptionClass = e.getClass();
+    }
+
+    public JcrDavException(AccessDeniedException e) {
+        this(e, DavServletResponse.SC_FORBIDDEN);
+    }
+
+    public JcrDavException(ConstraintViolationException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(InvalidItemStateException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(InvalidSerializedDataException e) {
+        this(e, DavServletResponse.SC_BAD_REQUEST);
+    }
+
+    public JcrDavException(InvalidQueryException e) {
+        this(e, DavServletResponse.SC_BAD_REQUEST);
+    }
+
+    public JcrDavException(ItemExistsException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(ItemNotFoundException e) {
+        this(e, DavServletResponse.SC_FORBIDDEN);
+    }
+
+    public JcrDavException(LockException e) {
+        this(e, DavServletResponse.SC_LOCKED);
+    }
+
+    public JcrDavException(MergeException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(NamespaceException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(NoSuchNodeTypeException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(NoSuchWorkspaceException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(PathNotFoundException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(ReferentialIntegrityException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(RepositoryException e) {
+        this(e, DavServletResponse.SC_FORBIDDEN);
+    }
+
+    public JcrDavException(LoginException e) {
+        this(e, DavServletResponse.SC_UNAUTHORIZED);
+    }
+
+    public JcrDavException(UnsupportedRepositoryOperationException e) {
+        this(e, DavServletResponse.SC_NOT_IMPLEMENTED);
+    }
+
+    public JcrDavException(ValueFormatException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    public JcrDavException(VersionException e) {
+        this(e, DavServletResponse.SC_CONFLICT);
+    }
+
+    /**
+     * Returns a DAV:error Xml element containing the exceptions class and the
+     * message as child elements.
+     *
+     * @return Xml representation of this exception.
+     */
+    public Element getError() {
+        Element error = super.getError();
+        Element excep = new Element("exception", ItemResourceConstants.NAMESPACE);
+        excep.addContent(new Element("class", ItemResourceConstants.NAMESPACE).setText(exceptionClass.getName()));
+        excep.addContent(new Element("message", ItemResourceConstants.NAMESPACE).setText(getMessage()));
+        error.addContent(excep);
+        return error;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/JcrDavException.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,206 @@
+/*
+ * 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.*;
+import org.apache.jackrabbit.webdav.jcr.version.report.RegisteredNamespacesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.NodeTypesReport;
+import org.apache.jackrabbit.webdav.jcr.version.report.RepositoryDescriptorsReport;
+import org.apache.jackrabbit.webdav.version.report.SupportedReportSetProperty;
+import org.apache.jackrabbit.webdav.version.report.ReportType;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import java.util.*;
+import java.io.InputStream;
+
+/**
+ * <code>RootCollection</code> represent the WebDAV root resource that does not
+ * represent any repository item. A call to getMembers() returns a
+ * <code>DavResourceIterator</code> containing only <code>RootItemCollection</code>
+ * resources, thus revealing the names of the accessable workspaces.
+ */
+public class RootCollection extends AbstractResource implements DavResource {
+
+    private static Logger log = Logger.getLogger(RootCollection.class);
+
+    /**
+     * Create a new <code>RootCollection</code>.
+     *
+     * @param locator
+     * @param session
+     */
+    protected RootCollection(DavResourceLocator locator, DavSession session, DavResourceFactory factory) {
+        super(locator, session, factory);
+        setModificationTime(new Date().getTime());
+
+        // initialize the supported locks and reports
+        initLockSupport();
+        initSupportedReports();
+    }
+
+    /**
+     * Returns a string listing the complieance classes for this resource as it
+     * is required for the DAV response header.
+     *
+     * @return string listing the compliance classes.
+     * @see org.apache.jackrabbit.webdav.DavResource#getComplianceClass()
+     */
+    public String getComplianceClass() {
+        return DavResource.COMPLIANCE_CLASS;
+    }
+
+    /**
+     * Returns a string listing the METHODS for this resource as it
+     * is required for the "Allow" response header.
+     *
+     * @return string listing the METHODS allowed
+     * @see org.apache.jackrabbit.webdav.DavResource#getSupportedMethods()
+     */
+    public String getSupportedMethods() {
+        StringBuffer sb = new StringBuffer(DavResource.METHODS);
+        return sb.toString();
+    }
+
+    /**
+     * Returns true
+     *
+     * @return true
+     * @see org.apache.jackrabbit.webdav.DavResource#exists()
+     */
+    public boolean exists() {
+        return true;
+    }
+
+    /**
+     * Returns true
+     *
+     * @return true
+     * @see org.apache.jackrabbit.webdav.DavResource#isCollection()
+     */
+    public boolean isCollection() {
+        return true;
+    }
+
+    /**
+     * Returns an empty string.
+     *
+     * @return empty string
+     * @see org.apache.jackrabbit.webdav.DavResource#getDisplayName()
+     */
+    public String getDisplayName() {
+        return "";
+    }
+
+    /**
+     * Always returns <code>null</code>
+     *
+     * @return <code>null</code> for the root resource is not internal member
+     * of any resource.
+     * @see org.apache.jackrabbit.webdav.DavResource#getCollection()
+     */
+    public DavResource getCollection() {
+        return null;
+    }
+
+    /**
+     * Throws exception: 403 Forbidden.
+     * @see DavResource#addMember(DavResource, InputStream)
+     */
+    public void addMember(DavResource resource, InputStream in) throws DavException {
+        throw new DavException(DavServletResponse.SC_FORBIDDEN);
+    }
+
+    /**
+     * Throws exception: 403 Forbidden.
+     * @see DavResource#addMember(org.apache.jackrabbit.webdav.DavResource)
+     */
+    public void addMember(DavResource resource) throws DavException {
+        throw new DavException(DavServletResponse.SC_FORBIDDEN);
+    }
+
+    /**
+     * Returns an iterator over the member resources, which are all
+     * <code>RootItemCollection</code> resources, revealing
+     * the names of all available workspaces.
+     *
+     * @return members of this collection
+     * @see org.apache.jackrabbit.webdav.DavResource#getMembers()
+     */
+    public DavResourceIterator getMembers() {
+        List memberList = new ArrayList();
+        try {
+            String[] wsNames = getSession().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));
+            }
+        } catch (RepositoryException e) {
+            log.error(e.getMessage());
+        } catch (DavException e) {
+            // should never occur
+            log.error(e.getMessage());
+        }
+        return new DavResourceIteratorImpl(memberList);
+    }
+
+    /**
+     * Throws exception: 403 Forbidden.
+     * @see DavResource#removeMember(org.apache.jackrabbit.webdav.DavResource)
+     */
+    public void removeMember(DavResource member) throws DavException {
+        throw new DavException(DavServletResponse.SC_FORBIDDEN);
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * @see AbstractResource#initLockSupport()
+     */
+    protected void initLockSupport() {
+        // no locking supported
+    }
+
+    /**
+     * @see AbstractResource#initSupportedReports()
+     */
+    protected void initSupportedReports() {
+        supportedReports = new SupportedReportSetProperty(new ReportType[] {
+            ReportType.EXPAND_PROPERTY,
+            NodeTypesReport.NODETYPES_REPORT,
+            RegisteredNamespacesReport.REGISTERED_NAMESPACES_REPORT,
+            RepositoryDescriptorsReport.REPOSITORY_DESCRIPTORS_REPORT
+        });
+    }
+
+    /**
+     * Since the root resource does not represent a repository item and therefore
+     * is not member of a workspace resource, the workspace href is calculated
+     * from the workspace name retrieved from the underlaying repository session.
+     *
+     * @return workspace href build from workspace name.
+     * @see AbstractResource#getWorkspaceHref()
+     */
+    protected String getWorkspaceHref() {
+        Session session = this.getRepositorySession();
+        if (session != null) {
+            String workspaceName = session.getWorkspace().getName();
+            DavResourceLocator loc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), "/"+workspaceName, ItemResourceConstants.ROOT_ITEM_PATH);
+            return loc.getHref(true);
+        }
+        return null;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootCollection.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,107 @@
+/*
+ * 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.*;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.jdom.Element;
+
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.Item;
+
+/**
+ * <code>RootItemCollection</code> represents the root node of the underlaying
+ * 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...
+ */
+public class RootItemCollection extends VersionControlledItemCollection {
+
+    private static Logger log = Logger.getLogger(RootItemCollection.class);
+
+    /**
+     * Create a new <code>RootItemCollection</code>.
+     *
+     * @param locator
+     * @param session
+     */
+    protected RootItemCollection(DavResourceLocator locator, DavSession session,
+                                 DavResourceFactory factory, Item item) {
+        super(locator, session, factory, item);
+    }
+
+    //----------------------------------------------< DavResource interface >---
+    /**
+     * Returns the name of the workspace the underlaying root item forms part of.
+     *
+     * @return The workspace name
+     * @see org.apache.jackrabbit.webdav.DavResource#getDisplayName()
+     * @see javax.jcr.Workspace#getName()
+     */
+    public String getDisplayName() {
+        return getLocator().getWorkspaceName();
+    }
+
+    /**
+     * Retrieve the collection that has all root item / workspace collections
+     * as internal members.
+     *
+     * @see org.apache.jackrabbit.webdav.DavResource#getCollection()
+     */
+    public DavResource getCollection() {
+        DavResource collection = null;
+        // create location with 'null' values for workspace-path and resource-path
+        DavResourceLocator parentLoc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), null, null);
+        try {
+            collection = createResourceFromLocator(parentLoc);
+        } catch (DavException e) {
+            log.error("Unexpected error while retrieving collection: " + e.getMessage());
+        }
+        return collection;
+    }
+
+    public void setProperty(DavProperty property) throws DavException {
+        if (ItemResourceConstants.JCR_NAMESPACES.equals(property.getName())) {
+            // todo: register and unregister namespaces
+        } else {
+            super.setProperty(property);
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    protected void initProperties() {
+        super.initProperties();
+        try {
+            // init workspace specific properties
+            NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
+            String[] prefixes = nsReg.getPrefixes();
+            Element[] nsElems = new Element[prefixes.length];
+            for (int i = 0; i < prefixes.length; i++) {
+                Element elem = new Element(XML_NAMESPACE, NAMESPACE);
+                elem.addContent(new Element(XML_PREFIX).setText(prefixes[i]));
+                elem.addContent(new Element(XML_URI)).setText(nsReg.getURI(prefixes[i]));
+                nsElems[i] = elem;
+            }
+            properties.add(new DefaultDavProperty(ItemResourceConstants.JCR_NAMESPACES, nsElems, false));
+        } catch (RepositoryException e) {
+            log.error("Failed to access NamespaceRegistry from the session/workspace: " + e.getMessage());
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/RootItemCollection.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,584 @@
+/*
+ * 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.property.*;
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.version.*;
+import org.apache.jackrabbit.webdav.version.report.*;
+import org.apache.jackrabbit.JcrConstants;
+
+import javax.jcr.*;
+import javax.jcr.observation.*;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionHistory;
+import java.util.List;
+
+/**
+ * <code>VersionControlledItemCollection</code> represents a JCR node item and
+ * covers all functionality related to versioning of {@link Node}s.
+ *
+ * @see Node
+ */
+public class VersionControlledItemCollection extends DefaultItemCollection
+        implements VersionControlledResource {
+
+    private static Logger log = Logger.getLogger(VersionControlledItemCollection.class);
+
+    /**
+     * Create a new <code>VersionControlledItemCollection</code>.
+     *
+     * @param locator
+     * @param session
+     */
+    public VersionControlledItemCollection(DavResourceLocator locator,
+                                           DavSession session, DavResourceFactory factory,
+                                           Item item) {
+        super(locator, session, factory, item);
+        if (exists() && !(item instanceof Node)) {
+            throw new IllegalArgumentException("A collection resource can not be constructed from a Property item.");
+        }
+    }
+
+    //----------------------------------------------< DavResource interface >---
+    /**
+     * Return a comma separated string listing the supported method names.
+     *
+     * @return the supported method names.
+     * @see org.apache.jackrabbit.webdav.DavResource#getSupportedMethods()
+     */
+    public String getSupportedMethods() {
+        StringBuffer sb = new StringBuffer(super.getSupportedMethods());
+        // Versioning support
+        sb.append(", ").append(VersionableResource.METHODS);
+        if (this.isVersionControlled()) {
+            try {
+                if (((Node)item).isCheckedOut()) {
+                    sb.append(", ").append(VersionControlledResource.methods_checkedOut);
+                } else {
+                    sb.append(", ").append(VersionControlledResource.methods_checkedIn);
+                }
+            } catch (RepositoryException e) {
+                // should not occur.
+                log.error(e.getMessage());
+            }
+        }
+        return sb.toString();
+    }
+
+    //--------------------------------< VersionControlledResource interface >---
+    /**
+     * Adds version control to this resource. If the resource is already under
+     * version control, this method has no effect.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException if this resource does not
+     * exist yet or if an error occurs while making the underlaying node versionable.
+     * @see org.apache.jackrabbit.webdav.version.VersionableResource#addVersionControl()
+     */
+    public void addVersionControl() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            try {
+                ((Node)item).addMixin(JcrConstants.MIX_VERSIONABLE);
+                item.save();
+            } catch (RepositoryException e) {
+                throw new JcrDavException(e);
+            }
+        } // else: is already version controlled -> ignore
+    }
+
+    /**
+     * Calls {@link javax.jcr.Node#checkin()} on the underlaying repository node.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkin()
+     */
+    public String checkin() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+        try {
+            Version v = ((Node) item).checkin();
+            DavResourceLocator loc = getLocator();
+            String versionHref = loc.getFactory().createResourceLocator(loc.getPrefix(), loc.getWorkspacePath(), v.getPath()).getHref(true);
+            return versionHref;
+        } catch (RepositoryException e) {
+            // UnsupportedRepositoryException should not occur
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Calls {@link javax.jcr.Node#checkout()} on the underlaying repository node.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#checkout()
+     */
+    public void checkout() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+        try {
+            ((Node) item).checkout();
+        } catch (RepositoryException e) {
+            // UnsupportedRepositoryException should not occur
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Not implemented. Always throws a <code>DavException</code> with error code
+     * {@link org.apache.jackrabbit.webdav.DavServletResponse#SC_NOT_IMPLEMENTED}.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#uncheckout()
+     */
+    public void uncheckout() throws DavException {
+        throw new DavException(DavServletResponse.SC_NOT_IMPLEMENTED);
+    }
+
+    /**
+     * Perform an update on this resource. Depending on the format of the <code>updateInfo</code>
+     * this is translated to one of the following methods defined by the JCR API:
+     * <ul>
+     * <li>{@link Node#restore(javax.jcr.version.Version, boolean)}</li>
+     * <li>{@link Node#restore(javax.jcr.version.Version, String, boolean)}</li>
+     * <li>{@link Node#restoreByLabel(String, boolean)}</li>
+     * <li>{@link Workspace#restore(javax.jcr.version.Version[], boolean)}</li>
+     * <li>{@link Node#update(String)}</li>
+     * </ul>
+     * </p>
+     * Limitation: note that the <code>MultiStatus</code> returned by this method
+     * will not list any nodes that have been removed due to an Uuid conflict.
+     *
+     * @param updateInfo
+     * @return
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#update(org.apache.jackrabbit.webdav.version.UpdateInfo)
+     * @todo with jcr the node must not be versionable in order to perform Node.update.
+     */
+    public MultiStatus update(UpdateInfo updateInfo) throws DavException {
+        if (updateInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid update request body required.");
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        MultiStatus ms = new MultiStatus();
+        try {
+            Node node = (Node)item;
+            boolean removeExisting = updateInfo.getUpdateElement().getChild(XML_REMOVEEXISTING, NAMESPACE) != null;
+
+            // register eventListener in order to be able to report the modified resources.
+            EventListener el = new EListener(updateInfo.getPropertyNameSet(), ms);
+            registerEventListener(el, node.getPath());
+
+            // perform the update/restore according to the update info
+            if (updateInfo.getVersionHref() != null) {
+                VersionHistory vh = node.getVersionHistory();
+                String[] hrefs = updateInfo.getVersionHref();
+                Version[] versions = new Version[hrefs.length];
+                for (int  i = 0; i < hrefs.length; i++) {
+                    versions[i] = vh.getVersion(getResourceName(hrefs[i], true));
+                }
+                if (versions.length == 1) {
+                    String relPath = updateInfo.getUpdateElement().getChildText(XML_RELPATH, NAMESPACE);
+                    if (relPath == null) {
+                        node.restore(versions[0], removeExisting);
+                    } else {
+                        node.restore(versions[0], relPath, removeExisting);
+                    }
+                } else {
+                    getRepositorySession().getWorkspace().restore(versions, removeExisting);
+                }
+            } else if (updateInfo.getLabelName() != null) {
+                String[] labels = updateInfo.getLabelName();
+                if (labels.length == 1) {
+                    node.restoreByLabel(labels[0], removeExisting);
+                } else {
+                    Version[] vs = new Version[labels.length];
+                    VersionHistory vh = node.getVersionHistory();
+                    for (int  i = 0; i < labels.length; i++) {
+                        vs[i] = vh.getVersionByLabel(labels[i]);
+                    }
+                    getRepositorySession().getWorkspace().restore(vs, removeExisting);
+                }
+            } else if (updateInfo.getWorkspaceHref() != null) {
+                String workspaceName = getResourceName(updateInfo.getWorkspaceHref(), true);
+                node.update(workspaceName);
+            } else {
+                throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid update request body.");
+            }
+
+            // unregister the event listener again
+            unregisterEventListener(el);
+
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+        return ms;
+    }
+
+    /**
+     * Merge the repository node represented by this resource according to the
+     * information present in the given {@link MergeInfo} object.
+     *
+     * @param mergeInfo
+     * @return <code>MultiStatus</code> reccording all repository items affected
+     * by this merge call.
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#merge(org.apache.jackrabbit.webdav.version.MergeInfo)
+     * @see Node#merge(String, boolean)
+     */
+    //todo with jcr the node must not be versionable in order to perform Node.merge
+    public MultiStatus merge(MergeInfo mergeInfo) throws DavException {
+        if (mergeInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST);
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        MultiStatus ms = new MultiStatus();
+        try {
+            Node node = (Node)item;
+
+            // register eventListener in order to be able to report the modifications.
+            EventListener el = new EListener(mergeInfo.getPropertyNameSet(), ms);
+            registerEventListener(el, node.getPath());
+
+            String workspaceName = getResourceName(mergeInfo.getSourceHref(), true);
+            node.merge(workspaceName, !mergeInfo.isNoAutoMerge());
+
+            // unregister the event listener again
+            unregisterEventListener(el);
+
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+
+        return ms;
+    }
+
+    /**
+     * Resolve the merge conflicts according to the value of the {@link #AUTO_MERGE_SET DAV:auto-merge-set}
+     * property present in the specified <code>DavPropertySet</code>s.
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see VersionControlledResource#resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
+     * @see Node#doneMerge(Version)
+     * @see Node#cancelMerge(Version)
+     */
+    public void resolveMergeConflict(DavPropertySet setProperties,
+                                     DavPropertyNameSet removePropertyNames) throws DavException {
+
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+        if (!isVersionControlled()) {
+            throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED);
+        }
+
+        try {
+            Node n = (Node)item;
+            if (removePropertyNames.contains(AUTO_MERGE_SET)) {
+                // retrieve the current jcr:mergeFailed property values
+                if (!((Node)item).hasProperty(JcrConstants.JCR_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = ((Node)item).getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
+
+                // resolve all remaining merge conflicts with 'cancel'
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    n.cancelMerge((Version)getRepositorySession().getNodeByUUID(mergeFailed[i].getString()));
+                }
+                // adjust removeProperty set
+                removePropertyNames.remove(AUTO_MERGE_SET);
+
+            } else if (setProperties.contains(AUTO_MERGE_SET) && setProperties.contains(PREDECESSOR_SET)){
+                // retrieve the current jcr:mergeFailed property values
+                if (!((Node)item).hasProperty(JcrConstants.JCR_MERGEFAILED)) {
+                    throw new DavException(DavServletResponse.SC_CONFLICT, "Attempt to resolve non-existing merge conflicts.");
+                }
+                Value[] mergeFailed = ((Node)item).getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
+
+
+                // check which mergeFailed entries have been removed from the
+                // auto-merge-set (cancelMerge) and have been moved over to the
+                // predecessor set (doneMerge)
+                List mergeset = new HrefProperty(setProperties.get(AUTO_MERGE_SET)).getHrefs();
+                List predecSet = new HrefProperty(setProperties.get(PREDECESSOR_SET)).getHrefs();
+
+                Session session = getRepositorySession();
+                for (int i = 0; i < mergeFailed.length; i++) {
+                    // build version-href from each entry in the jcr:mergeFailed property
+                    Version version = (Version) session.getNodeByUUID(mergeFailed[i].getString());
+                    String href = this.getLocatorFromItem(version).getHref(true);
+
+                    // Test if that version has been removed from the merge-set.
+                    // thus indicating that the merge-conflict needs to be resolved.
+                    if (!mergeset.contains(href)) {
+                        // Test if the 'href' has been moved over to the
+                        // predecessor-set (thus 'doneMerge' is appropriate) or
+                        // if it is not present in the predecessor set and the
+                        // the conflict is resolved by 'cancelMerge'.
+                        if (predecSet.contains(href)) {
+                            n.doneMerge(version);
+                        } else {
+                            n.cancelMerge(version);
+                        }
+                    }
+                }
+                // adjust setProperty set
+                setProperties.remove(AUTO_MERGE_SET);
+                setProperties.remove(PREDECESSOR_SET);
+            } else {
+                // setPropertySet and removePropertySet do not ask for resolving merge conflicts */
+                log.debug("setProperties and removeProperties sets do not request for merge conflict resolution.");
+            }
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Modify the labels present with the versions of this resource.
+     *
+     * @param labelInfo
+     * @throws DavException
+     * @see VersionHistory#addVersionLabel(String, String, boolean)
+     * @see VersionHistory#removeVersionLabel(String)
+     */
+    public void label(LabelInfo labelInfo) throws DavException {
+        if (labelInfo == null) {
+            throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Valid label request body required.");
+        }
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        try {
+            if (!isVersionControlled() || ((Node)item).isCheckedOut()) {
+                throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "A LABEL request may only be applied to a version-controlled, checked-in resource.");
+            }
+            DavResource[] resArr = this.getReferenceResources(CHECKED_IN);
+            if (resArr.length == 1 && resArr[0] instanceof VersionResource) {
+                ((VersionResource)resArr[0]).label(labelInfo);
+            } else {
+                throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:checked-in property on '" + getHref() + "' did not point to a single VersionResource.");
+            }
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    /**
+     * Returns the {@link VersionHistory} associated with the repository node.
+     * If the node is not versionable an exception is thrown.
+     *
+     * @return the {@link VersionHistoryResource} associated with this resource.
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#getVersionHistory()
+     * @see javax.jcr.Node#getVersionHistory()
+     */
+    public VersionHistoryResource getVersionHistory() throws DavException {
+        if (!exists()) {
+            throw new DavException(DavServletResponse.SC_NOT_FOUND);
+        }
+
+        try {
+            VersionHistory vh = ((Node)item).getVersionHistory();
+            DavResourceLocator loc = getLocatorFromItem(vh);
+            return (VersionHistoryResource) createResourceFromLocator(loc);
+        } catch (RepositoryException e) {
+            throw new JcrDavException(e);
+        }
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * Define the set of reports supported by this resource.
+     *
+     * @see SupportedReportSetProperty
+     */
+    protected void initSupportedReports() {
+        super.initSupportedReports();
+        if (exists()) {
+	    supportedReports.addReportType(ReportType.LOCATE_BY_HISTORY);
+            if (this.isVersionControlled()) {
+            supportedReports.addReportType(ReportType.VERSION_TREE);
+	    }            
+        }
+    }
+
+    /**
+     * Fill the property set for this resource.
+     */
+    protected void initProperties() {
+        super.initProperties();
+        if (exists()) {
+            Node n = (Node)item;
+            // properties defined by RFC 3253 for version-controlled resources
+            if (isVersionControlled()) {
+                // workspace property already set in AbstractResource.initProperties()
+                try {
+                    // DAV:version-history (computed)
+                    String vhHref = getLocatorFromResourcePath(n.getVersionHistory().getPath()).getHref(true);
+                    properties.add(new HrefProperty(VERSION_HISTORY, vhHref, true));
+
+                    // DAV:auto-version property: there is no auto version, explicit CHECKOUT is required.
+                    properties.add(new DefaultDavProperty(AUTO_VERSION, null, false));
+
+                    String baseVHref = getLocatorFromResourcePath(n.getBaseVersion().getPath()).getHref(true);
+                    if (n.isCheckedOut()) {
+                        // DAV:checked-out property (protected)
+                        properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true));
+
+                        // DAV:predecessors property
+                        if (n.hasProperty(JcrConstants.JCR_PREDECESSORS)) {
+                            Value[] predec = n.getProperty(JcrConstants.JCR_PREDECESSORS).getValues();
+                            addHrefProperty(PREDECESSOR_SET, predec, false);
+                        }
+                        // DAV:auto-merge-set property. NOTE: the DAV:merge-set
+                        // never occurs, because merging without bestEffort flag
+                        // being set results in an exception on failure.
+                        if (n.hasProperty(JcrConstants.JCR_MERGEFAILED)) {
+                            Value[] mergeFailed = n.getProperty(JcrConstants.JCR_MERGEFAILED).getValues();
+                            addHrefProperty(AUTO_MERGE_SET, mergeFailed, false);
+                        }
+                        // todo: checkout-fork, checkin-fork
+                    } else {
+                        // DAV:checked-in property (protected)
+                        properties.add(new HrefProperty(CHECKED_IN, baseVHref, true));
+                    }
+                } catch (RepositoryException e) {
+                    log.error(e.getMessage());
+                }
+            }
+        }
+    }
+
+    /**
+     * Add a {@link org.apache.jackrabbit.webdav.property.HrefProperty} with the specified property name and values.
+     *
+     * @param name
+     * @param values Array of {@link Value}s.
+     * @param isProtected
+     * @throws javax.jcr.ValueFormatException
+     * @throws IllegalStateException
+     * @throws javax.jcr.RepositoryException
+     */
+    private void addHrefProperty(DavPropertyName name, Value[] values,
+                                 boolean isProtected)
+            throws ValueFormatException, IllegalStateException, RepositoryException {
+        Node[] nodes = new Node[values.length];
+        for (int i = 0; i < values.length; i++) {
+            nodes[i] = getRepositorySession().getNodeByUUID(values[i].getString());
+        }
+        addHrefProperty(name, nodes, isProtected);
+    }
+
+    /**
+     * @return true, if this resource represents an existing repository node
+     * that has the mixin nodetype 'mix:versionable' set.
+     */
+    private boolean isVersionControlled() {
+        boolean vc = false;
+        if (exists()) {
+            try {
+                vc = ((Node) item).isNodeType(JcrConstants.MIX_VERSIONABLE);
+            } catch (RepositoryException e) {
+                log.warn(e.getMessage());
+            }
+        }
+        return vc;
+    }
+
+    /**
+     * Register the specified event listener with the observation manager present
+     * the repository session.
+     *
+     * @param listener
+     * @param nodePath
+     * @throws javax.jcr.RepositoryException
+     */
+    private void registerEventListener(EventListener listener, String nodePath) throws RepositoryException {
+        getRepositorySession().getWorkspace().getObservationManager().addEventListener(listener, EListener.ALL_EVENTS, nodePath, true, null, null, false);
+    }
+
+    /**
+     * Unregister the specified event listener with the observation manager present
+     * the repository session.
+     *
+     * @param listener
+     * @throws javax.jcr.RepositoryException
+     */
+    private void unregisterEventListener(EventListener listener) throws RepositoryException {
+        getRepositorySession().getWorkspace().getObservationManager().removeEventListener(listener);
+    }
+
+    //------------------------------------------------------< inner classes >---
+    /**
+     * Simple EventListener that creates a new {@link org.apache.jackrabbit.webdav.MultiStatusResponse} object
+     * for each event and adds it to the specified {@link org.apache.jackrabbit.webdav.MultiStatus}.
+     */
+    private class EListener implements EventListener {
+
+        private static final int ALL_EVENTS = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+
+        private final DavPropertyNameSet propNameSet;
+        private MultiStatus ms;
+
+        private EListener(DavPropertyNameSet propNameSet, MultiStatus ms) {
+            this.propNameSet = propNameSet;
+            this.ms = ms;
+        }
+
+        /**
+         * @see EventListener#onEvent(javax.jcr.observation.EventIterator)
+         */
+        public void onEvent(EventIterator events) {
+            while (events.hasNext()) {
+                try {
+                    Event e = events.nextEvent();
+                    String itemPath = e.getPath();
+                    DavResourceLocator loc = getLocatorFromResourcePath(itemPath);
+                    DavResource res = createResourceFromLocator(loc);
+                    ms.addResponse(new MultiStatusResponse(res, propNameSet));
+
+                } catch (DavException e) {
+                    // should not occur
+                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
+                } catch (RepositoryException e) {
+                    // should not occur
+                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
+                }
+            }
+        }
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/VersionControlledItemCollection.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,177 @@
+/*
+ * 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.lock;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.webdav.lock.*;
+
+import javax.jcr.lock.Lock;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>JcrActiveLock</code> wraps a {@link Lock JCR lock} object.
+ */
+public class JcrActiveLock extends AbstractActiveLock implements ActiveLock, DavConstants {
+
+    private static Logger log = Logger.getLogger(JcrActiveLock.class);
+
+    private final Lock lock;
+    private final boolean sessionScoped;
+
+    /**
+     * Create a new <code>ActiveLock</code> object with type '{@link Type#WRITE write}'
+     * and scope '{@link Scope#EXCLUSIVE exclusive}'.
+     *
+     * @param lock
+     */
+    public JcrActiveLock(Lock lock) {
+        this (lock, false);
+    }
+
+    /**
+     * Create a new <code>ActiveLock</code> object with type '{@link Type#WRITE write}'
+     * and scope '{@link Scope#EXCLUSIVE exclusive}'.
+     *
+     * @param lock
+     */
+    public JcrActiveLock(Lock lock, boolean sessionScoped) {
+        if (lock == null) {
+            throw new IllegalArgumentException("Can not create a ActiveLock with a 'null' argument.");
+        }
+        this.lock = lock;
+        this.sessionScoped = sessionScoped;
+    }
+
+    /**
+     * Return true if the given lock token equals the token holding that lock.
+     *
+     * @param lockToken
+     * @return true if the given lock token equals this locks token.
+     * @see org.apache.jackrabbit.webdav.lock.ActiveLock#isLockedByToken(String)
+     */
+    public boolean isLockedByToken(String lockToken) {
+        if (lockToken != null && lockToken.equals(getToken())) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * @see ActiveLock#isExpired()
+     */
+    public boolean isExpired() {
+        try {
+            return lock.isLive();
+        } catch (RepositoryException e) {
+            log.error("Unexpected error: " + e.getMessage());
+            return false;
+        }
+    }
+
+    /**
+     * Return the lock token if the {@link javax.jcr.Session} that optained the lock
+     * is the lock token holder, <code>null</code> otherwise.<br>
+     * NOTE: currently the token generated by the underlaying JCR repository
+     * is not checked for compliance with RFC 2518 ("<cite>OpaqueLockToken-URI = "opaquelocktoken:"
+     * UUID [Extension] ; The UUID production is the string representation of a
+     * UUID, as defined in [ISO-11578]. Note that white space (LWS) is not allowed
+     * between elements of this production.</cite>").
+     *
+     * @see ActiveLock#getToken()
+     */
+    public String getToken() {
+        return lock.getLockToken();
+    }
+
+    /**
+     * @see ActiveLock#getOwner()
+     */
+    public String getOwner() {
+        return lock.getLockOwner();
+    }
+
+    /**
+     * @see ActiveLock#setOwner(String)
+     */
+    public void setOwner(String owner) {
+        throw new UnsupportedOperationException("setOwner is not implemented");
+    }
+
+    /**
+     * Always returns {@link DavConstants#UNDEFINED_TIMEOUT} for the timeout
+     * cannot be retrieved from the JCR lock.
+     * 
+     * @see ActiveLock#getTimeout()
+     * @see DavConstants#UNDEFINED_TIMEOUT
+     */
+    public long getTimeout() {
+        return UNDEFINED_TIMEOUT;
+    }
+
+    /**
+     * @see ActiveLock#setTimeout(long)
+     */
+    public void setTimeout(long timeout) {
+        throw new UnsupportedOperationException("setTimeout is not implemented");
+    }
+
+    /**
+     * @see ActiveLock#isDeep()
+     */
+    public boolean isDeep() {
+        boolean isDeep = true;
+        Node n = lock.getNode();
+        try {
+            // find out about deepness. if node does not hold the lock its deep anyway
+            if (n.holdsLock() && n.hasProperty("jcr:lockIsDeep")) {
+                isDeep = n.getProperty("jcr:lockIsDeep").getBoolean();
+            }
+        } catch (RepositoryException e) {
+            // ignore and keep default depth settings
+        }
+        return isDeep;
+    }
+
+    /**
+     * @see ActiveLock#setIsDeep(boolean)
+     */
+    public void setIsDeep(boolean isDeep) {
+        throw new UnsupportedOperationException("setIsDeep is not implemented");
+    }
+
+    /**
+     * Always returns {@link Type#WRITE}.
+     *
+     * @return {@link Type#WRITE}
+     * @see ActiveLock#getType()
+     */
+    public Type getType() {
+        return Type.WRITE;
+    }
+
+    /**
+     * @return The scope of this lock, which may either by an {@link Scope#EXCLUSIVE exclusive}
+     * or {@link ItemResourceConstants#EXCLUSIVE_SESSION exlusive session scoped}
+     * lock.
+     * @see ActiveLock#getScope()
+     */
+    public Scope getScope() {
+        return (sessionScoped) ? ItemResourceConstants.EXCLUSIVE_SESSION : Scope.EXCLUSIVE;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/JcrActiveLock.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/SessionScopedLockEntry.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/SessionScopedLockEntry.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/SessionScopedLockEntry.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/SessionScopedLockEntry.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,48 @@
+/*
+ * 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.lock;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.lock.LockEntry;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+import org.apache.jackrabbit.webdav.lock.AbstractLockEntry;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+
+/**
+ * <code>SessionScopedLockEntry</code> represents the 'session-scoped' write
+ * lock as defined by JCR.
+ */
+public class SessionScopedLockEntry extends AbstractLockEntry {
+
+    private static Logger log = Logger.getLogger(SessionScopedLockEntry.class);
+
+    /**
+     * @return always returns {@link Type#WRITE write}.
+     * @see LockEntry#getType()
+     */
+    public Type getType() {
+        return Type.WRITE;
+    }
+
+    /**
+     * @return returns {@link ItemResourceConstants#EXCLUSIVE_SESSION}.
+     * @see LockEntry#getScope()
+     */
+    public Scope getScope() {
+        return ItemResourceConstants.EXCLUSIVE_SESSION;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/lock/SessionScopedLockEntry.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2004 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.nodetype;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.ItemDefinition;
+import javax.jcr.version.OnParentVersionAction;
+
+/**
+ * <code>ItemDefinitionImpl</code>...
+ */
+abstract public class ItemDefinitionImpl implements ItemDefinition, NodeTypeConstants {
+
+    private static Logger log = Logger.getLogger(ItemDefinitionImpl.class);
+
+    private final String name;
+    private NodeType declaringNodeType;
+    private final boolean isAutoCreated;
+    private final boolean isMandatory;
+    private final boolean isProtected;
+    private final int onParentVersion;
+
+    ItemDefinitionImpl(ItemDefinition definition) {
+	if (definition == null) {
+            throw new IllegalArgumentException("PropDef argument can not be null");
+        }
+
+        name = definition.getName();
+	declaringNodeType = definition.getDeclaringNodeType();
+	isAutoCreated = definition.isAutoCreated();
+	isMandatory = definition.isMandatory();
+	isProtected = definition.isProtected();
+	onParentVersion = definition.getOnParentVersion();
+    }
+
+    /**
+     * @see ItemDefinition#getDeclaringNodeType()
+     */
+    public NodeType getDeclaringNodeType() {
+	return declaringNodeType;
+    }
+
+    /**
+     * @see ItemDefinition#getName()
+     */
+    public String getName() {
+	return name;
+    }
+
+    /**
+     * @see ItemDefinition#isAutoCreated()
+     */
+    public boolean isAutoCreated() {
+	return isAutoCreated;
+    }
+
+    /**
+     * @see ItemDefinition#isMandatory()
+     */
+    public boolean isMandatory() {
+	return isMandatory;
+    }
+
+    /**
+     * @see ItemDefinition#getOnParentVersion()
+     */
+    public int getOnParentVersion() {
+	return onParentVersion;
+    }
+
+    /**
+     * @see ItemDefinition#isProtected()
+     */
+    public boolean isProtected() {
+	return isProtected;
+    }
+
+    //-------------------------------------< implementation specific method >---
+    /**
+     * Returns the Xml representation of a {@link ItemDefinition} object.
+     *
+     * @return Xml representation of the specified {@link ItemDefinition def}.
+     */
+    public Element toXml() {
+	Element elem = new Element(getElementName());
+        elem.setAttribute(NAME_ATTRIBUTE, getName());
+        elem.setAttribute(AUTOCREATED_ATTRIBUTE, Boolean.toString(isAutoCreated()));
+        elem.setAttribute(MANDATORY_ATTRIBUTE, Boolean.toString(isMandatory()));
+        elem.setAttribute(ONPARENTVERSION_ATTRIBUTE, OnParentVersionAction.nameFromValue(getOnParentVersion()));
+        elem.setAttribute(PROTECTED_ATTRIBUTE, Boolean.toString(isProtected()));
+        return elem;
+    }
+
+    /**
+     * Returns the name of the root element
+     *
+     * @return the name of the root element
+     */
+    public abstract String getElementName();
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/ItemDefinitionImpl.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2004 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.nodetype;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeDefinition;
+
+/**
+ * <code>NodeDefinitionImpl</code>...
+ */
+public final class NodeDefinitionImpl extends ItemDefinitionImpl implements NodeDefinition {
+
+    private static Logger log = Logger.getLogger(NodeDefinitionImpl.class);
+
+    private final NodeType[] requiredPrimaryTypes;
+    private final NodeType defaultPrimaryType;
+    private final boolean allowsSameNameSiblings;
+
+    private NodeDefinitionImpl(NodeDefinition definition) {
+	super(definition);
+
+	requiredPrimaryTypes = definition.getRequiredPrimaryTypes();
+	defaultPrimaryType = definition.getDefaultPrimaryType();
+	allowsSameNameSiblings = definition.allowsSameNameSiblings();
+    }
+
+    public static NodeDefinitionImpl create(NodeDefinition definition) {
+	if (definition instanceof NodeDefinitionImpl) {
+	    return (NodeDefinitionImpl) definition;
+	} else {
+	    return new NodeDefinitionImpl(definition);
+	}
+    }
+
+    //--------------------------------------------------< NodeDef interface >---
+    /**
+     * @see javax.jcr.nodetype.NodeDefinition#getRequiredPrimaryTypes()
+     */
+    public NodeType[] getRequiredPrimaryTypes() {
+	return requiredPrimaryTypes;
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeDefinition#getDefaultPrimaryType()
+     */
+    public NodeType getDefaultPrimaryType() {
+	return defaultPrimaryType;
+    }
+
+    /**
+     * @see javax.jcr.nodetype.NodeDefinition#allowsSameNameSiblings()
+     */
+    public boolean allowsSameNameSiblings() {
+        return allowsSameNameSiblings;
+    }
+
+    //-------------------------------------< implementation specific method >---
+    /**
+     * Returns xml representation
+     *
+     * @return xml representation
+     */
+    public Element toXml() {
+        Element elem = super.toXml();
+
+        elem.setAttribute(SAMENAMESIBLINGS_ATTRIBUTE, Boolean.toString(allowsSameNameSiblings()));
+
+        // defaultPrimaryType can be 'null'
+        NodeType defaultPrimaryType = getDefaultPrimaryType();
+        if (defaultPrimaryType != null) {
+            elem.setAttribute(DEFAULTPRIMARYTYPE_ATTRIBUTE, defaultPrimaryType.getName());
+        }
+        // reqPrimaryTypes: minimal set is nt:base.
+        NodeType[] nts = getRequiredPrimaryTypes();
+        Element reqPrimaryTypes = new Element(REQUIREDPRIMARYTYPES_ELEMENT);
+	for (int i = 0; i < nts.length; i++) {
+	    reqPrimaryTypes.addContent(new Element(REQUIREDPRIMARYTYPE_ELEMENT).setText(nts[i].getName()));
+	}
+        elem.addContent(reqPrimaryTypes);
+
+        return elem;
+    }
+
+    /**
+     * Returns {@link #CHILDNODEDEFINITION_ELEMENT}
+     *
+     * @return always returns {@link #CHILDNODEDEFINITION_ELEMENT}.
+     */
+    public String getElementName() {
+	return CHILDNODEDEFINITION_ELEMENT;
+    }
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeDefinitionImpl.java
------------------------------------------------------------------------------
    svn = 

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java?rev=180346&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java Mon Jun  6 10:36:09 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.nodetype;
+
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.jcr.ItemResourceConstants;
+import org.apache.jackrabbit.nodetype.xml.Constants;
+
+/**
+ * <code>NodeTypeConstants</code> used to represent nodetype definitions in
+ * Xml.
+ *
+ * @see javax.jcr.nodetype.NodeType
+ * @todo intercaps only for consistency with jackrabbit... webdav rfcs never use intercaps.
+ */
+public interface NodeTypeConstants extends Constants {
+
+    public static final Namespace NAMESPACE = ItemResourceConstants.NAMESPACE;
+
+    public static final String XML_NODETYPENAME = "nodetypename";
+
+    public static final String XML_REPORT_ALLNODETYPES = "allnodetypes";
+    public static final String XML_REPORT_MIXINNODETYPES = "mixinnodetypes";
+    public static final String XML_REPORT_PRIMARYNODETYPES = "primarynodetypes";
+
+    // report response
+    /** Name of the node type definition root element. */
+    public static final String XML_NODETYPES = "nodeTypes";
+
+    /** Name of the node type definition element. */
+    public static final String XML_NODETYPE = "nodeType";
+}
\ No newline at end of file

Propchange: incubator/jackrabbit/trunk/contrib/jcr-server/server/src/java/org/apache/jackrabbit/webdav/jcr/nodetype/NodeTypeConstants.java
------------------------------------------------------------------------------
    svn = 

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



Mime
View raw message