[Bedework-commit] webdav r157 - in trunk/server/src/edu/rpi/cct/webdav/servlet: common shared

svnadmin at bedework.org svnadmin at bedework.org
Fri Nov 14 01:39:37 EST 2008


Author: douglm
Date: 2008-11-14 01:39:31 -0500 (Fri, 14 Nov 2008)
New Revision: 157

Added:
   trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavGroupNode.java
   trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavPrincipalNode.java
   trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavUserNode.java
Modified:
   trunk/server/src/edu/rpi/cct/webdav/servlet/common/MkcolMethod.java
   trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java
   trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
Log:
1. Move options classes into rpiutil to make them availabkle to other packages.

2. Make changes to the WebDAV classes to facilitate building of extra WebDAV based services (such as CardDAV)

Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/common/MkcolMethod.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/common/MkcolMethod.java	2008-11-07 21:18:59 UTC (rev 156)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/common/MkcolMethod.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -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 2008 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,12 +23,12 @@
     special, consequential, or incidental damages related to the software,
     to the maximum extent the law permits.
 */
-
 package edu.rpi.cct.webdav.servlet.common;
 
 import edu.rpi.cct.webdav.servlet.shared.WebdavException;
 import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;
 import edu.rpi.cct.webdav.servlet.shared.WebdavNsNode;
+import edu.rpi.sss.util.xml.tagdefs.WebdavTags;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -67,7 +39,7 @@
  *
  *   @author Mike Douglass   douglm at rpi.edu
  */
-public class MkcolMethod extends MethodBase {
+public class MkcolMethod extends PropPatchMethod {
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.common.MethodBase#init()
    */
@@ -83,9 +55,9 @@
       trace("MkcolMethod: doMethod");
     }
 
-    /* Parse any content
+    /* Parse any content */
     Document doc = parseContent(req, resp);
-    */
+
     /* Create the node */
     String resourceUri = getResourceUri(req);
 
@@ -93,27 +65,12 @@
                                             WebdavNsIntf.existanceNot,
                                             WebdavNsIntf.nodeTypeCollection);
 
-    getNsIntf().makeCollection(req, resp, node);
+    node.setDefaults(WebdavTags.mkcol);
 
-    /*
-    if (doc != null) {
-      int st = processDoc(req, doc);
-
-      if (st != HttpServletResponse.SC_OK) {
-        resp.setStatus(st);
-        throw new WebdavException(st);
-      }
+    if ((doc == null) ||
+        processDoc(req, resp, doc, node, WebdavTags.mkcol, true)) {
+      // Make collection using properties sent in request
+      getNsIntf().makeCollection(req, resp, node);
     }
-    */
   }
-
-  /* ====================================================================
-   *                   Private methods
-   * ==================================================================== */
-
-  protected int processDoc(HttpServletRequest req,
-                           Document doc) throws WebdavException {
-    throw new WebdavException(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
-  }
 }
-

Added: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavGroupNode.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavGroupNode.java	                        (rev 0)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavGroupNode.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -0,0 +1,51 @@
+/* **********************************************************************
+    Copyright 2007 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 edu.rpi.cct.webdav.servlet.shared;
+
+import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cmt.access.AccessPrincipal;
+
+/** Class to represent a user in caldav. Should only be created in
+   response to an incoming url which references principals.
+ *
+ *   @author Mike Douglass   douglm rpi.edu
+ */
+public class WebdavGroupNode extends WebdavPrincipalNode {
+  /**
+   * @param urlHandler - needed for building hrefs.
+   * @param path - resource path
+   * @param account
+   * @param collection - true if this is a collection
+   * @param debug
+   * @throws WebdavException
+   */
+  public WebdavGroupNode(UrlHandler urlHandler, String path,
+                         AccessPrincipal account,
+                         boolean collection, boolean debug) throws WebdavException {
+    super(urlHandler, path, account, collection, debug);
+    groupPrincipal = true;
+  }
+}

Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java	2008-11-07 21:18:59 UTC (rev 156)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsIntf.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -178,7 +178,7 @@
    * @throws WebdavException
    */
   public String getDavHeader(WebdavNsNode node) throws WebdavException {
-    return "1";
+    return "1, access-control, extended-mkcol";
   }
 
   /** Get an object suitable for use in parsing acls and generating access.

Modified: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java	2008-11-07 21:18:59 UTC (rev 156)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavNsNode.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -55,6 +55,7 @@
 package edu.rpi.cct.webdav.servlet.shared;
 
 import edu.rpi.cct.webdav.servlet.common.WebdavUtils;
+import edu.rpi.cmt.access.AccessPrincipal;
 import edu.rpi.cmt.access.AccessXmlUtil;
 import edu.rpi.cmt.access.PrivilegeSet;
 import edu.rpi.cmt.access.Acl.CurrentAccess;
@@ -694,7 +695,7 @@
       if (tag.equals(WebdavTags.owner)) {
         // access 5.1
         xml.openTag(tag);
-        xml.property(WebdavTags.href, intf.makeUserHref(getOwner()));
+        xml.property(WebdavTags.href, intf.makeUserHref(getOwner().getAccount()));
         xml.closeTag(tag);
 
         return true;
@@ -985,6 +986,13 @@
     return null;
   }
 
+  /**
+   * @param methodTag - acts as a flag for the method type
+   * @throws WebdavException
+   */
+  public void setDefaults(QName methodTag) throws WebdavException {
+  }
+
   /* ====================================================================
    *                   Required webdav properties
    * ==================================================================== */
@@ -1046,10 +1054,10 @@
 
   /** Should return a value suitable for WebdavNsIntf.makeUserHref
    *
-   * @return String owner
+   * @return AccessPrincipal owner
    * @throws WebdavException
    */
