continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1491782 - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/ continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/ continuum-core/src/test/java/org/apache/maven/continuum/buildde...
Date Tue, 11 Jun 2013 13:05:45 GMT
Author: batkinson
Date: Tue Jun 11 13:05:44 2013
New Revision: 1491782

URL: http://svn.apache.org/r1491782
Log:
[CONTINUUM-1777] Able to create a build template without build definition
Submitted by: John Michael Luy (with modifications)
Submitted by: Gwen Harold Autencio (with modifications)

Added:
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/buildDefinitionError.jsp
      - copied, changed from r1491313, continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
Tue Jun 11 13:05:44 2013
@@ -70,6 +70,9 @@ public interface BuildDefinitionService
      */
     BuildDefinition cloneBuildDefinition( BuildDefinition buildDefinition );
 
+    boolean isBuildDefinitionInUse( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException;
+
     // ------------------------------------------------------
     //  BuildDefinitionTemplate
     // ------------------------------------------------------

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
Tue Jun 11 13:05:44 2013
@@ -254,6 +254,31 @@ public class DefaultBuildDefinitionServi
         return cloned;
     }
 
+    public boolean isBuildDefinitionInUse( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException
+    {
+        boolean inUse = false;
+        List<BuildDefinitionTemplate> buildDefinitionTemplates = getAllBuildDefinitionTemplate();
+
+        for ( BuildDefinitionTemplate template : buildDefinitionTemplates )
+        {
+            for ( BuildDefinition definition : (List<BuildDefinition>) template.getBuildDefinitions()
)
+            {
+                if ( buildDefinition.getId() == definition.getId() )
+                {
+                    inUse = true;
+                    break;
+                }
+            }
+
+            if ( inUse )
+            {
+                break;
+            }
+        }
+
+        return inUse;
+    }
 
     public BuildDefinitionTemplate getContinuumDefaultWithType( String type )
         throws BuildDefinitionServiceException
@@ -676,4 +701,5 @@ public class DefaultBuildDefinitionServi
         }
         return isDuplicate;
     }
+
 }

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
(original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java
Tue Jun 11 13:05:44 2013
@@ -157,6 +157,9 @@ public class DefaultBuildDefinitionServi
             (BuildDefinition) getBuildDefinitionService().getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions().get(
                 0 );
         template = getBuildDefinitionService().addBuildDefinitionInTemplate( template, bd,
false );
+
+        assertEquals( true, getBuildDefinitionService().isBuildDefinitionInUse( bd ) );
+
         assertEquals( 1, template.getBuildDefinitions().size() );
         all = getBuildDefinitionService().getAllBuildDefinitions();
         assertEquals( 5, all.size() );
@@ -179,4 +182,18 @@ public class DefaultBuildDefinitionServi
         template = getBuildDefinitionService().addBuildDefinitionTemplate( template );
         assertNull( template );
     }
+
+    public void testUnusedBuildDefinition()
+        throws Exception
+    {
+        BuildDefinition unused = new BuildDefinition();
+
+        unused.setTemplate( true );
+        unused.setArguments( "-N" );
+        unused.setGoals( "clean test-compile" );
+        unused.setBuildFile( "pom.xml" );
+        unused.setDescription( "desc template" );
+
+        assertFalse( getBuildDefinitionService().isBuildDefinitionInUse( unused ) );
+    }
 }

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
Tue Jun 11 13:05:44 2013
@@ -44,7 +44,7 @@ public class BuildDefinitionTemplateTest
         throws Exception
     {
         goToAddTemplate();
-        addEditTemplate( "", new String[]{}, new String[]{}, false );
+        addEditTemplate( "", new String[] { "Default Maven Build Definition" }, new String[]
{}, false );
         assertTextPresent( "Name is required" );
     }
 
@@ -52,7 +52,7 @@ public class BuildDefinitionTemplateTest
         throws Exception
     {
         goToAddTemplate();
-        addEditTemplate( "Name <script>alert('gotcha')</script>", new String[]{},
new String[]{}, false );
+        addEditTemplate( "Name <script>alert('gotcha')</script>", new String[]{
"Default Maven Build Definition" }, new String[]{}, false );
         assertTextPresent( "Name contains invalid characters" );
     }
 
@@ -131,4 +131,13 @@ public class BuildDefinitionTemplateTest
         String TEMPLATE_BUILD_DESCRIPTION = getProperty( "TEMPLATE_BUILD_DESCRIPTION" );
         removeBuildDefinitionTemplate( TEMPLATE_BUILD_DESCRIPTION );
     }
