continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r691239 [1/3] - in /continuum/branches/continuum-transient-state: 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/ cont...
Date Tue, 02 Sep 2008 13:24:52 GMT
Author: ctan
Date: Tue Sep  2 06:24:15 2008
New Revision: 691239

URL: http://svn.apache.org/viewvc?rev=691239&view=rev
Log:
[CONTINUUM-1864] Transient State
Start some jobs
Todo: configurable notification

Added:
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTask.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
    continuum/branches/continuum-transient-state/continuum-store/src/main/java/org/apache/continuum/dao/ProjectScmRootDaoImpl.java
Modified:
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java
    continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildProjectTaskExecutor.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java
    continuum/branches/continuum-transient-state/continuum-core/src/main/resources/META-INF/plexus/components.xml
    continuum/branches/continuum-transient-state/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java
    continuum/branches/continuum-transient-state/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    continuum/branches/continuum-transient-state/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
    continuum/branches/continuum-transient-state/continuum-data-management/data-management-jdo/src/test/resources/expected.xml
    continuum/branches/continuum-transient-state/continuum-model/pom.xml
    continuum/branches/continuum-transient-state/continuum-model/src/main/mdo/continuum.xml
    continuum/branches/continuum-transient-state/continuum-store/src/main/java/org/apache/continuum/dao/AbstractDao.java
    continuum/branches/continuum-transient-state/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
    continuum/branches/continuum-transient-state/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
    continuum/branches/continuum-transient-state/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/branches/continuum-transient-state/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectsListAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/AbstractBuildQueueAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/util/StateGenerator.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/java/org/apache/maven/continuum/web/view/StateCell.java
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/branches/continuum-transient-state/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
    continuum/branches/continuum-transient-state/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Modified: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java (original)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java Tue Sep  2 06:24:15 2008
@@ -57,6 +57,9 @@
     Project getProjectWithCheckoutResult( int projectId )
         throws ContinuumStoreException;
 
+    Project getProjectWithScmResult( int projectId )
+        throws ContinuumStoreException;
+
     List<Project> getProjectsInGroup( int projectGroupId )
         throws ContinuumStoreException;
 

Added: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java?rev=691239&view=auto
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java (added)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/dao/ProjectScmRootDao.java Tue Sep  2 06:24:15 2008
@@ -0,0 +1,47 @@
+package org.apache.continuum.dao;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+import org.apache.continuum.model.project.ProjectScmRoot;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
+ */
+public interface ProjectScmRootDao
+{
+    ProjectScmRoot addProjectScmRoot( ProjectScmRoot projectScmRoot )
+        throws ContinuumStoreException;
+
+    void updateProjectScmRoot( ProjectScmRoot projectScmRoot )
+        throws ContinuumStoreException;
+
+    void removeProjectScmRoot( ProjectScmRoot projectScmRoot )
+        throws ContinuumStoreException;
+
+    List<ProjectScmRoot> getAllProjectScmRoots();
+
+    List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId );
+
+    ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
+        throws ContinuumStoreException;
+}

Modified: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java (original)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java Tue Sep  2 06:24:15 2008
@@ -55,7 +55,7 @@
      */
     void purgeDirectory( DirectoryPurgeConfiguration dirPurgeConfig )
         throws ContinuumPurgeManagerException;
-    
+    /*
     /**
      * Check if the repository is already in the purging queue
      * 
@@ -63,7 +63,7 @@
      * @return true if the repository is in the purging queue, otherwise false
      * @throws ContinuumPurgeManagerException
      */
-    boolean isRepositoryInPurgeQueue( int repositoryId )
+/*    boolean isRepositoryInPurgeQueue( int repositoryId )
         throws ContinuumPurgeManagerException;
     
     /**
@@ -73,7 +73,7 @@
      * @return true if the repository is in use, otherwise false
      * @throws ContinuumPurgeManagerException
      */
-    boolean isRepositoryInUse( int repositoryId )
+/*    boolean isRepositoryInUse( int repositoryId )
         throws ContinuumPurgeManagerException;
 
     /**
@@ -82,7 +82,7 @@
      * @param repositoryId the id of the local repository
      * @throws ContinuumPurgeManagerException
      */
-    void removeRepositoryFromPurgeQueue( int repositoryId )
+/*    void removeRepositoryFromPurgeQueue( int repositoryId )
         throws ContinuumPurgeManagerException;
     
     /**
@@ -92,7 +92,7 @@
      * @return true if the purge configuration was successfully removed from the purge queue, otherwise false
      * @throws ContinuumPurgeManagerException
      */
-    boolean removeFromPurgeQueue( int purgeConfigId )
+/*    boolean removeFromPurgeQueue( int purgeConfigId )
         throws ContinuumPurgeManagerException;
     
     /**
@@ -102,6 +102,6 @@
      * @return true if the purge configurations were successfully removed from the purge queue, otherwise false
      * @throws ContinuumPurgeManagerException
      */
-    boolean removeFromPurgeQueue( int[] purgeConfigIds )
-        throws ContinuumPurgeManagerException;
+/*    boolean removeFromPurgeQueue( int[] purgeConfigIds )
+        throws ContinuumPurgeManagerException;*/
 }

