[Bedework-commit] r509 - in trunk/calendar3:
appcommon/src/org/bedework/appcommon
caldav/src/edu/rpi/cct/uwcal/caldav
caldav/src/edu/rpi/cct/webdav/servlet/shared
test/caldavTestData/eg/content
webcommon/src/org/bedework/webcommon/taglib
svnadmin at bedework.org
svnadmin at bedework.org
Sun May 28 20:16:54 EDT 2006
Author: douglm
Date: 2006-05-28 20:16:48 -0400 (Sun, 28 May 2006)
New Revision: 509
Added:
trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessXmlUtil.java
Removed:
trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessAppUtil.java
Modified:
trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java
trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java
trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java
trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavComponentNode.java
trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavUserNode.java
trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/EmitAccess.java
trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java
trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
trunk/calendar3/test/caldavTestData/eg/content/eg15.xml
trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitAclTag.java
trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitCurrentPrivsTag.java
Log:
Caldav updates to finish current-user-prvilege-set
Deleted: trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessAppUtil.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessAppUtil.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessAppUtil.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -1,399 +0,0 @@
-/*
- 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.
-
- 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 Rensselaer Polytechnic
- Institute are not used in advertising or publicity without the
- express prior written permission of Rensselaer Polytechnic Institute;
-
- DISCLAIMER: The software is distributed" AS IS" without any express or
- implied warranty, including but not limited to, any implied warranties
- of merchantability or fitness for a particular purpose or any warrant)'
- of non-infringement of any current or pending patent rights. The authors
- of the software make no representations about the suitability of this
- software for any particular purpose. The entire risk as to the quality
- and performance of the software is with the user. Should the software
- prove defective, the user assumes the cost of all necessary servicing,
- repair or correction. In particular, neither Rensselaer Polytechnic
- Institute, nor the authors of the software are liable for any indirect,
- special, consequential, or incidental damages related to the software,
- to the maximum extent the law permits.
-*/
-package org.bedework.appcommon;
-
-import org.bedework.calfacade.CalFacadeException;
-import org.bedework.davdefs.CaldavTags;
-import org.bedework.davdefs.WebdavTags;
-
-import edu.rpi.cct.uwcal.access.Ace;
-import edu.rpi.cct.uwcal.access.Acl;
-import edu.rpi.cct.uwcal.access.Privilege;
-import edu.rpi.cct.uwcal.access.PrivilegeDefs;
-import edu.rpi.cct.uwcal.access.PrivilegeSet;
-import edu.rpi.cct.uwcal.access.Privileges;
-import edu.rpi.sss.util.xml.QName;
-import edu.rpi.sss.util.xml.XmlEmit;
-
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.Collection;
-import java.util.Iterator;
-
-/** Class to generate xml from an access specification. The resulting xml follows
- * the webdav acl spec rfc3744
- *
- * @author Mike Douglass douglm @ rpi.edu
- */
-public class AccessAppUtil implements Serializable {
- /** xml rpivilege tags */
- public static final QName[] privTags = {
- WebdavTags.all, // privAll = 0;
- WebdavTags.read, // privRead = 1;
- WebdavTags.readAcl, // privReadAcl = 2;
- WebdavTags.readCurrentUserPrivilegeSet, // privReadCurrentUserPrivilegeSet = 3;
- CaldavTags.readFreeBusy, // privReadFreeBusy = 4;
- WebdavTags.write, // privWrite = 5;
- WebdavTags.writeAcl, // privWriteAcl = 6;
- WebdavTags.writeProperties, // privWriteProperties = 7;
- WebdavTags.writeContent, // privWriteContent = 8;
- WebdavTags.bind, // privBind = 9;
- WebdavTags.unbind, // privUnbind = 10;
- WebdavTags.unlock, // privUnlock = 11;
- null // privNone = 12;
- };
-
- private XmlEmit xml;
-
- /** Acls use tags in the webdav and caldav namespace.
- *
- * @param xml
- */
- public AccessAppUtil(XmlEmit xml) {
- this.xml = xml;
- }
-
- /** Represent the acl as an xml string
- *
- * @param acl
- * @return String xml representation
- * @throws CalFacadeException
- */
- public static String getXmlAclString(Acl acl) throws CalFacadeException {
- try {
- XmlEmit xml = new XmlEmit(true); // no headers
- StringWriter su = new StringWriter();
- xml.startEmit(su);
- AccessAppUtil au = new AccessAppUtil(xml);
-
- au.emitAcl(acl);
-
- su.close();
-
- return su.toString();
- } catch (CalFacadeException cfe) {
- throw cfe;
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /** (Re)set the xml writer
- *
- * @param val xml Writer
- */
- public void setXml(XmlEmit val) {
- xml = val;
- }
-
- /** Override this to construct urls from the parameter
- *
- * @param who String
- * @return String href
- */
- public String makeUserHref(String who) {
- return who;
- }
-
- /** Override this to construct urls from the parameter
- *
- * @param who String
- * @return String href
- */
- public String makeGroupHref(String who) {
- return who;
- }
-
- /** Emit an acl as an xml string the current xml writer
- *
- * @param acl
- * @throws CalFacadeException
- */
- public void emitAcl(Acl acl) throws CalFacadeException {
- try {
- Collection aces = acl.getAces();
- emitAces(aces);
- } catch (CalFacadeException cfe) {
- throw cfe;
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /** Emit the Collection of aces as an xml sing the current xml writer
- *
- * @param aces
- * @throws CalFacadeException
- */
- public void emitAces(Collection aces) throws CalFacadeException {
- try {
- xml.openTag(WebdavTags.acl);
-
- if (aces != null) {
- Iterator it = aces.iterator();
- while (it.hasNext()) {
- Ace ace = (Ace)it.next();
-
- boolean aceOpen = emitAce(ace, true, false);
- if (emitAce(ace, false, aceOpen)) {
- aceOpen = true;
- }
-
- if (aceOpen) {
- xml.closeTag(WebdavTags.ace);
- }
- }
- }
-
- xml.closeTag(WebdavTags.acl);
- } catch (CalFacadeException cfe) {
- throw cfe;
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /** Produce an xml representation of supported privileges. This is the same
- * at all points in the system and is identical to the webdav/caldav
- * requirements.
- *
- * @throws CalFacadeException
- */
- public void emitSupportedPrivSet() throws CalFacadeException {
- try {
- xml.openTag(WebdavTags.supportedPrivilegeSet);
-
- emitSupportedPriv(Privileges.getPrivAll());
-
- xml.closeTag(WebdavTags.supportedPrivilegeSet);
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /** Produce an xml representation of current user privileges from an array
- * of allowed/disallowed/unspecified flags indexed by a privilege index.
- *
- * @param privileges char[] of allowed/disallowed
- * @throws CalFacadeException
- */
- public void emitCurrentPrivSet(char[] privileges) throws CalFacadeException {
- try {
- xml.openTag(WebdavTags.currentUserPrivilegeSet);
-
- for (int pi = 0; pi < privileges.length; pi++) {
- if ((privileges[pi] == PrivilegeDefs.allowed) ||
- (privileges[pi] == PrivilegeDefs.allowedInherited)) {
- // XXX further work - don't emit abstract privs or contained privs.
- QName pr = privTags[pi];
-
- if (pr != null) {
- xml.propertyTagVal(WebdavTags.privilege, pr);
- }
- }
- }
-
- xml.closeTag(WebdavTags.currentUserPrivilegeSet);
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /** Produce an xml representation of current user privileges from an array
- * of allowed/disallowed/unspecified flags indexed by a privilege index,
- * returning the representation a a String
- *
- * @param ps PrivilegeSet allowed/disallowed
- * @return String xml
- * @throws CalFacadeException
- */
- public static String getCurrentPrivSetString(PrivilegeSet ps)
- throws CalFacadeException {
- try {
- char[] privileges = ps.getPrivileges();
-
- XmlEmit xml = new XmlEmit(true); // no headers
- StringWriter su = new StringWriter();
- xml.startEmit(su);
- AccessAppUtil au = new AccessAppUtil(xml);
-
- au.emitCurrentPrivSet(privileges);
-
- su.close();
-
- return su.toString();
- } catch (CalFacadeException cfe) {
- throw cfe;
- } catch (Throwable t) {
- throw new CalFacadeException(t);
- }
- }
-
- /* ====================================================================
- * Private methods
- * ==================================================================== */
-
- private void emitSupportedPriv(Privilege priv) throws Throwable {
- xml.openTag(WebdavTags.supportedPrivilege);
-
- xml.openTagNoNewline(WebdavTags.privilege);
- xml.emptyTagSameLine(privTags[priv.getIndex()]);
- xml.closeTagNoblanks(WebdavTags.privilege);
-
- if (priv.getAbstractPriv()) {
- xml.emptyTag(WebdavTags._abstract);
- }
-
- xml.property(WebdavTags.description, priv.getDescription());
-
- Iterator it = priv.iterateContainedPrivileges();
- while (it.hasNext()) {
- emitSupportedPriv((Privilege)it.next());
- }
-
- xml.closeTag(WebdavTags.supportedPrivilege);
- }
-
- private boolean emitAce(Ace ace, boolean denials, boolean aceOpen) throws Throwable {
- Collection privs = ace.getPrivs();
- boolean tagOpen = false;
-
- QName tag;
- if (denials) {
- tag = WebdavTags.deny;
- } else {
- tag = WebdavTags.grant;
- }
-
- Iterator it = privs.iterator();
- while (it.hasNext()) {
- Privilege p = (Privilege)it.next();
-
- if (denials == p.getDenial()) {
- if (!aceOpen) {
- xml.openTag(WebdavTags.ace);
-
- emitAceWho(ace);
- aceOpen = true;
- }
-
- if (!tagOpen) {
- xml.openTag(tag);
- tagOpen = true;
- }
- xml.emptyTag(privTags[p.getIndex()]);
- }
- }
-
- if (tagOpen) {
- // XXX Wrong - need to encode an href in the acl
- /*
- if (ace.getInherited()) {
- xml.emptyTag(WebdavTags.inherited);
- }
- */
- xml.closeTag(tag);
- }
-
- return aceOpen;
- }
-
- private void emitAceWho(Ace ace) throws Throwable {
- boolean invert = ace.getNotWho();
-
- if (ace.getWhoType() == Ace.whoTypeOther) {
- invert = !invert;
- }
-
- if (invert) {
- xml.openTag(WebdavTags.invert);
- }
-
- xml.openTag(WebdavTags.principal);
-
- int whoType = ace.getWhoType();
-
- /*
- <!ELEMENT principal (href)
- | all | authenticated | unauthenticated
- | property | self)>
- */
-
- if (whoType == Ace.whoTypeUser) {
- xml.property(WebdavTags.href, makeUserHref(ace.getWho()));
- } else if (whoType == Ace.whoTypeGroup) {
- xml.property(WebdavTags.href, makeGroupHref(ace.getWho()));
- } else if ((whoType == Ace.whoTypeOwner) ||
- (whoType == Ace.whoTypeOther)) {
- // Other is !owner
- xml.openTag(WebdavTags.property);
- xml.emptyTag(WebdavTags.owner);
- xml.closeTag(WebdavTags.property);
- } else if (whoType == Ace.whoTypeUnauthenticated) {
- xml.emptyTag(WebdavTags.unauthenticated);
- } else if (whoType == Ace.whoTypeAuthenticated) {
- xml.emptyTag(WebdavTags.authenticated);
- } else if (whoType == Ace.whoTypeAll) {
- xml.emptyTag(WebdavTags.all);
- } else {
- throw new CalFacadeException("access.unknown.who");
- }
-
- xml.closeTag(WebdavTags.principal);
-
- if (invert) {
- xml.closeTag(WebdavTags.invert);
- }
- }
-}
Added: trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessXmlUtil.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessXmlUtil.java (rev 0)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/AccessXmlUtil.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -0,0 +1,399 @@
+/*
+ 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.
+
+ 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 Rensselaer Polytechnic
+ Institute are not used in advertising or publicity without the
+ express prior written permission of Rensselaer Polytechnic Institute;
+
+ DISCLAIMER: The software is distributed" AS IS" without any express or
+ implied warranty, including but not limited to, any implied warranties
+ of merchantability or fitness for a particular purpose or any warrant)'
+ of non-infringement of any current or pending patent rights. The authors
+ of the software make no representations about the suitability of this
+ software for any particular purpose. The entire risk as to the quality
+ and performance of the software is with the user. Should the software
+ prove defective, the user assumes the cost of all necessary servicing,
+ repair or correction. In particular, neither Rensselaer Polytechnic
+ Institute, nor the authors of the software are liable for any indirect,
+ special, consequential, or incidental damages related to the software,
+ to the maximum extent the law permits.
+*/
+package org.bedework.appcommon;
+
+import org.bedework.calfacade.CalFacadeException;
+import org.bedework.davdefs.CaldavTags;
+import org.bedework.davdefs.WebdavTags;
+
+import edu.rpi.cct.uwcal.access.Ace;
+import edu.rpi.cct.uwcal.access.Acl;
+import edu.rpi.cct.uwcal.access.Privilege;
+import edu.rpi.cct.uwcal.access.PrivilegeDefs;
+import edu.rpi.cct.uwcal.access.PrivilegeSet;
+import edu.rpi.cct.uwcal.access.Privileges;
+import edu.rpi.sss.util.xml.QName;
+import edu.rpi.sss.util.xml.XmlEmit;
+
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.Iterator;
+
+/** Class to generate xml from an access specification. The resulting xml follows
+ * the webdav acl spec rfc3744
+ *
+ * @author Mike Douglass douglm @ rpi.edu
+ */
+public class AccessXmlUtil implements Serializable {
+ /** xml rpivilege tags */
+ public static final QName[] privTags = {
+ WebdavTags.all, // privAll = 0;
+ WebdavTags.read, // privRead = 1;
+ WebdavTags.readAcl, // privReadAcl = 2;
+ WebdavTags.readCurrentUserPrivilegeSet, // privReadCurrentUserPrivilegeSet = 3;
+ CaldavTags.readFreeBusy, // privReadFreeBusy = 4;
+ WebdavTags.write, // privWrite = 5;
+ WebdavTags.writeAcl, // privWriteAcl = 6;
+ WebdavTags.writeProperties, // privWriteProperties = 7;
+ WebdavTags.writeContent, // privWriteContent = 8;
+ WebdavTags.bind, // privBind = 9;
+ WebdavTags.unbind, // privUnbind = 10;
+ WebdavTags.unlock, // privUnlock = 11;
+ null // privNone = 12;
+ };
+
+ private XmlEmit xml;
+
+ /** Acls use tags in the webdav and caldav namespace.
+ *
+ * @param xml
+ */
+ public AccessXmlUtil(XmlEmit xml) {
+ this.xml = xml;
+ }
+
+ /** Represent the acl as an xml string
+ *
+ * @param acl
+ * @return String xml representation
+ * @throws CalFacadeException
+ */
+ public static String getXmlAclString(Acl acl) throws CalFacadeException {
+ try {
+ XmlEmit xml = new XmlEmit(true); // no headers
+ StringWriter su = new StringWriter();
+ xml.startEmit(su);
+ AccessXmlUtil au = new AccessXmlUtil(xml);
+
+ au.emitAcl(acl);
+
+ su.close();
+
+ return su.toString();
+ } catch (CalFacadeException cfe) {
+ throw cfe;
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /** (Re)set the xml writer
+ *
+ * @param val xml Writer
+ */
+ public void setXml(XmlEmit val) {
+ xml = val;
+ }
+
+ /** Override this to construct urls from the parameter
+ *
+ * @param who String
+ * @return String href
+ */
+ public String makeUserHref(String who) {
+ return who;
+ }
+
+ /** Override this to construct urls from the parameter
+ *
+ * @param who String
+ * @return String href
+ */
+ public String makeGroupHref(String who) {
+ return who;
+ }
+
+ /** Emit an acl as an xml string the current xml writer
+ *
+ * @param acl
+ * @throws CalFacadeException
+ */
+ public void emitAcl(Acl acl) throws CalFacadeException {
+ try {
+ Collection aces = acl.getAces();
+ emitAces(aces);
+ } catch (CalFacadeException cfe) {
+ throw cfe;
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /** Emit the Collection of aces as an xml sing the current xml writer
+ *
+ * @param aces
+ * @throws CalFacadeException
+ */
+ public void emitAces(Collection aces) throws CalFacadeException {
+ try {
+ xml.openTag(WebdavTags.acl);
+
+ if (aces != null) {
+ Iterator it = aces.iterator();
+ while (it.hasNext()) {
+ Ace ace = (Ace)it.next();
+
+ boolean aceOpen = emitAce(ace, true, false);
+ if (emitAce(ace, false, aceOpen)) {
+ aceOpen = true;
+ }
+
+ if (aceOpen) {
+ xml.closeTag(WebdavTags.ace);
+ }
+ }
+ }
+
+ xml.closeTag(WebdavTags.acl);
+ } catch (CalFacadeException cfe) {
+ throw cfe;
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /** Produce an xml representation of supported privileges. This is the same
+ * at all points in the system and is identical to the webdav/caldav
+ * requirements.
+ *
+ * @throws CalFacadeException
+ */
+ public void emitSupportedPrivSet() throws CalFacadeException {
+ try {
+ xml.openTag(WebdavTags.supportedPrivilegeSet);
+
+ emitSupportedPriv(Privileges.getPrivAll());
+
+ xml.closeTag(WebdavTags.supportedPrivilegeSet);
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /** Produce an xml representation of current user privileges from an array
+ * of allowed/disallowed/unspecified flags indexed by a privilege index.
+ *
+ * @param xml
+ * @param privileges char[] of allowed/disallowed
+ * @throws CalFacadeException
+ */
+ public static void emitCurrentPrivSet(XmlEmit xml,
+ char[] privileges) throws CalFacadeException {
+ try {
+ xml.openTag(WebdavTags.currentUserPrivilegeSet);
+
+ for (int pi = 0; pi < privileges.length; pi++) {
+ if ((privileges[pi] == PrivilegeDefs.allowed) ||
+ (privileges[pi] == PrivilegeDefs.allowedInherited)) {
+ // XXX further work - don't emit abstract privs or contained privs.
+ QName pr = privTags[pi];
+
+ if (pr != null) {
+ xml.propertyTagVal(WebdavTags.privilege, pr);
+ }
+ }
+ }
+
+ xml.closeTag(WebdavTags.currentUserPrivilegeSet);
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /** Produce an xml representation of current user privileges from an array
+ * of allowed/disallowed/unspecified flags indexed by a privilege index,
+ * returning the representation a a String
+ *
+ * @param ps PrivilegeSet allowed/disallowed
+ * @return String xml
+ * @throws CalFacadeException
+ */
+ public static String getCurrentPrivSetString(PrivilegeSet ps)
+ throws CalFacadeException {
+ try {
+ char[] privileges = ps.getPrivileges();
+
+ XmlEmit xml = new XmlEmit(true); // no headers
+ StringWriter su = new StringWriter();
+ xml.startEmit(su);
+ AccessXmlUtil.emitCurrentPrivSet(xml, privileges);
+
+ su.close();
+
+ return su.toString();
+ } catch (CalFacadeException cfe) {
+ throw cfe;
+ } catch (Throwable t) {
+ throw new CalFacadeException(t);
+ }
+ }
+
+ /* ====================================================================
+ * Private methods
+ * ==================================================================== */
+
+ private void emitSupportedPriv(Privilege priv) throws Throwable {
+ xml.openTag(WebdavTags.supportedPrivilege);
+
+ xml.openTagNoNewline(WebdavTags.privilege);
+ xml.emptyTagSameLine(privTags[priv.getIndex()]);
+ xml.closeTagNoblanks(WebdavTags.privilege);
+
+ if (priv.getAbstractPriv()) {
+ xml.emptyTag(WebdavTags._abstract);
+ }
+
+ xml.property(WebdavTags.description, priv.getDescription());
+
+ Iterator it = priv.iterateContainedPrivileges();
+ while (it.hasNext()) {
+ emitSupportedPriv((Privilege)it.next());
+ }
+
+ xml.closeTag(WebdavTags.supportedPrivilege);
+ }
+
+ private boolean emitAce(Ace ace, boolean denials, boolean aceOpen) throws Throwable {
+ Collection privs = ace.getPrivs();
+ boolean tagOpen = false;
+
+ QName tag;
+ if (denials) {
+ tag = WebdavTags.deny;
+ } else {
+ tag = WebdavTags.grant;
+ }
+
+ Iterator it = privs.iterator();
+ while (it.hasNext()) {
+ Privilege p = (Privilege)it.next();
+
+ if (denials == p.getDenial()) {
+ if (!aceOpen) {
+ xml.openTag(WebdavTags.ace);
+
+ emitAceWho(ace);
+ aceOpen = true;
+ }
+
+ if (!tagOpen) {
+ xml.openTag(tag);
+ tagOpen = true;
+ }
+ xml.emptyTag(privTags[p.getIndex()]);
+ }
+ }
+
+ if (tagOpen) {
+ // XXX Wrong - need to encode an href in the acl
+ /*
+ if (ace.getInherited()) {
+ xml.emptyTag(WebdavTags.inherited);
+ }
+ */
+ xml.closeTag(tag);
+ }
+
+ return aceOpen;
+ }
+
+ private void emitAceWho(Ace ace) throws Throwable {
+ boolean invert = ace.getNotWho();
+
+ if (ace.getWhoType() == Ace.whoTypeOther) {
+ invert = !invert;
+ }
+
+ if (invert) {
+ xml.openTag(WebdavTags.invert);
+ }
+
+ xml.openTag(WebdavTags.principal);
+
+ int whoType = ace.getWhoType();
+
+ /*
+ <!ELEMENT principal (href)
+ | all | authenticated | unauthenticated
+ | property | self)>
+ */
+
+ if (whoType == Ace.whoTypeUser) {
+ xml.property(WebdavTags.href, makeUserHref(ace.getWho()));
+ } else if (whoType == Ace.whoTypeGroup) {
+ xml.property(WebdavTags.href, makeGroupHref(ace.getWho()));
+ } else if ((whoType == Ace.whoTypeOwner) ||
+ (whoType == Ace.whoTypeOther)) {
+ // Other is !owner
+ xml.openTag(WebdavTags.property);
+ xml.emptyTag(WebdavTags.owner);
+ xml.closeTag(WebdavTags.property);
+ } else if (whoType == Ace.whoTypeUnauthenticated) {
+ xml.emptyTag(WebdavTags.unauthenticated);
+ } else if (whoType == Ace.whoTypeAuthenticated) {
+ xml.emptyTag(WebdavTags.authenticated);
+ } else if (whoType == Ace.whoTypeAll) {
+ xml.emptyTag(WebdavTags.all);
+ } else {
+ throw new CalFacadeException("access.unknown.who");
+ }
+
+ xml.closeTag(WebdavTags.principal);
+
+ if (invert) {
+ xml.closeTag(WebdavTags.invert);
+ }
+ }
+}
Modified: trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java
===================================================================
--- trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/appcommon/src/org/bedework/appcommon/EventFormatter.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -216,7 +216,7 @@
if (xmlAccess == null) {
// Acl acl = svci.getAcl(getEvent());
Acl acl = eventInfo.getCurrentAccess().acl;
- xmlAccess = AccessAppUtil.getXmlAclString(acl);
+ xmlAccess = AccessXmlUtil.getXmlAclString(acl);
}
} catch (Throwable t) {
error(t);
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavBWIntf.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -53,7 +53,7 @@
*/
package edu.rpi.cct.uwcal.caldav;
-import org.bedework.appcommon.AccessAppUtil;
+import org.bedework.appcommon.AccessXmlUtil;
import org.bedework.calfacade.BwCalendar;
import org.bedework.calfacade.BwEvent;
import org.bedework.calfacade.BwFreeBusy;
@@ -784,8 +784,8 @@
findPriv: {
// ENUM
- for (priv = 0; priv < AccessAppUtil.privTags.length; priv++) {
- if (MethodBase.nodeMatches(el, AccessAppUtil.privTags[priv])) {
+ for (priv = 0; priv < AccessXmlUtil.privTags.length; priv++) {
+ if (MethodBase.nodeMatches(el, AccessXmlUtil.privTags[priv])) {
break findPriv;
}
}
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavCalNode.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -62,11 +62,11 @@
import org.bedework.icalendar.IcalTranslator;
import org.bedework.icalendar.VFreeUtil;
+import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import edu.rpi.cct.webdav.servlet.shared.WebdavIntfException;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Vector;
import net.fortuna.ical4j.model.Calendar;
import net.fortuna.ical4j.model.component.VFreeBusy;
@@ -138,7 +138,7 @@
Collection events = svci.getEvents(sub, CalFacadeDefs.retrieveRecurExpanded);
if (events == null) {
- return new Vector();
+ return new ArrayList();
}
return events;
@@ -186,14 +186,13 @@
* Abstract methods
* ==================================================================== */
- /** Return all properties special to this namespace for this node.
- * For example, if there is a creator property there will be a
- * WebdavProperty object for the property
- *
- * @return Enumeration
- */
- public Enumeration properties() {
- return null;
+ public CurrentAccess getCurrentAccess() throws WebdavIntfException {
+ BwCalendar cal = getCDURI().getCal();
+ if (cal == null) {
+ return null;
+ }
+
+ return cal.getCurrentAccess();
}
/* ====================================================================
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavComponentNode.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavComponentNode.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavComponentNode.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -63,6 +63,7 @@
import org.bedework.icalendar.IcalTranslator;
//import org.bedework.icalendar.IcalUtil;
+import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import edu.rpi.cct.uwcal.caldav.calquery.CalendarData;
import edu.rpi.cct.webdav.servlet.shared.WebdavIntfException;
import edu.rpi.cct.webdav.servlet.shared.WebdavProperty;
@@ -315,6 +316,14 @@
* Overridden property methods
* ==================================================================== */
+ public CurrentAccess getCurrentAccess() throws WebdavIntfException {
+ if (eventInfo == null) {
+ return null;
+ }
+
+ return eventInfo.getCurrentAccess();
+ }
+
public void setLastmodDate(String val) throws WebdavIntfException {
init(true);
super.setLastmodDate(val);
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavUserNode.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavUserNode.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/CaldavUserNode.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -57,10 +57,10 @@
import org.bedework.calsvci.CalSvcI;
import org.bedework.icalendar.IcalTranslator;
+import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import edu.rpi.cct.webdav.servlet.shared.WebdavIntfException;
import java.util.Collection;
-import java.util.Enumeration;
/** Class to represent a user in caldav.
@@ -126,13 +126,7 @@
* Abstract methods
* ==================================================================== */
- /** Return all properties special to this namespace for this node.
- * For example, if there is a creator property there will be a
- * WebdavProperty object for the property
- *
- * @return Enumeration
- */
- public Enumeration properties() {
+ public CurrentAccess getCurrentAccess() throws WebdavIntfException {
return null;
}
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/EmitAccess.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/EmitAccess.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/uwcal/caldav/EmitAccess.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -53,14 +53,15 @@
*/
package edu.rpi.cct.uwcal.caldav;
-import org.bedework.appcommon.AccessAppUtil;
+import org.bedework.appcommon.AccessXmlUtil;
+
import edu.rpi.sss.util.xml.XmlEmit;
/**
* @author douglm
*
*/
-public class EmitAccess extends AccessAppUtil {
+public class EmitAccess extends AccessXmlUtil {
private String namespacePrefix;
/** Acls use tags in the webdav and caldav namespace. For use over caldav
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -54,11 +54,14 @@
package edu.rpi.cct.webdav.servlet.shared;
+import org.bedework.appcommon.AccessXmlUtil;
import org.bedework.davdefs.WebdavTags;
import edu.rpi.sss.util.xml.QName;
import edu.rpi.sss.util.xml.XmlEmit;
import edu.rpi.sss.util.xml.XmlUtil;
+import edu.rpi.cct.uwcal.access.PrivilegeSet;
+import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import edu.rpi.cct.webdav.servlet.common.MethodBase;
import edu.rpi.cct.webdav.servlet.common.WebdavServlet;
@@ -671,6 +674,15 @@
closePropstat();
} else if (tag.equals(WebdavTags.currentUserPrivilegeSet)) {
// access 5.3
+ CurrentAccess ca = node.getCurrentAccess();
+ if (ca != null) {
+ PrivilegeSet ps = ca.privileges;
+ char[] privileges = ps.getPrivileges();
+
+ openPropstat();
+ AccessXmlUtil.emitCurrentPrivSet(xml, privileges);
+ closePropstat();
+ }
} else if (tag.equals(WebdavTags.acl)) {
// access 5.4
openPropstat();
Modified: trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
===================================================================
--- trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/caldav/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -54,6 +54,8 @@
package edu.rpi.cct.webdav.servlet.shared;
+import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
+
import java.io.Serializable;
import javax.servlet.http.HttpServletResponse;
@@ -155,6 +157,13 @@
*/
public abstract String getOwner() throws WebdavIntfException;
+ /** Get the current access granted to this principal for this node.
+ *
+ * @return CurrentAccess
+ * @throws WebdavIntfException
+ */
+ public abstract CurrentAccess getCurrentAccess() throws WebdavIntfException;
+
/* ====================================================================
* Property methods
* ==================================================================== */
Modified: trunk/calendar3/test/caldavTestData/eg/content/eg15.xml
===================================================================
--- trunk/calendar3/test/caldavTestData/eg/content/eg15.xml 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/test/caldavTestData/eg/content/eg15.xml 2006-05-29 00:16:48 UTC (rev 509)
@@ -4,6 +4,7 @@
<D:getetag/>
<D:owner/>
<D:acl/>
+ <D:current-user-privilege-set/>
<C:calendar-timezone/>
<C:max-resource-size/>
</D:prop>
Modified: trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitAclTag.java
===================================================================
--- trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitAclTag.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitAclTag.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -53,8 +53,9 @@
*/
package org.bedework.webcommon.taglib;
-import org.bedework.appcommon.AccessAppUtil;
+import org.bedework.appcommon.AccessXmlUtil;
+
import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import javax.servlet.jsp.JspWriter;
@@ -104,6 +105,6 @@
return null;
}
- return AccessAppUtil.getXmlAclString(ca.acl);
+ return AccessXmlUtil.getXmlAclString(ca.acl);
}
}
Modified: trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitCurrentPrivsTag.java
===================================================================
--- trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitCurrentPrivsTag.java 2006-05-28 20:24:07 UTC (rev 508)
+++ trunk/calendar3/webcommon/src/org/bedework/webcommon/taglib/EmitCurrentPrivsTag.java 2006-05-29 00:16:48 UTC (rev 509)
@@ -53,8 +53,9 @@
*/
package org.bedework.webcommon.taglib;
-import org.bedework.appcommon.AccessAppUtil;
+import org.bedework.appcommon.AccessXmlUtil;
+
import edu.rpi.cct.uwcal.access.Acl.CurrentAccess;
import javax.servlet.jsp.JspWriter;
@@ -121,7 +122,7 @@
return null;
}
- return AccessAppUtil.getCurrentPrivSetString(ca.privileges);
+ return AccessXmlUtil.getCurrentPrivSetString(ca.privileges);
}
/**
More information about the Bedework-commit
mailing list