continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r760328 [1/2] - in /continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/initialization/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/...
Date Tue, 31 Mar 2009 04:55:04 GMT
Author: evenisse
Date: Tue Mar 31 04:55:00 2009
New Revision: 760328

URL: http://svn.apache.org/viewvc?rev=760328&view=rev
Log:
[CONTINUUM-1130] Allow to delete the default project group

Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java
    continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction.properties
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction_fr.properties
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
    continuum/trunk/maven-continuum-plugin/src/main/java/org/apache/maven/continuum/plugin/AbstractAddProject.java
    continuum/trunk/maven-continuum-plugin/src/main/java/org/apache/maven/continuum/plugin/AddMavenOneProject.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Tue Mar 31 04:55:00 2009
@@ -26,8 +26,8 @@
 
 import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.continuum.buildmanager.BuildsManager;
-import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.project.ProjectScmRoot;
+import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.purge.ContinuumPurgeManager;
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
@@ -62,8 +62,6 @@
     // Project Groups
     // ----------------------------------------------------------------------
 
-    public static final String DEFAULT_PROJECT_GROUP_GROUP_ID = "default";
-
     public ProjectGroup getProjectGroup( int projectGroupId )
         throws ContinuumException;
 
@@ -106,7 +104,7 @@
         throws ContinuumException;
 
     public List<ProjectGroup> getAllProjectGroupsWithRepository( int repositoryId );
-    
+
     // ----------------------------------------------------------------------
     // Project
     // ----------------------------------------------------------------------
@@ -114,11 +112,11 @@
     void removeProject( int projectId )
         throws ContinuumException;
 
-    
+
     /**
-     * @deprecated
      * @param projectId
      * @throws ContinuumException
+     * @deprecated
      */
     void checkoutProject( int projectId )
         throws ContinuumException;
@@ -237,17 +235,6 @@
     /**
      * Add a project to the list of building projects (ant, shell,...)
      *
-     * @param project    the project to add
-     * @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
-     * @return id of the project
-     * @throws ContinuumException
-     */
-    int addProject( Project project, String executorId )
-        throws ContinuumException;
-
-    /**
-     * Add a project to the list of building projects (ant, shell,...)
-     *
      * @param project        the project to add
      * @param executorId     the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
      * @param projectGroupId
@@ -365,27 +352,6 @@
     /**
      * Add a Maven 1 project to the list of projects.
      *
-     * @param metadataUrl url of the project.xml
-     * @return a holder with the projects, project groups and errors occurred during the project adding
-     * @throws ContinuumException
-     */
-    ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl )
-        throws ContinuumException;
-
-    /**
-     * Add a Maven 1 project to the list of projects.
-     *
-     * @param metadataUrl   url of the project.xml
-     * @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
-     * @return a holder with the projects, project groups and errors occurred during the project adding
-     * @throws ContinuumException
-     */
-    ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, boolean checkProtocol )
-        throws ContinuumException;
-
-    /**
-     * Add a Maven 1 project to the list of projects.
-     *
      * @param metadataUrl    url of the project.xml
      * @param projectGroupId id of the project group to use
      * @return a holder with the projects, project groups and errors occurred during the project adding
@@ -634,7 +600,7 @@
     // ----------------------------------------------------------------------
     // Builds Manager
     // ----------------------------------------------------------------------
-    BuildsManager getBuildsManager();    
+    BuildsManager getBuildsManager();
 
     // ----------------------------------------------------------------------
     // Build Queue

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java Tue Mar 31 04:55:00 2009
@@ -1,24 +1,23 @@
 package org.apache.maven.continuum.initialization;
 
-
 /*
- * 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
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
+* 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
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@@ -26,6 +25,8 @@
  */
 public interface ContinuumInitializer
 {
+    String DEFAULT_PROJECT_GROUP_GROUP_ID = "default";
+
     String ROLE = ContinuumInitializer.class.getName();
 
     void initialize()

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Tue Mar 31 04:55:00 2009
@@ -425,7 +425,7 @@
 
             log.info( "Remove project group " + projectGroup.getName() + "(" + projectGroup.getId() + ")" );
 
-            Map context = new HashMap();
+            Map<String, Object> context = new HashMap<String, Object>();
             context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroup.getId() );
             executeAction( "remove-assignable-roles", context );
 
@@ -463,7 +463,7 @@
                 buildDefinitionService.addBuildDefinitionTemplateToProjectGroup( new_pg.getId(),
                                                                                  buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate() );
 
-                Map context = new HashMap();
+                Map<String, Object> context = new HashMap<String, Object>();
                 context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new_pg.getId() );
                 executeAction( "add-assignable-roles", context );
 
@@ -1239,27 +1239,6 @@
     // Maven 1.x projects
     // ----------------------------------------------------------------------
 
