geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r348407 - in /geronimo/gbuild/trunk: gbuild-agent-application/src/conf/application.xml gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java
Date Wed, 23 Nov 2005 10:19:37 GMT
Author: dblevins
Date: Wed Nov 23 02:19:30 2005
New Revision: 348407

URL: http://svn.apache.org/viewcvs?rev=348407&view=rev
Log:
Changed log levels and added different checking in start()

Modified:
    geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java

Modified: geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml?rev=348407&r1=348406&r2=348407&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml (original)
+++ geronimo/gbuild/trunk/gbuild-agent-application/src/conf/application.xml Wed Nov 23 02:19:30
2005
@@ -203,7 +203,7 @@
           </level>
           <level>
             <hierarchy>org.apache.geronimo.gbuild.agent.BuildResultsExtention:write-include-file</hierarchy>
-            <level>INFO</level>
+            <level>DEBUG</level>
           </level>
           <level>
             <hierarchy>org.apache.geronimo.gbuild.agent.BuildAgentExtention:file-include</hierarchy>

Modified: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java
URL: http://svn.apache.org/viewcvs/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java?rev=348407&r1=348406&r2=348407&view=diff
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java
(original)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/WriteIncludeFileExtention.java
Wed Nov 23 02:19:30 2005
@@ -20,14 +20,14 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
 
-import java.util.Map;
-import java.util.Iterator;
-import java.util.Date;
-import java.util.HashMap;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 /**
  * @version $Rev$ $Date$
@@ -77,11 +77,20 @@
         template = new StringTemplate(fileNameTemplate);
         directory = new File(resultsDirectory);
         directory.mkdirs();
-        assert directory.exists(): "File specified does not exist. " + directory.getAbsolutePath();
-        assert directory.isDirectory(): "File specified is not a directory. " + directory.getAbsolutePath();
-        assert directory.canWrite(): "Directory specified is not writable. " + directory.getAbsolutePath();
 
-        getLogger().info("Include files will be written to "+directory.getAbsolutePath());
+        if (!directory.exists()) {
+            throw new IllegalStateException("File specified does not exist. " + directory.getAbsolutePath());
+        }
+
+        if (!directory.isDirectory()) {
+            throw new IllegalStateException("File specified is not a directory. " + directory.getAbsolutePath());
+        }
+
+        if (!directory.canWrite()) {
+            throw new IllegalStateException("Directory specified is not writable. " + directory.getAbsolutePath());
+        }
+
+        getLogger().info("Include files will be written to " + directory.getAbsolutePath());
         dateFormatter = new SimpleDateFormat(dateFormat);
     }
 
@@ -89,7 +98,7 @@
     }
 
     public void execute(Map context) throws Exception {
-        getLogger().debug("Pattern "+includePattern);
+        getLogger().debug("Pattern " + includePattern);
         Map map = new HashMap();
         map.putAll(context);
         map.put("date", dateFormatter.format(new Date()));
@@ -99,16 +108,16 @@
             String key = (String) entry.getKey();
             Object value = entry.getValue();
 
-            if (key.matches(includePattern)){
+            if (key.matches(includePattern)) {
                 try {
-                    getLogger().debug("Found include pattern "+key);
+                    getLogger().debug("Found include pattern " + key);
                     String fileName = template.apply(map);
                     File file = new File(directory, fileName);
                     File parent = file.getParentFile();
                     parent.mkdirs();
-                    write(file, (String)value);
+                    write(file, (String) value);
                 } catch (Exception e) {
-                    getLogger().warn("Abnormal failure on header "+key, e);
+                    getLogger().warn("Abnormal failure on header " + key, e);
                 }
             }
         }
@@ -117,13 +126,13 @@
 
     private void write(File file, String content) {
         try {
-            getLogger().info("Writing "+content.length()+" characters to "+file.getAbsolutePath());
+            getLogger().info("Writing " + content.length() + " characters to " + file.getAbsolutePath());
             FileOutputStream out = new FileOutputStream(file);
             out.write(content.getBytes());
             out.flush();
             out.close();
         } catch (IOException e) {
-            getLogger().error("Could not write to file "+file.getAbsolutePath(), e);
+            getLogger().error("Could not write to file " + file.getAbsolutePath(), e);
         }
     }
 }



Mime
View raw message