juergen 02/01/21 10:26:55
Modified: src/webdav/server/org/apache/slide/webdav/method
PropFindMethod.java
Log:
1) encode the owner URL, if it contains reserved or I18N characters.
2) if the property value contains < or & enclose it between a cdata section, if not
already done.
Revision Changes Path
1.44 +110 -101
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.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- PropFindMethod.java 10 Jan 2002 15:45:37 -0000 1.43
+++ PropFindMethod.java 21 Jan 2002 18:26:54 -0000 1.44
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.43 2002/01/10 15:45:37 juergen Exp $
- * $Revision: 1.43 $
- * $Date: 2002/01/10 15:45:37 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/PropFindMethod.java,v
1.44 2002/01/21 18:26:54 juergen Exp $
+ * $Revision: 1.44 $
+ * $Date: 2002/01/21 18:26:54 $
*
* ====================================================================
*
@@ -93,7 +93,7 @@
// -------------------------------------------------------------- Constants
-
+
/**
* Root node URI.
*/
@@ -187,8 +187,8 @@
*/
protected static final String OWNER =
"owner";
-
-
+
+
/**
* Current user privilege set.
*/
@@ -566,35 +566,35 @@
String path = object.getUri();
-// String absoluteUri =
-// req.getRequestURI();
+ // String absoluteUri =
+ // req.getRequestURI();
//
-// System.out.println("getContextPath "+req.getContextPath());
-// System.out.println("getRequestURI "+req.getRequestURI());
-// System.out.println("getPathInfo "+req.getPathInfo());
-// System.out.println("getPathTranslated "+req.getPathTranslated());
-// System.out.println("getRealPath "+req.getRealPath("xx"));
-// System.out.println("getRemoteAddr "+req.getRemoteAddr());
-// System.out.println("getRemoteHost "+req.getRemoteHost());
-// System.out.println("getServerName "+req.getServerName());
-// System.out.println("getServletPath "+req.getServletPath());
+ // System.out.println("getContextPath
"+req.getContextPath());
+ // System.out.println("getRequestURI
"+req.getRequestURI());
+ // System.out.println("getPathInfo
"+req.getPathInfo());
+ // System.out.println("getPathTranslated
"+req.getPathTranslated());
+ // System.out.println("getRealPath
"+req.getRealPath("xx"));
+ // System.out.println("getRemoteAddr
"+req.getRemoteAddr());
+ // System.out.println("getRemoteHost
"+req.getRemoteHost());
+ // System.out.println("getServerName
"+req.getServerName());
+ // System.out.println("getServletPath
"+req.getServletPath());
//
-// String relativePath = requestUri;
-// String toAppend = "";
-// if (relativePath.length() <= path.length()) {
-// toAppend = path.substring(relativePath.length());
-// if ((!absoluteUri.endsWith("/")) &&
-// (!toAppend.startsWith("/"))) {
-// toAppend = "/" + toAppend;
-// }
-// if (toAppend.equals("/")) {
-// toAppend = "";
-// }
-// }
+ // String relativePath = requestUri;
+ // String toAppend = "";
+ // if (relativePath.length() <= path.length()) {
+ // toAppend =
path.substring(relativePath.length());
+ // if ((!absoluteUri.endsWith("/")) &&
+ // (!toAppend.startsWith("/"))) {
+ // toAppend = "/" + toAppend;
+ // }
+ // if (toAppend.equals("/")) {
+ // toAppend = "";
+ // }
+ // }
generatedXML.writeText(
- WebdavUtils.encodeURL(req.getContextPath() + path, "UTF-8"));
-// generatedXML.writeText(absoluteUri + toAppend);
+ WebdavUtils.encodeURL(req.getContextPath() + path, "UTF-8"));
+ // generatedXML.writeText(absoluteUri + toAppend);
} catch (RevisionDescriptorNotFoundException e) {
@@ -611,25 +611,25 @@
String path = object.getUri();
-// String absoluteUri =
-// WebdavUtils.getRelativePath(req, getConfig());
-// String relativePath = requestUri;
-// String toAppend = "";
-// if (relativePath.length() <= path.length()) {
-// toAppend = path.substring(relativePath.length());
-// if ((!absoluteUri.endsWith("/"))
-// && (!toAppend.startsWith("/"))) {
-// toAppend = "/" + toAppend;
-// }
-// }
+ // String absoluteUri =
+ // WebdavUtils.getRelativePath(req, getConfig());
+ // String relativePath = requestUri;
+ // String toAppend = "";
+ // if (relativePath.length() <= path.length()) {
+ // toAppend =
path.substring(relativePath.length());
+ // if ((!absoluteUri.endsWith("/"))
+ // && (!toAppend.startsWith("/"))) {
+ // toAppend = "/" + toAppend;
+ // }
+ // }
//
generatedXML.writeText(
- WebdavUtils.encodeURL(req.getContextPath() + path, "UTF-8"));
+ WebdavUtils.encodeURL(req.getContextPath() + path, "UTF-8"));
-// generatedXML.writeText(
-// WebdavUtils.encodeURL(absoluteUri + toAppend, "UTF-8"));
-// generatedXML.writeText(absoluteUri + toAppend);
+ // generatedXML.writeText(
+ // WebdavUtils.encodeURL(absoluteUri + toAppend,
"UTF-8"));
+ // generatedXML.writeText(absoluteUri + toAppend);
}
@@ -684,13 +684,13 @@
showAclSemantics(generatedXML);
showPrincipalCollectionSet(generatedXML);
}
-
+
{ // Owner property
NodeProperty ownerProperty =
revisionDescriptor.getProperty(OWNER, NodeProperty.DEFAULT_NAMESPACE);
String ownerHref;
NamespaceConfig config = token.getNamespaceConfig();
if ((ownerProperty != null) && (ownerProperty.getValue()!=null)
&&
- (!"".equals(ownerProperty.getValue().toString()))) {
+ (!"".equals(ownerProperty.getValue().toString()))) {
ownerHref=config.getUsersPath() + "/" +
ownerProperty.getValue().toString();
}
else {
@@ -702,7 +702,7 @@
generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
generatedXML.writeElement(null, OWNER, XMLPrinter.CLOSING);
}
-
+
// Other properties
Enumeration propertyList =
@@ -712,34 +712,16 @@
NodeProperty currentProperty =
(NodeProperty) propertyList.nextElement();
if (currentProperty != null) {
- String propertyName = currentProperty.getName();
- String namespace = currentProperty.getNamespace();
- if ((OWNER.equals(propertyName)) &&
(NodeProperty.DEFAULT_NAMESPACE.equals(namespace))) {
+ if ((OWNER.equals(currentProperty.getName())) &&
+ (NodeProperty.DEFAULT_NAMESPACE.equals(
+ currentProperty.getNamespace()))) {
// skip owner property
continue;
}
- generateNamespaceAbbreviation(namespace);
- String namespaceAbbrev =
- (String) namespaces.get(namespace);
- Object currentPropertyValue = currentProperty.getValue();
- if ((currentPropertyValue == null) ||
- (currentPropertyValue.toString().equals(""))) {
- generatedXML.writeElement
- (namespaceAbbrev, namespace,
- currentProperty.getName(),
- XMLPrinter.NO_CONTENT);
- } else {
- generatedXML.writeElement
- (namespaceAbbrev, namespace,
- currentProperty.getName(),
- XMLPrinter.OPENING);
- generatedXML.writeText
- (currentPropertyValue.toString());
- generatedXML.writeElement
- (namespaceAbbrev, namespace,
- currentProperty.getName(),
- XMLPrinter.CLOSING);
- }
+ generateNamespaceAbbreviation(
+ currentProperty.getNamespace());
+
+ writeSingleProperty(generatedXML, currentProperty);
}
}
@@ -850,7 +832,7 @@
String ownerHref;
NamespaceConfig config = token.getNamespaceConfig();
if ((ownerProperty != null) &&
(ownerProperty.getValue()!=null) &&
- (!"".equals(ownerProperty.getValue().toString()))) {
+ (!"".equals(ownerProperty.getValue().toString()))) {
ownerHref=config.getUsersPath() + "/" +
ownerProperty.getValue().toString();
}
else {
@@ -895,31 +877,7 @@
revisionDescriptor.getProperty(propertyName,
propertyNamespace);
if (currentProperty != null) {
-
- String namespace = currentProperty.getNamespace();
- String namespaceAbbrev =
- (String) namespaces.get(namespace);
- Object currentPropertyValue =
- currentProperty.getValue();
- if ((currentPropertyValue == null) ||
- (currentPropertyValue.toString().equals(""))) {
- generatedXML.writeElement
- (namespaceAbbrev, null,
- currentProperty.getName(),
- XMLPrinter.NO_CONTENT);
- } else {
- generatedXML.writeElement
- (namespaceAbbrev, null,
- currentProperty.getName(),
- XMLPrinter.OPENING);
- generatedXML.writeText
- (currentPropertyValue.toString());
- generatedXML.writeElement
- (namespaceAbbrev, null,
- currentProperty.getName(),
- XMLPrinter.CLOSING);
- }
-
+ writeSingleProperty(generatedXML, currentProperty);
} else {
propertiesNotFoundVector.addElement(property);
}
@@ -977,6 +935,56 @@
/**
+ * Write a single property including the value to the XML printer.
+ *
+ * @param generatedXML the output channel
+ * @param currentProperty the property to be written to the output channel
+ */
+ private void writeSingleProperty(XMLPrinter generatedXML, NodeProperty
currentProperty) {
+ if (currentProperty != null) {
+ writeSingleProperty(generatedXML,
+ currentProperty.getNamespace(),
+ currentProperty.getName(),
+ currentProperty.getValue());
+ }
+ }
+
+ /**
+ * Write a single property including the value to the XML printer.
+ *
+ * @param generatedXML the output channel
+ * @param namespace the property namespace
+ * @param propertyName the property Name
+ * @param propertyValue the property Value
+ */
+ private void writeSingleProperty(XMLPrinter generatedXML,
+ String namespace,
+ String propertyName,
+ Object propertyValue) {
+ String namespaceAbbrev = (String) namespaces.get(namespace);
+ if ((propertyValue == null) ||
+ (propertyValue.toString().equals(""))) {
+ generatedXML.writeElement
+ (namespaceAbbrev, null, propertyName, XMLPrinter.NO_CONTENT);
+ } else {
+ generatedXML.writeElement
+ (namespaceAbbrev, null, propertyName, XMLPrinter.OPENING);
+ String currentPropertyString = propertyValue.toString();
+ if (propertyName.equals("displayname") &&
+ !currentPropertyString.startsWith("<![CDATA[") &&
+ (currentPropertyString.indexOf("&") != -1||
+ currentPropertyString.indexOf("<") != -1 )) {
+ generatedXML.writeData(currentPropertyString);
+ } else {
+ generatedXML.writeText(currentPropertyString);
+ }
+ generatedXML.writeElement
+ (namespaceAbbrev, null, propertyName, XMLPrinter.CLOSING);
+ }
+ }
+
+
+ /**
* Generate a namespace abbreviation for the given namespace.
*
* @param namespaceName Name of the namespace
@@ -1062,7 +1070,8 @@
* contain. The webdav RFC leaves us completely free to
* put whatever we want inside the owner element.
*/
- generatedXML.writeData(token.getSubjectUri());
+ generatedXML.writeText(getFullPath(token.getSubjectUri()));
+// generatedXML.writeData(token.getSubjectUri());
generatedXML.writeElement(null, "owner", XMLPrinter.CLOSING);
generatedXML.writeElement(null, "timeout", XMLPrinter.OPENING);
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>