Added: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=691239&view=auto
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java (added)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java Tue Sep  2 06:24:15 2008
@@ -0,0 +1,143 @@
+package org.apache.continuum.taskqueue.manager;
+
+import java.util.List;
+
+import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+
+/**
+ * @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
+ */
+public interface TaskQueueManager
+{
+    String ROLE = TaskQueueManager.class.getName();
+
+    boolean buildInProgress()
+        throws TaskQueueManagerException;
+
+    void cancelBuildTask( int projectId )
+        throws TaskQueueManagerException;
+    
+    void cancelCheckoutTask( int projectId )
+        throws TaskQueueManagerException;
+
+    TaskQueue getBuildQueue();
+
+    TaskQueueExecutor getBuildTaskQueueExecutor()
+        throws TaskQueueManagerException;
+
+    TaskQueue getCheckoutQueue();
+
+    List /* CheckOutTask */getCheckOutTasksInQueue()
+        throws TaskQueueManagerException;
+
+    int getCurrentProjectIdBuilding()
+        throws TaskQueueManagerException;
+
+    TaskQueue getPrepareBuildQueue();
+
+    TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+        throws TaskQueueManagerException;
+
+    public List<BuildProjectTask> getProjectsInBuildQueue()
+        throws TaskQueueManagerException;
+
+    TaskQueue getPurgeQueue();
+
+    boolean isInBuildingQueue( int projectId )
+        throws TaskQueueManagerException;
+
+    boolean isInBuildingQueue( int projectId, int buildDefinitionId )
+        throws TaskQueueManagerException;
+
+    boolean isInCheckoutQueue( int projectId )
+        throws TaskQueueManagerException;
+
+    boolean isInPrepareBuildQueue( int projectId )
+        throws TaskQueueManagerException;
+
+    boolean isInPurgeQueue( int purgeConfigurationId )
+        throws TaskQueueManagerException;
+
+    /**
+     * 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 TaskQueueManagerException
+     */
+    boolean isRepositoryInPurgeQueue( int repositoryId )
+        throws TaskQueueManagerException;
+
+    /**
+     * 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 TaskQueueManagerException
+     */
+    boolean isRepositoryInUse( int repositoryId )
+        throws TaskQueueManagerException;
+
+    boolean releaseInProgress()
+        throws TaskQueueManagerException;
+
+    boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
+        throws TaskQueueManagerException;
+
+    /**
+     * 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 TaskQueueManagerException
+     */
+    boolean removeFromPurgeQueue( int purgeConfigId )
+        throws TaskQueueManagerException;
+
+    /**
+     * 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 TaskQueueManagerException
+     */
+    boolean removeFromPurgeQueue( int[] purgeConfigIds )
+        throws TaskQueueManagerException;
+
+    boolean removeProjectFromBuildingQueue( int projectId )
+        throws TaskQueueManagerException;
+
+    boolean removeProjectsFromBuildingQueue( int[] projectsId )
+        throws TaskQueueManagerException;
+
+    /**
+     * @param hashCodes BuildProjectTask hashCodes
+     * @throws TaskQueueManagerException
+     */
+    void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException;
+
+    boolean removeProjectFromCheckoutQueue( int projectId )
+        throws TaskQueueManagerException;
+
+    boolean removeProjectsFromCheckoutQueue( int[] projectId )
+        throws TaskQueueManagerException;
+
+    /**
+     * Remove local repository from the purge queue
+     * 
+     * @param repositoryId the id of the local repository
+     * @throws TaskQueueManagerException
+     */
+    void removeRepositoryFromPurgeQueue( int repositoryId )
+        throws TaskQueueManagerException;
+
+    /**
+     * @param hashCodes CheckOutTask hashCodes
+     * @throws TaskQueueManagerException
+     */
+    void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException;
+}

Added: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java?rev=691239&view=auto
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java (added)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManagerException.java Tue Sep  2 06:24:15 2008
@@ -0,0 +1,20 @@
+package org.apache.continuum.taskqueue.manager;
+
+public class TaskQueueManagerException
+    extends Exception
+{
+    public TaskQueueManagerException( String message )
+    {
+        super( message );
+    }
+
+    public TaskQueueManagerException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    public TaskQueueManagerException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}

Modified: continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/branches/continuum-transient-state/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Tue Sep  2 06:24:15 2008
@@ -24,8 +24,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.purge.ContinuumPurgeManager;
 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;
@@ -40,6 +42,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,7 +149,7 @@
     // ----------------------------------------------------------------------
     // Queues
     // ----------------------------------------------------------------------
-
+/*
     public List<BuildProjectTask> getProjectsInBuildQueue()
         throws ContinuumException;
 
@@ -163,7 +166,7 @@
      * @param hashCodes BuildProjectTask hashCodes
      * @throws ContinuumException
      */
-    void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
+/*    void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
         throws ContinuumException;
 
     boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
@@ -175,7 +178,7 @@
     boolean removeProjectFromCheckoutQueue( int projectId )
         throws ContinuumException;
 
-    List /* CheckOutTask */getCheckOutTasksInQueue()
+    List /* CheckOutTask *//*getCheckOutTasksInQueue()
         throws ContinuumException;
 
     boolean removeProjectsFromCheckoutQueue( int[] projectId )
@@ -185,9 +188,15 @@
      * @param hashCodes CheckOutTask hashCodes
      * @throws ContinuumException
      */
-    void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
+/*    void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
         throws ContinuumException;
 
+    TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+        throws ContinuumException;
+    
+    boolean isProjectInPrepareBuild( int projectId )
+        throws ContinuumException;
+*/    
     // ----------------------------------------------------------------------
     // Building
     // ----------------------------------------------------------------------
@@ -256,12 +265,22 @@
     Collection<BuildResult> getBuildResultsForProject( int projectId )
         throws ContinuumException;
 
