continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r578318 [1/3] - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/ continuum-api/src/main/java/org/apache/maven/continuum/configuration/...
Date Fri, 21 Sep 2007 23:20:55 GMT
Author: olamy
Date: Fri Sep 21 16:20:52 2007
New Revision: 578318

URL: http://svn.apache.org/viewvc?rev=578318&view=rev
Log:
[CONTINUUM-1436] Add build definition template.


Added:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java   (with props)
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java   (with props)
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java   (with props)
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionServiceTest.java   (with props)
    maven/continuum/trunk/continuum-core/src/test/resources/plexus.xml   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AbstractBuildDefinitionAction.java   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.java   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionAsTemplate-validation.xml   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction-saveBuildDefinitionTemplate-validation.xml   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/resources/org/apache/maven/continuum/web/action/admin/BuildDefinitionTemplateAction.properties   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/buildDefinitionTemplateSummary.jsp   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editBuildDefinitionAsTemplate.jsp   (with props)
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editBuildDefinitionTemplate.jsp   (with props)
Removed:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/security/
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/configuration/
    maven/continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/configuration/
Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    maven/continuum/trunk/continuum-core/pom.xml
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddBuildDefinitionToProjectGroupAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializer.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/initialization/DefaultContinuumInitializerTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java
    maven/continuum/trunk/continuum-security/src/main/java/org/apache/maven/continuum/security/ContinuumRoleConstants.java
    maven/continuum/trunk/continuum-security/src/main/resources/META-INF/redback/redback.xml
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
    maven/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildDefinitionAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/BuildDefinitionSummaryAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/resources/webwork.properties
    maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenOneProject.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addProject.jsp
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/Menu.jsp

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Fri Sep 21 16:20:52 2007
@@ -19,9 +19,11 @@
  * under the License.
  */
 
+import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -256,6 +258,18 @@
         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
+     * @return id of the project
+     * @throws ContinuumException
+     */    
+    int addProject( Project project, String executorId, int projectGroupId, int buildDefintionTemplateId )
+        throws ContinuumException;    
+    
+    /**
      * Add a Maven 2 project to the list of projects.
      *
      * @param metadataUrl url of the pom.xml
@@ -331,6 +345,23 @@
         throws ContinuumException;
 
     /**
+     * Add a Maven 2 project to the list of projects.
+     *
+     * @param metadataUrl              url of the pom.xml
+     * @param projectGroupId           id of the project group to use
+     * @param checkProtocol            check if the protocol is allowed, use false if the pom is uploaded
+     * @param useCredentialsCache      whether to use cached scm account credentials or not
+     * @param loadRecursiveProjects    if multi modules project record all projects (if false only root project added)
+     * @param buildDefintionTemplateId buildDefintionTemplateId
+     * @return a holder with the projects, project groups and errors occurred during the project adding
+     * @throws ContinuumException
+     */
+    public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
+                                                              boolean checkProtocol, boolean useCredentialsCache,
+                                                              boolean loadRecursiveProjects, int buildDefintionTemplateId )
+        throws ContinuumException;    
+    
+    /**
      * Add a Maven 1 project to the list of projects.
      *
      * @param metadataUrl url of the project.xml
@@ -387,6 +418,10 @@
     ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
                                                        boolean useCredentialsCache )
         throws ContinuumException;
+    
+    ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol,
+                                                       boolean useCredentialsCache, int buildDefintionTemplateId )
+        throws ContinuumException;    
 
     void updateProject( Project project )
         throws ContinuumException;
@@ -481,8 +516,9 @@
     BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition )
         throws ContinuumException;
 
+
     BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
-        throws ContinuumException;
+        throws ContinuumException;    
 
     List getBuildDefinitionsForProject( int projectId )
         throws ContinuumException;
@@ -564,4 +600,6 @@
     InstallationService getInstallationService();
 
     ProfileService getProfileService();
+    
+    BuildDefinitionService getBuildDefinitionService();
 }

Added: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java?rev=578318&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java (added)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java Fri Sep 21 16:20:52 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+package org.apache.maven.continuum.builddefinition;
+
+import java.util.List;
+
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+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;
+
+/**
+ * @author <a href="mailto:olamy@apache.org">olamy</a>
+ * @since 15 sept. 07
+ * @version $Id$
+ */
+public interface BuildDefinitionService
+{
+    
+    /**
+     * @param buildDefinitionId
+     * @return null if not in store
+     * @throws BuildDefinitionServiceException
+     */
+    BuildDefinition getBuildDefinition( int buildDefinitionId )
+        throws BuildDefinitionServiceException;
+    
+   /**
+    * @return List<BuildDefinition> all build defintions
+    * @throws BuildDefinitionServiceException
+    */
+    List<BuildDefinition> getAllBuildDefinitions()
+        throws BuildDefinitionServiceException;
+
+    BuildDefinition addBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException;
+
+    void removeBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException;
+
+    void updateBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException;
+
+    List<BuildDefinition> getAllTemplates()
+        throws BuildDefinitionServiceException;    
+    
+    /**
+     * @param buildDefinition
+     * @return clone of {@link BuildDefinition} template/continuumDefault set to false
+     */
+    BuildDefinition cloneBuildDefinition( BuildDefinition buildDefinition );
+    
+    // ------------------------------------------------------
+    //  BuildDefinitionTemplate
+    // ------------------------------------------------------
+
+    void addTemplateInProject( int buildDefinitionTemplateId, Project project )
+        throws BuildDefinitionServiceException;
+    
+    
+    List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException;
+
+    BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
+        throws BuildDefinitionServiceException;
+
+    BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException;
+
+    BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException;
+
+    void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate addBuildDefinitionInTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
+                                                                 BuildDefinition buildDefinition, boolean template )
+        throws BuildDefinitionServiceException;
+
+    BuildDefinitionTemplate removeBuildDefinitionFromTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
+                                                               BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate getDefaultAntBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate getDefaultMavenOneBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate getDefaultMavenTwoBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate getDefaultShellBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException;
+
+    public BuildDefinitionTemplate getContinuumDefaultWithType( String type )
+        throws BuildDefinitionServiceException;
+
+    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
+        throws BuildDefinitionServiceException;
+
+    public ProjectGroup addBuildDefinitionTemplateToProjectGroup( int projectGroupId,
+                                                                  BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException, ContinuumObjectNotFoundException;
+
+    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
+        throws BuildDefinitionServiceException;
+}

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionService.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Fri Sep 21 16:20:52 2007
@@ -0,0 +1 @@
+URL HeadURL Author LastChangedBy Date LastChangedDate Rev Revision LastChangedRevision Id

