[Bedework-commit] webdav r75 - in
trunk/server/src/edu/rpi/cct/webdav/servlet: common shared
svnadmin at bedework.org
svnadmin at bedework.org
Tue Mar 13 21:55:34 EDT 2007
Author: douglm
Date: 2007-03-13 21:55:32 -0400 (Tue, 13 Mar 2007)
New Revision: 75
Modified:
trunk/server/src/edu/rpi/cct/webdav/servlet/common/CopyMethod.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/GetMethod.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/PrincipalMatchReport.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropFindMethod.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java
trunk/server/src/edu/rpi/cct/webdav/servlet/common/ReportMethod.java
trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
Log:
Changes to caldav code to move towards better handling of principals
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/CopyMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/CopyMethod.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/CopyMethod.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -126,7 +126,7 @@
WebdavNsIntf.nodeTypeUnknown);
int toNodeType;
- if (from.getCollection()) {
+ if (from.isCollection()) {
toNodeType = WebdavNsIntf.nodeTypeCollection;
} else {
toNodeType = WebdavNsIntf.nodeTypeEntity;
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/GetMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/GetMethod.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/GetMethod.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -116,7 +116,7 @@
String contentType;
int contentLength;
- if (node.getCollection()) {
+ if (node.isCollection()) {
if (getNsIntf().getDirectoryBrowsingDisallowed()) {
throw new WebdavException(HttpServletResponse.SC_FORBIDDEN);
}
@@ -279,7 +279,7 @@
sb.line("<tr>");
- if (node.getCollection()) {
+ if (node.isCollection()) {
/* folder */
} else {
/* calendar? */
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/MethodBase.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -57,7 +57,6 @@
import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;
-import edu.rpi.cct.webdav.servlet.shared.WebdavNsNode;
import edu.rpi.cct.webdav.servlet.shared.WebdavStatusCode;
import edu.rpi.sss.util.xml.QName;
import edu.rpi.sss.util.xml.XmlEmit;
@@ -66,7 +65,6 @@
import java.io.FilterReader;
import java.io.IOException;
import java.io.Reader;
-import java.net.URI;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
@@ -100,8 +98,6 @@
*/
protected WebdavNsIntf nsIntf;
- private String urlPrefix;
-
private String resourceUri;
// private String content;
@@ -173,7 +169,6 @@
this.dumpContent = dumpContent;
// config = servlet.getServletConfig();
- urlPrefix = WebdavUtils.getUrlPrefix(nsIntf.getRequest());
xml = nsIntf.getXmlEmit();
// content = null;
@@ -190,13 +185,6 @@
return nsIntf;
}
- /**
- * @return String url prefix
- */
- public String getUrlPrefix() {
- return urlPrefix;
- }
-
/** Get the decoded and fixed resource URI
*
* @param req Servlet request object
@@ -334,21 +322,6 @@
}
}
- protected void addHref(WebdavNsNode node) throws WebdavException {
- try {
- if (debug) {
- trace("Adding href " + getUrlPrefix() + node.getEncodedUri());
- }
-
- String url = getUrlPrefix() + new URI(node.getEncodedUri()).toASCIIString();
- property(WebdavTags.href, url);
- } catch (WebdavException wde) {
- throw wde;
- } catch (Throwable t) {
- throw new WebdavException(t);
- }
- }
-
protected void addStatus(int status, String message) throws WebdavException {
try {
if (message == null) {
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/PrincipalMatchReport.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/PrincipalMatchReport.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/PrincipalMatchReport.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -239,7 +239,7 @@
return nodes;
}
- if (!node.getCollection()) {
+ if (!node.isCollection()) {
nodes.add(node);
return nodes;
}
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropFindMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropFindMethod.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropFindMethod.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -258,7 +258,7 @@
*/
public void doNodeProperties(WebdavNsNode node,
PropRequest pr) throws WebdavException {
- addHref(node);
+ node.generateHref(xml);
openTag(WebdavTags.propstat);
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/PropPatchMethod.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -174,7 +174,7 @@
openTag(WebdavTags.multistatus);
openTag(WebdavTags.response);
- addHref(node);
+ node.generateHref(xml);
for (SetPropertyResult spr: failures) {
openTag(WebdavTags.propstat);
openTag(WebdavTags.prop);
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/ReportMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/ReportMethod.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/ReportMethod.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -131,7 +131,7 @@
openTag(WebdavTags.response);
if (status != HttpServletResponse.SC_OK) {
- addHref(node);
+ node.generateHref(xml);
openTag(WebdavTags.propstat);
Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java 2007-03-13 15:00:55 UTC (rev 74)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java 2007-03-14 01:55:32 UTC (rev 75)
@@ -60,7 +60,10 @@
import edu.rpi.sss.util.xml.QName;
import edu.rpi.sss.util.xml.XmlEmit;
+import java.io.Reader;
import java.io.Serializable;
+import java.io.StringReader;
+
import javax.servlet.http.HttpServletResponse;
import java.net.URI;
@@ -98,6 +101,10 @@
*/
//protected String name;
+ protected String urlPrefix;
+
+ protected String path;
+
/** True if this node is a collection
*/
protected boolean collection;
@@ -186,9 +193,16 @@
/** Constructor
*
+ * @param urlPrefix - needed for building hrefs.
+ * @param path - resource path
+ * @param collection - true if this is a collection
* @param debug
*/
- public WebdavNsNode(boolean debug) {
+ public WebdavNsNode(String urlPrefix, String path,
+ boolean collection, boolean debug) {
+ this.urlPrefix = urlPrefix;
+ this.path = path;
+ this.collection = collection;
this.debug = debug;
}
@@ -244,12 +258,74 @@
*/
public abstract boolean trailSlash();
+ /**
+ * @return String url prefix
+ */
+ public String getUrlPrefix() {
+ return urlPrefix;
+ }
+
+ /**
+ * @return String
+ */
+ public String getPath() {
+ return path;
+ }
+
/* ====================================================================
* Property methods
* ==================================================================== */
/**
+ * @param xml
+ * @throws WebdavException
*/
+ public void generateHref(XmlEmit xml) throws WebdavException {
+ try {
+ String url = getUrlPrefix() + new URI(getEncodedUri()).toASCIIString();
+ xml.property(WebdavTags.href, url);
+ } catch (WebdavException wde) {
+ throw wde;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
+ /**
+ * @param xml
+ * @param uri
+ * @throws WebdavException
+ */
+ public void generateHref(XmlEmit xml, String uri) throws WebdavException {
+ generateUrl(xml, WebdavTags.href, uri);
+ }
+
+ /**
+ * @param xml
+ * @param tag
+ * @param uri
+ * @throws WebdavException
+ */
+ public void generateUrl(XmlEmit xml, QName tag, String uri) throws WebdavException {
+ try {
+ String enc = new URI(null, null, uri, null).toString();
+ enc = new URI(enc).toASCIIString(); // XXX ???????
+
+ StringBuffer sb = new StringBuffer(getUrlPrefix());
+
+ if (!enc.startsWith("/")) {
+ sb.append("/");
+ }
+
+ sb.append(enc);
+ xml.property(tag, sb.toString());
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
+ /**
+ */
public static class PropVal {
/**
*/
@@ -382,11 +458,17 @@
if (tag.equals(WebdavTags.resourcetype)) {
// dav 13.9
- if (getCollection()) {
- xml.propertyTagVal(WebdavTags.resourcetype,
- WebdavTags.collection);
+ xml.openTag(WebdavTags.resourcetype);
+
+ if (isPrincipal()) {
+ xml.emptyTag(WebdavTags.principal);
}
+ if (isCollection()) {
+ xml.emptyTag(WebdavTags.collection);
+ }
+
+ xml.closeTag(WebdavTags.resourcetype);
return true;
}
@@ -514,18 +596,10 @@
}
/**
- * @param val boolean true for a collection
- * @throws WebdavException
- */
- public void setCollection(boolean val) throws WebdavException {
- collection = val;
- }
-
- /**
* @return boolean true for a collection
* @throws WebdavException
*/
- public boolean getCollection() throws WebdavException {
+ public boolean isCollection() throws WebdavException {
return collection;
}
@@ -595,6 +669,42 @@
return targetUri;
}
+ /** Return a collection of property objects
+ *
+ * <p>Default is to return an empty Collection
+ *
+ * @param ns String interface namespace.
+ * @return Collection (possibly empty) of WebdavProperty objects
+ * @throws WebdavException
+ */
+ public Collection<WebdavProperty> getProperties(String ns) throws WebdavException {
+ return new ArrayList<WebdavProperty>();
+ }
+
+ /** Returns an InputStream for the content.
+ *
+ * @return Reader A reader for the content.
+ * @throws WebdavException
+ */
+ public Reader getContent() throws WebdavException {
+ String cont = getContentString();
+
+ if (cont == null) {
+ return null;
+ }
+
+ return new StringReader(cont);
+ }
+
+ /** Return string content
+ *
+ * @return String content.
+ * @throws WebdavException
+ */
+ public String getContentString() throws WebdavException {
+ return null;
+ }
+
/* ====================================================================
* Required webdav properties
* ==================================================================== */
More information about the Bedework-commit
mailing list