+    /**
+     * @deprecated
+     * @param projectId
+     * @param buildResultId
+     * @return
+     * @throws ContinuumException
+     */
     List<ChangeSet> getChangesSinceLastSuccess( int projectId, int buildResultId )
         throws ContinuumException;
 
     void removeBuildResult( int buildId )
         throws ContinuumException;
 
+    List<ChangeSet> getChangesSinceLastUpdate( int projectId )
+        throws ContinuumException;
+    
     // ----------------------------------------------------------------------
     // Projects
     // ----------------------------------------------------------------------
@@ -632,17 +651,42 @@
     ProfileService getProfileService();
 
     BuildDefinitionService getBuildDefinitionService();
-    
+
     // ----------------------------------------------------------------------
     // Continuum Purge
     // ----------------------------------------------------------------------
     ContinuumPurgeManager getPurgeManager();
-    
+
     // ----------------------------------------------------------------------
     // Repository Service
     // ----------------------------------------------------------------------
     RepositoryService getRepositoryService();
-    
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+    List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId );
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+    Map<Integer, Integer> getProjectsAndBuildDefinitionsMap( Collection<Project> projects, 
+                                                             List<BuildDefinition> bds,
+                                                             boolean checkDefaultBuildDefinitionForProject )
+        throws ContinuumException;
+
+    Map<Integer, Integer> getProjectsAndBuildDefinitionsMap( Collection<Project> projects, 
+                                                             int buildDefinitionId )
+        throws ContinuumException;
+
+    void prepareBuildProjects( Map<Integer, Integer> projectsAndBuildDefinitionsMap )
+        throws ContinuumException;
+
+    // ----------------------------------------------------------------------
+    // Task Queue Manager
+    // ----------------------------------------------------------------------
+    TaskQueueManager getTaskQueueManager();
+
     public void startup()
         throws ContinuumException;
 }

Modified: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java (original)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java Tue Sep  2 06:24:15 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,25 +45,28 @@
  * @since 25 jul 07
  */
 public class DefaultContinuumPurgeManager
-    implements ContinuumPurgeManager, Contextualizable
+    implements ContinuumPurgeManager
 {
     /**
      * @plexus.requirement
      */
     private ProjectDao projectDao;
-
+/*
     /**
      * @plexus.requirement role-hint="purge"
      */
-    private TaskQueue purgeQueue;
+//    private TaskQueue purgeQueue;
 
     /**
      * @plexus.requirement
      */
     private PurgeConfigurationService purgeConfigurationService;
 
-    private PlexusContainer container;
-
+    /**
+     * @plexus.requirement
+     */
+    private TaskQueueManager taskQueueManager;
+    
     public void purge( Schedule schedule )
         throws ContinuumPurgeManagerException
     {
@@ -97,7 +92,7 @@
             }
         }
     }
-
+/*
     public boolean isRepositoryInPurgeQueue( int repositoryId )
         throws ContinuumPurgeManagerException
     {
@@ -106,9 +101,16 @@
 
         for ( RepositoryPurgeConfiguration repoPurge : repoPurgeConfigs )
         {
-            if ( isInPurgeQueue( repoPurge.getId() ) )
+            try
             {
-                return true;
+                if ( taskQueueManager.isInPurgeQueue( repoPurge.getId() ) )
+                {
+                    return true;
+                }
+            }
+            catch ( TaskQueueManagerException e )
+            {
+                throw new ContinuumPurgeManagerException( e.getMessage(), e );
             }
         }
         return false;
@@ -203,7 +205,7 @@
         }
         return false;
     }
-
+*/
     public void purgeRepository( RepositoryPurgeConfiguration repoPurge )
         throws ContinuumPurgeManagerException
     {
@@ -212,15 +214,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 +238,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,14 +259,13 @@
         {
             throw new ContinuumPurgeManagerException( "Error while enqueuing repository", e );
         }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumPurgeManagerException( e.getMessage(), e );
+        }
     }
 
-    public void contextualize( Context context )
-        throws ContextException
-    {
-        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
-    }
-
+/*
     private boolean isInPurgeQueue( int purgeConfigId )
         throws ContinuumPurgeManagerException
     {
@@ -324,5 +332,5 @@
         }
 
         return false;
-    }
+    }*/
 }
\ No newline at end of file

Modified: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java (original)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/repository/DefaultRepositoryService.java Tue Sep  2 06:24:15 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;
@@ -59,11 +59,11 @@
      * @plexus.requirement
      */
     private ProjectGroupDao projectGroupDao;
-
+    
     /**
      * @plexus.requirement
      */
-    private ContinuumPurgeManager purgeManager;
+    private TaskQueueManager taskQueueManager;
 
     public LocalRepository addLocalRepository( LocalRepository localRepository )
         throws RepositoryServiceException
@@ -94,14 +94,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() );
@@ -119,7 +119,7 @@
 
             getLogger().info( "Removed local repository: " + repository.getName() );
         }
-        catch ( ContinuumPurgeManagerException e )
+        catch ( TaskQueueManagerException e )
         {
             // swallow?
         }
@@ -137,7 +137,7 @@
 
         try
         {
-            if ( purgeManager.isRepositoryInUse( localRepository.getId() ) )
+            if ( taskQueueManager.isRepositoryInUse( localRepository.getId() ) )
             {
                 return;
             }
@@ -146,7 +146,7 @@
 
             getLogger().info( "Updated local repository: " + localRepository.getName() );
         }
