continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tryg...@apache.org
Subject svn commit: r366256 - /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Date Thu, 05 Jan 2006 19:34:52 GMT
Author: trygvis
Date: Thu Jan  5 11:34:39 2006
New Revision: 366256

URL: http://svn.apache.org/viewcvs?rev=366256&view=rev
Log:
o Cleaning up some IDEA warnings.

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=366256&r1=366255&r2=366256&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Thu Jan  5 11:34:39 2006
@@ -308,7 +308,7 @@
     public void buildProjects( int trigger )
         throws ContinuumException
     {
-        Collection projectsList = null;
+        Collection projectsList;
 
         try
         {
@@ -341,7 +341,7 @@
     public void buildProjects( Schedule schedule )
         throws ContinuumException
     {
-        Collection projectsList = null;
+        Collection projectsList;
         Map projectsMap = null;
 
         try
@@ -478,7 +478,7 @@
     public List getChangesSinceLastSuccess( int projectId, int buildResultId )
         throws ContinuumException
     {
-        ArrayList buildResults = null;
+        ArrayList buildResults;
 
         try
         {
@@ -552,7 +552,7 @@
     }
 
     private List getProjectsInBuildOrder( Collection projects )
-        throws CycleDetectedException, ContinuumException
+        throws CycleDetectedException
     {
         if ( projects == null || projects.isEmpty() )
         {
@@ -1043,7 +1043,7 @@
 
         buildDefinition.setArguments( (String) configuration.get( "arguments" ) );
 
-        Schedule schedule = getSchedule( new Integer( (String) configuration.get( "schedule"
) ).intValue() );
+        Schedule schedule = getSchedule( Integer.parseInt( (String) configuration.get( "schedule"
) ) );
 
         buildDefinition.setSchedule( schedule );
 
@@ -1098,7 +1098,7 @@
 
         buildDefinition.setArguments( (String) configuration.get( "arguments" ) );
 
-        Schedule schedule = getSchedule( new Integer( (String) configuration.get( "schedule"
) ).intValue() );
+        Schedule schedule = getSchedule( Integer.parseInt( (String) configuration.get( "schedule"
) ) );
 
         buildDefinition.setSchedule( schedule );
 
@@ -1164,32 +1164,31 @@
     public void addSchedule( Schedule schedule )
         throws ContinuumException
     {
-        Schedule s = null;
+        Schedule s;
 
         try
         {
             s = store.getScheduleByName( schedule.getName() );
+
+            if ( s == null )
+            {
+                throw logAndCreateException( "Can't create schedule. A schedule with the
same name already exists.", null );
+            }
+
+            s = store.addSchedule( schedule );
         }
         catch ( ContinuumStoreException e )
         {
+            throw logAndCreateException( "Error while accessing the store.", e );
         }
 
-        if ( s == null )
+        try
         {
-            s = store.addSchedule( schedule );
-
-            try
-            {
-                schedulesActivator.activateSchedule( s, this );
-            }
-            catch ( SchedulesActivationException e )
-            {
-                throw new ContinuumException( "Error activating schedule " + s.getName()
+ ".", e );
-            }
+            schedulesActivator.activateSchedule( s, this );
         }
-        else
+        catch ( SchedulesActivationException e )
         {
-            throw logAndCreateException( "Can't create schedule. A schedule with the same
name already exists.", null );
+            throw new ContinuumException( "Error activating schedule " + s.getName() + ".",
e );
         }
     }
 
@@ -1238,9 +1237,9 @@
 
         schedule.setCronExpression( (String) configuration.get( "schedule.cronExpression"
) );
 
-        schedule.setDelay( new Integer( (String) configuration.get( "schedule.delay" ) ).intValue()
);
+        schedule.setDelay( Integer.parseInt( (String) configuration.get( "schedule.delay"
) ) );
 
-        schedule.setActive( new Boolean( (String) configuration.get( "schedule.active" )
).booleanValue() );
+        schedule.setActive( Boolean.valueOf( (String) configuration.get( "schedule.active"
) ).booleanValue() );
 
         updateSchedule( schedule, true );
     }
@@ -1323,11 +1322,11 @@
     {
         List dirs = new ArrayList();
 
-        File workingDirectory = null;
+        File workingDirectory;
 
         if ( currentSubDirectory != null )
         {
-            workingDirectory = new File( baseDirectory, currentSubDirectory);
+            workingDirectory = new File( baseDirectory, currentSubDirectory );
         }
         else
         {
@@ -1340,17 +1339,17 @@
         {
             for ( int i = 0; i < files.length; i++ )
             {
-                File current = new File( workingDirectory, files[i] );
+                File current = new File( workingDirectory, files[ i ] );
 
-                String currentFile = null;
+                String currentFile;
 
                 if ( currentSubDirectory == null )
                 {
-                    currentFile = files[i];
+                    currentFile = files[ i ];
                 }
                 else
                 {
-                    currentFile = currentSubDirectory + "/" + files[i];
+                    currentFile = currentSubDirectory + "/" + files[ i ];
                 }
 
                 if ( userDirectory != null && current.isDirectory() && userDirectory.startsWith(
currentFile ) )
@@ -1490,7 +1489,7 @@
 
         user.setEmail( (String) configuration.get( "user.email" ) );
 
-        user.setGroup( getUserGroup( new Integer( (String) configuration.get( "user.group"
) ).intValue() ) );
+        user.setGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
 
         addUser( user );
     }
@@ -1521,7 +1520,7 @@
 
         user.setEmail( (String) configuration.get( "user.email" ) );
 
-        user.setGroup( getUserGroup( new Integer( (String) configuration.get( "user.group"
) ).intValue() ) );
+        user.setGroup( getUserGroup( Integer.parseInt( (String) configuration.get( "user.group"
) ) ) );
 
         updateUser( user );
     }
@@ -1727,18 +1726,6 @@
         store.removeUserGroup( group );
     }
 
-    private boolean convertBoolean( String value )
-    {
-        if ( "true".equalsIgnoreCase( value ) || "on".equalsIgnoreCase( value ) || "yes".equalsIgnoreCase(
value ) )
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
     // ----------------------------------------------------------------------
     // Lifecycle Management
     // ----------------------------------------------------------------------
@@ -1986,61 +1973,6 @@
         return workingDirectory;
     }
 
-    private void startMessage()
-    {
-        getLogger().info( "Starting Continuum." );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        String banner = StringUtils.repeat( "-", getVersion().length() );
-
-        getLogger().info( "" );
-        getLogger().info( "" );
-        getLogger().info( "< Continuum " + getVersion() + " started! >" );
-        getLogger().info( "-----------------------" + banner );
-        getLogger().info( "       \\   ^__^" );
-        getLogger().info( "        \\  (oo)\\_______" );
-        getLogger().info( "           (__)\\       )\\/\\" );
-        getLogger().info( "               ||----w |" );
-        getLogger().info( "               ||     ||" );
-        getLogger().info( "" );
-        getLogger().info( "" );
-    }
-
-    private void stopMessage()
-    {
-        getLogger().info( "Stopping Continuum." );
-
-        getLogger().info( "Continuum stopped." );
-    }
-
-    private String getVersion()
-    {
-        try
-        {
-            Properties properties = new Properties();
-
-            String name = "META-INF/maven/org.apache.maven.continuum/continuum-core/pom.properties";
-
-            InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(
name );
-
-            if ( resourceAsStream == null )
-            {
-                return "unknown";
-            }
-
-            properties.load( resourceAsStream );
-
-            return properties.getProperty( "version", "unknown" );
-        }
-        catch ( IOException e )
-        {
-            return "unknown";
-        }
-    }
-
     public Project getProjectWithCheckoutResult( int projectId )
         throws ContinuumException
     {
@@ -2094,6 +2026,77 @@
         catch ( ContinuumStoreException e )
         {
             throw new ContinuumException( "Error retrieving the requested project", e );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Private Utilities
+    // ----------------------------------------------------------------------
+
+    private boolean convertBoolean( String value )
+    {
+        if ( "true".equalsIgnoreCase( value ) || "on".equalsIgnoreCase( value ) || "yes".equalsIgnoreCase(
value ) )
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    private void startMessage()
+    {
+        getLogger().info( "Starting Continuum." );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        String banner = StringUtils.repeat( "-", getVersion().length() );
+
+        getLogger().info( "" );
+        getLogger().info( "" );
+        getLogger().info( "< Continuum " + getVersion() + " started! >" );
+        getLogger().info( "-----------------------" + banner );
+        getLogger().info( "       \\   ^__^" );
+        getLogger().info( "        \\  (oo)\\_______" );
+        getLogger().info( "           (__)\\       )\\/\\" );
+        getLogger().info( "               ||----w |" );
+        getLogger().info( "               ||     ||" );
+        getLogger().info( "" );
+        getLogger().info( "" );
+    }
+
+    private void stopMessage()
+    {
+        getLogger().info( "Stopping Continuum." );
+
+        getLogger().info( "Continuum stopped." );
+    }
+
+    private String getVersion()
+    {
+        try
+        {
+            Properties properties = new Properties();
+
+            String name = "META-INF/maven/org.apache.maven.continuum/continuum-core/pom.properties";
+
+            InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(
name );
+
+            if ( resourceAsStream == null )
+            {
+                return "unknown";
+            }
+
+            properties.load( resourceAsStream );
+
+            return properties.getProperty( "version", "unknown" );
+        }
+        catch ( IOException e )
+        {
+            return "unknown";
         }
     }
 }



Mime
View raw message