You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2008/10/31 01:01:41 UTC

svn commit: r709300 [1/3] - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-api/src/main/java/org/apache/continuum/purge/ continuum-api/src/main/java/org/apache/continuum/taskqueue/ continuum-api/src/main/java/org/a...

Author: ctan
Date: Thu Oct 30 17:01:38 2008
New Revision: 709300

URL: http://svn.apache.org/viewvc?rev=709300&view=rev
Log:
merge -r 690852:708342 from continuum-transient-state branch

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/
      - copied from r708799, continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/
      - copied from r708799, continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/
      - copied from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/
      - copied from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
    continuum/trunk/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/PrepareBuildComplete.vm
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/PrepareBuildComplete.vm
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectScmRootDaoImpl.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-store/src/main/java/org/apache/continuum/dao/ProjectScmRootDaoImpl.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/ScmResultAction.java
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/continuum/web/action/ScmResultAction.java
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/scmResult.jsp
      - copied unchanged from r708799, continuum/branches/continuum-transient-state/continuum-webapp/src/main/webapp/WEB-INF/jsp/scmResult.jsp
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.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/buildcontroller/BuildContext.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.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/CheckoutProjectContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/DefaultContinuumNotificationDispatcher.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/console/ConsoleNotifier.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifierTest.java
    continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
    continuum/trunk/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
    continuum/trunk/continuum-model/pom.xml
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-model/src/main/resources/package-mssql.orm
    continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/AbstractContinuumNotifier.java
    continuum/trunk/continuum-notifiers/continuum-notifier-api/src/main/java/org/apache/maven/continuum/notification/MessageContext.java
    continuum/trunk/continuum-notifiers/continuum-notifier-irc/src/main/java/org/apache/maven/continuum/notification/irc/IrcContinuumNotifier.java
    continuum/trunk/continuum-notifiers/continuum-notifier-jabber/src/main/java/org/apache/maven/continuum/notification/jabber/JabberContinuumNotifier.java
    continuum/trunk/continuum-notifiers/continuum-notifier-msn/src/main/java/org/apache/maven/continuum/notification/msn/MsnContinuumNotifier.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
    continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/AbstractContinuumTest.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/component/NotifierSummaryAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/notifier/AbstractNotifierEditActionSupport.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/components/projectSummaryComponent.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/notifier/notifierIrc.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/notifier/notifierJabber.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/notifier/notifierMail.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/notifier/notifierMsn.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java Thu Oct 30 17:01:38 2008
@@ -57,6 +57,9 @@
     Project getProjectWithCheckoutResult( int projectId )
         throws ContinuumStoreException;
 
+    Project getProjectWithScmDetails( int projectId )
+        throws ContinuumStoreException;
+
     List<Project> getProjectsInGroup( int projectGroupId )
         throws ContinuumStoreException;
 

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java Thu Oct 30 17:01:38 2008
@@ -55,53 +55,4 @@
      */
     void purgeDirectory( DirectoryPurgeConfiguration dirPurgeConfig )
         throws ContinuumPurgeManagerException;
-    
-    /**
-     * Check if the repository is already in the purging queue
-     * 
-     * @param repositoryId the id of the repository purge configuration
-     * @return true if the repository is in the purging queue, otherwise false
-     * @throws ContinuumPurgeManagerException
-     */
-    boolean isRepositoryInPurgeQueue( int repositoryId )
-        throws ContinuumPurgeManagerException;
-    
-    /**
-     * Check if the repository is being used by a project that is currently building
-     * 
-     * @param repositoryId the id of the local repository
-     * @return true if the repository is in use, otherwise false
-     * @throws ContinuumPurgeManagerException
-     */
-    boolean isRepositoryInUse( int repositoryId )
-        throws ContinuumPurgeManagerException;
-
-    /**
-     * Remove local repository from the purge queue
-     * 
-     * @param repositoryId the id of the local repository
-     * @throws ContinuumPurgeManagerException
-     */
-    void removeRepositoryFromPurgeQueue( int repositoryId )
-        throws ContinuumPurgeManagerException;
-    
-    /**
-     * Remove local repository from the purge queue
-     * 
-     * @param purgeConfigId the id of the purge configuration
-     * @return true if the purge configuration was successfully removed from the purge queue, otherwise false
-     * @throws ContinuumPurgeManagerException
-     */
-    boolean removeFromPurgeQueue( int purgeConfigId )
-        throws ContinuumPurgeManagerException;
-    
-    /**
-     * Remove local repositories from the purge queue
-     * 
-     * @param purgeConfigIds the ids of the purge configuration
-     * @return true if the purge configurations were successfully removed from the purge queue, otherwise false
-     * @throws ContinuumPurgeManagerException
-     */
-    boolean removeFromPurgeQueue( int[] purgeConfigIds )
-        throws ContinuumPurgeManagerException;
 }

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=709300&r1=709299&r2=709300&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 Thu Oct 30 17:01:38 2008
@@ -25,9 +25,11 @@
 import java.util.Map;
 
 import org.apache.continuum.model.release.ContinuumReleaseResult;
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.purge.ContinuumPurgeManager;
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.repository.RepositoryService;
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.configuration.ConfigurationService;
@@ -42,6 +44,7 @@
 import org.apache.maven.continuum.profile.ProfileService;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 
 /**
@@ -146,54 +149,6 @@
     Map<Integer, BuildResult> getBuildResultsInSuccess();
 
     // ----------------------------------------------------------------------
-    // Queues
-    // ----------------------------------------------------------------------
-
-    public List<BuildProjectTask> getProjectsInBuildQueue()
-        throws ContinuumException;
-
-    boolean isInBuildingQueue( int projectId )
-        throws ContinuumException;
-
-    boolean isInBuildingQueue( int projectId, int buildDefinitionId )
-        throws ContinuumException;
-
-    boolean removeProjectsFromBuildingQueue( int[] projectsId )
-        throws ContinuumException;
-
-    /**
-     * @param hashCodes BuildProjectTask hashCodes
-     * @throws ContinuumException
-     */
-    void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
-        throws ContinuumException;
-
-    boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
-        throws ContinuumException;
-
-    boolean isInCheckoutQueue( int projectId )
-        throws ContinuumException;
-
-    boolean removeProjectFromCheckoutQueue( int projectId )
-        throws ContinuumException;
-
-    List /* CheckOutTask */getCheckOutTasksInQueue()
-        throws ContinuumException;
-
-    boolean removeProjectsFromCheckoutQueue( int[] projectId )
-        throws ContinuumException;
-
-    /**
-     * @param hashCodes CheckOutTask hashCodes
-     * @throws ContinuumException
-     */
-    void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
-        throws ContinuumException;
-
-    boolean cancelCurrentBuild()
-        throws ContinuumException;
-    
-    // ----------------------------------------------------------------------
     // Building
     // ----------------------------------------------------------------------
 