-        catch ( ContinuumPurgeManagerException e )
+        catch ( TaskQueueManagerException e )
         {
             // swallow?
         }

Added: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=691239&view=auto
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (added)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Tue Sep  2 06:24:15 2008
@@ -0,0 +1,616 @@
+package org.apache.continuum.taskqueue.manager;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
+import org.apache.continuum.purge.ContinuumPurgeManagerException;
+import org.apache.continuum.purge.PurgeConfigurationService;
+import org.apache.continuum.purge.task.PurgeTask;
+import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.release.tasks.PerformReleaseProjectTask;
+import org.apache.maven.continuum.scm.queue.CheckOutTask;
+import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
+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.logging.AbstractLogEnabled;
+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 org.codehaus.plexus.util.StringUtils;
+
+/**
+ * @author Maria Catherine Tan
+ * @plexus.component role="org.apache.continuum.taskqueue.manager.TaskQueueManager" role-hint="default"
+ */
+public class DefaultTaskQueueManager
+    extends AbstractLogEnabled
+    implements TaskQueueManager, Contextualizable
+{
+    /**
+     * @plexus.requirement role-hint="build-project"
+     */
+    private TaskQueue buildQueue;
+
+    /**
+     * @plexus.requirement role-hint="check-out-project"
+     */
+    private TaskQueue checkoutQueue;
+
+    /**
+     * @plexus.requirement role-hint="prepare-build-project"
+     */
+    private TaskQueue prepareBuildQueue;
+
+    /**
+     * @plexus.requirement role-hint="purge"
+     */
+    private TaskQueue purgeQueue;
+    
+    /**
+     * @plexus.requirement
+     */
+    private BuildDefinitionDao buildDefinitionDao;
+    
+    /**
+     * @plexus.requirement
+     */
+    private ProjectDao projectDao;
+
+    /**
+     * @plexus.requirement
+     */
+    private PurgeConfigurationService purgeConfigurationService;
+    
+    private PlexusContainer container;
+
+    public boolean buildInProgress()
+        throws TaskQueueManagerException
+    {
+        Task task = getCurrentTask( "build-project" );
+    
+        if ( task != null && task instanceof BuildProjectTask )
+        {
+            return true;
+        }
+    
+        return false;
+    }
+    
+    public void cancelBuildTask( int projectId )
+        throws TaskQueueManagerException
+    {
+        Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
+        
+        if ( currentTask instanceof BuildProjectTask )
+        {
+            if ( ( (BuildProjectTask) currentTask ).getProjectId() == projectId )
+            {
+                getLogger().info( "Cancelling task for project " + projectId );
+                getBuildTaskQueueExecutor().cancelTask( currentTask );
+            }
+        }
+    }
+    
+    public void cancelCheckoutTask( int projectId )
+        throws TaskQueueManagerException
+    {
+        Task currentTask = getCheckoutTaskQueueExecutor().getCurrentTask();
+
+        if ( currentTask instanceof CheckOutTask )
+        {
+            if ( ( (CheckOutTask) currentTask ).getProjectId() == projectId )
+            {
+                getLogger().info( "Cancelling task for project " + projectId );
+                getCheckoutTaskQueueExecutor().cancelTask( currentTask );
+            }
+        }    
+    }
+    
+    public TaskQueue getBuildQueue()
+    {
+        return buildQueue;
+    }
+
+    public TaskQueueExecutor getBuildTaskQueueExecutor()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "build-project" );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new TaskQueueManagerException( e.getMessage(), e );
+        }
+    }
+
+    public TaskQueueExecutor getCheckoutTaskQueueExecutor()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "check-out-project" );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new TaskQueueManagerException( e.getMessage(), e );
+        }
+    }
+
+    public TaskQueue getCheckoutQueue()
+    {
+        return checkoutQueue;
+    }
+    
+    public List<CheckOutTask> getCheckOutTasksInQueue()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return checkoutQueue.getQueueSnapshot();
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( "Error while getting the checkout queue.", e );
+        }
+    }
+
+    public int getCurrentProjectIdBuilding()
+        throws TaskQueueManagerException
+    {
+        Task task = getBuildTaskQueueExecutor().getCurrentTask();
+        if ( task != null )
+        {
+            if ( task instanceof BuildProjectTask )
+            {
+                return ( (BuildProjectTask) task ).getProjectId();
+            }
+        }
+        return -1;
+    }
+
+    public TaskQueue getPrepareBuildQueue()
+    {
+        return prepareBuildQueue;
+    }   
+
+    public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "prepare-build-project" );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new TaskQueueManagerException( e.getMessage(), e );
+        }
+    }
+
+    public List<BuildProjectTask> getProjectsInBuildQueue()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return buildQueue.getQueueSnapshot();
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( "Error while getting the building queue.", e );
+        }
+    }
+    
+    public TaskQueue getPurgeQueue()
+    {
+        return purgeQueue;
+    }
+    
+    public boolean isInBuildingQueue( int projectId )
+        throws TaskQueueManagerException
+    {
+        return isInBuildingQueue( projectId, -1 );
+    }
+    
+    public boolean isInBuildingQueue( int projectId, int buildDefinitionId )
+        throws TaskQueueManagerException
+    {
+        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 TaskQueueManagerException
+    {
+        List<CheckOutTask> queue = getCheckOutTasksInQueue();
+    
+        for ( CheckOutTask task : queue )
+        {
+            if ( task != null && task.getProjectId() == projectId )
+            {
+                return true;
+            }
+        }
+    
+        return false;
+    }
+    
+    public boolean isInPrepareBuildQueue( int projectId )
+        throws TaskQueueManagerException
+    {
+        Task task = getPrepareBuildTaskQueueExecutor().getCurrentTask();
+        if ( task != null && task instanceof PrepareBuildProjectsTask )
+        {
+            Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task).getProjectsBuildDefinitionsMap();
+            
+            if ( map.size() > 0 )
+            {
+                Set<Integer> projectIds = map.keySet();
+                
+                if ( projectIds.contains( new Integer( projectId ) ) )
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    public boolean isInPurgeQueue( int purgeConfigId )
+        throws TaskQueueManagerException
+    {
+        List<PurgeTask> queue = getAllPurgeConfigurationsInPurgeQueue();
+    
+        for ( PurgeTask task : queue )
+        {
+            if ( task != null && task.getPurgeConfigurationId() == purgeConfigId )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public boolean isRepositoryInPurgeQueue( int repositoryId )
+        throws TaskQueueManagerException
+    {
+        List<RepositoryPurgeConfiguration> repoPurgeConfigs =
+            purgeConfigurationService.getRepositoryPurgeConfigurationsByRepository( repositoryId );
+    
+        for ( RepositoryPurgeConfiguration repoPurge : repoPurgeConfigs )
+        {
+            if ( isInPurgeQueue( repoPurge.getId() ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public boolean isRepositoryInUse( int repositoryId )
+        throws TaskQueueManagerException
+    {
+        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 TaskQueueManagerException( e.getMessage(), e );
+        }
+    }
+
+    public boolean releaseInProgress()
+        throws TaskQueueManagerException
+    {
+        Task task = getCurrentTask( "perform-release" );
+    
+        if ( task != null && task instanceof PerformReleaseProjectTask )
+        {
+            return true;
+        }
+    
+        return false;
+    }
+
+    public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
+        throws TaskQueueManagerException
+    {
+        BuildDefinition buildDefinition;
+        
+        try
+        {
+            buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new TaskQueueManagerException( "Error while removing project from build queue: " + projectName, e );
+        }
+        
+        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 removeFromPurgeQueue( int purgeConfigId )
+        throws TaskQueueManagerException
+    {
+        List<PurgeTask> queue = getAllPurgeConfigurationsInPurgeQueue();
+    
+        for ( PurgeTask task : queue )
+        {
+            if ( task != null && task.getPurgeConfigurationId() == purgeConfigId )
+            {
+                return purgeQueue.remove( task );
+            }
+        }
+        return false;
+    }
+
+
+    public boolean removeFromPurgeQueue( int[] purgeConfigIds )
+        throws TaskQueueManagerException
+    {
+        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 removeProjectsFromBuildingQueue( int[] projectsId )
+        throws TaskQueueManagerException
+    {
+        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 removeProjectFromBuildingQueue( int projectId )
+        throws TaskQueueManagerException
+    {
+        List<BuildProjectTask> queue = getProjectsInBuildQueue();
+    
+        for ( BuildProjectTask task : queue )
+        {
+            if ( task != null && task.getProjectId() == projectId )
+            {
+                return buildQueue.remove( task );
+            }
+        }
+    
+        return false;
+    }
+    
+    public boolean removeProjectsFromCheckoutQueue( int[] projectsId )
+        throws TaskQueueManagerException
+    {
+        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 void removeProjectsFromBuildingQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException
+    {
+        List<BuildProjectTask> queue = getProjectsInBuildQueue();
+    
+        for ( BuildProjectTask task : queue )
+        {
+            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
+            {
+                buildQueue.remove( task );
+            }
+        }
+    }
+    
+    public boolean removeProjectFromCheckoutQueue( int projectId )
+        throws TaskQueueManagerException
+    {
+        List<CheckOutTask> queue = getCheckOutTasksInQueue();
+    
+        for ( CheckOutTask task : queue )
+        {
+            if ( task != null && task.getProjectId() == projectId )
+            {
+                return checkoutQueue.remove( task );
+            }
+        }
+    
+        return false;
+    }
+    
+    public void removeRepositoryFromPurgeQueue( int repositoryId )
+        throws TaskQueueManagerException
+    {
+        List<RepositoryPurgeConfiguration> repoPurgeConfigs =
+            purgeConfigurationService.getRepositoryPurgeConfigurationsByRepository( repositoryId );
+    
+        for ( RepositoryPurgeConfiguration repoPurge : repoPurgeConfigs )
+        {
+            removeFromPurgeQueue( repoPurge.getId() );
+        }
+    }
+
+    public void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException
+    {
+        List<CheckOutTask> queue = getCheckOutTasksInQueue();
+    
+        for ( CheckOutTask task : queue )
+        {
+            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
+            {
+                checkoutQueue.remove( task );
+            }
+        }
+    }
+
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+    
+    private List<PurgeTask> getAllPurgeConfigurationsInPurgeQueue()
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            return purgeQueue.getQueueSnapshot();
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( "Error while getting the purge configs in purge queue", e );
+        }
+    }
+    
+    private Task getCurrentTask( String task )
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            TaskQueueExecutor executor = (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, task );
+            return executor.getCurrentTask();
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new TaskQueueManagerException( "Unable to lookup current task", e );
+        }
+    }
+}

Modified: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Tue Sep  2 06:24:15 2008
@@ -30,10 +30,11 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.lang.ArrayUtils;
+//import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.BuildResultDao;
@@ -41,9 +42,13 @@
 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.purge.ContinuumPurgeManager;
 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;
@@ -75,7 +80,8 @@
 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.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;
@@ -86,7 +92,7 @@
 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.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
@@ -96,10 +102,10 @@
 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.Task;
+//import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+//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;
@@ -162,6 +168,11 @@
     /**
      * @plexus.requirement
      */
+    private ProjectScmRootDao projectScmRootDao;
+    
+    /**
+     * @plexus.requirement
+     */
     private ContinuumInitializer initializer;
 
     /**
@@ -187,18 +198,23 @@
     // ----------------------------------------------------------------------
     // Moved from core
     // ----------------------------------------------------------------------
-
+/*
     /**
      * @plexus.requirement role-hint="build-project"
      */
-    private TaskQueue buildQueue;
+/*    private TaskQueue buildQueue;
 
     /**
      * @plexus.requirement role-hint="check-out-project"
      */
-    private TaskQueue checkoutQueue;
+/*    private TaskQueue checkoutQueue;
 
     /**
+     * @plexus.requirement role-hint="prepare-build-project"
+     */
+//    private TaskQueue prepareBuildQueue;
+    
+    /**
      * @plexus.requirement
      */
     private ContinuumReleaseManager releaseManager;
@@ -238,6 +254,11 @@
      */
     private RepositoryService repositoryService;
 
+    /**
+     * @plexus.requirement
+     */
+    private TaskQueueManager taskQueueManager;
+    
     public DefaultContinuum()
     {
         Runtime.getRuntime().addShutdownHook( new Thread()
@@ -280,6 +301,11 @@
     {
         return repositoryService;
     }
+    
+    public TaskQueueManager getTaskQueueManager()
+    {
+        return taskQueueManager;
+    }
 
     // ----------------------------------------------------------------------
     // Project Groups
@@ -338,6 +364,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() + ")" );
@@ -533,7 +573,7 @@
     // ----------------------------------------------------------------------
     // Queues
     // ----------------------------------------------------------------------
-
+/*
     public List<BuildProjectTask> getProjectsInBuildQueue()
         throws ContinuumException
     {
@@ -637,6 +677,40 @@
         }
         return -1;
     }
+    
+    public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+        throws ContinuumException
+    {
+        try
+        {
+            return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "prepare-build-project" );
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
+    }
+    
+    public boolean isProjectInPrepareBuild( int projectId )
+        throws ContinuumException
+    {
+        Task task = getPrepareBuildTaskQueueExecutor().getCurrentTask();
+        if ( task != null && task instanceof PrepareBuildProjectsTask )
+        {
+            Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task).getProjectsBuildDefinitionsMap();
+            
+            if ( map.size() > 0 )
+            {
+                Set<Integer> projectIds = map.keySet();
+                
+                if ( projectIds.contains( new Integer( projectId ) ) )
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 
     public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
         throws ContinuumException
@@ -781,7 +855,7 @@
             }
         }
     }
-
+*/
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -796,32 +870,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() )
             {
@@ -935,21 +1005,16 @@
             projectsList = getProjects();
         }
 
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = getProjectsAndBuildDefinitionsMap( projectsList, null, true );
+
+        prepareBuildProjects( projectsAndBuildDefinitionsMap );
+
         for ( Project project : projectsList )
         {
-            Integer buildDefId = null;
-
-            try
+            if ( projectsAndBuildDefinitionsMap.get( project.getId() ) != null )
             {
-                buildDefId = new Integer( buildDefinitionDao.getDefaultBuildDefinition( project.getId() ).getId() );
+                buildProject( project, projectsAndBuildDefinitionsMap.get( project.getId() ), trigger );
             }
-            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." );
-            }
-
-            buildProject( project, buildDefId.intValue(), trigger );
         }
     }
 
@@ -976,9 +1041,16 @@
             projectsList = getProjects();
         }
 
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = getProjectsAndBuildDefinitionsMap( projectsList, buildDefinitionId );
+
+        prepareBuildProjects( projectsAndBuildDefinitionsMap );
+        
         for ( Project project : projectsList )
         {
-            buildProject( project, buildDefinitionId, trigger );
+            if ( projectsAndBuildDefinitionsMap.get( project.getId() ) != null )
+            {
+                buildProject( project, buildDefinitionId, trigger );
+            }
         }
     }
 
@@ -1029,6 +1101,8 @@
     {
         Collection<Project> projectsList;
 
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+        
         try
         {
             projectsList = getProjectsInBuildOrder( projectDao.getProjectsWithDependenciesByGroupId( projectGroupId ) );
@@ -1040,54 +1114,18 @@
             projectsList = getProjects();
         }
 
-        //Map buildDefinitionsIds = store.getDefaultBuildDefinitions();
+        projectsAndBuildDefinitionsMap = getProjectsAndBuildDefinitionsMap( projectsList, 
+                                                                            bds, 
+                                                                            checkDefaultBuildDefinitionForProject );
+
+        prepareBuildProjects( projectsAndBuildDefinitionsMap );
 
         for ( Project project : projectsList )
         {
-            int buildDefId = -1;
-
-            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 )
+            if ( projectsAndBuildDefinitionsMap.get( project.getId() ) != null )
             {
-                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." );
-                }
+                buildProject( project, projectsAndBuildDefinitionsMap.get( project.getId() ), ContinuumProjectState.TRIGGER_FORCED );
             }
-
-            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 );
         }
     }
 
