maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r952433 - /maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/
Date Mon, 07 Jun 2010 21:00:15 GMT
Author: hboutemy
Date: Mon Jun  7 21:00:15 2010
New Revision: 952433

URL: http://svn.apache.org/viewvc?rev=952433&view=rev
Log:
o removed dead code
o delete temp file after use

Removed:
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceDescriptor.java
Modified:
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceException.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
    maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSink.java
Mon Jun  7 21:00:15 2010
@@ -26,12 +26,9 @@ import java.util.Properties;
 /** @author Jason van Zyl */
 public interface ArchetypeDataSink
 {
-    void putArchetypes( List archetypes,
-                        Writer writer )
+    void putArchetypes( List archetypes, Writer writer )
         throws ArchetypeDataSinkException;
 
-    void putArchetypes( ArchetypeDataSource source,
-                        Properties properties,
-                        Writer writer )
+    void putArchetypes( ArchetypeDataSource source, Properties properties, Writer writer
)
         throws ArchetypeDataSourceException, ArchetypeDataSinkException;
 }

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSinkException.java
Mon Jun  7 21:00:15 2010
@@ -23,15 +23,14 @@ package org.apache.maven.archetype.sourc
 public class ArchetypeDataSinkException
     extends Exception
 {
-    public ArchetypeDataSinkException( String s )
+    public ArchetypeDataSinkException( String message )
     {
-        super( s );
+        super( message );
     }
 
-    public ArchetypeDataSinkException( String s,
-                                       Throwable throwable )
+    public ArchetypeDataSinkException( String message, Throwable throwable )
     {
-        super( s, throwable );
+        super( message, throwable );
     }
 
     public ArchetypeDataSinkException( Throwable throwable )

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSource.java
Mon Jun  7 21:00:15 2010
@@ -37,14 +37,9 @@ public interface ArchetypeDataSource
 {
     String ROLE = ArchetypeDataSource.class.getName();
 
-//    List getArchetypes( Properties properties )
-//        throws ArchetypeDataSourceException;
-
     ArchetypeCatalog getArchetypeCatalog( Properties properties )
         throws ArchetypeDataSourceException;
 
     void updateCatalog( Properties properties, Archetype archetype )
         throws ArchetypeDataSourceException;
-
-//    ArchetypeDataSourceDescriptor getDescriptor();
 }
\ No newline at end of file

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceException.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceException.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceException.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/ArchetypeDataSourceException.java
Mon Jun  7 21:00:15 2010
@@ -23,15 +23,14 @@ package org.apache.maven.archetype.sourc
 public class ArchetypeDataSourceException
     extends Exception
 {
-    public ArchetypeDataSourceException( String s )
+    public ArchetypeDataSourceException( String message )
     {
-        super( s );
+        super( message );
     }
 
-    public ArchetypeDataSourceException( String s,
-                                         Throwable throwable )
+    public ArchetypeDataSourceException( String message, Throwable throwable )
     {
-        super( s, throwable );
+        super( message, throwable );
     }
 
     public ArchetypeDataSourceException( Throwable throwable )

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSink.java
Mon Jun  7 21:00:15 2010
@@ -38,8 +38,7 @@ public class CatalogArchetypeDataSink
 {
     private ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
 
-    public void putArchetypes( List archetypes,
-                               Writer writer )
+    public void putArchetypes( List archetypes, Writer writer )
         throws ArchetypeDataSinkException
     {
         ArchetypeCatalog catalog = new ArchetypeCatalog();
@@ -65,9 +64,7 @@ public class CatalogArchetypeDataSink
         }
     }
 
-    public void putArchetypes( ArchetypeDataSource source,
-                               Properties properties,
-                               Writer writer )
+    public void putArchetypes( ArchetypeDataSource source, Properties properties, Writer
writer )
         throws ArchetypeDataSourceException, ArchetypeDataSinkException
     {
         List archetypes = source.getArchetypeCatalog( properties ).getArchetypes();

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/CatalogArchetypeDataSource.java
Mon Jun  7 21:00:15 2010
@@ -35,9 +35,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.Reader;
 import java.io.Writer;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Properties;
 
 /**
@@ -52,53 +50,13 @@ public class CatalogArchetypeDataSource
 
     public static final String ARCHETYPE_CATALOG_FILENAME = "archetype-catalog.xml";
 
-    private ArchetypeCatalogXpp3Reader catalogReader = new ArchetypeCatalogXpp3Reader();
-
-    private ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
-
     public static final File USER_HOME = new File( System.getProperty( "user.home" ) );
 
     public static final File MAVEN_CONFIGURATION = new File( USER_HOME, ".m2" );
 
     public static final File DEFAULT_ARCHETYPE_CATALOG = new File( MAVEN_CONFIGURATION, ARCHETYPE_CATALOG_FILENAME
);
 
-    public List getArchetypes( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        String s = properties.getProperty( ARCHETYPE_CATALOG_PROPERTY );
-
-        s = StringUtils.replace( s, "${user.home}", System.getProperty( "user.home" ) );
-
-        getLogger().debug( "Using catalog " + s );
-
-        File catalogFile = new File( s );
-
-        if ( catalogFile.exists() )
-        {
-
-            try
-            {
-                ArchetypeCatalog catalog = readCatalog( ReaderFactory.newXmlReader( catalogFile
) );
-
-                return createArchetypeMap( catalog );
-            }
-            catch ( FileNotFoundException e )
-            {
-                throw new ArchetypeDataSourceException( "The specific archetype catalog does
not exist.", e );
-            }
-            catch ( IOException e )
-            {
-                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
-            }
-        }
-        else
-        {
-            return new ArrayList();
-        }
-    }
-
-    public void updateCatalog( Properties properties,
-                               Archetype archetype )
+    public void updateCatalog( Properties properties, Archetype archetype )
         throws ArchetypeDataSourceException
     {
         String s = properties.getProperty( ARCHETYPE_CATALOG_PROPERTY );
@@ -139,8 +97,8 @@ public class CatalogArchetypeDataSource
         while ( !found && archetypes.hasNext() )
         {
             Archetype a = (Archetype) archetypes.next();
-            if ( a.getGroupId().equals( archetype.getGroupId() ) && a.getArtifactId().
-                equals( archetype.getArtifactId() ) )
+            if ( a.getGroupId().equals( archetype.getGroupId() )
+                && a.getArtifactId().equals( archetype.getArtifactId() ) )
             {
                 newArchetype = a;
                 found = true;
@@ -160,14 +118,51 @@ public class CatalogArchetypeDataSource
         writeLocalCatalog( catalog, catalogFile );
     }
 
-    protected void writeLocalCatalog( ArchetypeCatalog catalog,
-                                      File catalogFile )
+    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
+        throws ArchetypeDataSourceException
+    {
+        String s = properties.getProperty( ARCHETYPE_CATALOG_PROPERTY );
+
+        s = StringUtils.replace( s, "${user.home}", System.getProperty( "user.home" ) );
+
+        File catalogFile = new File( s );
+        if ( catalogFile.exists() && catalogFile.isDirectory() )
+        {
+            catalogFile = new File( catalogFile, ARCHETYPE_CATALOG_FILENAME );
+        }
+        getLogger().debug( "Using catalog " + catalogFile );
+
+        if ( catalogFile.exists() )
+        {
+            try
+            {
+                return readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
+            }
+            catch ( FileNotFoundException e )
+            {
+                throw new ArchetypeDataSourceException( "The specific archetype catalog does
not exist.", e );
+            }
+            catch ( IOException e )
+            {
+                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
+            }
+        }
+        else
+        {
+            return new ArchetypeCatalog();
+        }
+    }
+
+    protected void writeLocalCatalog( ArchetypeCatalog catalog, File catalogFile )
         throws ArchetypeDataSourceException
     {
         Writer writer = null;
         try
         {
             writer = WriterFactory.newXmlWriter( catalogFile );
+
+            ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
+
             catalogWriter.write( writer, catalog );
         }
         catch ( IOException e )
@@ -180,26 +175,13 @@ public class CatalogArchetypeDataSource
         }
     }
 
-    protected List createArchetypeMap( ArchetypeCatalog archetypeCatalog )
-        throws ArchetypeDataSourceException
-    {
-        List archetypes = new ArrayList();
-
-        for ( Iterator i = archetypeCatalog.getArchetypes().iterator(); i.hasNext(); )
-        {
-            Archetype archetype = (Archetype) i.next();
-
-            archetypes.add( archetype );
-        }
-
-        return archetypes;
-    }
-
     protected ArchetypeCatalog readCatalog( Reader reader )
         throws ArchetypeDataSourceException
     {
         try
         {
+            ArchetypeCatalogXpp3Reader catalogReader = new ArchetypeCatalogXpp3Reader();
+
             return catalogReader.read( reader );
         }
         catch ( IOException e )
@@ -215,52 +197,4 @@ public class CatalogArchetypeDataSource
             IOUtil.close( reader );
         }
     }
-
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        String s = properties.getProperty( ARCHETYPE_CATALOG_PROPERTY );
-
-        s = StringUtils.replace( s, "${user.home}", System.getProperty( "user.home" ) );
-
-        File catalogFile = new File( s );
-        if ( catalogFile.exists() && catalogFile.isDirectory() )
-        {
-            catalogFile = new File( catalogFile, ARCHETYPE_CATALOG_FILENAME );
-        }
-        getLogger().debug( "Using catalog " + catalogFile );
-
-        if ( catalogFile.exists() )
-        {
-
-            try
-            {
-                return readCatalog( ReaderFactory.newXmlReader( catalogFile ) );
-
-            }
-            catch ( FileNotFoundException e )
-            {
-                throw new ArchetypeDataSourceException( "The specific archetype catalog does
not exist.",
-                    e );
-            }
-            catch ( IOException e )
-            {
-                throw new ArchetypeDataSourceException( "Error reading archetype catalog.",
e );
-            }
-        }
-        else
-        {
-            return new ArchetypeCatalog();
-        }
-    }
-
-//    public ArchetypeDataSourceDescriptor getDescriptor()
-//    {
-//        ArchetypeDataSourceDescriptor d = new ArchetypeDataSourceDescriptor();
-//
-//        d.addParameter( ARCHETYPE_CATALOG_PROPERTY, String.class, DEFAULT_ARCHETYPE_CATALOG.getAbsolutePath(),
-//            "The repository URL where the archetype catalog resides." );
-//
-//        return d;
-//    }
 }
\ No newline at end of file

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/InternalCatalogArchetypeDataSource.java
Mon Jun  7 21:00:15 2010
@@ -23,8 +23,8 @@ import org.apache.maven.archetype.catalo
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.Reader;
-import java.util.List;
 import java.util.Properties;
 
 /**
@@ -40,8 +40,8 @@ public class InternalCatalogArchetypeDat
     {
         try
         {
-            Reader reader = ReaderFactory.newXmlReader(
-                getClass().getClassLoader().getResourceAsStream( "archetype-catalog.xml"
) );
+            InputStream in = getClass().getClassLoader().getResourceAsStream( ARCHETYPE_CATALOG_FILENAME
);
+            Reader reader = ReaderFactory.newXmlReader( in );
 
             return readCatalog( reader );
         }
@@ -50,28 +50,4 @@ public class InternalCatalogArchetypeDat
             throw new ArchetypeDataSourceException( "Error reading archetype catalog.", e
);
         }
     }
-
-    public List getArchetypes( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        try
-        {
-            Reader reader = ReaderFactory.newXmlReader(
-                getClass().getClassLoader().getResourceAsStream( "archetype-catalog.xml"
) );
-
-            return createArchetypeMap( readCatalog( reader ) );
-        }
-        catch ( IOException e )
-        {
-            throw new ArchetypeDataSourceException( "Error reading archetype catalog.", e
);
-        }
-    }
-
-//    public void updateCatalog( Properties properties,
-//                               Archetype archetype,
-//                               Settings settings )
-//        throws ArchetypeDataSourceException
-//    {
-//        throw new ArchetypeDataSourceException( "Not supported yet." );
-//    }
 }
\ No newline at end of file

Modified: maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java?rev=952433&r1=952432&r2=952433&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
(original)
+++ maven/archetype/trunk/archetype-common/src/main/java/org/apache/maven/archetype/source/RemoteCatalogArchetypeDataSource.java
Mon Jun  7 21:00:15 2010
@@ -31,7 +31,6 @@ import org.codehaus.plexus.util.ReaderFa
 
 import java.io.File;
 import java.io.IOException;
-import java.util.List;
 import java.util.Properties;
 
 /**
@@ -92,33 +91,6 @@ public class RemoteCatalogArchetypeDataS
         }
     }
 
-    public List getArchetypes( Properties properties )
-        throws ArchetypeDataSourceException
-    {
-        String repository = properties.getProperty( REPOSITORY_PROPERTY );
-
-        if ( repository == null )
-        {
-            throw new ArchetypeDataSourceException( "To use the remote catalog you must specify
the 'remote-catalog.repository' property correctly in your ~/.m2/archetype-catalog.properties
file." );
-        }
-
-        if ( repository.endsWith( "/" ) )
-        {
-            repository = repository.substring( 0, repository.length() - 1 );
-        }
-
-        try
-        {
-            ArchetypeCatalog catalog = downloadCatalog( repository, ARCHETYPE_CATALOG_FILENAME
);
-
-            return createArchetypeMap( catalog );
-        }
-        catch ( Exception e )
-        {
-            throw new ArchetypeDataSourceException( "Error reading archetype registry.",
e );
-        }
-    }
-
     public void updateCatalog( Properties properties, Archetype archetype )
         throws ArchetypeDataSourceException
     {
@@ -142,12 +114,14 @@ public class RemoteCatalogArchetypeDataS
         {
             wagon.connect( wagonRepository, authInfo, proxyInfo );
             wagon.get( filename, catalog );
+
+            return readCatalog( ReaderFactory.newXmlReader( catalog ) );
         }
         finally
         {
             disconnectWagon( wagon );
+            catalog.delete();
         }
-        return readCatalog( ReaderFactory.newXmlReader( catalog ) );
     }
 
     private void disconnectWagon( Wagon wagon )



Mime
View raw message