juergen 02/01/02 07:12:33
Added: src/webdav/client/src/org/apache/webdav/lib/methods
CheckinMethod.java CheckoutMethod.java
MkWorkspaceMethod.java ReportMethod.java
UncheckoutMethod.java VersionControlMethod.java
Log:
first version of the delta-v prototype (client part).
Revision Changes Path
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckinMethod.java
Index: CheckinMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckinMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.InputStream;
import java.io.IOException;
import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
import org.apache.util.XMLPrinter;
/**
* The CHECKIN method can be applied to a checked-out version-controlled
* resource to produce a new version whose content and dead properties are
* copied from the checked-out resource.
*
* <p> This implementation of a CHECKIN client method does support a
* a request body.</p>
*
* <p> If a CHECKIN request fails, the server state preceding the request
* MUST be restored. The request body MUST be a DAV:checkin XML element with
* at most one DAV:keep-checked-out or DAV:fork-ok.</p>
*
*
* <h3>Example Request</h3>
* <pre>
* CHECKIN /foo.html HTTP/1.1
* Host: www.server.org
* Content-type: text/xml; charset="utf-8"
* Content-Length: xx
* </pre>
*
* <h3>Example Response</h3>
* <pre>
* HTTP/1.1 201 Created
* Location: http://server.org/history/1/1.1
* Content-type: text/xml; charset="utf-8"
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Cristina
Karpenstein</a>
*/
public class CheckinMethod
extends XMLResponseMethodBase {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public CheckinMethod() {
name = "CHECKIN";
}
/**
* Method constructor.
*/
public CheckinMethod(String path) {
super(path);
name = "CHECKIN";
}
// ------------------------------------------------------------- Properties
public void setHeader(String headerName, String headerValue) {
super.setHeader(headerName, headerValue);
}
// --------------------------------------------------- WebdavMethod Methods
public void recycle() {
super.recycle();
}
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
public void generateHeaders(String host, State state) {
super.generateHeaders(host, state);
//super.setHeader("Content-Type", "text/xml; charset=utf-8");
}
/**
* Generate the query body.
*
* @return String query
*/
public String generateQuery() {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
System.out.println(printer.toString());
return "";
/*if (query != null)
return printer.toString()+ query;
printer.writeElement("D", "DAV:", "checkin",
XMLPrinter.OPENING);
printer.writeElement("D", "fork-ok", XMLPrinter.NO_CONTENT);
printer.writeElement("D", "keep-checked-out", XMLPrinter.NO_CONTENT);
printer.writeElement("D", "checkin", XMLPrinter.CLOSING);
query = printer.toString();
System.out.println("query: " +query);
return query;*/
}
/**
* Parse response.
*
* @param input Input stream
*/
public void parseResponse(InputStream input)
throws IOException, HttpException {
}
}
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckoutMethod.java
Index: CheckoutMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/CheckoutMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.InputStream;
import java.io.IOException;
import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
/**
* The Checkout method can be applied to a checked-in version-controlled
* resource.
*
*
*
* <h3>Example Request</h3>
* <pre>
* Checkout /foo.html HTTP/1.1
* Host: www.server.org
* Content-Length: xx
* </pre>
*
* <h3>Example Response</h3>
* <pre>
* HTTP/1.1 200 OK
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mathias Luber</a>
*/
public class CheckoutMethod
extends XMLResponseMethodBase {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public CheckoutMethod() {
name = "Checkout";
}
/**
* Method constructor.
*/
public CheckoutMethod(String path) {
super(path);
name = "Checkout";
}
// ------------------------------------------------------------- Properties
public void setHeader(String headerName, String headerValue) {
super.setHeader(headerName, headerValue);
}
// --------------------------------------------------- WebdavMethod Methods
public void recycle() {
super.recycle();
}
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
public void generateHeaders(String host, State state) {
super.generateHeaders(host, state);
}
/**
* Generate the query body.
*
* @return String query
*/
public String generateQuery() {
return "";
}
/**
* Parse response.
*
* @param input Input stream
*/
public void parseResponse(InputStream input)
throws IOException, HttpException {
}
}
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkWorkspaceMethod.java
Index: MkWorkspaceMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/MkWorkspaceMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.InputStream;
import java.io.IOException;
import org.apache.commons.httpclient.HttpMethodBase;
/**
* The MkWorkspace method is used to create a new workspace. New workspaces
* can only be created in the workspace collection of the server. A workspace
* can contain version controled resources and any other. Each resource
* must identify its workspace.
*
* It is not allowed to create a new workspace inside an exiting workspace.
*
*
* <h3>Example Request</h3>
* <pre>
* MKWORKSPACE /ws/myWs/ HTTP/1.1
* Host: www.server.org
* </pre>
*
* <h3>Example Response</h3>
* <pre>
* HTTP/1.1 201 Created
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mathias Luber</a>
*/
public class MkWorkspaceMethod
extends HttpMethodBase {
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public MkWorkspaceMethod() {
name = "MKWORKSPACE";
}
/**
* Method constructor.
*/
public MkWorkspaceMethod(String path) {
super(path);
name = "MKWORKSPACE";
}
// --------------------------------------------------- WebdavMethod Methods
/**
* Parse the response body. The MkWorkspace method does not receive a response
* body.
*
* @param is Input stream
*/
public void parseResponse(InputStream is)
throws IOException {
}
}
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/ReportMethod.java
Index: ReportMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/ReportMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.util.Enumeration;
import java.util.Vector;
import org.apache.util.XMLPrinter;
import org.apache.commons.httpclient.State;
import org.apache.webdav.lib.PropertyName;
/**
* This class implements the WebDAV REPORT Method.
*
* <P> The REPORT method retrieves properties defined on the resource
* identified by the Request-URI, if the resource does not have any internal
* members, or on the resource identified by the Request-URI and potentially
* its member resources, if the resource is a collection that has internal
* member URIs.
*
* <P> A typical request looks like this:
*
* @author Mathias Luber
*/
public class ReportMethod extends XMLResponseMethodBase
implements DepthSupport {
// -------------------------------------------------------------- Constants
/**
* Request specified properties.
*/
public static final int SUB_SET = 0;
/**
* Request of all properties name and value.
*/
public static final int ALL = 1;
public static final int LOCATE_HISTORY = 2;
public String sVersionHistory ="";
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public ReportMethod() {
name = "REPORT";
}
/**
* Method constructor.
*/
public ReportMethod(String path) {
super(path);
name = "REPORT";
}
/**
* Method constructor.
*/
public ReportMethod(String path, int depth) {
this(path);
setDepth(depth);
}
/**
* Method constructor.
*/
public ReportMethod(String path, Enumeration propertyNames) {
this(path);
setDepth(1);
setPropertyNames(propertyNames);
setType(SUB_SET);
}
/**
* Method constructor.
*/
public ReportMethod(String path, int depth, Enumeration propertyNames,
Enumeration histUrl) {
this(path);
setDepth(depth);
setPropertyNames(propertyNames);
setHistoryURLs(histUrl);
setType(LOCATE_HISTORY);
}
/**
* Method constructor.
*/
public ReportMethod(String path, int depth, Enumeration propertyNames) {
this(path);
setDepth(depth);
setPropertyNames(propertyNames);
setType(SUB_SET);
}
public ReportMethod(String path, int depth, String sBody) {
this(path);
setDepth(depth);
setType(SUB_SET);
query=sBody;
}
// ----------------------------------------------------- Instance Variables
/**
* Type of the Propfind.
*/
protected int type = ALL;
/**
* Property name list.
*/
protected PropertyName[] propertyNames;
/**
* Depth.
*/
protected int depth = DEPTH_INFINITY;
/**
* The namespace abbreviation that prefixes DAV tags
*/
protected String prefix = null;
// ------------------------------------------------------------- Properties
/**
* Set header. handle the special case of Depth.
*
* @param headerName Header name
* @param headerValue Header value
*/
public void setHeader(String headerName, String headerValue) {
if (headerName.equalsIgnoreCase("Depth")){
int depth = -1;
if (headerValue.equals("0")){
depth = DEPTH_0;
}
if (headerValue.equals("1")){
depth = DEPTH_1;
}
else if (headerValue.equalsIgnoreCase("infinity")){
depth = DEPTH_INFINITY;
}
setDepth(depth);
}
else{
super.setHeader(headerName, headerValue);
}
}
/**
* Type setter.
*
* @param type New type value
*/
public void setType(int type) {
checkNotUsed();
this.type = type;
}
/**
* Type getter.
*
* @return int type value
*/
public int getType() {
return type;
}
/**
* Depth setter.
*
* @param depth New depth value
*/
public void setDepth(int depth) {
checkNotUsed();
this.depth = depth;
}
/**
* Depth getter.
*
* @return int depth value
*/
public int getDepth() {
return depth;
}
/**
* Property names setter.
* The enumeration may contain strings with or without a namespace prefix
* but the preferred way is to provide PropertyName objects.
*
* @param propertyNames List of the property names
*/
public void setPropertyNames(Enumeration propertyNames) {
checkNotUsed();
Vector list = new Vector();
while (propertyNames.hasMoreElements()) {
Object item = propertyNames.nextElement();
if (item instanceof PropertyName)
{
list.add(item);
}
else if (item instanceof String)
{
String propertyName = (String) item;
int length = propertyName.length();
boolean found = false;
int i = 1;
while (!found && (i <= length)) {
char chr = propertyName.charAt(length - i);
if (!Character.isUnicodeIdentifierPart(chr)
&& chr!='-' && chr!='_' && chr!='.') {
found = true;
} else {
i++;
}
}
if ((i == 1) || (i >= length)) {
list.add(new PropertyName("DAV:",propertyName));
} else {
String namespace = propertyName.substring(0, length + 1 - i);
String localName = propertyName.substring(length + 1 - i);
list.add(new PropertyName(namespace,localName));
}
}
else
{
// unknown type
// ignore
}
}
this.propertyNames = (PropertyName[])list.toArray(new
PropertyName[list.size()]);
}
/**
* sets History URL for locate by history Report
*/
public void setHistoryURLs(Enumeration historyURLs) {
sVersionHistory = "<D:version-history-set>";
while (historyURLs.hasMoreElements())
{
sVersionHistory += "<D:href>"+ historyURLs.nextElement().toString() +
"</D:href>";
}
sVersionHistory += "</D:version-history-set>";
}
// --------------------------------------------------- WebdavMethod Methods
public void recycle() {
super.recycle();
prefix = null;
}
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
public void generateHeaders(String host, State state) {
super.generateHeaders(host, state);
super.setHeader("Content-Type", "text/xml; charset=utf-8");
switch (depth) {
case DEPTH_0:
super.setHeader("Depth", "0");
break;
case DEPTH_1:
super.setHeader("Depth", "1");
break;
case DEPTH_INFINITY:
super.setHeader("Depth", "infinity");
break;
}
}
/**
* Generate the query body.
*
* @return String query
*/
public String generateQuery() {
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
if (query != null)
return printer.toString()+ query;
if (type!= LOCATE_HISTORY)
printer.writeElement("D", "DAV:", "version-tree",
XMLPrinter.OPENING);
switch (type) {
case ALL:
printer.writeElement("D", "allprop", XMLPrinter.NO_CONTENT);
printer.writeElement("D", "version-tree", XMLPrinter.CLOSING);
break;
case SUB_SET:
printer.writeElement("D", "prop", XMLPrinter.OPENING);
for (int i=0 ; i<propertyNames.length ; i++)
{
String namespace = propertyNames[i].getNamespaceURI();
String localname = propertyNames[i].getLocalName();
if ("DAV:".equals(namespace)) {
printer.writeElement("D", localname, XMLPrinter.NO_CONTENT);
} else {
printer.writeElement("ZZ", namespace,localname ,
XMLPrinter.NO_CONTENT);
}
}
printer.writeElement("D", "prop", XMLPrinter.CLOSING);
printer.writeElement("D", "version-tree", XMLPrinter.CLOSING);
break;
case LOCATE_HISTORY:
printer.writeElement("D", "DAV:", "locate-by-history",
XMLPrinter.OPENING);
printer.writeText(sVersionHistory);
printer.writeElement("D", "prop", XMLPrinter.OPENING);
for (int i=0 ; i<propertyNames.length ; i++)
{
String namespace = propertyNames[i].getNamespaceURI();
String localname = propertyNames[i].getLocalName();
if ("DAV:".equals(namespace)) {
printer.writeElement("D", localname, XMLPrinter.NO_CONTENT);
} else {
printer.writeElement("ZZ", namespace,localname ,
XMLPrinter.NO_CONTENT);
}
}
printer.writeElement("D", "prop", XMLPrinter.CLOSING);
printer.writeElement("D", "locate-by-history", XMLPrinter.CLOSING);
break;
}
query = printer.toString();
//System.out.println(query);
return query;
}
/**
* This method returns an enumeration of URL paths. If the ReportMethod
* was sent to the URL of a collection, then there will be multiple URLs.
* The URLs are picked out of the <code><D:href></code> elements
* of the response.
*
* @return an enumeration of URL paths as Strings
*/
public Enumeration getAllResponseURLs() {
checkUsed();
return getResponseHashtable().keys();
}
/**
* Returns an enumeration of <code>Property</code> objects.
*/
public Enumeration getResponseProperties(String urlPath) {
checkUsed();
Response response = (Response) getResponseHashtable().get(urlPath);
if (response != null) {
return response.getProperties();
} else {
return (new Vector()).elements();
}
}
}
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UncheckoutMethod.java
Index: UncheckoutMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/UncheckoutMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.InputStream;
import java.io.IOException;
import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
/**
* The Checkout method can be applied to a checked-in version-controlled
* resource.
*
*
*
* <h3>Example Request</h3>
* <pre>
* Uncheckout /foo.html HTTP/1.1
* Host: www.server.org
* Content-Length: xx
* </pre>
*
* <h3>Example Response</h3>
* <pre>
* HTTP/1.1 200 OK
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Mathias Luber</a>
*/
public class UncheckoutMethod
extends XMLResponseMethodBase {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public UncheckoutMethod() {
name = "Uncheckout";
}
/**
* Method constructor.
*/
public UncheckoutMethod(String path) {
super(path);
name = "Uncheckout";
}
// ------------------------------------------------------------- Properties
public void setHeader(String headerName, String headerValue) {
super.setHeader(headerName, headerValue);
}
// --------------------------------------------------- WebdavMethod Methods
public void recycle() {
super.recycle();
}
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
public void generateHeaders(String host, State state) {
super.generateHeaders(host, state);
}
/**
* Generate the query body.
*
* @return String query
*/
public String generateQuery() {
return "";
}
/**
* Parse response.
*
* @param input Input stream
*/
public void parseResponse(InputStream input)
throws IOException, HttpException {
}
}
1.1
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/VersionControlMethod.java
Index: VersionControlMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/VersionControlMethod.java,v
1.1 2002/01/02 15:12:32 juergen Exp $
* $Revision: 1.1 $
* $Date: 2002/01/02 15:12:32 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.webdav.lib.methods;
import java.io.InputStream;
import java.io.IOException;
import org.apache.commons.httpclient.State;
import org.apache.commons.httpclient.HttpException;
import org.apache.util.XMLPrinter;
/**
*/
public class VersionControlMethod
extends XMLResponseMethodBase implements DepthSupport {
// -------------------------------------------------------------- Constants
// ----------------------------------------------------- Instance Variables
private String sComment, sCreatorDisplayName;
private String sTarget = null;
// ----------------------------------------------------------- Constructors
/**
* Method constructor.
*/
public VersionControlMethod() {
name = "VERSION-CONTROL";
sComment ="none";
sCreatorDisplayName ="unknown";
}
/**
* Method constructor.
*/
public VersionControlMethod(String path) {
super(path);
name = "VERSION-CONTROL";
}
public VersionControlMethod(String path, String sTarget) {
super(path);
name = "VERSION-CONTROL";
this.sTarget = sTarget;
}
// ------------------------------------------------------------- Properties
public int getDepth(){
return 0;
}
public void setDepth(int depth){
/*azblm: don't know if needed and / or allowed */
}
public void setHeader(String headerName, String headerValue) {
super.setHeader(headerName, headerValue);
if (sTarget != null) super.setHeader("Content-Type", "text/xml;
charset=utf-8");
}
// --------------------------------------------------- WebdavMethod Methods
public void recycle() {
super.recycle();
}
/**
* Generate additional headers needed by the request.
*
* @param host the host
* @param state State token
*/
public void generateHeaders(String host, State state) {
super.generateHeaders(host, state);
}
/**
* Generate the query body.
*
* @return String query
*/
public String generateQuery() {
if (sTarget != null){
XMLPrinter printer = new XMLPrinter();
printer.writeXMLHeader();
printer.writeElement("D", "DAV:", "version-control",
XMLPrinter.OPENING);
printer.writeElement("D", "version",
XMLPrinter.OPENING);
printer.writeElement("D", "href",
XMLPrinter.OPENING);
printer.writeText(sTarget);
printer.writeElement("D", "href",
XMLPrinter.CLOSING);
printer.writeElement("D", "version",
XMLPrinter.CLOSING);
printer.writeElement("D", "version-control",
XMLPrinter.CLOSING);
String query;
query = printer.toString();
System.out.println(query.toString());
return query;
}else return "";
}
/**
* Parse response.
*
* @param input Input stream
*/
public void parseResponse(InputStream input)
throws IOException, HttpException {
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>