@@ -1130,6 +1168,8 @@
             projectsList = getProjects();
         }
 
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+        
         for ( Project project : projectsList )
         {
             List<Integer> buildDefIds = (List<Integer>) projectsMap.get( new Integer( project.getId() ) );
@@ -1138,14 +1178,32 @@
             {
                 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() ) )
+                        {
+                            projectsAndBuildDefinitionsMap.put( project.getId(), buildDefId );
+                        }
+                    } 
+                    catch ( TaskQueueManagerException e )
+                    {
+                        throw new ContinuumException( e.getMessage(), e );
                     }
                 }
             }
         }
+        
+        prepareBuildProjects( projectsAndBuildDefinitionsMap );
+        
+        for ( Project project : projectsList )
+        {
+            //buildProject( project, projectsAndBuildDefinitionsMap.get( project.getId() ), ContinuumProjectState.TRIGGER_SCHEDULED, false );
+            if ( projectsAndBuildDefinitionsMap.get(  project.getId() ) != null )
+            {
+                buildProject( project, projectsAndBuildDefinitionsMap.get( project.getId() ), ContinuumProjectState.TRIGGER_SCHEDULED );
+            }
+        }
     }
 
     public void buildProject( int projectId )
@@ -1157,6 +1215,29 @@
     public void buildProjectWithBuildDefinition( int projectId, int buildDefinitionId )
         throws ContinuumException
     {
+        try
+        {
+            if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.isInPrepareBuildQueue( projectId ) )
+            {
+                return;
+            }
+
+            if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+            {
+                taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+            }
+
+            taskQueueManager.cancelCheckoutTask( projectId );
+        }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
+     
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>( projectId, buildDefinitionId );
+        
+        prepareBuildProjects( projectsAndBuildDefinitionsMap );
+        
         buildProject( projectId, buildDefinitionId, ContinuumProjectState.TRIGGER_FORCED );
     }
 
