* @author Edwin Punzalan
* @plexus.component role="org.apache.maven.repository.proxy.ProxyManager"
* @todo too much of wagon manager is reproduced here because checksums need to be downloaded separately - is that necessary?
- * @todo this isn't reusing the parts of wagon manager than handle snapshots [!]
+ * @todo this isn't reusing the parts of artifact resolver that handles snapshots - should this be more artifact based than file-based?
* @todo currently, cache must be in the same layout as the request, which prohibits any mapping
*/
public class DefaultProxyManager
*/
private ArtifactRepositoryFactory repositoryFactory;
- /**
- * @plexus.requirement
- */
- private ProxyConfiguration config;
-
/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Map repositoryLayoutMap;
- /**
- * A map
- */
private Map failuresCache = new HashMap();
+ private ProxyConfiguration config;
+
private static final int MS_PER_SEC = 1000;
/**
this.config = config;
}
- public ProxyConfiguration getConfiguration()
- {
- return config;
- }
-
/**
* @see org.apache.maven.repository.proxy.ProxyManager#get(String)
*/
File cachedFile = new File( cachePath, path );
if ( !cachedFile.exists() )
{
- cachedFile = getRemoteFile( path );
+ cachedFile = getAlways( path );
}
return cachedFile;
}
/**
- * @see org.apache.maven.repository.proxy.ProxyManager#getRemoteFile(String)
+ * @see org.apache.maven.repository.proxy.ProxyManager#getAlways(String)
*/
- public File getRemoteFile( String path )
+ public File getAlways( String path )
throws ProxyException, ResourceDoesNotExistException
{
checkConfiguration();
{
wagon = wagonManager.getWagon( repository.getProtocol() );
- //@todo configure wagonManager [!]
+ //@todo configure wagon (ssh settings, etc)
if ( useChecksum )
{
* Class used to bridge the servlet to the repository proxy implementation.
*
* @author Edwin Punzalan
- * @todo the names get() and getRemoteFile() are confusing [!]
*/
public interface ProxyManager
{
* @throws ResourceDoesNotExistException when the requested object can't be found in any of the
* configured repositories
*/
- File getRemoteFile( String path )
+ File getAlways( String path )
throws ProxyException, ResourceDoesNotExistException;
/**
* @param config the ProxyConfiguration to set the behavior of the proxy
*/
void setConfiguration( ProxyConfiguration config );
-
- /**
- * Used to retrieve the configuration describing the behavior of the proxy
- *
- * @return the ProxyConfiguration of this proxy
- */
- ProxyConfiguration getConfiguration();
}
{
private ProxyManager proxy;
+ private ProxyConfiguration configuration;
+
protected void setUp()
throws Exception
{
proxy = (ProxyManager) container.lookup( ProxyManager.ROLE );
- proxy.setConfiguration( getTestConfiguration() );
+ configuration = getTestConfiguration();
+ proxy.setConfiguration( configuration );
}
public void testExceptions()
File file = proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
//test cache
proxy.get( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar" );
public void testArtifactChecksum()
throws Exception
{
- //force the downlod from the remote repository, use getRemoteFile()
- File file = proxy.getRemoteFile( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar.md5" );
+ //force the downlod from the remote repository, use getAlways()
+ File file = proxy.getAlways( "/commons-logging/commons-logging/1.0/commons-logging-1.0.jar.md5" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithNoChecksum()
File file = proxy.get( "/not-standard/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithMD5Checksum()
File file = proxy.get( "/checksumed-md5/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithSHA1Checksum()
File file = proxy.get( "/checksumed-sha1/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
protected void tearDown()
private ProxyConfiguration getTestConfiguration()
throws ComponentLookupException
{
- ProxyConfiguration config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
+ ProxyConfiguration config = new ProxyConfiguration();
config.setRepositoryCachePath( "target/proxy-cache" );
{
private ProxyManager proxy;
+ private ProxyConfiguration configuration;
+
protected void setUp()
throws Exception
{
proxy = (ProxyManager) container.lookup( ProxyManager.ROLE );
- proxy.setConfiguration( getTestConfiguration() );
+ configuration = getTestConfiguration();
+ proxy.setConfiguration( configuration );
}
public void testExceptions()
File file = proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
assertTrue( "File must be downloaded: " + file.getAbsolutePath(), file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
//test cache
proxy.get( "/commons-logging/jars/commons-logging-1.0.jar" );
public void testArtifactChecksum()
throws Exception
{
- //force the downlod from the remote repository, use getRemoteFile()
- File file = proxy.getRemoteFile( "/commons-logging/jars/commons-logging-1.0.jar.md5" );
+ //force the downlod from the remote repository, use getAlways()
+ File file = proxy.getAlways( "/commons-logging/jars/commons-logging-1.0.jar.md5" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithNoChecksum()
File file = proxy.get( "/not-standard/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithMD5Checksum()
File file = proxy.get( "/checksumed-md5/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
public void testNonArtifactWithSHA1Checksum()
File file = proxy.get( "/checksumed-sha1/repository/file.txt" );
assertTrue( "File must be downloaded.", file.exists() );
assertTrue( "Downloaded file should be present in the cache.",
- file.getAbsolutePath().startsWith( proxy.getConfiguration().getRepositoryCachePath() ) );
+ file.getAbsolutePath().startsWith( configuration.getRepositoryCachePath() ) );
}
protected void tearDown()
private ProxyConfiguration getTestConfiguration()
throws ComponentLookupException
{
- ProxyConfiguration config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );
+ ProxyConfiguration config = new ProxyConfiguration();
config.setRepositoryCachePath( getTestFile( "target/m1-proxy-cache" ).getAbsolutePath() );
{\r
super.setUp();\r
\r
- config = (ProxyConfiguration) container.lookup( ProxyConfiguration.ROLE );\r
+ config = new ProxyConfiguration();\r
}\r
\r
public void testRepositoryCache()\r