-    public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl )
-        throws ContinuumException
-    {
-        return addMavenOneProject( metadataUrl, true );
-    }
-
-    public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, boolean checkProtocol )
-        throws ContinuumException
-    {
-        try
-        {
-            return executeAddProjectsFromMetadataActivity( metadataUrl, MavenOneContinuumProjectBuilder.ID,
-                                                           getDefaultProjectGroup().getId(), checkProtocol,
-                                                           buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate().getId() );
-        }
-        catch ( BuildDefinitionServiceException e )
-        {
-            throw new ContinuumException( e.getMessage(), e );
-        }
-    }
-
     public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId )
         throws ContinuumException
     {
@@ -1384,15 +1363,6 @@
     // Shell projects
     // ----------------------------------------------------------------------
 
-    /**
-     * @see org.apache.maven.continuum.Continuum#addProject(org.apache.maven.continuum.model.project.Project, java.lang.String)
-     */
-    public int addProject( Project project, String executorId )
-        throws ContinuumException
-    {
-        return addProject( project, executorId, getDefaultProjectGroup().getId() );
-    }
-
     public int addProject( Project project, String executorId, int groupId )
         throws ContinuumException
     {
@@ -1407,13 +1377,47 @@
     {
         project.setExecutorId( executorId );
 
-        List<BuildDefinition> buildDefinitions = Collections.EMPTY_LIST;
+        return executeAddProjectFromScmActivity( project, groupId, buildDefintionTemplateId );
+    }
+
+    // ----------------------------------------------------------------------
+    // Activities. These should end up as workflows in werkflow
+    // ----------------------------------------------------------------------
+
+    private int executeAddProjectFromScmActivity( Project project, int groupId, int buildDefintionTemplateId )
+        throws ContinuumException
+    {
+        String executorId = project.getExecutorId();
+
+        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( groupId );
+
+        Map<String, Object> context = new HashMap<String, Object>();
+
+        String scmUrl = project.getScmUrl();
+        createProjectScmRoot( projectGroup, scmUrl );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        context.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, getWorkingDirectory() );
+
+        context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
+
+        context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT_GROUP, projectGroup );
+
+        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroup.getId() );
+
+        executeAction( "validate-project", context );
+
+        executeAction( "store-project", context );
 
         try
         {
+            BuildDefinitionTemplate bdt;
+
             if ( executorId.equalsIgnoreCase( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR ) )
             {
-                BuildDefinitionTemplate bdt = null;
                 if ( buildDefintionTemplateId <= 0 )
                 {
                     bdt = buildDefinitionService.getDefaultAntBuildDefinitionTemplate();
@@ -1422,13 +1426,10 @@
                 {
                     bdt = buildDefinitionService.getBuildDefinitionTemplate( buildDefintionTemplateId );
                 }
-                buildDefinitions = bdt.getBuildDefinitions();
             }
             else
             {
                 //shell default
-
-                BuildDefinitionTemplate bdt = null;
                 if ( buildDefintionTemplateId <= 0 )
                 {
                     bdt = buildDefinitionService.getDefaultShellBuildDefinitionTemplate();
@@ -1437,60 +1438,22 @@
                 {
                     bdt = buildDefinitionService.getBuildDefinitionTemplate( buildDefintionTemplateId );
                 }
-                buildDefinitions = bdt.getBuildDefinitions();
             }
-            for ( BuildDefinition buildDefinition : buildDefinitions )
-            {
 
-                BuildDefinition cloned = buildDefinitionService.cloneBuildDefinition( buildDefinition );
-                cloned.setTemplate( false );
-                project.addBuildDefinition( buildDefinitionService.addBuildDefinition( cloned ) );
-            }
+            buildDefinitionService.addTemplateInProject( bdt.getId(), getProject(
+                (Integer) context.get( AbstractContinuumAction.KEY_PROJECT_ID ) ) );
         }
         catch ( BuildDefinitionServiceException e )
         {
             throw new ContinuumException( e.getMessage(), e );
         }
 
-        return executeAddProjectFromScmActivity( project, groupId );
-    }
-
-    // ----------------------------------------------------------------------
-    // Activities. These should end up as workflows in werkflow
-    // ----------------------------------------------------------------------
-
-    @SuppressWarnings("unchecked")
-    private int executeAddProjectFromScmActivity( Project project, int groupId )
-        throws ContinuumException
-    {
-        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( groupId );
-
-        Map context = new HashMap();
-
-        String scmUrl = project.getScmUrl();
-        createProjectScmRoot( projectGroup, scmUrl );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        context.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, getWorkingDirectory() );
-
-        context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT, project );
-
-        context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT_GROUP, projectGroup );
-
-        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroup.getId() );
-
-        // used by BuildManager to determine on which build queue will the project be put
-        context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, project.getBuildDefinitions().get( 0 ) );
-
-        executeAction( "validate-project", context );
-
-        executeAction( "store-project", context );
-
         if ( !configurationService.isDistributedBuildEnabled() )
         {
+            // used by BuildManager to determine on which build queue will the project be put
+            context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, getProjectWithBuildDetails(
+                (Integer) context.get( AbstractContinuumAction.KEY_PROJECT_ID ) ).getBuildDefinitions().get( 0 ) );
+
             executeAction( "add-project-to-checkout-queue", context );
         }
 
@@ -1531,7 +1494,7 @@
             }
         }
 
-        Map context = new HashMap();
+        Map<String, Object> context = new HashMap<String, Object>();
 
         context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, projectBuilderId );
 
@@ -1622,7 +1585,7 @@
                 {
                     log.info( "Creating project group with the group id: '" + projectGroup.getGroupId() + "'." );
 
-                    Map pgContext = new HashMap();
+                    Map<String, Object> pgContext = new HashMap<String, Object>();
 
                     pgContext.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, getWorkingDirectory() );
 
@@ -2094,10 +2057,10 @@
     public BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
-        context.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_ID, projectId );
 
         executeAction( "add-build-definition-to-project", context );
 
@@ -2107,10 +2070,10 @@
     public void removeBuildDefinitionFromProject( int projectId, int buildDefinitionId )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, getBuildDefinition( buildDefinitionId ) );
-        context.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_ID, projectId );
 
         executeAction( "remove-build-definition-from-project", context );
     }
@@ -2118,10 +2081,10 @@
     public BuildDefinition updateBuildDefinitionForProject( int projectId, BuildDefinition buildDefinition )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