@@ -1170,20 +1251,50 @@
             throw new ContinuumException( "Project (id=" + projectId + " doens't have a default build definition." );
         }
 
-        if ( isInBuildingQueue( projectId, buildDef.getId() ) || isInCheckoutQueue( projectId ) )
+        try
         {
-            return;
+            if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) || 
+                 taskQueueManager.isInCheckoutQueue( projectId ) ||
+                 taskQueueManager.isInPrepareBuildQueue( projectId ))
+            {
+                return;
+            }
+            
+            taskQueueManager.cancelCheckoutTask( projectId );
         }
+        catch ( TaskQueueManagerException e )
+        {
+            throw new ContinuumException( e.getMessage(), e );
+        }
+
+        Map<Integer, Integer> projectsBuildDefinitionsMap = new HashMap<Integer, Integer>( projectId, buildDef.getId() );
+        
+        prepareBuildProjects( projectsBuildDefinitionsMap );
+        
+        //buildProject( projectId, buildDef.getId(), trigger, false );
 
-        buildProject( projectId, buildDef.getId(), trigger, false );
+        buildProject( projectId, buildDef.getId(), trigger );
     }
 
     public void buildProject( int projectId, int buildDefinitionId, int trigger )
         throws ContinuumException
     {
-        buildProject( projectId, buildDefinitionId, trigger, true );
+        //buildProject( projectId, buildDefinitionId, trigger, true );
+        Project project;
+
+        try
+        {
+            project = projectDao.getProject( projectId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw logAndCreateException( "Error while getting project " + projectId + ".", e );
+        }
+
+        buildProject( project, buildDefinitionId, trigger );
     }
 
+    /*
     public void buildProject( Project project, int buildDefinitionId, int trigger )
         throws ContinuumException
     {
@@ -1205,20 +1316,96 @@
         }
 
         buildProject( project, buildDefinitionId, trigger, checkQueues );
+    }*/
+    
+    private synchronized void buildProject( Project project, int buildDefinitionId, int trigger )
+        throws ContinuumException
+    {
+        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
+            {
+                project.setOldState( project.getState() );
+    
+                projectDao.updateProject( project );
+    
+                project = projectDao.getProject( project.getId() );
+            }
+    
+            BuildDefinition buildDefinition = getBuildDefinition( buildDefinitionId );
+            String buildDefinitionLabel = buildDefinition.getDescription();
+            if ( StringUtils.isEmpty( buildDefinitionLabel ) )
+            {
+                buildDefinitionLabel = buildDefinition.getGoals();
+            }
+    
+            getLogger().info( "Enqueuing '" + project.getName() + "' with build definition '" + buildDefinitionLabel +
+                "' - id=" + buildDefinitionId + ")." );
+    
+            BuildProjectTask task = new BuildProjectTask( project.getId(), buildDefinitionId, trigger, project
+                .getName(), buildDefinitionLabel );
+    
+            task.setMaxExecutionTime( buildDefinitionDao.getBuildDefinition( buildDefinitionId ).getSchedule()
+                .getMaxJobExecutionTime() * 1000 );
+    
+            taskQueueManager.getBuildQueue().put( task );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw logAndCreateException( "Error while creating build object.", e );
+        }
+        catch ( TaskQueueException e )
+        {
+            throw logAndCreateException( "Error while creating enqueuing object.", e );
+        }
     }
 