@@ -267,6 +222,9 @@
     void removeBuildResult( int buildId )
         throws ContinuumException;
 
+    List<ChangeSet> getChangesSinceLastUpdate( int projectId )
+        throws ContinuumException;
+    
     // ----------------------------------------------------------------------
     // Projects
     // ----------------------------------------------------------------------
@@ -637,7 +595,7 @@
     ProfileService getProfileService();
 
     BuildDefinitionService getBuildDefinitionService();
-    
+
     // ----------------------------------------------------------------------
     // Continuum Purge
     // ----------------------------------------------------------------------
@@ -649,7 +607,38 @@
     // Repository Service
     // ----------------------------------------------------------------------
     RepositoryService getRepositoryService();
-    
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+    List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId );
+
+    ProjectScmRoot getProjectScmRoot( int projectScmRootId )
+        throws ContinuumException;
+
+    ProjectScmRoot getProjectScmRootByProject( int projectId )
+        throws ContinuumException;
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+    Collection<Map<Integer, Integer>> getProjectsAndBuildDefinitions( Collection<Project> projects, 
+                                                             List<BuildDefinition> bds,
+                                                             boolean checkDefaultBuildDefinitionForProject )
+        throws ContinuumException;
+
+    Collection<Map<Integer, Integer>> getProjectsAndBuildDefinitions( Collection<Project> projects, 
+                                                             int buildDefinitionId )
+        throws ContinuumException;
+
+    void prepareBuildProjects( Collection<Map<Integer, Integer>> projectsAndBuildDefinitions, int trigger )
+        throws ContinuumException;
+
+    // ----------------------------------------------------------------------
+    // Task Queue Manager
+    // ----------------------------------------------------------------------
+    TaskQueueManager getTaskQueueManager();
+
     public void startup()
         throws ContinuumException;
     

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcher.java Thu Oct 30 17:01:38 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
@@ -48,6 +49,8 @@
 
     String MESSAGE_ID_BUILD_COMPLETE = "BuildComplete";
 
+    String MESSAGE_ID_PREPARE_BUILD_COMPLETE = "PrepareBuildComplete";
+
     String CONTEXT_BUILD = "build";
 
     String CONTEXT_BUILD_OUTPUT = "build-output";
@@ -77,4 +80,6 @@
     void goalsCompleted( Project project, BuildDefinition buildDefinition, BuildResult buildResult );
 
     void buildComplete( Project project, BuildDefinition buildDefinition, BuildResult buildResult );
+
+    void prepareBuildComplete( ProjectScmRoot projectScmRoot );
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java Thu Oct 30 17:01:38 2008
@@ -116,6 +116,6 @@
     void perform( String releaseId, File buildDirectory, String goals, boolean useReleaseProfile,
                   ContinuumReleaseManagerListener listener, LocalRepository repository )
         throws ContinuumReleaseException;
-    
+
     Map<String, String> getEnvironments( Profile profile );
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java Thu Oct 30 17:01:38 2008
@@ -19,29 +19,21 @@
  * under the License.
  */
 
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.task.PurgeTask;
-import org.apache.maven.continuum.buildqueue.BuildProjectTask;
-import org.apache.maven.continuum.model.project.Project;
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.model.project.Schedule;
-import org.apache.maven.continuum.release.tasks.PerformReleaseProjectTask;
-import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
-import org.codehaus.plexus.taskqueue.Task;
-import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -53,7 +45,7 @@
  * @since 25 jul 07
  */
 public class DefaultContinuumPurgeManager
-    implements ContinuumPurgeManager, Contextualizable
+    implements ContinuumPurgeManager
 {
     /**
      * @plexus.requirement
@@ -61,17 +53,15 @@
     private ProjectDao projectDao;
 
     /**
-     * @plexus.requirement role-hint="purge"
+     * @plexus.requirement
      */
-    private TaskQueue purgeQueue;
+    private PurgeConfigurationService purgeConfigurationService;
 
     /**
      * @plexus.requirement
      */
-    private PurgeConfigurationService purgeConfigurationService;
-
-    private PlexusContainer container;
-
+    private TaskQueueManager taskQueueManager;
+    
     public void purge( Schedule schedule )
         throws ContinuumPurgeManagerException
     {
@@ -98,112 +88,6 @@
         }
     }
 
-    public boolean isRepositoryInPurgeQueue( int repositoryId )
-        throws ContinuumPurgeManagerException
-    {
-        List<RepositoryPurgeConfiguration> repoPurgeConfigs =
-            purgeConfigurationService.getRepositoryPurgeConfigurationsByRepository( repositoryId );
-
-        for ( RepositoryPurgeConfiguration repoPurge : repoPurgeConfigs )
-        {
-            if ( isInPurgeQueue( repoPurge.getId() ) )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public boolean isRepositoryInUse( int repositoryId )
-        throws ContinuumPurgeManagerException
-    {
-        try
-        {
-            Task task = getCurrentTask( "build-project" );
-
-            if ( task != null && task instanceof BuildProjectTask )
-            {
-                int projectId = ( (BuildProjectTask) task ).getProjectId();
-
-                Project project = projectDao.getProject( projectId );
-                LocalRepository repository = project.getProjectGroup().getLocalRepository();
-
-                if ( repository != null && repository.getId() == repositoryId )
-                {
-                    return true;
-                }
-            }
-            return false;
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new ContinuumPurgeManagerException( e.getMessage(), e );
-        }
-    }
-
-    public void removeRepositoryFromPurgeQueue( int repositoryId )
-        throws ContinuumPurgeManagerException
-    {
-        List<RepositoryPurgeConfiguration> repoPurgeConfigs =
-            purgeConfigurationService.getRepositoryPurgeConfigurationsByRepository( repositoryId );
-
-        for ( RepositoryPurgeConfiguration repoPurge : repoPurgeConfigs )
-        {
-            removeFromPurgeQueue( repoPurge.getId() );
-        }
-    }
-
-    public boolean removeFromPurgeQueue( int[] purgeConfigIds )
-        throws ContinuumPurgeManagerException
-    {
-        if ( purgeConfigIds == null )
-        {
-            return false;
-        }
-
-        if ( purgeConfigIds.length < 1 )
-        {
-            return false;
-        }
-
-        List<PurgeTask> queue = getAllPurgeConfigurationsInPurgeQueue();
-
-        List<PurgeTask> tasks = new ArrayList<PurgeTask>();
-
-        for ( PurgeTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( ArrayUtils.contains( purgeConfigIds, task.getPurgeConfigurationId() ) )
-                {
-                    tasks.add( task );
-                }
-            }
-        }
-
-        if ( !tasks.isEmpty() )
-        {
-            return purgeQueue.removeAll( tasks );
-        }
-
-        return false;
-    }
-
-    public boolean removeFromPurgeQueue( int purgeConfigId )
-        throws ContinuumPurgeManagerException
-    {
-        List<PurgeTask> queue = getAllPurgeConfigurationsInPurgeQueue();
-
-        for ( PurgeTask task : queue )
-        {
-            if ( task != null && task.getPurgeConfigurationId() == purgeConfigId )
-            {
-                return purgeQueue.remove( task );
-            }
-        }
-        return false;
-    }
-
     public void purgeRepository( RepositoryPurgeConfiguration repoPurge )
         throws ContinuumPurgeManagerException
     {
@@ -212,15 +96,20 @@
             LocalRepository repository = repoPurge.getRepository();
 
             // do not purge if repository is in use and if repository is already in purge queue
-            if ( !isRepositoryInUse( repository.getId() ) && !isInPurgeQueue( repoPurge.getId() ) )
+            if ( !taskQueueManager.isRepositoryInUse( repository.getId() ) && 
+                 !taskQueueManager.isInPurgeQueue( repoPurge.getId() ) )
             {
-                purgeQueue.put( new PurgeTask( repoPurge.getId() ) );
+                taskQueueManager.getPurgeQueue().put( new PurgeTask( repoPurge.getId() ) );
             }
         }
         catch ( TaskQueueException e )
         {
             throw new ContinuumPurgeManagerException( "Error while enqueuing repository", e );
         }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumPurgeManagerException( e.getMessage(), e );
+        }
     }
 
     public void purgeDirectory( DirectoryPurgeConfiguration dirPurge )