-        context.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_ID, projectId );
 
         executeAction( "update-build-definition-from-project", context );
 
@@ -2131,10 +2094,10 @@
     public BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
-        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroupId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroupId );
 
         executeAction( "add-build-definition-to-project-group", context );
 
@@ -2144,10 +2107,10 @@
     public void removeBuildDefinitionFromProjectGroup( int projectGroupId, int buildDefinitionId )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, getBuildDefinition( buildDefinitionId ) );
-        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroupId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroupId );
 
         executeAction( "remove-build-definition-from-project-group", context );
     }
@@ -2155,10 +2118,10 @@
     public BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
         throws ContinuumException
     {
-        HashMap context = new HashMap();
+        HashMap<String, Object> context = new HashMap<String, Object>();
 
         context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
-        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroupId ) );
+        context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, projectGroupId );
 
         executeAction( "update-build-definition-from-project-group", context );
 
@@ -3047,24 +3010,6 @@
         }
     }
 
-    private ProjectGroup getDefaultProjectGroup()
-        throws ContinuumException
-    {
-        try
-        {
-            return projectGroupDao.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
-        }
-        catch ( ContinuumObjectNotFoundException e )
-        {
-            throw new ContinuumException( "Continuum is not properly initialized, default project group does not exist",
-                                          e );
-        }
-        catch ( ContinuumStoreException ex )
-        {
-            throw logAndCreateException( "Exception while getting default project group.", ex );
-        }
-    }
-
     public InstallationService getInstallationService()
     {
         return installationService;
@@ -3612,7 +3557,7 @@
                 ProjectScmRoot newScmRoot = new ProjectScmRoot();
                 if ( project.getScmUrl().equals( oldScmRoot.getScmRootAddress() ) )
                 {
-                    BeanUtils.copyProperties( oldScmRoot, newScmRoot, new String[] { "id", "projectGroup" } );
+                    BeanUtils.copyProperties( oldScmRoot, newScmRoot, new String[]{"id", "projectGroup"} );
                 }
                 else
                 {

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=760328&r1=760327&r2=760328&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 Mar 31 04:55:00 2009
@@ -18,6 +18,10 @@
  */
 package org.apache.maven.continuum.builddefinition;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.dao.BuildDefinitionDao;
@@ -39,10 +43,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
  * @version $Id$
@@ -576,7 +576,7 @@
                 return;
             }
             project = projectDao.getProjectWithBuildDetails( project.getId() );
-            List<BuildDefinition> buildDefs = new ArrayList<BuildDefinition>();
+
             for ( Iterator<BuildDefinition> iterator = template.getBuildDefinitions().iterator(); iterator.hasNext(); )
             {
                 BuildDefinition bd = iterator.next();
@@ -605,10 +605,11 @@
             {
                 return null;
             }
-            List<BuildDefinition> buildDefs = new ArrayList<BuildDefinition>();
+
             for ( Iterator<BuildDefinition> iterator = template.getBuildDefinitions().iterator(); iterator.hasNext(); )
             {
                 BuildDefinition bd = iterator.next();
+                bd.setTemplate( false );
                 bd = buildDefinitionDao.addBuildDefinition( cloneBuildDefinition( bd ) );
                 projectGroup.addBuildDefinition( bd );
             }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Tue Mar 31 04:55:00 2009
@@ -19,6 +19,10 @@
  * under the License.
  */
 
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -28,10 +32,6 @@
 import org.codehaus.plexus.action.AbstractAction;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -46,9 +46,9 @@
     public static final String KEY_PROJECT_ID = "project-id";
 
     public static final String KEY_PROJECT = "project";
-    
+
     public static final String KEY_PROJECTS = "projects";
-    
+
     public static final String KEY_PROJECTS_BUILD_DEFINITIONS_MAP = "projects-build-definitions";
 
     public static final String KEY_BUILD_DEFINITION_TEMPLATE = "build-definition-template";
@@ -80,11 +80,11 @@
     public static final String KEY_FIRST_RUN = "first-run";
 
     public static final String KEY_PROJECT_RELATIVE_PATH = "project-relative-path";
-    
+
     public static final String KEY_SCM_USE_CREDENTIALS_CACHE = "useCredentialsCache";
-    
+
     public static final String KEY_SCM_USERNAME = "scmUserName";
-    
+
     public static final String KEY_SCM_PASSWORD = "scmUserPassword";
 
     public static final String KEY_SCM_RESULT = "scmResult";
@@ -224,14 +224,14 @@
 
     public static int getOldBuildId( Map context )
     {
-        return getInteger( context, KEY_OLD_BUILD_ID ); 
+        return getInteger( context, KEY_OLD_BUILD_ID );
     }
-    
+
     public static List<Project> getListOfProjects( Map context )
     {
         return (List<Project>) getObject( context, KEY_PROJECTS );
     }
-    
+
     public static Map<Integer, BuildDefinition> getProjectsBuildDefinitionsMap( Map context )
     {
         return (Map<Integer, BuildDefinition>) getObject( context, KEY_PROJECTS_BUILD_DEFINITIONS_MAP );
@@ -258,25 +258,25 @@
 
     public static boolean getBoolean( Map context, String key )
     {
-        return ( (Boolean) getObject( context, key ) ).booleanValue();
+        return (Boolean) getObject( context, key );
     }
-    
+
     public static boolean getBoolean( Map context, String key, boolean defaultValue )
     {
-        return ( (Boolean) getObject( context, key, Boolean.valueOf( defaultValue ) ) ).booleanValue();
-    }    
+        return (Boolean) getObject( context, key, Boolean.valueOf( defaultValue ) );
+    }
 
     protected static int getInteger( Map context, String key )
     {
         Object obj = getObject( context, key, null );
-        
+
         if ( obj == null )
         {
             return 0;
         }
         else
         {
-            return ( (Integer) obj ).intValue();
+            return (Integer) obj;
         }
     }
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java Tue Mar 31 04:55:00 2009
@@ -19,14 +19,14 @@
  * under the License.
  */
 
+import java.util.Map;
+
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 
-import java.util.Map;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -45,12 +45,12 @@
      * @plexus.requirement
      */
     private ProjectDao projectDao;
-    
+
     /**
      * @plexus.requirement role-hint="parallel"
      */
     private BuildsManager parallelBuildsManager;
-    
+
     @SuppressWarnings("unchecked")
     public void execute( Map context )
         throws Exception
@@ -61,7 +61,7 @@
             project = projectDao.getProject( getProjectId( context ) );
         }
 
-        BuildDefinition defaultBuildDefinition = ( BuildDefinition ) getBuildDefinition( context );
+        BuildDefinition defaultBuildDefinition = getBuildDefinition( context );
         parallelBuildsManager.checkoutProject( project.getId(), project.getName(),
                                                workingDirectoryService.getWorkingDirectory( project ),
                                                project.getScmUsername(), project.getScmPassword(),

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/StoreProjectAction.java Tue Mar 31 04:55:00 2009
@@ -19,14 +19,14 @@
  * under the License.
  */
 
+import java.util.Map;
+
 import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
-import java.util.Map;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -65,7 +65,7 @@
 
         projectGroupDao.updateProjectGroup( projectGroup );
 
-        context.put( KEY_PROJECT_ID, new Integer( project.getId() ) );
+        context.put( KEY_PROJECT_ID, project.getId() );
 
         // ----------------------------------------------------------------------
         // Set the working directory

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java Tue Mar 31 04:55:00 2009
@@ -19,15 +19,18 @@
  * under the License.
  */
 
+import java.io.IOException;
+import java.util.Collection;
+
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.ProjectGroupDao;
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.dao.SystemConfigurationDao;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
-import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
@@ -39,8 +42,6 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
@@ -144,30 +145,34 @@
         ProjectGroup group;
         try
         {
-            group = projectGroupDao.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+            group = projectGroupDao.getProjectGroupByGroupId( DEFAULT_PROJECT_GROUP_GROUP_ID );
             log.info( "Default Project Group exists" );
         }
         catch ( ContinuumObjectNotFoundException e )
         {
+            Collection<ProjectGroup> pgs = projectGroupDao.getAllProjectGroups();
+            if ( pgs != null && pgs.isEmpty() )
+            {
+                log.info( "create Default Project Group" );
 
-            log.info( "create Default Project Group" );
+                group = new ProjectGroup();
 
-            group = new ProjectGroup();
+                group.setName( "Default Project Group" );
 
-            group.setName( "Default Project Group" );
+                group.setGroupId( DEFAULT_PROJECT_GROUP_GROUP_ID );
 
-            group.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+                group.setDescription( "Contains all projects that do not have a group of their own" );
 
-            group.setDescription( "Contains all projects that do not have a group of their own" );
+                LocalRepository localRepository = localRepositoryDao.getLocalRepositoryByName( "DEFAULT" );
 
-            LocalRepository localRepository = localRepositoryDao.getLocalRepositoryByName( "DEFAULT" );
+                group.setLocalRepository( localRepository );
 
-            group.setLocalRepository( localRepository );
+                group = projectGroupDao.addProjectGroup( group );
 
-            group.getBuildDefinitions().addAll(
-                buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions() );
+                BuildDefinitionTemplate bdt = buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate();
 
-            group = projectGroupDao.addProjectGroup( group );
+                buildDefinitionService.addBuildDefinitionTemplateToProjectGroup( group.getId(), bdt );
+            }
         }
     }
 

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java Tue Mar 31 04:55:00 2009
@@ -20,20 +20,14 @@
  */
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.ConnectException;
 import java.net.MalformedURLException;
-import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.model.repository.LocalRepository;
-import org.apache.http.HttpException;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
@@ -105,8 +99,8 @@
     {
         try
         {
-            return buildProjectsFromMetadata( url, username, password, loadRecursiveProjects, buildDefinitionService
-                .getDefaultMavenTwoBuildDefinitionTemplate() );
+            return buildProjectsFromMetadata( url, username, password, loadRecursiveProjects,
+                                              buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate() );
         }
         catch ( BuildDefinitionServiceException e )
         {
@@ -153,12 +147,12 @@
         try
         {
             pomFile = createMetadataFile( result, url, username, password );
-            
+
             if ( result.hasErrors() )
             {
                 return;
             }
-            
+
             mavenProject = builderHelper.getMavenProject( result, pomFile );
 
             if ( result.hasErrors() )
@@ -345,7 +339,7 @@
                 if ( StringUtils.isEmpty( buildDefinition.getArguments() ) )
                 {
                     // strange for a mvn build 
-                    log.info( "build definition has empty args" );
+                    log.info( "build definition '" + buildDefinition.getId() + "' has empty args" );
                 }
                 else
                 {

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java Tue Mar 31 04:55:00 2009
@@ -23,7 +23,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -36,6 +35,7 @@
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
+import org.apache.maven.continuum.initialization.ContinuumInitializer;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -56,32 +56,32 @@
     extends AbstractContinuumTest
 {
     protected Logger log = LoggerFactory.getLogger( getClass() );
-    
+
     private Mockery context;
-    
+
     private TaskQueueManager taskQueueManager;
-    
+
     private ProjectDao projectDao;
-    
+
     @Override
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        
+
         context = new JUnit3Mockery();
-        
+
         taskQueueManager = context.mock( TaskQueueManager.class );
-        
+
         projectDao = context.mock( ProjectDao.class );
     }
-    
+
     public void testContinuumConfiguration()
         throws Exception
     {
         lookup( Continuum.ROLE );
     }
-    
+
     public void testAddMavenTwoProjectSet()
         throws Exception
     {
@@ -94,20 +94,19 @@
         File rootPom = getTestFile( "src/test/resources/projects/continuum/continuum-notifiers/pom.xml" );
 
         assertTrue( rootPom.exists() );
-        
+
         ContinuumUrlValidator validator = (ContinuumUrlValidator) lookup( ContinuumUrlValidator.class, "continuumUrl" );
-        
+
         String fileUrl = rootPom.toURL().toExternalForm();
-        
+
         //assertTrue( validator.validate( fileUrl ) );
-        
-        ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( rootPom.toURI().toURL()
-                                                                              .toExternalForm(), -1, true,
-                                                                              false, true, -1 );
+
+        ContinuumProjectBuildingResult result =
+            continuum.addMavenTwoProject( rootPom.toURI().toURL().toExternalForm(), -1, true, false, true, -1 );
 
         assertNotNull( result );
 
-        assertEquals( "result.warnings.size", 0, result.getWarnings().size() );
+        assertEquals( "result.warnings.size" + result.getWarnings(), 0, result.getWarnings().size() );
 
         assertEquals( "result.projects.size", 3, result.getProjects().size() );
 
@@ -115,20 +114,17 @@
 
         log.info( "number of projects: " + getProjectDao().getAllProjectsByName().size() );
 
-        log.info(
-            "number of project groups: " + getProjectGroupDao().getAllProjectGroupsWithProjects().size() );
+        log.info( "number of project groups: " + getProjectGroupDao().getAllProjectGroupsWithProjects().size() );
 
         assertEquals( "Total project count", projectCount + 3, getProjectDao().getAllProjectsByName().size() );
 
         assertEquals( "Total project group count.", projectGroupCount + 1,
                       getProjectGroupDao().getAllProjectGroupsWithProjects().size() );
 
-        Map projects = new HashMap();
+        Map<String, Project> projects = new HashMap<String, Project>();
 
-        for ( Iterator i = getProjectDao().getAllProjectsByName().iterator(); i.hasNext(); )
+        for ( Project project : getProjectDao().getAllProjectsByName() )
         {
-            Project project = (Project) i.next();
-
             projects.put( project.getName(), project );
 
             // validate project in project group
@@ -252,8 +248,6 @@
 
     /**
      * todo add another project group to test
-     *
-     * @throws Exception
      */
     public void testProjectGroups()
         throws Exception
@@ -274,7 +268,7 @@
 
         assertEquals( 1, result.getProjectGroups().size() );
 
-        ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().get( 0 );
+        ProjectGroup projectGroup = result.getProjectGroups().get( 0 );
 
         assertEquals( "plexus", projectGroup.getGroupId() );
 
@@ -286,24 +280,23 @@
         projectGroup = (ProjectGroup) projectGroupList.iterator().next();
 
         assertNotNull( projectGroup );
-        
+
         BuildsManager buildsManager = continuum.getBuildsManager();
-        
+
         List<Project> projects = projectGroup.getProjects();
-        int[] projectIds = new int[ projects.size() ];
-        
+        int[] projectIds = new int[projects.size()];
+
         int idx = 0;
-        for( Project project : projects )
+        for ( Project project : projects )
         {
-            projectIds[ idx ] = project.getId();
+            projectIds[idx] = project.getId();
             idx++;
         }
-        
-        while( buildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds ) )
+
+        while ( buildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds ) )
         {
-            continue;
         }
-        
+
         continuum.removeProjectGroup( projectGroup.getId() );
 
         projectGroupList = continuum.getAllProjectGroupsWithProjects();
@@ -313,8 +306,6 @@
 
     /**
      * test the logic for notifiers
-     *
-     * @throws Exception
      */
     public void testProjectAndGroupNotifiers()
         throws Exception
@@ -335,13 +326,12 @@
 
         assertEquals( 1, result.getProjectGroups().size() );
 
-        ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().get( 0 );
+        ProjectGroup projectGroup = result.getProjectGroups().get( 0 );
 
         continuum.addGroupNotifier( projectGroup.getId(), new ProjectNotifier() );
 
-        for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
+        for ( Project p : (List<Project>) projectGroup.getProjects() )
         {
-            Project p = (Project) i.next();
             continuum.addNotifier( p.getId(), new ProjectNotifier() );
         }
 
@@ -349,9 +339,8 @@
 
         assertEquals( 1, projectGroup.getNotifiers().size() );
 
-        for ( Iterator i = projectGroup.getProjects().iterator(); i.hasNext(); )
+        for ( Project p : (List<Project>) projectGroup.getProjects() )
         {
-            Project p = (Project) i.next();
             assertEquals( 2, p.getNotifiers().size() );
         }
     }
@@ -371,8 +360,8 @@
             //expected, check for twice wrapped exception
             if ( e.getCause() != null )
             {
-                assertFalse( exceptionName + " is wrapped in " + exceptionName, e.getCause().getClass()
-                    .equals( ContinuumException.class ) );
+                assertFalse( exceptionName + " is wrapped in " + exceptionName,
+                             e.getCause().getClass().equals( ContinuumException.class ) );
             }
         }
     }
@@ -381,9 +370,9 @@
         throws Exception
     {
         Continuum continuum = (Continuum) lookup( Continuum.ROLE );
-        
+
         BuildsManager parallelBuildsManager = continuum.getBuildsManager();
-        
+
         String url = getTestFile( "src/test-projects/project1/pom.xml" ).toURL().toExternalForm();
 
         ContinuumProjectBuildingResult result = continuum.addMavenTwoProject( url );
@@ -397,9 +386,9 @@
         assertEquals( Project.class, projects.get( 0 ).getClass() );
 
         Project project = (Project) projects.get( 0 );
-        
+
         parallelBuildsManager.removeProjectFromCheckoutQueue( project.getId() );
-        
+
         assertFalse( "project still exist on the checkout queue",
                      parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) );
     }
@@ -411,9 +400,10 @@
 
         Project project = new Project();
         project.setScmUrl( "scmUrl" );
-        int projectId = continuum.addProject( project, ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR );
-        ProjectGroup defaultProjectGroup = continuum
-            .getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        ProjectGroup defaultProjectGroup =
+            continuum.getProjectGroupByGroupId( ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        int projectId = continuum.addProject( project, ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR,
+                                              defaultProjectGroup.getId() );
         assertEquals( 1, continuum.getProjectGroupWithProjects( defaultProjectGroup.getId() ).getProjects().size() );
         project = continuum.getProjectWithAllDetails( projectId );
         assertNotNull( project );
@@ -422,8 +412,8 @@
         assertEquals( 4, service.getAllBuildDefinitionTemplate().size() );
         assertEquals( 5, service.getAllBuildDefinitions().size() );
 
-        BuildDefinition buildDef = (BuildDefinition) service.getDefaultAntBuildDefinitionTemplate()
-            .getBuildDefinitions().get( 0 );
+        BuildDefinition buildDef =
+            (BuildDefinition) service.getDefaultAntBuildDefinitionTemplate().getBuildDefinitions().get( 0 );
         buildDef = service.cloneBuildDefinition( buildDef );
         buildDef.setTemplate( false );
         continuum.addBuildDefinitionToProject( project.getId(), buildDef );
@@ -438,24 +428,23 @@
     {
         Continuum continuum = getContinuum();
         RepositoryService service = (RepositoryService) lookup( RepositoryService.ROLE );
-        
+
         LocalRepository repository = new LocalRepository();
         repository.setName( "defaultRepo" );
         repository.setLocation( getTestFile( "target/default-repository" ).getAbsolutePath() );
         repository = service.addLocalRepository( repository );
-        
+
         ProjectGroup group = new ProjectGroup();
         group.setGroupId( "testGroup" );
         group.setName( "testGroup" );
         group.setLocalRepository( repository );
         continuum.addProjectGroup( group );
-        
-        ProjectGroup retrievedDefaultProjectGroup = continuum
-        .getProjectGroupByGroupId( "testGroup" );
+
+        ProjectGroup retrievedDefaultProjectGroup = continuum.getProjectGroupByGroupId( "testGroup" );
         assertNotNull( retrievedDefaultProjectGroup.getLocalRepository() );
-        
+
         continuum.removeProjectGroup( retrievedDefaultProjectGroup.getId() );
-        
+
         try
         {
             continuum.getProjectGroupByGroupId( "testGroup" );
@@ -465,7 +454,7 @@
         {
             // should fail. do nothing.
         }
-        
+
         LocalRepository retrievedRepository = service.getLocalRepository( repository.getId() );
         assertNotNull( retrievedRepository );
         assertEquals( repository, retrievedRepository );
@@ -476,14 +465,15 @@
     {
         Continuum continuum = getContinuum();
 
-        ProjectGroup defaultProjectGroup = continuum.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        ProjectGroup defaultProjectGroup =
+            continuum.getProjectGroupByGroupId( ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID );
 
         assertEquals( 0, continuum.getAllContinuumReleaseResults().size() );
 
         ContinuumReleaseResult releaseResult = new ContinuumReleaseResult();
         releaseResult.setStartTime( System.currentTimeMillis() );
 
-        File logFile = continuum.getConfiguration().getReleaseOutputFile( defaultProjectGroup.getId(), 
+        File logFile = continuum.getConfiguration().getReleaseOutputFile( defaultProjectGroup.getId(),
                                                                           "releases-" + releaseResult.getStartTime() );
         logFile.mkdirs();
 
@@ -495,43 +485,44 @@
 
         releaseResult = continuum.addContinuumReleaseResult( releaseResult );
 
-        List<ContinuumReleaseResult> releaseResults = continuum.getContinuumReleaseResultsByProjectGroup( defaultProjectGroup.getId() );
+        List<ContinuumReleaseResult> releaseResults =
+            continuum.getContinuumReleaseResultsByProjectGroup( defaultProjectGroup.getId() );
         assertEquals( 1, releaseResults.size() );
         assertEquals( releaseResult, releaseResults.get( 0 ) );
 
         continuum.removeContinuumReleaseResult( releaseResult.getId() );
-        assertEquals( 0 , continuum.getAllContinuumReleaseResults().size() );
+        assertEquals( 0, continuum.getAllContinuumReleaseResults().size() );
         assertFalse( logFile.exists() );
-        assertEquals( defaultProjectGroup, continuum.getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID ) );
-        
+        assertEquals( defaultProjectGroup,
+                      continuum.getProjectGroupByGroupId( ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID ) );
+
     }
-    
+
     public void testBuildProjectWhileProjectIsInReleaseStage()
         throws Exception
     {
-        DefaultContinuum continuum = ( DefaultContinuum ) getContinuum();
-        
+        DefaultContinuum continuum = (DefaultContinuum) getContinuum();
+
         continuum.setTaskQueueManager( taskQueueManager );
-        
+
         continuum.setProjectDao( projectDao );
-        
+
         final Project project = new Project();
         project.setId( 1 );
         project.setName( "Continuum Core" );
         project.setGroupId( "org.apache.continuum" );
         project.setArtifactId( "continuum-core" );
-        
+
         context.checking( new Expectations()
         {
-            {                
+            {
                 one( projectDao ).getProject( 1 );
                 will( returnValue( project ) );
-                
+
                 one( taskQueueManager ).isProjectInReleaseStage( "org.apache.continuum:continuum-core" );
                 will( returnValue( true ) );
-            }
-        });
-        
+            }} );
+
         try
         {
             continuum.buildProject( 1 );
@@ -542,43 +533,42 @@
             assertEquals( "Project (id=1) is currently in release stage.", e.getMessage() );
         }
     }
-        
+
     public void testBuildProjectGroupWhileAtLeastOneProjectIsInReleaseStage()
         throws Exception
     {
-        DefaultContinuum continuum = ( DefaultContinuum ) getContinuum();
-        
+        DefaultContinuum continuum = (DefaultContinuum) getContinuum();
+
         continuum.setTaskQueueManager( taskQueueManager );
-        
+
         continuum.setProjectDao( projectDao );
-        
+
         final List<Project> projects = new ArrayList<Project>();
-        
+
         Project project = new Project();
         project.setId( 1 );
         project.setName( "Continuum Core" );
         project.setGroupId( "org.apache.continuum" );
         project.setArtifactId( "continuum-core" );
         projects.add( project );
-        
+
         project = new Project();
         project.setId( 2 );
         project.setName( "Continuum API" );
         project.setGroupId( "org.apache.continuum" );
         project.setArtifactId( "continuum-api" );
         projects.add( project );
-        
-        context.checking( new Expectations()  
+
+        context.checking( new Expectations()
         {
             {
                 one( projectDao ).getProjectsInGroup( 1 );
                 will( returnValue( projects ) );
-                
+
                 one( taskQueueManager ).isProjectInReleaseStage( "org.apache.continuum:continuum-core" );
                 will( returnValue( true ) );
-            }
-        });
-        
+            }} );
+
         try
         {
             continuum.buildProjectGroup( 1 );
@@ -590,7 +580,7 @@
                           e.getMessage() );
         }
     }
