continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1671638 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-api/src/main/java/org/apache/continuum/purge/ continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ conti...
Date Mon, 06 Apr 2015 18:58:39 GMT
Author: batkinson
Date: Mon Apr  6 18:58:38 2015
New Revision: 1671638

URL: http://svn.apache.org/r1671638
Log:
Stubbed out distributed repository purge support.

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDao.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedRepositoryPurgeController.java
      - copied, changed from r1671480, continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java
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-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-core/src/main/java/org/apache/continuum/purge/DefaultContinuumPurgeManager.java
    continuum/trunk/continuum-core/src/test/java/org/apache/continuum/builder/distributed/stubs/SlaveBuildAgentTransportClientStub.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-model/pom.xml
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-model/src/main/resources/META-INF/package.jdo
    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/DistributedDirectoryPurgeController.java
    continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/task/PurgeTaskExecutor.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDao.java?rev=1671638&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDao.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDao.java Mon Apr  6 18:58:38 2015
@@ -0,0 +1,57 @@
+package org.apache.continuum.dao;
+
+import org.apache.continuum.model.repository.DistributedRepositoryPurgeConfiguration;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import java.util.List;
+
+public interface DistributedRepositoryPurgeConfigurationDao
+{
+    /**
+     * Retrieve all DistributedDirectoryPurgeConfiguration instances.
+     *
+     * @return list of all DistributedDirectoryPurgeConfiguration instances
+     */
+    List<DistributedRepositoryPurgeConfiguration> getAllDistributedRepositoryPurgeConfigurations();
+
+    /**
+     * Adds a new DistributedRepositoryPurgeConfiguration instance.
+     *
+     * @param purgeConfiguration DistributedRepositoryPurgeConfiguration instance to be added
+     * @return DistributedRepositoryPurgeConfiguration instance that was added
+     * @throws ContinuumStoreException if unable to add the new instance
+     */
+    DistributedRepositoryPurgeConfiguration addDistributedRepositoryPurgeConfiguration(
+        DistributedRepositoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException;
+
+    /**
+     * Removes an existing DistributedRepositoryPurgeConfiguration instance.
+     *
+     * @param purgeConfig
+     */
+    void removeDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
+        throws ContinuumStoreException;
+
+    /**
+     * Retrieves an existing configuration object.
+     *
+     * @param dirPurgeId
+     * @return
+     * @throws ContinuumStoreException
+     */
+    DistributedRepositoryPurgeConfiguration getDistributedRepositoryPurgeConfiguration( int dirPurgeId )
+        throws ContinuumStoreException;
+
+    /**
+     * Updates an existing configuration object.
+     *
+     * @param purgeConfig
+     * @throws ContinuumStoreException
+     */
+    void updateDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
+        throws ContinuumStoreException;
+
+    List<DistributedRepositoryPurgeConfiguration> getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+        int scheduleId );
+}

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -21,6 +21,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.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.model.project.Schedule;
 
@@ -67,4 +68,13 @@ public interface ContinuumPurgeManager
      */
     void purgeDistributedDirectory( DistributedDirectoryPurgeConfiguration dirPurgeConfig )
         throws ContinuumPurgeManagerException;
+
+    /**
+     * Purge repository in distributed build mode
+     *
+     * @param repoPurgeConfig distributed purge configuration
+     * @throws ContinuumPurgeManagerException
+     */
+    void purgeDistributedRepository( DistributedRepositoryPurgeConfiguration repoPurgeConfig )
+        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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -22,6 +22,7 @@ package org.apache.continuum.purge;
 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.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
 
@@ -92,6 +93,8 @@ public interface PurgeConfigurationServi
 
     List<DistributedDirectoryPurgeConfiguration> getAllDistributedDirectoryPurgeConfigurations();
 
+    List<DistributedRepositoryPurgeConfiguration> getAllDistributedRepositoryPurgeConfigurations();
+
     DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int dirPurgeId )
         throws PurgeConfigurationServiceException;
 
@@ -110,11 +113,13 @@ public interface PurgeConfigurationServi
     List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule(
         int scheduleId );
 
+    List<DistributedRepositoryPurgeConfiguration> getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+        int scheduleId );
+
     /**
      * @param repositoryId
      * @return
      * @throws PurgeConfigurationServiceException
-     *
      */
     RepositoryManagedContent getManagedRepositoryContent( int repositoryId )
         throws PurgeConfigurationServiceException;

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -170,4 +170,18 @@ public interface ContinuumBuildAgentServ
     void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
         throws ContinuumBuildAgentException;
 
