You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2003/12/03 21:41:53 UTC
cvs commit: avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util LOADER.java
mcconnell 2003/12/03 12:41:53
Modified: repository/util/src/java/org/apache/avalon/repository/util
LOADER.java
Log:
Add support for SNAPSHOT handling.
Revision Changes Path
1.5 +28 -35 avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/LOADER.java
Index: LOADER.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/repository/util/src/java/org/apache/avalon/repository/util/LOADER.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LOADER.java 30 Nov 2003 08:11:37 -0000 1.4
+++ LOADER.java 3 Dec 2003 20:41:53 -0000 1.5
@@ -104,9 +104,6 @@
File destination = new File( root, artifact.getPath() );
- /*
- * Don't fail fast - keep trying until we get something.
- */
for ( int i = 0; i < repositories.length; i++ )
{
try
@@ -120,20 +117,7 @@
}
}
- if( destination.exists() )
- {
- try
- {
- return destination.toURL();
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to create a url from the file: "
- + destination;
- throw new RepositoryException( error, e );
- }
- }
+ if( destination.exists() ) return getURL( destination );
StringBuffer buffer = new StringBuffer();
buffer.append(
@@ -180,9 +164,6 @@
File destination = new File( root, artifact.getPath() + "." + mime );
- /*
- * Don't fail fast - keep trying until we get something.
- */
for ( int i = 0; i < repositories.length; i++ )
{
try
@@ -196,20 +177,7 @@
}
}
- if( destination.exists() )
- {
- try
- {
- return destination.toURL();
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to create a url from the file: "
- + destination;
- throw new RepositoryException( error, e );
- }
- }
+ if( destination.exists() ) return getURL( destination );
StringBuffer buffer = new StringBuffer();
buffer.append(
@@ -276,6 +244,11 @@
}
}
+ if( destination.exists() && !isSnapshot( destination ) )
+ {
+ return getURL( destination );
+ }
+
//
// otherwise continue with classic processing
//
@@ -421,5 +394,25 @@
}
}
return destination.toURL();
+ }
+
+ private static boolean isSnapshot( File file )
+ {
+ return file.getName().endsWith( "SNAPSHOT" );
+ }
+
+ private static URL getURL( File file ) throws RepositoryException
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to create a url from the file: "
+ + file;
+ throw new RepositoryException( error, e );
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org