-    
+
     private Continuum getContinuum()
         throws Exception
     {

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java (original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectGroupDaoImpl.java Tue Mar 31 04:55:00 2009
@@ -19,22 +19,26 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.jdo.PlexusJdoUtils;
-import org.springframework.stereotype.Repository;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.annotation.Resource;
 import javax.jdo.Extent;
 import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.jdo.PlexusJdoUtils;
+import org.springframework.stereotype.Repository;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -48,7 +52,7 @@
 {
     /**
      * @plexus.requirement role=org.apache.continuum.dao.ProjectDao"
-     */  
+     */
     @Resource
     private ProjectDao projectDao;
 
@@ -62,7 +66,7 @@
         ProjectGroup pg = null;
         try
         {
-            pg = getProjectGroupWithProjects( projectGroup.getId() );
+            pg = getProjectGroupWithBuildDetailsByProjectGroupId( projectGroup.getId() );
         }
         catch ( Exception e )
         {
@@ -78,6 +82,35 @@
             {
                 projectDao.removeProject( p );
             }
+
+            List<BuildDefinition> buildDefs = new ArrayList<BuildDefinition>();
+            Iterator<BuildDefinition> it = pg.getBuildDefinitions().listIterator();
+            boolean template = false;
+            while ( it.hasNext() )
+            {
+                BuildDefinition bd = it.next();
+                if ( bd.isTemplate() )
+                {
+                    template = true;
+                }
+                else
+                {
+                    buildDefs.add( bd );
+                }
+            }
+            if ( template )
+            {
+                try
+                {
+                    pg.setBuildDefinitions( buildDefs );
+                    updateProjectGroup( pg );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    // Do nothing
+                }
+            }
+
             removeObject( pg );
         }
     }
@@ -158,10 +191,10 @@
 
     public List<ProjectGroup> getAllProjectGroupsWithTheLot()
     {
-        List fetchGroups = Arrays.asList( new String[]{PROJECT_WITH_BUILDS_FETCH_GROUP,
-            PROJECTGROUP_PROJECTS_FETCH_GROUP, BUILD_RESULT_WITH_DETAILS_FETCH_GROUP,
-            PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP, PROJECT_ALL_DETAILS_FETCH_GROUP,
-            PROJECT_BUILD_DETAILS_FETCH_GROUP} );
+        List fetchGroups = Arrays.asList(
+            new String[]{PROJECT_WITH_BUILDS_FETCH_GROUP, PROJECTGROUP_PROJECTS_FETCH_GROUP,
+                BUILD_RESULT_WITH_DETAILS_FETCH_GROUP, PROJECT_WITH_CHECKOUT_RESULT_FETCH_GROUP,
+                PROJECT_ALL_DETAILS_FETCH_GROUP, PROJECT_BUILD_DETAILS_FETCH_GROUP} );
         return PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), ProjectGroup.class, "name ascending",
                                                      fetchGroups );
     }