+
     private synchronized void buildProject( Project project, int buildDefinitionId, int trigger, boolean checkQueues )
         throws ContinuumException
     {
         if ( checkQueues )
         {
-            if ( isInBuildingQueue( project.getId(), buildDefinitionId ) )
+            try
             {
-                return;
+                if ( taskQueueManager.isInBuildingQueue( project.getId(), buildDefinitionId ) )
+                {
+                    return;
+                }
+                
+                if ( taskQueueManager.isInCheckoutQueue( project.getId() ) )
+                {
+                    taskQueueManager.removeProjectFromCheckoutQueue( project.getId() );
+                }
             }
-            if ( isInCheckoutQueue( project.getId() ) )
+            catch ( TaskQueueManagerException e )
             {
-                removeProjectFromCheckoutQueue( project.getId() );
+                throw new ContinuumException( e.getMessage(), e );
             }
         }
 
@@ -1274,7 +1461,7 @@
             task.setMaxExecutionTime( buildDefinitionDao.getBuildDefinition( buildDefinitionId ).getSchedule()
                 .getMaxJobExecutionTime() * 1000 );
 
-            buildQueue.put( task );
+            taskQueueManager.getBuildQueue().put( task );
         }
         catch ( ContinuumStoreException e )
         {
@@ -1420,6 +1607,32 @@
 
         return changes;
     }