+    /**
+     * Execute a repository purge on the build agent
+     *
+     * @param repoName                used to determine location at the build agent
+     * @param daysOlder               age in days when file is eligible for purging
+     * @param retentionCount          number of artifact versions required to retain
+     * @param deleteAll               triggers full deletion
+     * @param deleteReleasedSnapshots whether to remove all snapshots matching a released artifact version
+     * @throws Exception
+     */
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -1172,6 +1172,21 @@ public class ContinuumBuildAgentServiceI
         }
     }
 
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        throws ContinuumBuildAgentException
+    {
+        try
+        {
+            LocalRepository localRepo = buildAgentConfigurationService.getLocalRepositoryByName( repoName );
+            log.warn( "purging repository {}", repoName );
+        }
+        catch ( BuildAgentConfigurationException e )
+        {
+            log.warn( "purge request ignored, repository {} not found", repoName );
+        }
+    }
+
     private List<BuildContext> initializeBuildContext( List<Map<String, Object>> projectsBuildContext )
     {
         List<BuildContext> buildContext = new ArrayList<BuildContext>();

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -22,6 +22,7 @@ package org.apache.continuum.purge;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.task.PurgeTask;
@@ -65,18 +66,23 @@ public class DefaultContinuumPurgeManage
     public void purge( Schedule schedule )
         throws ContinuumPurgeManagerException
     {
-        List<RepositoryPurgeConfiguration> repoPurgeList = null;
-        List<DirectoryPurgeConfiguration> dirPurgeList = null;
-        List<DistributedDirectoryPurgeConfiguration> distributedDirPurgeList = null;
+        List<RepositoryPurgeConfiguration> repoPurgeList;
+        List<DirectoryPurgeConfiguration> dirPurgeList;
+        List<DistributedDirectoryPurgeConfiguration> distributedDirPurgeList;
+        List<DistributedRepositoryPurgeConfiguration> distributedRepoPurgeList;
 
         repoPurgeList = purgeConfigurationService.getEnableRepositoryPurgeConfigurationsBySchedule( schedule.getId() );
         dirPurgeList = purgeConfigurationService.getEnableDirectoryPurgeConfigurationsBySchedule( schedule.getId() );
         distributedDirPurgeList = purgeConfigurationService.getEnableDistributedDirectoryPurgeConfigurationsBySchedule(
             schedule.getId() );
+        distributedRepoPurgeList =
+            purgeConfigurationService.getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+                schedule.getId() );
 
         boolean hasRepoPurge = repoPurgeList != null && repoPurgeList.size() > 0;
         boolean hasDirPurge = dirPurgeList != null && dirPurgeList.size() > 0;
         boolean hasDitributedDirPurge = distributedDirPurgeList != null && distributedDirPurgeList.size() > 0;
+        boolean hasDistributedRepoPurge = distributedRepoPurgeList != null && distributedRepoPurgeList.size() > 0;
 
         if ( hasRepoPurge )
         {
@@ -102,7 +108,15 @@ public class DefaultContinuumPurgeManage
             }
         }
 
-        if ( !hasRepoPurge && !hasDirPurge && !hasDitributedDirPurge )
+        if ( hasDistributedRepoPurge )
+        {
+            for ( DistributedRepositoryPurgeConfiguration repoPurge : distributedRepoPurgeList )
+            {
+                purgeDistributedRepository( repoPurge );
+            }
+        }
+
+        if ( !hasRepoPurge && !hasDirPurge && !hasDitributedDirPurge && !hasDistributedRepoPurge )
         {
             // This purge is not enable for a purge process.
             try
@@ -188,4 +202,17 @@ public class DefaultContinuumPurgeManage
         }
     }
 
+    public void purgeDistributedRepository( DistributedRepositoryPurgeConfiguration repoPurgeConfig )
+        throws ContinuumPurgeManagerException
+    {
+        try
+        {
+            taskQueueManager.getPurgeQueue().put( new PurgeTask( repoPurgeConfig.getId() ) );
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new ContinuumPurgeManagerException( "Error while enqueuing distributed repository", e );
+        }
+    }
+
 }
\ No newline at end of file

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -301,4 +301,11 @@ public class SlaveBuildAgentTransportCli
 
     }
 
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        throws Exception
+    {
+
+    }
+
 }

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -166,4 +166,18 @@ public interface SlaveBuildAgentTranspor
      */
     public void executeDirectoryPurge( String directoryType, int daysOlder, int retentionCount, boolean deleteAll )
         throws Exception;
+
+    /**
+     * Execute a repository purge on the build agent
+     *
+     * @param repoName                used to determine location at the build agent
+     * @param daysOlder               age in days when file is eligible for purging
+     * @param retentionCount          number of artifact versions required to retain
+     * @param deleteAll               triggers full deletion
+     * @param deleteReleasedSnapshots whether to remove all snapshots matching a released artifact version
+     * @throws Exception
+     */
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -887,4 +887,11 @@ public class SlaveBuildAgentTransportCli
     {
         slave.executeDirectoryPurge( directoryType, daysOlder, retentionCount, deleteAll );
     }
+
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        throws Exception
+    {
+        slave.executeRepositoryPurge( repoName, daysOlder, retentionCount, deleteAll, deleteReleasedSnapshots );
+    }
 }

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -587,4 +587,13 @@ public class SlaveBuildAgentTransportSer
     {
         continuumBuildAgentService.executeDirectoryPurge( directoryType, daysOlder, retentionCount, deleteAll );
     }
+
+    public void executeRepositoryPurge( String repoName, int daysOlder, int retentionCount, boolean deleteAll,
+                                        boolean deleteReleasedSnapshots )
+        throws Exception
+    {
+        continuumBuildAgentService.executeRepositoryPurge( repoName, daysOlder, retentionCount, deleteAll,
+                                                           deleteReleasedSnapshots );
+    }
+
 }

Modified: continuum/trunk/continuum-model/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/pom.xml?rev=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-model/pom.xml (original)
+++ continuum/trunk/continuum-model/pom.xml Mon Apr  6 18:58:38 2015
@@ -44,7 +44,7 @@
           </execution>
         </executions>
         <configuration>
-          <version>1.4.1</version>
+          <version>1.5.0</version>
           <packageWithVersion>false</packageWithVersion>
           <models>
             <model>src/main/mdo/continuum.xml</model>

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=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ continuum/trunk/continuum-model/src/main/mdo/continuum.xml Mon Apr  6 18:58:38 2015
@@ -108,6 +108,14 @@
           </association>
         </field>
         <field>
+          <name>distributedRepositoryPurgeConfigurations</name>
+          <version>1.5.0+</version>
+          <association>
+            <type>DistributedRepositoryPurgeConfiguration</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+        <field>
           <name>projectScmRoots</name>
           <version>1.1.3+</version>
           <association java.init="field">
