continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1162043 [1/2] - 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/purge/controller/ continuum-api/src/main/ja...
Date Fri, 26 Aug 2011 09:34:44 GMT
Author: ctan
Date: Fri Aug 26 09:34:42 2011
New Revision: 1162043

URL: http://svn.apache.org/viewvc?rev=1162043&view=rev
Log:
[CONTINUUM-2658] added support for purging working copies and releases directory of build agents

Submitted By: Greg Michael Meneses
With minor modification


Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java   (with props)
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java   (with props)
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java   (with props)
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java   (with props)
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDaoImpl.java   (with props)
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java   (with props)
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java   (with props)
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction-saveDistributedPurgeConfig-validation.xml   (with props)
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.properties   (with props)
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction_en.properties   (with props)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteDistributedPurgeConfiguration.jsp   (with props)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp   (with props)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp   (with props)
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/ContinuumPurgeManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/PurgeConfigurationService.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/controller/PurgeController.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java
    continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java
    continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java
    continuum/trunk/continuum-distributed/continuum-distributed-tests/src/test/it/org/apache/continuum/distributed/transport/tests/SlaveBuildAgentTransportServiceTest.java
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
    continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdorepl
    continuum/trunk/continuum-purge/pom.xml
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/DefaultPurgeConfigurationService.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/RepositoryPurgeController.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java
    continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java
    continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java
    continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum_de.properties
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum_fr.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/navigations/Menu.jsp

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java?rev=1162043&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java Fri Aug 26 09:34:42 2011
@@ -0,0 +1,110 @@
+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.repository.DistributedDirectoryPurgeConfiguration;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author
+ * @version $Id$
+ */
+public interface DistributedDirectoryPurgeConfigurationDao
+{
+    /**
+     * Retrieve all DistributedDirectoryPurgeConfiguration instances.
+     * 
+     * @return list of all DistributedDirectoryPurgeConfiguration instances
+     */
+    List<DistributedDirectoryPurgeConfiguration> getAllDistributedDirectoryPurgeConfigurations();
+
+    /**
+     * Retrieve all DistributedDirectoryPurgeConfiguration instances associated with the input scheduleId.
+     * 
+     * @param scheduleId schedule id
+     * 
+     * @return list of all DistributedDirectoryPurgeConfiguration instances associated with the input scheduleId
+     */
+    List<DistributedDirectoryPurgeConfiguration> getDistributedDirectoryPurgeConfigurationsBySchedule( int scheduleId );
+
+    /**
+     * Retrieve all enabled DistributedDirectoryPurgeConfiguration instances associated with the input scheduleId.
+     * 
+     * @param scheduleId schedule id
+     * 
+     * @return list of all enabled DistributedDirectoryPurgeConfiguration instances associated with the input scheduleId
+     */
+    List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule( int scheduleId );
+
+    /**
+     * Retrieve all DistributedDirectoryPurgeConfiguration instances having the specified directory type.
+     * 
+     * @param type directory type
+     * 
+     * @return list of all DistributedDirectoryPurgeConfiguration instances having the specified directory type
+     */
+    List<DistributedDirectoryPurgeConfiguration> getDistributedDirectoryPurgeConfigurationsByType( String type );
+
+    /**
+     * Retrieve the DistributedDirectoryPurgeConfiguration instance associated with the input id.
+     * 
+     * @param configurationId DistributedDirectoryPurgeConfiguration instance id
+     * 
+     * @return DistributedDirectoryPurgeConfiguration instance
+     * 
+     * @throws ContinuumStoreException if unable to retrieve an instance associated with the input id
+     */
+    DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int configurationId )
+        throws ContinuumStoreException;
+
+    /**
+     * Adds a new DistributedDirectoryPurgeConfiguration instance.
+     * 
+     * @param purgeConfiguration DistributedDirectoryPurgeConfiguration instance to be added
+     * 
+     * @return DistributedDirectoryPurgeConfiguration instance that was added
+     * 
+     * @throws ContinuumStoreException if unable to add the new instance
+     */
+    DistributedDirectoryPurgeConfiguration addDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException;
+
+    /**
+     * Updates the DistributedDirectoryPurgeConfiguration instance.
+     * 
+     * @param purgeConfiguration DistributedDirectoryPurgeConfiguration instance to be updated
+     * 
+     * @throws ContinuumStoreException if unable to update the instance
+     */
+    void updateDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException;
+
+    /**
+     * Removes the DistributedDirectoryPurgeConfiguration instance.
+     * 
+     * @param purgeConfiguration DistributedDirectoryPurgeConfiguration instance to be removed
+     * 
+     * @throws ContinuumStoreException if unable to remove the instance
+     */
+    void removeDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException;
+}

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedDirectoryPurgeConfigurationDao.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

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=1162043&r1=1162042&r2=1162043&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 Fri Aug 26 09:34:42 2011
@@ -20,6 +20,7 @@ package org.apache.continuum.purge;
  */
 
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.model.project.Schedule;
 
@@ -55,4 +56,14 @@ public interface ContinuumPurgeManager
      */
     void purgeDirectory( DirectoryPurgeConfiguration dirPurgeConfig )
         throws ContinuumPurgeManagerException;
+    
+    /**
+     * Purge directory in distributed build mode
+     * 
+     * @param dirPurgeConfig distributed purge configuration
+     * 
+     * @throws ContinuumPurgeManagerException
+     */
+    void purgeDistributedDirectory( DistributedDirectoryPurgeConfiguration dirPurgeConfig )
+        throws ContinuumPurgeManagerException;
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/PurgeConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/PurgeConfigurationService.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/PurgeConfigurationService.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/PurgeConfigurationService.java Fri Aug 26 09:34:42 2011
@@ -23,6 +23,7 @@ import java.util.List;
 
 import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
 
@@ -90,8 +91,24 @@ public interface PurgeConfigurationServi
     
     List<AbstractPurgeConfiguration> getAllPurgeConfigurations();
     