@@ -231,17 +120,19 @@
             if ( "releases".equals( dirPurge.getDirectoryType() ) )
             {
                 // do not purge if release in progress
-                if ( !releaseInProgress() && !isInPurgeQueue( dirPurge.getId() ) )
+                if ( !taskQueueManager.releaseInProgress() && 
+                     !taskQueueManager.isInPurgeQueue( dirPurge.getId() ) )
                 {
-                    purgeQueue.put( new PurgeTask( dirPurge.getId() ) );
+                    taskQueueManager.getPurgeQueue().put( new PurgeTask( dirPurge.getId() ) );
                 }
             }
             else if ( "buildOutput".equals( dirPurge.getDirectoryType() ) )
             {
                 // do not purge if build in progress
-                if ( !buildInProgress() && !isInPurgeQueue( dirPurge.getId() ) )
+                if ( !taskQueueManager.buildInProgress() && 
+                     !taskQueueManager.isInPurgeQueue( dirPurge.getId() ) )
                 {
-                    purgeQueue.put( new PurgeTask( dirPurge.getId() ) );
+                    taskQueueManager.getPurgeQueue().put( new PurgeTask( dirPurge.getId() ) );
                 }
             }
 
@@ -250,79 +141,10 @@
         {
             throw new ContinuumPurgeManagerException( "Error while enqueuing repository", e );
         }