@@ -1646,6 +1654,40 @@
         </field>
       </fields>
     </class>
+    <class>
+      <name>DistributedRepositoryPurgeConfiguration</name>
+      <version>1.5.0+</version>
+      <superClass>AbstractPurgeConfiguration</superClass>
+      <packageName>org.apache.continuum.model.repository</packageName>
+      <fields>
+        <field>
+          <name>repositoryName</name>
+          <version>1.5.0+</version>
+          <type>String</type>
+          <description>
+            The remote name of the repository to purge. Slave purge requests find configuration by this name.
+          </description>
+        </field>
+        <field>
+          <name>deleteReleasedSnapshots</name>
+          <version>1.5.0+</version>
+          <type>boolean</type>
+          <defaultValue>false</defaultValue>
+          <description>
+            True if the released snapshots are to be removed from the repo during repository purge.
+          </description>
+        </field>
+        <field>
+          <name>buildAgentUrl</name>
+          <version>1.5.0+</version>
+          <type>String</type>
+          <description>
+            BuildAgent URL
+          </description>
+          <required>true</required>
+        </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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -393,6 +393,12 @@
       <field name="buildAgentUrl" null-value="exception"/>
       <field name="directoryType"/>
     </class>
+    <class name="DistributedRepositoryPurgeConfiguration" persistence-capable-superclass="org.apache.continuum.model.repository.AbstractPurgeConfiguration" detachable="true" table="DistributedRepositoryPurgeConfiguration">
+      <inheritance strategy="new-table"/>
+      <field name="repositoryName" null-value="exception" />
+      <field name="deleteReleasedSnapshots"/>
+      <field name="buildAgentUrl" null-value="exception"/>
+    </class>
   </package>
   <package name="org.apache.maven.continuum.model.scm">
     <class name="ScmResult" detachable="true" table="ScmResult">

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -21,11 +21,13 @@ package org.apache.continuum.purge;
 
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
 import org.apache.continuum.dao.DistributedDirectoryPurgeConfigurationDao;
+import org.apache.continuum.dao.DistributedRepositoryPurgeConfigurationDao;
 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.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.repository.content.RepositoryManagedContent;
@@ -66,6 +68,9 @@ public class DefaultPurgeConfigurationSe
     @Requirement
     private DistributedDirectoryPurgeConfigurationDao distributedDirectoryPurgeConfigurationDao;
 
+    @Requirement
+    private DistributedRepositoryPurgeConfigurationDao distributedRepositoryPurgeConfigurationDao;
+
     private PlexusContainer container;
 
     public AbstractPurgeConfiguration addPurgeConfiguration( AbstractPurgeConfiguration purgeConfig )
@@ -86,6 +91,11 @@ public class DefaultPurgeConfigurationSe
             purgeConfiguration = addDistributedDirectoryPurgeConfiguration(
                 (DistributedDirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+        {
+            purgeConfiguration =
+                addDistributedRepositoryPurgeConfiguration( (DistributedRepositoryPurgeConfiguration) purgeConfig );
+        }
 
         return purgeConfiguration;
     }
@@ -105,6 +115,10 @@ public class DefaultPurgeConfigurationSe
         {
             updateDistributedDirectoryPurgeConfiguration( (DistributedDirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+        {
+            updateDistributedRepositoryPurgeConfiguration( (DistributedRepositoryPurgeConfiguration) purgeConfig );
+        }
     }
 
     public void removePurgeConfiguration( int purgeConfigId )
@@ -124,6 +138,10 @@ public class DefaultPurgeConfigurationSe
         {
             removeDistributedDirectoryPurgeConfiguration( (DistributedDirectoryPurgeConfiguration) purgeConfig );
         }
+        else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+        {
+            removeDistributedRepositoryPurgeConfiguration( (DistributedRepositoryPurgeConfiguration) purgeConfig );
+        }
     }
 
     public DirectoryPurgeConfiguration addDirectoryPurgeConfiguration( DirectoryPurgeConfiguration dirPurge )
@@ -367,6 +385,18 @@ public class DefaultPurgeConfigurationSe
             }
         }
 
+        if ( purgeConfig == null )
+        {
+            try
+            {
+                purgeConfig = getDistributedRepositoryPurgeConfiguration( purgeConfigId );
+            }
+            catch ( PurgeConfigurationServiceException e )
+            {
+                // purgeConfigId is not of type directory purge configuration
+            }
+        }
+
         return purgeConfig;
     }
 
@@ -407,24 +437,38 @@ public class DefaultPurgeConfigurationSe
         return distributedDirectoryPurgeConfigurationDao.getAllDistributedDirectoryPurgeConfigurations();
     }
 
+    public List<DistributedRepositoryPurgeConfiguration> getAllDistributedRepositoryPurgeConfigurations()
+    {
+        return distributedRepositoryPurgeConfigurationDao.getAllDistributedRepositoryPurgeConfigurations();
+    }
+
     public DistributedDirectoryPurgeConfiguration addDistributedDirectoryPurgeConfiguration(
         DistributedDirectoryPurgeConfiguration dirPurge )
         throws PurgeConfigurationServiceException
     {
-        DistributedDirectoryPurgeConfiguration dirPurgeConfig;
-
         try
         {
-            dirPurgeConfig = distributedDirectoryPurgeConfigurationDao.addDistributedDirectoryPurgeConfiguration(
-                dirPurge );
+            return distributedDirectoryPurgeConfigurationDao.addDistributedDirectoryPurgeConfiguration( dirPurge );
         }
         catch ( ContinuumStoreException e )
         {
             throw new PurgeConfigurationServiceException( e.getMessage(), e );
         }
+    }
 
