jericho     01/05/10 12:04:52

  Modified:    src/webdav/client/src/org/apache/webdav/lib
                        WebdavSession.java WebdavResource.java
  Log:
  - Add the setSession method to save the session.
  - Save authentication and lock information for the client.
     I almost forgot to set the client for authentication and more.  :(
  
  Revision  Changes    Path
  1.8       +123 -10   
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
  
  Index: WebdavSession.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebdavSession.java        2001/05/05 15:34:51     1.7
  +++ WebdavSession.java        2001/05/10 19:04:45     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
 1.7 2001/05/05 15:34:51 jericho Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/05/05 15:34:51 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
 1.8 2001/05/10 19:04:45 jericho Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/05/10 19:04:45 $
    *
    * ====================================================================
    *
  @@ -71,6 +71,7 @@
   import org.apache.util.HttpURL;
   import org.apache.commons.httpclient.HttpClient;
   import org.apache.commons.httpclient.Credentials;
  +import org.apache.commons.httpclient.ConnectionInterceptor;
   import org.apache.commons.httpclient.StreamInterceptor;
   
   /**
  @@ -88,7 +89,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Park, Sung-Gu</a>
    */
  -public class WebdavSession {
  +public class WebdavSession implements ConnectionInterceptor {
   
       // ---------------------------------------------------- Instance Variables
   
  @@ -97,12 +98,12 @@
        * Infomation hashtable for WebDAV clients  HTTP/1.1 communication.
        */
       private static Hashtable clientInfo = new Hashtable();
  -
  -
  +    
  +    
       /**
  -     * The session progress.
  +     * The Http client instance.
        */
  -    //private ProgressUtil sessionProgress = new ProgressUtil();
  +    protected HttpClient client;
   
   
       /**
  @@ -146,13 +147,30 @@
                   String password = httpURL.getPassword();
                   client.setCredentials(new Credentials(userName, password));
               }
  +            client.setConnectionInterceptor(this);
               clientInfo.put(authority, client);
           }
  -        //client.getProgressUtil().addProgressListener(this);
           
           return client;
       }
   
  +   
  +    /**
  +     * Set the session by the given client.
  +     * In order to save infomration of the client, it must be used.
  +     *
  +     * @param client The Http client instance.
  +     * @exception IOException
  +     */
  +    public synchronized void setSession(HttpClient client)
  +        throws IOException {
  +        
  +        HttpURL httpURL =
  +            new HttpURL(client.getUserName(), client.getPassword(),
  +                        client.getHost(), client.getPort());
  +        clientInfo.put(httpURL.getAuthority(), client);
  +    }
  +
   
       /**
        * Test a session to be connected.
  @@ -236,9 +254,98 @@
           // Remove the progress listener.
           // webdavClient.getProgressUtil().addProgressListener(this);
       }
  -    
  +
   
       /**
  +     * Connect.
  +     */
  +    public void connect() {
  +        // Not implemented yet.
  +    }
  +
  +
  +    /**
  +     * Disconnect.
  +     */
  +    public void disconnect() {
  +        // Not implemented yet.
  +    }
  +
  +
  +    /**
  +     * Retry.
  +     * 
  +     * @return boolean true if a retry should be attempted
  +     */
  +    public boolean retry(int status) {
  +        // Not implemented yet.
  +        return false;
  +    }
  +
  +
  +    /**
  +     * Recieved an informational status code.
  +     * 
  +     * @return boolean true if a retry should be attempted
  +     */
  +    public boolean info(int status, Hashtable headers) {
  +        // Not implemented yet.
  +        return false;
  +    }
  +
  +
  +    /**
  +     * Unexpected error.
  +     * 
  +     * @param status Status code; can be equal to -1 if status code is not 
  +     * known
  +     * @param e Underlying exception; can be null
  +     * @return boolean true if processing of the request should be stopped
  +     */
  +    public boolean error(int status, Exception e) {
  +        // Not implemented yet.
  +        return false;
  +    }
  +
  +
  +    /**
  +     * Sent request.
  +     */
  +    public void sentRequest() {
  +        // Not implemented yet.
  +    }
  +
  +
  +    /**
  +     * Recieved response.
  +     */
  +    public void recievedResponse() {
  +        // Not implemented yet.
  +    }
  +
  +
  +    /**
  +     * Recieved expectation.
  +     */
  +    public void recievedExpectation() {
  +        // Not implemented yet.
  +    }
  +
  +
  +    /**
  +     * Authenticate.
  +     */
  +    public void authenticate() {
  +        try {
  +            if (client != null) {
  +                setSession(client);
  +            }
  +        } catch (IOException e) {
  +        }
  +    }
  +
  +
  +    /**
        * Progressing by the progress event.
        *
        * @param pe The progress event.
  @@ -269,3 +376,9 @@
       }
       */
   }
  +
  +
  +
  +
  +
  +
  
  
  
  1.7       +6 -9      
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
  
  Index: WebdavResource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WebdavResource.java       2001/05/10 10:29:42     1.6
  +++ WebdavResource.java       2001/05/10 19:04:47     1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
 1.6 2001/05/10 10:29:42 jericho Exp $
  - * $Revision: 1.6 $
  - * $Date: 2001/05/10 10:29:42 $
  + * $Header: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
 1.7 2001/05/10 19:04:47 jericho Exp $
  + * $Revision: 1.7 $
  + * $Date: 2001/05/10 19:04:47 $
    *
    * ====================================================================
    *
  @@ -320,12 +320,6 @@
   
   
       /**
  -     * The HttpClient instance for this resource.
  -     */
  -    private HttpClient client;
  -
  -
  -    /**
        * Table of the hrefs gotten in a collection.
        */
       private WebdavResources childResources = new WebdavResources();
  @@ -1650,6 +1644,7 @@
           if (state != null) {
               state.setEncodeURLs(encodeURLs);
               client.setState(state);
  +            setSession(client);
           }
       }
   
  @@ -2633,6 +2628,7 @@
           setStatusCode(statusCode, lock);
           if (statusCode >= 200 && statusCode < 300) {
               client.setState(state);
  +            setSession(client);
               return true;
           }
   
  @@ -2693,6 +2689,7 @@
           if (statusCode >= 200 && statusCode < 300) {
               state.removeLocks(path);
               client.setState(state);
  +            setSession(client);
               return true;
           }
   
  
  
  

Reply via email to