Modified: continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java (original)
+++ continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java Tue Mar 31 04:55:00 2009
@@ -19,6 +19,16 @@
  * under the License.
  */
 
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
 import org.apache.continuum.dao.DaoUtils;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.dao.ProjectGroupDao;
@@ -26,6 +36,7 @@
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
+import org.apache.maven.continuum.initialization.ContinuumInitializer;
 import org.apache.maven.continuum.jdo.MemoryJdoFactory;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
@@ -38,15 +49,6 @@
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.jpox.SchemaTool;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -117,7 +119,7 @@
 
             group.setName( "Default Project Group" );
 
-            group.setGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+            group.setGroupId( ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID );
 
             group.setDescription( "Contains all projects that do not have a group of their own" );
 
@@ -131,7 +133,7 @@
         configurationService.setBuildOutputDirectory( getTestFile( "target/build-output" ) );
 
         configurationService.setWorkingDirectory( getTestFile( "target/working-directory" ) );
-        
+
         configurationService.setReleaseOutputDirectory( getTestFile( "target/release-outpur" ) );
 
         configurationService.setReleaseOutputDirectory( getTestFile( "target/release-outpur" ) );
@@ -142,7 +144,8 @@
     protected ProjectGroup getDefaultProjectGroup()
         throws ContinuumStoreException
     {
-        return projectGroupDao.getProjectGroupByGroupIdWithProjects( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID );
+        return projectGroupDao.getProjectGroupByGroupIdWithProjects(
+            ContinuumInitializer.DEFAULT_PROJECT_GROUP_GROUP_ID );
     }
 
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java Tue Mar 31 04:55:00 2009
@@ -21,10 +21,8 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
-import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -64,7 +62,7 @@
 
     private String projectType;
 