+
+    public void testAddTemplateWithEmptyBuildDefinitions()
+        throws Exception
+    {
+        String TEMPLATE_NAME = getProperty( "TEMPLATE_NAME" );
+        goToAddTemplate();
+        addEditTemplate( TEMPLATE_NAME, new String[] {}, new String[] {}, false );
+    }
+
 }

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
Tue Jun 11 13:05:44 2013
@@ -65,19 +65,12 @@ public class MavenTwoProjectTest
         projectGroupId = getProperty( "MAVEN2_POM_PROJECT_GROUP_ID" );
         projectGroupDescription = getProperty( "MAVEN2_POM_PROJECT_GROUP_DESCRIPTION" );
         projectGroupScmRootUrl = getProperty( "MAVEN2_POM_PROJECT_GROUP_SCM_ROOT_URL" );
-
-        readdDefaultBuildDefinitionToTemplate = false;
     }
 
     @AfterMethod
     public void tearDown()
     {
         removeProjectGroup( projectGroupName, false );
-
-        if ( readdDefaultBuildDefinitionToTemplate )
-        {
-            addDefaultBuildDefinitionFromTemplate( "maven2" );
-        }
     }
 
     public void testAddMavenTwoProject()
@@ -92,19 +85,6 @@ public class MavenTwoProjectTest
         assertTextPresent( projectGroupScmRootUrl );
     }
 
-    public void testAddMavenTwoProjectWithNoDefaultBuildDefinitionInTemplate()
-        throws Exception
-    {
-        removeDefaultBuildDefinitionFromTemplate( "maven2" );
-        readdDefaultBuildDefinitionToTemplate = true;
-
-        addMavenTwoProject( pomUrl, pomUsername, pomPassword, null, true );
-
-        assertProjectGroupSummaryPage( projectGroupName, projectGroupId, projectGroupDescription
);
-
-        assertTextPresent( projectGroupScmRootUrl );
-    }
-
     /**
      * Test flat multi module project with names that start with the same letter
      */

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
Tue Jun 11 13:05:44 2013
@@ -72,6 +72,8 @@ public abstract class AbstractBuildDefin
     protected void addEditTemplate( String name, String[] addBuildDefinitions, String[] removeBuildDefinitions,
                                     boolean success )
     {
+        boolean empty = false;
+
         setFieldValue( "buildDefinitionTemplate.name", name );
         if ( addBuildDefinitions != null && addBuildDefinitions.length > 0 )
         {
@@ -81,6 +83,11 @@ public abstract class AbstractBuildDefin
                 clickButtonWithValue( "->", false );
             }
         }
+        else
+        {
+            empty = true;
+        }
+
         if ( removeBuildDefinitions != null && removeBuildDefinitions.length >
0 )
         {
             for ( String bd : removeBuildDefinitions )
@@ -96,7 +103,14 @@ public abstract class AbstractBuildDefin
         }
         else
         {
-            assertAddEditTemplatePage( null, null );
+            if ( empty )
+            {
+                assertTextPresent( "Template requires at least one build definition" );
+            }
+            else
+            {
+                assertAddEditTemplatePage( null, null );
+            }
         }
     }
 

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java
Tue Jun 11 13:05:44 2013
@@ -206,7 +206,7 @@ public class BuildDefinitionTemplateActi
         return SUCCESS;
     }
 
