cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1196061 - /cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java
Date Tue, 01 Nov 2011 15:35:27 GMT
Author: simonetripodi
Date: Tue Nov  1 15:35:26 2011
New Revision: 1196061

URL: http://svn.apache.org/viewvc?rev=1196061&view=rev
Log:
first draft of program execution

Modified:
    cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java

Modified: cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java?rev=1196061&r1=1196060&r2=1196061&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java (original)
+++ cocoon/cocoon3/trunk/cocoon-cli/src/main/java/org/apache/cocoon/cli/Main.java Tue Nov
 1 15:35:26 2011
@@ -18,11 +18,16 @@
  */
 package org.apache.cocoon.cli;
 
+import static java.lang.String.format;
+
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Date;
 import java.util.Properties;
 
+import org.apache.cocoon.pipeline.Pipeline;
+import org.apache.cocoon.sax.SAXPipelineComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -131,6 +136,15 @@ public final class Main
             // StatusPrinter should handle this
         }
 
+        File pipelineDescriptor = options.getPipelineDescriptor();
+        if ( pipelineDescriptor == null
+                        || !pipelineDescriptor.exists()
+                        || pipelineDescriptor.isDirectory() )
+        {
+            System.err.println( "'c3p.xml' file does not exist!" );
+            System.exit( -1 );
+        }
+
         logger.info( "" );
         logger.info( "------------------------------------------------------------------------"
);
         logger.info( "Apache Cocoon 3" );
@@ -143,7 +157,52 @@ public final class Main
         Throwable error = null;
         try
         {
-            // FIXME add program execution
+            PipelinesRegistry registry = new PipelineDescriptorParser( options.isPipesHelp()
).parse( pipelineDescriptor );
+
+            if ( !options.isPipesHelp() )
+            {
+                if ( !options.getPipelineIDs().isEmpty() )
+                {
+                    for ( String id : options.getPipelineIDs() )
+                    {
+                        logger.info( "Executing pipeline '{}'...", id );
+
+                        Pipeline<SAXPipelineComponent> pipeline = registry.getPipeline(
id );
+
+                        if ( pipeline == null )
+                        {
+                            throw new NullPointerException( format( "Pipeline '%s' not found!",
id ) );
+                        }
+
+                        pipeline.setup( System.out );
+                        pipeline.execute();
+
+                        logger.info( "Pipeline '{}' executed", id );
+                    }
+                }
+                else
+                {
+                    if ( registry.getDefaultId() == null )
+                    {
+                        throw new NullPointerException( "Default pipeline not specified,
no pipeline executed!" );
+                    }
+
+                    logger.info( "Executing default Pipeline '{}'", registry.getDefaultId()
);
+
+                    Pipeline<SAXPipelineComponent> pipeline = registry.getDefaultPipeline();
+
+                    if ( pipeline == null )
+                    {
+                        throw new NullPointerException( format( "Default pipeline '%s' not
found!", registry.getDefaultId() ) );
+                    }
+
+                    pipeline.setup( System.out );
+                    pipeline.execute();
+
+                    logger.info( "Default pipeline '{}' executed", registry.getDefaultId()
);
+                }
+            }
+
         }
         catch ( Throwable t )
         {



Mime
View raw message