[Bedework-commit] caldav r456 - in trunk:
server/src/org/bedework/caldav/server server/war/WEB-INF
util/src/org/bedework/caldav/util
svnadmin at bedework.org
svnadmin at bedework.org
Fri Sep 3 16:15:03 EDT 2010
Author: douglm
Date: 2010-09-03 16:15:01 -0400 (Fri, 03 Sep 2010)
New Revision: 456
Added:
trunk/server/war/WEB-INF/publicws-web.xml
trunk/server/war/WEB-INF/userws-web.xml
Modified:
trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java
trunk/server/src/org/bedework/caldav/server/CaldavBWServlet.java
trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java
trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java
trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java
trunk/util/src/org/bedework/caldav/util/CalDAVConfig.java
Log:
Changes to support ACCEPT header on GET
* Will enable fetching of calendars and address books when targeting collections
* Will be used by new web service to get XRD objects
Changes to XmlEmit to support better abbreviating of namespaces and better handling of default namespace. Also changes to handle some new xrd needs.
CalDAV server has partial support for CalWS - supports GET of XRD object.
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -25,6 +25,7 @@
*/
package org.bedework.caldav.server;
+import org.bedework.caldav.server.CaldavBwNode.PropertyTagXrdEntry;
import org.bedework.caldav.server.PostMethod.RequestPars;
import org.bedework.caldav.server.calquery.CalendarData;
import org.bedework.caldav.server.calquery.FreeBusyQuery;
@@ -68,12 +69,18 @@
import edu.rpi.sss.util.OptionsI;
import edu.rpi.sss.util.xml.XmlEmit;
import edu.rpi.sss.util.xml.XmlUtil;
+import edu.rpi.sss.util.xml.XmlEmit.NameSpace;
+import edu.rpi.sss.util.xml.tagdefs.CalWSTags;
+import edu.rpi.sss.util.xml.tagdefs.CalWSXrdDefs;
import edu.rpi.sss.util.xml.tagdefs.CaldavDefs;
import edu.rpi.sss.util.xml.tagdefs.CaldavTags;
import edu.rpi.sss.util.xml.tagdefs.WebdavTags;
+import edu.rpi.sss.util.xml.tagdefs.XrdTags;
+import edu.rpi.sss.util.xml.tagdefs.XsiTags;
import org.w3c.dom.Element;
+import java.io.CharArrayReader;
import java.io.InputStream;
import java.io.Reader;
import java.io.Serializable;
@@ -123,6 +130,9 @@
private CalDAVConfig config;
+ /* true if this is a CalWS server */
+ private boolean calWs;
+
/** We store CaldavURI objects here
* /
private HashMap<String, CaldavURI> uriMap = new HashMap<String, CaldavURI>();
@@ -148,9 +158,12 @@
final boolean debug,
final HashMap<String, MethodInfo> methods,
final boolean dumpContent) throws WebdavException {
- super.init(servlet, req, debug, methods, dumpContent);
+ try {
+ // Needed before any other initialization
+ calWs = Boolean.parseBoolean(servlet.getInitParameter("calws"));
- try {
+ super.init(servlet, req, debug, methods, dumpContent);
+
HttpSession session = req.getSession();
ServletContext sc = session.getServletContext();
@@ -171,10 +184,14 @@
sysi = getSysi(config.getSysintfImpl());
+ config.setCalWS(calWs);
+
sysi.init(req, account, config, debug);
accessUtil = new AccessUtil(namespacePrefix, xml,
new CalDavAccessXmlCb(sysi), debug);
+ } catch (WebdavException we) {
+ throw we;
} catch (Throwable t) {
throw new WebdavException(t);
}
@@ -398,11 +415,19 @@
*/
@Override
public void addNamespace(final XmlEmit xml) throws WebdavException {
- super.addNamespace(xml);
+ try {
+ if (calWs) {
+ xml.addNs(new NameSpace(CalWSTags.namespace, "CalWS"), true);
+ xml.addNs(new NameSpace(XsiTags.namespace, "xsi"), false);
+ xml.addNs(new NameSpace(XrdTags.namespace, "xrd"), false);
- try {
- xml.addNs(CaldavDefs.caldavNamespace);
- xml.addNs(CaldavDefs.icalNamespace);
+ return;
+ }
+
+ super.addNamespace(xml);
+
+ xml.addNs(new NameSpace(CaldavDefs.caldavNamespace, "C"), true);
+ xml.addNs(new NameSpace(CaldavDefs.icalNamespace, "ical"), false);
} catch (Throwable t) {
throw new WebdavException(t);
}
@@ -546,6 +571,10 @@
return false;
}
+ if (calWs) {
+ return true;
+ }
+
if (!(node instanceof CaldavComponentNode)) {
return true;
}
@@ -565,15 +594,58 @@
}
@Override
- public Reader getContent(final HttpServletRequest req,
- final HttpServletResponse resp,
- final WebdavNsNode node) throws WebdavException {
+ public Content getContent(final HttpServletRequest req,
+ final HttpServletResponse resp,
+ final WebdavNsNode node) throws WebdavException {
try {
+ String accept = req.getHeader("ACCEPT");
+
+ if (node.isCollection()) {
+ if ((accept == null) || (accept.indexOf("text/html") >= 0)) {
+ if (getDirectoryBrowsingDisallowed()) {
+ throw new WebdavException(HttpServletResponse.SC_FORBIDDEN);
+ }
+
+ Content c = new Content();
+
+ String content = generateHtml(req, node);
+ c.rdr = new CharArrayReader(content.toCharArray());
+ c.contentType = "text/html";
+ c.contentLength = content.getBytes().length;
+
+ return c;
+ }
+
+ if (!calWs) {
+ return null;
+ }
+ }
+
+ boolean xrd = false;
+
+ if (calWs&& (accept != null)) {
+ xrd = "application/xrd+xml".equals(accept.trim());
+ }
+
+ if (xrd) {
+ return doXrd(req, resp, (CaldavBwNode)node);
+ }
+
+ if (node.isCollection()) {
+ return null;
+ }
+
if (!node.getAllowsGet()) {
return null;
}
- return node.getContent();
+ Content c = new Content();
+
+ c.rdr = node.getContent();
+ c.contentType = node.getContentType();
+ c.contentLength = node.getContentLen();
+
+ return c;
} catch (WebdavException we) {
throw we;
} catch (Throwable t) {
@@ -585,7 +657,7 @@
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#getBinaryContent(edu.rpi.cct.webdav.servlet.shared.WebdavNsNode)
*/
@Override
- public InputStream getBinaryContent(final WebdavNsNode node) throws WebdavException {
+ public Content getBinaryContent(final WebdavNsNode node) throws WebdavException {
try {
if (!node.getAllowsGet()) {
return null;
@@ -597,7 +669,13 @@
CaldavResourceNode bwnode = (CaldavResourceNode)node;
- return bwnode.getContentStream();
+ Content c = new Content();
+
+ c.stream = bwnode.getContentStream();
+ c.contentType = node.getContentType();
+ c.contentLength = node.getContentLen();
+
+ return c;
} catch (WebdavException we) {
throw we;
} catch (Throwable t) {
@@ -902,6 +980,64 @@
throw new WebdavBadRequest();
}
+ private Content doXrd(final HttpServletRequest req,
+ final HttpServletResponse resp,
+ final CaldavBwNode node) throws WebdavException {
+ resp.setContentType("application/xrd+xml; charset=UTF-8");
+
+ try {
+ xml.addNs(new NameSpace(XrdTags.namespace, "xrd"), true);
+
+ xml.startEmit(resp.getWriter());
+
+ xml.openTag(XrdTags.xrd);
+
+ xml.property(XrdTags.subject, node.getUrlValue());
+
+ for (PropertyTagXrdEntry pxe: node.getXrdNames()) {
+ if (pxe.inPropAll) {
+ node.generateXrdValue(pxe.xrdName, this, true);
+ }
+ }
+
+ if (node.isCollection()) {
+ // Provide link info for each child collection
+
+ for (WebdavNsNode child: getChildren(node)) {
+ CaldavBwNode cn = (CaldavBwNode)child;
+
+ xml.startTagIndent(XrdTags.link);
+ xml.attribute("rel", CalWSXrdDefs.childCollection);
+ xml.newline();
+ xml.value(" "); // Just to indent
+ xml.attribute("href", cn.getUrlValue());
+ xml.endTag();
+ xml.newline();
+
+ for (PropertyTagXrdEntry pxe: node.getXrdNames()) {
+ if (pxe.inLink) {
+ cn.generateXrdValue(pxe.xrdName, this, true);
+ }
+ }
+
+ xml.closeTag(XrdTags.link);
+ }
+ }
+
+ xml.closeTag(XrdTags.xrd);
+
+ xml.flush();
+
+ Content c = new Content();
+
+ c.written = true; // set content to say it's done
+
+ return c;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
private void copyMoveCollection(final HttpServletResponse resp,
final CaldavCalNode from,
final WebdavNsNode to,
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBWServlet.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBWServlet.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBWServlet.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -26,11 +26,18 @@
package org.bedework.caldav.server;
+import edu.rpi.cct.webdav.servlet.common.DeleteMethod;
+import edu.rpi.cct.webdav.servlet.common.GetMethod;
+import edu.rpi.cct.webdav.servlet.common.HeadMethod;
+import edu.rpi.cct.webdav.servlet.common.OptionsMethod;
+import edu.rpi.cct.webdav.servlet.common.PutMethod;
import edu.rpi.cct.webdav.servlet.common.WebdavServlet;
import edu.rpi.cct.webdav.servlet.common.MethodBase.MethodInfo;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
/** This class extends the webdav servlet class, implementing the abstract
@@ -39,15 +46,39 @@
* @author Mike Douglass douglm rpi.edu
*/
public class CaldavBWServlet extends WebdavServlet {
+ /* Is this a CalWS servlet? */
+ private boolean calWs;
+
/* ====================================================================
* Abstract servlet methods
* ==================================================================== */
+ @Override
+ public void init(final ServletConfig config) throws ServletException {
+ calWs = Boolean.parseBoolean(config.getInitParameter("calws"));
+
+ super.init(config);
+ }
+
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.common.WebdavServlet#addMethods()
*/
@Override
protected void addMethods() {
+ if (calWs) {
+ // Much reduced method set
+ methods.clear();
+
+ methods.put("DELETE", new MethodInfo(DeleteMethod.class, true));
+ methods.put("GET", new MethodInfo(GetMethod.class, false));
+ methods.put("HEAD", new MethodInfo(HeadMethod.class, false));
+ methods.put("OPTIONS", new MethodInfo(OptionsMethod.class, false));
+ methods.put("POST", new MethodInfo(PostMethod.class, false)); // Allow unauth POST for freebusy etc. true));
+ methods.put("PUT", new MethodInfo(PutMethod.class, true));
+
+ return;
+ }
+
super.addMethods();
// Replace methods
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -32,8 +32,13 @@
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.sss.util.xml.XmlEmit;
+import edu.rpi.sss.util.xml.tagdefs.CalWSXrdDefs;
import edu.rpi.sss.util.xml.tagdefs.CaldavTags;
+import edu.rpi.sss.util.xml.tagdefs.XrdTags;
+import edu.rpi.sss.util.xml.tagdefs.XsiTags;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -47,6 +52,8 @@
public abstract class CaldavBwNode extends WebdavNsNode {
// protected CaldavURI cdURI;
+ protected boolean rootNode;
+
protected CalDAVCollection col;
private final static HashMap<QName, PropertyTagEntry> propertyNames =
@@ -59,29 +66,67 @@
supportedReports.add(CaldavTags.calendarQuery); // Calendar access
}
+ /** */
+ public static final class PropertyTagXrdEntry extends PropertyTagEntry {
+ /** */
+ public String xrdName;
+
+ /** */
+ public boolean inLink;
+
+ /**
+ * @param tag
+ * @param xrdName
+ * @param inPropAll
+ * @param inLink
+ */
+ public PropertyTagXrdEntry(final QName tag, final String xrdName,
+ final boolean inPropAll,
+ final boolean inLink) {
+ super(tag, inPropAll);
+ this.xrdName = xrdName;
+ this.inLink = inLink;
+ }
+ }
+
+ private final static HashMap<String, PropertyTagXrdEntry> xrdNames =
+ new HashMap<String, PropertyTagXrdEntry>();
+
+ static {
+ addXrdEntry(xrdNames, CalWSXrdDefs.created, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.displayname, true, true);
+ addXrdEntry(xrdNames, CalWSXrdDefs.lastModified, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.owner, true, false);
+ }
+
/* for accessing calendars */
private SysIntf sysi;
- CaldavBwNode(CaldavURI cdURI, SysIntf sysi, boolean debug) throws WebdavException {
+ CaldavBwNode(final CaldavURI cdURI, final SysIntf sysi, final boolean debug) throws WebdavException {
super(sysi.getUrlHandler(), cdURI.getPath(), cdURI.isCollection(),
cdURI.getUri(), debug);
//this.cdURI = cdURI;
this.sysi = sysi;
+
+ rootNode = (uri != null) && uri.equals("/");
}
- CaldavBwNode(boolean collection, SysIntf sysi, String uri, boolean debug) {
+ CaldavBwNode(final boolean collection, final SysIntf sysi, final String uri, final boolean debug) {
super(sysi.getUrlHandler(), null, collection, uri, debug);
//this.cdURI = cdURI;
this.sysi = sysi;
+
+ rootNode = (uri != null) && uri.equals("/");
}
/* ====================================================================
* Public methods
* ==================================================================== */
- public WdCollection getCollection(boolean deref) throws WebdavException {
+ @Override
+ public WdCollection getCollection(final boolean deref) throws WebdavException {
if (!deref) {
return col;
}
@@ -128,6 +173,7 @@
* @return Collection of QName
* @throws WebdavException
*/
+ @Override
public Collection<QName> getSupportedReports() throws WebdavException {
Collection<QName> res = new ArrayList<QName>();
res.addAll(super.getSupportedReports());
@@ -143,6 +189,7 @@
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getContentBinary()
*/
+ @Override
public boolean getContentBinary() throws WebdavException {
return false;
}
@@ -150,6 +197,7 @@
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getChildren()
*/
+ @Override
public Collection<? extends WdEntity> getChildren() throws WebdavException {
return null;
}
@@ -161,7 +209,8 @@
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#knownProperty(edu.rpi.sss.util.xml.QName)
*/
- public boolean knownProperty(QName tag) {
+ @Override
+ public boolean knownProperty(final QName tag) {
if (propertyNames.get(tag) != null) {
return true;
}
@@ -173,9 +222,10 @@
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#generatePropertyValue(edu.rpi.sss.util.xml.QName, edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf, boolean)
*/
- public boolean generatePropertyValue(QName tag,
- WebdavNsIntf intf,
- boolean allProp) throws WebdavException {
+ @Override
+ public boolean generatePropertyValue(final QName tag,
+ final WebdavNsIntf intf,
+ final boolean allProp) throws WebdavException {
try {
// Not known - try higher
return super.generatePropertyValue(tag, intf, allProp);
@@ -186,12 +236,185 @@
}
}
+ /**
+ * @param name
+ * @param intf
+ * @param allProp
+ * @return true if proeprty emiited
+ * @throws WebdavException
+ */
+ public boolean generateXrdValue(final String name,
+ final WebdavNsIntf intf,
+ final boolean allProp) throws WebdavException {
+ XmlEmit xml = intf.getXmlEmit();
+
+ try {
+ if (name.equals(CalWSXrdDefs.created)) {
+ String val = getCreDate();
+ if (val == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, val);
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.displayname)) {
+ String val = getDisplayname();
+ if (val == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, val);
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.lastModified)) {
+ String val = getLastmodDate();
+ if (val == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, val);
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.owner)) {
+ String href = intf.makeUserHref(getOwner().getPrincipalRef());
+ if (!href.endsWith("/")) {
+ href += "/";
+ }
+ xrdProperty(xml, name, href);
+
+ return true;
+ }
+
+ return false;
+ } catch (WebdavException wde) {
+ throw wde;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
/* ====================================================================
+ * Protected methods
+ * ==================================================================== */
+
+ /** Return a set of PropertyTagEntry defining properties this node supports.
+ *
+ * @return Collection of PropertyTagEntry
+ * @throws WebdavException
+ */
+ public Collection<PropertyTagXrdEntry> getXrdNames() throws WebdavException {
+ return xrdNames.values();
+ }
+
+ protected void xrdProperty(final XmlEmit xml, final String name,
+ final String val) throws WebdavException {
+ try {
+ xml.openTagNoNewline(XrdTags.property, "type", name);
+ xml.value(val);
+ xml.closeTagNoblanks(XrdTags.property);
+ } catch (IOException ioe) {
+ throw new WebdavException(ioe);
+ }
+ }
+
+ protected void xrdEmptyProperty(final XmlEmit xml,
+ final String name) throws WebdavException {
+ try {
+ xml.startTag(XrdTags.property);
+ xml.attribute("type", name);
+ xml.attribute(XsiTags.nil, "true");
+ xml.endEmptyTag();
+ xml.newline();
+ } catch (IOException ioe) {
+ throw new WebdavException(ioe);
+ }
+ }
+
+ /**
+ * @return formatted url value for the node
+ * @throws WebdavException
+ */
+ public String getUrlValue() throws WebdavException {
+ return getUrlValue(uri, exists);
+ }
+
+ /**
+ * @param uri
+ * @param exists - true if we KNOW it exists
+ * @return formatted url value
+ * @throws WebdavException
+ */
+ public String getUrlValue(final String uri,
+ final boolean exists) throws WebdavException {
+ try {
+ String prefixed = urlHandler.prefix(uri);
+
+ if (exists) {
+ if (prefixed.endsWith("/")) {
+ if (!trailSlash()) {
+ prefixed = prefixed.substring(0, prefixed.length() - 1);
+ }
+ } else {
+ if (trailSlash()) {
+ prefixed = prefixed + "/";
+ }
+ }
+ }
+
+ return prefixed;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
+ protected static void addPropEntry(final HashMap<QName, PropertyTagEntry> propertyNames,
+ final HashMap<String, PropertyTagXrdEntry> xrdNames,
+ final QName tag,
+ final String xrdName) {
+ PropertyTagXrdEntry pte = new PropertyTagXrdEntry(tag, xrdName, false,
+ false);
+ propertyNames.put(tag, pte);
+ xrdNames.put(xrdName, pte);
+ }
+
+ protected static void addPropEntry(final HashMap<QName, PropertyTagEntry> propertyNames,
+ final HashMap<String, PropertyTagXrdEntry> xrdNames,
+ final QName tag,
+ final String xrdName,
+ final boolean inAllProp) {
+ PropertyTagXrdEntry pte = new PropertyTagXrdEntry(tag, xrdName, inAllProp,
+ false);
+ propertyNames.put(tag, pte);
+ xrdNames.put(xrdName, pte);
+ }
+
+ protected static void addXrdEntry(final HashMap<String, PropertyTagXrdEntry> xrdNames,
+ final String xrdName) {
+ PropertyTagXrdEntry pte = new PropertyTagXrdEntry(null, xrdName, false,
+ false);
+ xrdNames.put(xrdName, pte);
+ }
+
+ protected static void addXrdEntry(final HashMap<String, PropertyTagXrdEntry> xrdNames,
+ final String xrdName,
+ final boolean inAllProp,
+ final boolean inLink) {
+ PropertyTagXrdEntry pte = new PropertyTagXrdEntry(null, xrdName,
+ inAllProp, inLink);
+ xrdNames.put(xrdName, pte);
+ }
+
+ /* ====================================================================
* Object methods
* ==================================================================== */
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer(this.getClass().getName());
+ StringBuilder sb = new StringBuilder(this.getClass().getName());
sb.append("{");
sb.append("path=");
Modified: trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -42,6 +42,7 @@
import edu.rpi.sss.util.xml.XmlUtil;
import edu.rpi.sss.util.xml.tagdefs.AppleIcalTags;
import edu.rpi.sss.util.xml.tagdefs.AppleServerTags;
+import edu.rpi.sss.util.xml.tagdefs.CalWSXrdDefs;
import edu.rpi.sss.util.xml.tagdefs.CaldavTags;
import edu.rpi.sss.util.xml.tagdefs.WebdavTags;
@@ -72,6 +73,9 @@
private final static HashMap<QName, PropertyTagEntry> propertyNames =
new HashMap<QName, PropertyTagEntry>();
+ private final static HashMap<String, PropertyTagXrdEntry> xrdNames =
+ new HashMap<String, PropertyTagXrdEntry>();
+
static {
addPropEntry(propertyNames, CaldavTags.calendarDescription);
addPropEntry(propertyNames, CaldavTags.calendarFreeBusySet);
@@ -87,6 +91,17 @@
addPropEntry(propertyNames, CaldavTags.supportedCalendarData);
addPropEntry(propertyNames, AppleServerTags.getctag);
addPropEntry(propertyNames, AppleIcalTags.calendarColor);
+
+ //addXrdEntry(xrdNames, CalWSXrdDefs.calendarCollection, true);
+ addXrdEntry(xrdNames, CalWSXrdDefs.collection, true, true); // for all resource types
+ addXrdEntry(xrdNames, CalWSXrdDefs.description, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.maxAttendeesPerInstance, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.maxDateTime, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.maxInstances, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.maxResourceSize, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.minDateTime, true, false);
+ addXrdEntry(xrdNames, CalWSXrdDefs.principalHome, true, true);
+ addXrdEntry(xrdNames, CalWSXrdDefs.timezone, true, false);
}
/** Place holder for status
@@ -96,7 +111,8 @@
* @param uri
* @param debug
*/
- public CaldavCalNode(final SysIntf sysi, final int status, final String uri, final boolean debug) {
+ public CaldavCalNode(final SysIntf sysi, final int status,
+ final String uri, final boolean debug) {
super(true, sysi, uri, debug);
setStatus(status);
}
@@ -821,10 +837,169 @@
}
}
- /** Return a set of PropertyTagEntry defining properties this node supports.
- *
- * @return Collection of PropertyTagEntry
- * @throws WebdavException
+ @Override
+ public boolean generateXrdValue(final String name,
+ final WebdavNsIntf intf,
+ final boolean allProp) throws WebdavException {
+ XmlEmit xml = intf.getXmlEmit();
+
+ try {
+ int calType;
+ CalDAVCollection c = (CalDAVCollection)getCollection(true); // deref this
+ if (c == null) {
+ // Probably no access -- fake it up as a collection
+ calType = CalDAVCollection.calTypeCollection;
+ } else {
+ calType = c.getCalType();
+ }
+
+ if (name.equals(CalWSXrdDefs.collection)) {
+ xrdEmptyProperty(xml, name);
+
+ //boolean isCollection = cal.getCalendarCollection();
+
+ if (calType == CalDAVCollection.calTypeInbox) {
+ xrdEmptyProperty(xml, CalWSXrdDefs.inbox);
+ } else if (calType == CalDAVCollection.calTypeOutbox) {
+ xrdEmptyProperty(xml, CalWSXrdDefs.outbox);
+ } else if (calType == CalDAVCollection.calTypeCalendarCollection) {
+ xrdEmptyProperty(xml, CalWSXrdDefs.calendarCollection);
+ }
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.description)) {
+ String s = col.getDescription();
+
+ if (s == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, s);
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.principalHome)) {
+ if (!rootNode || intf.getAnonymous()) {
+ return true;
+ }
+
+ SysIntf si = getSysi();
+ CalPrincipalInfo cinfo = si.getCalPrincipalInfo(si.getPrincipal());
+ if (cinfo.userHomePath == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, getUrlValue(cinfo.userHomePath, true));
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.maxAttendeesPerInstance)) {
+ if (!rootNode) {
+ return true;
+ }
+
+ Integer val = getSysi().getSystemProperties().getMaxAttendeesPerInstance();
+
+ if (val == null) {
+ return true;
+ }
+
+ xrdProperty(xml, name, String.valueOf(val));
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.maxDateTime)) {
+ if (!rootNode) {
+ return true;
+ }
+
+ Integer val = getSysi().getSystemProperties().getMaxAttendeesPerInstance();
+
+ if (val == null) {
+ return false;
+ }
+
+ xrdProperty(xml, name, String.valueOf(val));
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.maxInstances)) {
+ if (!rootNode) {
+ return true;
+ }
+
+ Integer val = getSysi().getSystemProperties().getMaxInstances();
+
+ if (val == null) {
+ return false;
+ }
+
+ xrdProperty(xml, name, String.valueOf(val));
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.maxResourceSize)) {
+ if (!rootNode) {
+ return true;
+ }
+
+ Integer val = getSysi().getSystemProperties().getMaxUserEntitySize();
+
+ if (val == null) {
+ return false;
+ }
+
+ xrdProperty(xml, name, String.valueOf(val));
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.minDateTime)) {
+ if (!rootNode) {
+ return true;
+ }
+
+ String val = getSysi().getSystemProperties().getMinDateTime();
+
+ if (val == null) {
+ return false;
+ }
+
+ xrdProperty(xml, name, val);
+
+ return true;
+ }
+
+ if (name.equals(CalWSXrdDefs.timezone)) {
+ String tzid = col.getTimezone();
+
+ if (tzid == null) {
+ return false;
+ }
+
+ xrdProperty(xml, name, tzid);
+
+ return true;
+ }
+
+ // Not known - try higher
+ return super.generateXrdValue(name, intf, allProp);
+ } catch (WebdavException wde) {
+ throw wde;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getPropertyNames()
*/
@Override
public Collection<PropertyTagEntry> getPropertyNames()throws WebdavException {
@@ -837,6 +1012,19 @@
}
/* (non-Javadoc)
+ * @see org.bedework.caldav.server.CaldavBwNode#getXrdNames()
+ */
+ @Override
+ public Collection<PropertyTagXrdEntry> getXrdNames()throws WebdavException {
+ Collection<PropertyTagXrdEntry> res = new ArrayList<PropertyTagXrdEntry>();
+
+ res.addAll(super.getXrdNames());
+ res.addAll(xrdNames.values());
+
+ return res;
+ }
+
+ /* (non-Javadoc)
* @see org.bedework.caldav.server.CaldavBwNode#getSupportedReports()
*/
@Override
Modified: trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -44,6 +44,7 @@
import edu.rpi.cct.webdav.servlet.shared.WebdavNsNode;
import edu.rpi.cct.webdav.servlet.shared.WebdavProperty;
import edu.rpi.cct.webdav.servlet.shared.WebdavStatusCode;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf.Content;
import edu.rpi.sss.util.Util;
import edu.rpi.sss.util.xml.XmlUtil;
import edu.rpi.sss.util.xml.tagdefs.CaldavTags;
@@ -589,20 +590,21 @@
/** Get the content now to set up length, type etc.
*/
- Reader in = getNsIntf().getContent(req, resp, node);
- resp.setContentLength((int)node.getContentLen());
- if (in == null) {
+ Content c = getNsIntf().getContent(req, resp, node);
+ if ((c == null) || (c.rdr == null)) {
if (debug) {
debugMsg("status: " + HttpServletResponse.SC_NO_CONTENT);
}
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
} else {
+ resp.setContentType(c.contentType);
+ resp.setContentLength((int)c.contentLength);
if (debug) {
- debugMsg("send content - length=" + node.getContentLen());
+ debugMsg("send content - length=" + c.contentLength);
}
- writeContent(in, out);
+ writeContent(c.rdr, out);
}
}
Added: trunk/server/war/WEB-INF/publicws-web.xml
===================================================================
--- trunk/server/war/WEB-INF/publicws-web.xml (rev 0)
+++ trunk/server/war/WEB-INF/publicws-web.xml 2010-09-03 20:15:01 UTC (rev 456)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <display-name>Bedework public caldav</display-name>
+
+ <context-param>
+ <param-name>bwappname</param-name>
+ <param-value>@BW-APP-NAME@</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>edu.rpi.sss.util.jsp.SessionListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>action</servlet-name>
+ <servlet-class>
+ org.bedework.caldav.server.CaldavBWServlet
+ </servlet-class>
+ <init-param>
+ <param-name>application</param-name>
+ <param-value>servlet</param-value>
+ </init-param>
+ <init-param>
+ <param-name>calws</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>dumpContent</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>debug</param-name>
+ <param-value>@RPI-DEBUG@</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>action</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>1</session-timeout>
+ </session-config>
+
+ <!-- JDBC DataSources (java:comp/env/jdbc) -->
+ <resource-ref>
+ <description>The calendar DS</description>
+ <res-ref-name>jdbc/calDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <!-- JMS DataSources (java:comp/env/jms) -->
+ <resource-ref>
+ <res-ref-name>jms/BedeworkConnectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <!-- Insert ejb-ref here -->
+</web-app>
Added: trunk/server/war/WEB-INF/userws-web.xml
===================================================================
--- trunk/server/war/WEB-INF/userws-web.xml (rev 0)
+++ trunk/server/war/WEB-INF/userws-web.xml 2010-09-03 20:15:01 UTC (rev 456)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <display-name>Bedework user caldav</display-name>
+
+ <context-param>
+ <param-name>bwappname</param-name>
+ <param-value>@BW-APP-NAME@</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>edu.rpi.sss.util.jsp.SessionListener</listener-class>
+ </listener>
+
+ <!-- Need this to fush a static table maintained by the servlet -->
+ <listener>
+ <listener-class>org.bedework.caldav.server.CaldavBWServlet</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>action</servlet-name>
+ <servlet-class>
+ org.bedework.caldav.server.CaldavBWServlet
+ </servlet-class>
+ <init-param>
+ <param-name>application</param-name>
+ <param-value>servlet</param-value>
+ </init-param>
+ <init-param>
+ <param-name>calws</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>dumpContent</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>debug</param-name>
+ <param-value>@RPI-DEBUG@</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>action</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+ <session-config>
+ <session-timeout>1</session-timeout>
+ </session-config>
+
+ <!-- JDBC DataSources (java:comp/env/jdbc) -->
+ <resource-ref>
+ <description>The calendar DS</description>
+ <res-ref-name>jdbc/calDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <!-- JMS DataSources (java:comp/env/jms) -->
+ <resource-ref>
+ <res-ref-name>jms/BedeworkConnectionFactory</res-ref-name>
+ <res-type>javax.jms.ConnectionFactory</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+ <!-- The role name of * below means all roles defined in this web.xml -->
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Bedework</web-resource-name>
+ <description>Bedework user</description>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <description>no description</description>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>@SECURITY-DOMAIN@</realm-name>
+ </login-config>
+
+ <security-role>
+ <description>A calendar system user</description>
+ <role-name>@SECURITY-PREFIX at .user</role-name>
+ </security-role>
+
+ <!-- Insert ejb-ref here -->
+</web-app>
Modified: trunk/util/src/org/bedework/caldav/util/CalDAVConfig.java
===================================================================
--- trunk/util/src/org/bedework/caldav/util/CalDAVConfig.java 2010-08-30 14:20:44 UTC (rev 455)
+++ trunk/util/src/org/bedework/caldav/util/CalDAVConfig.java 2010-09-03 20:15:01 UTC (rev 456)
@@ -51,6 +51,9 @@
/* Web calendar service uri - null for no web calendar service */
private String webcalServiceURI;
+ /* Set at server init */
+ private boolean calWS;
+
/**
* @param val
*/
@@ -158,4 +161,19 @@
public String getWebcalServiceURI() {
return webcalServiceURI;
}
+
+ /** True for a web service - set by server..
+ *
+ * @param val
+ */
+ public void setCalWS(final boolean val) {
+ calWS = val;
+ }
+
+ /**
+ * @return boolean
+ */
+ public boolean getCalWS() {
+ return calWS;
+ }
}
More information about the Bedework-commit
mailing list