[Bedework-commit] caldav r324 - in
trunk/server/src/org/bedework/caldav/server: . filter
svnadmin at bedework.org
svnadmin at bedework.org
Tue Feb 10 16:51:31 EST 2009
Author: douglm
Date: 2009-02-10 16:51:30 -0500 (Tue, 10 Feb 2009)
New Revision: 324
Modified:
trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.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/CaldavComponentNode.java
trunk/server/src/org/bedework/caldav/server/CaldavResourceNode.java
trunk/server/src/org/bedework/caldav/server/PostMethod.java
trunk/server/src/org/bedework/caldav/server/filter/Filter.java
Log:
Allow carddav to be built from the bw script
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -322,7 +322,7 @@
if (comp.getEventInfo() != null) {
ent = comp.getEventInfo().getEvent();
} else {
- ent = comp.getCalendar();
+ ent = comp.getCollection(true); // deref - we're trying to put into the target
access = PrivilegeDefs.privBind;
}
} else {
@@ -474,7 +474,7 @@
CaldavCalNode cnode = (CaldavCalNode)bwnode;
- BwCalendar cal = cnode.getCalendar();
+ BwCalendar cal = cnode.getCollection(false); // Don't deref for delete
sysi.deleteCalendar(cal);
}
@@ -504,8 +504,14 @@
}
Collection children = wdnode.getChildren();
+
+ if (children == null) {
+ // Perhaps no access
+ return al;
+ }
+
String uri = wdnode.getUri();
- BwCalendar parent = wdnode.getCalendar();
+ BwCalendar parent = wdnode.getCollection(true); // deref
Iterator it = children.iterator();
@@ -709,7 +715,7 @@
}
CaldavComponentNode bwnode = (CaldavComponentNode)getBwnode(node);
- BwCalendar cal = bwnode.getCalendar();
+ BwCalendar cal = bwnode.getCollection(true); // deref - put into target
boolean calContent = false;
if ((contentTypePars != null) && contentTypePars.length > 0) {
@@ -771,9 +777,9 @@
}
CaldavResourceNode bwnode = (CaldavResourceNode)getBwnode(node);
- BwCalendar cal = bwnode.getCalendar();
+ BwCalendar cal = bwnode.getCollection(true);
- if (cal.getCalendarCollection()) {
+ if ((cal == null) || cal.getCalendarCollection()) {
throw new WebdavException(HttpServletResponse.SC_PRECONDITION_FAILED);
}
@@ -860,7 +866,7 @@
String ifEtag) throws WebdavException {
BwEvent ev = evinfo.getEvent();
String entityName = bwnode.getEntityName();
- BwCalendar cal = bwnode.getCalendar();
+ BwCalendar cal = bwnode.getCollection(true); // deref
boolean created = false;
if (debug) {
@@ -963,7 +969,8 @@
* A namepart of null means that the path already exists
*/
- BwCalendar newCal = bwnode.getCalendar();
+ BwCalendar newCal = bwnode.getCollection(false); // No deref?
+
BwCalendar parent = newCal.getCalendar();
if (parent.getCalendarCollection()) {
throw new WebdavForbidden(CaldavTags.calendarCollectionLocationOk);
@@ -1041,9 +1048,19 @@
return;
}
- BwCalendar fromCal = fromCalNode.getCalendar();
- BwCalendar toCal = toCalNode.getCalendar();
+ /* XXX This is NOT rename - we really move or copy.
+ * For the moment we'll deref both - but I think there are alias issues here
+ */
+ BwCalendar fromCal = fromCalNode.getCollection(true);
+ BwCalendar toCal = toCalNode.getCollection(true);
+ if ((fromCal == null) || (toCal == null)) {
+ // What do we do here?
+ resp.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED);
+
+ return;
+ }
+
getSysi().copyMove(fromCal, toCal, copy, overwrite);
if (toCalNode.getExists()) {
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
@@ -1071,8 +1088,10 @@
}
EventInfo fromEi = from.getEventInfo();
- BwCalendar toCal = toNode.getCalendar();
+ /* deref - copy/move into targetted collection */
+ BwCalendar toCal = toNode.getCollection(true);
+
if (!getSysi().copyMove(fromEi,
toCal, toNode.getEntityName(), copy,
overwrite)) {
@@ -1389,7 +1408,8 @@
try {
// May need a real principal hierarchy
if (node instanceof CaldavCalNode) {
- sysi.updateAccess(((CaldavCalNode)node).getCalendar(), info.acl);
+ // XXX to dref or not deref?
+ sysi.updateAccess(((CaldavCalNode)node).getCollection(true), info.acl);
} else if (node instanceof CaldavComponentNode) {
sysi.updateAccess(((CaldavComponentNode)node).getEventInfo().getEvent(),
info.acl);
@@ -1621,6 +1641,11 @@
*/
Collection<WebdavNsNode> evnodes = new ArrayList<WebdavNsNode>();
+
+ if (events == null) {
+ return evnodes;
+ }
+
//HashMap evnodeMap = new HashMap();
try {
@@ -1692,7 +1717,15 @@
FreeBusyQuery freeBusy,
int depth) throws WebdavException {
try {
- BwEvent fb = freeBusy.getFreeBusy(sysi, cnode.getCalendar(),
+ /* We need to deref as the freebusy comes from the target */
+ BwCalendar c = cnode.getCollection(true);
+
+ if (c == null) {
+ // XXX - exception?
+ return;
+ }
+
+ BwEvent fb = freeBusy.getFreeBusy(sysi, c,
cnode.getOwner().getAccount(),
depth);
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBwNode.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -45,6 +45,8 @@
public abstract class CaldavBwNode extends WebdavNsNode {
// protected CaldavURI cdURI;
+ protected BwCalendar cal;
+
private final static HashMap<QName, PropertyTagEntry> propertyNames =
new HashMap<QName, PropertyTagEntry>();
@@ -77,18 +79,52 @@
* Public methods
* ==================================================================== */
- /**
- * @return BwCalendar containing or represented by this entity
+ /** The node may refer to a collection object which may in fact be an alias to
+ * another. For deletions we want to remove the alias itself.
+ *
+ * <p>Move and rename are also targetted at the alias.
+ *
+ * <p>Other operations are probably intended to work on the underlying target
+ * of the alias.
+ *
+ * @param deref true if we want to act upon the target of an alias.
+ * @return Collection this node represents
* @throws WebdavException
*/
- public abstract BwCalendar getCalendar() throws WebdavException ;
+ public BwCalendar getCollection(boolean deref) throws WebdavException {
+ if (!deref) {
+ return cal;
+ }
+ BwCalendar curCal = cal;
+
+ if ((curCal != null) &&
+ (curCal.getCalType() == BwCalendar.calTypeAlias)) {
+ curCal = cal.getAliasTarget();
+ if (curCal == null) {
+ getSysi().resolveAlias(cal);
+ curCal = cal.getAliasTarget();
+ }
+ }
+
+ return curCal;
+ }
+
/**
* @return boolean if this is a calendar
* @throws WebdavException
*/
public boolean isCalendarCollection() throws WebdavException {
- return (isCollection() && getCalendar().getCalendarCollection());
+ if (!isCollection()) {
+ return false;
+ }
+
+ BwCalendar c = getCollection(true);
+ if (c == null) {
+ return false;
+ }
+
+ return c.getCalendarCollection();
}
/** Return a collection of children objects. These will all be calendar
Modified: trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -1,31 +1,3 @@
-/*
- Copyright (c) 2000-2005 University of Washington. All rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
-
- The above copyright notice and this permission notice appear in
- all copies and supporting documentation;
-
- The name, identifiers, and trademarks of the University of Washington
- are not used in advertising or publicity without the express prior
- written permission of the University of Washington;
-
- Recipients acknowledge that this distribution is made available as a
- research courtesy, "as is", potentially with defects, without
- any obligation on the part of the University of Washington to
- provide support, services, or repair;
-
- THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR
- IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING
- NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
/* **********************************************************************
Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
@@ -100,8 +72,6 @@
public class CaldavCalNode extends CaldavBwNode {
private Calendar ical;
- private BwCalendar cal;
-
private BwUser owner;
private String vfreeBusyString;
@@ -155,24 +125,6 @@
exists = cdURI.getExists();
}
- /**
- * @return BwCalendar this node represents
- */
- public BwCalendar getCalendar() throws WebdavException {
- BwCalendar curCal = cal;
-
- if ((curCal != null) &&
- (curCal.getCalType() == BwCalendar.calTypeAlias)) {
- curCal = cal.getAliasTarget();
- if (curCal == null) {
- getSysi().resolveAlias(cal);
- curCal = cal.getAliasTarget();
- }
- }
-
- return curCal;
- }
-
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getOwner()
*/
@@ -198,8 +150,12 @@
}
}
+ /* (non-Javadoc)
+ * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getEtagValue(boolean)
+ */
public String getEtagValue(boolean strong) throws WebdavException {
- BwCalendar c = getCalendar(); // Unalias
+ /* We need the etag of the target if this is an alias */
+ BwCalendar c = getCollection(true); // deref
if (c == null) {
return null;
@@ -219,7 +175,8 @@
* @throws WebdavException
*/
public boolean getSchedulingAllowed() throws WebdavException {
- BwCalendar c = getCalendar(); // Unalias
+ /* It's the alias target that matters */
+ BwCalendar c = getCollection(true); // deref
if (c == null) {
return false;
@@ -250,7 +207,7 @@
return;
}
- BwCalendar c = getCalendar(); // Unalias
+ BwCalendar c = getCollection(false); // Don't deref
c.setCalType(BwCalendar.calTypeCollection);
}
@@ -262,8 +219,12 @@
*/
try {
- BwCalendar c = getCalendar(); // Unalias
+ BwCalendar c = getCollection(true); // deref
+ if (c == null) { // no access?
+ return null;
+ }
+
if (!c.getCollectionInfo().entitiesAllowed) {
if (debug) {
debugMsg("POSSIBLE SEARCH: getChildren for cal " + c.getPath());
@@ -411,7 +372,7 @@
return currentAccess;
}
- BwCalendar c = getCalendar(); // Unalias
+ BwCalendar c = getCollection(true); // We want access of underlying object?
if (c == null) {
return null;
@@ -585,7 +546,12 @@
XmlEmit xml = intf.getXmlEmit();
try {
- BwCalendar c = getCalendar(); // Unalias
+ BwCalendar c = getCollection(true); // deref this
+ if (c == null) {
+ // Probably no access
+ return false;
+ }
+
int calType = c.getCalType();
if (tag.equals(WebdavTags.resourcetype)) {
@@ -760,15 +726,17 @@
return res;
}
- /** Return a set of Qname defining reports this node supports.
- *
- * @return Collection of QName
- * @throws WebdavException
+ /* (non-Javadoc)
+ * @see org.bedework.caldav.server.CaldavBwNode#getSupportedReports()
*/
public Collection<QName> getSupportedReports() throws WebdavException {
Collection<QName> res = new ArrayList<QName>();
- BwCalendar c = getCalendar(); // Unalias
+ BwCalendar c = getCollection(true); // deref
+ if (c == null) {
+ return res;
+ }
+
res.addAll(super.getSupportedReports());
/* Cannot do free-busy on in and outbox */
Modified: trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -1,33 +1,5 @@
-/*
- Copyright (c) 2000-2005 University of Washington. All rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
-
- The above copyright notice and this permission notice appear in
- all copies and supporting documentation;
-
- The name, identifiers, and trademarks of the University of Washington
- are not used in advertising or publicity without the express prior
- written permission of the University of Washington;
-
- Recipients acknowledge that this distribution is made available as a
- research courtesy, "as is", potentially with defects, without
- any obligation on the part of the University of Washington to
- provide support, services, or repair;
-
- THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR
- IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING
- NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
/* **********************************************************************
- Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+ Copyright 2009 Rensselaer Polytechnic Institute. All worldwide rights reserved.
Redistribution and use of this distribution in source and binary forms,
with or without modification, are permitted provided that:
@@ -51,11 +23,9 @@
special, consequential, or incidental damages related to the software,
to the maximum extent the law permits.
*/
-
package org.bedework.caldav.server;
import org.bedework.caldav.server.calquery.CalendarData;
-import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.BwEvent;
import org.bedework.calfacade.BwUser;
import org.bedework.calfacade.svc.EventInfo;
@@ -104,8 +74,6 @@
private Calendar ical;
- private BwCalendar cal;
-
/** The event Component object
*/
private Component comp;
@@ -221,24 +189,6 @@
}
}
- /**
- * @return BwCalendar containing this entity
- */
- public BwCalendar getCalendar() throws WebdavException {
- BwCalendar curCal = cal;
-
- if ((curCal != null) &&
- (curCal.getCalType() == BwCalendar.calTypeAlias)) {
- curCal = cal.getAliasTarget();
- if (curCal == null) {
- getSysi().resolveAlias(cal);
- curCal = cal.getAliasTarget();
- }
- }
-
- return curCal;
- }
-
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getOwner()
*/
Modified: trunk/server/src/org/bedework/caldav/server/CaldavResourceNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavResourceNode.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/CaldavResourceNode.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -1,33 +1,5 @@
-/*
- Copyright (c) 2000-2005 University of Washington. All rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
-
- The above copyright notice and this permission notice appear in
- all copies and supporting documentation;
-
- The name, identifiers, and trademarks of the University of Washington
- are not used in advertising or publicity without the express prior
- written permission of the University of Washington;
-
- Recipients acknowledge that this distribution is made available as a
- research courtesy, "as is", potentially with defects, without
- any obligation on the part of the University of Washington to
- provide support, services, or repair;
-
- THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR
- IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
- WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING
- NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
/* **********************************************************************
- Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+ Copyright 2009 Rensselaer Polytechnic Institute. All worldwide rights reserved.
Redistribution and use of this distribution in source and binary forms,
with or without modification, are permitted provided that:
@@ -51,10 +23,8 @@
special, consequential, or incidental damages related to the software,
to the maximum extent the law permits.
*/
-
package org.bedework.caldav.server;
-import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.BwResource;
import org.bedework.calfacade.BwUser;
@@ -75,8 +45,6 @@
public class CaldavResourceNode extends CaldavBwNode {
private BwResource resource;
- private BwCalendar cal;
-
private BwUser owner;
private String entityName;
@@ -138,24 +106,6 @@
}
}
- /**
- * @return BwCalendar containing this entity
- */
- public BwCalendar getCalendar() throws WebdavException {
- BwCalendar curCal = cal;
-
- if ((curCal != null) &&
- (curCal.getCalType() == BwCalendar.calTypeAlias)) {
- curCal = cal.getAliasTarget();
- if (curCal == null) {
- getSysi().resolveAlias(cal);
- curCal = cal.getAliasTarget();
- }
- }
-
- return curCal;
- }
-
/* (non-Javadoc)
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getOwner()
*/
Modified: trunk/server/src/org/bedework/caldav/server/PostMethod.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/PostMethod.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/PostMethod.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -259,8 +259,10 @@
/* (CALDAV:supported-collection) */
CaldavCalNode calnode = intf.getCalnode(node,
HttpServletResponse.SC_FORBIDDEN);
- pars.cal = calnode.getCalendar();
+ /* Don't deref - this should be targetted at a real outbox */
+ pars.cal = calnode.getCollection(false);
+
if (pars.cal.getCalType() != BwCalendar.calTypeOutbox) {
if (debug) {
debugMsg("Not targetted at Outbox");
Modified: trunk/server/src/org/bedework/caldav/server/filter/Filter.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/filter/Filter.java 2009-01-27 19:07:50 UTC (rev 323)
+++ trunk/server/src/org/bedework/caldav/server/filter/Filter.java 2009-02-10 21:51:30 UTC (rev 324)
@@ -27,6 +27,7 @@
import org.bedework.caldav.server.CaldavBwNode;
import org.bedework.caldav.server.CaldavComponentNode;
+import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.CalFacadeDefs;
import org.bedework.calfacade.RecurringRetrievalMode;
import org.bedework.calfacade.exc.CalFacadeException;
@@ -187,7 +188,12 @@
Collection<EventInfo> events;
- events = wdnode.getSysi().getEvents(wdnode.getCalendar(),
+ BwCalendar c = wdnode.getCollection(true);
+ if (c == null) {
+ return null;
+ }
+
+ events = wdnode.getSysi().getEvents(c,
eventq.filter, retrieveRecur);
if (debug) {
More information about the Bedework-commit
mailing list