maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r658034 - in /maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav: ./ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/webdav/ src/main/java/org/apache/jackrabbit/webdav/client/ src/main/java/org/apache/jackr...
Date Mon, 19 May 2008 23:09:05 GMT
Author: brett
Date: Mon May 19 16:09:04 2008
New Revision: 658034

URL: http://svn.apache.org/viewvc?rev=658034&view=rev
Log:
[WAGON-109] including files from Jackrabbit 1.4, r658025, and applying patch from JCR-1310
until a new release can be made available with the same solution to remove the xerces dependency

Added:
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
  (with props)
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
  (with props)
Modified:
    maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/pom.xml

Modified: maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/pom.xml
URL: http://svn.apache.org/viewvc/maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/pom.xml?rev=658034&r1=658033&r2=658034&view=diff
==============================================================================
--- maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/pom.xml (original)
+++ maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/pom.xml Mon May 19 16:09:04
2008
@@ -55,6 +55,17 @@
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-webdav</artifactId>
       <version>1.4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>xerces</groupId>
+          <artifactId>xercesImpl</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>2.3</version>
     </dependency>
 
     <!-- Test dependencies -->
@@ -65,12 +76,6 @@
       <scope>test</scope>
     </dependency>
     <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/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java?rev=658034&view=auto
