Author: jvanzyl
Date: Sat Nov  4 02:17:41 2006
New Revision: 471157

URL: http://svn.apache.org/viewvc?view=rev&rev=471157
Log:
o use a properties file for the repository conversion

Modified:
    
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/Cli.java
    
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/CliManager.java

Modified: 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/Cli.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/Cli.java?view=diff&rev=471157&r1=471156&r2=471157
==============================================================================
--- 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/Cli.java
 (original)
+++ 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/Cli.java
 Sat Nov  4 02:17:41 2006
@@ -31,6 +31,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.util.Properties;
 import java.util.List;
 import java.util.Arrays;
@@ -44,6 +45,12 @@
  */
 public class Cli
 {
+    public static final String SOURCE_REPO_PATH = "sourceRepositoryPath";
+
+    public static final String TARGET_REPO_PATH = "targetRepositoryPath";
+
+    public static final String BLACKLISTED_PATTERNS = "blacklistPatterns";
+
     public static void main( String[] args )
     {
         ClassWorld classWorld = new ClassWorld( "plexus.core", 
Thread.currentThread().getContextClassLoader() );
@@ -154,41 +161,43 @@
 
             if ( cli.hasOption( CliManager.CONVERT ) )
             {
-                if ( cli.hasOption( CliManager.OLD_REPOSITORY_PATH ) &&
-                    cli.hasOption( CliManager.NEW_REPOSITORY_PATH ) )
+                Properties p = new Properties();
+
+                try
                 {
-                    File oldRepositoryPath = new File( cli.getOptionValue( 
CliManager.OLD_REPOSITORY_PATH ) );
+                    p.load( new FileInputStream( cli.getOptionValue( 
CliManager.CONVERT ) ) );
+                }
+                catch ( IOException e )
+                {
+                    showFatalError( "Cannot find properties file which 
describes the conversion.", e, true );
+                }
 
-                    File newRepositoryPath = new File( cli.getOptionValue( 
CliManager.NEW_REPOSITORY_PATH ) );
+                File oldRepositoryPath = new File( p.getProperty( 
SOURCE_REPO_PATH ) );
 
-                    System.out.println( "Converting " + oldRepositoryPath + " 
to " + newRepositoryPath );
+                File newRepositoryPath = new File( p.getProperty( 
TARGET_REPO_PATH ) );
 
-                    List blacklistedPatterns = null;
+                System.out.println( "Converting " + oldRepositoryPath + " to " 
+ newRepositoryPath );
 
-                    if ( cli.hasOption( CliManager.BLACKLISTED_PATTERNS ) )
-                    {
-                        blacklistedPatterns = Arrays.asList( 
StringUtils.split( cli.getOptionValue( CliManager.BLACKLISTED_PATTERNS ), "," ) 
);
-                    }
+                List blacklistedPatterns = null;
 
-                    try
-                    {
-                        archiva.convertLegacyRepository( oldRepositoryPath, 
newRepositoryPath, blacklistedPatterns, true );
-                    }
-                    catch ( RepositoryConversionException e )
-                    {
-                        showFatalError( "", e, true );
-                    }
-                    catch ( DiscovererException e )
-                    {
-                        showFatalError( "", e, true );
-                    }
-                }
-                else
+                String s = p.getProperty( BLACKLISTED_PATTERNS );
+
+                if ( s != null )
                 {
-                    System.out.println(
-                        "You need to specify both a repository to convert and 
the path for the repository that will be created." );
+                    blacklistedPatterns = Arrays.asList( StringUtils.split( s, 
"," ) );
+                }
 
-                    cliManager.displayHelp();
+                try
+                {
+                    archiva.convertLegacyRepository( oldRepositoryPath, 
newRepositoryPath, blacklistedPatterns, true );
+                }
+                catch ( RepositoryConversionException e )
+                {
+                    showFatalError( "Error converting repository.", e, true );
+                }
+                catch ( DiscovererException e )
+                {
+                    showFatalError( "Error discovery artifacts to convert.", 
e, true );
                 }
             }
 
@@ -206,8 +215,8 @@
     }
 
     private static int showFatalError( String message,
-                                        Exception e,
-                                        boolean show )
+                                       Exception e,
+                                       boolean show )
     {
         System.err.println( "FATAL ERROR: " + message );
 

Modified: 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/CliManager.java
URL: 
http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/CliManager.java?view=diff&rev=471157&r1=471156&r2=471157
==============================================================================
--- 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/CliManager.java
 (original)
+++ 
maven/archiva/trunk/archiva-cli/src/main/java/org/apache/maven/archiva/cli/CliManager.java
 Sat Nov  4 02:17:41 2006
@@ -19,12 +19,6 @@
 {
     public static char CONVERT = 'c';
 
-    public static final char OLD_REPOSITORY_PATH = 'o';
-
-    public static final char NEW_REPOSITORY_PATH = 'n';
-
-    public static final char BLACKLISTED_PATTERNS = 'b';
-
     // 
----------------------------------------------------------------------------
     // These are standard options that we would want to use for all our 
projects.
     // 
----------------------------------------------------------------------------
@@ -47,17 +41,10 @@
     {
         options = new Options();
 
-        options.addOption( OptionBuilder.withLongOpt( "convert" 
).withDescription(
-            "Convert a legacy Maven 1.x repository to a Maven 2.x repository." 
).create( CONVERT ) );
-
-        options.addOption( OptionBuilder.withLongOpt( "old-repo" 
).hasArg().withDescription(
-            "Path to Maven 1.x legacy repository to convert." ).create( 
OLD_REPOSITORY_PATH ) );
-
-        options.addOption( OptionBuilder.withLongOpt( "new-repo" 
).hasArg().withDescription(
-            "Path to newly created Maven 2.x repository." ).create( 
NEW_REPOSITORY_PATH ) );
-
-        options.addOption( OptionBuilder.withLongOpt( "new-repo" 
).hasArg().withDescription(
-            "Path to newly created Maven 2.x repository." ).create( 
BLACKLISTED_PATTERNS  ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "convert" ).hasArg().withDescription(
+            "Convert a legacy Maven 1.x repository to a Maven 2.x repository 
using a properties file to describe the conversion." )
+                .create( CONVERT ) );
     }
 
     public CommandLine parse( String[] args )


Reply via email to