Added: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java?rev=578318&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java (added)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java Fri Sep 21 16:20:52 2007
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+package org.apache.maven.continuum.builddefinition;
+
+/**
+ * @author <a href="mailto:olamy@apache.org">olamy</a>
+ * @since 15 sept. 07
+ * @version $Id$
+ */
+public class BuildDefinitionServiceException
+    extends Exception
+{
+
+    /**
+     * 
+     */
+    public BuildDefinitionServiceException()
+    {
+        // nothing
+    }
+
+    /**
+     * @param message
+     */
+    public BuildDefinitionServiceException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * @param cause
+     */
+    public BuildDefinitionServiceException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public BuildDefinitionServiceException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+}

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/builddefinition/BuildDefinitionServiceException.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Fri Sep 21 16:20:52 2007
@@ -0,0 +1 @@
+URL HeadURL Author LastChangedBy Date LastChangedDate Rev Revision LastChangedRevision Id

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java Fri Sep 21 16:20:52 2007
@@ -19,11 +19,11 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-
 import java.io.File;
 
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
@@ -32,6 +32,8 @@
 {
     String ROLE = ConfigurationService.class.getName();
 
+    public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -86,25 +88,7 @@
 
     void store()
         throws ConfigurationStoringException;
-
-    public BuildDefinition getDefaultAntBuildDefinition()
-        throws ContinuumStoreException;
-
-    public String getDefaultAntGoals();
-
-    public String getDefaultAntArguments();
-
-    public BuildDefinition getDefaultMavenOneBuildDefinition()
-        throws ContinuumStoreException;
-
-    public String getDefaultMavenOneGoals();
-
-    public String getDefaultMavenOneArguments();
-
-    public BuildDefinition getDefaultMavenTwoBuildDefinition()
-        throws ContinuumStoreException;
-
-    public String getDefaultMavenTwoGoals();
-
-    public String getDefaultMavenTwoArguments();
+    
+    Schedule getDefaultSchedule()
+        throws ContinuumStoreException, ConfigurationLoadingException;
 }

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java Fri Sep 21 16:20:52 2007
@@ -19,13 +19,12 @@
  * under the License.
  */
 
+import java.io.File;
+import java.util.List;
+
 import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.scm.TestResult;
-
-import java.io.File;
-import java.util.List;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/initialization/ContinuumInitializer.java Fri Sep 21 16:20:52 2007
@@ -1,5 +1,6 @@
 package org.apache.maven.continuum.initialization;
 
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -26,10 +27,6 @@
 public interface ContinuumInitializer
 {
     String ROLE = ContinuumInitializer.class.getName();
-
-    //TODO: move this to an other place
-
-    public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
 
     void initialize()
         throws ContinuumInitializationException;

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java Fri Sep 21 16:20:52 2007
@@ -21,6 +21,9 @@
 
 import java.net.URL;
 
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -34,5 +37,12 @@
 
     ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
                                                               boolean recursiveProjects )
+        throws ContinuumProjectBuilderException;
+
+    ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
+                                                              boolean recursiveProjects, BuildDefinitionTemplate buildDefinitionTemplate )
+        throws ContinuumProjectBuilderException;
+
+    BuildDefinitionTemplate getDefaultBuildDefinitionTemplate()
         throws ContinuumProjectBuilderException;
 }

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Fri Sep 21 16:20:52 2007
@@ -19,7 +19,12 @@
  * under the License.
  */
 
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -29,10 +34,6 @@
 import org.apache.maven.continuum.model.system.Profile;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -99,6 +100,60 @@
 
     BuildDefinition storeBuildDefinition( BuildDefinition buildDefinition )
         throws ContinuumStoreException;
+    
+    BuildDefinition addBuildDefinition( BuildDefinition buildDefinition )
+        throws ContinuumStoreException;
+    
+    List<BuildDefinition> getAllBuildDefinitions()
+        throws ContinuumStoreException;
+    
+    List<BuildDefinition> getAllTemplates()
+        throws ContinuumStoreException;
+
+    // ------------------------------------------------------
+    //  BuildDefinitionTemplate
+    // ------------------------------------------------------
+
+    List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
+        throws ContinuumStoreException;
+
+    BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException;
+
+    BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws ContinuumStoreException;
+
+    BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws ContinuumStoreException;
+
+    void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws ContinuumStoreException;
+
+    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
+        throws ContinuumStoreException;    
+    
+    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
+        throws ContinuumStoreException;    
+
+    /**
+     * @param type
+     * @return BuildDefinitionTemplate null if not found
+     * @throws ContinuumStoreException
+     */
+    BuildDefinitionTemplate getContinuumBuildDefinitionTemplateWithType( String type )
+        throws ContinuumStoreException;
+
+    /**
+     * the list returned will contains only continuumDefaults {@link BuildDefinition}
+     * @return List<BuildDefinitionTemplate> 
+     * @throws ContinuumStoreException
+     */
+    List<BuildDefinitionTemplate> getContinuumDefaultdDefinitions()
+        throws ContinuumStoreException;
+
+    // ------------------------------------------------------
+    //  Project Group
+    // ------------------------------------------------------
 
     ProjectGroup addProjectGroup( ProjectGroup group );
 

