jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r156314 [11/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:11 GMT
Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionInfo.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,148 @@
+/*
+ * 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.observation;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.jdom.Element;
+
+import java.util.List;
+
+/**
+ * <code>SubscriptionInfo</code> class encapsulates the subscription info
+ * that forms the request body of a SUBSCRIBE request.
+ * @see ObservationConstants#XML_SUBSCRIPTIONINFO
+ */
+public class SubscriptionInfo implements ObservationConstants {
+
+    private static Logger log = Logger.getLogger(SubscriptionInfo.class);
+
+    private Element info;
+    private List eventTypes;
+    private long timeout;
+    private boolean isDeep;
+
+    /**
+     * Create a new <code>SubscriptionInfo</code>
+     *
+     * @param reqInfo Xml element present in the request body.
+     * @param timeout as defined by the {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_TIMEOUT timeout header}.
+     * @param isDeep as defined by the {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_DEPTH depth header}.
+     * @throws IllegalArgumentException if the reqInfo element does not contain the mandatory elements.
+     */
+    public SubscriptionInfo(Element reqInfo, long timeout, boolean isDeep) {
+        if (!XML_SUBSCRIPTIONINFO.equals(reqInfo.getName())) {
+            throw new IllegalArgumentException("Element with name 'subscriptioninfo' expected");
+        }
+        if (reqInfo.getChild(XML_EVENTTYPE, NAMESPACE) == null ) {
+            throw new IllegalArgumentException("'subscriptioninfo' must contain an 'eventtype' child element.");
+        }
+
+        eventTypes = reqInfo.getChild(XML_EVENTTYPE, NAMESPACE).getChildren();
+        if (eventTypes.size() == 0) {
+            throw new IllegalArgumentException("'subscriptioninfo' must at least indicate a single event type.");
+        }
+
+        // detach the request info, in order to remove the reference to the parent
+        this.info = (Element)reqInfo.detach();
+        this.isDeep = isDeep;
+        setTimeOut(timeout);
+    }
+
+    /**
+     * Return list of event types Xml elements present in the subscription info.
+     * NOTE: the elements need to be detached in order to be added as content
+     * to any other Xml element.
+     *
+     * @return List of Xml elements defining which events this subscription should
+     * listen to.
+     *
+     */
+    public List getEventTypes() {
+        return eventTypes;
+    }
+
+    /**
+     * Return array of filters with the specified name.
+     *
+     * @param name the filter elments must provide.
+     * @return array containing the text of the filter elements with the given
+     * name.
+     */
+    public String[] getFilters(String name) {
+        String[] filters = null;
+        Element filter = info.getChild(XML_FILTER);
+        if (filter != null) {
+            List li = filter.getChildren(name);
+            if (!li.isEmpty()) {
+                filters = new String[li.size()];
+                for (int i = 0; i < filters.length; i++) {
+                    filters[i] = ((Element)li.get(i)).getText();
+                }
+            }
+        }
+        return filters;
+    }
+
+    /**
+     * Returns true if the {@link #XML_NOLOCAL} element is present in this
+     * subscription info.
+     *
+     * @return if {@link #XML_NOLOCAL} element is present.
+     */
+    public boolean isNoLocal() {
+        return info.getChild(XML_NOLOCAL, NAMESPACE) != null;
+    }
+
+    /**
+     * Returns true if the {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_DEPTH
+     * depths header} defined a depth other than '0'.
+     *
+     * @return true if this subscription info was created with <code>isDeep</code>
+     * true.
+     */
+    public boolean isDeep() {
+        return isDeep;
+    }
+
+    /**
+     * Return the timeout as retrieved from the request.
+     *
+     * @return timeout.
+     */
+    public long getTimeOut() {
+        return timeout;
+    }
+
+    /**
+     * Set the timeout. NOTE: no validation is made.
+     *
+     * @param timeout as defined by the {@link org.apache.jackrabbit.webdav.DavConstants#HEADER_TIMEOUT}.
+     */
+    public void setTimeOut(long timeout) {
+        this.timeout = timeout;
+    }
+
+    /**
+     * Xml representation of this <code>SubscriptionInfo</code>.
+     *
+     * @return Xml representation
+     */
+    public Element[] toXml() {
+        Element[] elems = { info, XmlUtil.depthToXml(isDeep), XmlUtil.timeoutToXml(timeout)};
+        return elems;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/SubscriptionManager.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.observation;
+
+import org.apache.jackrabbit.webdav.DavException;
+
+/**
+ * <code>SubscriptionManager</code> interface.
+ */
+public interface SubscriptionManager {
+
+    /**
+     * Retrieve the {@link org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery} object for the given
+     * resource. Note, that the discovery object will be empty if there are
+     * no subscriptions present.
+     *
+     * @param resource
+     */
+    public SubscriptionDiscovery getSubscriptionDiscovery(ObservationResource resource);
+
+    /**
+     * Create a new <code>Subscription</code> or update an existing <code>Subscription</code>..
+     *
+     * @param info
+     * @param subscriptionId
+     * @param resource
+     * @return <code>Subscription</code> that has been created or updated
+     * @throws DavException if the subscription fails
+     */
+    public Subscription subscribe(SubscriptionInfo info, String subscriptionId,
+                                  ObservationResource resource)
+            throws DavException;
+
+    /**
+     * Unsubscribe the <code>Subscription</code> with the given id.
+     *
+     * @param subscriptionId
+     * @param resource
+     * @throws DavException
+     */
+    public void unsubscribe(String subscriptionId, ObservationResource resource)
+            throws DavException;
+
+    /**
+     * Retrieve the list of events that occured since the last poll.
+     *
+     * @param subscriptionId indentifier for the subscription
+     * @param resource
+     * @return
+     */
+    public EventDiscovery poll(String subscriptionId, ObservationResource resource)
+            throws DavException;
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/package.html?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/observation/package.html Sun Mar  6 06:02:39 2005
@@ -0,0 +1,4 @@
+<body>
+Contains interfaces and classes related to observation, which is not covered
+by the WebDAV protocol.
+</body>
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderPatch.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,152 @@
+/*
+ * 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.ordering;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.jdom.Element;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+/**
+ * <code>OrderPatch</code> represents the mandatory request body of an
+ * ORDERPATCH request. RFC 3648 defines the following structure for it:<br>
+ * <pre>
+ * &lt;!ELEMENT orderpatch (ordering-type?, order-member*) &gt;
+ * &lt;!ELEMENT order-member (segment, position) &gt;
+ * &lt;!ELEMENT position (first | last | before | after) &gt;
+ * &lt;!ELEMENT segment (#PCDATA) &gt;
+ * &lt;!ELEMENT first EMPTY &gt;
+ * &lt;!ELEMENT last EMPTY &gt;
+ * &lt;!ELEMENT before segment &gt;
+ * &lt;!ELEMENT after segment &gt;
+ * </pre>
+ */
+public class OrderPatch implements OrderingConstants{
+
+    private static Logger log = Logger.getLogger(OrderPatch.class);
+
+    private Member[] instructions;
+    private String orderingType;
+
+    /**
+     * Create a new <code>OrderPath</code> object.
+     *
+     * @param orderPatchElement
+     * @throws IllegalArgumentException if the specified Xml element was not valid.
+     */
+    public OrderPatch(Element orderPatchElement) {
+        if (!OrderingConstants.XML_ORDERPATCH.equals(orderPatchElement.getName()) ||
+                orderPatchElement.getChild(OrderingConstants.XML_ORDERING_TYPE) == null) {
+            throw new IllegalArgumentException("ORDERPATH request body must start with an 'orderpatch' element, which must contain an 'ordering-type' child element.");
+        }
+        // retrieve the orderingtype element
+        orderingType = orderPatchElement.getChild(OrderingConstants.XML_ORDERING_TYPE).getChildText(DavConstants.XML_HREF);
+
+        // set build the list of ordering instructions
+        List oMembers = orderPatchElement.getChildren(OrderingConstants.XML_ORDER_MEMBER, DavConstants.NAMESPACE);
+        Iterator it = oMembers.iterator();
+        int cnt = 0;
+        List tmpInst = new ArrayList();
+        while (it.hasNext()) {
+            Element member = (Element) it.next();
+            try {
+                String segment = member.getChildText(OrderingConstants.XML_SEGMENT);
+                Position pos = new Position(member.getChild(OrderingConstants.XML_POSITION));
+                Member om = new Member(segment, pos);
+                tmpInst.add(om);
+                cnt++;
+            } catch (IllegalArgumentException e) {
+                log.error("Invalid element in 'orderpatch' request body: " + e.getMessage());
+            }
+        }
+        instructions = (Member[]) tmpInst.toArray(new Member[cnt]);
+    }
+
+    /**
+     * Create a new <code>OrderPath</code> object.
+     *
+     * @param orderingType
+     * @param instructions
+     */
+    public OrderPatch(String orderingType, Member[] instructions) {
+        this.orderingType = orderingType;
+        this.instructions = instructions;
+    }
+
+    /**
+     * Return the ordering type.
+     *
+     * @return ordering type
+     */
+    public String getOrderingType() {
+        return orderingType;
+    }
+
+    /**
+     * Return an array of {@link Member} objects defining the re-ordering
+     * instructions to be applied to the requested resource.
+     *
+     * @return ordering instructions.
+     */
+    public Member[] getOrderInstructions() {
+        return instructions;
+    }
+
+    //--------------------------------------------------------------------------
+    /**
+     * Internal class <code>Member</code> represents the 'Order-Member' children
+     * elements of an 'OrderPatch' request body present in the ORDERPATCH request.
+     */
+    public class Member {
+
+        private String memberHandle;
+        private Position position;
+
+        /**
+         * Create a new <code>Member</code> object.
+         *
+         * @param memberHandle
+         * @param position
+         */
+        public Member(String memberHandle, Position position) {
+            this.memberHandle = memberHandle;
+            this.position = position;
+        }
+
+        /**
+         * Return the handle of the internal member to be reordered.
+         *
+         * @return handle of the internal member.
+         */
+        public String getMemberHandle() {
+            return memberHandle;
+        }
+
+        /**
+         * Return the position where the internal member identified by the
+         * member handle should be placed.
+         *
+         * @return position for the member after the request.
+         * @see #getMemberHandle()
+         */
+        public Position getPosition() {
+            return position;
+        }
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingConstants.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingConstants.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingConstants.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingConstants.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,96 @@
+/*
+ * 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.ordering;
+
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+/**
+ * <code>OrderingConstants</code> provide constants for request and response
+ * headers, Xml elements and property names defined by
+ * <a href="http://www.ietf.org/rfc/rfc3648.txt">RFC 3648</a>.
+ */
+public interface OrderingConstants {
+
+    /**
+     * The "Ordering-Type" request header.
+     */
+    public static final String HEADER_ORDERING_TYPE = "Ordering-Type";
+
+    /**
+     * When a new member is added to a collection with a client-maintained
+     * ordering (for example, with PUT, COPY, or MKCOL), its position in the
+     * ordering can be set with the new Position header.<br><br>
+     * <code>
+     * Position = "Position" ":" ("first" | "last" | (("before" | "after") segment))
+     * </code>
+     * <br><br>NOTE: segment is defined in section 3.3 of RFC2396.
+     */
+    public static final String HEADER_POSITION = "Position";
+
+    /**
+     * Xml elements used for reordering internal members of a collection.
+     */
+    public static final String XML_ORDERPATCH = "orderpatch";
+    public static final String XML_ORDERING_TYPE = "ordering-type";
+    public static final String XML_ORDER_MEMBER = "order-member";
+    public static final String XML_POSITION = "position";
+    public static final String XML_SEGMENT = "segment";
+
+    public static final String XML_FIRST = "first";
+    public static final String XML_LAST = "last";
+    public static final String XML_BEFORE = "before";
+    public static final String XML_AFTER = "after";
+
+    /**
+     * Constant representing the DAV:custom ordering type URI, which indicates
+     * that the collection is not ordered.
+     */
+    public static final String ORDERING_TYPE_CUSTOM = "DAV:custom";
+
+    /**
+     * Constant representing the DAV:unordered ordering type URI, which indicates
+     * that the collection is to be ordered, but the semantics of the ordering
+     * is not being advertised.
+     */
+    public static final String ORDERING_TYPE_UNORDERED = "DAV:unordered";
+
+    /**
+     * The DAV:ordering-type property indicates whether the collection is
+     * ordered and, if so, uniquely identifies the semantics of the ordering.
+     *
+     * @see OrderingType
+     */
+    public static final DavPropertyName ORDERING_TYPE = DavPropertyName.create("ordering-type", DavConstants.NAMESPACE);
+
+    /**
+     * Required live property for resources that honor the 'ordered-collections'
+     * compliance class defined by RFC 3648.<br>
+     * The supported-method-set property has been introduced with RFC 3253.
+     *
+     * @see org.apache.jackrabbit.webdav.version.DeltaVConstants#SUPPORTED_METHOD_SET
+     */
+    public static final DavPropertyName SUPPORTED_METHOD_SET = DavPropertyName.create("supported-method-set", DavConstants.NAMESPACE);
+
+    /**
+     * Required live property for resources that honor the 'ordered-collections'
+     * compliance class defined by RFC 3648.<br>
+     * The supported-live-property-set property has been introduced with RFC 3253.
+     *
+     * @see org.apache.jackrabbit.webdav.version.DeltaVConstants#SUPPORTED_LIVE_PROPERTY_SET
+     */
+    public static final DavPropertyName SUPPORTED_LIVE_PROPERTY_SET = DavPropertyName.create("supported-live-property-set", DavConstants.NAMESPACE);
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingDavServletRequest.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingDavServletRequest.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingDavServletRequest.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingDavServletRequest.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.ordering;
+
+import org.apache.jackrabbit.webdav.DavServletRequest;
+
+/**
+ * <code>OrderingDavServletRequest</code> provides extensions to the
+ * {@link DavServletRequest} interface used for ordering members of orderable
+ * collections.
+ */
+public interface OrderingDavServletRequest extends DavServletRequest {
+
+    /**
+     * Returns the {@link OrderingConstants#HEADER_ORDERING_TYPE Ordering-Type header}.
+     *
+     * @return the String value of the {@link OrderingConstants#HEADER_ORDERING_TYPE Ordering-Type header}.
+     */
+    public String getOrderingType();
+
+    /**
+     * Return a <code>Position</code> object encapsulating the {@link OrderingConstants#HEADER_POSITION
+     * Position header} field or <code>null</code> if no Position header is present
+     * or does not contain a valid format.
+     *
+     * @return <code>Position</code> object encapsulating the {@link OrderingConstants#HEADER_POSITION
+     * Position header}
+     */
+    public Position getPosition();
+
+    /**
+     * Return a <code>OrderPatch</code> object encapsulating the request body
+     * of an ORDERPATCH request or <code>null</code> if the request body was
+     * either missing or could not be parsed.
+     *
+     * @return <code>OrderPatch</code> object encapsulating the request body.
+     */
+    public OrderPatch getOrderPatch();
+
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingResource.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingResource.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingResource.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingResource.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,47 @@
+/*
+ * 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.ordering;
+
+import org.apache.jackrabbit.webdav.DavResource;
+import org.apache.jackrabbit.webdav.DavException;
+
+/**
+ * <code>OrderingResource</code> extends the {@link DavResource} interface by
+ * METHODS relating to ordering functionality defined by
+ * <a href="http://www.ietf.org/rfc/rfc3648.txt">RFC 3648</a>.
+ */
+public interface OrderingResource extends DavResource {
+
+    public String COMPLIANCE_CLASS = "ordered-collections";
+    public String METHODS = "ORDERPATCH";
+
+    /**
+     * Returns true if this resources allows ordering of its internal members.
+     *
+     * @return true if internal members are orderable.
+     */
+    public boolean isOrderable();
+
+    /**
+     * Reorders the internal members of this resource according to the
+     * instructions present in the specified {@link OrderPatch} object.
+     *
+     * @param orderPatch as present in the ORDERPATCH request body.
+     * @throws DavException
+     */
+    public void orderMembers(OrderPatch orderPatch) throws DavException;
+
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingType.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/OrderingType.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,59 @@
+/*
+ * 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.ordering;
+
+import org.jdom.Element;
+import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+
+/**
+ * <code>OrderingType</code> represents the {@link #ORDERING_TYPE
+ * DAV:ordering-type} property as defined by
+ * <a href="http://www.ietf.org/rfc/rfc3648.txt">RFC 3648</a>. This property is
+ * protected cannot be set using PROPPATCH. Its value may only be set by
+ * including the Ordering-Type header with a MKCOL request or by submitting an
+ * ORDERPATCH request.
+ *
+ * @see org.apache.jackrabbit.webdav.property.DavProperty#isProtected()
+ */
+public class OrderingType extends DefaultDavProperty implements OrderingConstants {
+
+    /**
+     * Create an OrderingType with the given ordering.<br>
+     * NOTE: the ordering-type property is defined to be protected.
+     *
+     * @param href
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#isProtected()
+     */
+    public OrderingType(String href) {
+        super(ORDERING_TYPE, href, true);
+    }
+
+    /**
+     * Returns the Xml representation of this property. If the property has
+     * a <code>null</code> value, the default ({@link #ORDERING_TYPE_UNORDERED
+     * DAV:unordered}) is assumed.
+     *
+     * @return Xml representation
+     */
+    public Element toXml() {
+        Element elem = getName().toXml();
+        // spec requires that the default is 'DAV:unordered'
+        String href = (getValue() != null) ? getValue().toString() : ORDERING_TYPE_UNORDERED;
+        XmlUtil.hrefToXml(href);
+        return elem;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/Position.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,155 @@
+/*
+ * 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.ordering;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import java.util.HashMap;
+
+/**
+ * <code>Position</code> encapsulates the position in ordering information
+ * contained in a Webdav request. This includes both the
+ * {@link OrderingConstants#HEADER_POSITION Position header} and the position
+ * Xml element present in the request body of an ORDERPATCH request.
+ *
+ * @see OrderingConstants#HEADER_POSITION
+ * @see OrderingConstants#XML_POSITION
+ * @see OrderPatch
+ */
+public class Position implements OrderingConstants {
+
+    private static Logger log = Logger.getLogger(Position.class);
+
+    public static final int TYPE_FIRST = 1;
+    public static final int TYPE_LAST = 2;
+    public static final int TYPE_BEFORE = 4;
+    public static final int TYPE_AFTER = 8;
+
+    private static final HashMap xmlTypeMap = new HashMap(4);
+    static {
+        xmlTypeMap.put(XML_FIRST, new Integer(TYPE_FIRST));
+        xmlTypeMap.put(XML_LAST, new Integer(TYPE_LAST));
+        xmlTypeMap.put(XML_BEFORE, new Integer(TYPE_BEFORE));
+        xmlTypeMap.put(XML_AFTER, new Integer(TYPE_AFTER));
+    }
+
+    private int type;
+    private String segment;
+
+    /**
+     * Create a new <code>Position</code> object with the specified type.
+     * Since any type except for {@link #XML_FIRST first} and {@link #XML_LAST last}
+     * must be combined with a segment, only the mentioned types are valid
+     * arguments.
+     *
+     * @param type {@link #XML_FIRST first} or {@link #XML_LAST last}
+     * @throws IllegalArgumentException if the given type is other than {@link #XML_FIRST}
+     * or {@link #XML_LAST}.
+     */
+    public Position(String type) {
+        if (!(XML_FIRST.equals(type) || XML_LAST.equals(type))) {
+            throw new IllegalArgumentException("If type is other than 'first' or 'last' a segment must be specified");
+        }
+        setType(type);
+    }
+
+    /**
+     * Create a new <code>Position</code> object from the specified position
+     * element. The element must fulfill the following structure:<br>
+     * <pre>
+     * &lt;!ELEMENT position (first | last | before | after) &gt;
+     * &lt;!ELEMENT segment (#PCDATA) &gt;
+     * &lt;!ELEMENT first EMPTY &gt;
+     * &lt;!ELEMENT last EMPTY &gt;
+     * &lt;!ELEMENT before segment &gt;
+     * &lt;!ELEMENT after segment &gt;
+     * </pre>
+     *
+     * @param position Xml element defining the position.
+     * @throws IllegalArgumentException if the given Xml element is not valid.
+     */
+    public Position(Element position) {
+        if (position.getChildren().size() != 1) {
+            throw new IllegalArgumentException("The 'position' element must contain exactly a single child indicating the type.");
+        }
+        Element typeElem = (Element)position.getChildren().get(0);
+        String type = typeElem.getName();
+        String segmentText = null;
+        if (typeElem.getChildren().size() > 0) {
+            segmentText = typeElem.getChildText(XML_SEGMENT);
+        }
+        init(type, segmentText);
+    }
+
+    /**
+     * Create a new <code>Position</code> object with the specified type and
+     * segment.
+     *
+     * @param type
+     * @param segment
+     * @throws IllegalArgumentException if the specified type and segment do not
+     * form a valid pair.
+     */
+    public Position(String type, String segment) {
+        init(type, segment);
+    }
+
+    /**
+     * Initialize the internal fields.
+     *
+     * @param type
+     * @param segment
+     */
+    private void init(String type, String segment) {
+        if ((XML_AFTER.equals(type) || XML_BEFORE.equals(type)) && (segment == null || "".equals(segment))) {
+            throw new IllegalArgumentException("If type is other than 'first' or 'last' a segment must be specified");
+        }
+        setType(type);
+        this.segment = segment;
+    }
+
+    /**
+     * Return the type of this <code>Position</code> object, which may be any
+     * of the following valid types: {@link #XML_FIRST first},
+     * {@link #XML_LAST last}, {@link #XML_AFTER after}, {@link #XML_BEFORE before}
+     *
+     * @return type
+     */
+    public int getType() {
+        return type;
+    }
+
+    /**
+     * Set the type.
+     *
+     * @param xmlType
+     */
+    private void setType(String xmlType) {
+        type = ((Integer)xmlTypeMap.get(xmlType)).intValue();
+    }
+
+    /**
+     * Returns the segment used to create this <code>Position</code> object or
+     * <code>null</code> if no segment is present with the type.
+     *
+     * @return segment or <code>null</code>
+     * @see #getType()
+     */
+    public String getSegment() {
+        return segment;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/package.html?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/ordering/package.html Sun Mar  6 06:02:39 2005
@@ -0,0 +1,5 @@
+<body>
+Contains interfaces and classes used to cover the functionality defined by the
+<a href="http://www.ietf.org/rfc/rfc3648.txt">RFC 3648: Web Distributed Authoring
+and Versioning (WebDAV) Ordered Collections Protocol </a>.
+</body>
\ No newline at end of file

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/AbstractDavProperty.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,139 @@
+/*
+ * 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.property;
+
+import org.apache.log4j.Logger;
+import org.jdom.Element;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * <code>AbstractDavProperty</code> provides generic METHODS used by various
+ * implementations of the {@link DavProperty} interface.
+ */
+public abstract class AbstractDavProperty implements DavProperty {
+
+    private static Logger log = Logger.getLogger(AbstractDavProperty.class);
+
+    private final DavPropertyName name;
+    private final boolean isProtected;
+
+    /**
+     * Create a new <code>AbstractDavProperty</code> with the given {@link DavPropertyName}
+     * and a boolean flag indicating whether this property is protected.
+     * 
+     * @param name
+     * @param isProtected
+     */
+    public AbstractDavProperty(DavPropertyName name, boolean isProtected) {
+        this.name = name;
+        this.isProtected = isProtected;
+    }
+
+    /**
+     * Computes the hash code using this propertys name and value.
+     *
+     * @return the hash code
+     */
+    public int hashCode() {
+        int hashCode = getName().hashCode();
+        if (getValue() != null) {
+            hashCode += getValue().hashCode();
+        }
+        return hashCode % Integer.MAX_VALUE;
+    }
+
+    /**
+     * Checks if this property has the same {@link DavPropertyName name}
+     * and value as the given one.
+     *
+     * @param obj the object to compare to
+     * @return <code>true</code> if the 2 objects are equal;
+     *         <code>false</code> otherwise
+     */
+    public boolean equals(Object obj) {
+        if (obj instanceof DavProperty) {
+            DavProperty prop = (DavProperty) obj;
+            boolean equalName = getName().equals(prop.getName());
+            boolean equalValue = (getValue() == null) ? prop.getValue() == null : getValue().equals(prop.getValue());
+            return equalName && equalValue;
+        }
+        return false;
+    }
+
+
+    /**
+     * Return a JDOM element representation of this property. The value of the
+     * property will be added as text or as child element.
+     * <pre>
+     * new DavProperty("displayname", "WebDAV Directory").toXml()
+     * gives a element like:
+     * &lt;D:displayname&gt;WebDAV Directory&lt;/D:displayname&gt;
+     *
+     * new DavProperty("resourcetype", new Element("collection")).toXml()
+     * gives a element like:
+     * &lt;D:resourcetype&gt;&lt;D:collection/&gt;&lt;/D:resourcetype&gt;
+     *
+     * Element[] customVals = { new Element("bla", customNamespace), new Element("bli", customNamespace) };
+     * new DavProperty("custom-property", customVals, customNamespace).toXml()
+     * gives an element like
+     * &lt;Z:custom-property&gt;
+     *    &lt;Z:bla/&gt;
+     *    &lt;Z:bli/&gt;
+     * &lt;/Z:custom-property&gt;
+     * </pre>
+     *
+     * @return a JDOM element of this property
+     * @see DavProperty#toXml()
+     */
+    public Element toXml() {
+	Element elem = getName().toXml();
+        Object value = getValue();
+	if (value != null) {
+	    if (value instanceof Element) {
+		elem.addContent((Element) value);
+	    } else if (value instanceof Element[]) {
+                elem.addContent(Arrays.asList((Element[])value));
+            } else if (value instanceof List) {
+                elem.addContent((List)value);
+            } else {
+                elem.setText(value.toString());
+	    }
+	}
+	return elem;
+    }
+
+    /**
+     * Returns the name of this property.
+     *
+     * @return name
+     * @see DavProperty#getName()
+     */
+    public DavPropertyName getName() {
+        return name;
+    }
+
+    /**
+     * Returns true if this property is protected or computed.
+     *
+     * @return true if this is a protected (or computed) property.
+     * @see org.apache.jackrabbit.webdav.property.DavProperty#isProtected()
+     */
+    public boolean isProtected() {
+        return isProtected;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavProperty.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.property;
+
+import org.jdom.Element;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+/**
+ * The <code>Property</code> class represents a Property of a WebDAV
+ * resource. The {@link #hashCode()} and {@link #equals(Object)} METHODS are
+ * overridden in a way, that the name and value of the property are
+ * respected. this means, an property is equal to another, if the names
+ * and values are equal.
+ */
+public interface DavProperty extends DavConstants {
+
+    /**
+     * Return a JDOM element representation of this property. The value of the
+     * property will be added as text or as child element.
+     * <pre>
+     * new DavProperty("displayname", "WebDAV Directory").toXml()
+     * gives a element like:
+     * &lt;D:displayname&gt;WebDAV Directory&lt;/D:displayname&gt;
+     *
+     * new DavProperty("resourcetype", new Element("collection")).toXml()
+     * gives a element like:
+     * &lt;D:resourcetype&gt;&lt;D:collection/&gt;&lt;/D:resourcetype&gt;
+     *
+     * Element[] customVals = { new Element("bla", customNamespace), new Element("bli", customNamespace) };
+     * new DavProperty("custom-property", customVals, customNamespace).toXml()
+     * gives an element like
+     * &lt;Z:custom-property&gt;
+     *    &lt;Z:bla/&gt;
+     *    &lt;Z:bli/&gt;
+     * &lt;/Z:custom-property&gt;
+     * </pre>
+     *
+     * @return a JDOM element of this property
+     */
+    public Element toXml();
+
+    /**
+     * Returns the name of this property
+     * 
+     * @return the name of this property
+     */
+    public DavPropertyName getName();
+
+    /**
+     * Returns the value of this property
+     *
+     * @return the value of this property
+     */
+    public Object getValue();
+
+    /**
+     * Return true if this property is protected. A protected property
+     * will not be returned in a {@link DavConstants#PROPFIND_ALL_PROP DAV:allprop}
+     * PROPFIND request and cannot be set/removed with a PROPPATCH request.
+     *
+     * @return true, if this property is protected.
+     */
+    public boolean isProtected();
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyIterator.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyIterator.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyIterator.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyIterator.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.property;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * The <code>DavPropertyIterator</code> extends the <code>Iterator</code> by
+ * a property specific <code>next()</code> method.
+ */
+public interface DavPropertyIterator extends Iterator {
+    /**
+     * Returns the next <code>Property</code> in the interation.
+     *
+     * @return the next <code>Property</code> in the iteration.
+     * @throws java.util.NoSuchElementException if iteration has no more elements.
+     */
+    public DavProperty nextProperty() throws NoSuchElementException;
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyName.java Sun Mar  6 06:02:39 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.property;
+
+import org.jdom.Namespace;
+import org.jdom.Element;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+import java.util.HashMap;
+
+/**
+ * The <code>DavPropertyName</code> class reflects a Webdav property name. It
+ * holds together the actualy name of the property and its namespace.
+ */
+public class DavPropertyName implements DavConstants {
+
+    /** internal 'cache' of created property names */
+    private static final HashMap cache = new HashMap();
+
+    /* some standard webdav property (that have #PCDATA) */
+    public static final DavPropertyName CREATIONDATE = DavPropertyName.create(PROPERTY_CREATIONDATE);
+    public static final DavPropertyName DISPLAYNAME = DavPropertyName.create(PROPERTY_DISPLAYNAME);
+    public static final DavPropertyName GETCONTENTLANGUAGE = DavPropertyName.create(PROPERTY_GETCONTENTLANGUAGE);
+    public static final DavPropertyName GETCONTENTLENGTH = DavPropertyName.create(PROPERTY_GETCONTENTLENGTH);
+    public static final DavPropertyName GETCONTENTTYPE = DavPropertyName.create(PROPERTY_GETCONTENTTYPE);
+    public static final DavPropertyName GETETAG = DavPropertyName.create(PROPERTY_GETETAG);
+    public static final DavPropertyName GETLASTMODIFIED = DavPropertyName.create(PROPERTY_GETLASTMODIFIED);
+
+    /* some standard webdav property (that have other elements) */
+    public static final DavPropertyName LOCKDISCOVERY = DavPropertyName.create(PROPERTY_LOCKDISCOVERY);
+    public static final DavPropertyName RESOURCETYPE = DavPropertyName.create(PROPERTY_RESOURCETYPE);
+    public static final DavPropertyName SOURCE = DavPropertyName.create(PROPERTY_SOURCE);
+    public static final DavPropertyName SUPPORTEDLOCK = DavPropertyName.create(PROPERTY_SUPPORTEDLOCK);
+
+    /* property use by microsoft that are not specified in the RFC 2518 */
+    public static final DavPropertyName ISCOLLECTION = DavPropertyName.create("iscollection");
+
+    /** the name of the property */
+    private final String name;
+
+    /** the namespace of the property */
+    private final Namespace namespace;
+
+    /**
+     * Creates a new <code>DavPropertyName</code> with the given name and
+     * Namespace.
+     *
+     * @param name The local name of the new property name
+     * @param namespace The namespace of the new property name
+     *
+     * @return The WebDAV property name
+     */
+    public synchronized static DavPropertyName create(String name, Namespace namespace) {
+
+        // get (or create) map for the given namespace
+        HashMap map = (HashMap) cache.get(namespace);
+        if (map == null) {
+            map = new HashMap();
+            cache.put(namespace, map);
+        }
+        // get (or create) property name object 
+        DavPropertyName ret = (DavPropertyName) map.get(name);
+        if (ret == null) {
+            if (namespace.equals(NAMESPACE)) {
+                // ensure prefix for default 'DAV:' namespace
+                namespace = NAMESPACE;
+            }
+            ret = new DavPropertyName(name, namespace);
+            map.put(name, ret);
+        }
+        return ret;
+    }
+
+    /**
+     * Creates a new <code>DavPropertyName</code> with the given local name
+     * and the default WebDAV {@link DavConstants#NAMESPACE namespace}.
+     *
+     * @param name The local name of the new property name
+     *
+     * @return The WebDAV property name
+     */
+    public synchronized static DavPropertyName create(String name) {
+        return create(name, NAMESPACE);
+    }
+
+    /**
+     * Creates a new <code>DavPropertyName</code> with the given name and
+     * Namespace.
+     *
+     * @param name The local name of the new property name
+     * @param namespace The namespace of the new property name
+     */
+    private DavPropertyName(String name, Namespace namespace) {
+        if (name == null || namespace == null) {
+            throw new IllegalArgumentException("Name and namespace must not be 'null' for a DavPropertyName.");
+        }
+        this.name = name;
+        this.namespace = namespace;
+    }
+
+    /**
+     * Return the name of this <code>DavPropertyName</code>.
+     *
+     * @return name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Return the namespace of this <code>DavPropertyName</code>.
+     *
+     * @return namespace
+     */
+    public Namespace getNamespace() {
+        return namespace;
+    }
+
+
+    /**
+     * Computes the hash code using this propertys name and namespace.
+     *
+     * @return the hash code
+     */
+    public int hashCode() {
+        return (name.hashCode() + namespace.hashCode()) % Integer.MAX_VALUE;
+    }
+
+    /**
+     * Checks if this property has the same name and namespace as the
+     * given one.
+     *
+     * @param obj the object to compare to
+     *
+     * @return <code>true</code> if the 2 objects are equal;
+     *         <code>false</code> otherwise
+     */
+    public boolean equals(Object obj) {
+        if (obj instanceof DavPropertyName) {
+            DavPropertyName propName = (DavPropertyName) obj;
+            return  name.equals(propName.name) && namespace.equals(propName.namespace);
+        }
+        return false;
+    }
+
+    /**
+     * Returns a string representation of this property suitable for debugging
+     * @return a human readable string representation
+     */
+    public String toString() {
+        return name + " (" + namespace + ")";
+    }
+
+    /**
+     * Creates a JDOM element with the name and namespace of this
+     * DavPropertyName.
+     *
+     * @return A JDOM Element.
+     */
+    public Element toXml() {
+        return new Element(name, namespace);
+    }
+}
+

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertyNameSet.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.property;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.jdom.Element;
+
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * <code>DavPropertyNameSet</code> represents a Set of {@link DavPropertyName}
+ * objects.
+ */
+public class DavPropertyNameSet extends HashSet {
+
+    private static Logger log = Logger.getLogger(DavPropertyNameSet.class);
+
+    /**
+     * Create a new empty set.
+     * @see HashSet()
+     */
+    public DavPropertyNameSet() {
+        super();
+    }
+
+    /**
+     * Create a new set from the given collection.
+     * @param c
+     * @see HashSet(Collection)
+     */
+    public DavPropertyNameSet(Collection c) {
+        super(c);
+    }
+
+    /**
+     * Create a new <code>DavPropertyNameSet</code> from the given DAV:prop
+     * element.
+     *
+     * @param propElement
+     * @throws IllegalArgumentException if the specified element is <code>null</code>
+     * or is not a DAV:prop element.
+     */
+    public DavPropertyNameSet(Element propElement) {
+        super();
+        if (propElement == null || !propElement.getName().equals(DavConstants.XML_PROP)) {
+            throw new IllegalArgumentException("'DAV:prop' element expected.");
+        }
+
+        // fill the set
+        List props = propElement.getChildren();
+        for (int j = 0; j < props.size(); j++) {
+            Element prop = (Element) props.get(j);
+            String propName = prop.getName();
+            if (propName != null && !"".equals(propName)) {
+                add(DavPropertyName.create(propName, prop.getNamespace()));
+            }
+        }
+    }
+
+    /**
+     * Adds the specified {@link DavPropertyName} object to this
+     * set if it is not already present.
+     *
+     * @param propertyName element to be added to this set.
+     * @return <tt>true</tt> if the set did not already contain the specified
+     * element.
+     */
+    public boolean add(DavPropertyName propertyName) {
+        return super.add(propertyName);
+    }
+
+    /**
+     * Add the given object to this set. In case the object is not a {@link DavPropertyName}
+     * this method returns false.
+     *
+     * @param o
+     * @return true if adding the object was successful.
+     * @see #add(DavPropertyName)
+     */
+    public boolean add(Object o) {
+        if (o instanceof DavPropertyName) {
+            return add((DavPropertyName) o);
+        } else {
+            return false;
+        }
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DavPropertySet.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,271 @@
+/*
+ * 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.property;
+
+import org.jdom.Namespace;
+import org.apache.jackrabbit.webdav.DavConstants;
+
+import java.util.*;
+
+/**
+ * The <code>DavPropertySet</code> class represents a set of WebDAV
+ * property.
+ */
+public class DavPropertySet {
+
+    /**
+     * the set of property
+     */
+    private final HashMap map = new HashMap();
+
+    /**
+     * Adds a new property to this set.
+     *
+     * @param property The property to add
+     *
+     * @return The previously assigned property or <code>null</code>.
+     */
+    public DavProperty add(DavProperty property) {
+        return (DavProperty) map.put(property.getName(), property);
+    }
+
+    /**
+     *
+     * @param pset Properties to add
+     */
+    public void addAll(DavPropertySet pset) {
+	map.putAll(pset.map);
+    }
+
+    /**
+     * Retrieves the property with the specified <code>name</code> and the
+     * default WebDAV {@link org.apache.jackrabbit.webdav.DavConstants#NAMESPACE namespace}.
+     *
+     * @param name The name of the property to retrieve
+     *
+     * @return The desired property or <code>null</code>
+     */
+    public DavProperty get(String name) {
+    	return get(DavPropertyName.create(name));
+    }
+
+    /**
+     * Retrieves the property with the specified <code>name</code> and
+     * <code>namespace</code>.
+     *
+     * @param name The name of the property to retrieve
+     * @param namespace The namespace of the property to retrieve
+     *
+     * @return The desired property or <code>null</code>
+     */
+    public DavProperty get(String name, Namespace namespace) {
+        return get(DavPropertyName.create(name, namespace));
+    }
+
+    /**
+     * Retrieves the property with the specified <code>name</code>
+     *
+     * @param name The webdav property name of the property to retrieve
+     *
+     * @return The desired property or <code>null</code>
+     */
+    public DavProperty get(DavPropertyName name) {
+    	return (DavProperty) map.get(name);
+    }
+
+
+    /**
+     * Removes the indicated property from this set.
+     *
+     * @param name The webdav property name to remove
+     *
+     * @return The removed property or <code>null</code>
+     */
+    public DavProperty remove(DavPropertyName name) {
+        return (DavProperty) map.remove(name);
+    }
+
+    /**
+     * Removes the property with the specified <code>name</code> and the
+     * default WebDAV {@link org.apache.jackrabbit.webdav.DavConstants#NAMESPACE namespace}.
+     *
+     * @param name The name of the property to remove
+     *
+     * @return The removed property or <code>null</code>
+     */
+    public DavProperty remove(String name) {
+        return remove(DavPropertyName.create(name));
+    }
+
+    /**
+     * Removes the property with the specified <code>name</code> and
+     * <code>namespace</code> from this set.
+     *
+     * @param name The name of the property to remove
+     * @param namespace The namespace of the property to remove
+     *
+     * @return The removed property or <code>null</code>
+     */
+    public DavProperty remove(String name, Namespace namespace) {
+        return remove(DavPropertyName.create(name, namespace));
+    }
+
+    /**
+     * Returns an iterator over all property in this set.
+     *
+     * @return An iterator over {@link DavProperty}.
+     */
+    public DavPropertyIterator iterator() {
+        return new PropIter();
+    }
+
+    /**
+     * Returns an iterator over all those property in this set, that have the
+     * indicated <code>namespace</code>.
+     *
+     * @param namespace The namespace of the property in the iteration.
+     *
+     * @return An iterator over {@link DavProperty}.
+     */
+    public DavPropertyIterator iterator(Namespace namespace) {
+        return new PropIter(namespace);
+    }
+
+    /**
+     * Checks if this set contains the property with the specified name.
+     *
+     * @param name The name of the property
+     *
+     * @return <code>true</code> if this set contains the property;
+     *         <code>false</code> otherwise.
+     */
+    public boolean contains(DavPropertyName name) {
+        return map.containsKey(name);
+    }
+
+    /**
+     * Checks if this set contains the property with the specified name and the
+     * default WebDAV {@link org.apache.jackrabbit.webdav.DavConstants#NAMESPACE namespace}.
+     *
+     * @param name The name of the property
+     *
+     * @return <code>true</code> if this set contains the property;
+     *         <code>false</code> otherwise.
+     */
+    public boolean contains(String name) {
+        return contains(DavPropertyName.create(name, DavConstants.NAMESPACE));
+    }
+
+    /**
+     * Return true if this property set is empty.
+     *
+     * @return true if the internal map contains no elements.
+     */
+    public boolean isEmpty() {
+        return map.isEmpty();
+    }
+
+    /**
+     * Return the names of all properties present in this set.
+     *
+     * @return array of {@link DavPropertyName property names} present in this set.
+     */
+    public DavPropertyName[] getPropertyNames() {
+        Set keySet = map.keySet();
+	return (DavPropertyName[]) keySet.toArray(new DavPropertyName[keySet.size()]);
+    }
+
+    //---------------------------------------------------------- Inner class ---
+    /**
+     * Implementation of a DavPropertyIterator that returns webdav property.
+     * Additionally, it can only return property with the given namespace.
+     */
+    private class PropIter implements DavPropertyIterator {
+
+        /** the namespace to match agains */
+        private final Namespace namespace;
+
+        /** the internal iterator */
+        private final Iterator iterator;
+
+        /** the next property to return */
+        private DavProperty next;
+
+        /**
+         * Creates a new property iterator.
+         */
+        private PropIter() {
+            this(null);
+        }
+
+        /**
+         * Creates a new iterator with the given namespace
+         * @param namespace The namespace to match against
+         */
+	private PropIter(Namespace namespace) {
+            this.namespace = namespace;
+            iterator = map.values().iterator();
+            seek();
+        }
+
+        /**
+         * @see DavPropertyIterator#nextProperty();
+         */
+        public DavProperty nextProperty() throws NoSuchElementException {
+            if (next==null) {
+                throw new NoSuchElementException();
+            }
+            DavProperty ret = next;
+            seek();
+            return ret;
+        }
+
+        /**
+         * @see DavPropertyIterator#hasNext();
+         */
+        public boolean hasNext() {
+            return next!=null;
+        }
+
+        /**
+         * @see DavPropertyIterator#next();
+         */
+        public Object next() {
+            return nextProperty();
+        }
+
+        /**
+         * @see DavPropertyIterator#remove();
+         */
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+
+        /**
+         * Seeks for the next valid property
+         */
+        private void seek() {
+            while (iterator.hasNext()) {
+                next = (DavProperty) iterator.next();
+                if (namespace == null || namespace.equals(next.getName().getNamespace())) {
+                    return;
+                }
+            }
+            next = null;
+        }
+    }
+}
+

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/DefaultDavProperty.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,97 @@
+/*
+ * 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.property;
+
+import org.apache.log4j.Logger;
+import org.jdom.Namespace;
+
+/**
+ * <code>DefaultDavProperty</code>...
+ */
+public class DefaultDavProperty extends AbstractDavProperty {
+
+    private static Logger log = Logger.getLogger(DefaultDavProperty.class);
+
+    /**
+     * the value of the property
+     */
+    private final Object value;
+
+    /**
+     * Creates a new WebDAV property with the given namespace, name and value.
+     * If the property is intended to be protected the isProtected flag must
+     * be set to true.
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     * @param namespace the namespace of the property
+     * @param isProtected A value of true, defines this property to be protected.
+     * It will not be returned in a {@link org.apache.jackrabbit.webdav.DavConstants#PROPFIND_ALL_PROP DAV:allprop}
+     * PROPFIND request and cannot be set/removed with a PROPPATCH request.
+     */
+    public DefaultDavProperty(String name, Object value, Namespace namespace, boolean isProtected) {
+        super(DavPropertyName.create(name, namespace), isProtected);
+        this.value = value;
+    }
+
+    /**
+     * Creates a new non-protected WebDAV property with the given namespace, name
+     * and value.
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     * @param namespace the namespace of the property
+     */
+    public DefaultDavProperty(String name, Object value, Namespace namespace) {
+        this(name, value, namespace, false);
+    }
+
+    /**
+     * Creates a new WebDAV property with the given <code>DavPropertyName</code>
+     * and value. If the property is meant to be protected the 'isProtected'
+     * flag must be set to true.
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     * @param isProtected A value of true, defines this property to be protected.
+     * It will not be returned in a {@link org.apache.jackrabbit.webdav.DavConstants#PROPFIND_ALL_PROP DAV:allprop}
+     * PROPFIND request and cannot be set/removed with a PROPPATCH request.
+     */
+    public DefaultDavProperty(DavPropertyName name, Object value, boolean isProtected) {
+        super(name, isProtected);
+        this.value = value;
+    }
+
+    /**
+     * Creates a new non- protected WebDAV property with the given
+     * <code>DavPropertyName</code> and value.
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     */
+    public DefaultDavProperty(DavPropertyName name, Object value) {
+        this(name, value, false);
+    }
+
+    /**
+     * Returns the value of this property
+     *
+     * @return the value of this property
+     */
+    public Object getValue() {
+        return value;
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/HrefProperty.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,150 @@
+/*
+ * 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.property;
+
+import org.apache.log4j.Logger;
+import org.apache.jackrabbit.webdav.util.XmlUtil;
+import org.jdom.Element;
+
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * <code>HrefProperty</code> is an extension to the common {@link DavProperty}.
+ * The String representation of the property value is always displayed as text
+ * inside an extra 'href' element. If the value is a String array each array
+ * element is added as text to a separate 'href' element.
+ *
+ * @see org.apache.jackrabbit.webdav.DavConstants#XML_HREF
+ * @see org.apache.jackrabbit.webdav.property.DavProperty#getValue()
+ */
+public class HrefProperty extends AbstractDavProperty {
+
+    private static Logger log = Logger.getLogger(HrefProperty.class);
+
+    private final String[] value;
+
+    /**
+     * Creates a new WebDAV property with the given <code>DavPropertyName</code>
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     * @param isProtected A value of true, defines this property to be protected.
+     * It will not be returned in a {@link org.apache.jackrabbit.webdav.DavConstants#PROPFIND_ALL_PROP DAV:allprop}
+     * PROPFIND request and cannot be set/removed with a PROPPATCH request.
+     */
+    public HrefProperty(DavPropertyName name, String value, boolean isProtected) {
+        super(name, isProtected);
+        this.value = new String[]{value};
+    }
+
+    /**
+     * Creates a new WebDAV property with the given <code>DavPropertyName</code>
+     *
+     * @param name the name of the property
+     * @param value the value of the property
+     * @param isProtected A value of true, defines this property to be protected.
+     * It will not be returned in a {@link org.apache.jackrabbit.webdav.DavConstants#PROPFIND_ALL_PROP DAV:allprop}
+     * PROPFIND request and cannot be set/removed with a PROPPATCH request.
+     */
+    public HrefProperty(DavPropertyName name, String[] value, boolean isProtected) {
+        super(name, isProtected);
+        this.value = value;
+    }
+
+    /**
+     * Create a new <code>HrefProperty</code> from the specified property.
+     * Please note, that the property must have a <code>List</code> value
+     * object, consisting of {@link #XML_HREF href} <code>Element</code> entries.
+     *
+     * @param prop
+     * @throws IllegalArgumentException if the property {@link DavProperty#getValue() value}
+     * is not a <code>List</code>.
+     */
+    public HrefProperty(DavProperty prop) {
+        super(prop.getName(), prop.isProtected());
+        if (! (prop.getValue() instanceof List)) {
+            throw new IllegalArgumentException("Expected a property with a List value object.");
+        }
+        Iterator it = ((List)prop.getValue()).iterator();
+        ArrayList hrefList = new ArrayList();
+        while (it.hasNext()) {
+            Object o = it.next();
+            if (o instanceof Element) {
+                String href = ((Element)o).getChildText(XML_HREF, NAMESPACE);
+                if (href != null) {
+                    hrefList.add(href);
+                } else {
+                    log.warn("Valid DAV:href element expected instead of " + o.toString());
+                }
+            } else {
+                log.warn("DAV: href element expected in the content of " + getName().toString());
+            }
+        }
+        value = (String[]) hrefList.toArray(new String[hrefList.size()]);
+    }
+
+    /**
+     * Returns an Xml element with the following form:
+     * <pre>
+     * &lt;Z:name&gt;
+     *    &lt;DAV:href&gt;value&lt;/DAV:href/&gt;
+     * &lt;/Z:name&gt;
+     * </pre>
+     * where Z: represents the prefix of the namespace defined with the initial
+     * webdav property name.
+     *
+     * @return Xml representation
+     * @see XmlUtil#hrefToXml(String)
+     */
+    public Element toXml() {
+        Element elem = getName().toXml();
+        Object value = getValue();
+        if (value != null) {
+            if (value instanceof String[]) {
+                String[] hrefs = (String[]) value;
+                for (int i = 0; i < hrefs.length; i++) {
+                    elem.addContent(XmlUtil.hrefToXml(hrefs[i]));
+                }
+            } else {
+                elem.addContent(XmlUtil.hrefToXml(value.toString()));
+            }
+        }
+        return elem;
+    }
+
+    /**
+     * Returns an array of String.
+     *
+     * @return an array of String.
+     * @see DavProperty#getValue() 
+     */
+    public Object getValue() {
+        return value;
+    }
+
+    /**
+     * Return an array of String containg the text of those DAV:href elements
+     * that would be returned as child elements of this property on {@link #toXml()}
+     *
+     * @return
+     */
+    public List getHrefs() {
+        return Arrays.asList(value);
+    }
+}
\ No newline at end of file

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/ResourceType.java Sun Mar  6 06:02:39 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.property;
+
+import org.jdom.Element;
+
+/**
+ * The <code>ResourceType</code> class represents the webdav resource
+ * type property. Valid resource types are '{@link #COLLECTION collection}',
+ * {@link #DEFAULT_RESOURCE}.
+ */
+public class ResourceType extends AbstractDavProperty {
+
+    /**
+     * The default resource type
+     */
+    public static final int DEFAULT_RESOURCE = 0;
+
+    /**
+     * The collection resource type
+     */
+    public static final int COLLECTION = DEFAULT_RESOURCE + 1;
+
+    private int resourceType = DEFAULT_RESOURCE;
+
+    /**
+     * Create a resource type property
+     */
+    public ResourceType(int resourceType) {
+        super(DavPropertyName.RESOURCETYPE, false);
+	if (!isValidResourceType(resourceType)) {
+           throw new IllegalArgumentException("Invalid resource type '"+ resourceType +"'.");
+        }
+	this.resourceType = resourceType;
+    }
+
+    /**
+     * Return the JDOM element representation of this resource type
+     *
+     * @return a JDOM element
+     */
+    public Element toXml() {
+        Element elem = getName().toXml();
+        if (getValue() != null) {
+            elem.addContent((Element)getValue());
+        }
+        return elem;
+    }
+
+    /**
+     * Returns the Xml representation of this resource type.
+     *
+     * @return Xml representation of this resource type.
+     * @see DavProperty#getValue()
+     */
+    public Object getValue() {
+        return (resourceType == COLLECTION) ? new Element(XML_COLLECTION, NAMESPACE) : null;
+    }
+
+    /**
+     * Returns the resource type specified with the constructor.
+     *
+     * @return resourceType
+     */
+    public int getResourceType() {
+        return resourceType;
+    }
+
+    /**
+     * Validates the specified resourceType.
+     *
+     * @param resourceType
+     * @return true if the specified resourceType is valid.
+     */
+    public boolean isValidResourceType(int resourceType) {
+        if (resourceType < DEFAULT_RESOURCE || resourceType > COLLECTION) {
+	    return false;
+	}
+        return true;
+    }
+}

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

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

Added: incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/package.html
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/package.html?view=auto&rev=156314
==============================================================================
--- incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/package.html (added)
+++ incubator/jackrabbit/trunk/contrib/jcr-server/webdav/src/java/org/apache/jackrabbit/webdav/property/package.html Sun Mar  6 06:02:39 2005
@@ -0,0 +1,3 @@
+<body>
+Interfaces and classes related to WebDAV properties.
+</body>
\ No newline at end of file

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



Mime
View raw message