ozeigermann    2004/04/14 07:36:46

  Modified:    webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
                        XMLResponseMethodBase.java
               webdavclient/clientlib/src/java/org/apache/util
                        XMLPrinter.java
               webdavclient/clientlib/src/java/org/apache/webdav/lib
                        WebdavResource.java
  Log:
  Applied enhancement by Thomas Bernert described in #28379
  
  Revision  Changes    Path
  1.6       +25 -8     
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XMLResponseMethodBase.java        9 Apr 2004 15:47:04 -0000       1.5
  +++ XMLResponseMethodBase.java        14 Apr 2004 14:36:46 -0000      1.6
  @@ -71,6 +71,11 @@
       extends HttpRequestBodyMethodBase {
   
       //static private final Log log = 
LogSource.getInstance(XMLResponseMethodBase.class.getName());
  +    
  +    
  +    // debug level 
  +    private int debug = 0;
  +
   
       // ----------------------------------------------------------- Constructors
   
  @@ -155,13 +160,11 @@
        * Debug property setter.
        *
        * @param int Debug
  -     */
  -/*
  +     */ 
       public void setDebug(int debug) {
  -        super.setDebug(debug);
  -        log.setLevel(debug);
  +        this.debug = debug;
       }
  -*/
  +
   
   
       /**
  @@ -209,6 +212,13 @@
                   contents = "";
   
               setRequestBody(contents);
  +            
  +            if (debug > 0) {
  +                System.out.println("\n>>>>>>>  to  server  
---------------------------------------------------");
  +                System.out.println(contents);
  +                
System.out.println("------------------------------------------------------------------------");
  +            }
  +
           }
   
           return super.getRequestContentLength();
  @@ -289,6 +299,13 @@
               // avoid ugly printlns from the default error handler.
               builder.setErrorHandler(new DummyErrorHandler());
               responseDocument = builder.parse(new InputSource(input));
  +            
  +            if (debug > 0) {
  +                System.out.println("\n<<<<<<< from server  
---------------------------------------------------");
  +                
System.out.println(responseDocument.getDocumentElement().toString());
  +                
System.out.println("------------------------------------------------------------------------");
  +            }
  +
   
           } catch (Exception e) {
               throw new IOException
  
  
  
  1.3       +46 -13    
jakarta-slide/webdavclient/clientlib/src/java/org/apache/util/XMLPrinter.java
  
  Index: XMLPrinter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/util/XMLPrinter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLPrinter.java   11 Feb 2004 11:30:51 -0000      1.2
  +++ XMLPrinter.java   14 Apr 2004 14:36:46 -0000      1.3
  @@ -37,6 +37,8 @@
       
       // -------------------------------------------------------------- Constants
       
  +    private int indentLevel   = 0;  // indentlevel of XML formating
  +    
       
       /**
        * Opening tag.
  @@ -169,6 +171,22 @@
           writeElement(namespace, null, name, type);
       }
       
  +    /**
  +     * Make a formatstring for debuging output of XML data
  +     * 
  +     * @param debugMode    
  +     * @param indentLevel  Level of indention
  +     * @return
  +     */    
  +    private String debugFormat(boolean debugMode,  int indentLevel) {
  +        int step = 3;
  +        String out = "\n                                                            
                                                                                ";
  +         
  +        if (debugMode)  
  +            return out.substring(0, step * indentLevel + 1);
  +        else
  +            return "";             
  +    }
       
       /**
        * Write an element.
  @@ -180,51 +198,66 @@
        */
       public void writeElement(String namespace, String namespaceInfo, 
                                String name, int type) {
  +                                 
  +        boolean debugMode = true;
  +                                 
  +                                 
           if ((namespace != null) && (namespace.length() > 0)) {
               switch (type) {
               case OPENING:
  +                indentLevel++;           
                   if ((namespaceInfo != null) && (namespaceInfo.length() > 0)) {
  -                    buffer.append("<" + namespace + ":" + name + " xmlns:" 
  +                    buffer.append(debugFormat(debugMode, indentLevel) + "<" + 
namespace + ":" + name + " xmlns:" 
                                     + namespace + "=\"" 
                                     + namespaceInfo + "\">");
                   } else {
  -                    buffer.append("<" + namespace + ":" + name + ">");
  +                    buffer.append(debugFormat(debugMode, indentLevel)+"<" + 
namespace + ":" + name + ">");
                   }
                   break;
               case CLOSING:
  -                buffer.append("</" + namespace + ":" + name + ">");
  +                indentLevel--;
  +
  +                buffer.append(debugFormat(debugMode, indentLevel)+"</" + namespace 
+ ":" + name + ">");
                   break;
               case NO_CONTENT:
               default:
                   if ((namespaceInfo != null)  && (namespaceInfo.length() > 0)) {
  -                    buffer.append("<" + namespace + ":" + name + " xmlns:" 
  +                    buffer.append(debugFormat(debugMode, indentLevel+1)+"<" + 
namespace + ":" + name + " xmlns:" 
                                     + namespace + "=\"" 
                                     + namespaceInfo + "\"/>");
                   } else {
  -                    buffer.append("<" + namespace + ":" + name + "/>");
  +                    buffer.append(debugFormat(debugMode, indentLevel+1)+ "<" + 
namespace + ":" + name + "/>");
                   }
                   break;
               }
           } else {
               switch (type) {
               case OPENING:
  +            
  +
                   if ((namespaceInfo != null) && (namespaceInfo.length()>0)) {
  -                    buffer.append("<" + name + " xmlns=\"" + namespaceInfo 
  +                    buffer.append(debugFormat(debugMode, indentLevel+1)+"<op3" + 
name + " xmlns=\"" + namespaceInfo 
                                     + "\">");
                   } else {
  -                    buffer.append("<" + name + ">");
  +                    indentLevel++;
  +
  +                    buffer.append(debugFormat(debugMode, indentLevel)+"<op4" + name 
+ ">");
                   }
                   break;
               case CLOSING:
  -                buffer.append("</" + name + ">");
  +                indentLevel--;
  +                
  +                buffer.append(debugFormat(debugMode, indentLevel)+"</" + name + 
">");
                   break;
               case NO_CONTENT:
               default:
                   if ((namespaceInfo != null) && (namespaceInfo.length()>0)) {
  -                    buffer.append("<" + name + " xmlns=\"" + namespaceInfo 
  +                    buffer.append(debugFormat(debugMode, indentLevel+1)+"<nc3" + 
name + " xmlns=\"" + namespaceInfo 
                                     + "\"/>");
                   } else {
  -                    buffer.append("<" + name + "/>");
  +                    indentLevel++;
  +
  +                    buffer.append(debugFormat(debugMode, indentLevel)+"<nc4" + name 
+ ">");
                   }
                   break;
               }
  
  
  
  1.13      +73 -8     
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java
  
  Index: WebdavResource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- WebdavResource.java       13 Apr 2004 09:00:53 -0000      1.12
  +++ WebdavResource.java       14 Apr 2004 14:36:46 -0000      1.13
  @@ -2101,6 +2101,8 @@
           setClient();
   
           AclMethod method = new AclMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug);                                            
  +
           generateIfHeader(method);
           for (int i=0; i<aces.length ; i++) {
               Ace ace = aces[i];
  @@ -2135,6 +2137,8 @@
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      DepthSupport.DEPTH_0,
                                                      properties.elements());
  +        method.setDebug(debug);                                            
  +
           client.executeMethod(method);
   
           Enumeration responses = method.getResponses();
  @@ -2185,6 +2189,7 @@
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      DepthSupport.DEPTH_0,
                                                      properties.elements());
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           Enumeration responses = method.getResponses();
  @@ -2236,6 +2241,7 @@
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      DepthSupport.DEPTH_0,
                                                      properties.elements());
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           Enumeration responses = method.getResponses();
  @@ -2293,6 +2299,7 @@
           setClient();
   
           GetMethod method = new GetMethod(URIUtil.encodePathQuery(path));
  +
           client.executeMethod(method);
   
           int statusCode = method.getStatusLine().getStatusCode();
  @@ -2369,6 +2376,7 @@
   
           setClient();
           GetMethod method = new GetMethod(URIUtil.encodePathQuery(path));
  +
           int statusCode = client.executeMethod(method);
   
           // Do a simple little loop to read the response back into the passed
  @@ -2643,6 +2651,9 @@
               method = new OptionsMethod("*");
           else
               method = new OptionsMethod(URIUtil.encodePath(path));
  +            
  +        method.setDebug(debug); 
  +    
           int statusCode = client.executeMethod(method);
   
           setStatusCode(statusCode);
  @@ -2697,6 +2708,8 @@
           HttpClient client = getSessionInstance(httpURL, true);
   
           OptionsMethod method = new OptionsMethod(httpURL.getEscapedPath());
  +        method.setDebug(debug); 
  +
           client.executeMethod(method);
   
           Vector options = new Vector();
  @@ -2752,6 +2765,8 @@
   
           OptionsMethod method = new OptionsMethod(httpURL.getEscapedPath(),
                                                    type);
  +        method.setDebug(debug); 
  +                                                 
           client.executeMethod(method);
   
           Vector options = new Vector();
  @@ -2802,6 +2817,9 @@
   
           OptionsMethod method = new OptionsMethod(URIUtil.encodePath(path),
                                                    type);
  +        method.setDebug(debug); 
  +                                                 
  +                                                 
           client.executeMethod(method);
   
           Vector options = new Vector();
  @@ -2884,6 +2902,7 @@
           setClient();
           LabelMethod method = new LabelMethod(URIUtil.encodePath(path),
                                                labeltype, labelname);
  +        method.setDebug(debug); 
   
           int statusCode = client.executeMethod(method);
   
  @@ -2901,6 +2920,8 @@
           // Default depth=0, type=by_name
           ReportMethod method = new ReportMethod(httpURL.getEscapedPath(),
                                                  depth);
  +        method.setDebug(debug); 
  +                                               
           client.executeMethod(method);
   
           Vector results = new Vector();
  @@ -2937,6 +2958,7 @@
           ReportMethod method =
               new ReportMethod(httpURL.getEscapedPath(), DepthSupport.DEPTH_0,
                                properties.elements());
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           return method.getResponses();
  @@ -2950,6 +2972,7 @@
           // Default depth=0, type=by_name
           ReportMethod method = new ReportMethod(httpURL.getEscapedPath(), depth,
                                                  properties.elements());
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           /*first draft, does work anyhow
  @@ -3000,6 +3023,7 @@
           ReportMethod method = new ReportMethod(httpURL.getEscapedPath(), depth,
                                                  properties.elements(),
                                                  histUri.elements());
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           Vector results = new Vector();
  @@ -3034,6 +3058,8 @@
           // Default depth=0, type=by_name
           ReportMethod method = new ReportMethod(httpURL.getEscapedPath(), depth,
                                                  sQuery);
  +
  +        method.setDebug(debug); 
           client.executeMethod(method);
   
           Vector results = new Vector();
  @@ -3104,10 +3130,13 @@
       public Enumeration propfindMethod(String path, int depth)
           throws HttpException, IOException {
   
  -        setClient();
  +        setClient(); 
           // Change the depth for allprop
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      depth);
  +                                                   
  +        method.setDebug(debug);                                            
  +                                                   
           // Default depth=infinity, type=allprop
           int status = client.executeMethod(method);
   
  @@ -3179,6 +3208,9 @@
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      depth,
                                                      properties.elements());
  +                                                   
  +        method.setDebug(debug); 
  +                                                   
           int status = client.executeMethod(method);
   
           // Set status code for this resource.
  @@ -3275,6 +3307,8 @@
           PropFindMethod method = new PropFindMethod(URIUtil.encodePath(path),
                                                      DepthSupport.DEPTH_0,
                                                      properties.elements());
  +        method.setDebug(debug); 
  +                                                   
           int status = client.executeMethod(method);
   
           // Also accept OK sent by buggy servers.
  @@ -3564,6 +3598,8 @@
   
           setClient();
           PropPatchMethod method = new PropPatchMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           Enumeration names = properties.keys();
           boolean hasSomething = false;
  @@ -3633,6 +3669,7 @@
   
           setClient();
           HeadMethod method = new HeadMethod(URIUtil.encodePathQuery(path));
  +
           int statusCode = client.executeMethod(method);
   
           setStatusCode(statusCode);
  @@ -3672,6 +3709,8 @@
   
           setClient();
           DeleteMethod method = new DeleteMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -3716,6 +3755,8 @@
           setClient();
           MoveMethod method = new MoveMethod(URIUtil.encodePath(source),
                                              URIUtil.encodePath(destination));
  +        method.setDebug(debug); 
  +                                           
           generateIfHeader(method);
           method.setOverwrite(overwrite);
           int statusCode = client.executeMethod(method);
  @@ -3761,6 +3802,8 @@
           setClient();
           CopyMethod method = new CopyMethod(URIUtil.encodePath(source),
                                              URIUtil.encodePath(destination));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           method.setOverwrite(overwrite);
           int statusCode = client.executeMethod(method);
  @@ -3805,6 +3848,7 @@
   
           setClient();
           MkcolMethod method = new MkcolMethod(URIUtil.encodePath(path));
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -3896,6 +3940,8 @@
           short lockType = LockMethod.SCOPE_EXCLUSIVE;
           LockMethod method = new LockMethod(URIUtil.encodePath(path), owner,
                                              lockType, timeout);
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
           String lock = method.getLockToken();
  @@ -3996,6 +4042,8 @@
           if (lock == null) return false;
           // unlock for the given path.
           UnlockMethod method = new UnlockMethod(URIUtil.encodePath(path));
  +        //method.setDebug(debug); 
  +
           generateIfHeader(method);
           method.setLockToken(lock);
           int statusCode = client.executeMethod(method);
  @@ -4085,6 +4133,8 @@
           setClient();
           UpdateMethod method = new UpdateMethod(URIUtil.encodePath(path),
                                                  URIUtil.encodePath(target));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4099,8 +4149,10 @@
   
           setClient();
   
  -        VersionControlMethod method =
  -            new VersionControlMethod(URIUtil.encodePath(path));
  +        VersionControlMethod method = new VersionControlMethod(
  +                                            URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +            
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4115,9 +4167,11 @@
   
           setClient();
   
  -        VersionControlMethod method =
  -            new VersionControlMethod(URIUtil.encodePath(path),
  +        VersionControlMethod method = new VersionControlMethod(
  +                                     URIUtil.encodePath(path),
                                        URIUtil.encodePath(target));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4159,6 +4213,8 @@
           setClient();
           MkWorkspaceMethod method =
               new MkWorkspaceMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +            
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4285,6 +4341,8 @@
   
           setClient();
           CheckinMethod method = new CheckinMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4321,6 +4379,8 @@
   
           setClient();
           CheckoutMethod method = new CheckoutMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4360,6 +4420,8 @@
           setClient();
           UncheckoutMethod method =
               new UncheckoutMethod(URIUtil.encodePath(path));
  +        method.setDebug(debug); 
  +
           generateIfHeader(method);
           int statusCode = client.executeMethod(method);
   
  @@ -4464,6 +4526,9 @@
                   properties,
                   DepthSupport.DEPTH_INFINITY,
                   reportType);
  + 
  +        method.setDebug(debug); 
  +                
           int status = client.executeMethod(method);
   
           // Set status code for this resource.
  
  
  

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

Reply via email to