+    List<DistributedDirectoryPurgeConfiguration> getAllDistributedDirectoryPurgeConfigurations();
+    
+    DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int dirPurgeId )
+        throws PurgeConfigurationServiceException;
+    
+    DistributedDirectoryPurgeConfiguration addDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws PurgeConfigurationServiceException;
+    
+    void updateDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws PurgeConfigurationServiceException;
+    
+    void removeDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws PurgeConfigurationServiceException;
+    
     AbstractPurgeConfiguration getPurgeConfiguration( int purgeConfigId );
     
+    List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule( int scheduleId );
+    
     /**
      * @param repositoryId
      * @return

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/controller/PurgeController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/controller/PurgeController.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/controller/PurgeController.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/purge/controller/PurgeController.java Fri Aug 26 09:34:42 2011
@@ -34,5 +34,7 @@ public interface PurgeController
     void initializeExecutors( AbstractPurgeConfiguration purgeConfig )
         throws ContinuumPurgeExecutorException;
     
+    void doPurge( AbstractPurgeConfiguration purgeConfig );
+    
     void doPurge( String path );
 }

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=1162043&r1=1162042&r2=1162043&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 Fri Aug 26 09:34:42 2011
@@ -21,7 +21,9 @@ package org.apache.maven.continuum.relea
 
 import org.apache.continuum.model.release.ReleaseListenerSummary;
 import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.maven.continuum.model.project.Project;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 
 import java.io.File;
 import java.util.Map;
@@ -152,5 +154,41 @@ public interface ContinuumReleaseManager
      * @return
      */
     ReleaseListenerSummary getListener( String releaseId );
+    
+    /**
+     * Determines if there is an ongoing release
+     * 
+     * @return true if there is an ongoing release; false otherwise
+     * 
+     * @throws Exception if unable to determine if release is ongoing
+     */
+    boolean isExecutingRelease() throws Exception;
+    
+    /**
+     * Retrieve the Release TaskQueueExecutor instance
+     * 
+     * @return Release TaskQueueExecutor instance
+     * 
+     * @throws TaskQueueManagerException if unable to retrieve the Release TaskQueueExecutor instance
+     */
+    TaskQueueExecutor getPerformReleaseTaskQueueExecutor() throws TaskQueueManagerException;
+    
+    /**
+     * Retrieve the PrepareRelease TaskQueueExecutor instance
+     * 
+     * @return PrepareRelease TaskQueueExecutor instance
+     * 
+     * @throws TaskQueueManagerException if unable to retrieve the PrepareRelease TaskQueueExecutor instance
+     */
+    TaskQueueExecutor getPrepareReleaseTaskQueueExecutor() throws TaskQueueManagerException;
+    
+    /**
+     * Retrieve the RollbackRelease TaskQueueExecutor instance
+     * 
+     * @return RollbackRelease TaskQueueExecutor instance
+     * 
+     * @throws TaskQueueManagerException if unable to retrieve the RollbackRelease TaskQueueExecutor instance
+     */
+    TaskQueueExecutor getRollbackReleaseTaskQueueExecutor() throws TaskQueueManagerException;
 
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java Fri Aug 26 09:34:42 2011
@@ -139,4 +139,36 @@ public interface ContinuumBuildAgentServ
      */
     String getBuildAgentPlatform()
         throws ContinuumBuildAgentException;
+    
+    /**
+     * Determines if build agent is currently executing a build
+     * 
+     * @return true if executing build; false otherwise
+     */
+    boolean isExecutingBuild();
+    
+    /**
+     * Determines if build agent is currently executing a release
+     * 
+     * @return true if executing release; false otherwise
+     * 
+     * @throws ContinuumBuildAgentException if unable to determine if buildagent is executing a release
+     */
+    boolean isExecutingRelease() throws ContinuumBuildAgentException;
+    
+    /**
+     * Execute a directory purge on the build agent
+     * 
+     * @param directoryType valid types are <i>working</i> and <i>releases</i>
+     * @param daysOlder days older
+     * @param retentionCount retention count
+     * @param deleteAll delete all flag
+     * 
+     * @return true if purge is successful; false otherwise
+     * 
+     * @throws ContinuumBuildAgentException error that will occur during the purge
+     */
+    void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
+        throws ContinuumBuildAgentException;
+    
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java Fri Aug 26 09:34:42 2011
@@ -21,6 +21,7 @@ package org.apache.continuum.buildagent;
 
 import java.io.File;
 import java.io.IOException;
+import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -35,6 +36,7 @@ import org.apache.continuum.buildagent.b
 import org.apache.continuum.buildagent.buildcontext.manager.BuildContextManager;
 import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
 import org.apache.continuum.buildagent.manager.BuildAgentManager;
+import org.apache.continuum.buildagent.manager.BuildAgentPurgeManager;
 import org.apache.continuum.buildagent.manager.BuildAgentReleaseManager;
 import org.apache.continuum.buildagent.model.Installation;
 import org.apache.continuum.buildagent.taskqueue.PrepareBuildProjectsTask;
@@ -96,6 +98,11 @@ public class ContinuumBuildAgentServiceI
      * @plexus.requirement
      */
     private BuildAgentManager buildAgentManager;
+    
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentPurgeManager purgeManager;
 
     public void buildProjects( List<Map<String, Object>> projectsBuildContext )
         throws ContinuumBuildAgentException
@@ -1014,6 +1021,62 @@ public class ContinuumBuildAgentServiceI
             throw new ContinuumBuildAgentException( "Error in when trying to get build agent's platform", e );
         }
     }
