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 da...@locus.apache.org on 2000/12/14 03:21:06 UTC

cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd Main.java

daveb       00/12/13 18:21:06

  Modified:    src/webdav/client/src/org/apache/webdav/cmd Main.java
  Log:
  Added minimal support for propfind. Add Stack for
  holding params.  Still having probs with Put.
  
  Revision  Changes    Path
  1.3       +50 -22    jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Main.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Main.java	2000/11/29 07:00:03	1.2
  +++ Main.java	2000/12/14 02:21:05	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Main.java,v 1.2 2000/11/29 07:00:03 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/11/29 07:00:03 $
  + * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Main.java,v 1.3 2000/12/14 02:21:05 daveb Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/12/14 02:21:05 $
    *
    * ====================================================================
    *
  @@ -79,7 +79,7 @@
    * 
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
    * @author <a href="mailto:daveb@miceda-data.com">Dave Bryson</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class Main {
   
  @@ -185,11 +185,13 @@
                   command = command.trim();
                   StringTokenizer st = new StringTokenizer(command);
                   String todo = st.nextToken();
  -                String params = "";
  +                Stack params = new Stack();
                   
  -                if( st.hasMoreTokens() )
  -                    params = st.nextToken();
  -                
  +                while ( st.hasMoreTokens() )
  +                {
  +                    params.push( st.nextToken() );
  +                }
  +
                   System.out.println( todo );
                   
                   if( todo.equalsIgnoreCase("quit") )
  @@ -204,13 +206,13 @@
                   {
                       GetMethod gm = new GetMethod();
                       
  -                    if( params == null || params.length() == 0 )
  +                    if( params.empty() )
                       {
  -                        System.out.println("get <uri to file to fetch>");
  +                        System.out.println("get <uri of file to fetch>");
                       }
                       else
                       {
  -                         gm.setPath( params );
  +                         gm.setPath( (String)params.pop() );
                            client.executeMethod( gm );
                            System.out.println( "Status: " + gm.getStatusCode() );
                            System.out.println();
  @@ -221,15 +223,24 @@
                   {
                       PutMethod pm = new PutMethod();
                       
  -                    if( params == null || params.length() == 0 )
  +                    if( params.empty() || params.size() < 2 )
                       {
  -                        System.out.println("put <uri to file to upload>");
  +                        System.out.println("put <uri to file to upload> <uri destination>");
                       }
                       else
                       {
  -                        pm.setPath( "/slide/files" );
  -                        pm.sendData( new File( params ) );
  +                        String dest   = (String)params.pop();
  +                        String toload = (String)params.pop();
  +                        
  +                        System.out.println(" file to load " + toload );
  +                        System.out.println(" dest of file " + dest);
  +                        
  +                        pm.setPath( dest );
  +                        pm.sendData( new File( toload ) );
                           client.executeMethod( pm );
  +                        
  +                        // TODO: The put is actually uploading the file on TC 4
  +                        // however it's hanging on the response?
                           System.out.println( "Status: " + pm.getStatusCode() );
                           System.out.println();
                       }
  @@ -238,13 +249,13 @@
                   {
                       MkcolMethod mc = new MkcolMethod();
                       
  -                    if( params == null || params.length() == 0 )
  +                    if( params.empty() )
                       {
                           System.out.println("mkcol <uri to make>");
                       }
                       else
                       {
  -                         mc.setPath( params );
  +                         mc.setPath( (String)params.pop() );
                            client.executeMethod( mc );
                            System.out.println( "Status: " + mc.getStatusCode() );
                            System.out.println();
  @@ -254,13 +265,13 @@
                   {
                       OptionsMethod mc = new OptionsMethod();
                       
  -                    if( params == null || params.length() == 0 )
  +                    if( params.empty() )
                       {
                           System.out.println("options <uri>");
                       }
                       else
                       {
  -                         mc.setPath( params );
  +                         mc.setPath( (String)params.pop() );
                            client.executeMethod( mc );
                            System.out.println( "Status: " + mc.getStatusCode() );
                            // Allowed methods
  @@ -283,6 +294,21 @@
                            System.out.println();
                       }
                   }
  +                else if( todo.equalsIgnoreCase("propfind") )
  +                {
  +                    PropFindMethod pf = new PropFindMethod();
  +                    
  +                    if( params.empty() )
  +                    {
  +                        System.out.println("propfind <uri>");
  +                    }
  +                    else
  +                    {
  +                         pf.setPath( (String)params.pop() );
  +                         client.executeMethod( pf );
  +                         System.out.println( "Status: " + pf.getStatusCode() );
  +                    }
  +                }
              }
              while (true );
     
  @@ -395,9 +421,12 @@
       {
           System.out.println("WebDAV Client commands:");
           System.out.println("  quit");
  -        System.out.println("  get <uri of file to fetch>");
  -        System.out.println("  put <uri of file to upload>");
  +        System.out.println("  get <uri>");
  +        System.out.println("  put <uri - source file> <uri - destination>");
           System.out.println("  options <uri>");
  +        System.out.println("  mkcol <uri>");
  +        System.out.println("  propfind <uri>");
  +        
       }
       
       
  @@ -417,7 +446,6 @@
           {
           }
       }
  -    
       
   }