-    private List<BuildDefinition> getBuildDefinitionsFromSelectedBuildDefinitions()
+    public List<BuildDefinition> getBuildDefinitionsFromSelectedBuildDefinitions()
         throws ContinuumException
     {
         if ( this.selectedBuildDefinitionIds == null )
@@ -293,9 +293,17 @@ public class BuildDefinitionTemplateActi
     {
         if ( confirmed )
         {
-            buildDefinition = getContinuum().getBuildDefinitionService().getBuildDefinition(
-                this.buildDefinition.getId() );
-            this.getContinuum().getBuildDefinitionService().removeBuildDefinition( buildDefinition
);
+            if ( getContinuum().getBuildDefinitionService().isBuildDefinitionInUse( buildDefinition
) )
+            {
+                addActionError( getText( "buildDefinition.used" ) );
+                return ERROR;
+            }
+            else
+            {
+                buildDefinition =
+                    getContinuum().getBuildDefinitionService().getBuildDefinition( this.buildDefinition.getId()
);
+                this.getContinuum().getBuildDefinitionService().removeBuildDefinition( buildDefinition
);
+            }
         }
         else
         {

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=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Tue Jun 11 13:05:44 2013
@@ -892,6 +892,12 @@ deletebuildDefinition.template.section.t
 deletebuildDefinition.template.confirmation.message = Are you sure you want to delete build
definition template "{0}"?
 
 # ----------------------------------------------------------------------
+# Page: Build Definition Error
+# ----------------------------------------------------------------------
+buildDefinitionError.page.title=Delete Build Definition Error
+buildDefinitionError.section.title=Delete Build Definition Error
+
+# ----------------------------------------------------------------------
 # Page: Queues
 # ----------------------------------------------------------------------
 buildQueue.page.title = Continuum - Build Queue

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
Tue Jun 11 13:05:44 2013
@@ -31,4 +31,8 @@
       <message key="buildDefinitionTemplate.name.invalid"/>
     </field-validator>
   </field>
+  <validator type="expression">
+    <param name="expression">#selectedDefs = buildDefinitionsFromSelectedBuildDefinitions,
#selectedDefs != null and #selectedDefs.size() > 0</param>
+    <message key="buildDefinitionTemplate.definition.empty" />
+  </validator>
 </validators>
\ No newline at end of file

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties
(original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties
Tue Jun 11 13:05:44 2013
@@ -19,10 +19,12 @@
 
 buildDefinitionTemplate.name.exists = Name already exists
 buildDefinitionTemplate.name.required = Name is required
+buildDefinitionTemplate.definition.empty = Template requires at least one build definition
 buildDefinitionTemplate.name.invalid = Name contains invalid characters
 buildDefinition.buildFile.required = BuildFile is required
 buildDefinition.buildFile.invalid = BuildFile contains invalid characters
 buildDefinition.description.required = Description is required
+buildDefinition.used = Build definition is used by a template
 buildDefinition.goals.required = Goals are required
 buildDefinition.goals.invalid = Goals contain invalid characters
 buildDefinition.arguments.invalid = Arguments contain invalid characters

Modified: continuum/trunk/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/struts.xml?rev=1491782&r1=1491781&r2=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/struts.xml Tue Jun 11 13:05:44 2013
@@ -909,6 +909,7 @@
         <param name="actionName">buildDefinitionTemplates.action</param>
       </result>
       <result name="confirm">/WEB-INF/jsp/admin/confirmDeleteBuildDefinitionAsTemplate.jsp</result>
+      <result name="error">/WEB-INF/jsp/error/buildDefinitionError.jsp</result>
     </action>
 
     <action name="displayQueues" class="queues" method="display">

Copied: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/buildDefinitionError.jsp
(from r1491313, continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml)
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/buildDefinitionError.jsp?p2=continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/buildDefinitionError.jsp&p1=continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml&r1=1491313&r2=1491782&rev=1491782&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml
(original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/error/buildDefinitionError.jsp
Tue Jun 11 13:05:44 2013
@@ -1,4 +1,4 @@
-<!--
+<%--
   ~ Licensed to the Apache Software Foundation (ASF) under one
   ~ or more contributor license agreements.  See the NOTICE file
   ~ distributed with this work for additional information
@@ -15,20 +15,30 @@
   ~ KIND, either express or implied.  See the License for the
   ~ specific language governing permissions and limitations
   ~ under the License.
-  -->
+  --%>
 
-<!DOCTYPE validators PUBLIC
-    "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
-    "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 
-<validators>
-  <field name="buildDefinitionTemplate.name">
-    <field-validator type="requiredstring">
-      <message key="buildDefinitionTemplate.name.required"/>
-    </field-validator>
-    <field-validator type="regex">
-      <param name="regex"><![CDATA[[A-Za-z0-9_.\s\-]*]]></param>
-      <message key="buildDefinitionTemplate.name.invalid"/>
-    </field-validator>
-  </field>
-</validators>
\ No newline at end of file
+<html>
+<s:i18n name="localization.Continuum">
+<head>
+  <title><s:text name="buildDefinitionError.page.title"/></title>
+</head>
+
+<body>
+  <div id="h3">
+    <h3><s:text name="buildDefinitionError.section.title"/></h3>
+    <div class="errors">
+      <c:if test="${!empty actionErrors}">
+        <div class="errormessage">
+          <s:iterator value="actionErrors">
+            <p><s:property/></p>
+          </s:iterator>
+        </div>
+      </c:if>
+    </div>
+  </div>
+</body>
+</s:i18n>
+</html>



Mime
View raw message