+    
+    public boolean isExecutingBuild()
+    {
+        return getBuildSizeOfAgent() > 0;
+    }
+    
+    public boolean isExecutingRelease() throws ContinuumBuildAgentException
+    {
+        try
+        {
+            return buildAgentReleaseManager.getReleaseManager().isExecutingRelease();
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumBuildAgentException( e.getMessage(), e );
+        }
+    }
+    
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
+        throws ContinuumBuildAgentException
+    {
+        String logMsgFormat = "Directory purge [directoryType={0}, daysOlder={1}, retentionCount={2}, deleteAll={3}] not possible; {4}";
+        if ( isExecutingBuild() )
+        {
+            log.info( MessageFormat.format( logMsgFormat, directoryType, daysOlder, retentionCount, deleteAll, "Build Agent busy" ) );
+            return;
+        } 
+       
+        try
+        {
+            if ( isExecutingRelease() )
+            {
+                log.info( MessageFormat.format( logMsgFormat, directoryType, daysOlder, retentionCount, deleteAll, 
+                                                    "Build Agent is executing a release." ) );
+                return;
+            }
+        }
+        catch ( ContinuumBuildAgentException e )
+        {
+            if ( isExecutingRelease() )
+            {
+                 log.info( MessageFormat.format( logMsgFormat, directoryType, daysOlder, retentionCount, deleteAll, 
+                                                 "Unable to determine if Build Agent is executing a release." ) );
+                 return;
+            }
+        }
+        
+        try
+        {
+            purgeManager.executeDirectoryPurge( directoryType, daysOlder, retentionCount, deleteAll );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumBuildAgentException( e.getMessage(), e );
+        }
+    }
 
     private List<BuildContext> initializeBuildContext( List<Map<String, Object>> projectsBuildContext )
     {

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java?rev=1162043&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java Fri Aug 26 09:34:42 2011
@@ -0,0 +1,10 @@
+package org.apache.continuum.buildagent.manager;
+
+
+public interface BuildAgentPurgeManager
+{
+    String ROLE = BuildAgentPurgeManager.class.getName();
+    
+    void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
+        throws Exception;
+}

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentPurgeManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java Fri Aug 26 09:34:42 2011
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Properties;
 
 import org.apache.maven.continuum.release.ContinuumReleaseException;
+import org.apache.maven.continuum.release.ContinuumReleaseManager;
 import org.apache.maven.shared.release.ReleaseResult;
 
 public interface BuildAgentReleaseManager
@@ -54,4 +55,6 @@ public interface BuildAgentReleaseManage
 
     void releaseRollback( String releaseId, int projectId )
         throws ContinuumReleaseException;
+    
+    ContinuumReleaseManager getReleaseManager();
 }

Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java?rev=1162043&view=auto
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java (added)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java Fri Aug 26 09:34:42 2011
@@ -0,0 +1,164 @@
+package org.apache.continuum.buildagent.manager;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.comparator.LastModifiedFileComparator;
+import org.apache.commons.io.filefilter.AgeFileFilter;
+import org.apache.commons.io.filefilter.AndFileFilter;
+import org.apache.commons.io.filefilter.DirectoryFileFilter;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.filefilter.NotFileFilter;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
+import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.apache.continuum.buildagent.manager.BuildAgentPurgeManager" role-hint="default"
+ */
+public class DefaultBuildAgentPurgeManager
+    implements BuildAgentPurgeManager
+{
+    private static final Logger logger = LoggerFactory.getLogger( DefaultBuildAgentPurgeManager.class );
+
+    /**
+     * @plexus.requirement
+     */
+    private BuildAgentConfigurationService buildAgentConfigurationService;
+    
+    @Override
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
+        throws Exception
+    {
+        StringBuilder log = new StringBuilder().append( "Executing directory purge with the following settings[directoryType=" ).
+                                                append( directoryType ).append( ",daysOlder=" ).
+                                                append( daysOlder ).append( ", retentionCount=" ).
+                                                append( retentionCount ).append( ", deleteAll=" ).
+                                                append( deleteAll ).append( "]" );
+        logger.info( log.toString() );
+        
+        File directory = null;
+        
+        if ( "working".equals( directoryType ) || "releases".equals( directoryType ) )
+        {
+            directory = buildAgentConfigurationService.getWorkingDirectory();
+        }
+        else
+        {
+            logger.warn( "Cannot execute purge: DirectoryType: " + directoryType + " is not valid." );
+            return;
+        }
+        if ( deleteAll )
+        {
+            purgeAll( directory, directoryType );
+        }
+        else
+        {
+            purgeFiles( directory, directoryType, daysOlder, retentionCount );
+        }
+        
+        logger.info( "Directory purge execution done" );
+    }
+    
+    private void purgeAll( File directory, String directoryType ) throws Exception
+    {
+        AndFileFilter filter = new AndFileFilter();
+        filter.addFileFilter( DirectoryFileFilter.DIRECTORY );
+        filter.addFileFilter( createFileFilterForDirectoryType( directoryType ) );
+        
+        File[] files = directory.listFiles( ( FileFilter ) filter );
+        if  ( files == null )
+        {
+            return;
+        }
+        for ( File file : files )
+        {
+            try
+            {
+                FileUtils.deleteDirectory( file );
+            }
+            catch ( IOException e )
+            {
+                logger.warn( "Unable to purge " + directoryType + " directory: " + file.getName() );
+            }
+        }
+    }
+    
+    private void purgeFiles( File directory, String directoryType, int daysOlder, int retentionCount )
+    {
+        AndFileFilter filter = new AndFileFilter();
+        filter.addFileFilter( DirectoryFileFilter.DIRECTORY );
+        filter.addFileFilter( createFileFilterForDirectoryType( directoryType ) );
+        
+        
+        File[] files = directory.listFiles( ( FileFilter ) filter );
+        
+        if ( files == null )
+        {
+            return;
+        }
+        
+        //calculate to include files not in the dayold category
+        int countToPurge = files.length - retentionCount;
+        
+        if ( daysOlder > 0 )
+        {
+            long cutoff = System.currentTimeMillis() - ( 24 * 60 * 26 * 1000 * daysOlder );
+            filter.addFileFilter( new AgeFileFilter( cutoff ) );
+        }
+        
+        files = directory.listFiles( ( FileFilter ) filter );
+        
+        if ( files == null )
+        {
+            return;
+        }
+        
+        Arrays.sort( files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR );
+        
+        for ( File file : files )
+        {
+            if ( countToPurge - 1 < 0 )
+            {
+                break;
+            }
+            try
+            {
+                FileUtils.deleteDirectory( file );
+                countToPurge--;
+            }
+            catch ( IOException e )
+            {
+                logger.warn( "Unable to purge " + directoryType + " directory: " + file.getName() );
+            }
+        }
+        
+    }
+    
+    private IOFileFilter createFileFilterForDirectoryType( String directoryType )
+    {
+        WildcardFileFilter releasesFilter = new WildcardFileFilter( "releases-*" );
+        
+        if ( "working".equals( directoryType ) )
+        {
+            return new NotFileFilter( releasesFilter );
+        } 
+        else if ( "releases".equals( directoryType ) )
+        {
+            return releasesFilter;
+        }
+        else
+        {
+            return null;
+        }
+    }
+    
+    public void setBuildAgentConfigurationService( BuildAgentConfigurationService buildAgentConfigurationService )
+    {
+        this.buildAgentConfigurationService = buildAgentConfigurationService;
+    }
+}

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentPurgeManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java Fri Aug 26 09:34:42 2011
@@ -324,4 +324,9 @@ public class DefaultBuildAgentReleaseMan
     {
         this.buildAgentConfigurationService = buildAgentConfigurationService;
     }    
