maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r596182 - /maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
Date Mon, 19 Nov 2007 02:37:19 GMT
Author: jvanzyl
Date: Sun Nov 18 18:37:15 2007
New Revision: 596182

URL: http://svn.apache.org/viewvc?rev=596182&view=rev
Log:
o make the remote catalog use the wagon manager to take advantage of the already configured
proxies, otherwise
  she blows up with a proxied connection nice.

Modified:
    maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java

Modified: maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java?rev=596182&r1=596181&r2=596182&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
(original)
+++ maven/sandbox/trunk/archetypeng/archetypeng-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
Sun Nov 18 18:37:15 2007
@@ -22,11 +22,11 @@
 import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.settings.Settings;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.repository.Repository;
 
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
+import java.io.File;
+import java.io.FileReader;
 import java.util.List;
 import java.util.Properties;
 
@@ -58,17 +58,27 @@
             {
                 repository = repository.substring( 0, repository.length(  ) - 1 );
             }
-                        
-            URL url = new URL( repository + "/" + "archetype-catalog.xml" );
 
-            return createArchetypeMap( readCatalog( new InputStreamReader( url.openStream(
 ) ) ) );
-        }
-        catch ( MalformedURLException e )
-        {
-            throw new ArchetypeDataSourceException( "Invalid URL provided for archetype registry.",
e );
+            // We use wagon to take advantage of a Proxy that has already been setup in a
Maven environment.
+
+            Repository wagonRepository = new Repository( "archetype", repository );
+
+            Wagon wagon = wagonManager.getWagon( wagonRepository );
+
+            File catalog = File.createTempFile( "archetype-catalog", ".xml" );
+
+            wagon.connect( wagonRepository );
+
+            wagon.get( "archetype-catalog.xml", catalog );
+
+            wagon.disconnect();
+
+            return createArchetypeMap( readCatalog( new FileReader( catalog ) ) );
         }
-        catch ( IOException e )
+        catch ( Exception e )
         {
+            e.printStackTrace();
+
             throw new ArchetypeDataSourceException( "Error reading archetype registry.",
e );
         }
     }



Mime
View raw message