+    
+    public List<ChangeSet> getChangesSinceLastUpdate( int projectId )
+        throws ContinuumException
+    {
+        List<ChangeSet> changes = new ArrayList<ChangeSet>();
+        
+        Project project;
+        
+        try
+        {
+            project = projectDao.getProjectWithScmResult( projectId );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "", e );
+        }
+        
+        ScmResult scmResult = project.getScmResult();
+        
+        if ( scmResult != null )
+        {
+            changes.addAll( scmResult.getChanges() );
+        }
+        
+        return changes;
+    }
 
     // ----------------------------------------------------------------------
     //
@@ -1844,6 +2057,22 @@
 
             projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );
 
+            String url = (String) context.get( CreateProjectsFromMetadataAction.KEY_URL );
+            
+            ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
+            
+            if ( scmRoot == null )
+            {
+                scmRoot = new ProjectScmRoot();
+                
+                scmRoot.setProjectGroup( projectGroup );
+                
+                scmRoot.setScmRootAddress( url );
+                
+                projectScmRootDao.addProjectScmRoot( scmRoot );
+
+            }
+
             /* add the project group loaded from database, which has more info, like id */
             result.getProjectGroups().remove( 0 );
             result.getProjectGroups().add( projectGroup );
@@ -1883,7 +2112,7 @@
         try
         {
             projectGroupDao.updateProjectGroup( projectGroup );
-
+            
             for ( Project project : projects )
             {
                 context = new HashMap();
@@ -1911,7 +2140,7 @@
                 // remove object data -> we don't display the project name in the build queue
                 context.put( AbstractContinuumAction.KEY_PROJECT, projectDao.getProject( project.getId() ) );
                 executeAction( "add-project-to-checkout-queue", context );
-            }
+            }            
         }
         catch ( ContinuumStoreException e )
         {
@@ -3273,4 +3502,151 @@
         return buildDefinitionService;
     }
 
+    public List<ProjectScmRoot> getProjectScmRootByProjectGroup( int projectGroupId )
+    {
+        return projectScmRootDao.getProjectScmRootByProjectGroup( projectGroupId );
+    }
+
+    public Map<Integer, Integer> getProjectsAndBuildDefinitionsMap( Collection<Project> projects, 
+                                                                    List<BuildDefinition> bds,
+                                                                    boolean checkDefaultBuildDefinitionForProject )
+        throws ContinuumException
+    {
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+
+        for ( Project project : projects )
+        {
+            int projectId = project.getId();
+
+            if ( projectsAndBuildDefinitionsMap.containsKey( projectId ) )
+            {
+                continue;
+            }
+            
+            try
+            {
+                // check if project already in queue
+                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                {
+                    continue;
+                }
+                
+                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                {
+                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                }
+                
+                taskQueueManager.cancelCheckoutTask( 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;
+            }
+
+            projectsAndBuildDefinitionsMap.put( projectId, buildDefId );
+        }
+
+        return projectsAndBuildDefinitionsMap;
+    }
+
+    public Map<Integer, Integer> getProjectsAndBuildDefinitionsMap( Collection<Project> projects, 
+                                                                    int buildDefinitionId )
+        throws ContinuumException
+    {
+        Map<Integer, Integer> projectsAndBuildDefinitionsMap = new HashMap<Integer, Integer>();
+
+        for ( Project project : projects )
+        {
+            int projectId = project.getId();
+            
+            if ( projectsAndBuildDefinitionsMap.containsKey( projectId ) )
+            {
+                continue;
+            }
+
+            try
+            {
+                // check if project already in queue
+                if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+                {
+                    continue;
+                }
+                
+                if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+                {
+                    taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+                }
+                
+                taskQueueManager.cancelCheckoutTask( projectId );
+            }
+            catch ( TaskQueueManagerException e )
+            {
+                throw new ContinuumException( e.getMessage(), e );
+            }
+
+            projectsAndBuildDefinitionsMap.put( projectId, buildDefinitionId );
+        }
+
+        return projectsAndBuildDefinitionsMap;
+    }
+
+    public void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap )
+        throws ContinuumException
+    {
+        try
+        {
+            PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap );
+            taskQueueManager.getPrepareBuildQueue().put( task );
+        }
+        catch ( TaskQueueException e )
+        {
+            throw logAndCreateException( "Error while creating enqueuing object.", e );
+        }
+    }
 }

Modified: continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java?rev=691239&r1=691238&r2=691239&view=diff
==============================================================================
--- continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java (original)
+++ continuum/branches/continuum-transient-state/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/BuildContext.java Tue Sep  2 06:24:15 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;
+    }
 }



Mime
View raw message