Modified: maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java (original)
+++ maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java Fri Sep 21 16:20:52 2007
@@ -19,12 +19,14 @@
  * under the License.
  */
 
+import java.net.URL;
+
 import junit.framework.TestCase;
+
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.console.ConsoleLogger;
 
-import java.net.URL;
-
 /**
  * Test for {@link AbstractContinuumProjectBuilder}
  *
@@ -71,6 +73,20 @@
 
         public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
                                                                          boolean recursiveProjects )
+            throws ContinuumProjectBuilderException
+        {
+            return null;
+        }
+
+        public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String password,
+                                                                         boolean recursiveProjects,
+                                                                         BuildDefinitionTemplate buildDefinitionTemplate )
+            throws ContinuumProjectBuilderException
+        {
+            return null;
+        }
+
+        public BuildDefinitionTemplate  getDefaultBuildDefinitionTemplate()
             throws ContinuumProjectBuilderException
         {
             return null;

Modified: maven/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java (original)
+++ maven/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java Fri Sep 21 16:20:52 2007
@@ -19,9 +19,9 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
-import org.apache.maven.continuum.initialization.ContinuumInitializer;
-import org.apache.maven.continuum.model.project.BuildDefinition;
+import java.io.File;
+import java.io.IOException;
+
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.store.ContinuumStore;
@@ -29,9 +29,6 @@
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.FileUtils;
 
-import java.io.File;
-import java.io.IOException;
-
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id$
@@ -49,35 +46,6 @@
      */
     private File applicationHome;
 
-    /**
-     * @plexus.configuration default-value=""
-     */
-    private String defaultAntGoals;
-
-    /**
-     * @plexus.configuration default-value=""
-     */
-    private String defaultAntArguments;
-
-    /**
-     * @plexus.configuration default-value="clean:clean jar:install"
-     */
-    private String defaultM1Goals;
-
-    /**
-     * @plexus.configuration default-value=""
-     */
-    private String defaultM1Arguments;
-
-    /**
-     * @plexus.configuration default-value="clean install"
-     */
-    private String defaultM2Goals;
-
-    /**
-     * @plexus.configuration default-value="--batch-mode --non-recursive"
-     */
-    private String defaultM2Arguments;
 
     /**
      * @plexus.requirement role-hint="jdo"
@@ -91,11 +59,16 @@
     private SystemConfiguration systemConf;
 
     private boolean loaded = false;
+    
 
+    
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
+
+
     public File getApplicationHome()
     {
         return applicationHome;
@@ -320,100 +293,49 @@
             throw new ConfigurationStoringException( "Error writting configuration to database.", e );
         }
     }
-
-    public BuildDefinition getDefaultAntBuildDefinition()
-        throws ContinuumStoreException
+    
+    public Schedule getDefaultSchedule()
+        throws ContinuumStoreException, ConfigurationLoadingException
     {
-        BuildDefinition bd = new BuildDefinition();
-
-        bd.setDefaultForProject( true );
+        // Schedule
+        Schedule defaultSchedule = store.getScheduleByName( DEFAULT_SCHEDULE_NAME );
 
-        bd.setGoals( getDefaultAntGoals() );
-
-        bd.setArguments( getDefaultAntArguments() );
-
-        bd.setBuildFile( "build.xml" );
-
-        bd.setSchedule( getDefaultSchedule() );
-
-        bd.setType( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR );
-        
-        return bd;
-    }
-
-    public String getDefaultAntGoals()
-    {
-        return defaultAntGoals;
-    }
+        if ( defaultSchedule == null )
+        {
+            defaultSchedule = createDefaultSchedule();
 
-    public String getDefaultAntArguments()
-    {
-        return defaultAntArguments;
-    }
+            defaultSchedule = store.addSchedule( defaultSchedule );
+        }
 
-    public String getDefaultMavenOneGoals()
-    {
-        return defaultM1Goals;
+        return defaultSchedule;
     }
 
-    public String getDefaultMavenOneArguments()
-    {
-        return defaultM1Arguments;
-    }
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
 
-    public BuildDefinition getDefaultMavenOneBuildDefinition()
-        throws ContinuumStoreException
+    private Schedule createDefaultSchedule()
+        throws ConfigurationLoadingException
     {
-        BuildDefinition bd = new BuildDefinition();
-
-        bd.setDefaultForProject( true );
-
-        bd.setArguments( getDefaultMavenOneArguments() );
-
-        bd.setGoals( getDefaultMavenOneGoals() );
-
-        bd.setBuildFile( "project.xml" );
-
-        bd.setSchedule( getDefaultSchedule() );
-
-        bd.setType( ContinuumBuildExecutorConstants.MAVEN_ONE_BUILD_EXECUTOR );
         
-        return bd;
-    }
-
-    public String getDefaultMavenTwoArguments()
-    {
-        return this.defaultM2Arguments;
-    }
-
-    public String getDefaultMavenTwoGoals()
-    {
-        return this.defaultM2Goals;
-    }
-
-    public BuildDefinition getDefaultMavenTwoBuildDefinition()
-        throws ContinuumStoreException
-    {
-        BuildDefinition bd = new BuildDefinition();
+        getLogger().info( "create Default Schedule" );
+        
+        Schedule schedule = new Schedule();
 
-        bd.setDefaultForProject( true );
+        schedule.setName( DEFAULT_SCHEDULE_NAME );
 
-        bd.setGoals( getDefaultMavenTwoGoals() );
+        if ( systemConf == null )
+        {
+            this.load();
+        }
 
-        bd.setArguments( getDefaultMavenTwoArguments() );
+        schedule.setDescription( systemConf.getDefaultScheduleDescription() );
 
-        bd.setBuildFile( "pom.xml" );
+        schedule.setCronExpression( systemConf.getDefaultScheduleCronExpression() );
 
-        bd.setSchedule( getDefaultSchedule() );
+        schedule.setActive( true );
 
-        bd.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
-        
-        return bd;
-    }
+        return schedule;
+    }    
 
-    private Schedule getDefaultSchedule()
-        throws ContinuumStoreException
-    {
-        return store.getScheduleByName( ContinuumInitializer.DEFAULT_SCHEDULE_NAME );
-    }
 }

Modified: maven/continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/pom.xml?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/pom.xml (original)
+++ maven/continuum/trunk/continuum-core/pom.xml Fri Sep 21 16:20:52 2007
@@ -190,6 +190,11 @@
       <artifactId>redback-rbac-memory</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-log4j-logging</artifactId>
+      <scope>test</scope>
+    </dependency>    
   </dependencies>
   <build>
     <plugins>
@@ -232,7 +237,7 @@
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-plugin</artifactId>
-            <version>2.2</version>
+            <!--version>2.2</version-->
             <configuration>
               <argLine>-Xmx512m</argLine>
               <childDelegation>true</childDelegation>

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Fri Sep 21 16:20:52 2007
@@ -22,6 +22,8 @@
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.maven.continuum.build.settings.SchedulesActivationException;
 import org.apache.maven.continuum.build.settings.SchedulesActivator;
+import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
+import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
@@ -36,6 +38,7 @@
 import org.apache.maven.continuum.initialization.ContinuumInitializer;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -135,6 +138,11 @@
      * @plexus.requirement
      */
     private ProfileService profileService;
