[Bedework-commit] caldav r162 - in trunk:
boeingexchange/src/edu/rpi/cct/bedework/caldav
bwcaldav/src/org/bedework/caldav/bwserver
domino/src/edu/rpi/cct/bedework/caldav
google/src/edu/rpi/cct/bedework/caldav
server/src/org/bedework/caldav/server
svnadmin at bedework.org
svnadmin at bedework.org
Mon May 14 15:47:53 EDT 2007
Author: douglm
Date: 2007-05-14 15:47:52 -0400 (Mon, 14 May 2007)
New Revision: 162
Modified:
trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/BexchangeSysIntfImpl.java
trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java
trunk/domino/src/edu/rpi/cct/bedework/caldav/DominoSysIntfImpl.java
trunk/google/src/edu/rpi/cct/bedework/caldav/GoogleSysIntfImpl.java
trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.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/CaldavPrincipalNode.java
trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java
trunk/server/src/org/bedework/caldav/server/CaldavUserNode.java
trunk/server/src/org/bedework/caldav/server/EmitAccess.java
trunk/server/src/org/bedework/caldav/server/SysIntf.java
Log:
Mostly caldav related code:
Move much of the code related to mapping principal hierarchies to directory information into the directory interface.
AbstractDirImpl is an abstract implementation of the Directories interface and handles much of the mapping.
Moved definition of principal hierarchy roots out of the system information into the directory configuration.
Also added values to identify more types of account, e.g. resources, locations, tickets.
Some changes to property handling in caldav
Modified: trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/BexchangeSysIntfImpl.java
===================================================================
--- trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/BexchangeSysIntfImpl.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/boeingexchange/src/edu/rpi/cct/bedework/caldav/BexchangeSysIntfImpl.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -79,6 +79,9 @@
import edu.rpi.cct.webdav.servlet.shared.PrincipalPropertySearch;
import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNotFound;
+import edu.rpi.cmt.access.Ace;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import net.fortuna.ical4j.model.Calendar;
@@ -94,6 +97,7 @@
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -118,6 +122,9 @@
// XXX get from properties
private static String defaultTimezone = "America/Los_Angeles";
+ private static HashMap<String, Integer> toWho = new HashMap<String, Integer>();
+ private static HashMap<Integer, String> fromWho = new HashMap<Integer, String>();
+
/* These could come from a db
*/
private static class BexchangeInfo implements Serializable {
@@ -190,6 +197,13 @@
new BexchangeInfo("fbtester2 at calnet.local",
"207.145.218.101", 80,
"/fbsrv/getfbsrv.asp?email=", false));
+
+ initWhoMaps("/principals/users", Ace.whoTypeUser);
+ initWhoMaps("/principals/groups", Ace.whoTypeGroup);
+ initWhoMaps("/principals/tickets", Ace.whoTypeTicket);
+ initWhoMaps("/principals/resources", Ace.whoTypeResource);
+ initWhoMaps("/principals/venues", Ace.whoTypeVenue);
+ initWhoMaps("/principals/hosts", Ace.whoTypeHost);
}
private boolean debug;
@@ -220,38 +234,81 @@
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#isPrincipal(java.lang.String)
*/
- public String getPrincipalRoot() {
- return "/principals";
+ public boolean isPrincipal(String val) throws WebdavException {
+ return val.startsWith("/principals");
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getUserPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#getPrincipalInfo(java.lang.String)
*/
- public String getUserPrincipalRoot() {
- return "/principals/users";
+ public PrincipalInfo getPrincipalInfo(String href) throws WebdavException {
+ PrincipalInfo pi = new PrincipalInfo();
+
+ try {
+ String uri = new URI(href).getPath();
+
+ if (!isPrincipal(uri)) {
+ return null;
+ }
+
+ int start;
+
+ int end = uri.length();
+ if (uri.endsWith("/")) {
+ end--;
+ }
+
+ String groupRoot = "/principals/groups";
+ String userRoot = "/principals/users";
+
+ if (uri.startsWith(userRoot)) {
+ start = userRoot.length();
+ pi.prefix = userRoot;
+ pi.whoType = Ace.whoTypeUser;
+ } else if (uri.startsWith(groupRoot)) {
+ start = groupRoot.length();
+ pi.prefix = groupRoot;
+ pi.whoType = Ace.whoTypeGroup;
+ } else {
+ throw new WebdavNotFound(uri);
+ }
+
+ if (start == end) {
+ // Trying to browse user principals?
+ pi.who = null;
+ } else if (uri.charAt(start) != '/') {
+ throw new WebdavNotFound(uri);
+ } else {
+ pi.who = uri.substring(start + 1, end);
+ }
+
+ return pi;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getGroupPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#makeHref(java.lang.String, boolean)
*/
- public String getGroupPrincipalRoot() {
- return "/principals/groups";
- }
+ public String makeHref(String id, int whoType) throws WebdavException {
+ String root = fromWho.get(whoType);
- /* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeUserHref(java.lang.String)
- */
- public String makeUserHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getUserPrincipalRoot() + "/" + id;
+ if (root == null) {
+ throw new WebdavException("unknown who type " + whoType);
+ }
+
+ return root + "/" + id;
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeGroupHref(java.lang.String)
+ * @see org.bedework.caldav.server.SysIntf#getGroups(java.lang.String, java.lang.String)
*/
- public String makeGroupHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getGroupPrincipalRoot() + "/" + id;
+ public Collection<String>getGroups(String rootUrl,
+ String principalUrl) throws WebdavException {
+ return Collections.emptySet();
}
public boolean getDirectoryBrowsingDisallowed() throws WebdavException {
@@ -274,7 +331,7 @@
*/
public CalUserInfo getCalUserInfo(String account,
boolean getDirInfo) throws WebdavException {
- return new CalUserInfo(account, null, null, null, null, null);
+ return new CalUserInfo(account, "/principals/users", null, null, null, null, null);
}
public Collection<String> getPrincipalCollectionSet(String resourceUri)
@@ -862,6 +919,11 @@
return cio;
}
+ private static void initWhoMaps(String prefix, int whoType) {
+ toWho.put(prefix, whoType);
+ fromWho.put(whoType, prefix);
+ }
+
/* ====================================================================
* Protected methods
* ==================================================================== */
Modified: trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java
===================================================================
--- trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwSysIntfImpl.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -62,9 +62,11 @@
import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
import edu.rpi.cct.webdav.servlet.shared.WebdavForbidden;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNotFound;
import edu.rpi.cct.webdav.servlet.shared.WebdavProperty;
import edu.rpi.cct.webdav.servlet.shared.WebdavUnauthorized;
import edu.rpi.cmt.access.Ace;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import edu.rpi.sss.util.xml.XmlUtil;
@@ -96,10 +98,6 @@
private String account;
- //private String principalCollectionSetUri;
- private String userPrincipalCollectionSetUri;
- private String groupPrincipalCollectionSetUri;
-
/* These two set after a call to getSvci()
*/
private IcalTranslator trans;
@@ -129,18 +127,6 @@
sb.append(req.getContextPath());
- String hostPortContext;
-
- hostPortContext = sb.toString();
-
- //BwSystem sys = getSvci().getSyspars();
- //String userRootPath = sys.getUserCalendarRoot();
-
- //principalCollectionSetUri = "/" + userRootPath + "/";
- userPrincipalCollectionSetUri = hostPortContext + getUserPrincipalRoot() +
- "/";
- groupPrincipalCollectionSetUri = hostPortContext + getGroupPrincipalRoot() +
- "/";
urlPrefix = WebdavUtils.getUrlPrefix(req);
} catch (Throwable t) {
throw new WebdavException(t);
@@ -152,74 +138,53 @@
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#isPrincipal(java.lang.String)
*/
- public String getPrincipalRoot() throws WebdavException {
+ public boolean isPrincipal(String val) throws WebdavException {
try {
- return getSvci().getSyspars().getPrincipalRoot();
+ return getSvci().isPrincipal(val);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getUserPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#getPrincipalInfo(java.lang.String)
*/
- public String getUserPrincipalRoot() throws WebdavException {
+ public PrincipalInfo getPrincipalInfo(String href) throws WebdavException {
try {
- return getSvci().getSyspars().getUserPrincipalRoot();
- } catch (Throwable t) {
- throw new WebdavException(t);
+ return getSvci().getDirectories().getPrincipalInfo(href);
+ } catch (CalFacadeException cfe) {
+ if (cfe.getMessage().equals(CalFacadeException.principalNotFound)) {
+ throw new WebdavNotFound(href);
+ }
+ throw new WebdavException(cfe);
}
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getGroupPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#makeHref(java.lang.String, boolean)
*/
- public String getGroupPrincipalRoot() throws WebdavException {
+ public String makeHref(String id, int whoType) throws WebdavException {
try {
- return getSvci().getSyspars().getGroupPrincipalRoot();
+ return getUrlPrefix() + getSvci().getDirectories().makePrincipalUri(id, whoType);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeUserHref(java.lang.String)
+ * @see org.bedework.caldav.server.SysIntf#getGroups(java.lang.String, java.lang.String)
*/
- public String makeUserHref(String id) throws WebdavException {
- StringBuffer sb = new StringBuffer(getUrlPrefix());
-
- String root = getUserPrincipalRoot();
- if (!root.startsWith("/")) {
- sb.append("/");
+ public Collection<String>getGroups(String rootUrl,
+ String principalUrl) throws WebdavException {
+ try {
+ return getSvci().getDirectories().getGroups(rootUrl, principalUrl);
+ } catch (Throwable t) {
+ throw new WebdavException(t);
}
-
- sb.append(root);
- sb.append("/");
- sb.append(id);
-
- return sb.toString();
}
- /* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeGroupHref(java.lang.String)
- */
- public String makeGroupHref(String id) throws WebdavException {
- StringBuffer sb = new StringBuffer(getUrlPrefix());
-
- String root = getGroupPrincipalRoot();
- if (!root.startsWith("/")) {
- sb.append("/");
- }
-
- sb.append(root);
- sb.append("/");
- sb.append(id);
-
- return sb.toString();
- }
-
public boolean getDirectoryBrowsingDisallowed() throws WebdavException {
try {
return getSvci().getSyspars().getDirectoryBrowsingDisallowed();
@@ -233,7 +198,7 @@
*/
public String caladdrToUser(String caladdr) throws WebdavException {
try {
- return getSvci().caladdrToUser(caladdr);
+ return getSvci().getDirectories().caladdrToUser(caladdr);
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
@@ -246,7 +211,7 @@
*/
public String userToCaladdr(String account) throws WebdavException {
try {
- return getSvci().userToCaladdr(account);
+ return getSvci().getDirectories().userToCaladdr(account);
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
@@ -277,7 +242,12 @@
dirInfo = getSvci().getDirInfo(account);
}
+ // XXX Cheat at this - we should just use principals throughout.
+ String principalUri = getSvci().getDirectories().makePrincipalUri(account,
+ Ace.whoTypeUser);
+ String prefix = principalUri.substring(0, principalUri.length() - account.length());
return new CalUserInfo(account,
+ prefix,
userHomePath,
defaultCalendarPath,
inboxPath,
@@ -295,8 +265,7 @@
try {
ArrayList<String> al = new ArrayList<String>();
- al.add(userPrincipalCollectionSetUri);
- al.add(groupPrincipalCollectionSetUri);
+ al.add(getSvci().getDirectories().getPrincipalRoot());
return al;
} catch (Throwable t) {
@@ -319,8 +288,12 @@
resourceUri += "/";
}
- if (!resourceUri.equals(userPrincipalCollectionSetUri)) {
- return principals;
+ try {
+ if (!resourceUri.equals(getSvci().getDirectories().getPrincipalRoot())) {
+ return principals;
+ }
+ } catch (Throwable t) {
+ throw new WebdavException(t);
}
/* If we don't support any of the properties in the searches we don't match
Modified: trunk/domino/src/edu/rpi/cct/bedework/caldav/DominoSysIntfImpl.java
===================================================================
--- trunk/domino/src/edu/rpi/cct/bedework/caldav/DominoSysIntfImpl.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/domino/src/edu/rpi/cct/bedework/caldav/DominoSysIntfImpl.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -80,7 +80,10 @@
import edu.rpi.cct.webdav.servlet.shared.PrincipalPropertySearch;
import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNotFound;
import edu.rpi.cct.webdav.servlet.shared.WebdavServerError;
+import edu.rpi.cmt.access.Ace;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import edu.rpi.sss.util.xml.XmlUtil;
@@ -105,6 +108,7 @@
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -132,6 +136,9 @@
// XXX get from properties
private static String defaultTimezone = "America/Los_Angeles";
+ private static HashMap<String, Integer> toWho = new HashMap<String, Integer>();
+ private static HashMap<Integer, String> fromWho = new HashMap<Integer, String>();
+
/* These could come from a db
*/
private static class DominoInfo implements Serializable {
@@ -188,6 +195,13 @@
static {
serversInfo.put("egenconsulting", egenconsultingInfo);
serversInfo.put("showcase2", showcase2Info);
+
+ initWhoMaps("/principals/users", Ace.whoTypeUser);
+ initWhoMaps("/principals/groups", Ace.whoTypeGroup);
+ initWhoMaps("/principals/tickets", Ace.whoTypeTicket);
+ initWhoMaps("/principals/resources", Ace.whoTypeResource);
+ initWhoMaps("/principals/venues", Ace.whoTypeVenue);
+ initWhoMaps("/principals/hosts", Ace.whoTypeHost);
}
private boolean debug;
@@ -218,38 +232,81 @@
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#isPrincipal(java.lang.String)
*/
- public String getPrincipalRoot() {
- return "/principals";
+ public boolean isPrincipal(String val) throws WebdavException {
+ return val.startsWith("/principals");
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getUserPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#getPrincipalInfo(java.lang.String)
*/
- public String getUserPrincipalRoot() {
- return "/principals/users";
+ public PrincipalInfo getPrincipalInfo(String href) throws WebdavException {
+ PrincipalInfo pi = new PrincipalInfo();
+
+ try {
+ String uri = new URI(href).getPath();
+
+ if (!isPrincipal(uri)) {
+ return null;
+ }
+
+ int start;
+
+ int end = uri.length();
+ if (uri.endsWith("/")) {
+ end--;
+ }
+
+ String groupRoot = "/principals/groups";
+ String userRoot = "/principals/users";
+
+ if (uri.startsWith(userRoot)) {
+ start = userRoot.length();
+ pi.prefix = userRoot;
+ pi.whoType = Ace.whoTypeUser;
+ } else if (uri.startsWith(groupRoot)) {
+ start = groupRoot.length();
+ pi.prefix = groupRoot;
+ pi.whoType = Ace.whoTypeGroup;
+ } else {
+ throw new WebdavNotFound(uri);
+ }
+
+ if (start == end) {
+ // Trying to browse user principals?
+ pi.who = null;
+ } else if (uri.charAt(start) != '/') {
+ throw new WebdavNotFound(uri);
+ } else {
+ pi.who = uri.substring(start + 1, end);
+ }
+
+ return pi;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getGroupPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#makeHref(java.lang.String, boolean)
*/
- public String getGroupPrincipalRoot() {
- return "/principals/groups";
- }
+ public String makeHref(String id, int whoType) throws WebdavException {
+ String root = fromWho.get(whoType);
- /* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeUserHref(java.lang.String)
- */
- public String makeUserHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getUserPrincipalRoot() + "/" + id;
+ if (root == null) {
+ throw new WebdavException("unknown who type " + whoType);
+ }
+
+ return root + "/" + id;
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeGroupHref(java.lang.String)
+ * @see org.bedework.caldav.server.SysIntf#getGroups(java.lang.String, java.lang.String)
*/
- public String makeGroupHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getGroupPrincipalRoot() + "/" + id;
+ public Collection<String>getGroups(String rootUrl,
+ String principalUrl) throws WebdavException {
+ return Collections.emptySet();
}
public boolean getDirectoryBrowsingDisallowed() throws WebdavException {
@@ -272,7 +329,7 @@
*/
public CalUserInfo getCalUserInfo(String account,
boolean getDirInfo) throws WebdavException {
- return new CalUserInfo(account, null, null, null, null, null);
+ return new CalUserInfo(account, "/principals/users", null, null, null, null, null);
}
public Collection<String> getPrincipalCollectionSet(String resourceUri)
@@ -842,6 +899,11 @@
return cio;
}
+ private static void initWhoMaps(String prefix, int whoType) {
+ toWho.put(prefix, whoType);
+ fromWho.put(whoType, prefix);
+ }
+
/* ====================================================================
* Protected methods
* ==================================================================== */
Modified: trunk/google/src/edu/rpi/cct/bedework/caldav/GoogleSysIntfImpl.java
===================================================================
--- trunk/google/src/edu/rpi/cct/bedework/caldav/GoogleSysIntfImpl.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/google/src/edu/rpi/cct/bedework/caldav/GoogleSysIntfImpl.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -75,6 +75,9 @@
import edu.rpi.cct.webdav.servlet.shared.PrincipalPropertySearch;
import edu.rpi.cct.webdav.servlet.shared.WebdavBadRequest;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNotFound;
+import edu.rpi.cmt.access.Ace;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import net.fortuna.ical4j.model.Calendar;
@@ -93,8 +96,11 @@
import com.google.gdata.data.extensions.EventEntry.Transparency;
import java.io.Reader;
+import java.net.URI;
import java.net.URL;
import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
@@ -118,6 +124,18 @@
private String urlPrefix;
+ private static HashMap<String, Integer> toWho = new HashMap<String, Integer>();
+ private static HashMap<Integer, String> fromWho = new HashMap<Integer, String>();
+
+ static {
+ initWhoMaps("/principals/users", Ace.whoTypeUser);
+ initWhoMaps("/principals/groups", Ace.whoTypeGroup);
+ initWhoMaps("/principals/tickets", Ace.whoTypeTicket);
+ initWhoMaps("/principals/resources", Ace.whoTypeResource);
+ initWhoMaps("/principals/venues", Ace.whoTypeVenue);
+ initWhoMaps("/principals/hosts", Ace.whoTypeHost);
+ }
+
public void init(HttpServletRequest req,
String envPrefix,
String account,
@@ -135,38 +153,81 @@
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#isPrincipal(java.lang.String)
*/
- public String getPrincipalRoot() {
- return "/principals";
+ public boolean isPrincipal(String val) throws WebdavException {
+ return val.startsWith("/principals");
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getUserPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#getPrincipalInfo(java.lang.String)
*/
- public String getUserPrincipalRoot() {
- return "/principals/users";
+ public PrincipalInfo getPrincipalInfo(String href) throws WebdavException {
+ PrincipalInfo pi = new PrincipalInfo();
+
+ try {
+ String uri = new URI(href).getPath();
+
+ if (!isPrincipal(uri)) {
+ return null;
+ }
+
+ int start;
+
+ int end = uri.length();
+ if (uri.endsWith("/")) {
+ end--;
+ }
+
+ String groupRoot = "/principals/groups";
+ String userRoot = "/principals/users";
+
+ if (uri.startsWith(userRoot)) {
+ start = userRoot.length();
+ pi.prefix = userRoot;
+ pi.whoType = Ace.whoTypeUser;
+ } else if (uri.startsWith(groupRoot)) {
+ start = groupRoot.length();
+ pi.prefix = groupRoot;
+ pi.whoType = Ace.whoTypeGroup;
+ } else {
+ throw new WebdavNotFound(uri);
+ }
+
+ if (start == end) {
+ // Trying to browse user principals?
+ pi.who = null;
+ } else if (uri.charAt(start) != '/') {
+ throw new WebdavNotFound(uri);
+ } else {
+ pi.who = uri.substring(start + 1, end);
+ }
+
+ return pi;
+ } catch (Throwable t) {
+ throw new WebdavException(t);
+ }
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#getGroupPrincipalRoot()
+ * @see org.bedework.caldav.server.SysIntf#makeHref(java.lang.String, boolean)
*/
- public String getGroupPrincipalRoot() {
- return "/principals/groups";
- }
+ public String makeHref(String id, int whoType) throws WebdavException {
+ String root = fromWho.get(whoType);
- /* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeUserHref(java.lang.String)
- */
- public String makeUserHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getUserPrincipalRoot() + "/" + id;
+ if (root == null) {
+ throw new WebdavException("unknown who type " + whoType);
+ }
+
+ return root + "/" + id;
}
/* (non-Javadoc)
- * @see org.bedework.caldav.server.SysIntf#makeGroupHref(java.lang.String)
+ * @see org.bedework.caldav.server.SysIntf#getGroups(java.lang.String, java.lang.String)
*/
- public String makeGroupHref(String id) throws WebdavException {
- return getUrlPrefix() + "/" + getGroupPrincipalRoot() + "/" + id;
+ public Collection<String>getGroups(String rootUrl,
+ String principalUrl) throws WebdavException {
+ return Collections.emptySet();
}
public boolean getDirectoryBrowsingDisallowed() throws WebdavException {
@@ -189,7 +250,7 @@
*/
public CalUserInfo getCalUserInfo(String account,
boolean getDirInfo) throws WebdavException {
- return new CalUserInfo(account, null, null, null, null, null);
+ return new CalUserInfo(account, "/principals/users", null, null, null, null, null);
}
public Collection<String> getPrincipalCollectionSet(String resourceUri)
@@ -530,6 +591,11 @@
}
}
+ private static void initWhoMaps(String prefix, int whoType) {
+ toWho.put(prefix, whoType);
+ fromWho.put(whoType, prefix);
+ }
+
/* ====================================================================
* Protected methods
* ==================================================================== */
Modified: trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavBWIntf.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -73,7 +73,6 @@
import edu.rpi.cct.webdav.servlet.common.Headers;
import edu.rpi.cct.webdav.servlet.common.MethodBase;
-import edu.rpi.cct.webdav.servlet.common.PrincipalMatchReport;
import edu.rpi.cct.webdav.servlet.common.WebdavServlet;
import edu.rpi.cct.webdav.servlet.common.WebdavUtils;
import edu.rpi.cct.webdav.servlet.common.MethodBase.MethodInfo;
@@ -92,6 +91,7 @@
import edu.rpi.cmt.access.Ace;
import edu.rpi.cmt.access.AceWho;
import edu.rpi.cmt.access.Acl;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Privileges;
import edu.rpi.cmt.access.WhoDefs;
import edu.rpi.cmt.access.Acl.CurrentAccess;
@@ -802,36 +802,24 @@
* ==================================================================== */
/* (non-Javadoc)
- * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#getPrincipalPrefix()
+ * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#getGroups(java.lang.String, java.lang.String)
*/
- public String getPrincipalPrefix() throws WebdavException {
- return getSysi().getPrincipalRoot();
- }
-
- /* (non-Javadoc)
- * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#principalMatch(java.lang.String, edu.rpi.cct.webdav.servlet.common.PrincipalMatchReport)
- */
- public Collection<WebdavNsNode> principalMatch(String resourceUri,
- PrincipalMatchReport pmatch)
+ public Collection<WebdavNsNode> getGroups(String resourceUri,
+ String principalUrl)
throws WebdavException {
Collection<WebdavNsNode> res = new ArrayList<WebdavNsNode>();
- if (pmatch.self) {
- if (resourceUri.endsWith("/")) {
- resourceUri = resourceUri.substring(0, resourceUri.length() - 1);
+ Collection<String> hrefs = getSysi().getGroups(resourceUri, principalUrl);
+ for (String href: hrefs) {
+ if (href.endsWith("/")) {
+ href = href.substring(0, href.length());
}
+ int pos = href.lastIndexOf("/");
+ String account = href.substring(pos + 1);
+ String basePath = href.substring(0, pos);
- /* ResourceUri should be the principals root or user principal root */
- if (!resourceUri.equals(getPrincipalPrefix()) &&
- !resourceUri.equals(getSysi().getUserPrincipalRoot())) {
- return res;
- }
-
- res.add(new CaldavUserNode(new CaldavURI(this.account,
- getSysi().getUserPrincipalRoot(),
- true),
+ res.add(new CaldavUserNode(new CaldavURI(account, basePath, true),
getSysi(), null, debug));
- return res;
}
return res;
@@ -855,7 +843,7 @@
for (CalUserInfo cui: sysi.getPrincipals(resourceUri, pps)) {
pnodes.add(new CaldavUserNode(new CaldavURI(cui.account,
- getSysi().getUserPrincipalRoot(),
+ cui.principalPathPrefix,
true),
getSysi(), cui, debug));
}
@@ -867,16 +855,9 @@
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#makeUserHref(java.lang.String)
*/
public String makeUserHref(String id) throws WebdavException {
- return getSysi().makeUserHref(id);
+ return getSysi().makeHref(id, Ace.whoTypeUser);
}
- /* (non-Javadoc)
- * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#makeGroupHref(java.lang.String)
- */
- public String makeGroupHref(String id) throws WebdavException {
- return getSysi().makeGroupHref(id);
- }
-
/** Object class passed around as we parse access.
*/
public static class CdAclInfo extends AclInfo {
@@ -924,7 +905,7 @@
if ((href == null) || (href.length() == 0)) {
throw new WebdavBadRequest("Missing href");
}
- info.pi = getPrincipalInfo(info.pi, href);
+ info.pi = getSysi().getPrincipalInfo(href);
if (info.pi == null) {
info.errorTag = WebdavTags.recognizedPrincipal;
return false;
@@ -1063,96 +1044,9 @@
}
}
- /** This class is the result of interpreting a principal url
+ /* (non-Javadoc)
+ * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf#getAclPrincipalInfo(edu.rpi.cct.webdav.servlet.shared.WebdavNsNode)
*/
- public static class PrincipalInfo {
- int whoType; // from access.Ace user, group etc
- String who; // id of user group etc.
- String prefix; // prefix of hierarchy e.g. /principals/users
- }
-
- private PrincipalInfo getPrincipalInfo(PrincipalInfo pi, String href)
- throws WebdavException {
- if (pi == null) {
- pi = new PrincipalInfo();
- }
-
- try {
- String uri = new URI(href).getPath();
-
- /*
- String[] segs = uri.split("/");
-
- // First element should be empty, second = "users" or "groups"
- // third is id.
-
- if ((segs.length != 3) || (segs[0].length() != 0)) {
- throw new WebdavBadRequest("0 or 3 elements expected");
- }
-
- if ("users".equals(segs[1])) {
- pi.whoType = Ace.whoTypeUser;
- } else if ("groups".equals(segs[1])) {
- pi.whoType = Ace.whoTypeGroup;
- } else {
- throw new WebdavBadRequest("Bad WHO type - expect 'users|groups'");
- }
-
- if (segs[2].length() == 0) {
- throw new WebdavBadRequest("Missing id");
- }
-
- pi.who = segs[2];
- */
- if (!uri.startsWith(getPrincipalPrefix())) {
- return null;
- }
-
- int start;
-
- int end = uri.length();
- if (uri.endsWith("/")) {
- end--;
- }
-
- String groupRoot = getSysi().getGroupPrincipalRoot();
- String userRoot = getSysi().getUserPrincipalRoot();
-
- if (uri.startsWith(userRoot)) {
- start = userRoot.length();
- pi.prefix = userRoot;
- pi.whoType = Ace.whoTypeUser;
- } else if (uri.startsWith(groupRoot)) {
- start = groupRoot.length();
- pi.prefix = groupRoot;
- pi.whoType = Ace.whoTypeGroup;
- } else {
- throw new WebdavNotFound(uri);
- }
-
- if (start == end) {
- // Trying to browse user principals?
- pi.who = null;
- } else if (uri.charAt(start) != '/') {
- throw new WebdavNotFound(uri);
- } else {
- pi.who = uri.substring(start + 1, end);
- }
-
- if (debug) {
- debugMsg("getPrincipalInfo \"" + pi.who +
- "\" group=" + (pi.whoType == Ace.whoTypeGroup) +
- " principalUri=\"" + uri + "\"");
- }
-
- return pi;
- } catch (Throwable t) {
- if (debug) {
- error(t);
- }
- throw new WebdavBadRequest();
- }
- }
public Collection<String> getAclPrincipalInfo(WebdavNsNode node) throws WebdavException {
try {
TreeSet<String> hrefs = new TreeSet<String>();
@@ -1229,15 +1123,7 @@
public boolean knownProperty(WebdavNsNode node,
WebdavProperty pr) {
QName tag = pr.getTag();
- String ns = tag.getNamespaceURI();
- if (!ns.equals(CaldavDefs.caldavNamespace) &&
- !ns.equals(CaldavDefs.icalNamespace) &&
- !ns.equals(AppleServerTags.appleCaldavNamespace)) {
- // Not ours
- return super.knownProperty(node, pr);
- }
-
for (int i = 0; i < knownProperties.length; i++) {
if (tag.equals(knownProperties[i])) {
return true;
@@ -1246,7 +1132,7 @@
/* Try the node for a value */
- return node.knownProperty(tag);
+ return super.knownProperty(node, pr);
}
/* (non-Javadoc)
@@ -1548,67 +1434,17 @@
return curi;
}
- boolean isPrincipal = uri.startsWith(getPrincipalPrefix());
+ boolean isPrincipal = sysi.isPrincipal(uri);
if ((nodeType == WebdavNsIntf.nodeTypePrincipal) && !isPrincipal) {
throw new WebdavNotFound(uri);
}
if (isPrincipal) {
- PrincipalInfo pi = getPrincipalInfo(null, uri);
+ PrincipalInfo pi = getSysi().getPrincipalInfo(uri);
- /*
- boolean group;
- int start;
-
- int end = uri.length();
- if (uri.endsWith("/")) {
- end--;
- }
-
- String groupRoot = getSysi().getGroupPrincipalRoot();
- String userRoot = getSysi().getUserPrincipalRoot();
- String prefix;
-
- if (uri.startsWith(userRoot)) {
- start = userRoot.length();
- prefix = userRoot;
- group = false;
- } else if (uri.startsWith(groupRoot)) {
- start = groupRoot.length();
- prefix = groupRoot;
- group = true;
- } else {
- throw new WebdavNotFound(uri);
- }
-
- if (start == end) {
- // Trying to browse user principals.
- throw new WebdavForbidden();
- }
-
- if (uri.charAt(start) != '/') {
- throw new WebdavNotFound(uri);
- }
-
- String account = uri.substring(start + 1, end);
- if (debug) {
- debugMsg("get uri for account \"" + account +
- "\" group=" + group +
- " principalUri=\"" + uri + "\"");
- }
- */
-
- if (pi.whoType == Ace.whoTypeGroup) {
- if (!sysi.validGroup(pi.who)) {
- throw new WebdavNotFound(uri);
- }
- } else if (!sysi.validUser(pi.who)) {
- throw new WebdavNotFound(uri);
- }
-
return new CaldavURI(/*sysi.userToCaladdr(pi.who)*/pi.who, pi.prefix,
- pi.whoType == Ace.whoTypeUser);
+ pi.whoType != Ace.whoTypeGroup);
}
if (existance == WebdavNsIntf.existanceDoesExist) {
Modified: trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavCalNode.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -144,9 +144,9 @@
collection = true;
allowsGet = false;
- if (!uri.endsWith("/")) {
- uri += "/";
- }
+// if (!uri.endsWith("/")) {
+// uri += "/";
+// }
}
/**
@@ -446,16 +446,12 @@
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#knownProperty(edu.rpi.sss.util.xml.QName)
*/
public boolean knownProperty(QName tag) {
- String ns = tag.getNamespaceURI();
-
- if (!ns.equals(CaldavDefs.caldavNamespace) &&
- !ns.equals(CaldavDefs.icalNamespace) &&
- !ns.equals(AppleServerTags.appleCaldavNamespace)) {
- // Not ours
- return super.knownProperty(tag);
+ if (propertyNames.get(tag) != null) {
+ return true;
}
- return propertyNames.get(tag) != null;
+ // Not ours
+ return super.knownProperty(tag);
}
/* (non-Javadoc)
Modified: trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavComponentNode.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -171,6 +171,19 @@
//addPropEntry(propertyNames, ICalTags.version); /* * * * * * CALENDAR*/
}
+ /** Place holder for status
+ *
+ * @param sysi
+ * @param status
+ * @param uri
+ * @param debug
+ */
+ public CaldavComponentNode(SysIntf sysi, int status, String uri, boolean debug) {
+ super(true, sysi, debug);
+ setStatus(status);
+ this.uri = uri;
+ }
+
/** Constructor
*
* @param cdURI
@@ -312,15 +325,12 @@
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#knownProperty(edu.rpi.sss.util.xml.QName)
*/
public boolean knownProperty(QName tag) {
- String ns = tag.getNamespaceURI();
-
- if ((!ns.equals(CaldavDefs.caldavNamespace) &&
- !ns.equals(CaldavDefs.icalNamespace))) {
- // Not ours
- return super.knownProperty(tag);
+ if (propertyNames.get(tag) != null) {
+ return true;
}
- return propertyNames.get(tag) != null;
+ // Not ours
+ return super.knownProperty(tag);
}
/* (non-Javadoc)
Modified: trunk/server/src/org/bedework/caldav/server/CaldavPrincipalNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavPrincipalNode.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavPrincipalNode.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -58,12 +58,16 @@
import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import edu.rpi.sss.util.xml.QName;
+import edu.rpi.sss.util.xml.XmlEmit;
import org.bedework.calfacade.BwCalendar;
import org.bedework.davdefs.CaldavDefs;
+import org.bedework.davdefs.WebdavTags;
+
import org.w3c.dom.Element;
import java.util.Collection;
+import java.util.HashMap;
/** Class to represent a principal in caldav.
*
@@ -73,6 +77,14 @@
public class CaldavPrincipalNode extends CaldavBwNode {
private String displayName;
+ private final static HashMap<QName, PropertyTagEntry> propertyNames =
+ new HashMap<QName, PropertyTagEntry>();
+
+ static {
+ addPropEntry(propertyNames, WebdavTags.groupMemberSet);
+ addPropEntry(propertyNames, WebdavTags.groupMembership);
+ }
+
/**
* @param cdURI
* @param sysi
@@ -83,6 +95,9 @@
boolean debug) throws WebdavException {
super(cdURI, sysi, debug);
displayName = cdURI.getEntityName();
+// if (displayName.startsWith("/")) {
+// debugMsg(displayName);
+// }
}
/**
@@ -201,20 +216,45 @@
}
/* (non-Javadoc)
+ * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#knownProperty(edu.rpi.sss.util.xml.QName)
+ */
+ public boolean knownProperty(QName tag) {
+ if (propertyNames.get(tag) != null) {
+ return true;
+ }
+
+ // Not ours
+ return super.knownProperty(tag);
+ }
+
+ /* (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 {
String ns = tag.getNamespaceURI();
+ XmlEmit xml = intf.getXmlEmit();
/* Deal with webdav properties */
- if (!ns.equals(CaldavDefs.caldavNamespace)) {
+ if (!ns.equals(WebdavTags.namespace)) {
// Not ours
return super.generatePropertyValue(tag, intf, allProp);
}
try {
+ if (tag.equals(WebdavTags.groupMemberSet)) {
+ // PROPTODO
+ xml.emptyTag(tag);
+ return true;
+ }
+
+ if (tag.equals(WebdavTags.groupMembership)) {
+ // PROPTODO
+ xml.emptyTag(tag);
+ return true;
+ }
+
// Not known - try higher
return super.generatePropertyValue(tag, intf, allProp);
} catch (Throwable t) {
Modified: trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavReportMethod.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -393,9 +393,15 @@
WebdavNsIntf.existanceMust,
WebdavNsIntf.nodeTypeUnknown));
} catch (WebdavException we) {
- nodes.add((WebdavNsNode)new CaldavCalNode(intf.getSysi(),
- we.getStatusCode(),
- intf.getUri(hr), debug));
+ if (hr.endsWith("/")) {
+ nodes.add((WebdavNsNode)new CaldavCalNode(intf.getSysi(),
+ we.getStatusCode(),
+ intf.getUri(hr), debug));
+ } else {
+ nodes.add((WebdavNsNode)new CaldavComponentNode(intf.getSysi(),
+ we.getStatusCode(),
+ intf.getUri(hr), debug));
+ }
}
}
}
@@ -409,10 +415,7 @@
node.setStatus(status);
doNodeProperties(node);
} else if (nodes != null) {
- Iterator it = nodes.iterator();
- while (it.hasNext()) {
- WebdavNsNode curnode = (WebdavNsNode)it.next();
-
+ for (WebdavNsNode curnode: nodes) {
doNodeProperties(curnode);
}
}
Modified: trunk/server/src/org/bedework/caldav/server/CaldavUserNode.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/CaldavUserNode.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/CaldavUserNode.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -176,14 +176,12 @@
* @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#knownProperty(edu.rpi.sss.util.xml.QName)
*/
public boolean knownProperty(QName tag) {
- String ns = tag.getNamespaceURI();
-
- if (!ns.equals(CaldavDefs.caldavNamespace)) {
- // Not ours
- return super.knownProperty(tag);
+ if (propertyNames.get(tag) != null) {
+ return true;
}
- return propertyNames.get(tag) != null;
+ // Not ours
+ return super.knownProperty(tag);
}
/* (non-Javadoc)
@@ -234,8 +232,8 @@
return true;
}
- // Not known
- return false;
+ // Not known - try higher
+ return super.generatePropertyValue(tag, intf, allProp);
} catch (Throwable t) {
throw new WebdavException(t);
}
Modified: trunk/server/src/org/bedework/caldav/server/EmitAccess.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/EmitAccess.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/EmitAccess.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -100,21 +100,16 @@
this.sysi = sysi;
}
- public String makeUserHref(String id) throws AccessException {
+ /* (non-Javadoc)
+ * @see edu.rpi.cmt.access.AccessXmlUtil.HrefBuilder#makeHref(java.lang.String, int)
+ */
+ public String makeHref(String id, int whoType) throws AccessException {
try {
- return sysi.makeUserHref(id);
+ return sysi.makeHref(id, whoType);
} catch (Throwable t) {
throw new AccessException(t);
}
}
-
- public String makeGroupHref(String id) throws AccessException {
- try {
- return sysi.makeGroupHref(id);
- } catch (Throwable t) {
- throw new AccessException(t);
- }
- }
}
/** Acls use tags in the webdav and caldav namespace. For use over caldav
Modified: trunk/server/src/org/bedework/caldav/server/SysIntf.java
===================================================================
--- trunk/server/src/org/bedework/caldav/server/SysIntf.java 2007-05-09 16:42:26 UTC (rev 161)
+++ trunk/server/src/org/bedework/caldav/server/SysIntf.java 2007-05-14 19:47:52 UTC (rev 162)
@@ -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.
@@ -71,6 +43,7 @@
import edu.rpi.cct.webdav.servlet.shared.PrincipalPropertySearch;
import edu.rpi.cct.webdav.servlet.shared.WebdavException;
import edu.rpi.cmt.access.Ace;
+import edu.rpi.cmt.access.PrincipalInfo;
import edu.rpi.cmt.access.Acl.CurrentAccess;
import net.fortuna.ical4j.model.Calendar;
@@ -111,40 +84,46 @@
*/
public String getUrlPrefix();
- /** get the principal root e.g. "/principals"
+ /** Does the value appear to represent a valid principal?
*
- * @return String
- * @throws WebdavException for errors
+ * @param val
+ * @return true if it's a (possible) principal
+ * @throws WebdavException
*/
- public String getPrincipalRoot() throws WebdavException;
+ public boolean isPrincipal(String val) throws WebdavException;
- /** get the principal root e.g. "/principals/users"
+ /** Return principal information for the given href. Also tests for a valid
+ * principal.
*
- * @return String
- * @throws WebdavException for errors
- */
- public String getUserPrincipalRoot() throws WebdavException;
-
- /** get the group principal root e.g. "/principals/groups"
*
- * @return String
- * @throws WebdavException for errors
+ * @param href
+ * @return PrincipalInfo
+ * @throws WebdavException
*/
- public String getGroupPrincipalRoot() throws WebdavException;
+ public PrincipalInfo getPrincipalInfo(String href) throws WebdavException;
/**
* @param id
+ * @param whoType - from WhoDefs
* @return String href
* @throws WebdavException
*/
- public String makeUserHref(String id) throws WebdavException;
+ public String makeHref(String id, int whoType) throws WebdavException;
- /**
- * @param id
- * @return String href
+ /** The urls should be principal urls. principalUrl can null for the current user.
+ * The result is a collection of principal urls of which the given url is a
+ * member, based upon rootUrl. For example, if rootUrl points to the base of
+ * the user principal hierarchy, then the rsult should be at least the current
+ * user's principal url, remembering that user principals are themselves groups
+ * and the user is considered a member of their own group.
+ *
+ * @param rootUrl - url to base search on.
+ * @param principalUrl - url of principal or null for current user
+ * @return Collection of urls - always non-null
* @throws WebdavException
*/
- public String makeGroupHref(String id) throws WebdavException;
+ public Collection<String>getGroups(String rootUrl,
+ String principalUrl) throws WebdavException;
/** Do we allow browsing of directories?
*
@@ -180,10 +159,16 @@
* @author Mike Douglass
*/
public static class CalUserInfo implements Serializable {
- /** account as returned by caladdrToUer
+ /** account as returned by caladdrToUser
+ *
+ * Currently tail end of principal path
*/
public String account;
+ /** principal path prefix
+ */
+ public String principalPathPrefix;
+
/** Path to user home
*/
public String userHomePath;
@@ -206,16 +191,19 @@
/**
* @param account
+ * @param principalPathPrefix
* @param userHomePath
* @param defaultCalendarPath
* @param inboxPath
* @param outboxPath
* @param directoryInfo
*/
- public CalUserInfo(String account, String userHomePath,
+ public CalUserInfo(String account, String principalPathPrefix,
+ String userHomePath,
String defaultCalendarPath, String inboxPath,
String outboxPath, BwUserInfo directoryInfo) {
this.account = account;
+ this.principalPathPrefix = principalPathPrefix;
this.userHomePath = userHomePath;
this.defaultCalendarPath = defaultCalendarPath;
this.inboxPath = inboxPath;
More information about the Bedework-commit
mailing list