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 2005/01/14 15:09:56 UTC

cvs commit: jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods ReportMethod.java

luetzkendorf    2005/01/14 06:09:56

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
                        ReportMethod.java
  Log:
  comments and cleanup
  
  Revision  Changes    Path
  1.7       +38 -23    jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/ReportMethod.java
  
  Index: ReportMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/ReportMethod.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ReportMethod.java	2 Aug 2004 15:45:48 -0000	1.6
  +++ ReportMethod.java	14 Jan 2005 14:09:56 -0000	1.7
  @@ -52,20 +52,29 @@
   
   
       /**
  -     * Request specified properties.
  +     * Report type: <code>DAV:version-tree</code> with a certain set of properties.
        */
       public static final int SUB_SET = 0;
   
  -
       /**
  -     * Request of all properties name and value.
  +     * Report type: <code>DAV:version-tree</code> with <code>DAV:allprop</code>. 
        */
       public static final int ALL = 1;
   
  +    /**
  +     * Report type: <code>DAV:locate-by-history</code>.
  +     * @see {@link #setHistoryURLs(Enumeration)}.
  +     */
       public static final int LOCATE_HISTORY = 2;
   
  -    public String sVersionHistory ="";
  -
  +    /**
  +     * The <code>D:version-history-set</code> element for the 
  +     * <code>DAV:locate-by-history</code> report. 
  +     */
  +    private String sVersionHistory ="";
  +    /**
  +     * The request body provided in ctor.
  +     */
       private String preloadedQuery = null;
   
       // ----------------------------------------------------------- Constructors
  @@ -280,12 +289,13 @@
               }
               else
               {
  -                // unknown type
  -                // ignore
  +                throw new IllegalArgumentException("Invalid object given for property.");
               }
           }
   
           this.propertyNames = (PropertyName[])list.toArray(new PropertyName[list.size()]);
  +        
  +        if (this.type == ALL) this.type = SUB_SET;
       }
   
       /**
  @@ -293,14 +303,17 @@
        */
       public void setHistoryURLs(Enumeration historyURLs) {
   
  -        sVersionHistory = "<D:version-history-set>";
  +        StringBuffer buffer = new StringBuffer();
  +        buffer.append("<D:version-history-set>");
   
  -        while (historyURLs.hasMoreElements())
  -        {
  -            sVersionHistory += "<D:href>"+ historyURLs.nextElement().toString() + "</D:href>";
  +        while (historyURLs.hasMoreElements()) {
  +            buffer.append("<D:href>")
  +                  .append(historyURLs.nextElement().toString())
  +                  .append("</D:href>");
           }
  -
  -        sVersionHistory += "</D:version-history-set>";
  +        buffer.append("</D:version-history-set>");
  +        
  +        sVersionHistory = buffer.toString();
       }
   
   
  @@ -354,20 +367,17 @@
               return preloadedQuery;
   
           XMLPrinter printer = new XMLPrinter();
  -
  -
           printer.writeXMLHeader();
  -        if (type!= LOCATE_HISTORY)
  -            printer.writeElement("D", "DAV:", "version-tree",
  -                             XMLPrinter.OPENING);
   
           switch (type) {
           case ALL:
  +            printer.writeElement("D", "DAV:", "version-tree", XMLPrinter.OPENING);
               printer.writeElement("D", "allprop", XMLPrinter.NO_CONTENT);
               printer.writeElement("D", "version-tree", XMLPrinter.CLOSING);
               break;
   
           case SUB_SET:
  +            printer.writeElement("D", "DAV:", "version-tree", XMLPrinter.OPENING);
               printer.writeElement("D", "prop", XMLPrinter.OPENING);
               for (int i=0 ; i<propertyNames.length ; i++)
               {
  @@ -427,7 +437,7 @@
       /**
        * Returns an enumeration of <code>Property</code> objects.
        */
  -            public Enumeration getResponseProperties(String urlPath) {
  +    public Enumeration getResponseProperties(String urlPath) {
           checkUsed();
   
           Response response = (Response) getResponseHashtable().get(urlPath);
  @@ -437,6 +447,11 @@
               return (new Vector()).elements();
           }
   
  -         }
  +    }
  +    
  +    public static void main(String[] args) {
  +        ReportMethod method = new ReportMethod("/abc");
  +        System.out.println(method.generateRequestBody());
  +    }
   }
   
  
  
  

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