* under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.archiva.converter.ConversionListener;
import org.apache.maven.archiva.converter.RepositoryConversionException;
import org.apache.maven.archiva.discoverer.Discoverer;
try
{
- legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy", legacyRepositoryDirectory
- .toURI().toURL().toString(), legacyLayout, null, null );
-
- repository = artifactRepositoryFactory.createArtifactRepository( "default", repositoryDirectory.toURI()
- .toURL().toString(), defaultLayout, null, null );
+ String legacyRepositoryDir = legacyRepositoryDirectory.toURI().toURL().toString();
+ String repositoryDir = repositoryDirectory.toURI().toURL().toString();
+
+ //workaround for spaces non converted by PathUtils in wagon
+ //TODO: remove it when PathUtils will be fixed
+ if ( legacyRepositoryDir.indexOf( "%20" ) >= 0 )
+ {
+ legacyRepositoryDir = StringUtils.replace( legacyRepositoryDir, "%20", " " );
+ }
+ if ( repositoryDir.indexOf( "%20" ) >= 0 )
+ {
+ repositoryDir = StringUtils.replace( repositoryDir, "%20", " " );
+ }
+
+ legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy", legacyRepositoryDir,
+ legacyLayout, null, null );
+
+ repository = artifactRepositoryFactory.createArtifactRepository( "default", repositoryDir, defaultLayout,
+ null, null );
}
catch ( MalformedURLException e )
{
}
catch ( DiscovererException e )
{
- throw new RepositoryConversionException( "Unable to convert repository due to discoverer error:"
- + e.getMessage(), e );
+ throw new RepositoryConversionException(
+ "Unable to convert repository due to discoverer error:" + e.getMessage(), e );
}
}
/**
* Add a listener to the conversion process.
- *
+ *
* @param listener the listener to add.
*/
public void addConversionListener( ConversionListener listener )
/**
* Remove a listener from the conversion process.
- *
+ *
* @param listener the listener to remove.
*/
public void removeConversionListener( ConversionListener listener )
public ArtifactRepository createRepository( RepositoryConfiguration configuration )
{
- File repositoryDirectory = new File( configuration.getDirectory() );
- String repoDir = repositoryDirectory.toURI().toString();
-
- //workaround for spaces non converted by PathUtils in wagon
- //todo: remove it when PathUtils will be fixed
- if ( repoDir.indexOf( "%20" ) >= 0 )
- {
- repoDir = StringUtils.replace( repoDir, "%20", " " );
- }
-
- ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() );
- return repoFactory.createArtifactRepository( configuration.getId(), repoDir, layout, null, null );
+ return createRepository( configuration.getLayout(), configuration.getId(), configuration.getDirectory());
}
public ProxiedArtifactRepository createProxiedRepository( ProxiedRepositoryConfiguration configuration )
public ArtifactRepository createLocalRepository( Configuration configuration )
{
- ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( "default" );
- File localRepository = new File( configuration.getLocalRepository() );
- localRepository.mkdirs();
- return repoFactory.createArtifactRepository( "local", localRepository.toURI().toString(), layout, null, null );
+ return createRepository( "default", "local", configuration.getLocalRepository() );
+ }
+
+ public ArtifactRepository createRepository( String layout, String id, String directory )
+ {
+ ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) repositoryLayouts.get( layout );
+ File repository = new File( directory );
+ repository.mkdirs();
+
+ String repoDir = repository.toURI().toString();
+ //workaround for spaces non converted by PathUtils in wagon
+ //TODO: remove it when PathUtils will be fixed
+ if ( repoDir.indexOf( "%20" ) >= 0 )
+ {
+ repoDir = StringUtils.replace( repoDir, "%20", " " );
+ }
+
+ return repoFactory.createArtifactRepository( id, repoDir, repositoryLayout, null, null );
}
private static String getUpdatePolicy( String policy, int interval )