juergen 01/01/29 04:18:11
Modified: src/webdav/server/org/apache/slide/webdav/method
LockMethod.java PropFindMethod.java
PropPatchMethod.java WebdavMethod.java
Log:
if the body of a propfind method was coded in utf-8, the body was not properly
decoded by the Reader wrapper.. Now a Stream is used and the bytes are converted to a
String using the right encoding. Remy, isn't this a reader bug in Tomcat? The encoding
stays quoted in speachmarks, do we want to change this?
Revision Changes Path
1.4 +28 -28
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
Index: LockMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LockMethod.java 2001/01/17 16:49:00 1.3
+++ LockMethod.java 2001/01/29 12:18:04 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
1.3 2001/01/17 16:49:00 juergen Exp $
- * $Revision: 1.3 $
- * $Date: 2001/01/17 16:49:00 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
1.4 2001/01/29 12:18:04 juergen Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/01/29 12:18:04 $
*
* ====================================================================
*
@@ -211,28 +211,28 @@
// Show request
if (req.getContentLength() > 0) {
- System.out.println(new String(requestBody));
+ System.out.println(requestBody);
}
msProprietarySupport = isMsProprietarySupport();
- // Loads the associated object from the store.
- lockInfo_lockSubject = requestUri;
- if (lockInfo_lockSubject == null) {
- lockInfo_lockSubject = "/";
- }
-
- String depthStr = req.getHeader("Depth");
-
- if (depthStr == null) {
- depth = INFINITY;
- } else {
- if (depthStr.equals("0")) {
- depth = 0;
- } else {
+ // Loads the associated object from the store.
+ lockInfo_lockSubject = requestUri;
+ if (lockInfo_lockSubject == null) {
+ lockInfo_lockSubject = "/";
+ }
+
+ String depthStr = req.getHeader("Depth");
+
+ if (depthStr == null) {
+ depth = INFINITY;
+ } else {
+ if (depthStr.equals("0")) {
+ depth = 0;
+ } else {
depth = INFINITY;
- }
- }
+ }
+ }
String lockDurationStr = req.getHeader("Timeout");
if (lockDurationStr == null) {
@@ -269,7 +269,7 @@
}
*/
- if (req.getContentLength() > 0) {
+ if (req.getContentLength() > 0) {
lockType = LOCK_CREATION;
@@ -277,15 +277,15 @@
try {
Document document = documentBuilder.parse(new InputSource
- (new StringReader(new String(requestBody))));
+ (new StringReader(requestBody)));
// Get the root element of the document
Element rootElement = document.getDocumentElement();
lockInfoNode = rootElement;
} catch(Exception e) {
e.printStackTrace();
- resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
- throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
+ resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
+ throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
}
NodeList childList = lockInfoNode.getChildNodes();
@@ -693,13 +693,13 @@
}
-
-
+
+
/**
* Returns true
*/
- protected boolean methodNeedsTransactionSupport() {
- return true;
+ protected boolean methodNeedsTransactionSupport() {
+ return true;
}
1.5 +130 -129
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java
Index: PropFindMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropFindMethod.java 2001/01/25 05:48:11 1.4
+++ PropFindMethod.java 2001/01/29 12:18:05 1.5
@@ -1,13 +1,13 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.4 2001/01/25 05:48:11 remm Exp $
- * $Revision: 1.4 $
- * $Date: 2001/01/25 05:48:11 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.5 2001/01/29 12:18:05 juergen Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/01/29 12:18:05 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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
+ * 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"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.slide.webdav.method;
@@ -82,7 +82,7 @@
/**
* PROPFIND method.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
*/
public final class PropFindMethod extends WebdavMethod {
@@ -124,11 +124,11 @@
/**
* Supported locks property value.
*/
- private static final String SUPPORTED_LOCK = "<lockentry>"
+ private static final String SUPPORTED_LOCK = "<lockentry>"
+ "<lockscope><exclusive/></lockscope>"
+ "<locktype><write/></locktype>"
+ "</lockentry>"
- + "<lockentry>"
+ + "<lockentry>"
+ "<lockscope><shared/></lockscope>"
+ "<locktype><write/></locktype>"
+ "</lockentry>";
@@ -150,7 +150,7 @@
/**
- * Properties to display
+ * Properties to display
*/
private Vector propertyVector;
@@ -178,12 +178,12 @@
/**
* PROPFIND method constructor.
- *
+ *
* @param token Namespace access token
* @param req HTTP request
* @param resp HTTP response
*/
- public PropFindMethod(GenericServlet servlet, NamespaceAccessToken token,
+ public PropFindMethod(GenericServlet servlet, NamespaceAccessToken token,
HttpServletRequest req, HttpServletResponse resp) {
super(servlet, token, req, resp);
readRequestContent();
@@ -199,32 +199,32 @@
/**
* Parse the request.
- *
+ *
* @exception WebdavException Bad request
*/
- protected void parseRequest()
- throws WebdavException {
-
+ protected void parseRequest()
+ throws WebdavException {
+
msProprietarySupport = isMsProprietarySupport();
- String depthStr = req.getHeader("Depth");
-
- if (depthStr == null) {
- depth = INFINITY;
- } else {
- if (depthStr.equals("0")) {
+ String depthStr = req.getHeader("Depth");
+
+ if (depthStr == null) {
+ depth = INFINITY;
+ } else {
+ if (depthStr.equals("0")) {
depth = 0;
- }
- if (depthStr.equals("1")) {
+ }
+ if (depthStr.equals("1")) {
depth = 1;
- }
- if (depthStr.equals("infinity")) {
+ }
+ if (depthStr.equals("infinity")) {
depth = INFINITY;
- }
- }
+ }
+ }
+
+ if (req.getContentLength() != 0) {
- if (req.getContentLength() != 0) {
-
//Propfind propfind = null;
// Workaround : Castor doesn't work, so I use DOM in the meantime
@@ -232,9 +232,9 @@
Node propNode = null;
try {
- Document document =
+ Document document =
documentBuilder.parse(new InputSource
- (new StringReader(new String(requestBody))));
+ (new StringReader(requestBody)));
// Get the root element of the document
Element rootElement = document.getDocumentElement();
@@ -287,23 +287,23 @@
}
- }
-
+ }
+
}
/**
* Execute the request.
- *
- * @exception WebdavException
+ *
+ * @exception WebdavException
*/
- protected void executeRequest()
- throws IOException, WebdavException {
-
+ protected void executeRequest()
+ throws IOException, WebdavException {
+
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
- // Loads the associated object from the store.
- String resourceUri = requestUri;
+ // Loads the associated object from the store.
+ String resourceUri = requestUri;
// Get the object from Data.
ObjectNode resource = null;
@@ -315,7 +315,7 @@
e.printStackTrace();
try {
resp.sendError
- (WebdavStatus.SC_NOT_FOUND,
+ (WebdavStatus.SC_NOT_FOUND,
WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND));
} catch(IOException ex) {
ex.printStackTrace();
@@ -336,8 +336,8 @@
WebdavXMLPrinter generatedXML = new WebdavXMLPrinter(resp.getWriter());
generatedXML.writeXMLHeader();
- generatedXML.writeElement(null, "multistatus"
- + generateNamespaceDeclarations(),
+ generatedXML.writeElement(null, "multistatus"
+ + generateNamespaceDeclarations(),
WebdavXMLPrinter.OPENING);
if (resource != null) {
@@ -387,24 +387,24 @@
}
}
- generatedXML.writeElement(null, "multistatus",
+ generatedXML.writeElement(null, "multistatus",
WebdavXMLPrinter.CLOSING);
// Send remaining data
generatedXML.sendData();
/*
- try {
+ try {
//System.out.println("Query result");
//System.out.println(generatedXML.toString());
- Writer writer = resp.getWriter();
+ Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
- writer.flush();
- } catch (Exception e) {
+ writer.flush();
+ } catch (Exception e) {
e.printStackTrace();
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
*/
}
@@ -412,18 +412,18 @@
/**
* Parse properties of an object.
- *
- * @param object
- * @param multistatus
- * @exception WebdavException
+ *
+ * @param object
+ * @param multistatus
+ * @exception WebdavException
*/
- protected void parsePropertiesOfObject(ObjectNode object,
+ protected void parsePropertiesOfObject(ObjectNode object,
WebdavXMLPrinter generatedXML)
- throws WebdavException {
+ throws WebdavException {
generatedXML.writeElement(null, "response", WebdavXMLPrinter.OPENING);
- String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " "
+ String status = new String("HTTP/1.1 " + WebdavStatus.SC_OK + " "
+ WebdavStatus.getStatusText
(WebdavStatus.SC_OK));
NodeRevisionDescriptors revisionDescriptors = null;
@@ -435,12 +435,12 @@
try {
generatedXML.writeElement(null, "href", WebdavXMLPrinter.OPENING);
- revisionDescriptors =
+ revisionDescriptors =
content.retrieve(slideToken, object.getUri());
try {
- revisionDescriptor = content.retrieve(slideToken,
+ revisionDescriptor = content.retrieve(slideToken,
revisionDescriptors);
isCollection = isCollection(revisionDescriptor);
@@ -451,7 +451,7 @@
String toAppend = "";
if (relativePath.length() <= path.length()) {
toAppend = path.substring(relativePath.length());
- if ((!absoluteUri.endsWith("/")) &&
+ if ((!absoluteUri.endsWith("/")) &&
(!toAppend.startsWith("/"))) {
toAppend = "/" + toAppend;
}
@@ -464,7 +464,7 @@
} catch (RevisionDescriptorNotFoundException e) {
- // The object doesn't have any revision, we create a dummy
+ // The object doesn't have any revision, we create a dummy
// NodeRevisionDescriptor object
isCollection = true;
revisionDescriptor = new NodeRevisionDescriptor(0);
@@ -477,7 +477,7 @@
String toAppend = "";
if (relativePath.length() <= path.length()) {
toAppend = path.substring(relativePath.length());
- if ((!absoluteUri.endsWith("/"))
+ if ((!absoluteUri.endsWith("/"))
&& (!toAppend.startsWith("/"))) {
toAppend = "/" + toAppend;
}
@@ -489,7 +489,7 @@
generatedXML.writeElement(null, "href", WebdavXMLPrinter.CLOSING);
- Enumeration lockTokens = lock.enumerateLocks(slideToken,
+ Enumeration lockTokens = lock.enumerateLocks(slideToken,
object.getUri());
if (lockTokens.hasMoreElements()) {
@@ -516,11 +516,11 @@
case FIND_ALL_PROP :
// Show properties / values for current object.
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.OPENING);
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.OPENING);
- status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_OK));
@@ -530,41 +530,41 @@
}
// Supported locks
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.OPENING);
generatedXML.writeText(SUPPORTED_LOCK);
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.CLOSING);
// Other properties
- Enumeration propertyList =
+ Enumeration propertyList =
revisionDescriptor.enumerateProperties();
while (propertyList.hasMoreElements()) {
- NodeProperty currentProperty =
+ NodeProperty currentProperty =
(NodeProperty) propertyList.nextElement();
if (currentProperty != null) {
String namespace = currentProperty.getNamespace();
generateNamespaceAbbreviation(namespace);
- String namespaceAbbrev =
+ String namespaceAbbrev =
(String) namespaceAbbrevs.get(namespace);
Object currentPropertyValue = currentProperty.getValue();
- if ((currentPropertyValue == null) ||
+ if ((currentPropertyValue == null) ||
(currentPropertyValue.toString().equals(""))) {
generatedXML.writeElement
(namespaceAbbrev, namespace,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.NO_CONTENT);
} else {
generatedXML.writeElement
(namespaceAbbrev, namespace,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.OPENING);
generatedXML.writeText
(currentPropertyValue.toString());
generatedXML.writeElement
(namespaceAbbrev, namespace,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.CLOSING);
}
}
@@ -572,61 +572,61 @@
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.CLOSING);
generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.CLOSING);
- break;
- case FIND_PROPERTY_NAMES :
- // Show properties for current object.
+ break;
+ case FIND_PROPERTY_NAMES :
+ // Show properties for current object.
- status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_OK));
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.OPENING);
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.OPENING);
// Lock information
- generatedXML.writeElement(null, "lockdiscovery",
+ generatedXML.writeElement(null, "lockdiscovery",
WebdavXMLPrinter.NO_CONTENT);
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.NO_CONTENT);
// Then, add this resource's custom properties
propertyList = revisionDescriptor.enumerateProperties();
while (propertyList.hasMoreElements()) {
- NodeProperty currentProperty =
+ NodeProperty currentProperty =
(NodeProperty) propertyList.nextElement();
if (currentProperty != null) {
String namespace = currentProperty.getNamespace();
- String namespaceAbbrev =
+ String namespaceAbbrev =
(String) namespaceAbbrevs.get(namespace);
generatedXML.writeElement
(namespaceAbbrev, namespace,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.NO_CONTENT);
}
}
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.CLOSING);
generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.CLOSING);
- break;
- case FIND_BY_PROPERTY :
- // Show requested properties value.
+ break;
+ case FIND_BY_PROPERTY :
+ // Show requested properties value.
propertyList = propertyVector.elements();
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.OPENING);
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.OPENING);
- status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ status = new String("HTTP/1.1 " + WebdavStatus.SC_OK
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_OK));
@@ -639,48 +639,48 @@
// Lock information, dynamically generated
- if ((propertyName.equals("lockdiscovery")) &&
+ if ((propertyName.equals("lockdiscovery")) &&
(propertyNamespace.equals
(NodeProperty.DEFAULT_NAMESPACE))) {
// Return list of active locks ...
if (objectLockToken != null) {
showLockDiscoveryInfo(objectLockToken, generatedXML);
}
- } else if ((propertyName.equals("supportedlock")) &&
+ } else if ((propertyName.equals("supportedlock")) &&
(propertyNamespace.equals
(NodeProperty.DEFAULT_NAMESPACE))) {
// Supported locks
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.OPENING);
generatedXML.writeText(SUPPORTED_LOCK);
- generatedXML.writeElement(null, "supportedlock",
+ generatedXML.writeElement(null, "supportedlock",
WebdavXMLPrinter.CLOSING);
} else {
// Search in the custom properties
- NodeProperty currentProperty =
+ NodeProperty currentProperty =
revisionDescriptor.getProperty(propertyName,
propertyNamespace);
if (currentProperty != null) {
- Object currentPropertyValue =
+ Object currentPropertyValue =
currentProperty.getValue();
- if ((currentPropertyValue == null) ||
+ if ((currentPropertyValue == null) ||
(currentPropertyValue.toString().equals(""))) {
generatedXML.writeElement
(property.namespaceAbbrev, null,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.NO_CONTENT);
} else {
generatedXML.writeElement
(property.namespaceAbbrev, null,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.OPENING);
generatedXML.writeText
(currentPropertyValue.toString());
generatedXML.writeElement
(property.namespaceAbbrev, null,
- currentProperty.getName(),
+ currentProperty.getName(),
WebdavXMLPrinter.CLOSING);
}
} else {
@@ -692,33 +692,33 @@
generatedXML.writeElement(null, "prop", WebdavXMLPrinter.CLOSING);
generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.CLOSING);
- Enumeration propertiesNotFoundList =
+ Enumeration propertiesNotFoundList =
propertiesNotFoundVector.elements();
if (propertiesNotFoundList.hasMoreElements()) {
- status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND
+ status = new String("HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_NOT_FOUND));
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.OPENING);
- generatedXML.writeElement(null, "prop",
+ generatedXML.writeElement(null, "prop",
WebdavXMLPrinter.OPENING);
while (propertiesNotFoundList.hasMoreElements()) {
generatedXML.writeElement
- (null, (String) propertiesNotFoundList.nextElement(),
+ (null, (String) propertiesNotFoundList.nextElement(),
WebdavXMLPrinter.NO_CONTENT);
}
- generatedXML.writeElement(null, "prop",
+ generatedXML.writeElement(null, "prop",
WebdavXMLPrinter.CLOSING);
generatedXML.writeProperty(null, "status", status);
- generatedXML.writeElement(null, "propstat",
+ generatedXML.writeElement(null, "propstat",
WebdavXMLPrinter.CLOSING);
}
@@ -733,7 +733,7 @@
/**
* Parse a node for namespace declaration attributes.
- *
+ *
* @param node DOM node
*/
protected void parseNodeNamespaceDeclarations(Node node) {
@@ -754,7 +754,7 @@
if (attributeName.startsWith("xmlns:")) {
String namespaceAbbreviation =
attributeName.substring(6);
- namespaces.put(namespaceAbbreviation,
+ namespaces.put(namespaceAbbreviation,
currentNode.getNodeValue());
namespaceAbbrevs.put(currentNode.getNodeValue(),
namespaceAbbreviation);
@@ -772,7 +772,7 @@
/**
* Parse the namespace info of a node name.
- *
+ *
* @param node The DOM node to parse
* @return The corresponding Property object
*/
@@ -785,7 +785,7 @@
if (colon != -1) {
property.name = nodeName.substring(colon + 1);
property.namespaceAbbrev = nodeName.substring(0, colon);
- String namespace =
+ String namespace =
(String) namespaces.get(property.namespaceAbbrev);
if ((namespace) != null) {
property.namespace = namespace;
@@ -804,7 +804,7 @@
/**
* Generate a namespace abbreviation for the given namespace.
- *
+ *
* @param namespaceName Name of the namespace
*/
private void generateNamespaceAbbreviation(String namespaceName) {
@@ -826,7 +826,7 @@
/**
* Generate namespace declaration attributes.
- *
+ *
* @return String namespace attributes
*/
private String generateNamespaceDeclarations() {
@@ -852,17 +852,17 @@
/**
* Show lockdiscovery info.
- *
+ *
* @exception WebdavException Something is wrong with the servlet container
*/
- private void showLockDiscoveryInfo(NodeLock token,
- WebdavXMLPrinter generatedXML)
+ private void showLockDiscoveryInfo(NodeLock token,
+ WebdavXMLPrinter generatedXML)
throws WebdavException {
- generatedXML.writeElement(null, "lockdiscovery",
+ generatedXML.writeElement(null, "lockdiscovery",
WebdavXMLPrinter.OPENING);
- generatedXML.writeElement(null, "activelock",
+ generatedXML.writeElement(null, "activelock",
WebdavXMLPrinter.OPENING);
generatedXML.writeElement(null, "locktype", WebdavXMLPrinter.OPENING);
@@ -871,10 +871,10 @@
generatedXML.writeElement(null, "lockscope", WebdavXMLPrinter.OPENING);
if (token.isExclusive()) {
- generatedXML.writeElement(null, "exclusive",
+ generatedXML.writeElement(null, "exclusive",
WebdavXMLPrinter.NO_CONTENT);
} else {
- generatedXML.writeElement(null, "shared",
+ generatedXML.writeElement(null, "shared",
WebdavXMLPrinter.NO_CONTENT);
}
generatedXML.writeElement(null, "lockscope", WebdavXMLPrinter.CLOSING);
@@ -894,7 +894,7 @@
generatedXML.writeElement(null, "owner", WebdavXMLPrinter.CLOSING);
generatedXML.writeElement(null, "timeout", WebdavXMLPrinter.OPENING);
- generatedXML.writeText("Second-"
+ generatedXML.writeText("Second-"
+ (new Long((token.getExpirationDate().getTime()
- (new Date()).getTime())/1000))
.toString());
@@ -907,10 +907,10 @@
generatedXML.writeElement(null, "href", WebdavXMLPrinter.CLOSING);
generatedXML.writeElement(null, "locktoken", WebdavXMLPrinter.CLOSING);
- generatedXML.writeElement(null, "activelock",
+ generatedXML.writeElement(null, "activelock",
WebdavXMLPrinter.CLOSING);
- generatedXML.writeElement(null, "lockdiscovery",
+ generatedXML.writeElement(null, "lockdiscovery",
WebdavXMLPrinter.CLOSING);
}
@@ -931,3 +931,4 @@
}
+
1.5 +24 -24
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java
Index: PropPatchMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropPatchMethod.java 2001/01/22 18:47:17 1.4
+++ PropPatchMethod.java 2001/01/29 12:18:06 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
1.4 2001/01/22 18:47:17 remm Exp $
- * $Revision: 1.4 $
- * $Date: 2001/01/22 18:47:17 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropPatchMethod.java,v
1.5 2001/01/29 12:18:06 juergen Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/01/29 12:18:06 $
*
* ====================================================================
*
@@ -159,13 +159,13 @@
propertiesToRemove = new Vector();
- if (requestBody.length != 0) {
+ if (requestBody.length() != 0) {
try {
Node setNode = null;
Node removeNode = null;
Document document = documentBuilder.parse(new InputSource(
- (new StringReader(new String(requestBody)))));
+ (new StringReader(requestBody))));
// Get the root element of the document
Element rootElement = document.getDocumentElement();
@@ -299,15 +299,15 @@
content.create(slideToken, resourcePath, revisionDescriptor, null);
} catch(RevisionAlreadyExistException e) {
- // 500 - Internal server error
+ // 500 - Internal server error
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
} catch (LinkedObjectNotFoundException e) {
// 404 - Not found
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_NOT_FOUND);
- } catch (ObjectNotFoundException e) {
+ } catch (ObjectNotFoundException e) {
// 404 - Not found
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_NOT_FOUND);
@@ -315,21 +315,21 @@
// 403 - Forbidden
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_FORBIDDEN);
- } catch (ObjectLockedException e) {
+ } catch (ObjectLockedException e) {
// Locked
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_LOCKED);
} catch (ServiceAccessException e) {
- // 500 - Internal server error
+ // 500 - Internal server error
System.out.println(e.getMessage());
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- } catch (RuntimeException e) {
- // 500 - Internal server error
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ } catch (RuntimeException e) {
+ // 500 - Internal server error
e.printStackTrace();
resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
// No serious errors. Printing the XML report.
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
@@ -546,14 +546,14 @@
generatedXML.writeElement("d", "multistatus",
WebdavXMLPrinter.CLOSING);
- try {
+ try {
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
- writer.flush();
- } catch (Exception e) {
+ writer.flush();
+ } catch (Exception e) {
e.printStackTrace();
- throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
- }
+ throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
+ }
}
@@ -571,13 +571,13 @@
}
-
-
+
+
/**
* Returns true
*/
- protected boolean methodNeedsTransactionSupport() {
- return true;
+ protected boolean methodNeedsTransactionSupport() {
+ return true;
}
1.8 +74 -77
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java
Index: WebdavMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- WebdavMethod.java 2001/01/25 05:48:11 1.7
+++ WebdavMethod.java 2001/01/29 12:18:07 1.8
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.7 2001/01/25 05:48:11 remm Exp $
- * $Revision: 1.7 $
- * $Date: 2001/01/25 05:48:11 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/WebdavMethod.java,v
1.8 2001/01/29 12:18:07 juergen Exp $
+ * $Revision: 1.8 $
+ * $Date: 2001/01/29 12:18:07 $
*
* ====================================================================
*
@@ -140,7 +140,7 @@
/**
* Request body.
*/
- protected char[] requestBody;
+ protected String requestBody;
/**
@@ -302,7 +302,7 @@
}
}
-
+
/**
* Exceute method.
@@ -334,7 +334,7 @@
// something went wrong, we are here and the TA is still open
try {
token.rollback();
- } catch (Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -353,7 +353,7 @@
* methods get, propfind would not need transaction support.
*/
protected boolean methodNeedsTransactionSupport() {
- return true;
+ return true;
// this method should return false and e.g. PutMethod should
// overwrite it to true, but PropFind creates a RevisionDescriptors
// on the fly
@@ -427,31 +427,28 @@
return;
// TODO : Modify this and make it chunking aware
-
- int contentLength = req.getContentLength();
-
- char[] result = null;
- if (contentLength > 0) {
- try {
- BufferedReader reader = null;
- requestBody = new char[contentLength];
- int position = 0;
- reader = req.getReader();
- while (position < contentLength) {
- int nChar = reader.read(requestBody, position,
- contentLength - position);
- position = position + nChar;
- }
- reader.close();
- } catch (IOException e) {
- System.out.println(e.getMessage());
- } catch (RuntimeException e) {
- e.printStackTrace();
- }
+ try {
+ requestBody = new
String(NodeRevisionContent.readFromStream(req.getInputStream()),
+ getEncodingString(req.getCharacterEncoding()));
}
+ catch (Exception e) { e.printStackTrace();}
+
}
+
+
+
+ /**
+ * Translate the encoding string into a proper Java encoding String.
+ */
+ public static String getEncodingString(String httpEncoding) {
+ String result = httpEncoding;
+ if (result == null) result = System.getProperty("file.encoding");
+ if (result.startsWith("\"")) result = result.substring(1, result.length());
+ if (result.endsWith("\"")) result = result.substring(0,
result.length()-1);
+ return result;
+ }
/**
@@ -566,57 +563,57 @@
* by a valid 2-digit hexadecimal number
*/
protected static String URLDecode(String str)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
- if (str == null)
- return (null);
+ if (str == null)
+ return (null);
- StringBuffer dec = new StringBuffer();
- int pos = 0;
- int len = str.length();
- dec.ensureCapacity(str.length());
-
- while (pos < len) {
- int lookahead; // Look-ahead position
-
- // Look ahead to the next URLencoded metacharacter, if any
- for (lookahead = pos; lookahead < len; lookahead++) {
- char ch = str.charAt(lookahead);
- if ((ch == '+') || (ch == '%'))
- break;
- }
-
- // If there were non-metacharacters, copy them as a block
- if (lookahead > pos) {
- dec.append(str.substring(pos, lookahead));
- pos = lookahead;
- }
-
- // Shortcut out if we are at the end of the string
- if (pos >= len)
- break;
-
- // Process the next metacharacter
- char meta = str.charAt(pos);
- if (meta == '+') {
- dec.append(' ');
- pos++;
- } else if (meta == '%') {
- try {
- dec.append((char) Integer.parseInt
- (str.substring(pos+1, pos+3), 16));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException
- ("Invalid hexadecimal '" + str.substring(pos+1, pos+3)
- + " in URLencoded string");
- } catch (StringIndexOutOfBoundsException e) {
- throw new IllegalArgumentException
- ("Invalid unescaped '%' in URLcoded string");
- }
- pos += 3;
- }
- }
- return (dec.toString());
+ StringBuffer dec = new StringBuffer();
+ int pos = 0;
+ int len = str.length();
+ dec.ensureCapacity(str.length());
+
+ while (pos < len) {
+ int lookahead; // Look-ahead position
+
+ // Look ahead to the next URLencoded metacharacter, if any
+ for (lookahead = pos; lookahead < len; lookahead++) {
+ char ch = str.charAt(lookahead);
+ if ((ch == '+') || (ch == '%'))
+ break;
+ }
+
+ // If there were non-metacharacters, copy them as a block
+ if (lookahead > pos) {
+ dec.append(str.substring(pos, lookahead));
+ pos = lookahead;
+ }
+
+ // Shortcut out if we are at the end of the string
+ if (pos >= len)
+ break;
+
+ // Process the next metacharacter
+ char meta = str.charAt(pos);
+ if (meta == '+') {
+ dec.append(' ');
+ pos++;
+ } else if (meta == '%') {
+ try {
+ dec.append((char) Integer.parseInt
+ (str.substring(pos+1, pos+3), 16));
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException
+ ("Invalid hexadecimal '" + str.substring(pos+1, pos+3)
+ + " in URLencoded string");
+ } catch (StringIndexOutOfBoundsException e) {
+ throw new IllegalArgumentException
+ ("Invalid unescaped '%' in URLcoded string");
+ }
+ pos += 3;
+ }
+ }
+ return (dec.toString());
}