-    private Collection projectGroups;
+    private Collection<ProjectGroup> projectGroups;
 
     private int selectedProjectGroup;
 
@@ -104,6 +102,10 @@
             {
                 addActionError( getText( "addProject.scmUrl.required" ) );
             }
+            if ( selectedProjectGroup == 0 )
+            {
+                addActionError( getText( "addProject.projectGroup.required" ) );
+            }
             if ( hasActionErrors() )
             {
                 input();
@@ -147,9 +149,9 @@
         for ( Project project : getContinuum().getProjects() )
         {
             // CONTINUUM-1445
-            if ( StringUtils.equalsIgnoreCase( project.getName(), projectNameTrim )
-                && StringUtils.equalsIgnoreCase( project.getVersion(), versionTrim )
-                && StringUtils.equalsIgnoreCase( project.getScmUrl(), scmTrim ) )
+            if ( StringUtils.equalsIgnoreCase( project.getName(), projectNameTrim ) &&
+                StringUtils.equalsIgnoreCase( project.getVersion(), versionTrim ) &&
+                StringUtils.equalsIgnoreCase( project.getScmUrl(), scmTrim ) )
             {
                 addActionError( getText( "projectName.already.exist.error" ) );
                 return INPUT;
@@ -210,25 +212,18 @@
             return REQUIRES_AUTHORIZATION;
         }
 
-        projectGroups = new ArrayList();
+        projectGroups = new ArrayList<ProjectGroup>();
 
-        Collection allProjectGroups = getContinuum().getAllProjectGroups();
+        Collection<ProjectGroup> allProjectGroups = getContinuum().getAllProjectGroups();
 
-        for ( Iterator i = allProjectGroups.iterator(); i.hasNext(); )
+        for ( ProjectGroup pg : allProjectGroups )
         {
-            ProjectGroup pg = (ProjectGroup) i.next();
-
             if ( isAuthorizedToAddProjectToGroup( pg.getName() ) )
             {
                 projectGroups.add( pg );
             }
         }
 
-        if ( !disableGroupSelection )
-        {
-            selectedProjectGroup =
-                getContinuum().getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID ).getId();
-        }
         this.profiles = profileService.getAllProfiles();
         buildDefinitionTemplates = getContinuum().getBuildDefinitionService().getAllBuildDefinitionTemplate();
         return INPUT;
@@ -236,7 +231,7 @@
 
     private void initializeProjectGroupName()
     {
-        if ( disableGroupSelection == true )
+        if ( disableGroupSelection )
         {
             try
             {
@@ -319,12 +314,12 @@
         this.projectVersion = projectVersion;
     }
 
-    public Collection getProjectGroups()
+    public Collection<ProjectGroup> getProjectGroups()
     {
         return projectGroups;
     }
 
-    public void setProjectGroups( Collection projectGroups )
+    public void setProjectGroups( Collection<ProjectGroup> projectGroups )
     {
         this.projectGroups = projectGroups;
     }

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction.properties?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction.properties (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction.properties Tue Mar 31 04:55:00 2009
@@ -20,3 +20,4 @@
 addProject.name.required = Name is required and cannot contain null or spaces only
 addProject.version.required = Version is required and cannot contain null or spaces only
 addProject.scmUrl.required = SCM Url is required and cannot contain null or spaces only
+addProject.projectGroup.required = Project Group is required and all projects must be in a project group

Modified: continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction_fr.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction_fr.properties?rev=760328&r1=760327&r2=760328&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction_fr.properties (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/AddProjectAction_fr.properties Tue Mar 31 04:55:00 2009
@@ -20,3 +20,4 @@
 addProject.name.required = le nom est obligatoire et ne peut pas contenir uniquement des espaces
 addProject.version.required = la version est obligatoire et ne peut pas contenir uniquement des espaces
 addProject.scmUrl.required = l''URL du gestionnaire de sources est obligatoire et ne peut pas contenir uniquement des espaces
+addProject.projectGroup.required = Le groupe de projets est requis et tous les projets doivent \u00eatre dans un groupe de projets
\ No newline at end of file



Mime
View raw message