+    
+    /**
+     * @plexus.requirement
+     */    
+    private BuildDefinitionService buildDefinitionService;    
 
     // ----------------------------------------------------------------------
     // Moved from core
@@ -169,6 +177,7 @@
      * @plexus.requirement
      */
     private BuildExecutorManager executorManager;
+        
 
     /**
      * @plexus.requirement role-hint="url"
@@ -303,8 +312,8 @@
             {
                 ProjectGroup new_pg = store.addProjectGroup( projectGroup );
 
-                addBuildDefinitionToProjectGroup( new_pg.getId(),
-                                                  configurationService.getDefaultMavenTwoBuildDefinition() );
+                buildDefinitionService.addBuildDefinitionTemplateToProjectGroup( new_pg.getId(), buildDefinitionService
+                    .getDefaultMavenTwoBuildDefinitionTemplate() );
 
                 Map context = new HashMap();
                 context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( new_pg.getId() ) );
@@ -312,10 +321,15 @@
 
                 getLogger().info( "Added new project group: " + new_pg.getName() );
             }
-            catch ( ContinuumStoreException e )
+            catch ( BuildDefinitionServiceException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+            catch ( ContinuumObjectNotFoundException e )
             {
                 throw new ContinuumException( e.getMessage(), e );
             }
+            
         }
         else
         {
@@ -1352,7 +1366,17 @@
     public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, boolean checkProtocol )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenOneContinuumProjectBuilder.ID, checkProtocol );
+        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 )
@@ -1372,9 +1396,25 @@
                                                               boolean checkProtocol, boolean useCredentialsCache )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenOneContinuumProjectBuilder.ID, projectGroupId,
-                                                       checkProtocol, useCredentialsCache, true );
+        try
+        {
+            return addMavenOneProject( metadataUrl, projectGroupId, checkProtocol, useCredentialsCache,
+                                       buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate().getId() );
+        }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
     }
+    
+    public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId,
+                                                              boolean checkProtocol, boolean useCredentialsCache, int buildDefintionTemplateId )
+        throws ContinuumException
+    {
+            return executeAddProjectsFromMetadataActivity( metadataUrl, MavenOneContinuumProjectBuilder.ID,
+                                                           projectGroupId, checkProtocol, useCredentialsCache, true,
+                                                           buildDefintionTemplateId );
+    }    
 
     // ----------------------------------------------------------------------
     // Maven 2.x projects
@@ -1389,7 +1429,16 @@
     public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, boolean checkProtocol )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID, checkProtocol );
+        try
+        {
+            return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID, -1,
+                                                           checkProtocol, buildDefinitionService
+                                                               .getDefaultMavenTwoBuildDefinitionTemplate().getId() );
+        }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
     }
 
     public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId )
@@ -1409,8 +1458,17 @@
                                                               boolean checkProtocol, boolean useCredentialsCache )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID, projectGroupId,
-                                                       checkProtocol, useCredentialsCache, true );
+        try
+        {
+            return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
+                                                           projectGroupId, checkProtocol, useCredentialsCache, true,
+                                                           buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate()
+                                                               .getId() );
+        }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
     }
 
     public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
@@ -1418,9 +1476,27 @@
                                                               boolean recursiveProjects )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID, projectGroupId,
-                                                       checkProtocol, useCredentialsCache, recursiveProjects );
+        try
+        {
+            return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
+                                                           projectGroupId, checkProtocol, useCredentialsCache,
+                                                           recursiveProjects, buildDefinitionService
+                                                               .getDefaultMavenTwoBuildDefinitionTemplate().getId() );
+        }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
     }
+    
+    public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
+                                                              boolean checkProtocol, boolean useCredentialsCache,
+                                                              boolean recursiveProjects, int buildDefintionTemplateId )
+        throws ContinuumException
+    {
+        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID, projectGroupId,
+                                                       checkProtocol, useCredentialsCache, recursiveProjects, buildDefintionTemplateId );
+    }    
 
     // ----------------------------------------------------------------------
     // Shell projects
@@ -1435,22 +1511,58 @@
     public int addProject( Project project, String executorId, int groupId )
         throws ContinuumException
     {
-
+        return addProject(project, executorId, groupId, -1);
+    }
+    
+    public int addProject( Project project, String executorId, int groupId, int buildDefintionTemplateId )
+        throws ContinuumException
+    {
         project.setExecutorId( executorId );
 
-        if ( executorId.equalsIgnoreCase( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR ) )
+        List<BuildDefinition> buildDefinitions = Collections.EMPTY_LIST;
+
+        try
         {
-            try
+            if ( executorId.equalsIgnoreCase( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR ) )
+            {
+                BuildDefinitionTemplate bdt = null;
+                if ( buildDefintionTemplateId <= 0 )
+                {
+                    bdt = buildDefinitionService.getDefaultAntBuildDefinitionTemplate();
+                }
+                else
+                {
+                    bdt = buildDefinitionService.getBuildDefinitionTemplate( buildDefintionTemplateId );
+                }
+                buildDefinitions = bdt.getBuildDefinitions();
+            }
+            else
             {
-                BuildDefinition bd = configurationService.getDefaultAntBuildDefinition();
+                //shell default
 
-                project.addBuildDefinition( bd );
+                BuildDefinitionTemplate bdt = null;
+                if ( buildDefintionTemplateId <= 0 )
+                {
+                    bdt = buildDefinitionService.getDefaultShellBuildDefinitionTemplate();
+                }
+                else
+                {
+                    bdt = buildDefinitionService.getBuildDefinitionTemplate( buildDefintionTemplateId );
+                }
+                buildDefinitions = bdt.getBuildDefinitions();
             }
-            catch ( ContinuumStoreException e )
+            for ( BuildDefinition buildDefinition : buildDefinitions )
             {
-                getLogger().warn( "Can't get default schedule.", e );
+
+                BuildDefinition cloned = buildDefinitionService.cloneBuildDefinition( buildDefinition );
+                cloned.setTemplate( false );
+                project.addBuildDefinition( buildDefinitionService.addBuildDefinition( cloned ) );
             }
         }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
 
         return executeAddProjectFromScmActivity( project, groupId );
     }
@@ -1498,6 +1610,7 @@
      * @return a holder with the projects, project groups and errors occurred during the project adding
      * @throws ContinuumException
      */