-    }
-
-    public void contextualize( Context context )
-        throws ContextException
-    {
-        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
-    }
-
-    private boolean isInPurgeQueue( int purgeConfigId )
-        throws ContinuumPurgeManagerException
-    {
-        List<PurgeTask> queue = getAllPurgeConfigurationsInPurgeQueue();
-
-        for ( PurgeTask task : queue )
-        {
-            if ( task != null && task.getPurgeConfigurationId() == purgeConfigId )
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private List<PurgeTask> getAllPurgeConfigurationsInPurgeQueue()
-        throws ContinuumPurgeManagerException
-    {
-        try
-        {
-            return purgeQueue.getQueueSnapshot();
-        }
-        catch ( TaskQueueException e )
+        catch ( TaskQueueManagerException e )
         {
-            throw new ContinuumPurgeManagerException( "Error while getting the purge configs in purge queue", e );
-        }
-    }
-
-    private Task getCurrentTask( String task )
-        throws ContinuumPurgeManagerException
-    {
-        try
-        {
-            TaskQueueExecutor executor = (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, task );
-            return executor.getCurrentTask();
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new ContinuumPurgeManagerException( "Unable to lookup current task", e );
-        }
-    }
-
-    private boolean buildInProgress()
-        throws ContinuumPurgeManagerException
-    {
-        Task task = getCurrentTask( "build-project" );
-
-        if ( task != null && task instanceof BuildProjectTask )
-        {
-            return true;
+            throw new ContinuumPurgeManagerException( e.getMessage(), e );
         }
-
-        return false;
     }
 
-    private boolean releaseInProgress()
-        throws ContinuumPurgeManagerException
-    {
-        Task task = getCurrentTask( "perform-release" );
-
-        if ( task != null && task instanceof PerformReleaseProjectTask )
-        {
-            return true;
-        }
-
-        return false;
-    }
 }
\ No newline at end of file

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java Thu Oct 30 17:01:38 2008
@@ -24,8 +24,8 @@
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
-import org.apache.continuum.purge.ContinuumPurgeManager;
-import org.apache.continuum.purge.ContinuumPurgeManagerException;
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -63,7 +63,7 @@
     /**
      * @plexus.requirement
      */
-    private ContinuumPurgeManager purgeManager;
+    private TaskQueueManager taskQueueManager;
 
     public LocalRepository addLocalRepository( LocalRepository localRepository )
         throws RepositoryServiceException
@@ -108,14 +108,14 @@
         {
             LocalRepository repository = getLocalRepository( repositoryId );
 
-            if ( purgeManager.isRepositoryInUse( repositoryId ) )
+            if ( taskQueueManager.isRepositoryInUse( repositoryId ) )
             {
                 return;
             }
 
-            if ( purgeManager.isRepositoryInPurgeQueue( repositoryId ) )
+            if ( taskQueueManager.isRepositoryInPurgeQueue( repositoryId ) )
             {
-                purgeManager.removeRepositoryFromPurgeQueue( repositoryId );
+                taskQueueManager.removeRepositoryFromPurgeQueue( repositoryId );
             }
 
             getLogger().info( "Remove purge configurations of " + repository.getName() );
@@ -133,7 +133,7 @@
 
             getLogger().info( "Removed local repository: " + repository.getName() );
         }
-        catch ( ContinuumPurgeManagerException e )
+        catch ( TaskQueueManagerException e )
         {
             // swallow?
         }
@@ -151,7 +151,7 @@
 
         try
         {
-            if ( purgeManager.isRepositoryInUse( localRepository.getId() ) )
+            if ( taskQueueManager.isRepositoryInUse( localRepository.getId() ) )
             {
                 return;
             }
@@ -160,7 +160,7 @@
 
             getLogger().info( "Updated local repository: " + localRepository.getName() );
         }
-        catch ( ContinuumPurgeManagerException e )
+        catch ( TaskQueueManagerException e )
         {
             // swallow?
         }

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=709300&r1=709299&r2=709300&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 Thu Oct 30 17:01:38 2008
@@ -33,7 +33,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildResultDao;
@@ -42,22 +41,24 @@
 import org.apache.continuum.dao.NotifierDao;
 import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.dao.ProjectGroupDao;
+import org.apache.continuum.dao.ProjectScmRootDao;
 import org.apache.continuum.dao.ScheduleDao;
+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.repository.RepositoryService;
+import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 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;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.core.action.AbstractContinuumAction;
 import org.apache.maven.continuum.core.action.CreateProjectsFromMetadataAction;
-import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
 import org.apache.maven.continuum.initialization.ContinuumInitializationException;
@@ -78,7 +79,7 @@
 import org.apache.maven.continuum.project.builder.maven.MavenOneContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.maven.MavenTwoContinuumProjectBuilder;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
-import org.apache.maven.continuum.scm.queue.CheckOutTask;
+import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
 import org.apache.maven.continuum.store.ContinuumObjectNotFoundException;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.apache.maven.continuum.utils.ContinuumUrlValidator;
@@ -89,7 +90,6 @@
 import org.codehaus.plexus.action.Action;
 import org.codehaus.plexus.action.ActionManager;
 import org.codehaus.plexus.action.ActionNotFoundException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -99,10 +99,7 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
-import org.codehaus.plexus.taskqueue.Task;
-import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
@@ -170,6 +167,11 @@
     /**
      * @plexus.requirement
      */
+    private ProjectScmRootDao projectScmRootDao;
+    
+    /**
+     * @plexus.requirement
+     */
     private ContinuumInitializer initializer;
 
     /**
@@ -197,16 +199,6 @@
     // ----------------------------------------------------------------------
 
     /**
-     * @plexus.requirement role-hint="build-project"
-     */
-    private TaskQueue buildQueue;
-
-    /**
-     * @plexus.requirement role-hint="check-out-project"
-     */
-    private TaskQueue checkoutQueue;
-
-    /**
      * @plexus.requirement
      */
     private ContinuumReleaseManager releaseManager;
@@ -251,6 +243,11 @@
      */
     private PurgeConfigurationService purgeConfigurationService;
 
+    /**
+     * @plexus.requirement
+     */
+    private TaskQueueManager taskQueueManager;
+
     public DefaultContinuum()
     {
         Runtime.getRuntime().addShutdownHook( new Thread()
@@ -293,6 +290,11 @@
     {
         return repositoryService;
     }
+    
+    public TaskQueueManager getTaskQueueManager()
+    {
+        return taskQueueManager;
+    }
 
     public PurgeConfigurationService getPurgeConfigurationService()
     {
@@ -356,6 +358,20 @@
             {
                 removeProject( ( (Project) o ).getId() );
             }
+
+            List<ProjectScmRoot> projectScmRoots = getProjectScmRootByProjectGroup( projectGroupId );
+
+            for ( ProjectScmRoot projectScmRoot : projectScmRoots )
+            {
+                try
+                {
+                    projectScmRootDao.removeProjectScmRoot( projectScmRoot );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    throw new ContinuumException( "unable to delete project scm root: " + projectScmRoot.getScmRootAddress() );
+                }
+            }
         }
 
         getLogger().info( "Remove project group " + projectGroup.getName() + "(" + projectGroup.getId() + ")" );
@@ -549,286 +565,9 @@
     }
 
     // ----------------------------------------------------------------------
-    // Queues
-    // ----------------------------------------------------------------------
-
-    public List<BuildProjectTask> getProjectsInBuildQueue()
-        throws ContinuumException
-    {
-        try
-        {
-            return buildQueue.getQueueSnapshot();
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new ContinuumException( "Error while getting the building queue.", e );
-        }
-    }
-
-    public boolean isInBuildingQueue( int projectId )
-        throws ContinuumException
-    {
-        return isInBuildingQueue( projectId, -1 );
-    }
-
-    public boolean isInBuildingQueue( int projectId, int buildDefinitionId )
-        throws ContinuumException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( buildDefinitionId < 0 )
-                {
-                    if ( task.getProjectId() == projectId )
-                    {
-                        return true;
-                    }
-                }
-                else
-                {
-                    if ( task.getProjectId() == projectId && task.getBuildDefinitionId() == buildDefinitionId )
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-
-        return false;
-    }
-
-    public boolean isInCheckoutQueue( int projectId )
-        throws ContinuumException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    public List<CheckOutTask> getCheckOutTasksInQueue()
-        throws ContinuumException
-    {
-        try
-        {
-            return checkoutQueue.getQueueSnapshot();
-        }
-        catch ( TaskQueueException e )
-        {
-            throw new ContinuumException( "Error while getting the checkout queue.", e );
-        }
-    }
-
-    public TaskQueueExecutor getBuildTaskQueueExecutor()
-        throws ContinuumException
-    {
-        try
-        {
-            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "build-project" );
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new ContinuumException( e.getMessage(), e );
-        }
-    }
-
-    public int getCurrentProjectIdBuilding()
-        throws ContinuumException
-    {
-        Task task = getBuildTaskQueueExecutor().getCurrentTask();
-        if ( task != null )
-        {
-            if ( task instanceof BuildProjectTask )
-            {
-                return ( (BuildProjectTask) task ).getProjectId();
-            }
-        }
-        return -1;
-    }
-
-    public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
-        throws ContinuumException
-    {
-        BuildDefinition buildDefinition = getBuildDefinition( buildDefinitionId );
-        String buildDefinitionLabel = buildDefinition.getDescription();
-        if ( StringUtils.isEmpty( buildDefinitionLabel ) )
-        {
-            buildDefinitionLabel = buildDefinition.getGoals();
-        }
-        BuildProjectTask buildProjectTask =
-            new BuildProjectTask( projectId, buildDefinitionId, trigger, projectName, buildDefinitionLabel );
-        return this.buildQueue.remove( buildProjectTask );
-    }
-
-    public boolean removeProjectsFromBuildingQueue( int[] projectsId )
-        throws ContinuumException
-    {
-        if ( projectsId == null )
-        {
-            return false;
-        }
-        if ( projectsId.length < 1 )
-        {
-            return false;
-        }
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-
-        List<BuildProjectTask> tasks = new ArrayList<BuildProjectTask>();
-
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( ArrayUtils.contains( projectsId, task.getProjectId() ) )
-                {
-                    tasks.add( task );
-                }
-            }
-        }
-
-        for ( BuildProjectTask buildProjectTask : tasks )
-        {
-            getLogger().info( "cancel build for project " + buildProjectTask.getProjectId() );
-        }
-        if ( !tasks.isEmpty() )
-        {
-            return buildQueue.removeAll( tasks );
-        }
-
-        return false;
-    }
-
-    public boolean removeProjectsFromCheckoutQueue( int[] projectsId )
-        throws ContinuumException
-    {
-        if ( projectsId == null )
-        {
-            return false;
-        }
-        if ( projectsId.length < 1 )
-        {
-            return false;
-        }
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-
-        List<CheckOutTask> tasks = new ArrayList<CheckOutTask>();
-
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null )
-            {
-                if ( ArrayUtils.contains( projectsId, task.getProjectId() ) )
-                {
-                    tasks.add( task );
-                }
-            }
-        }
-        if ( !tasks.isEmpty() )
-        {
-            return checkoutQueue.removeAll( tasks );
-        }
-        return false;
-    }
-
-    public boolean removeProjectFromBuildingQueue( int projectId )
-        throws ContinuumException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-
-        for ( BuildProjectTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return buildQueue.remove( task );
-            }
-        }
-
-        return false;
-    }
-
-    public void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
-        throws ContinuumException
-    {
-        List<BuildProjectTask> queue = getProjectsInBuildQueue();
-
-        for ( BuildProjectTask task : queue )
-        {
-            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
-            {
-                buildQueue.remove( task );
-            }
-        }
-    }
-
-    public boolean removeProjectFromCheckoutQueue( int projectId )
-        throws ContinuumException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-
-        for ( CheckOutTask task : queue )
-        {
-            if ( task != null && task.getProjectId() == projectId )
-            {
-                return checkoutQueue.remove( task );
-            }
-        }
-
-        return false;
-    }
-
-    public void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
-        throws ContinuumException
-    {
-        List<CheckOutTask> queue = getCheckOutTasksInQueue();
-
-        for ( CheckOutTask task : queue )
-        {
-            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
-            {
-                checkoutQueue.remove( task );
-            }
-        }
-    }
-
-    public boolean cancelCurrentBuild()
-        throws ContinuumException
-    {
-        Task task = getBuildTaskQueueExecutor().getCurrentTask();
-        
-        if ( task != null )
-        {
-            if ( task instanceof BuildProjectTask )
-            {
-                getLogger().info( "Cancelling current build task" );
-                return getBuildTaskQueueExecutor().cancelTask( task );
-            }
-            else
-            {
-                getLogger().warn( "Current task not a BuildProjectTask - not cancelling" );
-            }
-        }
-        else
-        {
-            getLogger().warn( "No task running - not cancelling" );
-        }
-        return false;
-    }
-
-    // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
-
     public void removeProject( int projectId )
         throws ContinuumException
     {
@@ -863,32 +602,28 @@
 
             getLogger().info( "Remove project " + project.getName() + "(" + projectId + ")" );
 
-            if ( isInCheckoutQueue( projectId ) )
-            {
-                removeProjectFromCheckoutQueue( projectId );
-            }
-
-            if ( isInBuildingQueue( projectId ) )
-            {
-                removeProjectFromBuildingQueue( projectId );
-            }
-
-            // cancel it if currently building
-
-            if ( getCurrentProjectIdBuilding() == projectId )
+            try
             {
-                Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
+                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
                 {
-                    if ( currentTask instanceof BuildProjectTask )
-                    {
-                        if ( ( (BuildProjectTask) currentTask ).getProjectId() == projectId )
-                        {
-                            getLogger().info( "Cancelling task for project " + projectId );
-                            getBuildTaskQueueExecutor().cancelTask( currentTask );
-                        }
-                    }
+                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                }
+                
+                if ( taskQueueManager.isInBuildingQueue( projectId ) )
+                {
+                    taskQueueManager.removeProjectFromBuildingQueue( projectId );
+                }
+                
+                // cancel if currently building
+                if ( taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                {
+                    taskQueueManager.cancelBuildTask( projectId );
                 }
             }
+            catch ( TaskQueueManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
 
             for ( Object o : project.getBuildResults() )
             {
@@ -1002,22 +737,9 @@
             projectsList = getProjects();
         }
 
-        for ( Project project : projectsList )
-        {
-            Integer buildDefId = null;
-
-            try
-            {
-                buildDefId = new Integer( buildDefinitionDao.getDefaultBuildDefinition( project.getId() ).getId() );
-            }
-            catch ( ContinuumStoreException e )
-            {
-                throw new ContinuumException( "Project (id=" + project.getId() +
-                    " doens't have a default build definition, this should be impossible, parent should have default definition set." );
-            }
+        Collection<Map<Integer,Integer>> projectsAndBuildDefinitions = getProjectsAndBuildDefinitions( projectsList, null, true );
 
-            buildProject( project, buildDefId.intValue(), trigger );
-        }
+        prepareBuildProjects( projectsAndBuildDefinitions, trigger );
     }
 
     /**
@@ -1043,10 +765,9 @@
             projectsList = getProjects();
         }
 
-        for ( Project project : projectsList )
-        {
-            buildProject( project, buildDefinitionId, trigger );
-        }
+        Collection<Map<Integer, Integer>> projectsAndBuildDefinitions = getProjectsAndBuildDefinitions( projectsList, buildDefinitionId );
+
+        prepareBuildProjects( projectsAndBuildDefinitions, trigger );
     }
 
     /**
@@ -1107,55 +828,11 @@
             projectsList = getProjects();
         }
 
-        //Map buildDefinitionsIds = store.getDefaultBuildDefinitions();
-
-        for ( Project project : projectsList )
-        {
-            int buildDefId = -1;
+        Collection<Map<Integer, Integer>> projectsAndBuildDefinitions = getProjectsAndBuildDefinitions( projectsList, 
+                                                                                                        bds,
+                                                                                                        checkDefaultBuildDefinitionForProject );
 
-            for ( BuildDefinition bd : bds )
-            {
-                if ( project.getExecutorId().equals( bd.getType() ) || ( StringUtils.isEmpty( bd.getType() ) &&
-                    ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR.equals( project.getExecutorId() ) ) )
-                {
-                    buildDefId = bd.getId();
-                    break;
-                }
-            }
-
-            if ( checkDefaultBuildDefinitionForProject )
-            {
-                BuildDefinition projectDefaultBD = null;
-                try
-                {
-                    projectDefaultBD = buildDefinitionDao.getDefaultBuildDefinitionForProject( project.getId() );
-                }
-                catch ( ContinuumObjectNotFoundException e )
-                {
-                    getLogger().debug( e.getMessage() );
-                }
-                catch ( ContinuumStoreException e )
-                {
-                    getLogger().debug( e.getMessage() );
-                }
-
-                if ( projectDefaultBD != null )
-                {
-                    buildDefId = projectDefaultBD.getId();
-                    getLogger().debug( "Project " + project.getId() +
-                        " has own default build definition, will use it instead of group's." );
-                }
-            }
-
-            if ( buildDefId == -1 )
-            {
-                getLogger().info( "Project " + project.getId() +
-                    " don't have a default build definition defined in the project or project group, will not be included in group build." );
-                continue;
-            }
-
-            buildProject( project, buildDefId, ContinuumProjectState.TRIGGER_FORCED );
-        }
+        prepareBuildProjects( projectsAndBuildDefinitions, ContinuumProjectState.TRIGGER_FORCED );
     }
 
     /**
@@ -1197,6 +874,8 @@
             projectsList = getProjects();
         }
 
+        Map<String, Map<Integer, Integer>> map = new HashMap<String, Map<Integer, Integer>>();
+
         for ( Project project : projectsList )
         {
             List<Integer> buildDefIds = (List<Integer>) projectsMap.get( new Integer( project.getId() ) );
@@ -1205,14 +884,41 @@
             {
                 for ( Integer buildDefId : buildDefIds )
                 {
-                    if ( buildDefId != null && !isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
-                        !isInCheckoutQueue( project.getId() ) )
+                    try
                     {
-                        buildProject( project, buildDefId.intValue(), ContinuumProjectState.TRIGGER_SCHEDULED, false );
+                        if ( buildDefId != null && !taskQueueManager.isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
+                            !taskQueueManager.isInCheckoutQueue( project.getId() ) && !taskQueueManager.isInPrepareBuildQueue( project.getId() ) )
+                        {
+                            ProjectScmRoot scmRoot = getProjectScmRootByProject( project.getId() );
+                            
+                            String scmRootAddress = "";
+
+                            if ( scmRoot != null )
+                            {
+                                scmRootAddress = scmRoot.getScmRootAddress();
+                            }
+
+                            Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRootAddress );
+                            
+                            if ( projectsAndBuildDefinitionsMap == null )
+                            {
+                                projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+                            }
+                            
+                            projectsAndBuildDefinitionsMap.put( project.getId(), buildDefId );
+                            
+                            map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+                        }
+                    } 
+                    catch ( TaskQueueManagerException e )
+                    {
+                        throw new ContinuumException( e.getMessage(), e );
                     }
                 }
             }
         }
+
+        prepareBuildProjects( map.values(), ContinuumProjectState.TRIGGER_SCHEDULED );
     }
 
     public void buildProject( int projectId )
@@ -1224,133 +930,77 @@
     public void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId )
         throws ContinuumException
     {
-        buildProject( projectId, buildDefinitionId, ContinuumProjectState.TRIGGER_FORCED );
-    }
-
-    public void buildProject( int projectId, int trigger )
-        throws ContinuumException
-    {
-        BuildDefinition buildDef = getDefaultBuildDefinition( projectId );
-
-        if ( buildDef == null )
-        {
-            throw new ContinuumException( "Project (id=" + projectId + " doens't have a default build definition." );
-        }
-
-        if ( isInBuildingQueue( projectId, buildDef.getId() ) || isInCheckoutQueue( projectId ) )
-        {
-            return;
-        }
-
-        buildProject( projectId, buildDef.getId(), trigger, false );
-    }
-
-    public void buildProject( int projectId, int buildDefinitionId, int trigger )
-        throws ContinuumException
-    {
-        buildProject( projectId, buildDefinitionId, trigger, true );
-    }
-
-    public void buildProject( Project project, int buildDefinitionId, int trigger )
-        throws ContinuumException
-    {
-        buildProject( project, buildDefinitionId, trigger, true );
-    }
-
-    private void buildProject( int projectId, int buildDefinitionId, int trigger, boolean checkQueues )
-        throws ContinuumException
-    {
-        Project project;
-
         try
         {
-            project = projectDao.getProject( projectId );
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw logAndCreateException( "Error while getting project " + projectId + ".", e );
-        }
-
-        buildProject( project, buildDefinitionId, trigger, checkQueues );
-    }
-
-    private synchronized void buildProject( Project project, int buildDefinitionId, int trigger, boolean checkQueues )
-        throws ContinuumException
-    {
-        if ( checkQueues )
-        {
-            if ( isInBuildingQueue( project.getId(), buildDefinitionId ) )
+            if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.isInPrepareBuildQueue( projectId ) )
             {
                 return;
             }
-            if ( isInCheckoutQueue( project.getId() ) )
-            {
-                removeProjectFromCheckoutQueue( project.getId() );
-            }
-        }
-
-        try
-        {
-            if ( project.getState() != ContinuumProjectState.NEW &&
-                project.getState() != ContinuumProjectState.CHECKEDOUT &&
-                project.getState() != ContinuumProjectState.OK && project.getState() != ContinuumProjectState.FAILED &&
-                project.getState() != ContinuumProjectState.ERROR )
-            {
-                ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId() );
-
-                if ( executor.isBuilding( project ) || project.getState() == ContinuumProjectState.UPDATING )
-                {
-                    // project is building
-                    getLogger().info( "Project '" + project.getName() + "' already being built." );
-
-                    return;
-                }
-                else
-                {
-                    project.setOldState( project.getState() );
-
-                    project.setState( ContinuumProjectState.ERROR );
-
-                    projectDao.updateProject( project );
-
-                    project = projectDao.getProject( project.getId() );
-                }
-            }
-            else
+
+            if ( taskQueueManager.isInCheckoutQueue( projectId ) )
             {
-                project.setOldState( project.getState() );
+                taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+            }
+        }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
 
-                projectDao.updateProject( project );
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>( projectId, buildDefinitionId );
 
-                project = projectDao.getProject( project.getId() );
-            }
+        prepareBuildProjects( projectsAndBuildDefinitionsMap, ContinuumProjectState.TRIGGER_FORCED );
+    }
+
+    public void buildProject( int projectId, int trigger )
+        throws ContinuumException
+    {
+        BuildDefinition buildDef = getDefaultBuildDefinition( projectId );
+
+        if ( buildDef == null )
+        {
+            throw new ContinuumException( "Project (id=" + projectId + " doens't have a default build definition." );
+        }
 
-            BuildDefinition buildDefinition = getBuildDefinition( buildDefinitionId );
-            String buildDefinitionLabel = buildDefinition.getDescription();
-            if ( StringUtils.isEmpty( buildDefinitionLabel ) )
+        try
+        {
+            if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) || 
+                 taskQueueManager.isInCheckoutQueue( projectId ) ||
+                 taskQueueManager.isInPrepareBuildQueue( projectId ))
             {
-                buildDefinitionLabel = buildDefinition.getGoals();
+                return;
             }
+        }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
 
-            getLogger().info( "Enqueuing '" + project.getName() + "' with build definition '" + buildDefinitionLabel +
-                "' - id=" + buildDefinitionId + ")." );
+        Map<Integer, Integer> projectsBuildDefinitionsMap = new HashMap<Integer, Integer>( projectId, buildDef.getId() );
 
-            BuildProjectTask task = new BuildProjectTask( project.getId(), buildDefinitionId, trigger, project
-                .getName(), buildDefinitionLabel );
+        prepareBuildProjects( projectsBuildDefinitionsMap, trigger );
+    }
 
-            task.setMaxExecutionTime( buildDefinitionDao.getBuildDefinition( buildDefinitionId ).getSchedule()
-                .getMaxJobExecutionTime() * 1000 );
+    public void buildProject( int projectId, int buildDefinitionId, int trigger )
+        throws ContinuumException
+    {
+        Project project;
 
-            buildQueue.put( task );
-        }
-        catch ( ContinuumStoreException e )
+        try
         {
-            throw logAndCreateException( "Error while creating build object.", e );
+            project = projectDao.getProject( projectId );
         }
-        catch ( TaskQueueException e )
+        catch ( ContinuumStoreException e )
         {
-            throw logAndCreateException( "Error while creating enqueuing object.", e );
+            throw logAndCreateException( "Error while getting project " + projectId + ".", e );
         }
+
+        Map context = new HashMap();
+        context.put( AbstractContinuumAction.KEY_PROJECT, project );
+        context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION_ID, buildDefinitionId );
+        context.put( AbstractContinuumAction.KEY_TRIGGER, trigger );
+        
+        executeAction( "create-build-project-task", context );
     }
 
     public BuildResult getBuildResult( int buildId )
@@ -1488,6 +1138,32 @@
         return changes;
     }
 
+    public List<ChangeSet> getChangesSinceLastUpdate( int projectId )
+        throws ContinuumException
+    {
+        List<ChangeSet> changes = new ArrayList<ChangeSet>();
+        
+        Project project;
+        
+        try
+        {
+            project = projectDao.getProjectWithScmDetails( projectId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "", e );
+        }
+        
+        ScmResult scmResult = project.getScmResult();
+        
+        if ( scmResult != null )
+        {
+            changes.addAll( scmResult.getChanges() );
+        }
+        
+        return changes;
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -1877,6 +1553,8 @@
 
         ProjectGroup projectGroup = (ProjectGroup) result.getProjectGroups().iterator().next();
 
+        ProjectScmRoot projectScmRoot;
+
         try
         {
             if ( projectGroupId == -1 )
@@ -1911,6 +1589,15 @@
 
             projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
+            String url = (String) context.get( CreateProjectsFromMetadataAction.KEY_URL );
+            
+            projectScmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
+            
+            if ( projectScmRoot == null )
+            {
+                projectScmRoot = createProjectScmRoot( projectGroup, url );
+            }
+
             /* add the project group loaded from database, which has more info, like id */
             result.getProjectGroups().remove( 0 );
             result.getProjectGroups().add( projectGroup );
@@ -2155,6 +1842,8 @@
 
         notif.setSendOnWarning( notifier.isSendOnWarning() );
 
+        notif.setSendOnScmFailure( notifier.isSendOnScmFailure() );
+
         notif.setConfiguration( notifier.getConfiguration() );
 
         notif.setType( notifier.getType() );
@@ -2183,6 +1872,8 @@
 
         notif.setSendOnWarning( notifier.isSendOnWarning() );
 
+        notif.setSendOnScmFailure( notifier.isSendOnScmFailure() );
+
         notif.setConfiguration( notifier.getConfiguration() );
 
         notif.setType( notifier.getType() );
@@ -2810,6 +2501,19 @@
             }
         }
 
