]> source.dussan.org Git - archiva.git/commitdiff
Remove %20 in directories name when they contain spaces
authorEmmanuel Venisse <evenisse@apache.org>
Mon, 26 Feb 2007 16:07:53 +0000 (16:07 +0000)
committerEmmanuel Venisse <evenisse@apache.org>
Mon, 26 Feb 2007 16:07:53 +0000 (16:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@511870 13f79535-47bb-0310-9956-ffa450edef68

archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
archiva-core/src/main/java/org/apache/maven/archiva/configuration/DefaultConfiguredRepositoryFactory.java

index 469cc33e30ac019f2b10ab7e581d267381473178..abf303bcbb49ad2e0c84e5b1473c286012b46804 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.maven.archiva.converter.legacy;
  * 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;
@@ -76,11 +77,25 @@ public class DefaultLegacyRepositoryConverter
 
         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 )
         {
@@ -97,14 +112,14 @@ public class DefaultLegacyRepositoryConverter
         }
         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 )
@@ -114,7 +129,7 @@ public class DefaultLegacyRepositoryConverter
 
     /**
      * Remove a listener from the conversion process.
-     * 
+     *
      * @param listener the listener to remove.
      */
     public void removeConversionListener( ConversionListener listener )
index 57512439688bde5fc581bf2b5f94e7b7b29f6e7d..4c7e05e5ac298266be6b065dd8891e57f1b80fd6 100644 (file)
@@ -53,18 +53,7 @@ public class DefaultConfiguredRepositoryFactory
 
     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 )
@@ -126,10 +115,24 @@ public class DefaultConfiguredRepositoryFactory
 
     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 )