avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin/repository/impl/src/java/org/apache/avalon/repository/impl DefaultFileRepository.java HttpController.java
Date Mon, 15 Sep 2003 09:55:13 GMT
mcconnell    2003/09/15 02:55:13

  Modified:    merlin/repository/impl/src/java/org/apache/avalon/repository/impl
                        DefaultFileRepository.java HttpController.java
  Log:
  Add "...." messages to System.out when downloading content (special request from Alexis).
  
  Revision  Changes    Path
  1.4       +35 -8     avalon-sandbox/merlin/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFileRepository.java
  
  Index: DefaultFileRepository.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/repository/impl/src/java/org/apache/avalon/repository/impl/DefaultFileRepository.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultFileRepository.java	14 Sep 2003 13:07:15 -0000	1.3
  +++ DefaultFileRepository.java	15 Sep 2003 09:55:13 -0000	1.4
  @@ -174,29 +174,56 @@
           return m_base.toString();
       }
   
  +
      /**
       * Install a block archive into the repository.
       * @param url the block archive url
  -    * @param buffer a string buffer against which install messages may be logged
  +    * @param buffer a string buffer against which messages may be logged
       * @return the block manifest
       */
       public BlockManifest install( URL url, StringBuffer buffer ) throws RepositoryException
       {
  -        buffer.append( "install target: " + url );
  +        String path = url.getFile();
   
           try
           {
  +            File temp = File.createTempFile( "avalon-", "-bar" );
  +            temp.delete();
  +            HttpController.getFile( url.toString(), temp, true );
  +            temp.deleteOnExit();
  +            return expand( temp.toURL(), buffer );
  +        }
  +        catch( RepositoryException e )
  +        {
  +            throw e;
  +        }
  +        catch( Throwable e )
  +        {
  +            final String error = 
  +              "Cannot install target: " + url;
  +            throw new RepositoryException( error, e );
  +        }
  +    }
  +
  +   /**
  +    * Expand a block archive into the repository.
  +    * @param url the block archive url
  +    * @param buffer a string buffer against which messages may be logged
  +    * @return the block manifest
  +    */
  +    private BlockManifest expand( URL url, StringBuffer buffer ) throws RepositoryException
  +    {
  +        try
  +        {
               URL jurl = new URL( "jar:" + url.toString() + "!/" );
               JarURLConnection connection = (JarURLConnection) jurl.openConnection();
               BlockManifest manifest = 
                 new DefaultBlockManifest( connection.getManifest() );
               final String group = manifest.getBlockGroup();
   
  -            buffer.append( "\n  block group: " + group );
  +            buffer.append( "\nBlock Group: " + group );
               final File root = new File( m_base, group );
  -
  -            buffer.append( "\nInstall target: " + root );
  -
  +            buffer.append( "\nLocal target: " + root );
               JarFile jar = connection.getJarFile();
               Enumeration entries = jar.entries();
               while( entries.hasMoreElements() )
  @@ -207,7 +234,7 @@
                       installEntry( buffer, root, jar, entry );
                   }
               }
  -            buffer.append( "\nInstall sucessful." );
  +            buffer.append( "\nInstall successful." );
               return manifest;
           }
           catch( Throwable e )
  
  
  
  1.2       +4 -1      avalon-sandbox/merlin/repository/impl/src/java/org/apache/avalon/repository/impl/HttpController.java
  
  Index: HttpController.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin/repository/impl/src/java/org/apache/avalon/repository/impl/HttpController.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpController.java	11 Aug 2003 22:37:15 -0000	1.1
  +++ HttpController.java	15 Sep 2003 09:55:13 -0000	1.2
  @@ -202,11 +202,14 @@
           byte[] buffer = new byte[100 * 1024];
           int length;
   
  +        System.out.print( "Source: " + source + "\n");
           while ( ( length = is.read( buffer ) ) >= 0 )
           {
               fos.write( buffer, 0, length );
  +            System.out.print( "." );
           }
   
  +        System.out.println( "" );
           fos.close();
           is.close();
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message