You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by lu...@apache.org on 2004/09/26 16:19:20 UTC

cvs commit: jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties PropertyFactory.java ModificationDateProperty.java HrefValuedProperty.java DateProperty.java CreationDateProperty.java CheckedinProperty.java ResourceTypeProperty.java OwnerProperty.java GetLastModifiedProperty.java GetContentLengthProperty.java

luetzkendorf    2004/09/26 07:19:20

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
                        Tag: SLIDE_2_1_RELEASE_BRANCH
                        XMLResponseMethodBase.java
               webdavclient/clientlib/src/java/org/apache/webdav/lib/properties
                        Tag: SLIDE_2_1_RELEASE_BRANCH
                        ResourceTypeProperty.java OwnerProperty.java
                        GetLastModifiedProperty.java
                        GetContentLengthProperty.java
  Added:       webdavclient/clientlib/src/java/org/apache/webdav/lib/properties
                        Tag: SLIDE_2_1_RELEASE_BRANCH PropertyFactory.java
                        ModificationDateProperty.java
                        HrefValuedProperty.java DateProperty.java
                        CreationDateProperty.java CheckedinProperty.java
  Log:
  Property instanciation reworked, introduced new ProeprtyFactory to allow users
  its own properties instanciated.
  (resolves issues 29592, 30776 and 31318)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.14.2.1  +6 -46     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
  
  Index: XMLResponseMethodBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- XMLResponseMethodBase.java	2 Aug 2004 15:45:48 -0000	1.14
  +++ XMLResponseMethodBase.java	26 Sep 2004 14:19:20 -0000	1.14.2.1
  @@ -41,17 +41,9 @@
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.httpclient.HttpStatus;
   
  -import org.apache.webdav.lib.BaseProperty;
   import org.apache.webdav.lib.Property;
   import org.apache.webdav.lib.ResponseEntity;
  -import org.apache.webdav.lib.properties.AclProperty;
  -import org.apache.webdav.lib.properties.CurrentUserPrivilegeSetProperty;
  -import org.apache.webdav.lib.properties.GetLastModifiedProperty;
  -import org.apache.webdav.lib.properties.LockDiscoveryProperty;
  -import org.apache.webdav.lib.properties.OwnerProperty;
  -import org.apache.webdav.lib.properties.PrincipalCollectionSetProperty;
  -import org.apache.webdav.lib.properties.ResourceTypeProperty;
  -import org.apache.webdav.lib.properties.SupportedLockProperty;
  +import org.apache.webdav.lib.properties.PropertyFactory;
   import org.apache.webdav.lib.util.DOMUtils;
   import org.apache.webdav.lib.util.DOMWriter;
   import org.apache.webdav.lib.util.WebdavStatus;
  @@ -453,40 +445,8 @@
       protected static Property convertElementToProperty(
           Response response, Element element) {
   
  -        Property property = null;
  -        String namespace = DOMUtils.getElementNamespaceURI(element);
  -
  -        // handle DAV properties specially
  -        if (namespace != null && namespace.equals("DAV:")) {
  -
  -            String localName = DOMUtils.getElementLocalName(element);
  -
  -            if (ResourceTypeProperty.TAG_NAME.equals(localName)) {
  -                property = new ResourceTypeProperty(response, element);
  -            } else if (GetLastModifiedProperty.TAG_NAME.equals(localName)) {
  -                property = new GetLastModifiedProperty(response, element);
  -            } else if (CurrentUserPrivilegeSetProperty.TAG_NAME.equals
  -                       (localName)) {
  -                property =
  -                    new CurrentUserPrivilegeSetProperty(response, element);
  -            } else if (LockDiscoveryProperty.TAG_NAME.equals(localName)) {
  -                property = new LockDiscoveryProperty(response, element);
  -            } else if (SupportedLockProperty.TAG_NAME.equals(localName)) {
  -                property = new SupportedLockProperty(response, element);
  -            } else if (AclProperty.TAG_NAME.equals(localName)) {
  -                property = new AclProperty(response, element);
  -            } else if (PrincipalCollectionSetProperty.TAG_NAME.equals(localName)) {
  -                property = new PrincipalCollectionSetProperty(response, element);
  -            } else if (OwnerProperty.TAG_NAME.equals(localName)) {
  -                property = new OwnerProperty(response, element);
  -            }
  -        }
  -
  -        if (property == null) {
  -            property = new BaseProperty(response, element);
  -        }
  -
  -        return property;
  +        return PropertyFactory.create(response, element);
  +        
       }
   
   
  
  
  
  No                   revision
  No                   revision
  1.5.2.1   +19 -10    jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/ResourceTypeProperty.java
  
  Index: ResourceTypeProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/ResourceTypeProperty.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- ResourceTypeProperty.java	2 Aug 2004 15:45:50 -0000	1.5
  +++ ResourceTypeProperty.java	26 Sep 2004 14:19:20 -0000	1.5.2.1
  @@ -36,8 +36,9 @@
    */
   public class ResourceTypeProperty extends BaseProperty {
   
  -    private boolean initialized=false;
  -    private boolean isCollection;
  +    private boolean initialized = false;
  +    private boolean isCollection = false;
  +    private boolean isPrincipal = false;
   
       // -------------------------------------------------------------- Constants
   
  @@ -51,6 +52,7 @@
        * The property collection tag.
        */
       public static final String TAG_COLLECTION = "collection";
  +    public static final String TAG_PRINCIPAL = "principal";
   
   
       // ----------------------------------------------------------- Constructors
  @@ -79,14 +81,20 @@
           init();
           return isCollection;
       }
  +    
  +    public boolean isPrincipal() {
  +        init();
  +        return isPrincipal;
  +    }
   
       private void init()
       {
  -        // FIXME: only <DAV:collection/> is supported
   
           if (initialized)
               return;
   
  +        initialized=true;
  +
           NodeList tmp = element.getChildNodes();
           for (int i = 0; tmp != null && i < tmp.getLength(); i++ ) {
               try {
  @@ -95,14 +103,15 @@
                        && "DAV:".equals(DOMUtils.getElementNamespaceURI(child)))
                   {
                       isCollection=true;
  -                    initialized=true;
  -                    return;
  +                }
  +                if (TAG_PRINCIPAL.equals(DOMUtils.getElementLocalName(child))
  +                        && "DAV:".equals(DOMUtils.getElementNamespaceURI(child)))
  +                {
  +                    isPrincipal=true;
                   }
               } catch (ClassCastException e) {
               }
           }
  -        isCollection=false;
  -        initialized=true;
       }
   
       /**
  
  
  
  1.4.2.1   +4 -37     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/OwnerProperty.java
  
  Index: OwnerProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/OwnerProperty.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- OwnerProperty.java	2 Aug 2004 15:45:50 -0000	1.4
  +++ OwnerProperty.java	26 Sep 2004 14:19:20 -0000	1.4.2.1
  @@ -23,61 +23,28 @@
   
   package org.apache.webdav.lib.properties;
   
  -import org.apache.webdav.lib.BaseProperty;
   import org.apache.webdav.lib.ResponseEntity;
  -import org.apache.webdav.lib.util.DOMUtils;
   import org.w3c.dom.Element;
   
   /**
    * This interface models the <code>&lt;D:owner&gt;</code> property, which is
    * defined in the WebDAV Access Control Protocol specification.
  - *
  - * @version $Revision$
    */
  -public class OwnerProperty extends BaseProperty {
  -
  +public class OwnerProperty extends HrefValuedProperty {
   
       // -------------------------------------------------------------- Constants
   
  -
       /**
        * The property name.
        */
       public static final String TAG_NAME = "owner";
   
  -
       // ----------------------------------------------------------- Constructors
   
  -
       /**
        * Default constructor for the property.
        */
       public OwnerProperty(ResponseEntity response, Element element) {
           super(response, element);
       }
  -
  -
  -    // --------------------------------------------------------- Public Methods
  -
  -    /**
  -     * Returns the value of the href element.
  -     */
  -    public String getHref() {
  -        String principal="";
  -        Element href = DOMUtils.getFirstElement(element, "DAV:", "href");
  -        if (href!=null)
  -        {
  -            principal = DOMUtils.getTextValue(href);
  -        }
  -        return principal;
  -    }
  -
  -    public String getPropertyAsString() {
  -        return getHref();
  -    }
  -
  -    public String toString() {
  -        return getHref();
  -    }
  -
   }
  
  
  
  1.4.2.1   +6 -41     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetLastModifiedProperty.java
  
  Index: GetLastModifiedProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetLastModifiedProperty.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -r1.4 -r1.4.2.1
  --- GetLastModifiedProperty.java	2 Aug 2004 15:45:50 -0000	1.4
  +++ GetLastModifiedProperty.java	26 Sep 2004 14:19:20 -0000	1.4.2.1
  @@ -22,14 +22,7 @@
    */
   package org.apache.webdav.lib.properties;
   
  -import java.text.DateFormat;
  -import java.text.ParseException;
  -import java.text.SimpleDateFormat;
  -import java.util.Date;
  -import java.util.Locale;
  -import org.apache.webdav.lib.BaseProperty;
   import org.apache.webdav.lib.ResponseEntity;
  -import org.apache.webdav.lib.util.DOMUtils;
   import org.w3c.dom.Element;
   
   /**
  @@ -40,7 +33,7 @@
    *
    * @version $Revision$
    */
  -public class GetLastModifiedProperty extends BaseProperty {
  +public class GetLastModifiedProperty extends DateProperty {
   
   
       // -------------------------------------------------------------- Constants
  @@ -55,6 +48,7 @@
       /**
        * The standard date format for the last modified date, as specified in
        * the HTTP 1.1 specification (RFC 2068).
  +     * @deprecated
        */
       public static final String DATE_FORMAT = "EEE, d MMM yyyy kk:mm:ss z";
   
  @@ -67,35 +61,6 @@
        */
       public GetLastModifiedProperty(ResponseEntity response, Element element) {
           super(response, element);
  -        // RFC 1123, 822. Date and time specification is English.
  -        format = new SimpleDateFormat(DATE_FORMAT, Locale.US);
       }
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    protected DateFormat format = null;
  -
  -
  -    // --------------------------------------------------------- Public Methods
  -
  -
  -    /**
  -     * Get the date of the last modification.
  -     *
  -     * @return the last modified date.
  -     */
  -    public Date getDate() {
  -        Date date = null;
  -        try {
  -            synchronized (format) {
  -                date = format.parse(DOMUtils.getTextValue(element));
  -            }
  -        } catch (ParseException e) {
  -        }
  -        return date;
  -    }
  -
   
   }
  
  
  
  1.3.2.1   +20 -7     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetContentLengthProperty.java
  
  Index: GetContentLengthProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetContentLengthProperty.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- GetContentLengthProperty.java	28 Jul 2004 09:30:36 -0000	1.3
  +++ GetContentLengthProperty.java	26 Sep 2004 14:19:20 -0000	1.3.2.1
  @@ -22,16 +22,29 @@
    */
   package org.apache.webdav.lib.properties;
   
  -import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.BaseProperty;
  +import org.apache.webdav.lib.ResponseEntity;
  +import org.apache.webdav.lib.util.DOMUtils;
  +import org.w3c.dom.Element;
   
   /**
    * @version $Revision$
    */
  -public interface GetContentLengthProperty extends Property {
  +public class GetContentLengthProperty extends BaseProperty {
  +    
       public static final String TAG_NAME = "getcontentlength";
   
  +    public GetContentLengthProperty(ResponseEntity response, Element element)
  +    {
  +        super(response, element);
  +    }
  +    
       /**
        * Get the content length.
  +     * 
  +     * @throws NumberFormatException
        */
  -    public long getLength();
  +    public long getLength() {
  +        return Long.parseLong(DOMUtils.getTextValue(element));
  +    }
   }
  
  
  
  No                   revision
  
  Index: GetContentLengthProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetContentLengthProperty.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- GetContentLengthProperty.java	28 Jul 2004 09:30:36 -0000	1.3
  +++ GetContentLengthProperty.java	26 Sep 2004 14:19:20 -0000	1.3.2.1
  @@ -22,16 +22,29 @@
    */
   package org.apache.webdav.lib.properties;
   
  -import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.BaseProperty;
  +import org.apache.webdav.lib.ResponseEntity;
  +import org.apache.webdav.lib.util.DOMUtils;
  +import org.w3c.dom.Element;
   
   /**
    * @version $Revision$
    */
  -public interface GetContentLengthProperty extends Property {
  +public class GetContentLengthProperty extends BaseProperty {
  +    
       public static final String TAG_NAME = "getcontentlength";
   
  +    public GetContentLengthProperty(ResponseEntity response, Element element)
  +    {
  +        super(response, element);
  +    }
  +    
       /**
        * Get the content length.
  +     * 
  +     * @throws NumberFormatException
        */
  -    public long getLength();
  +    public long getLength() {
  +        return Long.parseLong(DOMUtils.getTextValue(element));
  +    }
   }
  
  
  
  No                   revision
  
  Index: GetContentLengthProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/GetContentLengthProperty.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- GetContentLengthProperty.java	28 Jul 2004 09:30:36 -0000	1.3
  +++ GetContentLengthProperty.java	26 Sep 2004 14:19:20 -0000	1.3.2.1
  @@ -22,16 +22,29 @@
    */
   package org.apache.webdav.lib.properties;
   
  -import org.apache.webdav.lib.Property;
  +import org.apache.webdav.lib.BaseProperty;
  +import org.apache.webdav.lib.ResponseEntity;
  +import org.apache.webdav.lib.util.DOMUtils;
  +import org.w3c.dom.Element;
   
   /**
    * @version $Revision$
    */
  -public interface GetContentLengthProperty extends Property {
  +public class GetContentLengthProperty extends BaseProperty {
  +    
       public static final String TAG_NAME = "getcontentlength";
   
  +    public GetContentLengthProperty(ResponseEntity response, Element element)
  +    {
  +        super(response, element);
  +    }
  +    
       /**
        * Get the content length.
  +     * 
  +     * @throws NumberFormatException
        */
  -    public long getLength();
  +    public long getLength() {
  +        return Long.parseLong(DOMUtils.getTextValue(element));
  +    }
   }
  
  
  
  1.1.2.1   +119 -0    jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/PropertyFactory.java
  
  
  
  
  1.1.2.1   +21 -0     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/ModificationDateProperty.java
  
  
  
  
  1.1.2.1   +72 -0     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/HrefValuedProperty.java
  
  
  
  
  1.1.2.1   +71 -0     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/DateProperty.java
  
  
  
  
  1.1.2.1   +40 -0     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/CreationDateProperty.java
  
  
  
  
  1.1.2.1   +56 -0     jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/properties/Attic/CheckedinProperty.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org