-  public abstract String getOwner() throws WebdavException;
+  public abstract AccessPrincipal getOwner() throws WebdavException;
 
   /* ********************************************************************
    *                        Protected methods

Added: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavPrincipalNode.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavPrincipalNode.java	                        (rev 0)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavPrincipalNode.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -0,0 +1,271 @@
+/*
+ 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 edu.rpi.cct.webdav.servlet.shared;
+
+import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cct.webdav.servlet.shared.WebdavNsIntf;
+import edu.rpi.cmt.access.AccessPrincipal;
+import edu.rpi.cmt.access.Acl.CurrentAccess;
+import edu.rpi.sss.util.xml.XmlEmit;
+import edu.rpi.sss.util.xml.tagdefs.WebdavTags;
+
+import org.w3c.dom.Element;
+
+import java.util.HashMap;
+
+import javax.xml.namespace.QName;
+
+/** Class to represent a principal in webdav.
+ *
+ *
+ *   @author Mike Douglass   douglm at rpi.edu
+ */
+public class WebdavPrincipalNode extends WebdavNsNode {
+  private AccessPrincipal account;
+
+  private final static HashMap<QName, PropertyTagEntry> propertyNames =
+    new HashMap<QName, PropertyTagEntry>();
+
+  static {
+    addPropEntry(propertyNames, WebdavTags.groupMemberSet);
+    addPropEntry(propertyNames, WebdavTags.groupMembership);
+  }
+
+  /**
+   * @param urlHandler - needed for building hrefs.
+   * @param path - resource path
+   * @param account
+   * @param collection - true if this is a collection
+   * @param debug
+   * @throws WebdavException
+   */
+  public WebdavPrincipalNode(UrlHandler urlHandler, String path,
+                             AccessPrincipal account,
+                             boolean collection, boolean debug) throws WebdavException {
+    super(urlHandler, path, collection, debug);
+    this.account = account;
+//    if (displayName.startsWith("/")) {
+//      debugMsg(displayName);
+//    }
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getOwner()
+   */
+  public AccessPrincipal getOwner() throws WebdavException {
+    return account;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#update()
+   */
+  public void update() throws WebdavException {
+  }
+
+  /* ====================================================================
+   *                   Abstract methods
+   * ==================================================================== */
+
+  public CurrentAccess getCurrentAccess() throws WebdavException {
+    return null;
+  }
+
+  public String getEtagValue(boolean strong) throws WebdavException {
+    String val = "1234567890";
+
+    if (strong) {
+      return "\"" + val + "\"";
+    }
+
+    return "W/\"" + val + "\"";
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#trailSlash()
+   */
+  public boolean trailSlash() {
+    return true;
+  }
+
+  /* ====================================================================
+   *                   Required webdav properties
+   * ==================================================================== */
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getContentBinary()
+   */
+  public boolean getContentBinary() throws WebdavException {
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getContentLang()
+   */
+  public String getContentLang() throws WebdavException {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getContentLen()
+   */
+  public int getContentLen() throws WebdavException {
+    return 0;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getContentType()
+   */
+  public String getContentType() throws WebdavException {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getCreDate()
+   */
+  public String getCreDate() throws WebdavException {
+    return null;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getDisplayname()
+   */
+  public String getDisplayname() throws WebdavException {
+    return account.getAccount();
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#getLastmodDate()
+   */
+  public String getLastmodDate() throws WebdavException {
+    return null;
+  }
+
+  /* ====================================================================
+   *                   Property methods
+   * ==================================================================== */
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#removeProperty(org.w3c.dom.Element)
+   */
+  public boolean removeProperty(Element val,
+                                SetPropertyResult spr) throws WebdavException {
+    warn("Unimplemented - removeProperty");
+
+    return false;
+  }
+
+  /* (non-Javadoc)
+   * @see edu.rpi.cct.webdav.servlet.shared.WebdavNsNode#setProperty(org.w3c.dom.Element)
+   */
+  public boolean setProperty(Element val,
+                             SetPropertyResult spr) throws WebdavException {
+    if (super.setProperty(val, spr)) {
+      return true;
+    }
+
+    return false;
+  }
+
+  /* (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(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) {
+      throw new WebdavException(t);
+    }
+  }
+
+  /* ====================================================================
+   *                   Private methods
+   * ==================================================================== */
+}

Added: trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavUserNode.java
===================================================================
--- trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavUserNode.java	                        (rev 0)
+++ trunk/server/src/edu/rpi/cct/webdav/servlet/shared/WebdavUserNode.java	2008-11-14 06:39:31 UTC (rev 157)
@@ -0,0 +1,54 @@
+/* **********************************************************************
+    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 edu.rpi.cct.webdav.servlet.shared;
+
+import edu.rpi.cct.webdav.servlet.shared.WebdavException;
+import edu.rpi.cct.webdav.servlet.shared.WebdavPrincipalNode;
+import edu.rpi.cmt.access.AccessPrincipal;
+
+/** Class to represent a user in webdav.
+ *
+ *
+ *   @author Mike Douglass   douglm at rpi.edu
+ */
+public class WebdavUserNode extends WebdavPrincipalNode {
+
+  /**
+   * @param urlHandler - needed for building hrefs.
+   * @param path - resource path
+   * @param account
+   * @param collection - true if this is a collection
+   * @param debug
+   * @throws WebdavException
+   */
+  public WebdavUserNode(UrlHandler urlHandler, String path,
+                        AccessPrincipal account,
+                        boolean collection, boolean debug) throws WebdavException {
+    super(urlHandler, path, account, collection, debug);
+    userPrincipal = true;
+  }
+
+}



More information about the Bedework-commit mailing list