+    
+    public ContinuumReleaseManager getReleaseManager()
+    {
+        return releaseManager;
+    }
 }

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=1162043&r1=1162042&r2=1162043&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 Fri Aug 26 09:34:42 2011
@@ -19,15 +19,16 @@ package org.apache.continuum.purge;
  * under the License.
  */
 
+import java.util.List;
+
 import org.apache.continuum.buildmanager.BuildsManager;
-import org.apache.continuum.dao.ProjectDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.task.PurgeTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
-import org.apache.maven.continuum.build.settings.DefaultSchedulesActivator;
 import org.apache.maven.continuum.build.settings.SchedulesActivationException;
 import org.apache.maven.continuum.build.settings.SchedulesActivator;
 import org.apache.maven.continuum.model.project.Schedule;
@@ -35,8 +36,6 @@ import org.codehaus.plexus.taskqueue.Tas
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-
 /**
  * DefaultContinuumPurgeManager
  *
@@ -75,11 +74,17 @@ public class DefaultContinuumPurgeManage
     {
         List<RepositoryPurgeConfiguration> repoPurgeList = null;
         List<DirectoryPurgeConfiguration> dirPurgeList = null;
+        List<DistributedDirectoryPurgeConfiguration> distributedDirPurgeList = null;
 
         repoPurgeList = purgeConfigurationService.getEnableRepositoryPurgeConfigurationsBySchedule( schedule.getId() );
         dirPurgeList = purgeConfigurationService.getEnableDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
+        distributedDirPurgeList = purgeConfigurationService.getEnableDistributedDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
 
-        if ( repoPurgeList != null && repoPurgeList.size() > 0 )
+        boolean hasRepoPurge = repoPurgeList != null && repoPurgeList.size() > 0;
+        boolean hasDirPurge = dirPurgeList != null && dirPurgeList.size() > 0;
+        boolean hasDitributedDirPurge = distributedDirPurgeList != null && distributedDirPurgeList.size() > 0;
+        
+        if ( hasRepoPurge )
         {
             for ( RepositoryPurgeConfiguration repoPurge : repoPurgeList )
             {
@@ -87,7 +92,7 @@ public class DefaultContinuumPurgeManage
             }
         }
 
-        if ( dirPurgeList != null && dirPurgeList.size() > 0 )
+        if ( hasDirPurge )
         {
             for ( DirectoryPurgeConfiguration dirPurge : dirPurgeList )
             {
@@ -95,7 +100,15 @@ public class DefaultContinuumPurgeManage
             }
         }
         
-        if ( ( repoPurgeList == null || repoPurgeList.isEmpty() ) && ( dirPurgeList == null || dirPurgeList.isEmpty() ) )
+        if ( hasDitributedDirPurge )
+        {
+            for ( DistributedDirectoryPurgeConfiguration dirPurge : distributedDirPurgeList )
+            {
+                purgeDistributedDirectory( dirPurge );
+            }
+        }
+        
+        if ( !hasRepoPurge && !hasDirPurge && !hasDitributedDirPurge )
         {
             // This purge is not enable for a purge process.
             try
@@ -161,7 +174,7 @@ public class DefaultContinuumPurgeManage
         }
         catch ( TaskQueueException e )
         {
-            throw new ContinuumPurgeManagerException( "Error while enqueuing repository", e );
+            throw new ContinuumPurgeManagerException( "Error while enqueuing directory", e );
         }
         catch ( TaskQueueManagerException e )
         {
@@ -169,4 +182,17 @@ public class DefaultContinuumPurgeManage
         }
     }
 
+    public void purgeDistributedDirectory( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws ContinuumPurgeManagerException
+    {
+        try
+        {
+            taskQueueManager.getPurgeQueue().put( new PurgeTask( dirPurge.getId() ) );
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new ContinuumPurgeManagerException( "Error while enqueuing distributed directory", e );
+        }
+    }
+
 }
\ No newline at end of file

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/build/settings/DefaultSchedulesActivator.java Fri Aug 26 09:34:42 2011
@@ -26,9 +26,11 @@ import java.util.List;
 
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -70,6 +72,12 @@ public class DefaultSchedulesActivator
     /**
      * @plexus.requirement
      */
+    private DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
+
+
+    /**
+     * @plexus.requirement
+     */
     private BuildDefinitionDao buildDefinitionDao;
 
     /**
@@ -288,8 +296,10 @@ public class DefaultSchedulesActivator
             repositoryPurgeConfigurationDao.getEnableRepositoryPurgeConfigurationsBySchedule( schedule.getId() );
         List<DirectoryPurgeConfiguration> dirPurgeConfigs =
             directoryPurgeConfigurationDao.getEnableDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
+        List<DistributedDirectoryPurgeConfiguration> distriDirPurgeConfigs = 
+            distributedDirectoryPurgeConfigurationDao.getEnableDistributedDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
 
-        return repoPurgeConfigs.size() > 0 || dirPurgeConfigs.size() > 0;
+        return repoPurgeConfigs.size() > 0 || dirPurgeConfigs.size() > 0 || distriDirPurgeConfigs.size() > 0;
 
     }
 }

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.java Fri Aug 26 09:34:42 2011
@@ -294,4 +294,12 @@ public class SlaveBuildAgentTransportCli
         return null;
     }
 
+    @Override
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
+        throws Exception
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
 }

Modified: continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java (original)
+++ continuum/trunk/continuum-core/src/test/java/org/apache/continuum/purge/DefaultContinuumPurgeManagerTest.java Fri Aug 26 09:34:42 2011
@@ -20,9 +20,11 @@ package org.apache.continuum.purge;
  */
 
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.task.PurgeTask;
@@ -43,6 +45,8 @@ public class DefaultContinuumPurgeManage
 
     private DirectoryPurgeConfigurationDao directoryPurgeConfigurationDao;
 