+    /*
     private ContinuumProjectBuildingResult executeAddProjectsFromMetadataActivity( String metadataUrl,
                                                                                    String projectBuilderId,
                                                                                    boolean checkProtocol )
@@ -1505,14 +1618,16 @@
     {
         return executeAddProjectsFromMetadataActivity( metadataUrl, projectBuilderId, -1, checkProtocol );
     }
+    */
 
     private ContinuumProjectBuildingResult executeAddProjectsFromMetadataActivity( String metadataUrl,
                                                                                    String projectBuilderId,
                                                                                    int projectGroupId,
-                                                                                   boolean checkProtocol )
+                                                                                   boolean checkProtocol, int buildDefintionTemplateId )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, projectBuilderId, -1, checkProtocol, false, false );
+        return executeAddProjectsFromMetadataActivity( metadataUrl, projectBuilderId, projectGroupId, checkProtocol, false, false,
+                                                       buildDefintionTemplateId );
     }
 
     private ContinuumProjectBuildingResult executeAddProjectsFromMetadataActivity( String metadataUrl,
@@ -1520,7 +1635,7 @@
                                                                                    int projectGroupId,
                                                                                    boolean checkProtocol,
                                                                                    boolean useCredentialsCache,
-                                                                                   boolean loadRecursiveProjects )
+                                                                                   boolean loadRecursiveProjects, int buildDefintionTemplateId )
         throws ContinuumException
     {
         if ( checkProtocol )
@@ -1550,7 +1665,22 @@
                      Boolean.valueOf( loadRecursiveProjects ) );
 
         context.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, getWorkingDirectory() );
+        
+        context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_TEMPLATE_ID, Integer.valueOf( buildDefintionTemplateId ) );
 
+        // CreateProjectsFromMetadataAction will check null and use default
+        if ( buildDefintionTemplateId > 0 )
+        {
+            try
+            {
+                context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_TEMPLATE_ID, buildDefinitionService
+                    .getBuildDefinitionTemplate( buildDefintionTemplateId ) );
+            }
+            catch ( BuildDefinitionServiceException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+        }
         // ----------------------------------------------------------------------
         // Create the projects from the URL
         // ----------------------------------------------------------------------
@@ -2118,8 +2248,9 @@
 
         return (BuildDefinition) context.get( AbstractContinuumAction.KEY_BUILD_DEFINITION );
     }
-
-    public BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
+    
+    public BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId,
+                                                             BuildDefinition buildDefinition )
         throws ContinuumException
     {
         HashMap context = new HashMap();
@@ -2130,7 +2261,7 @@
         executeAction( "add-build-definition-to-project-group", context );
 
         return (BuildDefinition) context.get( AbstractContinuumAction.KEY_BUILD_DEFINITION );
-    }
+    }    
 
     public void removeBuildDefinitionFromProjectGroup( int projectGroupId, int buildDefinitionId )
         throws ContinuumException