-        return dirPurgeConfig;
-
+    public DistributedRepositoryPurgeConfiguration addDistributedRepositoryPurgeConfiguration(
+        DistributedRepositoryPurgeConfiguration repoPurge )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            return distributedRepositoryPurgeConfigurationDao.addDistributedRepositoryPurgeConfiguration(
+                repoPurge );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
     }
 
     public DistributedDirectoryPurgeConfiguration getDistributedDirectoryPurgeConfiguration( int dirPurgeId )
@@ -457,6 +501,19 @@ public class DefaultPurgeConfigurationSe
         }
     }
 
+    private void updateDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            distributedRepositoryPurgeConfigurationDao.updateDistributedRepositoryPurgeConfiguration( purgeConfig );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+
     public void removeDistributedDirectoryPurgeConfiguration( DistributedDirectoryPurgeConfiguration purgeConfig )
         throws PurgeConfigurationServiceException
     {
@@ -470,6 +527,36 @@ public class DefaultPurgeConfigurationSe
         }
     }
 
+    public void removeDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            distributedRepositoryPurgeConfigurationDao.removeDistributedRepositoryPurgeConfiguration( purgeConfig );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+
+    public DistributedRepositoryPurgeConfiguration getDistributedRepositoryPurgeConfiguration( int dirPurgeId )
+        throws PurgeConfigurationServiceException
+    {
+        try
+        {
+            return distributedRepositoryPurgeConfigurationDao.getDistributedRepositoryPurgeConfiguration( dirPurgeId );
+        }
+        catch ( ContinuumObjectNotFoundException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new PurgeConfigurationServiceException( e.getMessage(), e );
+        }
+    }
+
     public List<DistributedDirectoryPurgeConfiguration> getEnableDistributedDirectoryPurgeConfigurationsBySchedule(
         int scheduleId )
     {
@@ -477,6 +564,13 @@ public class DefaultPurgeConfigurationSe
             scheduleId );
     }
 
