continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r762304 - in /continuum/trunk/continuum-webapp/src/main: java/org/apache/maven/continuum/web/action/ScheduleAction.java resources/localization/Continuum.properties
Date Mon, 06 Apr 2009 12:13:07 GMT
Author: evenisse
Date: Mon Apr  6 12:13:06 2009
New Revision: 762304

URL: http://svn.apache.org/viewvc?rev=762304&view=rev
Log:
[CONTINUUM-2143] Message schedule.buildqueues.add.error when a schedule already exist
Submitted by: Jose Morales Martinez

merge -r 761522:761523 from 1.3.x branch

Modified:
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java?rev=762304&r1=762303&r2=762304&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ScheduleAction.java
Mon Apr  6 12:13:06 2009
@@ -19,10 +19,13 @@
  * under the License.
  */
 
+import com.opensymphony.xwork2.Preparable;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
@@ -31,8 +34,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.opensymphony.xwork2.Preparable;
-
 /**
  * @author Nik Gonzalez
  * @version $Id$
@@ -91,7 +92,7 @@
     private void populateBuildQueues()
         throws ContinuumException
     {
-        List<BuildQueue> buildQueues = null;
+        List<BuildQueue> buildQueues;
         if ( schedule != null )
         {
             buildQueues = schedule.getBuildQueues();
@@ -215,7 +216,7 @@
             return REQUIRES_AUTHENTICATION;
         }
 
-        if ( ( "".equals( name ) ) || ( name == null ) )
+        if ( StringUtils.isBlank( name ) )
         {
             logger.error( "Can't create schedule. No schedule name was supplied." );
             addActionError( getText( "buildDefinition.noname.save.error.message" ) );
@@ -223,32 +224,45 @@
         }
         else
         {
-            if ( id == 0 )
+            try
             {
-                try
-                {
-                    getContinuum().addSchedule( setFields( new Schedule() ) );
-                }
-                catch ( ContinuumException e )
+                Schedule s = getContinuum().getScheduleByName( name );
+                if ( s != null && id != s.getId() )
                 {
-                    addActionError( getText( "schedule.buildqueues.add.error" ) );
+                    addActionError( getText( "schedule.name.already.exists" ) );
                     return ERROR;
                 }
-                return SUCCESS;
             }
-            else
+            catch ( ContinuumException e )
             {
-                try
-                {
-                    getContinuum().updateSchedule( setFields( getContinuum().getSchedule(
id ) ) );
-                }
-                catch ( ContinuumException e )
-                {
-                    addActionError( getText( "schedule.buildqueues.add.error" ) );
-                    return ERROR;
-                }
-                return SUCCESS;
+                logger.debug( "Unexpected error getting schedule" );
+            }
+        }
+        if ( id == 0 )
+        {
+            try
+            {
+                getContinuum().addSchedule( setFields( new Schedule() ) );
+            }
+            catch ( ContinuumException e )
+            {
+                addActionError( getText( "schedule.buildqueues.add.error" ) );
+                return ERROR;
+            }
+            return SUCCESS;
+        }
+        else
+        {
+            try
+            {
+                getContinuum().updateSchedule( setFields( getContinuum().getSchedule( id
) ) );
+            }
+            catch ( ContinuumException e )
+            {
+                addActionError( getText( "schedule.buildqueues.add.error" ) );
+                return ERROR;
             }
+            return SUCCESS;
         }
     }
 

Modified: continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=762304&r1=762303&r2=762304&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Mon Apr  6 12:13:06 2009
@@ -632,6 +632,7 @@
 schedule.available.buildqueues = --- Available Build Queues ---
 schedule.available.buildqueues.used = --- Used Build Queues ---
 schedule.buildqueues.add.error = Error attaching the build queue(s) to schedule.
+schedule.name.already.exists = A Schedule with the same name already exists
 
 # ----------------------------------------------------------------------
 # Page: SurefireReport
@@ -1168,4 +1169,4 @@
 distributedBuild.releaseViewResult.error = Unable to view release result because build agent
{0} was either removed or disabled
 distributedBuild.releaseCleanup.error = Unable to cleanup release because build agent {0}
was either removed or disabled
 distributedBuild.releasePerform.input.error = Unable to get release plugin parameters because
build agent {0} was either removed or disabled
-distributedBuild.releasePerform.release.error Unable to perform release because build agent
{0} was either removed or disabled
+distributedBuild.releasePerform.release.error = Unable to perform release because build agent
{0} was either removed or disabled



Mime
View raw message