+    private DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
+
     private RepositoryPurgeConfigurationDao repositoryPurgeConfigurationDao;
 
     private ContinuumPurgeManager purgeManager;
@@ -53,6 +57,8 @@ public class DefaultContinuumPurgeManage
 
     private DirectoryPurgeConfiguration dirPurge;
 
+    private DistributedDirectoryPurgeConfiguration distDirPurge;
+
     private TaskQueueManager taskQueueManager;
 
     @Override
@@ -68,6 +74,9 @@ public class DefaultContinuumPurgeManage
 
         repositoryPurgeConfigurationDao =
             (RepositoryPurgeConfigurationDao) lookup( RepositoryPurgeConfigurationDao.class.getName() );
+        
+        distributedDirectoryPurgeConfigurationDao =
+            (DistributedDirectoryPurgeConfigurationDao) lookup( DistributedDirectoryPurgeConfigurationDao.class.getName() );
 
         purgeManager = (ContinuumPurgeManager) lookup( ContinuumPurgeManager.ROLE );
 
@@ -122,9 +131,11 @@ public class DefaultContinuumPurgeManage
     {
         purgeManager.purgeRepository( repoPurge );
         purgeManager.purgeDirectory( dirPurge );
+        purgeManager.purgeDistributedDirectory( distDirPurge );
 
         assertNextBuildIs( repoPurge.getId() );
         assertNextBuildIs( dirPurge.getId() );
+        assertNextBuildIs( distDirPurge.getId() );
         assertNextBuildIsNull();
 
         purgeManager.purgeRepository( repoPurge );
@@ -158,6 +169,11 @@ public class DefaultContinuumPurgeManage
         dirPurge.setDirectoryType( "releases" );
         dirPurge.setLocation( getTestFile( "target/working-directory" ).getAbsolutePath() );
         dirPurge = directoryPurgeConfigurationDao.addDirectoryPurgeConfiguration( dirPurge );
+        
+        distDirPurge = new DistributedDirectoryPurgeConfiguration();
+        distDirPurge.setDirectoryType( "releases" );
+        distDirPurge.setBuildAgentUrl( "http://localhost:8186/continuum-buildagent/xmlrpc" );
+        distDirPurge = distributedDirectoryPurgeConfigurationDao.addDistributedDirectoryPurgeConfiguration( distDirPurge );
     }
 
     private void assertNextBuildIs( int expectedPurgeConfigId )

Modified: continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java (original)
+++ continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/JdoDataManagementTool.java Fri Aug 26 09:34:42 2011
@@ -46,6 +46,7 @@ import org.apache.continuum.dao.BuildQue
 import org.apache.continuum.dao.ContinuumReleaseResultDao;
 import org.apache.continuum.dao.DaoUtils;
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.InstallationDao;
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.ProfileDao;
@@ -107,6 +108,11 @@ public class JdoDataManagementTool
      * @plexus.requirement
      */
     private RepositoryPurgeConfigurationDao repositoryPurgeConfigurationDao;
+    
+    /**
+     * @plexus.requirement
+     */
+    private DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
 
     /**
      * @plexus.requirement
@@ -201,6 +207,7 @@ public class JdoDataManagementTool
         database.setRepositoryPurgeConfigurations(
             repositoryPurgeConfigurationDao.getAllRepositoryPurgeConfigurations() );
         database.setDirectoryPurgeConfigurations( directoryPurgeConfigurationDao.getAllDirectoryPurgeConfigurations() );
+        database.setDistributedDirectoryPurgeConfigurations( distributedDirectoryPurgeConfigurationDao.getAllDistributedDirectoryPurgeConfigurations() );
         database.setProjectScmRoots( projectScmRootDao.getAllProjectScmRoots() );
         database.setContinuumReleaseResults( releaseResultDao.getAllContinuumReleaseResults() );
 

Modified: continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java (original)
+++ continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java Fri Aug 26 09:34:42 2011
@@ -19,12 +19,11 @@ package org.apache.continuum.distributed
  * under the License.
  */
 
-import com.atlassian.xmlrpc.ServiceObject;
-
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+import com.atlassian.xmlrpc.ServiceObject;
 /**
  * SlaveBuildAgentTransportService
  */
@@ -154,4 +153,16 @@ public interface SlaveBuildAgentTranspor
      */
     public String getBuildAgentPlatform()
         throws Exception;
+
+    /**
+     * Execute a directory purge on the build agent
+     * 
+     * @param directoryType valid types are <i>working</i> and <i>releases</i>
+     * @param daysOlder days older
+     * @param retentionCount retention count
+     * @param deleteAll delete all flag
+     * 
+     * @throws Exception error that will occur during the purge
+     */
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll ) throws Exception;
 }

Modified: continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java (original)
+++ continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java Fri Aug 26 09:34:42 2011
@@ -19,20 +19,20 @@ package org.apache.continuum.distributed
  * under the License.
  */
 
-import com.atlassian.xmlrpc.ApacheBinder;
-import com.atlassian.xmlrpc.Binder;
-import com.atlassian.xmlrpc.BindingException;
-
 import java.net.URL;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.TimeZone;
 
-import com.atlassian.xmlrpc.ConnectionInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.atlassian.xmlrpc.ApacheBinder;
+import com.atlassian.xmlrpc.Binder;
+import com.atlassian.xmlrpc.BindingException;
+import com.atlassian.xmlrpc.ConnectionInfo;
+
 /**
  * SlaveBuildAgentTransportClient
  */
@@ -822,4 +822,10 @@ public class SlaveBuildAgentTransportCli
 
         return result;
     }
