brett       2005/04/13 05:32:26

  Modified:    maven-mboot2/src/main/java/download ArtifactDownloader.java
                        HttpUtils.java
  Log:
  turn off caching in mboot for snapshot version files
  
  Revision  Changes    Path
  1.16      +1 -1      
maven-components/maven-mboot2/src/main/java/download/ArtifactDownloader.java
  
  Index: ArtifactDownloader.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-mboot2/src/main/java/download/ArtifactDownloader.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ArtifactDownloader.java   13 Apr 2005 07:03:18 -0000      1.15
  +++ ArtifactDownloader.java   13 Apr 2005 12:32:26 -0000      1.16
  @@ -173,7 +173,7 @@
                       try
                       {
                           HttpUtils.getFile( metaUrl, new File( filename ), 
ignoreErrors, useTimestamp, proxyHost,
  -                                           proxyPort, proxyUserName, 
proxyPassword, true );
  +                                           proxyPort, proxyUserName, 
proxyPassword, false );
                           String version = FileUtils.fileRead( filename );
                           log( "Resolved version: " + version );
                           version = version.substring( version.lastIndexOf( 
"-", version.lastIndexOf( "-" ) - 1 ) + 1 );
  
  
  
  1.2       +19 -53    
maven-components/maven-mboot2/src/main/java/download/HttpUtils.java
  
  Index: HttpUtils.java
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-mboot2/src/main/java/download/HttpUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpUtils.java    5 Dec 2004 04:12:24 -0000       1.1
  +++ HttpUtils.java    13 Apr 2005 12:32:26 -0000      1.2
  @@ -52,9 +52,7 @@
        * @throws SecurityException if an operation is not authorized by the
        *                           SecurityManager
        */
  -    public static void useProxyUser( final String proxyHost,
  -                                     final String proxyPort,
  -                                     final String proxyUserName,
  +    public static void useProxyUser( final String proxyHost, final String 
proxyPort, final String proxyUserName,
                                        final String proxyPassword )
       {
           if ( proxyHost != null && proxyPort != null )
  @@ -70,7 +68,8 @@
                       protected PasswordAuthentication 
getPasswordAuthentication()
                       {
                           return new PasswordAuthentication( proxyUserName,
  -                                                           proxyPassword == 
null ? new char[0] : proxyPassword.toCharArray() );
  +                                                           proxyPassword == 
null
  +                                                           ? new char[0] : 
proxyPassword.toCharArray() );
                       }
                   } );
               }
  @@ -97,26 +96,13 @@
        *                        artifact if it is available.
        * @throws IOException If an I/O exception occurs.
        */
  -    public static void getFile( String url,
  -                                File destinationFile,
  -                                boolean ignoreErrors,
  -                                boolean useTimestamp,
  -                                String proxyHost,
  -                                String proxyPort,
  -                                String proxyUserName,
  -                                String proxyPassword,
  +    public static void getFile( String url, File destinationFile, boolean 
ignoreErrors, boolean useTimestamp,
  +                                String proxyHost, String proxyPort, String 
proxyUserName, String proxyPassword,
                                   boolean useChecksum )
           throws IOException
       {
           // Get the requested file.
  -        getFile( url,
  -                 destinationFile,
  -                 ignoreErrors,
  -                 useTimestamp,
  -                 proxyHost,
  -                 proxyPort,
  -                 proxyUserName,
  -                 proxyPassword );
  +        getFile( url, destinationFile, ignoreErrors, useTimestamp, 
proxyHost, proxyPort, proxyUserName, proxyPassword );
   
           // Get the checksum if requested.
           if ( useChecksum )
  @@ -125,13 +111,7 @@
   
               try
               {
  -                getFile( url + ".md5",
  -                         checksumFile,
  -                         ignoreErrors,
  -                         useTimestamp,
  -                         proxyHost,
  -                         proxyPort,
  -                         proxyUserName,
  +                getFile( url + ".md5", checksumFile, ignoreErrors, 
useTimestamp, proxyHost, proxyPort, proxyUserName,
                            proxyPassword );
               }
               catch ( Exception e )
  @@ -160,14 +140,8 @@
        *                        or null
        * @throws IOException If an I/O exception occurs.
        */
  -    public static void getFile( String url,
  -                                File destinationFile,
  -                                boolean ignoreErrors,
  -                                boolean useTimestamp,
  -                                String proxyHost,
  -                                String proxyPort,
  -                                String proxyUserName,
  -                                String proxyPassword )
  +    public static void getFile( String url, File destinationFile, boolean 
ignoreErrors, boolean useTimestamp,
  +                                String proxyHost, String proxyPort, String 
proxyUserName, String proxyPassword )
           throws IOException
       {
           //set the timestamp to the file date.
  @@ -179,13 +153,7 @@
   
           try
           {
  -            getFile( url,
  -                     destinationFile,
  -                     timestamp,
  -                     proxyHost,
  -                     proxyPort,
  -                     proxyUserName,
  -                     proxyPassword );
  +            getFile( url, destinationFile, timestamp, proxyHost, proxyPort, 
proxyUserName, proxyPassword );
           }
           catch ( IOException ex )
           {
  @@ -212,13 +180,8 @@
        *                        or null
        * @throws IOException If an I/O exception occurs.
        */
  -    public static void getFile( String url,
  -                                File destinationFile,
  -                                long timestamp,
  -                                String proxyHost,
  -                                String proxyPort,
  -                                String proxyUserName,
  -                                String proxyPassword )
  +    public static void getFile( String url, File destinationFile, long 
timestamp, String proxyHost, String proxyPort,
  +                                String proxyUserName, String proxyPassword )
           throws IOException
       {
           String[] s = parseUrl( url );
  @@ -247,6 +210,8 @@
               connection.setRequestProperty( "Authorization", "Basic " + 
encoding );
           }
   
  +        connection.setUseCaches( timestamp >= 0 );
  +
           //connect to the remote site (may take some time)
           connection.connect();
           //next test for a 304 result (HTTP only)
  @@ -258,8 +223,10 @@
               // test for 404 ourselves, and throw FileNotFoundException as 
needed
               if ( httpConnection.getResponseCode() == 
HttpURLConnection.HTTP_NOT_FOUND )
               {
  -                throw new FileNotFoundException( url.toString() + " (HTTP 
Error: "
  -                                                 + 
httpConnection.getResponseCode() + " " + httpConnection.getResponseMessage() + 
")" );
  +                throw new FileNotFoundException(
  +                    url.toString() + " (HTTP Error: " + 
httpConnection.getResponseCode() + " " +
  +                    httpConnection.getResponseMessage() +
  +                    ")" );
               }
               if ( httpConnection.getResponseCode() == 
HttpURLConnection.HTTP_NOT_MODIFIED )
               {
  @@ -301,8 +268,7 @@
               throw isException;
           }
   
  -        if ( connection.getLastModified() <= timestamp &&
  -            connection.getLastModified() != 0 )
  +        if ( connection.getLastModified() <= timestamp && 
connection.getLastModified() != 0 )
           {
               return;
           }
  
  
  

Reply via email to