You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wagon-commits@maven.apache.org by br...@apache.org on 2008/05/20 07:49:29 UTC
svn commit: r658110 - in /maven/wagon/trunk/wagon-providers/wagon-webdav:
pom.xml src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
Author: brett
Date: Mon May 19 22:49:29 2008
New Revision: 658110
URL: http://svn.apache.org/viewvc?rev=658110&view=rev
Log:
[WAGON-109] remove commons-collections, servlet-api dependency
Added:
maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java (with props)
Removed:
maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
Modified:
maven/wagon/trunk/wagon-providers/wagon-webdav/pom.xml
Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/pom.xml?rev=658110&r1=658109&r2=658110&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/pom.xml (original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/pom.xml Mon May 19 22:49:29 2008
@@ -60,14 +60,13 @@
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.3</version>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.0</version>
@@ -76,6 +75,12 @@
<!-- Test dependencies -->
<dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>it.could</groupId>
<artifactId>webdav</artifactId>
<version>0.4</version>
Added: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java?rev=658110&view=auto
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java (added)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java Mon May 19 22:49:29 2008
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+/**
+ * MultiStatus representing the content of a multistatus response body and
+ * allows to retrieve the Xml representation.
+ */
+public class MultiStatus implements DavConstants, XmlSerializable {
+
+ /**
+ * Map collecting the responses for this multistatus, where every href must
+ * only occure one single time.
+ */
+ private Map responses = new LinkedHashMap();
+
+ /**
+ * A general response description at the multistatus top level is used to
+ * provide a general message describing the overarching nature of the response.
+ * If this value is available an application may use it instead of
+ * presenting the individual response descriptions contained within the
+ * responses.
+ */
+ private String responseDescription;
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus for
+ * responding to a PROPFIND request.
+ *
+ * @param resource The resource to add property from
+ * @param propNameSet The requested property names of the PROPFIND request
+ * @param propFindType
+ * @param depth
+ */
+ public void addResourceProperties(DavResource resource, DavPropertyNameSet propNameSet,
+ int propFindType, int depth) {
+ addResponse(new MultiStatusResponse(resource, propNameSet, propFindType));
+ if (depth > 0 && resource.isCollection()) {
+ DavResourceIterator iter = resource.getMembers();
+ while (iter.hasNext()) {
+ addResourceProperties(iter.nextResource(), propNameSet, propFindType, depth-1);
+ }
+ }
+ }
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus e.g.
+ * in order to respond to a PROPFIND request. Please note, that in terms
+ * of PROPFIND, this method would correspond to a
+ * {@link DavConstants#PROPFIND_BY_PROPERTY} propfind type.
+ *
+ * @param resource The resource to add property from
+ * @param propNameSet The requested property names of the PROPFIND request
+ * @param depth
+ * @see #addResourceProperties(DavResource, DavPropertyNameSet, int, int) for
+ * the corresponding method that allows to specify the type explicitely.
+ */
+ public void addResourceProperties(DavResource resource, DavPropertyNameSet propNameSet,
+ int depth) {
+ addResourceProperties(resource, propNameSet, PROPFIND_BY_PROPERTY, depth);
+ }
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus
+ * as returned for COPY, MOVE, LOCK or DELETE requests resulting in an error
+ * with a resource other than the resource identified in the Request-URI.
+ *
+ * @param resource
+ * @param status
+ * @param depth
+ */
+ public void addResourceStatus(DavResource resource, int status, int depth) {
+ addResponse(new MultiStatusResponse(resource.getHref(), status));
+ if (depth > 0 && resource.isCollection()) {
+ DavResourceIterator iter = resource.getMembers();
+ while (iter.hasNext()) {
+ addResourceStatus(iter.nextResource(), status, depth-1);
+ }
+ }
+ }
+
+ /**
+ * Add a <code>MultiStatusResponse</code> element to this <code>MultiStatus</code>
+ *
+ * @param response
+ */
+ public void addResponse(MultiStatusResponse response) {
+ responses.put(response.getHref(), response);
+ }
+
+ /**
+ * Returns the multistatus responses present as array.
+ *
+ * @return array of all {@link MultiStatusResponse responses} present in this
+ * multistatus.
+ */
+ public MultiStatusResponse[] getResponses() {
+ return (MultiStatusResponse[]) responses.values().toArray(new MultiStatusResponse[responses.size()]);
+ }
+
+ /**
+ * Set the response description.
+ *
+ * @param responseDescription
+ */
+ public void setResponseDescription(String responseDescription) {
+ this.responseDescription = responseDescription;
+ }
+
+ /**
+ * Returns the response description.
+ *
+ * @return responseDescription
+ */
+ public String getResponseDescription() {
+ return responseDescription;
+ }
+
+ /**
+ * Return the Xml representation of this <code>MultiStatus</code>.
+ *
+ * @return Xml document
+ * @param document
+ */
+ public Element toXml(Document document) {
+ Element multistatus = DomUtil.createElement(document, XML_MULTISTATUS, NAMESPACE);
+ Iterator it = responses.values().iterator();
+ while(it.hasNext()) {
+ multistatus.appendChild(((MultiStatusResponse)it.next()).toXml(document));
+ }
+ if (responseDescription != null) {
+ Element respDesc = DomUtil.createElement(document, XML_RESPONSEDESCRIPTION, NAMESPACE, responseDescription);
+ multistatus.appendChild(respDesc);
+ }
+ return multistatus;
+ }
+
+ /**
+ * Build a <code>MultiStatus</code> from the specified xml element.
+ *
+ * @param multistatusElement
+ * @return new <code>MultiStatus</code> instance.
+ * @throws IllegalArgumentException if the given document is <code>null</code>
+ * or does not provide the required element.
+ */
+ public static MultiStatus createFromXml(Element multistatusElement) {
+ if (!DomUtil.matches(multistatusElement, XML_MULTISTATUS, NAMESPACE)) {
+ throw new IllegalArgumentException("DAV:multistatus element expected.");
+ }
+
+ MultiStatus multistatus = new MultiStatus();
+
+ ElementIterator it = DomUtil.getChildren(multistatusElement, XML_RESPONSE, NAMESPACE);
+ while (it.hasNext()) {
+ Element respElem = it.nextElement();
+ MultiStatusResponse response = MultiStatusResponse.createFromXml(respElem);
+ multistatus.addResponse(response);
+ }
+
+ // optional response description on the multistatus element
+ multistatus.setResponseDescription(DomUtil.getChildText(multistatusElement, XML_RESPONSEDESCRIPTION, NAMESPACE));
+ return multistatus;
+ }
+}
Propchange: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org