+
+    @Override
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll ) throws Exception
+    {
+        slave.executeDirectoryPurge( directoryType, daysOlder, retentionCount, deleteAll );
+    }
 }

Modified: continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java (original)
+++ continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java Fri Aug 26 09:34:42 2011
@@ -575,4 +575,10 @@ public class SlaveBuildAgentTransportSer
     {
         return continuumBuildAgentService.getBuildAgentPlatform();
     }
+    
+    @Override
+    public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll ) throws Exception
+    {
+        continuumBuildAgentService.executeDirectoryPurge( directoryType, daysOlder, retentionCount, deleteAll );
+    }
 }

Modified: continuum/trunk/continuum-distributed/continuum-distributed-tests/src/test/it/org/apache/continuum/distributed/transport/tests/SlaveBuildAgentTransportServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-distributed/continuum-distributed-tests/src/test/it/org/apache/continuum/distributed/transport/tests/SlaveBuildAgentTransportServiceTest.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-distributed/continuum-distributed-tests/src/test/it/org/apache/continuum/distributed/transport/tests/SlaveBuildAgentTransportServiceTest.java (original)
+++ continuum/trunk/continuum-distributed/continuum-distributed-tests/src/test/it/org/apache/continuum/distributed/transport/tests/SlaveBuildAgentTransportServiceTest.java Fri Aug 26 09:34:42 2011
@@ -107,4 +107,16 @@ public class SlaveBuildAgentTransportSer
             fail( e.getMessage() );
         }
     }
+    
+    public void testExecuteDirectoryPurge()
+    {
+        try
+        {
+            slaveProxy.executeDirectoryPurge( "releases", 1, 2, false );
+        }
+        catch ( Exception e )
+        {
+            fail( e.getMessage() );
+        }
+    }
 }

Modified: continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ continuum/trunk/continuum-model/src/main/mdo/continuum.xml Fri Aug 26 09:34:42 2011
@@ -100,6 +100,14 @@
           </association>
         </field>
         <field>
+          <name>distributedDirectoryPurgeConfigurations</name>
+          <version>1.4.1+</version>
+          <association>
+            <type>DistributedDirectoryPurgeConfiguration</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
           <name>projectScmRoots</name>
           <version>1.1.3+</version>
           <association java.init="field">
@@ -1611,6 +1619,31 @@
         </field>
       </fields>
     </class>
+    <class>
+      <name>DistributedDirectoryPurgeConfiguration</name>
+      <version>1.4.1+</version>
+      <superClass>AbstractPurgeConfiguration</superClass>
+      <packageName>org.apache.continuum.model.repository</packageName>
+      <fields>
+        <field>
+          <name>buildAgentUrl</name>
+          <version>1.4.1+</version>
+          <type>String</type>
+          <description>
+            BuildAgent URL
+          </description>
+          <required>true</required>
+        </field>
+        <field>
+          <name>directoryType</name>
+          <version>1.4.1+</version>
+          <type>String</type>
+          <description>
+            The type of directory. Valid values are "releases" and "working"
+          </description>
+        </field>
+      </fields>
+    </class>
        
     <class>
       <name>ContinuumReleaseResult</name>

Modified: continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo (original)
+++ continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo Fri Aug 26 09:34:42 2011
@@ -363,6 +363,11 @@
       </field>
       <field name="directoryType"/>
     </class>
+    <class name="DistributedDirectoryPurgeConfiguration" persistence-capable-superclass="org.apache.continuum.model.repository.AbstractPurgeConfiguration" detachable="true" table="DistributedDirectoryPurgeConfiguration">
+      <inheritance strategy="new-table"/>
+      <field name="buildAgentUrl" null-value="exception"/>
+      <field name="directoryType"/>
+    </class>
   </package>
   <package name="org.apache.maven.continuum.model.scm">
     <class name="ScmResult" detachable="true" table="ScmResult">

Modified: continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdorepl
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdorepl?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdorepl (original)
+++ continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdorepl Fri Aug 26 09:34:42 2011
@@ -363,6 +363,11 @@
       </field>
       <field name="directoryType"/>
     </class>
+    <class name="DistributedDirectoryPurgeConfiguration" persistence-capable-superclass="org.apache.continuum.model.repository.AbstractPurgeConfiguration" detachable="true" table="DistributedDirectoryPurgeConfiguration">
+      <inheritance strategy="new-table"/>
+      <field name="buildAgentUrl" null-value="exception"/>
+      <field name="directoryType"/>
+    </class>
   </package>
   <package name="org.apache.maven.continuum.model.scm">
     <class name="ScmResult" detachable="true" table="ScmResult">

Modified: continuum/trunk/continuum-purge/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/pom.xml?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/pom.xml (original)
+++ continuum/trunk/continuum-purge/pom.xml Fri Aug 26 09:34:42 2011
@@ -58,6 +58,14 @@ under the License.
       <artifactId>continuum-model</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.continuum</groupId>
+      <artifactId>continuum-distributed-slave-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.continuum</groupId>
+      <artifactId>continuum-distributed-slave-client</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>

Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/DefaultPurgeConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/DefaultPurgeConfigurationService.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/DefaultPurgeConfigurationService.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/DefaultPurgeConfigurationService.java Fri Aug 26 09:34:42 2011
@@ -20,10 +20,12 @@ package org.apache.continuum.purge;
  */
 
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
@@ -64,6 +66,11 @@ public class DefaultPurgeConfigurationSe
      * @plexus.requirement
      */
     private RepositoryPurgeConfigurationDao repositoryPurgeConfigurationDao;
+    
+    /**
+     * @plexus.requirement
+     */
+    private DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
 
     private PlexusContainer container;
 