+        getLogger().info( "Showing all groups:" );
+        try
+        {
+            for ( ProjectGroup group : projectGroupDao.getAllProjectGroups() )
+            {
+                createProjectScmRootForProjectGroup( group );
+            }
+        }
+        catch ( ContinuumException e )
+        {
+            throw new InitializationException( "Error while creating project scm root for the project group", e );
+        }
+
         getLogger().info( "Showing all projects: " );
 
         for ( Project project : projectDao.getAllProjectsByNameWithBuildDetails() )
@@ -2863,6 +2567,27 @@
             getLogger().info( " " + project.getId() + ":" + project.getName() + ":" + project.getVersion() + ":" +
                 project.getExecutorId() );
         }
+
+        for ( ProjectScmRoot projectScmRoot : projectScmRootDao.getAllProjectScmRoots() )
+        {
+            if ( projectScmRoot.getState() == ContinuumProjectState.UPDATING )
+            {
+                projectScmRoot.setState( projectScmRoot.getOldState() );
+
+                projectScmRoot.setOldState( 0 );
+
+                try
+                {
+                    getLogger().info( "Fix state for projectScmRoot " + projectScmRoot.getScmRootAddress() );
+                    
+                    projectScmRootDao.updateProjectScmRoot( projectScmRoot );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    throw new InitializationException( "Database is corrupted.", e );
+                }
+            }
+        }
     }
 
     // --------------------------------
