ib          2003/11/06 03:04:15

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        AclMethod.java
               src/webdav/client/src/org/apache/webdav/lib Ace.java
  Log:
  Add support for setting the "property" principal for ACL requests.
  This should now be supported by the WebDAV servlet.
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.13      +32 -14    
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/AclMethod.java
  
  Index: AclMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/AclMethod.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AclMethod.java    5 Sep 2003 11:56:23 -0000       1.12
  +++ AclMethod.java    6 Nov 2003 11:04:15 -0000       1.13
  @@ -72,7 +72,7 @@
   import org.apache.util.XMLPrinter;
   import org.apache.webdav.lib.Ace;
   import org.apache.webdav.lib.Privilege;
  -
  +import org.apache.webdav.lib.PropertyName;
   
   /**
    * ACL Method.
  @@ -180,20 +180,38 @@
               printer.writeElement("D", null, "principal",
                                    XMLPrinter.OPENING);
   
  -            boolean found=false;
  -            String principal=ace.getPrincipal();
  -            String[] 
types={"all","authenticated","unauthenticated","property","self"};
  -            for (int i=0; i<types.length && found==false; i++)
  -            {
  +            boolean found = false;
  +            String principal = ace.getPrincipal();
  +            String[] types = {"all", "authenticated", "unauthenticated",
  +                              "property", "self"};
  +            for (int i = 0; i < types.length && !found; i++) {
                   if (types[i].equals(principal)) {
  -                    found=true;
  -                    printer.writeElement("D",null,principal, XMLPrinter.NO_CONTENT);
  +                    found = true;
  +                    if ("property".equals(principal)) {
  +                        printer.writeElement("D", null, principal,
  +                                             XMLPrinter.OPENING);
  +                        PropertyName property = ace.getProperty();
  +                        String nsURI = property.getNamespaceURI();
  +                        if ("DAV:".equals(nsURI)) {
  +                            printer.writeElement("D", null,
  +                                                 property.getLocalName(),
  +                                                 XMLPrinter.NO_CONTENT);
  +                        } else {
  +                            printer.writeElement("Z", nsURI,
  +                                                 property.getLocalName(),
  +                                                 XMLPrinter.NO_CONTENT);
  +                        }
  +                        printer.writeElement("D", null, principal,
  +                                             XMLPrinter.CLOSING);
  +                    } else {
  +                        printer.writeElement("D", null, principal,
  +                                             XMLPrinter.NO_CONTENT);
  +                    }
                   }
               }
  -            if (!found)
  -            {
  +            if (!found) {
                   printer.writeElement("D", null, "href", XMLPrinter.OPENING);
  -                printer.writeText(ace.getPrincipal());
  +                printer.writeText(principal);
                   printer.writeElement("D", null, "href", XMLPrinter.CLOSING);
               }
   
  
  
  
  1.7       +36 -5     
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Ace.java
  
  Index: Ace.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Ace.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Ace.java  4 Apr 2003 15:25:18 -0000       1.6
  +++ Ace.java  6 Nov 2003 11:04:15 -0000       1.7
  @@ -74,7 +74,8 @@
    * @version $Revision$
    */
   public class Ace {
  -
  +    private static final PropertyName DEFAULT_PROPERTY
  +        = new PropertyName("DAV:", "owner");
   
       // ----------------------------------------------------------- Constructors
   
  @@ -133,6 +134,12 @@
       protected String inheritedFrom = null;
   
   
  +    /**
  +     * Property. Only used if principal.equals("property").
  +     */
  +    protected PropertyName property = null;
  +
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -213,6 +220,30 @@
        */
       public void setInheritedFrom(String inheritedFrom) {
           this.inheritedFrom = inheritedFrom;
  +    }
  +
  +
  +    /**
  +     * Property accessor.
  +     *
  +     * @return the property to compare if the pricipal is "property".
  +     *         If the property has not been set or has been set to null
  +     *         return "DAV:owner".
  +     * @see #setProperty(PropertyName)
  +     */
  +    public PropertyName getProperty() {
  +        return property != null ? property : DEFAULT_PROPERTY;
  +    }
  +
  +
  +    /**
  +     * Property mutator.
  +     *
  +     * @param property the property to compare if the principal is "property"
  +     * @see #getProperty()
  +     */
  +    public void setProperty(PropertyName property) {
  +        this.property = property;
       }
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to