@@ -3056,6 +3187,11 @@
     public ProfileService getProfileService()
     {
         return profileService;
+    }
+
+    public BuildDefinitionService getBuildDefinitionService()
+    {
+        return buildDefinitionService;
     }
 
 }

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java?rev=578318&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java Fri Sep 21 16:20:52 2007
@@ -0,0 +1,621 @@
+/*
+ * 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.
+ */
+package org.apache.maven.continuum.builddefinition;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.continuum.configuration.ConfigurationLoadingException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+/**
+ * @author <a href="mailto:olamy@apache.org">olamy</a>
+ * @since 15 sept. 07
+ * @version $Id$
+ * @plexus.component role="org.apache.maven.continuum.builddefinition.BuildDefinitionService"
+ * @TODO some cache mechanism ?
+ */
+public class DefaultBuildDefinitionService
+    extends AbstractLogEnabled
+    implements BuildDefinitionService, Initializable
+{
+
+    /**
+     * @plexus.configuration default-value=""
+     */
+    private String defaultAntGoals;
+
+    /**
+     * @plexus.configuration default-value=""
+     */
+    private String defaultAntArguments;
+
+    /**
+     * @plexus.configuration default-value="clean:clean jar:install"
+     */
+    private String defaultM1Goals;
+
+    /**
+     * @plexus.configuration default-value=""
+     */
+    private String defaultM1Arguments;
+
+    /**
+     * @plexus.configuration default-value="clean install"
+     */
+    private String defaultM2Goals;
+
+    /**
+     * @plexus.configuration default-value="--batch-mode --non-recursive"
+     */
+    private String defaultM2Arguments;
+    
+    
+    
+    /**
+     * @plexus.requirement role-hint="jdo"
+     */
+    private ContinuumStore store;
+    
+    /**
+     * @plexus.requirement role-hint="default"
+     */    
+    private ConfigurationService configurationService;
+    
+
+    // -----------------------------------------------
+    //  Plexus Lifecycle
+    // -----------------------------------------------
+
+    public void initialize()
+        throws InitializationException
+    {
+        try
+        {
+            initializeDefaultContinuumBuildDefintions();
+        }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new InitializationException( e.getMessage(), e );
+        }
+    } 
+    
+    private void initializeDefaultContinuumBuildDefintions()
+        throws BuildDefinitionServiceException
+    {
+        this.getDefaultAntBuildDefinitionTemplate();
+        this.getDefaultMavenOneBuildDefinitionTemplate();
+        this.getDefaultMavenTwoBuildDefinitionTemplate();
+        this.getDefaultShellBuildDefinitionTemplate();
+    }        
+    
+    public BuildDefinition getBuildDefinition( int buildDefinitionId )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getBuildDefinition( buildDefinitionId );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            return null;
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public BuildDefinition addBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.addBuildDefinition( buildDefinition );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    
+    public void removeBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            store.removeBuildDefinition( buildDefinition );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public void updateBuildDefinition( BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            BuildDefinition storedBuildDefinition = store.getBuildDefinition( buildDefinition.getId() );
+            storedBuildDefinition.setBuildFresh( buildDefinition.isBuildFresh() );
+            storedBuildDefinition.setAlwaysBuild( buildDefinition.isAlwaysBuild() );
+            storedBuildDefinition.setArguments( buildDefinition.getArguments() );
+            storedBuildDefinition.setBuildFile( buildDefinition.getBuildFile() );
+            storedBuildDefinition.setDefaultForProject( buildDefinition.isDefaultForProject() );
+            storedBuildDefinition.setDescription( buildDefinition.getDescription() );
+            storedBuildDefinition.setGoals( buildDefinition.getGoals() );
+            storedBuildDefinition.setProfile( buildDefinition.getProfile() );
+            storedBuildDefinition.setSchedule( buildDefinition.getSchedule() );
+            storedBuildDefinition.setType( buildDefinition.getType() );
+            store.storeBuildDefinition( storedBuildDefinition );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+
+    }
+
+    public List<BuildDefinition> getAllBuildDefinitions()
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getAllBuildDefinitions();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+    
+    
+    public List<BuildDefinition> getAllTemplates()
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getAllTemplates();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }        
+    }
+
+    /** 
+     * @see org.apache.maven.continuum.builddefinition.BuildDefinitionService#cloneBuildDefinition(org.apache.maven.continuum.model.project.BuildDefinition)
+     */
+    public BuildDefinition cloneBuildDefinition( BuildDefinition buildDefinition )
+    {
+        BuildDefinition cloned = new BuildDefinition();
+        cloned.setAlwaysBuild( buildDefinition.isAlwaysBuild() );
+        cloned.setArguments( buildDefinition.getArguments() );
+        cloned.setBuildFile( buildDefinition.getBuildFile() );
+        cloned.setBuildFresh( buildDefinition.isBuildFresh() );
+        cloned.setDefaultForProject( buildDefinition.isDefaultForProject() );
+        cloned.setDescription( buildDefinition.getDescription() );
+        cloned.setGoals( buildDefinition.getGoals() );
+        cloned.setProfile( buildDefinition.getProfile() );
+        cloned.setSchedule( buildDefinition.getSchedule() );
+        cloned.setType( buildDefinition.getType() );
+        cloned.setTemplate( buildDefinition.isTemplate() );
+        return cloned;
+    }
+    
+    
+
+    public BuildDefinitionTemplate getContinuumDefaultWithType( String type )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getContinuumBuildDefinitionTemplateWithType( type );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public BuildDefinitionTemplate getDefaultAntBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException
+    {
+        BuildDefinitionTemplate template = getContinuumDefaultWithType( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR );
+        if ( template != null )
+        {
+            return template;
+        }
+        getLogger().info( "create default AntBuildDefinitionTemplate" );
+        template = new BuildDefinitionTemplate();
+        template.setContinuumDefault( true );
+        template.setName( "default ant template" );
+        template.setType( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR  );
+
+        template = addBuildDefinitionTemplate( template );
+
+        BuildDefinition bd = new BuildDefinition();
+
+        bd.setDefaultForProject( true );
+
+        bd.setGoals( defaultAntGoals );
+
+        bd.setArguments( defaultAntArguments );
+
+        bd.setBuildFile( "build.xml" );
+
+        bd.setSchedule( getDefaultSchedule() );
+
+        bd.setDescription( "default ant buildDefinition" );
+        
+        bd.setTemplate( true );
+        
+        bd.setType( ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR );
+        return addBuildDefinitionInTemplate( template, bd, true );
+    }
+
+    public BuildDefinitionTemplate getDefaultMavenOneBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException
+    {
+        BuildDefinitionTemplate template = getContinuumDefaultWithType( ContinuumBuildExecutorConstants.MAVEN_ONE_BUILD_EXECUTOR );
+        if ( template != null )
+        {
+            getLogger().debug( "found default maven template " + template.getType() );
+            return template;
+        }
+        getLogger().info( "create default MavenOneBuildDefinitionTemplate" );
+        template = new BuildDefinitionTemplate();
+        template.setContinuumDefault( true );
+        template.setName( "default maven1 template" );
+        template.setType( ContinuumBuildExecutorConstants.MAVEN_ONE_BUILD_EXECUTOR  );
+        
+        template = addBuildDefinitionTemplate( template );
+        
+        BuildDefinition bd = new BuildDefinition();
+
+        bd.setDefaultForProject( true );
+
+        bd.setArguments( defaultM1Arguments );
+
+        bd.setGoals( defaultM1Goals );
+
+        bd.setBuildFile( "project.xml" );
+
+        bd.setSchedule( getDefaultSchedule() );
+
+        bd.setType( ContinuumBuildExecutorConstants.MAVEN_ONE_BUILD_EXECUTOR );
+
+        bd.setDescription( "default maven1 buildDefinition" );
+        
+        bd.setTemplate( true );
+        
+        return addBuildDefinitionInTemplate( template, bd, true );
+    }
+
+    public BuildDefinitionTemplate getDefaultMavenTwoBuildDefinitionTemplate()
+        throws  BuildDefinitionServiceException
+    {
+        BuildDefinitionTemplate template = getContinuumDefaultWithType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
+        if ( template != null )
+        {
+            return template;
+        }
+        getLogger().info( "create default MavenTwoBuildDefinitionTemplate" );
+        template = new BuildDefinitionTemplate();
+        template.setContinuumDefault( true );
+        template.setName( "default maven2 template" );
+        template.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR  );
+        
+        template = addBuildDefinitionTemplate( template );        
+        
+        BuildDefinition bd = new BuildDefinition();
+
+        bd.setDefaultForProject( true );
+
+        bd.setGoals( this.defaultM2Goals );
+
+        bd.setArguments( this.defaultM2Arguments );
+
+        bd.setBuildFile( "pom.xml" );
+
+        bd.setSchedule( getDefaultSchedule() );
+
+        bd.setType( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR );
+
+        bd.setDescription( "default maven2 buildDefinition" );
+        
+        bd.setTemplate( true );
+        
+        return addBuildDefinitionInTemplate( template, bd, true );
+    }
+
+    public BuildDefinitionTemplate getDefaultShellBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException
+    {
+        BuildDefinitionTemplate template = getContinuumDefaultWithType( ContinuumBuildExecutorConstants.SHELL_BUILD_EXECUTOR );
+        if ( template != null )
+        {
+            return template;
+        }
+        getLogger().info( "create default ShellBuildDefinitionTemplate" );
+        template = new BuildDefinitionTemplate();
+        template.setContinuumDefault( true );
+        template.setName( "default shell template" );
+        template.setType( ContinuumBuildExecutorConstants.SHELL_BUILD_EXECUTOR  );
+        
+        template = addBuildDefinitionTemplate( template );        
+        
+        BuildDefinition bd = new BuildDefinition();
+
+        bd.setDefaultForProject( true );
+
+        bd.setSchedule( getDefaultSchedule() );
+
+        bd.setType( ContinuumBuildExecutorConstants.SHELL_BUILD_EXECUTOR );
+
+        bd.setTemplate( true );
+        
+        bd.setDescription( "default shell buildDefinition" );
+        
+        return addBuildDefinitionInTemplate( template, bd, true );
+    }
+    
+    private Schedule getDefaultSchedule()
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return configurationService.getDefaultSchedule();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+        catch ( ConfigurationLoadingException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    
+    // ------------------------------------------------------
+    //  BuildDefinitionTemplate
+    // ------------------------------------------------------    
+
+    public List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate()
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getAllBuildDefinitionTemplate();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public BuildDefinitionTemplate getBuildDefinitionTemplate( int id )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getBuildDefinitionTemplate( id );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            // first remove links to buildDefs
+            // TODO in the same db transaction ?
+            buildDefinitionTemplate.setBuildDefinitions( null );
+            buildDefinitionTemplate = store.updateBuildDefinitionTemplate( buildDefinitionTemplate );
+            store.removeBuildDefinitionTemplate( buildDefinitionTemplate );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId() );
+            stored.setName( buildDefinitionTemplate.getName() );
+            stored.setBuildDefinitions( buildDefinitionTemplate.getBuildDefinitions() );
+            return store.updateBuildDefinitionTemplate( stored );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.addBuildDefinitionTemplate( buildDefinitionTemplate );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+    
+    public BuildDefinitionTemplate addBuildDefinitionInTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
+                                                                 BuildDefinition buildDefinition, boolean template )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId() );
+            stored.setName( buildDefinitionTemplate.getName() );
+            BuildDefinition storedBuildDefinition = getBuildDefinition( buildDefinition.getId() );
+            if (storedBuildDefinition != null)
+            {
+                buildDefinition = storedBuildDefinition;
+            }
+            buildDefinition.setTemplate( template );
+            //stored.addBuildDefinition( addBuildDefinition( buildDefinition ) );
+            stored.addBuildDefinition( buildDefinition );
+            return store.updateBuildDefinitionTemplate( stored );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }    
+
+    public BuildDefinitionTemplate removeBuildDefinitionFromTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
+                                                                      BuildDefinition buildDefinition )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            BuildDefinitionTemplate stored = getBuildDefinitionTemplate( buildDefinitionTemplate.getId() );
+            stored.setName( buildDefinitionTemplate.getName() );
+            List<BuildDefinition> buildDefinitions = new ArrayList<BuildDefinition>();
+            for (int i = 0,size = stored.getBuildDefinitions().size();i<size;i++)
+            {
+                BuildDefinition buildDef = (BuildDefinition) stored.getBuildDefinitions().get( i );
+                if ( buildDef.getId() != buildDefinition.getId() )
+                {
+                    buildDefinitions.add( getBuildDefinition( buildDef.getId() ) );
+                }                
+            }
+            stored.setBuildDefinitions( buildDefinitions );
+            return store.updateBuildDefinitionTemplate( stored );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+
+    }
+
+    public void addTemplateInProject( int buildDefinitionTemplateId, Project project )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            BuildDefinitionTemplate template = getBuildDefinitionTemplate( buildDefinitionTemplateId );
+            if ( template.getBuildDefinitions().isEmpty() )
+            {
+                return;
+            }
+            project = store.getProjectWithBuildDetails( project.getId() );
+            List<BuildDefinition> buildDefs = new ArrayList<BuildDefinition>();
+            for ( Iterator<BuildDefinition> iterator = template.getBuildDefinitions().iterator(); iterator.hasNext(); )
+            {
+                BuildDefinition bd = iterator.next();
+                bd = cloneBuildDefinition( bd );
+                bd.setTemplate( false );
+                bd = store.addBuildDefinition( bd );
+                project.addBuildDefinition( bd );
+            }
+            store.updateProject( project );
+
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public ProjectGroup addBuildDefinitionTemplateToProjectGroup( int projectGroupId,
+                                                                             BuildDefinitionTemplate template )
+        throws BuildDefinitionServiceException, ContinuumObjectNotFoundException
+    {
+        try
+        {
+            ProjectGroup projectGroup = store.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
+            if ( template.getBuildDefinitions().isEmpty() )
+            {
+                return null;
+            }
+            List<BuildDefinition> buildDefs = new ArrayList<BuildDefinition>();
+            for ( Iterator<BuildDefinition> iterator = template.getBuildDefinitions().iterator(); iterator.hasNext(); )
+            {
+                BuildDefinition bd = iterator.next();
+                bd = store.addBuildDefinition( cloneBuildDefinition( bd ) );
+                projectGroup.addBuildDefinition( bd );
+            }
+            store.updateProjectGroup( projectGroup );
+            return projectGroup;
+
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+    
+    public List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type )
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getBuildDefinitionTemplatesWithType( type );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+
+    public List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates()
+        throws BuildDefinitionServiceException
+    {
+        try
+        {
+            return store.getContinuumBuildDefinitionTemplates();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new BuildDefinitionServiceException( e.getMessage(), e );
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
------------------------------------------------------------------------------
    svn:eol-style = LF

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/builddefinition/DefaultBuildDefinitionService.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Fri Sep 21 16:20:52 2007
@@ -0,0 +1 @@
+URL HeadURL Author LastChangedBy Date LastChangedDate Rev Revision LastChangedRevision Id

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractBuildDefinitionContinuumAction.java Fri Sep 21 16:20:52 2007
@@ -19,8 +19,11 @@
  * under the License.
  */
 
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.initialization.DefaultContinuumInitializer;
+import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
@@ -29,9 +32,6 @@
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * AbstractBuildDefinitionContinuumAction:
  *
@@ -175,7 +175,7 @@
                 {
                     try
                     {
-                        schedule = store.getScheduleByName( DefaultContinuumInitializer.DEFAULT_SCHEDULE_NAME );
+                        schedule = store.getScheduleByName( ConfigurationService.DEFAULT_SCHEDULE_NAME );
                     }
                     catch ( ContinuumStoreException e )
                     {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=578318&r1=578317&r2=578318&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Fri Sep 21 16:20:52 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.model.scm.ScmResult;
@@ -27,6 +28,7 @@
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -45,10 +47,14 @@
 
     public static final String KEY_PROJECT = "project";
 
-    public static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
+    public static final String KEY_BUILD_DEFINITION_TEMPLATE_ID = "build-definition-template-id";
+    
+    public static final String KEY_BUILD_DEFINITION_TEMPLATE = "build-definition-template";
 
     public static final String KEY_BUILD_DEFINITION = "build-definition";
-
+    
+    public static final String KEY_BUILD_DEFINITION_ID = "build-definition-id";
+    
     public static final String KEY_UNVALIDATED_PROJECT = "unvalidated-project";
 
     public static final String KEY_PROJECT_GROUP_ID = "project-group-id";
@@ -106,14 +112,24 @@
         return getInteger( context, KEY_PROJECT_GROUP_ID );
     }
 
-    public static int getBuildDefinitionId( Map context )
+    public static int getBuildDefinitionTemplateId( Map context )
     {
-        return getInteger( context, KEY_BUILD_DEFINITION_ID );
+        return getInteger( context, KEY_BUILD_DEFINITION_TEMPLATE_ID );
     }
 
+    public static BuildDefinitionTemplate getBuildDefinitionTemplate( Map context )
+    {
+        return (BuildDefinitionTemplate) getObject( context, KEY_BUILD_DEFINITION_TEMPLATE_ID, null );
+    }
+    
     public static BuildDefinition getBuildDefinition( Map context )
     {
         return (BuildDefinition) getObject( context, KEY_BUILD_DEFINITION, null );
+    }
+    
+    public static int getBuildDefinitionId( Map context )
+    {
+        return getInteger( context, KEY_BUILD_DEFINITION_ID );
     }
 
     public static String getBuildId( Map context )



Mime
View raw message