@@ -80,6 +87,10 @@ public class DefaultPurgeConfigurationSe
         {
             purgeConfiguration = addDirectoryPurgeConfiguration( (DirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+        {
+            purgeConfiguration = addDistributedDirectoryPurgeConfiguration( ( DistributedDirectoryPurgeConfiguration ) purgeConfig );
+        }
 
         return purgeConfiguration;
     }
@@ -95,6 +106,10 @@ public class DefaultPurgeConfigurationSe
         {
             updateDirectoryPurgeConfiguration( (DirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+        {
+            updateDistributedDirectoryPurgeConfiguration( ( DistributedDirectoryPurgeConfiguration ) purgeConfig );
+        }
     }
 
     public void removePurgeConfiguration( int purgeConfigId )
@@ -110,6 +125,10 @@ public class DefaultPurgeConfigurationSe
         {
             removeDirectoryPurgeConfiguration( (DirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+        {
+            removeDistributedDirectoryPurgeConfiguration( ( DistributedDirectoryPurgeConfiguration ) purgeConfig );
+        }
     }
 
     public DirectoryPurgeConfiguration addDirectoryPurgeConfiguration( DirectoryPurgeConfiguration dirPurge )
@@ -340,6 +359,18 @@ public class DefaultPurgeConfigurationSe
                 // purgeConfigId is not of type directory purge configuration
             }
         }
+        
+        if ( purgeConfig == null )
+        {
+            try
+            {
+                purgeConfig = getDistributedDirectoryPurgeConfiguration( purgeConfigId );
+            }
+            catch ( PurgeConfigurationServiceException e )
+            {
+                // purgeConfigId is not of type directory purge configuration
+            }
+        }
 
         return purgeConfig;
     }
@@ -376,6 +407,77 @@ public class DefaultPurgeConfigurationSe
         }
     }
 
+    public List<DistributedDirectoryPurgeConfiguration> getAllDistributedDirectoryPurgeConfigurations()
+    {
+        return distributedDirectoryPurgeConfigurationDao.getAllDistributedDirectoryPurgeConfigurations();
+    }
+
+    public DistributedDirectoryPurgeConfiguration addDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws PurgeConfigurationServiceException
+    {
+        DistributedDirectoryPurgeConfiguration dirPurgeConfig;
+        
+        try
+        {
+            dirPurgeConfig = distributedDirectoryPurgeConfigurationDao.addDistributedDirectoryPurgeConfiguration( dirPurge );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+
+        return dirPurgeConfig;
+        
+    }
+
+    public DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int dirPurgeId )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            return distributedDirectoryPurgeConfigurationDao.getDistributedDirectoryPurgeConfiguration( dirPurgeId );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+    
+    public void updateDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration dirPurge )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            distributedDirectoryPurgeConfigurationDao.updateDistributedDirectoryPurgeConfiguration( dirPurge );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+
+    public void removeDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration purgeConfig )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            distributedDirectoryPurgeConfigurationDao.removeDistributedDirectoryPurgeConfiguration( purgeConfig );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+    
+    public List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule( int scheduleId )
+    {
+            return distributedDirectoryPurgeConfigurationDao.getEnableDistributedDirectoryPurgeConfigurationsBySchedule( scheduleId );
+    }
+
     public void contextualize( Context context )
         throws ContextException
     {

Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DirectoryPurgeController.java Fri Aug 26 09:34:42 2011
@@ -42,6 +42,12 @@ public class DirectoryPurgeController
 
     private ContinuumPurgeExecutor purgeExecutor;
 
+    public void doPurge( AbstractPurgeConfiguration purgeConfig )
+    {
+        DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) purgeConfig;
+        doPurge( dirPurge.getLocation() );
+    }
+    
     public void doPurge( String path )
     {
         try

Added: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java?rev=1162043&view=auto
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java (added)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java Fri Aug 26 09:34:42 2011
@@ -0,0 +1,95 @@
+package org.apache.continuum.purge.controller;
+
+/*
+ * 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.net.URL;
+
+import org.apache.continuum.distributed.transport.slave.SlaveBuildAgentTransportClient;
+import org.apache.continuum.distributed.transport.slave.SlaveBuildAgentTransportService;
+import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
+import org.apache.continuum.purge.executor.ContinuumPurgeExecutorException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * DirectoryPurgeController
+ *
+ * @author
+ * @plexus.component role="org.apache.continuum.purge.controller.PurgeController" role-hint="purge-distributed-directory"
+ */
+public class DistributedDirectoryPurgeController
+    implements PurgeController
+{
+    private static final Logger log = LoggerFactory.getLogger( DistributedDirectoryPurgeController.class );
+
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+    
+    private SlaveBuildAgentTransportService transportClient;
+    
+    public void doPurge( String path )
+    {
+        log.warn( "doPurge( String ) is not supported for DistributedDirectoryPurgeController" );
+    }
+
+    public void doPurge( AbstractPurgeConfiguration purgeConfig )
+    {
+        DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
+        try
+        {
+            transportClient.ping();
+
+            StringBuilder logMsg = new StringBuilder().append( "Executing directory purge with the following settings[directoryType=" ).
+                                                    append( dirPurge.getDirectoryType() ).append( ",daysOlder=" ).
+                                                    append( dirPurge.getDaysOlder() ).append( ", retentionCount=" ).
+                                                    append( dirPurge.getRetentionCount() ).append( ", deleteAll=" ).
+                                                    append( dirPurge.isDeleteAll() ).append( "]" );
+            
+            log.debug( logMsg.toString() );
+            
+            transportClient.executeDirectoryPurge( dirPurge.getDirectoryType(), dirPurge.getDaysOlder(), 
+                                                   dirPurge.getRetentionCount(), dirPurge.isDeleteAll() );
+        }
+        catch ( Exception e )
+        {
+            log.error( "Unable to execute purge: " + e.getMessage(), e );
+        }
+    }
+
+    public void initializeExecutors( AbstractPurgeConfiguration purgeConfig )
+        throws ContinuumPurgeExecutorException
+    {
+        DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
+
+        try
+        {
+            transportClient = new SlaveBuildAgentTransportClient( new URL( dirPurge.getBuildAgentUrl() ), "", 
+                                                                  configurationService.getSharedSecretPassword() );
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumPurgeExecutorException( e.getMessage(), e );
+        }
+    }
+}

Propchange: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/RepositoryPurgeController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/RepositoryPurgeController.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/RepositoryPurgeController.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/RepositoryPurgeController.java Fri Aug 26 09:34:42 2011
@@ -95,6 +95,12 @@ public class RepositoryPurgeController
         }
     }
 