@@ -3442,4 +3167,271 @@
             throw new ContinuumException( "Error while retrieving release output for release: " + releaseResultId );
         }
     }
+
+    public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId )
+    {
+        return projectScmRootDao.getProjectScmRootByProjectGroup( projectGroupId );
+    }
+
+    public ProjectScmRoot getProjectScmRoot( int projectScmRootId )
+        throws ContinuumException
+    {
+        try
+        {
+            return projectScmRootDao.getProjectScmRoot( projectScmRootId );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            throw new ContinuumException( "No projectScmRoot found with the given id: " + projectScmRootId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while retrieving projectScmRoot ", e );
+        }
+    }
+
+    public ProjectScmRoot getProjectScmRootByProject( int projectId )
+        throws ContinuumException
+    {
+        Project project = getProject( projectId );
+        ProjectGroup group = getProjectGroupByProjectId( projectId );
+        
+        List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( group.getId() );
+        
+        for ( ProjectScmRoot scmRoot : scmRoots )
+        {
+            if( project.getScmUrl() != null && project.getScmUrl().startsWith( scmRoot.getScmRootAddress() ) )
+            {
+                return scmRoot;
+            }
+        }
+        return null;
+    }
+   
+    public Collection<Map<Integer, Integer>> getProjectsAndBuildDefinitions( Collection<Project> projects, 
+                                                                             List<BuildDefinition> bds,
+                                                                             boolean checkDefaultBuildDefinitionForProject )
+        throws ContinuumException
+    {
+        Map<String, Map<Integer, Integer>> map = new HashMap<String, Map<Integer, Integer>>();
+
+        for ( Project project : projects )
+        {
+            int projectId = project.getId();
+            
+            try
+            {
+                // check if project already in queue
+                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                {
+                    continue;
+                }
+                
+                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                {
+                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                }
+            }
+            catch ( TaskQueueManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+            
+            int buildDefId = -1;
+
+            if ( bds != null )
+            {
+                for ( BuildDefinition bd : bds )
+                {
+                    if ( project.getExecutorId().equals( bd.getType() ) || ( StringUtils.isEmpty( bd.getType() ) &&
+                        ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR.equals( project.getExecutorId() ) ) )
+                    {
+                        buildDefId = bd.getId();
+                        break;
+                    }
+                }
+            }
+
+            if ( checkDefaultBuildDefinitionForProject )
+            {
+                BuildDefinition projectDefaultBD = null;
+                try
+                {
+                    projectDefaultBD = buildDefinitionDao.getDefaultBuildDefinitionForProject( projectId );
+                }
+                catch ( ContinuumObjectNotFoundException e )
+                {
+                    getLogger().debug( e.getMessage() );
+                }
+                catch ( ContinuumStoreException e )
+                {
+                    getLogger().debug( e.getMessage() );
+                }
+
+                if ( projectDefaultBD != null )
+                {
+                    buildDefId = projectDefaultBD.getId();
+                    getLogger().debug( "Project " + project.getId() +
+                        " has own default build definition, will use it instead of group's." );
+                }
+            }
+
+            if ( buildDefId == -1 )
+            {
+                getLogger().info( "Project " + projectId +
+                    " don't have a default build definition defined in the project or project group, will not be included in group prepare." );
+                continue;
+            }
+
+            ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
+
+            String scmRootAddress = "";
+            if ( scmRoot != null )
+            {
+                scmRootAddress = scmRoot.getScmRootAddress();
+            }
+
+            Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRootAddress );
+
+            if ( projectsAndBuildDefinitionsMap == null )
+            {
+                projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+            }
+
+            projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
+
+            map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+        }
+
+        return map.values();
+    }
+
+    public Collection<Map<Integer, Integer>> getProjectsAndBuildDefinitions( Collection<Project> projects, 
+                                                                             int buildDefinitionId )
+        throws ContinuumException
+    {
+        Map<String, Map<Integer,Integer>> map = new HashMap<String, Map<Integer, Integer>>();
+
+        for ( Project project : projects )
+        {
+            int projectId = project.getId();
+
+            try
+            {
+                // check if project already in queue
+                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                {
+                    continue;
+                }
+                
+                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                {
+                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                }
+                
+                ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
+
+                String scmRootAddress = "";
+                if ( scmRoot != null )
+                {
+                    scmRootAddress = scmRoot.getScmRootAddress();
+                }
+                
+                Map<Integer, Integer> projectsAndBuildDefinitionsMap = map.get( scmRootAddress );
+                
+                if ( projectsAndBuildDefinitionsMap == null )
+                {
+                    projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+                }
+                
+                projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );
+                
+                map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
+            }
+            catch ( TaskQueueManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+        }
+
+        return map.values();
+    }
+
+    public void prepareBuildProjects( Collection<Map<Integer, Integer>> projectsBuildDefinitions, int trigger )
+        throws ContinuumException
+    {
+        for ( Map<Integer, Integer> map : projectsBuildDefinitions )
+        {
+            prepareBuildProjects( map, trigger );
+        }
+    }
+
+    public void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger )
+        throws ContinuumException
+    {
+        try
+        {
+            PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger );
+            taskQueueManager.getPrepareBuildQueue().put( task );
+        }
+        catch ( TaskQueueException e )
+        {
+            throw logAndCreateException( "Error while creating enqueuing object.", e );
+        }
+    }
+
+    private void createProjectScmRootForProjectGroup( ProjectGroup projectGroup )
+        throws ContinuumException
+    {
+        List<Project> projectsList;
+
+        try
+        {
+            projectsList = getProjectsInBuildOrder( projectDao.getProjectsWithDependenciesByGroupId( projectGroup.getId() ) );
+        }
+        catch ( CycleDetectedException e )
+        {
+            throw new ContinuumException( "Error while retrieving projects", e );
+        }
+
+        int counter = 0;
+        String url = "";
+
+        for ( Project project : projectsList )
+        {
+            if ( counter == 0 || !project.getScmUrl().startsWith( url ) )
+            {
+                // this is a root
+                url = project.getScmUrl();
+                createProjectScmRoot( projectGroup, url );
+            }
+            counter++;
+        }
+    }
+    
+    private ProjectScmRoot createProjectScmRoot( ProjectGroup projectGroup, String url )
+        throws ContinuumException
+    {
+        try
+        {
+            ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
+
+            if ( scmRoot != null )
+            {
+                return null;
+            }
+
+            ProjectScmRoot projectScmRoot = new ProjectScmRoot();
+
+            projectScmRoot.setProjectGroup( projectGroup );
+
+            projectScmRoot.setScmRootAddress( url );
+
+            return projectScmRootDao.addProjectScmRoot( projectScmRoot );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while creating project scm root with scm root address:" + url );
+        }
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java?rev=709300&r1=709299&r2=709300&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java Thu Oct 30 17:01:38 2008
@@ -57,6 +57,8 @@
 
     private List<ProjectDependency> modifiedDependencies;
 
+    private boolean cancelled;
+
     public void setStartTime( long startTime )
     {
         this.startTime = startTime;
@@ -159,4 +161,14 @@
     {
         this.modifiedDependencies = modifiedDependencies;
     }
+
+    public boolean isCancelled()
+    {
+        return cancelled;
+    }
+
+    public void setCancelled( boolean cancelled )
+    {
+        this.cancelled = cancelled;
+    }
 }