jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r156314 [14/15] - in incubator/jackrabbit/trunk/contrib/jcr-server: ./ client/ client/src/ client/src/java/ client/src/java/org/ client/src/java/org/apache/ client/src/java/org/apache/jackrabbit/ client/src/java/org/apache/jackrabbit/client/ server/ server/src/ server/src/java/ server/src/java/org/ server/src/java/org/apache/ server/src/java/org/apache/jackrabbit/ server/src/java/org/apache/jackrabbit/server/ server/src/java/org/apache/jackrabbit/server/simple/ server/src/java/org/apache/jackrabbit/server/simple/dav/ server/src/java/org/apache/jackrabbit/server/simple/dav/lock/ server/src/java/org/apache/jackrabbit/webdav/ server/src/java/org/apache/jackrabbit/webdav/spi/ server/src/java/org/apache/jackrabbit/webdav/spi/lock/ server/src/java/org/apache/jackrabbit/webdav/spi/nodetype/ server/src/java/org/apache/jackrabbit/webdav/spi/observation/ server/src/java/org/apache/jackrabbit/webdav/spi/search/ server/src/java/org/apache/jackrabbit/webdav/spi/transaction/ server/src/java/org/apache/jackrabbit/webdav/spi/version/ server/src/java/org/apache/jackrabbit/webdav/spi/version/report/ webapp/ webapp/src/ webapp/src/webapp/ webapp/src/webapp/WEB-INF/ webapp/src/webapp/WEB-INF/repository/ webdav/ webdav/src/ webdav/src/java/ webdav/src/java/org/ webdav/src/java/org/apache/ webdav/src/java/org/apache/jackrabbit/ webdav/src/java/org/apache/jackrabbit/webdav/ webdav/src/java/org/apache/jackrabbit/webdav/lock/ webdav/src/java/org/apache/jackrabbit/webdav/observation/ webdav/src/java/org/apache/jackrabbit/webdav/ordering/ webdav/src/java/org/apache/jackrabbit/webdav/property/ webdav/src/java/org/apache/jackrabbit/webdav/search/ webdav/src/java/org/apache/jackrabbit/webdav/transaction/ webdav/src/java/org/apache/jackrabbit/webdav/util/ webdav/src/java/org/apache/jackrabbit/webdav/version/ webdav/src/java/org/apache/jackrabbit/webdav/version/report/
Date Sun, 06 Mar 2005 14:03:12 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,113 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.DavSession;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+import org.apache.jackrabbit.webdav.version.report.Report;
+
+/**
+ * The <code>DeltaVResource</code> encapsultes the functionality common to all
+ * DeltaV compliant resources.
+ * <p/>
+ * RFC 3253 defines the following required properties:
+ * <ul>
+ * <li>{@link DeltaVConstants#COMMENT DAV:comment}</li>
+ * <li>{@link DeltaVConstants#CREATOR_DISPLAYNAME DAV:creator-displayname}</li>
+ * <li>{@link DeltaVConstants#SUPPORTED_METHOD_SET DAV:supported-method-set}</li>
+ * <li>{@link DeltaVConstants#SUPPORTED_LIVE_PROPERTY_SET DAV:supported-live-property-set}</li>
+ * <li>{@link DeltaVConstants#SUPPORTED_REPORT_SET DAV:supported-report-set}</li>
+ * <li>all properties defined in WebDAV [RFC2518].</li>
+ * </ul>
+ * <p/>
+ * In addition a DeltaV compliant resource must support the following METHODS:
+ * <ul>
+ * <li>REPORT</li>
+ * <li>all METHODS defined in WebDAV [RFC2518]</li>
+ * <li>all METHODS defined in HTTP/1.1 [RFC2616].</li>
+ * </ul>
+ *
+ * @see DavResource
+ */
+public interface DeltaVResource extends DavResource {
+
+    public String COMPLIANCE_CLASS = "version-control, checkout-in-place, version-history, update, label, merge, workspace";
+
+    /**
+     * The generic deltaV complient resource defines one additional method REPORT.
+     *
+     * @see DeltaVResource#METHODS
+     * @see org.apache.jackrabbit.webdav.DavResource#METHODS
+     */
+    public String METHODS = "REPORT, MKWORKSPACE";
+
+    /**
+     * Retrieves the information requested in the OPTIONS request body and
+     * returns the corresponding values.
+     *
+     * @param optionsInfo
+     * @return object to be included to the OPTIONS response body or <code>null</code>
+     * if the specified optionsInfo was <code>null</code> or empty.
+     */
+    public OptionsResponse getOptionResponse(OptionsInfo optionsInfo);
+
+    /**
+     * Runs the report specified by the given <code>ReportInfo</code>.
+     *
+     * @param reportInfo
+     * @return the requested report.
+     * @throws DavException in case an error occured or if the specified <code>ReportInfo</code>
+     * is either not valid or cannot be run by the given resource.
+     */
+    public Report getReport(ReportInfo reportInfo) throws DavException;
+
+    /**
+     * Add a new member to this resource, that represents a workspace.<br>
+     * Please note that no resource must exist at the location of the new workspace.
+     *
+     * @param workspace resource representing the new workspace to be created as
+     * member of this resource.
+     * @throws DavException if creating the new workspace fails.
+     * @todo MKWORKSPACE may include an xml request body...
+     */
+    public void addWorkspace(DavResource workspace) throws DavException;
+
+    /**
+     * Returns an array of <code>DavResource</code> objects that are referenced
+     * by the {@link org.apache.jackrabbit.webdav.property.HrefProperty} with
+     * the specified {@link DavPropertyName name}.
+     *
+     * @param hrefPropertyName
+     * @return An array of <code>DavResource</code>s
+     * @throws DavException if the given hrefPropertyName does point to an
+     * unknown property or does not represent the name of a
+     * {@link org.apache.jackrabbit.webdav.property.HrefProperty href property}.
+     * Finally the exception may be caused if the property contains the href
+     * of a non-existing resource, which cannot be resolved.
+     * @see org.apache.jackrabbit.webdav.property.HrefProperty
+     */
+    public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName) throws DavException;
+
+    /**
+     * Retrieve the <code>DavSession</code> associated with this resource.
+     *
+     * @return session object associated with this resource.
+     */
+    public DavSession getSession();
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/DeltaVServletRequest.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.DavServletRequest;
+import org.apache.jackrabbit.webdav.version.report.ReportInfo;
+
+/**
+ * <code>DeltaVServletRequest</code> provides extension useful for functionality
+ * related to RFC 3253.
+ */
+public interface DeltaVServletRequest extends DavServletRequest {
+
+    /**
+     * Returns the Label header or <code>null</code>
+     *
+     * @return label header or <code>null</code>
+     * @see DeltaVConstants#HEADER_LABEL
+     */
+    public String getLabel();
+
+    /**
+     * Return the request body as <code>LabelInfo</code> object or <code>null</code>
+     * if parsing the request body or the creation of the label info failed.
+     *
+     * @return <code>LabelInfo</code> object or <code>null</code>
+     */
+    public LabelInfo getLabelInfo();
+
+    /**
+     * Return the request body as <code>MergeInfo</code> object or <code>null</code>
+     * if the creation failed due to invalid format.
+     *
+     * @return <code>MergeInfo</code> object or <code>null</code>
+     */
+    public MergeInfo getMergeInfo();
+
+    /**
+     * Parses the UPDATE request body a build the corresponding <code>UpdateInfo</code>
+     * object. If the request body is missing or does not of the required format
+     * <code>null</code> is returned.
+     *
+     * @return the parsed update request body or <code>null</code>
+     */
+    public UpdateInfo getUpdateInfo();
+
+    /**
+     * Returns the request body and the Depth header as <code>ReportInfo</code>
+     * object. The default depth, if no {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_DEPTH
+     * Depth header}, is {@link org.apache.jackrabbit.webdav.DavConstants#DEPTH_0}.
+     * If the requuest body could not be parsed into an {@link org.jdom.Element}
+     * <code>null</code> is returned.
+     *
+     * @return <code>ReportInfo</code> or <code>null</code>
+     */
+    public ReportInfo getReportInfo();
+
+    /**
+     * Returns the {@link OptionsInfo} present with the request or <code>null</code>.
+     *
+     * @return {@link OptionsInfo} or <code>null</code>
+     */
+    public OptionsInfo getOptionsInfo();
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/LabelInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,159 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import java.util.Iterator;
+
+/**
+ * <code>LabelInfo</code> encapsulates the request body of a LABEL request
+ * used to add, set or remove a label from the requested version resource or
+ * from that version specified with the Label header in case the requested resource
+ * is a version-controlled resource.<br><br>
+ * The request body (thus the 'labelElement' passed to the constructore must be
+ * a DAV:label element:
+ * <pre>
+ * &lt;!ELEMENT label ANY&gt;
+ * ANY value: A sequence of elements with at most one DAV:add,
+ * DAV:set, or DAV:remove element.
+ * &lt;!ELEMENT add (label-name)&gt;
+ * &lt;!ELEMENT set (label-name)&gt;
+ * &lt;!ELEMENT remove (label-name)&gt;
+ * &lt;!ELEMENT label-name (#PCDATA)&gt;
+ * PCDATA value: string
+ * </pre>
+ */
+public class LabelInfo implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(LabelInfo.class);
+
+    public static final int TYPE_SET = 0;
+    public static final int TYPE_REMOVE = 1;
+    public static final int TYPE_ADD = 2;
+
+    private final Element labelElement;
+    private final int depth;
+
+    private int type;
+    private String labelName;
+
+    /**
+     * Create a new <code>LabelInfo</code> from the given element and depth
+     * integer. If the specified Xml element does have a {@link DeltaVConstants#XML_LABEL}
+     * root element or no label name is specified with the action to perform
+     * the creation will fail.
+     *
+     * @param labelElement
+     * @param depth
+     * @throws IllegalArgumentException if the specified element does not
+     * start with a {@link DeltaVConstants#XML_LABEL} element or if the DAV:label
+     * element contains illegal instructions e.g. contains multiple DAV:add, DAV:set
+     * or DAV:remove elements.
+     */
+    public LabelInfo(Element labelElement, int depth) {
+        if (labelElement == null || !labelElement.getName().equals(DeltaVConstants.XML_LABEL)) {
+            throw new IllegalArgumentException("label element expected");
+        }
+
+        this.labelElement = (Element) labelElement.detach();
+
+        Iterator childrenIter = labelElement.getChildren().iterator();
+        while (childrenIter.hasNext()) {
+            Element child = (Element) childrenIter.next();
+            if (!NAMESPACE.equals(child.getNamespace())) {
+                continue;
+            }
+            String name = child.getName();
+            if (XML_LABEL_ADD.equals(name)) {
+                type = TYPE_ADD;
+                setLabelName(child);
+            } else if (XML_LABEL_REMOVE.equals(name)) {
+                type = TYPE_REMOVE;
+                setLabelName(child);
+            } else if (XML_LABEL_SET.equals(name)) {
+                type = TYPE_SET;
+                setLabelName(child);
+            }
+        }
+        this.depth = depth;
+    }
+
+    /**
+     * Create a new <code>LabelInfo</code> from the given element. As depth
+     * the default value 0 is assumed.
+     *
+     * @param labelElement
+     * @throws IllegalArgumentException
+     * @see #LabelInfo(org.jdom.Element, int)
+     */
+    public LabelInfo(Element labelElement) {
+        this(labelElement, 0);
+    }
+
+    /**
+     * Return the 'label-name' or <code>null</code>
+     *
+     * @return 'label-name' or <code>null</code>
+     */
+    public String getLabelName() {
+        return labelName;
+    }
+
+    /**
+     * Retrieve the text of the 'label-name' child element of the specified
+     * parent element.
+     *
+     * @param parent the is intended to contain a valid 'label-name' child.
+     * @throws IllegalArgumentException if the labelName has been set before.
+     */
+    private void setLabelName(Element parent) {
+        // test if any label name is present
+        if (labelName != null) {
+            throw new IllegalArgumentException("The DAV:label element may contain at most one DAV:add, DAV:set, or DAV:remove element");
+        }
+        labelName = parent.getChildText(XML_LABEL_NAME, NAMESPACE);
+    }
+
+    /**
+     * Return the type of the LABEL request. This might either be {@link #TYPE_SET},
+     * {@link #TYPE_ADD} or {@link #TYPE_REMOVE}.
+     *
+     * @return type
+     */
+    public int getType() {
+        return type;
+    }
+
+    /**
+     * Return the depth
+     *
+     * @return depth
+     */
+    public int getDepth() {
+        return depth;
+    }
+
+    /**
+     * Return the DAV:label element
+     *
+     * @return the DAV:label element
+     */
+    public Element getLabelElement() {
+        return labelElement;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/MergeInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,117 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.jdom.Element;
+
+/**
+ * <code>MergeInfo</code> encapsulates the information present in the DAV:merge
+ * element, that forms the mandatory request body of a MERGE request.<br>
+ * The DAV:merge element is specified to have the following form.
+ * <pre>
+ * &lt;!ELEMENT merge ANY&gt;
+ * ANY value: A sequence of elements with one DAV:source element, at most one
+ * DAV:no-auto-merge element, at most one DAV:no-checkout element, at most one
+ * DAV:prop element, and any legal set of elements that can occur in a DAV:checkout
+ * element.
+ * &lt;!ELEMENT source (href+)&gt;
+ * &lt;!ELEMENT no-auto-merge EMPTY&gt;
+ * &lt;!ELEMENT no-checkout EMPTY&gt;
+ * prop: see <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518, Section 12.11</a>
+ * </pre>
+ */
+public class MergeInfo implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(MergeInfo.class);
+
+    private Element mergeElement;
+
+    /**
+     * Create a new <code>MergeInfo</code>
+     *
+     * @param mergeElement
+     * @throws IllegalArgumentException if the mergeElement is <code>null</code>
+     * or not a DAV:merge element.
+     */
+    public MergeInfo(Element mergeElement) {
+        if (mergeElement == null || !mergeElement.getName().equals(XML_MERGE)) {
+            throw new IllegalArgumentException("'DAV:merge' element expected");
+        }
+        this.mergeElement = (Element) mergeElement.detach();
+    }
+
+    /**
+     * Returns the URL specified with the DAV:source element or <code>null</code>
+     * if no such child element is present in the DAV:merge element.
+     *
+     * @return href present in the DAV:source child element or <code>null</code>.
+     */
+    public String getSourceHref() {
+        Element source = mergeElement.getChild(DavConstants.XML_SOURCE, DavConstants.NAMESPACE);
+        if (source != null) {
+            return source.getChildText(DavConstants.XML_HREF, DavConstants.NAMESPACE);
+        }
+        return null;
+    }
+
+    /**
+     * Returns true if the DAV:merge element contains a DAV:no-auto-merge child element.
+     *
+     * @return true if the DAV:merge element contains a DAV:no-auto-merge child.
+     */
+    public boolean isNoAutoMerge() {
+        return mergeElement.getChild(XML_N0_AUTO_MERGE, NAMESPACE) != null;
+    }
+
+    /**
+     * Returns true if the DAV:merge element contains a DAV:no-checkout child element.
+     *
+     * @return true if the DAV:merge element contains a DAV:no-checkout child
+     */
+    public boolean isNoCheckout() {
+        return mergeElement.getChild(XML_N0_CHECKOUT, NAMESPACE) != null;
+    }
+
+    /**
+     * Returns a {@link DavPropertyNameSet}. If the DAV:merge element contains
+     * a DAV:prop child element the properties specified therein are included
+     * in the set. Otherwise an empty set is returned.
+     *
+     * @return set listing the properties specified in the DAV:prop element indicating
+     * those properties that must be reported in the response body.
+     */
+    public DavPropertyNameSet getPropertyNameSet() {
+        Element propElement = mergeElement.getChild(DavConstants.XML_PROP, DavConstants.NAMESPACE);
+        if (propElement != null) {
+            return new DavPropertyNameSet(propElement);
+        } else {
+            return new DavPropertyNameSet();
+        }
+    }
+
+    /**
+     * Returns the DAV:merge element used to create this <code>MergeInfo</code>
+     * object.
+     *
+     * @return DAV:merge element
+     */
+    public Element getMergeElement() {
+        return mergeElement;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,81 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+import org.jdom.Namespace;
+
+import java.util.List;
+
+/**
+ * <code>OptionsInfo</code> represents the Xml request body, that may be present
+ * with a OPTIONS request.
+ * <br>
+ * The DAV:options element is specified to have the following form.
+ *
+ * <pre>
+ * &lt;!ELEMENT options ANY&gt;
+ * ANY value: A sequence of elements each at most onces.
+ * </pre>
+ *
+ * @see DeltaVConstants#XML_VH_COLLECTION_SET
+ * @see DeltaVConstants#XML_WSP_COLLECTION_SET
+ * @see DeltaVConstants#XML_ACTIVITY_COLLECTION_SET
+ */
+public class OptionsInfo {
+
+    private static Logger log = Logger.getLogger(OptionsInfo.class);
+
+    private final Element optionsElement;
+
+    /**
+     * Create a new <code>UpdateInfo</code> object.
+     *
+     * @param optionsElement
+     * @throws IllegalArgumentException if the updateElement is <code>null</code>
+     * or not a DAV:update element or if the element does not match the required
+     * structure.
+     */
+    public OptionsInfo(Element optionsElement) {
+         if (optionsElement == null || !optionsElement.getName().equals(DeltaVConstants.XML_OPTIONS)) {
+            throw new IllegalArgumentException("DAV:options element expected");
+        }
+        this.optionsElement = (Element) optionsElement.detach();
+    }
+
+    /**
+     * Returns the set of elements present in the {@link DeltaVConstants#XML_OPTIONS DAV:options}
+     * element. These elements define the information the client wishes to retrieve
+     * the OPTIONS request.
+     *
+     * @return set of child elements
+     */
+    public List getElements() {
+        return optionsElement.getChildren();
+    }
+
+    /**
+     * Returns true if a child element with the given name and namespace is present.
+     *
+     * @param name
+     * @param namespace
+     * @return true if such a child element exists in the options element.
+     */
+    public boolean containsElement(String name, Namespace namespace) {
+        return optionsElement.getChild(name, namespace) != null;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsResponse.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsResponse.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsResponse.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/OptionsResponse.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.Namespace;
+
+/**
+ * <code>OptionsResponse</code> encapsulates the DAV:options-response element
+ * present in the response body of a successful OPTIONS request (with body).
+ * <br>
+ * The DAV:options-response element is defined to have the following format.
+ *
+ * <pre>
+ * &lt;!ELEMENT options-response ANY&gt;
+ * ANY value: A sequence of elements
+ * </pre>
+ */
+public class OptionsResponse implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(OptionsResponse.class);
+
+    private final Element optionsResponse = new Element(XML_OPTIONS_RESPONSE, NAMESPACE);
+
+    /**
+     * Add a new entry to this <code>OptionsResponse</code>
+     *
+     * @param elem
+     */
+    public void addEntry(Element elem) {
+        optionsResponse.addContent(elem.detach());
+    }
+
+    /**
+     * Add a new entry to this <code>OptionsResponse</code> and make each
+     * href present in the String array being a separate {@link org.apache.jackrabbit.webdav.DavConstants#XML_HREF DAV:href}
+     * element within the entry.
+     *
+     * @param name
+     * @param namespace
+     * @param hrefs
+     */
+    public void addEntry(String name, Namespace namespace, String[] hrefs) {
+        Element elem = new Element(name, namespace);
+        for (int i = 0; i < hrefs.length; i++) {
+            elem.addContent(XmlUtil.hrefToXml(hrefs[i]));
+        }
+        optionsResponse.addContent(elem);
+    }
+
+    /**
+     * Return the Xml representation.
+     *
+     * @return Xml representation.
+     */
+    public Document toXml() {
+        return new Document(optionsResponse);
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/ResourceType.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,89 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+/**
+ * The <code>ResourceType</code> extends the {@link org.apache.jackrabbit.webdav.property.ResourceType}
+ * by DeltaV specific types.
+ */
+public class ResourceType extends org.apache.jackrabbit.webdav.property.ResourceType
+        implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(ResourceType.class);
+
+    /**
+     * The version-history resource type
+     */
+    public static final int VERSION_HISTORY = COLLECTION + 1;
+
+    /**
+     * The activity resource type
+     */
+    public static final int ACTIVITY = VERSION_HISTORY + 1;
+
+    /**
+     * The baseline resource type
+     */
+    public static final int BASELINE = ACTIVITY + 1;
+
+    /**
+     * Array containing all possible resourcetype elements
+     */
+    private static final String[] ELEMENT_NAMES = {
+        null,
+        XML_COLLECTION,
+        XML_VERSION_HISTORY,
+        XML_ACTIVITY,
+        XML_BASELINE
+    };
+
+
+    /**
+     * Create a resource type property
+     * 
+     * @param resourceType
+     */
+    public ResourceType(int resourceType) {
+        super(resourceType);
+    }
+
+    /**
+     * Return the resource type as Xml element.
+     *
+     * @return Xml element representing the internal type or <code>null</code>
+     * if the resource has no element name assigned (default resource type).
+     */
+    public Object getValue() {
+        String name = ELEMENT_NAMES[getResourceType()];
+        return (name != null) ? new Element(name, DeltaVConstants.NAMESPACE) : null;
+    }
+
+    /**
+     * Returns true if the given integer defines a valid resource type.
+     *
+     * @param resourceType to be validated.
+     * @return true if this is a known resource type.
+     */
+    public boolean isValidResourceType(int resourceType) {
+        if (resourceType < DEFAULT_RESOURCE || resourceType > BASELINE) {
+            return false;
+        }
+        return true;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/SupportedMethodSetProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/SupportedMethodSetProperty.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/SupportedMethodSetProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/SupportedMethodSetProperty.java Sun Mar  6 06:02:39 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.version;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.jdom.Element;
+
+/**
+ * The <code>SupportedMethodSetProperty</code>
+ */
+public class SupportedMethodSetProperty extends DefaultDavProperty implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(SupportedMethodSetProperty.class);
+
+    /**
+     * Create a new <code>SupportedMethodSetProperty</code> property.
+     *
+     * @param methods that are supported by the resource having this property.
+     */
+    public SupportedMethodSetProperty(String[] methods) {
+        super(DeltaVConstants.SUPPORTED_METHOD_SET, new Element[methods.length], true);
+
+        // fill the array with the proper elements
+        Element[] value = (Element[]) getValue();
+        for (int i = 0; i < methods.length; i++) {
+            Element methodElem = new Element(DeltaVConstants.XML_SUPPORTED_METHOD, DeltaVConstants.NAMESPACE);
+            methodElem.setAttribute("name",methods[i], DeltaVConstants.NAMESPACE);
+            value[i] = methodElem;
+        }
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/UpdateInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,146 @@
+/*
+ * 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.version;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.jdom.Element;
+
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * <code>UpdateInfo</code> encapsulates the request body of an UPDATE request.
+ * RFC 3253 defines the request body as follows:
+ * <pre>
+ * &lt;!ELEMENT update ANY&gt;
+ * ANY value: A sequence of elements with at most one DAV:version element and at
+ * most one DAV:prop element.
+ * &lt;!ELEMENT version (href)&gt;
+ * prop: see RFC 2518, Section 12.11
+ * </pre>
+ *
+ * In order to reflect the complete range of version restoring and updating
+ * of nodes defined by JSR170 the definition has been extended:
+ * <pre>
+ * &lt;!ELEMENT update ( (version+ | label-name | workspace ) , (prop)?, (removeExisting)? ) &gt;
+ * &lt;!ELEMENT version (href) &gt;
+ * &lt;!ELEMENT label-name (#PCDATA) &gt;
+ * &lt;!ELEMENT workspace (href) &gt;
+ * &lt;!ELEMENT prop ANY &gt;
+ * &lt;!ELEMENT removeExisting EMPTY &gt;
+ * </pre>
+ */
+public class UpdateInfo implements DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(UpdateInfo.class);
+
+    private final Element updateElement;
+    private String[] versionHref;
+    private String[] labelName;
+    private String workspaceHref;
+
+    /**
+     * Create a new <code>UpdateInfo</code> object.
+     *
+     * @param updateElement
+     * @throws IllegalArgumentException if the updateElement is <code>null</code>
+     * or not a DAV:update element or if the element does not match the required
+     * structure.
+     */
+    public UpdateInfo(Element updateElement) {
+         if (updateElement == null || !updateElement.getName().equals(DeltaVConstants.XML_UPDATE)) {
+            throw new IllegalArgumentException("DAV:update element expected");
+        }
+
+        List targetList;
+        if (!(targetList = updateElement.getChildren(XML_VERSION, NAMESPACE)).isEmpty()) {
+            Iterator it = targetList.iterator();
+            versionHref = new String[targetList.size()];
+            int i = 0;
+            while (it.hasNext()) {
+                Element versionElem = (Element) it.next();
+                versionHref[i] = versionElem.getChildText(DavConstants.XML_HREF, NAMESPACE);
+                i++;
+            }
+        } else if (!(targetList = updateElement.getChildren(XML_LABEL_NAME, NAMESPACE)).isEmpty()) {
+            Iterator it = targetList.iterator();
+            labelName = new String[targetList.size()];
+            int i = 0;
+            while (it.hasNext()) {
+                Element labelNameElem = (Element) it.next();
+                labelName[i] = labelNameElem.getText();
+                i++;
+            }
+        } else if (updateElement.getChild(XML_WORKSPACE, NAMESPACE) != null) {
+            workspaceHref = updateElement.getChild(XML_WORKSPACE, NAMESPACE).getChildText(DavConstants.XML_HREF, NAMESPACE);
+        } else {
+            throw new IllegalArgumentException("DAV:update element must contain either DAV:version, DAV:label-name or DAV:workspace child element.");
+        }
+
+        this.updateElement = (Element) updateElement.detach();
+    }
+
+    /**
+     *
+     * @return
+     */
+    public String[] getVersionHref() {
+       return versionHref;
+    }
+
+    /**
+     *
+     * @return
+     */
+    public String[] getLabelName() {
+       return labelName;
+    }
+
+    /**
+     *
+     * @return
+     */
+    public String getWorkspaceHref() {
+       return workspaceHref;
+    }
+
+    /**
+     * Returns a {@link DavPropertyNameSet}. If the DAV:update element contains
+     * a DAV:prop child element the properties specified therein are included
+     * in the set. Otherwise an empty set is returned.
+     *
+     * @return set listing the properties specified in the DAV:prop element indicating
+     * those properties that must be reported in the response body.
+     */
+    public DavPropertyNameSet getPropertyNameSet() {
+        Element propElement = updateElement.getChild(DavConstants.XML_PROP, DavConstants.NAMESPACE);
+        if (propElement != null) {
+            return new DavPropertyNameSet(propElement);
+        } else {
+            return new DavPropertyNameSet();
+        }
+    }
+
+    /**
+     *
+     * @return
+     */
+    public Element getUpdateElement() {
+        return updateElement;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionControlledResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,283 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+
+/**
+ * The <code>VersionControlledResource</code> represents in contrast to the
+ * <code>VersionableResource</code> a resource, that has already been put
+ * under version-control. This resource can be checked-in, checked-out and
+ * has its on {@link javax.jcr.version.VersionHistory version history}.
+ * <p/>
+ * RFC 3253 defines the following required properties for a
+ * version-controlled resource (vc-resource):
+ * <ul>
+ * <li>DAV:auto-version</li>
+ * <li>DAV:version-history (version-history)</li>
+ * <li>DAV:workspace (workspace)</li>
+ * <li>DAV:version-controlled-configuration (baseline)</li>
+ * <li>all DeltaV-compliant resource properties.</li>
+ * </ul>
+ *
+ * checked-in vc-resource:
+ * <ul>
+ * <li>DAV:checked-in</li>
+ * </ul>
+ *
+ * checked-out vc-resource:
+ * <ul>
+ * <li>DAV:checked-out</li>
+ * <li>DAV:predecessor-set</li>
+ * <li>DAV:checkout-fork (in-place-checkout or working resource)</li>
+ * <li>DAV:checkin-fork (in-place-checkout or working resource)</li>
+ * <li>DAV:merge-set (merge)</li>
+ * <li>DAV:auto-merge-set (merge)</li>
+ * <li>DAV:unreserved (activity)</li>
+ * <li>DAV:activity-set (activity)</li>
+ * </ul>
+ * <p/>
+ * In addition a version-controlled resource must support the following METHODS:
+ * <ul>
+ * <li>VERSION-CONTROL</li>
+ * <li>MERGE (merge)</li>
+ * <li>all DeltaV-compliant resource METHODS.</li>
+ * </ul>
+ *
+ * checked-in vc-resource:
+ * <ul>
+ * <li>CHECKOUT (checkout-in-place)</li>
+ * <li>UPDATE (update)</li>
+ * <li>all version-controlled resource METHODS.</li>
+ * </ul>
+ *
+ * checked-out vc-resource:
+ * <ul>
+ * <li>CHECKIN (checkout-in-place or working-resource)</li>
+ * <li>UNCHECKOUT (checkout-in-place)</li>
+ * <li>all DeltaV-compliant resource METHODS.</li>
+ * </ul>
+ *
+ * @see DeltaVResource
+ * @see VersionableResource
+ */
+public interface VersionControlledResource extends VersionableResource {
+
+    /**
+     * Methods defined for a checked-in version-controlled resource: CHECKOUT, UNCHECHKOUT, UPDATE, MERGE, LABEL
+     */
+    public String methods_checkedIn = "CHECKOUT, UNCHECHKOUT, UPDATE, MERGE, LABEL";
+    /**
+     * Methods defined for a checked-out version-controlled resource: CHECKIN, MERGE
+     */
+    public String methods_checkedOut = "CHECKIN, MERGE";
+
+    /**
+     * The DAV:auto-version property determines how it responds to a method that
+     * attempts to modify its content or dead properties. Possible responses
+     * include various combinations of automated checkout, write lock and checkin
+     * as well as failure until the resource is explicitely checked-out.<br>
+     * See <a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253</a> for a detailed
+     * description.
+     */
+    public static final DavPropertyName AUTO_VERSION = DavPropertyName.create("auto-version", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The computed property DAV:version-history identifies the version history
+     * resource for the DAV:checked-in or DAV:checked-out version of this
+     * version-controlled resource.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT version-history (href)&gt;
+     * </pre>
+     */
+    public static final DavPropertyName VERSION_HISTORY = DavPropertyName.create("version-history", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The DAV:checked-in property appears on a checked-in version-controlled
+     * resource, and identifies the base version of this version-controlled
+     * resource. This property is removed when the resource is checked out, and
+     * then added back (identifying a new version) when the resource is checked
+     * back in.<br>
+     * This property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT checked-in (href)&gt;
+     * </pre>
+     */
+    public static final DavPropertyName CHECKED_IN = DavPropertyName.create("checked-in", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The DAV:checked-out property identifies the base version of this resource.
+     * It is the same that was identified by the DAV:checked-in property at the
+     * time the resource was checked out. This property is removed when the
+     * resource is checked in.<br>
+     * This property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT checked-out (href)&gt;
+     * </pre>
+     *
+     * @see #CHECKED_IN
+     */
+    public static final DavPropertyName CHECKED_OUT = DavPropertyName.create("checked-out", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The DAV:predecessor-set property of a version-controlled resource points
+     * to those version resources, that are scheduled to become the predecessors
+     * of this resource when it is back checked-in. This property is not
+     * protected, however a server may reject attempts to modify the
+     * DAV:predecessor-set of a version-controlled resource.<br>
+     * This property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT predecessor-set (href+)&gt;
+     * </pre>
+     *
+     * @see #checkin()
+     * @see VersionResource#PREDECESSOR_SET
+     */
+    public static final DavPropertyName PREDECESSOR_SET = DavPropertyName.create("predecessor-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     *  This property determines the DAV:checkin-fork property of the version
+     * that results from checking in this resource.
+     */
+    public static final DavPropertyName CHECKIN_FORK = DavPropertyName.create("checkin-fork", DeltaVConstants.NAMESPACE);
+
+    /**
+     * This property determines the DAV:checkout-fork property of the version
+     * that results from checking in this resource.
+     */
+    public static final DavPropertyName CHECKOUT_FORK = DavPropertyName.create("checkout-fork", DeltaVConstants.NAMESPACE);
+
+    /**
+     * This property identifies each version that is to be merged into this
+     * checked-out resource. This property is set, whenever a MERGE request
+     * with the DAV:no-auto-merge flag succeeded. The client then must confirm
+     * each single merge by removing the version from the DAV:merge-set or
+     * moving it the the versions DAV:predecessor-set.<br>
+     * This property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT merge-set (href*)&gt;
+     * </pre>
+     *
+     * @see #merge(MergeInfo)
+     * @see #resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
+     */
+    public static final DavPropertyName MERGE_SET = DavPropertyName.create("merge-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The DAV:auto-merge-set property identifies each version that the server
+     * has merged into this checked-out resource. The client should confirm that
+     * the merge has been performed correctly before moving a URL from the
+     * DAV:auto-merge-set to the DAV:predecessor-set of a checked-out resource.<br>
+     * This property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT auto-merge-set (href*)&gt;
+     * </pre>
+     *
+     * @see #merge(MergeInfo)
+     * @see #resolveMergeConflict(DavPropertySet, DavPropertyNameSet)
+     */
+    public static final DavPropertyName AUTO_MERGE_SET = DavPropertyName.create("auto-merge-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * Perform a checkin on the version controlled resource.
+     *
+     * @return String representing the location of the version created by the
+     * checkin.
+     * @throws DavException if an error occurs.
+     */
+    public String checkin() throws DavException;
+
+    /**
+     * Perform a checkout on the version controlled resource.
+     *
+     * @throws DavException
+     */
+    public void checkout() throws DavException;
+
+    /**
+     * Perform an uncheckout on the version controlled resource.
+     * 
+     * @throws DavException
+     */
+    public void uncheckout() throws DavException;
+
+    /**
+     * Perform an update on this resource using the specified {@link UpdateInfo}.
+     *
+     * @param updateInfo
+     * @return <code>MultiStatus</code> containing the list of resources that
+     * have been modified by this update call.
+     * @throws DavException
+     */
+    public MultiStatus update(UpdateInfo updateInfo) throws DavException;
+
+    /**
+     * Perform a merge on this resource using the specified {@link MergeInfo}.
+     *
+     * @param mergeInfo
+     * @return <code>MultiStatus</code> containing the list of resources that
+     * have been modified.
+     * @throws DavException
+     */
+    public MultiStatus merge(MergeInfo mergeInfo) throws DavException;
+
+    /**
+     * Resolve one or multiple merge conflicts present on this resource. Please
+     * note that the 'setProperties' or 'removeProperties' set my contain additional
+     * resource properties, that need to be changed. Those properties are left
+     * untouched, whereas the {@link #AUTO_MERGE_SET}, {@link #MERGE_SET} and
+     * the {@link #PREDECESSOR_SET} are removed from the list upon successful
+     * resolution of a merge conflict.<br>
+     * If the removeProperties or setProperties set do not contain any of the
+     * mentioned resource properties or if the value of those properties do
+     * not allow for a resolution of an existing merge conflict, this METHODS
+     * returns silently.
+     *
+     * @param setProperties
+     * @param removePropertyNames
+     * @throws DavException the set or remove property sets attempt to resolve
+     * a non-existing merge conflict of if another error occurs while resolving
+     * an existing conflict.
+     */
+    public void resolveMergeConflict(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames) throws DavException;
+
+    /**
+     * Modify the labels of the version referenced by the DAV:checked-in property
+     * of this checked-in version-controlled resource. If the resource is not
+     * checked-in the request must fail.
+     *
+     * @param labelInfo
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see LabelInfo
+     * @see VersionResource#label(LabelInfo) for the pre- and postcondition of
+     * a successful LABEL request.
+     */
+    public void label(LabelInfo labelInfo) throws DavException;
+
+    /**
+     * Returns the <code>VersionHistoryResource</code>, that is referenced in the
+     * '{@link #VERSION_HISTORY version-history}' property.
+     *
+     * @return
+     * @throws DavException
+     */
+    public VersionHistoryResource getVersionHistory() throws DavException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionHistoryResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,73 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.DavException;
+
+/**
+ * <code>VersionHistoryResource</code> represents a collection that has
+ * all versions of a given version-controlled resource as members.
+ * <p/>
+ * RFC 3253 defines the following required properties for a version history:
+ * <ul>
+ * <li>DAV:version-set</li>
+ * <li>DAV:root-version</li>
+ * <li>all DeltaV-compliant resource properties.</li>
+ * </ul>
+ * <p/>
+ * In addition a version history resource must support the following METHODS:
+ * <ul>
+ * <li>all DeltaV-compliant resource METHODS.</li>
+ * </ul>
+ *
+ * NOTE: the {@link org.apache.jackrabbit.webdav.DavConstants#PROPERTY_RESOURCETYPE DAV:resourcetype}
+ * property must indicate 'DAV:version-history'.
+ *
+ * @see DeltaVResource
+ * @see ResourceType#VERSION_HISTORY
+ */
+public interface VersionHistoryResource extends DeltaVResource {
+
+    // supported METHODS: same as DeltaVResource > set to empty string
+    public static final String COMPLIANCE_CLASS = "";
+    // supported METHODS: same as DeltaVResource > set to empty string
+    public static final String METHODS = "";
+
+    /**
+     * Computed (protected) property identifying the root version of this version
+     * history.
+     */
+    public static final DavPropertyName ROOT_VERSION = DavPropertyName.create("root-version", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The protected property DAV:version-set identifies each version of this
+     * version history.
+     *
+     * @see #getVersions()
+     */
+    public static final DavPropertyName VERSION_SET = DavPropertyName.create("version-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * Returns an array of <code>VersionResource</code>s containing all versions
+     * that are a member of this resource.
+     *
+     * @return all <code>VersionResource</code>s that belong to this version history.
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see #VERSION_SET
+     */
+    public VersionResource[] getVersions() throws DavException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,167 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.DavException;
+
+/**
+ * <code>VersionResource</code> is a resource that contains a copy of a particular
+ * state of a version-controlled resource. A new version resource is created whenever
+ * a checked-out version-controlled resource is checked-in. The server allocates
+ * a distinct new URL for each new version, and this URL will never be used to
+ * identify any resource other than that version. The content and dead properties
+ * of a version never change.
+ * <p/>
+ * RFC 3253 defines the following required properties for a version resource:
+ * <ul>
+ * <li>DAV:predecessor-set  (protected)</li>
+ * <li>DAV:successor-set  (computed)</li>
+ * <li>DAV:checkout-set</li>
+ * <li>DAV:version-name</li>
+ * <li>DAV:checkout-fork (in-place-checkout or working resource)</li>
+ * <li>DAV:checkin-fork (in-place-checkout or working resource)</li>
+ * <li>DAV:version-history (version-history)</li>
+ * <li>DAV:label-name-set (label)</li>
+ * <li>DAV:activity-set (activity)</li>
+ * <li>all DeltaV-compliant resource properties.</li>
+ * </ul>
+ * <p/>
+ * In addition a version resource must support the following METHODS:
+ * <ul>
+ * <li>LABEL (label)</li>
+ * <li>CHECKOUT (working-resource)</li>
+ * <li>all DeltaV-compliant resource METHODS.</li>
+ * </ul>
+ *
+ * @see DeltaVResource
+ */
+public interface VersionResource extends DeltaVResource {
+
+    /**
+     * The version resource defines one additional method LABEL.
+     *
+     * @see DeltaVResource#METHODS
+     * @see org.apache.jackrabbit.webdav.DavResource#METHODS
+     */
+    public String METHODS = "LABEL";
+
+    /**
+     * Required protected property 'DAV:label-name-set' for a version of a webdav
+     * resource introduced with the 'LabelInfo' feature.
+     * This property contains the labels that currently select this version.<br>
+     * Property structure is defined as follows:<br>
+     * <pre>
+     * &lt;!ELEMENT label-name-set (label-name*)&gt;
+     * &lt;!ELEMENT label-name (#PCDATA)&gt;
+     * PCDATA value: string
+     * </pre>
+     */
+    public static final DavPropertyName LABEL_NAME_SET = DavPropertyName.create("label-name-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The protected DAV:predecessor property identifies each predecessor of
+     * this version. Except for the root version, which has no predecessors,
+     * each version has at least one predecessor.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT predecessor-set (href*)&gt;
+     * </pre>
+     */
+    public static final DavPropertyName PREDECESSOR_SET = DavPropertyName.create("predecessor-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The computed property DAV:successor-set identifies each version whose
+     * DAV:predecessor-set identifies this version.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT successor-set (href*)&gt;
+     * </pre>
+     *
+     */
+    public static final DavPropertyName SUCCESSOR_SET = DavPropertyName.create("successor-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The computed property  DAV:checkout-set identifies each checked-out
+     * resource whose DAV:checked-out property identifies this version.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT checkout-set (href*)&gt;
+     * </pre>
+     *
+     * @see VersionControlledResource#CHECKED_OUT
+     */
+    public static final DavPropertyName CHECKOUT_SET = DavPropertyName.create("checkout-set", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The protected property DAV:version-name defines a human readable id for
+     * this version. The id defined to be unique within the version-history this
+     * version belongs to.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT version-name (#PCDATA)&gt;
+     * PCDATA value: string
+     * </pre>
+     */
+    public static final DavPropertyName VERSION_NAME = DavPropertyName.create("version-name", DeltaVConstants.NAMESPACE);
+
+    /**
+     * The computed property DAV:version-history identifies the version history
+     * that contains this version.<br>
+     * The property is defined to have the following format:
+     * <pre>
+     * &lt;!ELEMENT version-history (href)&gt;
+     * </pre>
+     */
+    public static final DavPropertyName VERSION_HISTORY = DavPropertyName.create("version-history", DeltaVConstants.NAMESPACE);
+
+    /**
+     * This property controls the behavior of CHECKOUT when a version already
+     * is checked out or has a successor.
+     */
+    public static final DavPropertyName CHECKOUT_FORK = DavPropertyName.create("checkout-fork", DeltaVConstants.NAMESPACE);
+
+    /**
+     * This property controls the behavior of CHECKIN when a version already
+     * has a successor.
+     */
+    public static final DavPropertyName CHECKIN_FORK = DavPropertyName.create("checkin-fork", DeltaVConstants.NAMESPACE);
+
+    /**
+     * Modify the labels of this version resource. The modifications (SET, ADD or
+     * REMOVE) are listed in the specified <code>LabelInfo</code> object.<br>
+     * The case of a label name must be preserved when it is stored and retrieved.
+     * <br>If the type of modification is ADD, then the label must not yet occur on
+     * any other version within the same version history. In contrast a SET
+     * modification will move the indicated label to this version, if it existed
+     * with another version before. After a successful LABEL request the label
+     * must not appear with any other version in the same version history.
+     *
+     * @param labelInfo
+     * @throws org.apache.jackrabbit.webdav.DavException
+     * @see LabelInfo
+     */
+    public void label(LabelInfo labelInfo) throws DavException;
+
+    /**
+     * Returns the <code>VersionHistoryResource</code>, that is referenced in the
+     * {@link #VERSION_HISTORY DAV:version-history} property.
+     *
+     * @return
+     * @throws DavException
+     */
+    public VersionHistoryResource getVersionHistory() throws DavException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionableResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionableResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionableResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/VersionableResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.version;
+
+import org.apache.jackrabbit.webdav.DavException;
+
+/**
+ * <code>VersionableResource</code> represents an extension to the basic
+ * {@link DeltaVResource}, that allows to adding version-control support. By
+ * calling {@link #addVersionControl()} resource is put under version control,
+ * thus the versionable resource turns into a version controlled resource.
+ * <p/>
+ * RFC 3253 defines the following required properties for a versionable resource:
+ * <ul>
+ * <li>{@link DeltaVConstants#WORKSPACE DAV:workspace} (workspace feature)</li>
+ * <li>DAV:version-controlled-configuration (baseline feature)</li>
+ * <li>all DeltaV-compliant resource properties</li>
+ * </ul>
+ * <p/>
+ * In addition a versionable resource must support the following METHODS:
+ * <ul>
+ * <li>VERSION-CONTROL</li>
+ * <li>all DeltaV-compliant resource METHODS.</li>
+ * </ul>
+ *
+ * @see DeltaVResource
+ */
+public interface VersionableResource extends DeltaVResource {
+
+    /**
+     * No extra compliance class defined, therefore set to empty string
+     */
+    public static final String COMPLIANCE_CLASS = "";
+
+    /**
+     * The versionable resource defines one additional method VERSION-CONTROL.
+     *
+     * @see DeltaVResource#METHODS
+     * @see org.apache.jackrabbit.webdav.DavResource#METHODS
+     */
+    public String METHODS = "VERSION-CONTROL";
+
+    /**
+     * Converts this versionable resource into a version-controlled resource. If
+     * this resource is already version-controlled this resource is not affected.
+     * If however, this resource is not versionable an <code>DavException</code>
+     * (error code: {@link org.apache.jackrabbit.webdav.DavServletResponse#SC_METHOD_NOT_ALLOWED}
+     * is thrown. The same applies, if this resource is versionable but its
+     * current state does not allow to made it a version-controlled one or
+     * if any other error occurs.
+     *
+     * @throws org.apache.jackrabbit.webdav.DavException
+     */
+    public void addVersionControl() throws DavException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/package.html?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/package.html Sun Mar  6 06:02:39 2005
@@ -0,0 +1,4 @@
+<body>
+Interfaces and classes used to cover functionality defined by
+<a href="http://www.ietf.org/rfc/rfc3253.txt">RFC 3253: Versioning Extensions to WebDAV</a>.
+</body>
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/version/report/ExpandPropertyReport.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,230 @@
+/*
+ * 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.version.report;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.*;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.HrefProperty;
+import org.apache.jackrabbit.webdav.property.AbstractDavProperty;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+import org.apache.jackrabbit.webdav.version.DeltaVResource;
+import org.jdom.Element;
+import org.jdom.Attribute;
+import org.jdom.Namespace;
+import org.jdom.Document;
+
+import java.util.*;
+
+/**
+ * <code>ExpandPropertyReport</code> encapsulates the DAV:expand-property report,
+ * that provides a mechanism for retrieving in one request the properties from
+ * the resources identified by those DAV:href elements. It should be supported by
+ * all resources that support the REPORT method.
+ * <p/>
+ * RFC 3253 specifies the following required format for the request body:
+ * <pre>
+ * &lt;!ELEMENT expand-property (property*)&gt;
+ * &lt;!ELEMENT property (property*)&gt;
+ * &lt;!ATTLIST property name NMTOKEN #REQUIRED&gt;
+ * name value: a property element type
+ * &lt;!ATTLIST property namespace NMTOKEN "DAV:"&gt;
+ * namespace value: an XML namespace
+ * </pre>
+ * NOTE: any DAV:property elements defined in the request body, that does not
+ * represent {@link HrefProperty} is treated as in a common PROPFIND request.
+ *
+ * @see DeltaVConstants#XML_EXPAND_PROPERTY
+ * @see DeltaVConstants#XML_PROPERTY
+ */
+public class ExpandPropertyReport implements Report, DeltaVConstants {
+
+    private static Logger log = Logger.getLogger(ExpandPropertyReport.class);
+
+    private DeltaVResource resource;
+    private ReportInfo info;
+    private List properties;
+
+    /**
+     * Returns {@link ReportType#EXPAND_PROPERTY}.
+     *
+     * @return
+     * @see Report#getType()
+     */
+    public ReportType getType() {
+        return ReportType.EXPAND_PROPERTY;
+    }
+
+    /**
+     * Set the target resource.
+     *
+     * @param resource
+     * @throws IllegalArgumentException if the specified resource is <code>null</code>
+     * @see Report#setResource(org.apache.jackrabbit.webdav.version.DeltaVResource)
+     */
+    public void setResource(DeltaVResource resource) throws IllegalArgumentException {
+        if (resource == null) {
+            throw new IllegalArgumentException("The resource specified must not be null.");
+        }
+        this.resource = resource;
+    }
+
+    /**
+     * Set the <code>ReportInfo</code>.
+     *
+     * @param info
+     * @throws IllegalArgumentException if the given <code>ReportInfo</code>
+     * does not contain a DAV:expand-property element.
+     * @see Report#setInfo(ReportInfo)
+     */
+    public void setInfo(ReportInfo info) throws IllegalArgumentException {
+        if (info == null || !XML_EXPAND_PROPERTY.equals(info.getReportElement().getName())) {
+            throw new IllegalArgumentException("DAV:expand-property element expected.");
+        }
+        this.info = info;
+        properties = info.getReportElement().getChildren(XML_PROPERTY, NAMESPACE);
+    }
+
+    /**
+     * Run the report
+     *
+     * @return Xml <code>Document</code> as defined by
+     * <a href="http://www.ietf.org/rfc/rfc2518.txt">RFC 2518</a>
+     * @throws DavException
+     * @see Report#toXml()
+     */
+    public Document toXml() throws DavException {
+        if (info == null || resource == null) {
+            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while running DAV:version-tree report");
+        }
+
+        MultiStatus ms = new MultiStatus();
+        buildMultiStatus(resource, info.getDepth(), ms);
+        return ms.toXml();
+    }
+
+    /**
+     * Fills the specified <code>MultiStatus</code> object by generating a
+     * <code>MultiStatusResponse</code> for the given resource (and
+     * its member according to the depth value).
+     *
+     * @param res
+     * @param depth
+     * @param ms
+     * @throws DavException
+     * @see #getResponse(DavResource, List)
+     */
+    private void buildMultiStatus(DavResource res, int depth, MultiStatus ms)
+            throws DavException {
+        MultiStatusResponse response = getResponse(res, properties);
+        ms.addResponse(response);
+        if (depth > 0) {
+            DavResourceIterator it = res.getMembers();
+            while (it.hasNext()) {
+                buildMultiStatus(it.nextResource(), depth-1, ms);
+            }
+        }
+    }
+
+    /**
+     * Builds a <code>MultiStatusResponse</code> for the given resource respecting
+     * the properties specified. Any property that represents a {@link HrefProperty}
+     * is expanded: It's name equals the name of a valid {@link HrefProperty}.
+     * However the value of that given property (consisting of one or multiple DAV:href elements)
+     * is replaced by the Xml representation of a separate
+     * {@link MultiStatusResponse multistatus responses} for the
+     * resource referenced by the given DAV:href elements. The responses may
+     * themselves have properties, which are defined by the separate list.
+     *
+     * @param res
+     * @param propertyList
+     * @return <code>MultiStatusResponse</code> for the given resource.
+     * @see ExpandProperty
+     */
+    private MultiStatusResponse getResponse(DavResource res, List propertyList) {
+        MultiStatusResponse resp = new MultiStatusResponse(res.getHref());
+        Iterator propIter = propertyList.iterator();
+        while (propIter.hasNext()) {
+            Element propertyElem = (Element) propIter.next();
+            Attribute nameAttr = propertyElem.getAttribute(ATTR_NAME);
+            if (nameAttr == null) {
+                // NOTE: this is not valid according to the DTD
+                continue;
+            }
+            Attribute namespaceAttr = propertyElem.getAttribute(ATTR_NAMESPACE);
+
+            String name = nameAttr.getValue();
+            Namespace namespace = (namespaceAttr != null) ? Namespace.getNamespace(namespaceAttr.getValue()) : NAMESPACE;
+
+            DavPropertyName propName = DavPropertyName.create(name, namespace);
+            DavProperty p = res.getProperty(propName);
+            if (p != null) {
+                if (p instanceof HrefProperty && res instanceof DeltaVResource) {
+                    resp.add(new ExpandProperty((DeltaVResource)res, (HrefProperty)p, propertyElem.getChildren(XML_PROPERTY, NAMESPACE)));
+                } else {
+                    resp.add(p);
+                }
+            } else {
+                resp.add(propName, DavServletResponse.SC_NOT_FOUND);
+            }
+        }
+        return resp;
+    }
+
+    //--------------------------------------------------------< inner class >---
+    /**
+     * <code>ExpandProperty</code> extends <code>DavProperty</code>. It's name
+     * equals the name of a valid {@link HrefProperty}. However the value of
+     * that given property (consisting of one or multiple DAV:href elements)
+     * is replaced by the Xml representation of a separate
+     * {@link MultiStatusResponse multistatus responses} for the
+     * resource referenced to by the given DAV.:href elements. The responses may
+     * themselves have properties, which are defined by the separate list.
+     */
+    private class ExpandProperty extends AbstractDavProperty {
+
+        private List valueList = new ArrayList();
+
+        /**
+         * Create a new <code>ExpandProperty</code>.
+         *
+         * @param hrefProperty
+         * @param propertyList
+         */
+        private ExpandProperty(DeltaVResource deltaVResource, HrefProperty hrefProperty, List propertyList) {
+            super(hrefProperty.getName(), hrefProperty.isProtected());
+            try {
+                DavResource[] refResource = deltaVResource.getReferenceResources(hrefProperty.getName());
+                for (int i = 0; i < refResource.length; i++) {
+                    MultiStatusResponse resp = getResponse(refResource[i], propertyList);
+                    valueList.add(resp.toXml());
+                }
+            } catch (DavException e) {
+                // invalid references or unknown property
+                log.error(e.getMessage());
+            }
+        }
+
+        /**
+         * Returns
+         * @return
+         */
+        public Object getValue() {
+            return valueList;
+        }
+    }
+}
\ No newline at end of file

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

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



Mime
View raw message