+    public void doPurge( AbstractPurgeConfiguration purgeConfig )
+    {
+        RepositoryPurgeConfiguration repoPurge = (RepositoryPurgeConfiguration) purgeConfig;
+        doPurge( repoPurge.getRepository().getLocation() );
+    }
+    
     public void doPurge( String path )
     {
         try

Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/executor/RetentionCountDirectoryPurgeExecutor.java Fri Aug 26 09:34:42 2011
@@ -81,7 +81,7 @@ public class RetentionCountDirectoryPurg
 
         for ( File file : files )
         {
-            if ( countToPurge-- <= 0 )
+            if ( countToPurge <= 0 )
             {
                 break;
             }

Modified: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java Fri Aug 26 09:34:42 2011
@@ -21,6 +21,7 @@ package org.apache.continuum.purge.task;
 
 import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.PurgeConfigurationService;
@@ -102,6 +103,17 @@ public class PurgeTaskExecutor
 
                 purgeController.doPurge( dirPurge.getLocation() );
             }
+            else if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+            {
+                DistributedDirectoryPurgeConfiguration dirPurge = ( DistributedDirectoryPurgeConfiguration ) purgeConfig;
+                
+                PurgeController purgeController = 
+                    ( PurgeController ) container.lookup( PurgeController.ROLE, "purge-distributed-directory" );
+                
+                purgeController.initializeExecutors( dirPurge );
+                
+                purgeController.doPurge( dirPurge );
+            }
 
         }
         catch ( ComponentLookupException e )

Modified: continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java (original)
+++ continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/AbstractPurgeTest.java Fri Aug 26 09:34:42 2011
@@ -28,6 +28,7 @@ import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.LocalRepositoryDao;
 import org.apache.continuum.dao.RepositoryPurgeConfigurationDao;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
@@ -51,6 +52,8 @@ public abstract class AbstractPurgeTest
     private static final String TEST_DEFAULT_RELEASES_DIR = "target/working-directory";
 
     private static final String TEST_DEFAULT_BUILDOUTPUT_DIR = "target/build-output-directory";
+    
+    protected static final String TEST_BUILD_AGENT_URL = "http://localhost:8181/continuum-buildagent/xmlrpc";
 
     protected static final int TEST_DAYS_OLDER = 30;
 
@@ -59,6 +62,8 @@ public abstract class AbstractPurgeTest
     protected static final String TEST_RELEASES_DIRECTORY_TYPE = "releases";
 
     protected static final String TEST_BUILDOUTPUT_DIRECTORY_TYPE = "buildOutput";
+    
+    protected static final String TEST_WORKING_DIRECTORY_TYPE = "working";
 
     protected LocalRepositoryDao localRepositoryDao;
 
@@ -66,6 +71,8 @@ public abstract class AbstractPurgeTest
 
     protected RepositoryPurgeConfigurationDao repositoryPurgeConfigurationDao;
 
+    protected DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
+
     protected RepositoryPurgeConfiguration defaultRepoPurge;
 
     protected DirectoryPurgeConfiguration defaultReleasesDirPurge;
@@ -89,6 +96,9 @@ public abstract class AbstractPurgeTest
 
         directoryPurgeConfigurationDao =
             (DirectoryPurgeConfigurationDao) lookup( DirectoryPurgeConfigurationDao.class );
+        
+        distributedDirectoryPurgeConfigurationDao =
+            (DistributedDirectoryPurgeConfigurationDao) lookup( DistributedDirectoryPurgeConfigurationDao.class );
 
         if ( localRepositoryDao.getAllLocalRepositories().size() == 0 )
         {

Modified: continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java?rev=1162043&r1=1162042&r2=1162043&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java (original)
+++ continuum/trunk/continuum-purge/src/test/java/org/apache/continuum/purge/DefaultPurgeConfigurationServiceTest.java Fri Aug 26 09:34:42 2011
@@ -19,13 +19,14 @@ package org.apache.continuum.purge;
  * under the License.
  */
 
+import java.util.List;
+
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.repository.content.ManagedDefaultRepositoryContent;
 import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
 
-import java.util.List;
-
 /**
  * @author Maria Catherine Tan
  */
@@ -98,6 +99,35 @@ public class DefaultPurgeConfigurationSe
         assertFalse( "check if dir purge configuration was removed", dirConfigs.contains( dirConfig ) );
     }
 
+    public void testDistributedDirectoryPurgeConfiguration()
+        throws Exception
+    {
+        DistributedDirectoryPurgeConfiguration dirConfig = new DistributedDirectoryPurgeConfiguration();
+
+        dirConfig.setBuildAgentUrl( TEST_BUILD_AGENT_URL );
+        dirConfig.setDirectoryType( TEST_RELEASES_DIRECTORY_TYPE );
+        dirConfig.setDaysOlder( TEST_DAYS_OLDER );
+        dirConfig.setRetentionCount( TEST_RETENTION_COUNT );
+
+        dirConfig = purgeConfigurationService.addDistributedDirectoryPurgeConfiguration( dirConfig );
+
+        assertNotNull( dirConfig );
+
+        DistributedDirectoryPurgeConfiguration retrieved =
+            distributedDirectoryPurgeConfigurationDao.getDistributedDirectoryPurgeConfiguration( dirConfig.getId() );
+        assertEquals( dirConfig, retrieved );
+
+        dirConfig.setDirectoryType( TEST_WORKING_DIRECTORY_TYPE );
+        purgeConfigurationService.updateDistributedDirectoryPurgeConfiguration( dirConfig );
+        retrieved = distributedDirectoryPurgeConfigurationDao.getDistributedDirectoryPurgeConfiguration( dirConfig.getId() );
+        assertEquals( dirConfig, retrieved );
+
+        purgeConfigurationService.removeDistributedDirectoryPurgeConfiguration( dirConfig );
+
+        List<DistributedDirectoryPurgeConfiguration> dirConfigs = purgeConfigurationService.getAllDistributedDirectoryPurgeConfigurations();
+        assertFalse( "check if dir purge configuration was removed", dirConfigs.contains( dirConfig ) );
+    }
+
     public void testRepositoryManagedContent()
         throws Exception
     {



Mime
View raw message