==============================================================================
--- maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
(added)
+++ maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
Mon May 19 16:09:04 2008
@@ -0,0 +1,332 @@
+/*
+ * 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.lock.ActiveLock;
+import org.apache.jackrabbit.webdav.lock.LockDiscovery;
+import org.apache.jackrabbit.webdav.observation.EventDiscovery;
+import org.apache.jackrabbit.webdav.observation.Subscription;
+import org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery;
+import org.apache.jackrabbit.webdav.observation.ObservationConstants;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.header.CodedUrlHeader;
+import org.apache.jackrabbit.webdav.header.Header;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+/**
+ * WebdavResponseImpl implements the <code>WebdavResponse</code> interface.
+ */
+public class WebdavResponseImpl implements WebdavResponse {
+
+    private static Logger log = LoggerFactory.getLogger(WebdavResponseImpl.class);
+
+    private HttpServletResponse httpResponse;
+
+    /**
+     * Create a new <code>WebdavResponse</code>
+     * 
+     * @param httpResponse
+     */
+    public WebdavResponseImpl(HttpServletResponse httpResponse) {
+        this(httpResponse, false);
+    }
+
+    /**
+     * Create a new <code>WebdavResponse</code>
+     *
+     * @param httpResponse
+     * @param noCache
+     */
+    public WebdavResponseImpl(HttpServletResponse httpResponse, boolean noCache) {
+        this.httpResponse = httpResponse;
+        if (noCache) {
+            /* set cache control headers */
+            addHeader("Pragma", "No-cache");  // http1.0
+            addHeader("Cache-Control", "no-cache"); // http1.1
+        }
+    }
+
+    /**
+     * If the specifid exception provides an error condition an Xml response body
+     * is sent providing more detailed information about the error. Otherwise only
+     * the error code and status phrase is sent back.
+     *
+     * @param exception
+     * @throws IOException
+     * @see DavServletResponse#sendError(org.apache.jackrabbit.webdav.DavException)
+     * @see #sendError(int, String)
+     * @see #sendXmlResponse(XmlSerializable, int)
+     */
+    public void sendError(DavException exception) throws IOException {
+        if (!exception.hasErrorCondition()) {
+            httpResponse.sendError(exception.getErrorCode(), exception.getStatusPhrase());
+        } else {
+            sendXmlResponse(exception, exception.getErrorCode());
+        }
+    }
+
+    /**
+     * Send a multistatus response.
+     *
+     * @param multistatus
+     * @throws IOException
+     * @see DavServletResponse#sendMultiStatus(org.apache.jackrabbit.webdav.MultiStatus)
+     */
+    public void sendMultiStatus(MultiStatus multistatus) throws IOException {
+        sendXmlResponse(multistatus, SC_MULTI_STATUS);
+    }
+
+    /**
+     * Send response body for a lock request intended to create a new lock.
+     *
+     * @param lock
+     * @throws java.io.IOException
+     * @see DavServletResponse#sendLockResponse(org.apache.jackrabbit.webdav.lock.ActiveLock)
+     */
+    public void sendLockResponse(ActiveLock lock) throws IOException {
+        CodedUrlHeader ltHeader = new CodedUrlHeader(DavConstants.HEADER_LOCK_TOKEN, lock.getToken());
+        httpResponse.setHeader(ltHeader.getHeaderName(), ltHeader.getHeaderValue());
+
+        DavPropertySet propSet = new DavPropertySet();
+        propSet.add(new LockDiscovery(lock));
+        sendXmlResponse(propSet, SC_OK);
+    }
+
+    /**
+     * Send response body for a lock request that was intended to refresh one
+     * or several locks.
+     *
+     * @param locks
+     * @throws java.io.IOException
+     * @see DavServletResponse#sendRefreshLockResponse(org.apache.jackrabbit.webdav.lock.ActiveLock[])
+     */
+    public void sendRefreshLockResponse(ActiveLock[] locks) throws IOException {
+        DavPropertySet propSet = new DavPropertySet();
+        propSet.add(new LockDiscovery(locks));
+        sendXmlResponse(propSet, SC_OK);
+    }
+
+    /**
+     * Send Xml response body.
+     *
+     * @param serializable
+     * @param status
+     * @throws IOException
+     * @see DavServletResponse#sendXmlResponse(XmlSerializable, int)
+     */
+    public void sendXmlResponse(XmlSerializable serializable, int status) throws IOException
{
+        httpResponse.setStatus(status);
+        if (serializable != null) {
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            try {
+                Document doc = DomUtil.BUILDER_FACTORY.newDocumentBuilder().newDocument();
+                doc.appendChild(serializable.toXml(doc));
+
+                TransformerFactory factory = TransformerFactory.newInstance();
+                Transformer transformer = factory.newTransformer();
+                transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+                transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+                transformer.setOutputProperty(OutputKeys.INDENT, "no");
+                transformer.transform(new DOMSource(doc), new StreamResult(out));
+
+                byte[] bytes = out.toByteArray();
+                httpResponse.setContentType("text/xml; charset=UTF-8");
+                httpResponse.setContentLength(bytes.length);
+                httpResponse.getOutputStream().write(bytes);
+
+            } catch (ParserConfigurationException e) {
+                log.error(e.getMessage());
+                throw new IOException(e.getMessage());
+            } catch (TransformerException e) {
+                log.error("XML serialization failed", e);
+                IOException exception =
+                    new IOException("XML serialization failed");
+                exception.initCause(e);
+                throw exception;
+            }
+        }
+    }
+
+    //----------------------------< ObservationDavServletResponse Interface >---
+    /**
+     *
+     * @param subscription
+     * @throws IOException
+     * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletResponse#sendSubscriptionResponse(org.apache.jackrabbit.webdav.observation.Subscription)
+     */
+    public void sendSubscriptionResponse(Subscription subscription) throws IOException {
+        String id = subscription.getSubscriptionId();
+        if (id != null) {
+            Header h = new CodedUrlHeader(ObservationConstants.HEADER_SUBSCRIPTIONID, id);
+            httpResponse.setHeader(h.getHeaderName(), h.getHeaderValue());
+        }
+        DavPropertySet propSet = new DavPropertySet();
+        propSet.add(new SubscriptionDiscovery(subscription));
+        sendXmlResponse(propSet, SC_OK);
+    }
+
+    /**
+     *
+     * @param eventDiscovery
+     * @throws IOException
+     * @see org.apache.jackrabbit.webdav.observation.ObservationDavServletResponse#sendPollResponse(org.apache.jackrabbit.webdav.observation.EventDiscovery)
+     */
+    public void sendPollResponse(EventDiscovery eventDiscovery) throws IOException {
+        sendXmlResponse(eventDiscovery, SC_OK);
+    }
+
+    //--------------------------------------< HttpServletResponse interface >---
+    public void addCookie(Cookie cookie) {
+        httpResponse.addCookie(cookie);
+    }
+
+    public boolean containsHeader(String s) {
+        return httpResponse.containsHeader(s);
+    }
+
+    public String encodeURL(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public String encodeRedirectURL(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public String encodeUrl(String s) {
+        return httpResponse.encodeUrl(s);
+    }
+
+    public String encodeRedirectUrl(String s) {
+        return httpResponse.encodeRedirectURL(s);
+    }
+
+    public void sendError(int i, String s) throws IOException {
+        httpResponse.sendError(i, s);
+    }
+
+    public void sendError(int i) throws IOException {
+        httpResponse.sendError(i);
+    }
+
+    public void sendRedirect(String s) throws IOException {
+        httpResponse.sendRedirect(s);
+    }
+
+    public void setDateHeader(String s, long l) {
+        httpResponse.setDateHeader(s, l);
+    }
+
+    public void addDateHeader(String s, long l) {
+        httpResponse.addDateHeader(s, l);
+    }
+
+    public void setHeader(String s, String s1) {
+        httpResponse.setHeader(s, s1);
+    }
+
+    public void addHeader(String s, String s1) {
+        httpResponse.addHeader(s, s1);
+    }
+
+    public void setIntHeader(String s, int i) {
+        httpResponse.setIntHeader(s, i);
+    }
+
+    public void addIntHeader(String s, int i) {
+        httpResponse.addIntHeader(s, i);
+    }
+
+    public void setStatus(int i) {
+        httpResponse.setStatus(i);
+    }
+
+    public void setStatus(int i, String s) {
+        httpResponse.setStatus(i, s);
+    }
+
+    public String getCharacterEncoding() {
+        return httpResponse.getCharacterEncoding();
+    }
+
+    public ServletOutputStream getOutputStream() throws IOException {
+        return httpResponse.getOutputStream();
+    }
+
+    public PrintWriter getWriter() throws IOException {
+        return httpResponse.getWriter();
+    }
+
+    public void setContentLength(int i) {
+        httpResponse.setContentLength(i);
+    }
+
+    public void setContentType(String s) {
+        httpResponse.setContentType(s);
+    }
+
+    public void setBufferSize(int i) {
+        httpResponse.setBufferSize(i);
+    }
+
+    public int getBufferSize() {
+        return httpResponse.getBufferSize();
+    }
+
+    public void flushBuffer() throws IOException {
+        httpResponse.flushBuffer();
+    }
+
+    public void resetBuffer() {
+        httpResponse.resetBuffer();
+    }
+
+    public boolean isCommitted() {
+        return httpResponse.isCommitted();
+    }
+
+    public void reset() {
+        httpResponse.reset();
+    }
+
+    public void setLocale(Locale locale) {
+        httpResponse.setLocale(locale);
+    }
+
+    public Locale getLocale() {
+        return httpResponse.getLocale();
+    }
+}

Propchange: maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavResponseImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
URL: http://svn.apache.org/viewvc/maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java?rev=658034&view=auto
==============================================================================
--- maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
(added)
+++ maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
Mon May 19 16:09:04 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.client.methods;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.w3c.dom.Document;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+/**
+ * <code>XmlRequestEntity</code>...
+ */
+public class XmlRequestEntity implements RequestEntity {
+
+    private static Logger log = LoggerFactory.getLogger(XmlRequestEntity.class);
+
+    private final RequestEntity delegatee;
+
+    public XmlRequestEntity(Document xmlDocument) throws IOException {
+        super();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        try {
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer transformer = factory.newTransformer();
+            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            transformer.setOutputProperty(OutputKeys.INDENT, "no");
+            transformer.transform(
+                    new DOMSource(xmlDocument), new StreamResult(out));
+        } catch (TransformerException e) {
+            log.error("XML serialization failed", e);
+            IOException exception =
+                new IOException("XML serialization failed");
+            exception.initCause(e);
+            throw exception;
+        }
+
+        delegatee = new StringRequestEntity(out.toString(), "text/xml", "UTF-8");
+    }
+
+    public boolean isRepeatable() {
+        return delegatee.isRepeatable();
+    }
+
+    public String getContentType() {
+        return delegatee.getContentType();
+    }
+
+    public void writeRequest(OutputStream out) throws IOException {
+        delegatee.writeRequest(out);
+    }
+
+    public long getContentLength() {
+        return delegatee.getContentLength();
+    }
+}
\ No newline at end of file

Propchange: maven/wagon/branches/WAGON-109/wagon-providers/wagon-webdav/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.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


Mime
View raw message