+    public List<DistributedRepositoryPurgeConfiguration> getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+        int scheduleId )
+    {
+        return distributedRepositoryPurgeConfigurationDao.getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+            scheduleId );
+    }
+
     public void contextualize( Context context )
         throws ContextException
     {

Modified: 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=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java Mon Apr  6 18:58:38 2015
@@ -58,14 +58,20 @@ public class DistributedDirectoryPurgeCo
         {
             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() );
+            if ( log.isDebugEnabled() )
+            {
+                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() );

Copied: continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedRepositoryPurgeController.java (from r1671480, 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/DistributedRepositoryPurgeController.java?p2=continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedRepositoryPurgeController.java&p1=continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java&r1=1671480&r2=1671638&rev=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedDirectoryPurgeController.java (original)
+++ continuum/trunk/continuum-purge/src/main/java/org/apache/continuum/purge/controller/DistributedRepositoryPurgeController.java Mon Apr  6 18:58:38 2015
@@ -22,7 +22,7 @@ package org.apache.continuum.purge.contr
 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.model.repository.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.purge.executor.ContinuumPurgeExecutorException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.codehaus.plexus.component.annotations.Component;
@@ -35,11 +35,11 @@ import java.net.URL;
 /**
  * DirectoryPurgeController
  */
-@Component( role = org.apache.continuum.purge.controller.PurgeController.class, hint = "purge-distributed-directory" )
-public class DistributedDirectoryPurgeController
+@Component( role = PurgeController.class, hint = "purge-distributed-repository" )
+public class DistributedRepositoryPurgeController
     implements PurgeController
 {
-    private static final Logger log = LoggerFactory.getLogger( DistributedDirectoryPurgeController.class );
+    private static final Logger log = LoggerFactory.getLogger( DistributedRepositoryPurgeController.class );
 
     @Requirement
     private ConfigurationService configurationService;
@@ -48,27 +48,38 @@ public class DistributedDirectoryPurgeCo
 
     public void doPurge( String path )
     {
-        log.warn( "doPurge( String ) is not supported for DistributedDirectoryPurgeController" );
+        log.warn( "doPurge( String ) is not supported for {}",
+                  DistributedRepositoryPurgeController.class.getSimpleName() );
     }
 
     public void doPurge( AbstractPurgeConfiguration purgeConfig )
     {
-        DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
+        DistributedRepositoryPurgeConfiguration repoPurge = (DistributedRepositoryPurgeConfiguration) 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() );
+            if ( log.isDebugEnabled() )
+            {
+                StringBuilder logMsg = new StringBuilder().append(
+                    "Executing repository purge with the following settings[" )
+                                                          .append( "repo=" )
+                                                          .append( repoPurge.getRepositoryName() )
+                                                          .append( ",daysOlder=" )
+                                                          .append( repoPurge.getDaysOlder() )
+                                                          .append( ", retentionCount=" )
+                                                          .append( repoPurge.getRetentionCount() )
+                                                          .append( ", deleteAll=" )
+                                                          .append( repoPurge.isDeleteAll() )
+                                                          .append( ",deleteReleasedSnapshots=" )
+                                                          .append( repoPurge.isDeleteReleasedSnapshots() )
+                                                          .append( "]" );
+                log.debug( logMsg.toString() );
+            }
+
+            transportClient.executeRepositoryPurge( repoPurge.getRepositoryName(), repoPurge.getDaysOlder(),
+                                                    repoPurge.getRetentionCount(), repoPurge.isDeleteAll(),
+                                                    repoPurge.isDeleteReleasedSnapshots() );
         }
         catch ( Exception e )
         {
@@ -79,11 +90,10 @@ public class DistributedDirectoryPurgeCo
     public void initializeExecutors( AbstractPurgeConfiguration purgeConfig )
         throws ContinuumPurgeExecutorException
     {
-        DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
-
+        DistributedRepositoryPurgeConfiguration repoPurge = (DistributedRepositoryPurgeConfiguration) purgeConfig;
         try
         {
-            transportClient = new SlaveBuildAgentTransportClient( new URL( dirPurge.getBuildAgentUrl() ), "",
+            transportClient = new SlaveBuildAgentTransportClient( new URL( repoPurge.getBuildAgentUrl() ), "",
                                                                   configurationService.getSharedSecretPassword() );
         }
         catch ( Exception e )

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=1671638&r1=1671637&r2=1671638&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 Mon Apr  6 18:58:38 2015
@@ -22,6 +22,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.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.PurgeConfigurationService;
@@ -110,6 +111,18 @@ public class PurgeTaskExecutor
 
                 purgeController.initializeExecutors( dirPurge );
 
+                purgeController.doPurge( dirPurge );
+            }
+            else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+            {
+                DistributedRepositoryPurgeConfiguration dirPurge =
+                    (DistributedRepositoryPurgeConfiguration) purgeConfig;
+
+                PurgeController purgeController = (PurgeController) container.lookup( PurgeController.ROLE,
+                                                                                      "purge-distributed-repository" );
+
+                purgeController.initializeExecutors( dirPurge );
+
                 purgeController.doPurge( dirPurge );
             }
 

Added: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java?rev=1671638&view=auto
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java (added)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DistributedRepositoryPurgeConfigurationDaoImpl.java Mon Apr  6 18:58:38 2015
@@ -0,0 +1,72 @@
+package org.apache.continuum.dao;
+
+import org.apache.continuum.model.repository.DistributedRepositoryPurgeConfiguration;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.springframework.stereotype.Repository;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.util.Collections;
+import java.util.List;
+
+@Repository( "distributedRepositoryPurgeConfigurationDao" )
+public class DistributedRepositoryPurgeConfigurationDaoImpl
+    extends AbstractDao
+    implements DistributedRepositoryPurgeConfigurationDao
+{
+    public List<DistributedRepositoryPurgeConfiguration> getAllDistributedRepositoryPurgeConfigurations()
+    {
+        return getAllObjectsDetached( DistributedRepositoryPurgeConfiguration.class );
+    }
+
+    public DistributedRepositoryPurgeConfiguration addDistributedRepositoryPurgeConfiguration(
+        DistributedRepositoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        return (DistributedRepositoryPurgeConfiguration) addObject( purgeConfiguration );
+    }
+
+    public void removeDistributedRepositoryPurgeConfiguration(
+        DistributedRepositoryPurgeConfiguration purgeConfiguration )
+    {
+        removeObject( purgeConfiguration );
+    }
+
+    public DistributedRepositoryPurgeConfiguration getDistributedRepositoryPurgeConfiguration( int configId )
+        throws ContinuumStoreException
+    {
+        return (DistributedRepositoryPurgeConfiguration) getObjectById( DistributedRepositoryPurgeConfiguration.class,
+                                                                        configId );
+    }
+
+    public void updateDistributedRepositoryPurgeConfiguration( DistributedRepositoryPurgeConfiguration purgeConfig )
+        throws ContinuumStoreException
+    {
+        updateObject( purgeConfig );
+    }
+
+    public List<DistributedRepositoryPurgeConfiguration> getEnableDistributedRepositoryPurgeConfigurationsBySchedule(
+        int scheduleId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        Transaction tx = pm.currentTransaction();
+        try
+        {
+            tx.begin();
+            Extent extent = pm.getExtent( DistributedRepositoryPurgeConfiguration.class, true );
+            Query query = pm.newQuery( extent );
+            query.declareParameters( "int scheduleId" );
+            query.setFilter( "this.schedule.id == scheduleId && this.enabled == true" );
+            List result = (List) query.execute( scheduleId );
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+            rollback( tx );
+        }
+    }
+
+}
\ No newline at end of file

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java?rev=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/DistributedPurgeConfigurationAction.java Mon Apr  6 18:58:38 2015
@@ -21,12 +21,16 @@ package org.apache.continuum.web.action.
 
 import com.opensymphony.xwork2.Preparable;
 import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.continuum.configuration.BuildAgentConfiguration;
 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.DistributedRepositoryPurgeConfiguration;
+import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.purge.ContinuumPurgeManager;
 import org.apache.continuum.purge.PurgeConfigurationService;
+import org.apache.continuum.repository.RepositoryService;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumConfirmAction;
@@ -46,7 +50,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-@Component( role = com.opensymphony.xwork2.Action.class, hint = "distributedPurgeConfiguration", instantiationStrategy = "per-lookup"  )
+@Component( role = com.opensymphony.xwork2.Action.class, hint = "distributedPurgeConfiguration", instantiationStrategy = "per-lookup" )
 public class DistributedPurgeConfigurationAction
     extends ContinuumConfirmAction
     implements Preparable, SecureAction
@@ -55,6 +59,8 @@ public class DistributedPurgeConfigurati
 
     private static final String PURGE_TYPE_DIRECTORY = "directory";
 
+    private static final String PURGE_TYPE_REPOSITORY = "repository";
+
     private static final String PURGE_DIRECTORY_RELEASES = "releases";
 
     private static final String PURGE_DIRECTORY_WORKING = "working";
@@ -63,6 +69,8 @@ public class DistributedPurgeConfigurati
 
     private static final int DEFAULT_DAYS_OLDER = 100;
 
+    private String repositoryName;
+
     private String purgeType;
 
     private String directoryType;
@@ -95,6 +103,8 @@ public class DistributedPurgeConfigurati
 
     private Map<Integer, String> schedules;
 
+    private List<String> repositories;
+
     private List<String> directoryTypes;
 
     private List<String> buildAgentUrls;
@@ -102,6 +112,9 @@ public class DistributedPurgeConfigurati
     @Requirement
     private PurgeConfigurationService purgeConfigService;
 
+    @Requirement
+    private RepositoryService repositoryService;
+
     @Override
     public void prepare()
         throws Exception
@@ -122,6 +135,19 @@ public class DistributedPurgeConfigurati
         }
 
         // build repositories
+        if ( repositories == null )
+        {
+            repositories = new ArrayList<String>();
+
+            List<LocalRepository> allRepositories = repositoryService.getAllLocalRepositories();
+
+            for ( LocalRepository repository : allRepositories )
+            {
+                repositories.add( repository.getName() );
+            }
+        }
+
+        // build repositories
         if ( buildAgentUrls == null )
         {
             List<BuildAgentConfiguration> buildAgents = getContinuum().getConfiguration().getBuildAgents();
@@ -144,24 +170,39 @@ public class DistributedPurgeConfigurati
     {
         if ( purgeConfigId != 0 )
         {
+            // Shared configuration
             purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
+            this.daysOlder = purgeConfig.getDaysOlder();
+            this.retentionCount = purgeConfig.getRetentionCount();
+            this.deleteAll = purgeConfig.isDeleteAll();
+            this.enabled = purgeConfig.isEnabled();
+            this.defaultPurgeConfiguration = purgeConfig.isDefaultPurge();
+            this.description = purgeConfig.getDescription();
+
+            if ( purgeConfig.getSchedule() != null )
+            {
+                this.scheduleId = purgeConfig.getSchedule().getId();
+            }
 
             if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
             {
+                // Custom dir configuration
                 DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
-
                 this.purgeType = PURGE_TYPE_DIRECTORY;
-                this.daysOlder = dirPurge.getDaysOlder();
-                this.retentionCount = dirPurge.getRetentionCount();
                 this.directoryType = dirPurge.getDirectoryType();
-                this.deleteAll = dirPurge.isDeleteAll();
-                this.enabled = dirPurge.isEnabled();
-                this.defaultPurgeConfiguration = dirPurge.isDefaultPurge();
-                this.description = dirPurge.getDescription();
                 this.buildAgentUrl = dirPurge.getBuildAgentUrl();
-                if ( dirPurge.getSchedule() != null )
+            }
+            else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+            {
+                // Custom repo configuration
+                DistributedRepositoryPurgeConfiguration repoPurge =
+                    (DistributedRepositoryPurgeConfiguration) purgeConfig;
+                this.purgeType = PURGE_TYPE_REPOSITORY;
+                this.deleteReleasedSnapshots = repoPurge.isDeleteReleasedSnapshots();
+                this.buildAgentUrl = repoPurge.getBuildAgentUrl();
+                if ( !StringUtils.isEmpty( repoPurge.getRepositoryName() ) )
                 {
-                    this.scheduleId = dirPurge.getSchedule().getId();
+                    this.repositoryName = repoPurge.getRepositoryName();
                 }
             }
         }
@@ -179,16 +220,23 @@ public class DistributedPurgeConfigurati
     {
         if ( purgeConfigId == 0 )
         {
-            purgeConfig = new DistributedDirectoryPurgeConfiguration();
+            if ( PURGE_TYPE_REPOSITORY.equals( purgeType ) )
+            {
+                purgeConfig = new DistributedRepositoryPurgeConfiguration();
+            }
+            else
+            {
+                purgeConfig = new DistributedDirectoryPurgeConfiguration();
+            }
 
-            purgeConfig = setupPurgeConfiguration( purgeConfig );
+            purgeConfig = setupPurgeConfiguration();
 
             purgeConfig = purgeConfigService.addPurgeConfiguration( purgeConfig );
         }
         else
         {
             purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
-            purgeConfig = setupPurgeConfiguration( purgeConfig );
+            purgeConfig = setupPurgeConfiguration();
 
             purgeConfigService.updatePurgeConfiguration( purgeConfig );
         }
@@ -209,7 +257,6 @@ public class DistributedPurgeConfigurati
     public String remove()
         throws Exception
     {
-
         if ( confirmed )
         {
             purgeConfigService.removePurgeConfiguration( purgeConfigId );
@@ -225,15 +272,22 @@ public class DistributedPurgeConfigurati
     public String purge()
         throws Exception
     {
-
         ContinuumPurgeManager purgeManager = getContinuum().getPurgeManager();
 
         if ( purgeConfigId > 0 )
         {
             purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
-
-            DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
-            purgeManager.purgeDistributedDirectory( dirPurge );
+            if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+            {
+                DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
+                purgeManager.purgeDistributedDirectory( dirPurge );
+            }
+            else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+            {
+                DistributedRepositoryPurgeConfiguration repoPurge =
+                    (DistributedRepositoryPurgeConfiguration) purgeConfig;
+                purgeManager.purgeDistributedRepository( repoPurge );
+            }
         }
 
         return SUCCESS;
@@ -401,12 +455,6 @@ public class DistributedPurgeConfigurati
         this.directoryTypes = directoryTypes;
     }
 
-    private AbstractPurgeConfiguration setupPurgeConfiguration( AbstractPurgeConfiguration purgeConfiguration )
-        throws Exception
-    {
-        return buildDirPurgeConfiguration();
-    }
-
     public String getBuildAgentUrl()
     {
         return buildAgentUrl;
@@ -427,28 +475,38 @@ public class DistributedPurgeConfigurati
         this.buildAgentUrls = buildAgentUrls;
     }
 
-    private DistributedDirectoryPurgeConfiguration buildDirPurgeConfiguration()
+    private AbstractPurgeConfiguration setupPurgeConfiguration()
         throws Exception
     {
-        DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
-        dirPurge.setDeleteAll( this.deleteAll );
-        dirPurge.setEnabled( this.enabled );
-        dirPurge.setDaysOlder( this.daysOlder );
-        dirPurge.setRetentionCount( this.retentionCount );
-        dirPurge.setDirectoryType( this.directoryType );
-        dirPurge.setDefaultPurge( this.defaultPurgeConfiguration );
-        dirPurge.setBuildAgentUrl( buildAgentUrl );
+        purgeConfig.setDeleteAll( deleteAll );
+        purgeConfig.setEnabled( enabled );
+        purgeConfig.setDaysOlder( daysOlder );
+        purgeConfig.setRetentionCount( retentionCount );
+        purgeConfig.setDefaultPurge( defaultPurgeConfiguration );
 
         // escape xml to prevent xss attacks
-        dirPurge.setDescription( StringEscapeUtils.escapeXml( StringEscapeUtils.unescapeXml( this.description ) ) );
-
+        purgeConfig.setDescription( StringEscapeUtils.escapeXml( StringEscapeUtils.unescapeXml( this.description ) ) );
         if ( scheduleId > 0 )
         {
             Schedule schedule = getContinuum().getSchedule( scheduleId );
-            dirPurge.setSchedule( schedule );
+            purgeConfig.setSchedule( schedule );
+        }
+
+        if ( purgeConfig instanceof DistributedDirectoryPurgeConfiguration )
+        {
+            DistributedDirectoryPurgeConfiguration dirPurge = (DistributedDirectoryPurgeConfiguration) purgeConfig;
+            dirPurge.setDirectoryType( directoryType );
+            dirPurge.setBuildAgentUrl( buildAgentUrl );
+        }
+        else if ( purgeConfig instanceof DistributedRepositoryPurgeConfiguration )
+        {
+            DistributedRepositoryPurgeConfiguration repoPurge = (DistributedRepositoryPurgeConfiguration) purgeConfig;
+            repoPurge.setRepositoryName( repositoryName );
+            repoPurge.setDeleteReleasedSnapshots( deleteReleasedSnapshots );
+            repoPurge.setBuildAgentUrl( buildAgentUrl );
         }
 
-        return dirPurge;
+        return purgeConfig;
     }
 
     private void updateDefaultPurgeConfiguration()
@@ -473,4 +531,24 @@ public class DistributedPurgeConfigurati
 
         return bundle;
     }
+
+    public List<String> getRepositories()
+    {
+        return this.repositories;
+    }
+
+    public void setRepositories( List<String> repositories )
+    {
+        this.repositories = repositories;
+    }
+
+    public String getRepositoryName()
+    {
+        return repositoryName;
+    }
+
+    public void setRepositoryName( String repositoryName )
+    {
+        this.repositoryName = repositoryName;
+    }
 }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java?rev=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeAction.java Mon Apr  6 18:58:38 2015
@@ -22,6 +22,7 @@ package org.apache.continuum.web.action.
 import com.opensymphony.xwork2.Preparable;
 import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.DistributedRepositoryPurgeConfiguration;
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.repository.RepositoryService;
@@ -72,6 +73,8 @@ public class PurgeAction
 
     private List<DistributedDirectoryPurgeConfiguration> distributedDirPurgeConfigs;
 
+    private List<DistributedRepositoryPurgeConfiguration> distributedRepoPurgeConfigs;
+
     private List<String> directoryTypes;
 
     @Requirement
@@ -105,6 +108,7 @@ public class PurgeAction
                 addActionError( getText( errorMessage ) );
             }
             distributedDirPurgeConfigs = purgeConfigService.getAllDistributedDirectoryPurgeConfigurations();
+            distributedRepoPurgeConfigs = purgeConfigService.getAllDistributedRepositoryPurgeConfigurations();
 
             return DISTRIBUTED_BUILD_SUCCESS;
         }
@@ -175,6 +179,17 @@ public class PurgeAction
         this.distributedDirPurgeConfigs = distributedDirPurgeConfigs;
     }
 
+    public List<DistributedRepositoryPurgeConfiguration> getDistributedRepoPurgeConfigs()
+    {
+        return distributedRepoPurgeConfigs;
+    }
+
+    public void setDistributedRepoPurgeConfigs(
+        List<DistributedRepositoryPurgeConfiguration> distributedRepoPurgeConfigs )
+    {
+        this.distributedRepoPurgeConfigs = distributedRepoPurgeConfigs;
+    }
+
     public List<String> getDirectoryTypes()
     {
         return directoryTypes;

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp?rev=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/distributedPurgeConfigurationsList.jsp Mon Apr  6 18:58:38 2015
@@ -27,7 +27,69 @@
       <title><s:text name="purgeConfigs.page.title"/></title>
     </head>
     <body>
-      <div id="h3">
+      <div id="h3-1">
+        <h3><s:text name="purgeConfigs.repo.section.title"/></h3>
+        <s:if test="hasActionErrors()">
+          <div class="errormessage">
+            <s:iterator value="actionErrors">
+              <p><s:property/></p>
+            </s:iterator>
+          </div>
+        </s:if>
+        <s:set name="repoPurgeConfigs" value="distributedRepoPurgeConfigs" scope="request"/>
+        <ec:table items="repoPurgeConfigs"
+                  var="repoPurge"
+                  autoIncludeParameters="false"
+                  showExports="false"
+                  showPagination="false"
+                  showStatusBar="false"
+                  sortable="false"
+                  filterable="false">
+         <ec:row>
+            <ec:column property="repositoryName" title="purgeConfigs.table.repository"/>
+            <ec:column property="daysOlder" title="purgeConfigs.table.daysOlder"/>
+            <ec:column property="retentionCount" title="purgeConfigs.table.retentionCount"/>
+            <ec:column property="deleteAll" title="purgeConfigs.table.deleteAll"/>
+            <ec:column property="deleteReleasedSnapshots" title="purgeConfigs.table.deleteReleasedSnapshots"/>
+            <ec:column property="schedule.name" title="purgeConfigs.table.schedule"/>
+            <ec:column property="defaultPurge" title="purgeConfigs.table.default"/>
+            <ec:column property="enabled" title="purgeConfigs.table.enabled"/>
+            <ec:column property="description" title="purgeConfigs.table.description"/>
+            <ec:column property="buildAgentUrl" title="purgeConfigs.table.buildAgent"/>
+            <ec:column property="editActions" title="&nbsp;" width="1%">
+                <s:url id="editPurgeConfigUrl" action="editDistributedPurgeConfig">
+                  <s:param name="purgeConfigId"><s:property value="#attr['repoPurge'].id"/></s:param>
+                </s:url>
+                <s:a href="%{editPurgeConfigUrl}"><img src="<s:url value='/images/edit.gif' includeParams="none"/>" alt="<s:text name='edit'/>" title="<s:text name='edit'/>" border="0" /></s:a>
+            </ec:column>
+            <ec:column property="purgeActions" title="&nbsp;" width="1%">
+                <s:url id="purgeUrl" action="doDistributedPurge">
+                  <s:param name="purgeConfigId" value="#attr['repoPurge'].id"/>
+                </s:url>
+                <s:a href="%{purgeUrl}"><img src="<s:url value='/images/purgenow.gif' includeParams="none"/>" alt="<s:text name='purge'/>" title="<s:text name='purge'/>" border="0" /></s:a>
+            </ec:column>
+            <ec:column property="deleteActions" title="&nbsp;" width="1%">
+                <s:set var="tname" value="'repoPurgeToken' + #attr['repoPurge'].id" scope="page"/>
+                <s:token name="%{#attr['tname']}"/>
+                <s:url id="removePurgeConfigUrl" action="removeDistributedPurgeConfig">
+                  <s:param name="purgeConfigId" value="#attr['repoPurge'].id"/>
+                  <s:param name="description" value="#attr['repoPurge'].description"/>
+                  <s:param name="struts.token.name" value="#attr['tname']"/>
+                  <s:param name="%{#attr['tname']}" value="#session['struts.tokens.' + #attr['tname']]"/>
+                </s:url>
+                <s:a href="%{removePurgeConfigUrl}"><img src="<s:url value='/images/delete.gif' includeParams="none"/>" alt="<s:text name='delete'/>" title="<s:text name='delete'/>" border="0"></s:a>
+            </ec:column>
+          </ec:row>
+        </ec:table>
+      </div>
+      <div class="functnbar3">
+        <s:form name="addRepoPurgeConfig" action="editDistributedPurgeConfig" method="post">
+          <s:hidden name="purgeType" value="repository"/>
+          <s:submit value="%{getText('add')}" theme="simple"/>
+        </s:form>
+      </div>
+
+      <div id="h3-2">
         <h3><s:text name="purgeConfigs.dir.section.title"/></h3>
         <s:set name="distributedDirPurgeConfigs" value="distributedDirPurgeConfigs" scope="request"/>
         <ec:table items="distributedDirPurgeConfigs"

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp?rev=1671638&r1=1671637&r2=1671638&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editDistributedPurgeConfiguration.jsp Mon Apr  6 18:58:38 2015
@@ -16,8 +16,6 @@
   ~ specific language governing permissions and limitations
   ~ under the License.
   --%>
-
-<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
 <%@ taglib uri="/struts-tags" prefix="s" %>
 <html>
   <s:i18n name="localization.Continuum">
@@ -31,15 +29,21 @@
 
     <div class="axial">
       <s:form action="saveDistributedPurgeConfig" method="post" validate="true">
-        <c:if test="${!empty actionErrors}">
+        <s:if test="hasActionErrors()">
           <div class="errormessage">
             <s:iterator value="actionErrors">
               <p><s:property/></p>
             </s:iterator>
           </div>
-        </c:if>
+        </s:if>
+        <s:if test="repositories.size() > 0 || purgeType == 'directory'">
           <table>
-            <s:select label="%{getText('purgeConfig.directoryType.label')}" name="directoryType" list="directoryTypes"/>
+            <s:if test="purgeType == 'repository'">
+              <s:select label="%{getText('purgeConfig.repository.label')}" name="repositoryName" list="repositories" requiredLabel="true"/>
+            </s:if>
+            <s:else>
+              <s:select label="%{getText('purgeConfig.directoryType.label')}" name="directoryType" list="directoryTypes"/>
+            </s:else>
             <s:textfield label="%{getText('purgeConfig.daysOlder.label')}" name="daysOlder" size="100"/>
             <s:textfield label="%{getText('purgeConfig.retentionCount.label')}" name="retentionCount" size="100"/>
             <s:checkbox label="%{getText('purgeConfig.deleteAll.label')}" name="deleteAll"/>
@@ -58,6 +62,10 @@
             <s:submit value="%{getText('save')}" theme="simple"/>
             <input type="button" name="Cancel" value="<s:text name='cancel'/>" onclick="history.back();"/>
           </div>
+        </s:if>
+        <s:else>
+          <div class="warningmessage" style="color: red"><s:text name="purgeConfig.no.repositories" /></div>
+        </s:else>
       </s:form>
     </div>
   </div>



Mime
View raw message