continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r679588 [7/8] - in /continuum/branches/CONTINUUM-782: ./ continuum-api/ continuum-api/src/main/java/org/apache/continuum/purge/ continuum-api/src/main/java/org/apache/continuum/purge/controller/ continuum-api/src/main/java/org/apache/contin...
Date Thu, 24 Jul 2008 22:31:26 GMT
Modified: continuum/branches/CONTINUUM-782/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Thu Jul 24 15:31:19 2008
@@ -37,6 +37,10 @@
 import javax.jdo.Query;
 import javax.jdo.Transaction;
 
+import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
+import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -102,6 +106,8 @@
 
     private static final String BUILD_TEMPLATE_BUILD_DEFINITIONS = "build-template-build-definitions";
 
+    private static final String LOCALREPOSITORY_PURGE_CONFIGS = "localrepository-purge-configs";
+    
     // ----------------------------------------------------------------------
     // ContinuumStore Implementation
     // ----------------------------------------------------------------------
@@ -2002,7 +2008,424 @@
             return (SystemConfiguration) systemConfs.get( 0 );
         }
     }
+    
+    public LocalRepository addLocalRepository( LocalRepository repository )
+        throws ContinuumStoreException
+    {
+        return ( LocalRepository ) addObject( repository );
+    }
+    
+    public void updateLocalRepository( LocalRepository repository )
+        throws ContinuumStoreException
+    {
+        updateObject( repository );
+    }
+    
+    public void removeLocalRepository( LocalRepository repository )
+        throws ContinuumStoreException
+    {
+        removeObject( repository );
+    }
+    
+    public List<LocalRepository> getAllLocalRepositories()
+    {
+        return getAllObjectsDetached( LocalRepository.class );
+    }
+    
+    public List<LocalRepository> getLocalRepositoriesByLayout( String layout )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( LocalRepository.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareImports( "import java.lang.String" );
+            
+            query.declareParameters( "String layout" );
+    
+            query.setFilter( "this.layout == layout" );
+    
+            List result = (List) query.execute( layout );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public LocalRepository getLocalRepository( int repositoryId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        return (LocalRepository) getObjectById( LocalRepository.class, repositoryId );
+    }
+    
+    public LocalRepository getLocalRepositoryByName( String name )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        PersistenceManager pm = getPersistenceManager();
+    
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( LocalRepository.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareImports( "import java.lang.String" );
+    
+            query.declareParameters( "String name" );
+    
+            query.setFilter( "this.name == name" );
+    
+            Collection result = (Collection) query.execute( name );
+    
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+    
+                return null;
+            }
+    
+            Object object = pm.detachCopy( result.iterator().next() );
+    
+            tx.commit();
+    
+            return (LocalRepository) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+    
+    public LocalRepository getLocalRepositoryByLocation( String location )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        PersistenceManager pm = getPersistenceManager();
+    
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( LocalRepository.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareImports( "import java.lang.String" );
+    
+            query.declareParameters( "String location" );
+    
+            query.setFilter( "this.location == location" );
+    
+            Collection result = (Collection) query.execute( location );
+    
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+    
+                return null;
+            }
+    
+            Object object = pm.detachCopy( result.iterator().next() );
+    
+            tx.commit();
+    
+            return (LocalRepository) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+    
+    public List<RepositoryPurgeConfiguration> getAllRepositoryPurgeConfigurations()
+    {
+        return getAllObjectsDetached( RepositoryPurgeConfiguration.class );
+    }
+    
+    public List<RepositoryPurgeConfiguration> getRepositoryPurgeConfigurationsBySchedule( int scheduleId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareParameters( "int scheduleId" );
+    
+            query.setFilter( "this.schedule.id == scheduleId" );
+    
+            List result = (List) query.execute( new Integer( scheduleId ) );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public List<RepositoryPurgeConfiguration> getRepositoryPurgeConfigurationsByLocalRepository( int repositoryId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( RepositoryPurgeConfiguration.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareParameters( "int repositoryId" );
+    
+            query.setFilter( "this.repository.id == repositoryId" );
+    
+            List result = (List) query.execute( new Integer( repositoryId ) );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public RepositoryPurgeConfiguration getRepositoryPurgeConfiguration( int configurationId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        return (RepositoryPurgeConfiguration) getObjectById( RepositoryPurgeConfiguration.class, configurationId );
+    }
+    
+    public RepositoryPurgeConfiguration addRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        return (RepositoryPurgeConfiguration) addObject( purgeConfiguration );
+    }
+    
+    public void updateRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        updateObject( purgeConfiguration );
+    }
+    
+    public void removeRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        removeObject( purgeConfiguration );
+    }
+    
+    public List<DirectoryPurgeConfiguration> getAllDirectoryPurgeConfigurations()
+    {
+        return getAllObjectsDetached( DirectoryPurgeConfiguration.class );
+    }
+    
+    public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsBySchedule( int scheduleId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareParameters( "int scheduleId" );
+    
+            query.setFilter( "this.schedule.id == scheduleId" );
+    
+            List result = (List) query.execute( new Integer( scheduleId ) );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByLocation( String location )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareImports( "import java.lang.String" );
+            
+            query.declareParameters( "String location" );
+    
+            query.setFilter( "this.location == location" );
+    
+            List result = (List) query.execute( location );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public List<DirectoryPurgeConfiguration> getDirectoryPurgeConfigurationsByType( String type )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( DirectoryPurgeConfiguration.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareImports( "import java.lang.String" );
+            
+            query.declareParameters( "String type" );
+    
+            query.setFilter( "this.directoryType == type" );
+    
+            List result = (List) query.execute( type );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public DirectoryPurgeConfiguration getDirectoryPurgeConfiguration( int configurationId )
+        throws ContinuumStoreException, ContinuumObjectNotFoundException
+    {
+        return (DirectoryPurgeConfiguration) getObjectById( DirectoryPurgeConfiguration.class, configurationId );
+    }
+    
+    public DirectoryPurgeConfiguration addDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        return (DirectoryPurgeConfiguration) addObject( purgeConfiguration );
+    }
+    
+    public void updateDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        updateObject( purgeConfiguration );
+    }
+    
+    public void removeDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfiguration )
+        throws ContinuumStoreException
+    {
+        removeObject( purgeConfiguration );
+    }
+    
+    public List<BuildDefinition> getBuildDefinitionsBySchedule( int scheduleId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( BuildDefinition.class, true );
+    
+            Query query = pm.newQuery( extent );
+    
+            query.declareParameters( "int scheduleId" );
+    
+            query.setFilter( "this.schedule.id == scheduleId" );
+    
+            List result = (List) query.execute( new Integer( scheduleId ) );
+    
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+    
+            rollback( tx );
+        }
+    }
+    
+    public List<ProjectGroup> getProjectGroupByRepository( int repositoryId )
+    {
+        PersistenceManager pm = getPersistenceManager();
+        
+        Transaction tx = pm.currentTransaction();
+    
+        try
+        {
+            tx.begin();
+    
+            Extent extent = pm.getExtent( ProjectGroup.class, true );
+    
+            Query query = pm.newQuery( extent );
 
+            query.declareParameters( "int repositoryId" );
+    
+            query.setFilter( "this.localRepository.id == repositoryId" );
+    
+            List result = (List) query.execute( new Integer( repositoryId ) );
+            
+            return result == null ? Collections.EMPTY_LIST : (List) pm.detachCopyAll( result );
+        }
+        finally
+        {
+            tx.commit();
+            
+            rollback( tx );
+        }
+    }
+    
     private PersistenceManager getPersistenceManager()
     {
         return getPersistenceManager( getContinuumPersistenceManagerFactory() );
@@ -2040,6 +2463,9 @@
         PlexusJdoUtils.removeAll( getPersistenceManager(), ProjectGroup.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Project.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), BuildDefinition.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), RepositoryPurgeConfiguration.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), LocalRepository.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), DirectoryPurgeConfiguration.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Schedule.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Profile.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Installation.class );

Modified: continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java Thu Jul 24 15:31:19 2008
@@ -19,6 +19,9 @@
  * under the License.
  */
 
+import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
@@ -85,6 +88,20 @@
     protected BuildResult testBuildResult3;
 
     protected ScmResult testCheckoutResult1;
+    
+    protected LocalRepository testLocalRepository1;
+    
+    protected LocalRepository testLocalRepository2;
+    
+    protected LocalRepository testLocalRepository3;
+    
+    protected RepositoryPurgeConfiguration testRepoPurgeConfiguration1;
+    
+    protected RepositoryPurgeConfiguration testRepoPurgeConfiguration2;
+    
+    protected RepositoryPurgeConfiguration testRepoPurgeConfiguration3;
+    
+    protected DirectoryPurgeConfiguration testDirectoryPurgeConfig;
 
     private ProjectNotifier testGroupNotifier1;
 
@@ -130,10 +147,54 @@
         throws Exception
     {
         // Setting up test data
+        testLocalRepository1 = createTestLocalRepository( "name1", "location1", "layout1" );
+        
+        LocalRepository localRepository1 = createTestLocalRepository( testLocalRepository1 );
+        if ( addToStore )
+        {
+            localRepository1 = store.addLocalRepository( localRepository1 );
+            testLocalRepository1.setId( localRepository1.getId() );
+        }
+        else
+        {
+            localRepository1.setId( 1 );
+            testLocalRepository1.setId( 1 );
+        }
+        
+        testLocalRepository2 = createTestLocalRepository( "name2", "location2", "layout2" );
+        
+        LocalRepository localRepository2 = createTestLocalRepository( testLocalRepository2 );
+        if ( addToStore )
+        {
+            localRepository2 = store.addLocalRepository( localRepository2 );
+            testLocalRepository2.setId( localRepository2.getId() );
+        }
+        else
+        {
+            localRepository2.setId( 2 );
+            testLocalRepository2.setId( 2 );
+        }
+        
+        testLocalRepository3 = createTestLocalRepository( "name3", "location3", "layout3" );
+        
+        LocalRepository localRepository3 = createTestLocalRepository( testLocalRepository3 );
+        if ( addToStore )
+        {
+            localRepository3 = store.addLocalRepository( localRepository3 );
+            testLocalRepository3.setId( localRepository3.getId() );
+        }
+        else
+        {
+            localRepository3.setId( 3 );
+            testLocalRepository3.setId( 3 );
+        }
+        
         defaultProjectGroup =
-            createTestProjectGroup( "Default Group", "The Default Group", "org.apache.maven.test.default" );
+            createTestProjectGroup( "Default Group", "The Default Group", "org.apache.maven.test.default",
+                                    localRepository1);
 
-        testProjectGroup2 = createTestProjectGroup( "test group 2", "test group 2 desc", "test group 2 groupId" );
+        testProjectGroup2 = createTestProjectGroup( "test group 2", "test group 2 desc", "test group 2 groupId",
+                                                    localRepository2);
 
         testProject1 = createTestProject( "artifactId1", 1, "description1", defaultProjectGroup.getGroupId(), "name1",
                                           "scmUrl1", 1, "url1", "version1", "workingDirectory1" );
@@ -300,6 +361,46 @@
             profile3.setId( 3 );
         }
 
+        testRepoPurgeConfiguration1 = createTestRepositoryPurgeConfiguration( true, 5, 50, false, schedule2, true, localRepository1 );
+        if ( addToStore )
+        {
+            testRepoPurgeConfiguration1 = store.addRepositoryPurgeConfiguration( testRepoPurgeConfiguration1 );
+        }
+        else
+        {
+            testRepoPurgeConfiguration1.setId( 1 );
+        }
+        
+        testRepoPurgeConfiguration2 = createTestRepositoryPurgeConfiguration( false, 10, 200, true, schedule1, true, localRepository2 );
+        if ( addToStore )
+        {
+            testRepoPurgeConfiguration2 = store.addRepositoryPurgeConfiguration( testRepoPurgeConfiguration2 );
+        }
+        else
+        {
+            testRepoPurgeConfiguration2.setId( 2 );
+        }
+        
+        testRepoPurgeConfiguration3 = createTestRepositoryPurgeConfiguration( false, 10, 200, true, schedule2, true, localRepository1 );
+        if ( addToStore )
+        {
+            testRepoPurgeConfiguration3 = store.addRepositoryPurgeConfiguration( testRepoPurgeConfiguration3 );
+        }
+        else
+        {
+            testRepoPurgeConfiguration3.setId( 3 );
+        }
+        
+        testDirectoryPurgeConfig = createTestDirectoryPurgeConfiguration( "location1", "directoryType1", true, 10, 50, schedule2, true );
+        if ( addToStore )
+        {
+            testDirectoryPurgeConfig = store.addDirectoryPurgeConfiguration( testDirectoryPurgeConfig );
+        }
+        else
+        {
+            testDirectoryPurgeConfig.setId( 1 );
+        }
+        
         BuildDefinition testGroupBuildDefinition1 =
             createTestBuildDefinition( "arguments1", "buildFile1", "goals1", profile1, schedule2, false, false );
         BuildDefinition testGroupBuildDefinition2 =
@@ -840,15 +941,18 @@
 
     protected static ProjectGroup createTestProjectGroup( ProjectGroup group )
     {
-        return createTestProjectGroup( group.getName(), group.getDescription(), group.getGroupId() );
+        return createTestProjectGroup( group.getName(), group.getDescription(), group.getGroupId(), 
+                                       group.getLocalRepository() );
     }
 
-    protected static ProjectGroup createTestProjectGroup( String name, String description, String groupId )
+    protected static ProjectGroup createTestProjectGroup( String name, String description, String groupId, 
+                                                          LocalRepository repository )
     {
         ProjectGroup group = new ProjectGroup();
         group.setName( name );
         group.setDescription( description );
         group.setGroupId( groupId );
+        group.setLocalRepository( repository );
         return group;
     }
 
@@ -1105,6 +1209,98 @@
         return developer;
     }
 
+    protected static LocalRepository createTestLocalRepository( LocalRepository repository )
+    {
+        return createTestLocalRepository( repository.getName(), repository.getLocation(), repository.getLayout() );
+    }
+    
+    protected static LocalRepository createTestLocalRepository( String name, String location, String layout )
+    {
+        LocalRepository repository = new LocalRepository();
+        repository.setName( name );
+        repository.setLocation( location );
+        repository.setLayout( layout );
+        return repository;
+    }
+    
+    protected static RepositoryPurgeConfiguration createTestRepositoryPurgeConfiguration( RepositoryPurgeConfiguration purgeConfig )
+    {
+        return createTestRepositoryPurgeConfiguration( purgeConfig.isDeleteAll(), purgeConfig.getRetentionCount(), purgeConfig.getDaysOlder(),
+                                             purgeConfig.isDeleteReleasedSnapshots(), purgeConfig.getSchedule(), purgeConfig.isEnabled(), purgeConfig.getRepository() );
+    }
+    
+    protected static RepositoryPurgeConfiguration createTestRepositoryPurgeConfiguration( boolean deleteAllArtifacts, int retentionCount, int daysOlder, 
+                                                                      boolean deleteReleasedSnapshots, Schedule schedule, boolean enabled, LocalRepository repository )
+    {
+        RepositoryPurgeConfiguration purgeConfig = new RepositoryPurgeConfiguration();
+        purgeConfig.setDeleteAll( deleteAllArtifacts );
+        purgeConfig.setEnabled( enabled );
+        purgeConfig.setRetentionCount( retentionCount );
+        purgeConfig.setDaysOlder( daysOlder );
+        purgeConfig.setDeleteReleasedSnapshots( deleteReleasedSnapshots );
+        purgeConfig.setSchedule( schedule );
+        purgeConfig.setRepository( repository );
+        return purgeConfig;
+    }
+    
+    protected static DirectoryPurgeConfiguration createTestDirectoryPurgeConfiguration( DirectoryPurgeConfiguration purgeConfig )
+    {
+        return createTestDirectoryPurgeConfiguration( purgeConfig.getLocation(), purgeConfig.getDirectoryType(), purgeConfig.isDeleteAll(), purgeConfig.getRetentionCount(),
+                                                      purgeConfig.getDaysOlder(), purgeConfig.getSchedule(), purgeConfig.isEnabled() );
+    }
+    
+    protected static DirectoryPurgeConfiguration createTestDirectoryPurgeConfiguration( String location, String directoryType, boolean deleteAllDirectories, 
+                                                                                        int retentionCount, int daysOlder, Schedule schedule, boolean enabled )
+    {
+        DirectoryPurgeConfiguration purgeConfig = new DirectoryPurgeConfiguration();
+        purgeConfig.setDaysOlder( daysOlder );
+        purgeConfig.setDeleteAll( deleteAllDirectories );
+        purgeConfig.setDirectoryType( directoryType );
+        purgeConfig.setEnabled( enabled );
+        purgeConfig.setLocation( location );
+        purgeConfig.setRetentionCount( retentionCount );
+        purgeConfig.setSchedule( schedule );
+        return purgeConfig;
+    }
+    
+    protected static void assertLocalRepositoryEquals( LocalRepository expectedRepository, LocalRepository actualRepository )
+    {
+        assertEquals( expectedRepository, actualRepository );
+        if ( expectedRepository != null )
+        {
+            assertNotSame( expectedRepository, actualRepository );
+            assertEquals( "compare local repository - id", expectedRepository.getId(), actualRepository.getId() );
+            assertEquals( "compare local repository - name", expectedRepository.getName(), actualRepository.getName() );
+            assertEquals( "compare local repository - location", expectedRepository.getLocation(), 
+                          actualRepository.getLocation() );
+            assertEquals( "compare local repository - layout", expectedRepository.getLayout(), actualRepository.getLayout() );
+        }
+    }
+    
+    protected static void assertRepositoryPurgeConfigurationEquals( RepositoryPurgeConfiguration expectedConfig, RepositoryPurgeConfiguration actualConfig )
+    {
+        assertEquals( "compare repository purge configuration - id", expectedConfig.getId(), actualConfig.getId() );
+        assertEquals( "compare repository purge configuration - deleteAll", expectedConfig.isDeleteAll(), actualConfig.isDeleteAll() );
+        assertEquals( "compare repository purge configuration - retentionCount", expectedConfig.getRetentionCount(), 
+                      actualConfig.getRetentionCount() );
+        assertEquals( "compare repository purge configuration - daysOlder", expectedConfig.getDaysOlder(), actualConfig.getDaysOlder() );
+        assertEquals( "compare repository purge configuration - deleteReleasedSnapshots", expectedConfig.isDeleteReleasedSnapshots(), 
+                      actualConfig.isDeleteReleasedSnapshots() );
+        assertEquals( "compare repository purge configuration - enabled", expectedConfig.isEnabled(), actualConfig.isEnabled() );
+    }
+    
+    protected static void assertDirectoryPurgeConfigurationEquals( DirectoryPurgeConfiguration expectedConfig, DirectoryPurgeConfiguration actualConfig )
+    {
+        assertEquals( "compare directory purge configuration - id", expectedConfig.getId(), actualConfig.getId() );
+        assertEquals( "compare directory purge configuration - location", expectedConfig.getLocation(), actualConfig.getLocation() );
+        assertEquals( "compare directory purge configuration - directoryType", expectedConfig.getDirectoryType(), actualConfig.getDirectoryType() );
+        assertEquals( "compare directory purge configuration - deleteAll", expectedConfig.isDeleteAll(), actualConfig.isDeleteAll() );
+        assertEquals( "compare directory purge configuration - retentionCount", expectedConfig.getRetentionCount(), 
+                      actualConfig.getRetentionCount() );
+        assertEquals( "compare directory purge configuration - daysOlder", expectedConfig.getDaysOlder(), actualConfig.getDaysOlder() );
+        assertEquals( "compare directory purge configuration - enabled", expectedConfig.isEnabled(), actualConfig.isEnabled() );
+    }
+    
     /**
      * Setup JDO Factory
      *

Modified: continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java Thu Jul 24 15:31:19 2008
@@ -24,9 +24,13 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import javax.jdo.JDODetachedFieldAccessException;
 
+import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -69,7 +73,8 @@
         String name = "testAddProjectGroup";
         String description = "testAddProjectGroup description";
         String groupId = "org.apache.maven.continuum.test";
-        ProjectGroup group = createTestProjectGroup( name, description, groupId );
+        LocalRepository repository = store.getLocalRepository( testLocalRepository3.getId() );
+        ProjectGroup group = createTestProjectGroup( name, description, groupId, repository );
 
         ProjectGroup copy = createTestProjectGroup( group );
         store.addProjectGroup( group );
@@ -77,6 +82,7 @@
 
         ProjectGroup retrievedGroup = store.getProjectGroup( group.getId() );
         assertProjectGroupEquals( copy, retrievedGroup );
+        assertLocalRepositoryEquals( testLocalRepository3, retrievedGroup.getLocalRepository() );
     }
 
     public void testGetProjectGroup()
@@ -84,6 +90,7 @@
     {
         ProjectGroup retrievedGroup = store.getProjectGroupWithProjects( defaultProjectGroup.getId() );
         assertProjectGroupEquals( defaultProjectGroup, retrievedGroup );
+        assertLocalRepositoryEquals( testLocalRepository1, retrievedGroup.getLocalRepository() );
 
         List projects = retrievedGroup.getProjects();
         assertEquals( "Check number of projects", 2, projects.size() );
@@ -134,7 +141,7 @@
 
         ProjectGroup retrievedGroup = store.getProjectGroup( testProjectGroup2.getId() );
         assertProjectGroupEquals( copy, retrievedGroup );
-
+        assertLocalRepositoryEquals( testLocalRepository2, retrievedGroup.getLocalRepository() );
     }
 
     public void testUpdateUndetachedGroup()
@@ -172,11 +179,13 @@
             if ( group.getId() == testProjectGroup2.getId() )
             {
                 assertProjectGroupEquals( testProjectGroup2, group );
+                assertLocalRepositoryEquals( testLocalRepository2, group.getLocalRepository() );
                 assertTrue( "check no projects", projects.isEmpty() );
             }
             else if ( group.getId() == defaultProjectGroup.getId() )
             {
                 assertProjectGroupEquals( defaultProjectGroup, group );
+                assertLocalRepositoryEquals( testLocalRepository1, group.getLocalRepository() );
                 assertEquals( "Check number of projects", 2, projects.size() );
                 assertTrue( "Check existence of project 1", projects.contains( testProject1 ) );
                 assertTrue( "Check existence of project 2", projects.contains( testProject2 ) );
@@ -1096,6 +1105,132 @@
         assertEquals( 1, store.getAllBuildDefinitionTemplate().size() );
     }
     
+    public void testAddLocalRepository()
+        throws Exception
+    {
+        String name = "testAddLocalRepository";
+        String directory = "testAddLocalRepositoryDirectory";
+        String layout = "default";
+        
+        LocalRepository repository = createTestLocalRepository( name, directory, layout );
+    
+        LocalRepository copy = createTestLocalRepository( repository );
+        store.addLocalRepository( repository );
+        copy.setId( repository.getId() );
+    
+        LocalRepository retrievedRepository = store.getLocalRepository( repository.getId() );
+        assertLocalRepositoryEquals( copy, retrievedRepository );
+    }
+    
+    public void testRemoveLocalRepository()
+        throws Exception
+    {
+        LocalRepository repository = store.getLocalRepositoryByName( testLocalRepository2.getName() );
+
+        ProjectGroup projectGroup = store.getProjectGroupByGroupId( testProjectGroup2.getGroupId() );
+        assertLocalRepositoryEquals( testLocalRepository2, projectGroup.getLocalRepository() );
+        projectGroup.setLocalRepository( null );
+    
+        ProjectGroup copy = createTestProjectGroup( projectGroup );
+        store.updateProjectGroup( projectGroup );
+    
+        projectGroup = store.getProjectGroup( testProjectGroup2.getId() );
+        assertNull( "check local repository" , projectGroup.getLocalRepository() );
+        
+        List<RepositoryPurgeConfiguration> repoPurgeList = 
+            store.getRepositoryPurgeConfigurationsByLocalRepository( repository.getId() );
+        
+        assertEquals( "check # repo purge config", 1, repoPurgeList.size() );
+        store.removeRepositoryPurgeConfiguration( repoPurgeList.get( 0 ) );
+        store.removeLocalRepository( repository );
+    
+        List<LocalRepository> localRepositories = store.getAllLocalRepositories();
+        assertEquals( "check # local repositories", 2, localRepositories.size() );
+        assertFalse( "check not there", localRepositories.contains( repository ) );
+    }
+    
+    public void testGetAllLocalRepositories()
+        throws Exception
+    {
+        List<LocalRepository> localRepositories = store.getAllLocalRepositories();
+    
+        assertEquals( "check # local repositories", 3, localRepositories.size() );
+        assertLocalRepositoryEquals( testLocalRepository1, localRepositories.get( 0 ) );
+        assertLocalRepositoryEquals( testLocalRepository2, localRepositories.get( 1 ) );
+        assertLocalRepositoryEquals( testLocalRepository3, localRepositories.get( 2 ) );
+    }
+    
+    public void testAddRepositoryPurgeConfiguration()
+        throws Exception
+    {
+        LocalRepository repository = store.getLocalRepository( testLocalRepository3.getId() );
+        Schedule schedule = store.getSchedule( testSchedule1.getId() );
+        
+        RepositoryPurgeConfiguration repoPurge = createTestRepositoryPurgeConfiguration( true, 2, 100, false, schedule, true, repository );
+        
+        RepositoryPurgeConfiguration copy = createTestRepositoryPurgeConfiguration( repoPurge );
+        store.addRepositoryPurgeConfiguration( repoPurge );
+        copy.setId( repoPurge.getId() );
+        
+        RepositoryPurgeConfiguration retrieved = store.getRepositoryPurgeConfiguration( repoPurge.getId() );
+        assertRepositoryPurgeConfigurationEquals( copy, retrieved );
+        assertLocalRepositoryEquals( testLocalRepository3, retrieved.getRepository() );
+        assertScheduleEquals( testSchedule1, retrieved.getSchedule() );
+    }
+    
+    public void testRemoveRepositoryPurgeConfiguration()
+        throws Exception
+    {
+        RepositoryPurgeConfiguration repoPurge = store.getRepositoryPurgeConfiguration( testRepoPurgeConfiguration2.getId() );
+        store.removeRepositoryPurgeConfiguration( repoPurge );
+        
+        List<RepositoryPurgeConfiguration> repoPurgeList = store.getAllRepositoryPurgeConfigurations();
+        assertEquals( "check # repo purge configurations", 2, repoPurgeList.size() );
+        assertFalse( "check not there", repoPurgeList.contains( repoPurge ) );
+    }
+    
+    public void testAddDirectoryPurgeConfiguration()
+        throws Exception
+    {
+        String location = "release-directory";
+        String directoryType = "release";
+        
+        Schedule schedule = store.getSchedule( testSchedule1.getId() );
+        DirectoryPurgeConfiguration dirPurge = createTestDirectoryPurgeConfiguration( location, directoryType, false, 2, 100, schedule, true );
+        
+        DirectoryPurgeConfiguration copy = createTestDirectoryPurgeConfiguration( dirPurge );
+        store.addDirectoryPurgeConfiguration( dirPurge );
+        copy.setId( dirPurge.getId() );
+        
+        DirectoryPurgeConfiguration retrieved = store.getDirectoryPurgeConfiguration( dirPurge.getId() );
+        assertDirectoryPurgeConfigurationEquals( copy, retrieved );
+        assertScheduleEquals( testSchedule1, retrieved.getSchedule() );
+    }
+    
+    public void testRemoveDirectoryPurgeConfiguration()
+        throws Exception
+    {
+        DirectoryPurgeConfiguration dirPurge = store.getDirectoryPurgeConfiguration( testDirectoryPurgeConfig.getId() );
+        store.removeDirectoryPurgeConfiguration( dirPurge );
+        
+        List<DirectoryPurgeConfiguration> dirPurgeList = store.getAllDirectoryPurgeConfigurations();
+        assertEquals( "check #  dir purge configurations", 0, dirPurgeList.size() );
+    }
+    
+    public void testGetPurgeConfigurationsBySchedule()
+        throws Exception
+    {
+        List<RepositoryPurgeConfiguration> repoPurgeList = store.getRepositoryPurgeConfigurationsBySchedule( testSchedule2.getId() );
+        List<DirectoryPurgeConfiguration> dirPurgeList = store.getDirectoryPurgeConfigurationsBySchedule( testSchedule2.getId() );
+        
+        assertEquals( "check # repo purge configurations", 2, repoPurgeList.size() );
+        assertEquals( "check # dir purge configurations", 1, dirPurgeList.size() );
+        
+        assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration1, repoPurgeList.get( 0 ) );
+        assertRepositoryPurgeConfigurationEquals( testRepoPurgeConfiguration3, repoPurgeList.get( 1 ) );
+        assertDirectoryPurgeConfigurationEquals( testDirectoryPurgeConfig, dirPurgeList.get( 0 ) );
+    }
+    
     // ----------------------------------------------------------------------
     //  HELPER METHODS
     // ----------------------------------------------------------------------

Added: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java?rev=679588&view=auto
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java (added)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java Thu Jul 24 15:31:19 2008
@@ -0,0 +1,353 @@
+package org.apache.continuum.web.action.admin;
+
+/*
+ * 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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
+import org.apache.continuum.purge.ContinuumPurgeManager;
+import org.apache.continuum.purge.PurgeConfigurationService;
+import org.apache.continuum.repository.RepositoryService;
+import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.security.ContinuumRoleConstants;
+import org.apache.maven.continuum.web.action.ContinuumConfirmAction;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Preparable;
+
+/**
+ * @author Maria Catherine Tan
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="localRepository"
+ */
+public class LocalRepositoryAction
+    extends ContinuumConfirmAction
+    implements Preparable, SecureAction
+{
+    private static final String LAYOUT_DEFAULT = "default";
+    
+    private static final String LAYOUT_LEGACY = "legacy";
+    
+    private boolean confirmed;
+
+    private boolean defaultRepo;
+    
+    private LocalRepository repository;
+    
+    private List<LocalRepository> repositories;
+    
+    private List<ProjectGroup> groups;
+    
+    private List<String> layouts;
+    
+    private Map<String, Boolean> defaultPurgeMap;
+    
+    private String message;
+    
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryService repositoryService;
+    
+    /**
+     * @plexus.requirement
+     */
+    private PurgeConfigurationService purgeConfigService;
+    
+    public void prepare()
+        throws Exception
+    {
+        super.prepare();
+        
+        layouts = new ArrayList<String>();
+        layouts.add( LAYOUT_DEFAULT );
+        layouts.add( LAYOUT_LEGACY );
+    }
+    
+    public String input()
+        throws Exception
+    {
+        defaultRepo = false;
+        
+        if ( repository != null && repository.getId() > 0 )
+        {
+            repository = repositoryService.getLocalRepository( repository.getId() );
+            
+            if ( repository.getName().equals( "DEFAULT" ) )
+            {
+                defaultRepo = true;
+            }
+        }
+        
+        return INPUT;
+    }
+    
+    public String list()
+        throws Exception
+    {
+        String errorMessage = ServletActionContext.getRequest().getParameter( "errorMessage" );
+        
+        if ( errorMessage != null )
+        {
+            addActionError( errorMessage );
+        }
+        
+        repositories = repositoryService.getAllLocalRepositories();
+        
+        defaultPurgeMap = new HashMap<String, Boolean>();
+        
+        for ( LocalRepository repo : repositories )
+        {
+            // get default purge config of repository
+            RepositoryPurgeConfiguration purgeConfig = purgeConfigService.getDefaultPurgeConfigurationForRepository( repo.getId() );
+            
+            if ( purgeConfig == null )
+            {
+                defaultPurgeMap.put(  repo.getName(), Boolean.FALSE );
+            }
+            else
+            {
+                defaultPurgeMap.put(  repo.getName(), Boolean.TRUE );
+            }
+        }
+        
+        return SUCCESS;
+    }
+    
+    public String save()
+        throws Exception
+    {
+        List<LocalRepository> allRepositories = repositoryService.getAllLocalRepositories();
+        
+        for( LocalRepository repo : allRepositories )
+        {
+            if ( repository.getId() != repo.getId() )
+            {
+                if ( repository.getName().equals( repo.getName() ) )
+                {
+                    addActionError( "repository.error.name.unique" );
+                }
+                
+                if ( repository.getLocation().equals( repo.getLocation() ) )
+                {
+                    addActionError( "repository.error.location.unique" );
+                }
+            }
+        }
+        
+        if ( repository.getName().trim().equals( "" ) )
+        {
+            addActionError( "repository.error.name.cannot.be.spaces" );
+        }
+        
+        if ( repository.getLocation().trim().equals( "" ) )
+        {
+            addActionError( "repository.error.location.cannot.be.spaces" );
+        }
+        
+        if ( hasActionErrors() )
+        {
+            return INPUT;
+        }
+        
+        if ( repository.getId() == 0 )
+        {
+            repository = repositoryService.addLocalRepository( repository );
+            
+            createDefaultPurgeConfiguration();
+        }
+        else
+        {
+            // check if repository is in use
+            ContinuumPurgeManager purgeManager = getContinuum().getPurgeManager();
+            if ( purgeManager.isRepositoryInUse( repository.getId() ) )
+            {
+                addActionError( "repository.error.save.in.use" );
+                return ERROR;
+            }
+            
+            LocalRepository retrievedRepo = repositoryService.getLocalRepository( repository.getId() );
+            
+            retrievedRepo.setName( repository.getName() );
+            retrievedRepo.setLocation( repository.getLocation() );
+            retrievedRepo.setLayout( repository.getLayout() );
+            
+            repositoryService.updateLocalRepository( retrievedRepo );
+        }
+        
+        return SUCCESS;
+    }
+    
+    public String remove()
+        throws Exception
+    {
+        ContinuumPurgeManager purgeManager = getContinuum().getPurgeManager();
+        if ( purgeManager.isRepositoryInUse( repository.getId() ) )
+        {
+            message = "repository.error.remove.in.use";
+            return ERROR;
+        }
+        
+        repository = repositoryService.getLocalRepository( repository.getId() );
+        
+        if ( repository.getName().equals( "DEFAULT" ) )
+        {
+            message = "repository.error.remove.default";
+            return ERROR;
+        }
+        
+        if ( confirmed )
+        {
+            repositoryService.removeLocalRepository( repository.getId() );
+        }
+        else
+        {
+            return CONFIRM;
+        }
+        
+        return SUCCESS;
+    }
+    
+    public String doPurge()
+        throws Exception
+    {
+        ContinuumPurgeManager purgeManager = getContinuum().getPurgeManager();
+    
+        // check if repository is in use
+        if ( purgeManager.isRepositoryInUse( repository.getId() ) )
+        {
+            message = "repository.error.purge.in.use";
+            return ERROR;
+        }
+        
+        // get default purge configuration for repository
+        RepositoryPurgeConfiguration purgeConfig = purgeConfigService.getDefaultPurgeConfigurationForRepository( repository.getId() );
+        
+        if ( purgeConfig != null )
+        {
+            purgeManager.purgeRepository( purgeConfig );
+        }
+        
+        return SUCCESS;
+    }
+    
+    public LocalRepository getRepository()
+    {
+        return this.repository;
+    }
+    
+    public void setRepository( LocalRepository repository )
+    {
+        this.repository = repository;
+    }
+    
+    public List<LocalRepository> getRepositories()
+    {
+        return this.repositories;
+    }
+    
+    public void setRepositories( List<LocalRepository> repositories )
+    {
+        this.repositories = repositories;
+    }
+    
+    public List<ProjectGroup> getGroups()
+    {
+        return this.groups;
+    }
+    
+    public void setGroups( List<ProjectGroup> groups )
+    {
+        this.groups = groups;
+    }
+    
+    public boolean isConfirmed()
+    {
+        return this.confirmed;
+    }
+    
+    public void setConfirmed( boolean confirmed )
+    {
+        this.confirmed = confirmed;
+    }
+    
+    public boolean isDefaultRepo()
+    {
+        return this.defaultRepo;
+    }
+    
+    public void setDefaultRepo( boolean defaultRepo )
+    {
+        this.defaultRepo = defaultRepo;
+    }
+    
+    public List<String> getLayouts()
+    {
+        return this.layouts;
+    }
+    
+    public Map<String, Boolean> getDefaultPurgeMap()
+    {
+        return this.defaultPurgeMap;
+    }
+    
+    public void setDefaultPurgeMap( Map<String, Boolean> defaultPurgeMap )
+    {
+        this.defaultPurgeMap = defaultPurgeMap;
+    }
+    
+    public String getMessage()
+    {
+        return this.message;
+    }
+    
+    public void setMessage( String message )
+    {
+        this.message = message;
+    }
+    
+    private void createDefaultPurgeConfiguration()
+        throws Exception
+    {
+        RepositoryPurgeConfiguration repoPurge = new RepositoryPurgeConfiguration();
+        
+        repoPurge.setRepository( repository );
+        repoPurge.setDefaultPurge( true );
+        
+        purgeConfigService.addRepositoryPurgeConfiguration( repoPurge );
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_MANAGE_REPOSITORIES, Resource.GLOBAL );
+
+        return bundle;
+    }
+}

Propchange: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/LocalRepositoryAction.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Revision Id

Added: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java?rev=679588&view=auto
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java (added)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java Thu Jul 24 15:31:19 2008
@@ -0,0 +1,612 @@
+package org.apache.continuum.web.action.admin;
+
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
+import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
+import org.apache.continuum.purge.ContinuumPurgeManager;
+import org.apache.continuum.purge.PurgeConfigurationService;
+import org.apache.continuum.repository.RepositoryService;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.security.ContinuumRoleConstants;
+import org.apache.maven.continuum.web.action.ContinuumConfirmAction;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureAction;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
+import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Preparable;
+
+/**
+ * @author Maria Catherine Tan
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="purgeConfiguration"
+ *
+ */
+public class PurgeConfigurationAction
+    extends ContinuumConfirmAction
+    implements Preparable, SecureAction
+{
+    private static final String PURGE_TYPE_REPOSITORY = "repository";
+    
+    private static final String PURGE_TYPE_DIRECTORY = "directory";
+    
+    private static final String PURGE_DIRECTORY_RELEASES = "releases";
+    
+    private static final String PURGE_DIRECTORY_BUILDOUTPUT = "buildOutput";
+    
+    private static final int DEFAULT_RETENTION_COUNT = 2;
+    
+    private static final int DEFAULT_DAYS_OLDER = 100;
+    
+    private String purgeType;
+    
+    private String directoryType;
+    
+    private String description;
+    
+    private String message;
+    
+    private boolean deleteAll;
+    
+    private boolean deleteReleasedSnapshots;
+    
+    private boolean enabled;
+    
+    private boolean confirmed;
+    
+    private boolean defaultPurgeConfiguration;
+    
+    private int retentionCount;
+    
+    private int daysOlder;
+    
+    private int repositoryId;
+    
+    private int scheduleId;
+    
+    private int purgeConfigId;
+    
+    private AbstractPurgeConfiguration purgeConfig;
+    
+    private Map<Integer, String> repositories;
+    
+    private Map<Integer, String> schedules;
+    
+    private List<RepositoryPurgeConfiguration> repoPurgeConfigs;
+    
+    private List<DirectoryPurgeConfiguration> dirPurgeConfigs;
+    
+    private List<String> directoryTypes;
+    
+    /**
+     * @plexus.requirement
+     */
+    private PurgeConfigurationService purgeConfigService;
+    
+    /**
+     * @plexus.requirement
+     */
+    private RepositoryService repositoryService;
+    
+    public void prepare()
+        throws Exception
+    {
+        super.prepare();
+        
+        // build schedules
+        if ( schedules == null )
+        {
+            schedules = new HashMap<Integer, String>();
+
+            Collection<Schedule> allSchedules = getContinuum().getSchedules();
+
+            for ( Schedule schedule : allSchedules )
+            {
+                schedules.put( new Integer( schedule.getId() ), schedule.getName() );
+            }
+        }
+        
+        // build repositories
+        if ( repositories == null )
+        {
+            repositories = new HashMap<Integer, String>();
+            
+            List<LocalRepository> allRepositories = repositoryService.getAllLocalRepositories();
+            
+            for ( LocalRepository repository : allRepositories )
+            {
+                repositories.put( new Integer( repository.getId() ), repository.getName() );
+            }
+        }
+        
+        directoryTypes = new ArrayList<String>();
+        directoryTypes.add( PURGE_DIRECTORY_RELEASES );
+        directoryTypes.add( PURGE_DIRECTORY_BUILDOUTPUT );
+    }
+    
+    public String input()
+        throws Exception
+    {
+        if ( purgeConfigId != 0 )
+        {
+            purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
+            
+            if ( purgeConfig instanceof RepositoryPurgeConfiguration )
+            {
+                RepositoryPurgeConfiguration repoPurge = (RepositoryPurgeConfiguration) purgeConfig;
+                
+                this.purgeType = PURGE_TYPE_REPOSITORY;
+                this.daysOlder = repoPurge.getDaysOlder();
+                this.retentionCount = repoPurge.getRetentionCount();
+                this.deleteAll = repoPurge.isDeleteAll();
+                this.deleteReleasedSnapshots = repoPurge.isDeleteReleasedSnapshots();
+                this.enabled = repoPurge.isEnabled();
+                this.defaultPurgeConfiguration = repoPurge.isDefaultPurge();
+                this.description = repoPurge.getDescription();
+                
+                if ( repoPurge.getRepository() != null )
+                {
+                    this.repositoryId = repoPurge.getRepository().getId();
+                }
+                
+                if ( repoPurge.getSchedule() != null )
+                {
+                    this.scheduleId = repoPurge.getSchedule().getId();
+                }
+            }
+            else if ( purgeConfig instanceof DirectoryPurgeConfiguration )
+            {
+                DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) 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();
+                
+                if ( dirPurge.getSchedule() != null )
+                {
+                    this.scheduleId = dirPurge.getSchedule().getId();
+                }
+            }
+        }
+        else
+        {
+            this.retentionCount = DEFAULT_RETENTION_COUNT;
+            this.daysOlder = DEFAULT_DAYS_OLDER;
+        }
+        
+        return INPUT;
+    }
+    
+    public String list()
+        throws Exception
+    {
+        String errorMessage = ServletActionContext.getRequest().getParameter( "errorMessage" );
+        
+        if ( errorMessage != null )
+        {
+            addActionError( errorMessage );
+        }
+        
+        repoPurgeConfigs = purgeConfigService.getAllRepositoryPurgeConfigurations();
+        dirPurgeConfigs = purgeConfigService.getAllDirectoryPurgeConfigurations();
+        
+        return SUCCESS;
+    }
+    
+    public String save()
+        throws Exception
+    {
+        if ( purgeConfigId == 0 )
+        {
+            if ( purgeType.equals( PURGE_TYPE_REPOSITORY ) )
+            {
+                purgeConfig = new RepositoryPurgeConfiguration();
+            }
+            else
+            {
+                purgeConfig = new DirectoryPurgeConfiguration();
+            }
+            
+            purgeConfig = setupPurgeConfiguration( purgeConfig );
+            
+            purgeConfig = purgeConfigService.addPurgeConfiguration( purgeConfig );
+        }
+        else
+        {
+            purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
+            purgeConfig = setupPurgeConfiguration( purgeConfig );
+            
+            purgeConfigService.updatePurgeConfiguration( purgeConfig );
+        }
+        
+        if ( purgeConfig.isDefaultPurge() )
+        {
+            updateDefaultPurgeConfiguration();
+        }
+        
+        return SUCCESS;
+    }
+    
+    public String remove()
+        throws Exception
+    {
+        purgeConfigService.removePurgeConfiguration( purgeConfigId );
+        
+        return SUCCESS;
+    }
+    
+    public String purge()
+        throws Exception
+    {
+        ContinuumPurgeManager purgeManager = getContinuum().getPurgeManager();
+        
+        if ( purgeConfigId > 0 )
+        {
+            purgeConfig = purgeConfigService.getPurgeConfiguration( purgeConfigId );
+            
+            if ( purgeConfig instanceof RepositoryPurgeConfiguration )
+            {
+                RepositoryPurgeConfiguration repoPurge = (RepositoryPurgeConfiguration) purgeConfig;
+                
+                // check if repository is in use
+                if ( purgeManager.isRepositoryInUse( repoPurge.getRepository().getId() ) )
+                {
+                    message = "repository.error.purge.in.use";
+                    return ERROR;
+                }
+                
+                purgeManager.purgeRepository( repoPurge );
+            }
+            else
+            {
+                DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) purgeConfig;
+                purgeManager.purgeDirectory( dirPurge );
+            }
+        }
+        
+        return SUCCESS;
+    }
+    
+    public String getPurgeType()
+    {
+        return this.purgeType;
+    }
+    
+    public void setPurgeType( String purgeType )
+    {
+        this.purgeType = purgeType;
+    }
+    
+    public String getDirectoryType()
+    {
+        return this.directoryType;
+    }
+    
+    public void setDirectoryType( String directoryType )
+    {
+        this.directoryType = directoryType;
+    }
+    
+    public String getDescription()
+    {
+        return this.description;
+    }
+    
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+    
+    public String getMessage()
+    {
+        return this.message;
+    }
+    
+    public void setMessage( String message )
+    {
+        this.message = message;
+    }
+    
+    public boolean isDeleteAll()
+    {
+        return this.deleteAll;
+    }
+    
+    public void setDeleteAll( boolean deleteAll )
+    {
+        this.deleteAll = deleteAll;
+    }
+    
+    public boolean isDeleteReleasedSnapshots()
+    {
+        return this.deleteReleasedSnapshots;
+    }
+    
+    public void setDeleteReleasedSnapshots( boolean deleteReleasedSnapshots )
+    {
+        this.deleteReleasedSnapshots = deleteReleasedSnapshots;
+    }
+    
+    public boolean isEnabled()
+    {
+        return this.enabled;
+    }
+    
+    public void setEnabled( boolean enabled )
+    {
+        this.enabled = enabled;
+    }
+    
+    public boolean isConfirmed()
+    {
+        return this.confirmed;
+    }
+    
+    public void setConfirmed( boolean confirmed )
+    {
+        this.confirmed = confirmed;
+    }
+    
+    public boolean isDefaultPurgeConfiguration()
+    {
+        return this.defaultPurgeConfiguration;
+    }
+    
+    public void setDefaultPurgeConfiguration( boolean defaultPurgeConfiguration )
+    {
+        this.defaultPurgeConfiguration = defaultPurgeConfiguration;
+    }
+    
+    public int getRetentionCount()
+    {
+        return this.retentionCount;
+    }
+    
+    public void setRetentionCount( int retentionCount )
+    {
+        this.retentionCount = retentionCount;
+    }
+    
+    public int getDaysOlder()
+    {
+        return this.daysOlder;
+    }
+    
+    public void setDaysOlder( int daysOlder )
+    {
+        this.daysOlder = daysOlder;
+    }
+    
+    public int getRepositoryId()
+    {
+        return this.repositoryId;
+    }
+    
+    public void setRepositoryId( int repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+    
+    public int getScheduleId()
+    {
+        return this.scheduleId;
+    }
+    
+    public void setScheduleId( int scheduleId )
+    {
+        this.scheduleId = scheduleId;
+    }
+    
+    public int getPurgeConfigId()
+    {
+        return purgeConfigId;
+    }
+    
+    public void setPurgeConfigId( int purgeConfigId )
+    {
+        this.purgeConfigId = purgeConfigId;
+    }
+    
+    public AbstractPurgeConfiguration getPurgeConfig()
+    {
+        return this.purgeConfig;
+    }
+    
+    public void setPurgeConfig( AbstractPurgeConfiguration purgeConfig )
+    {
+        this.purgeConfig = purgeConfig;
+    }
+    
+    public Map<Integer, String> getRepositories()
+    {
+        return this.repositories;
+    }
+    
+    public void setRepositories( Map<Integer, String> repositories )
+    {
+        this.repositories = repositories;
+    }
+    
+    public Map<Integer, String> getSchedules()
+    {
+        return this.schedules;
+    }
+    
+    public void setSchedules( Map<Integer, String> schedules )
+    {
+        this.schedules = schedules;
+    }
+    
+    public List<RepositoryPurgeConfiguration> getRepoPurgeConfigs()
+    {
+        return this.repoPurgeConfigs;
+    }
+    
+    public void setRepoPurgeConfigs( List<RepositoryPurgeConfiguration> repoPurgeConfigs )
+    {
+        this.repoPurgeConfigs = repoPurgeConfigs;
+    }
+    
+    public List<DirectoryPurgeConfiguration> getDirPurgeConfigs()
+    {
+        return this.dirPurgeConfigs;
+    }
+    
+    public void setDirPurgeConfigs( List<DirectoryPurgeConfiguration> dirPurgeConfigs )
+    {
+        this.dirPurgeConfigs = dirPurgeConfigs;
+    }
+    
+    public List<String> getDirectoryTypes()
+    {
+        return this.directoryTypes;
+    }
+    
+    public void setDirectoryTypes( List<String> directoryTypes )
+    {
+        this.directoryTypes = directoryTypes;
+    }
+    
+    private AbstractPurgeConfiguration setupPurgeConfiguration( AbstractPurgeConfiguration purgeConfiguration )
+        throws Exception
+    {
+        if ( purgeConfiguration instanceof RepositoryPurgeConfiguration )
+        {
+            return buildRepoPurgeConfiguration();
+        }
+        else
+        {
+            return buildDirPurgeConfiguration();
+        }
+    }
+    
+    private RepositoryPurgeConfiguration buildRepoPurgeConfiguration()
+        throws Exception
+    {
+        RepositoryPurgeConfiguration repoPurge = (RepositoryPurgeConfiguration) purgeConfig;
+        repoPurge.setDeleteAll( this.deleteAll );
+        repoPurge.setDeleteReleasedSnapshots( this.deleteReleasedSnapshots );
+        repoPurge.setDaysOlder( this.daysOlder );
+        repoPurge.setRetentionCount( this.retentionCount );
+        repoPurge.setEnabled( this.enabled );
+        repoPurge.setDefaultPurge( this.defaultPurgeConfiguration );
+        repoPurge.setDescription( this.description );
+        repoPurge.setDefaultPurge( this.defaultPurgeConfiguration );
+        
+        if ( repositoryId != 0 )
+        {
+            LocalRepository repository = repositoryService.getLocalRepository( repositoryId );
+            repoPurge.setRepository( repository );
+        }
+        
+        if ( scheduleId > 0 )
+        {
+            Schedule schedule = getContinuum().getSchedule( scheduleId );
+            repoPurge.setSchedule( schedule );
+        }
+        
+        return repoPurge;
+    }
+    
+    private DirectoryPurgeConfiguration buildDirPurgeConfiguration()
+        throws Exception
+    {
+        DirectoryPurgeConfiguration dirPurge = (DirectoryPurgeConfiguration) purgeConfig;
+        dirPurge.setDeleteAll( this.deleteAll );
+        dirPurge.setEnabled( this.enabled );
+        dirPurge.setDaysOlder( this.daysOlder );
+        dirPurge.setRetentionCount( this.retentionCount );
+        dirPurge.setDescription( this.description );
+        dirPurge.setDirectoryType( this.directoryType );
+        dirPurge.setDefaultPurge( this.defaultPurgeConfiguration );
+        
+        if ( scheduleId > 0 )
+        {
+            Schedule schedule = getContinuum().getSchedule( scheduleId );
+            dirPurge.setSchedule( schedule );
+        }
+        
+        ConfigurationService configService = getContinuum().getConfiguration();
+        String path = null;
+        
+        if ( this.directoryType.equals( PURGE_DIRECTORY_RELEASES ) )
+        {
+            path = configService.getWorkingDirectory().getAbsolutePath();
+        }
+        else if ( this.directoryType.equals( PURGE_DIRECTORY_BUILDOUTPUT ) )
+        {
+            path = configService.getBuildOutputDirectory().getAbsolutePath();
+        }
+        
+        dirPurge.setLocation( path );
+        
+        return dirPurge;
+    }
+    
+    private void updateDefaultPurgeConfiguration()
+        throws Exception
+    {
+        if ( purgeConfig instanceof RepositoryPurgeConfiguration )
+        {
+            RepositoryPurgeConfiguration repoPurge = purgeConfigService.getDefaultPurgeConfigurationForRepository( repositoryId );
+            
+            if ( repoPurge != null && repoPurge.getId() != purgeConfig.getId() )
+            {
+                repoPurge.setDefaultPurge( false );
+                purgeConfigService.updateRepositoryPurgeConfiguration( repoPurge );
+            }
+        }
+        else if ( purgeConfig instanceof DirectoryPurgeConfiguration )
+        {
+            DirectoryPurgeConfiguration dirPurge = purgeConfigService.getDefaultPurgeConfigurationForDirectoryType( directoryType );
+            
+            if ( dirPurge != null && dirPurge.getId() != purgeConfig.getId() )
+            {
+                dirPurge.setDefaultPurge( false );
+                purgeConfigService.updateDirectoryPurgeConfiguration( dirPurge );
+            }
+        }
+    }
+    
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_MANAGE_PURGING, Resource.GLOBAL );
+
+        return bundle;
+    }
+}

Propchange: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/PurgeConfigurationAction.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Revision Id

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java Thu Jul 24 15:31:19 2008
@@ -75,6 +75,9 @@
 
         TaskQueueExecutor rollbackRelease = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
             .buildSpringId( TaskQueueExecutor.class, "rollback-release" ) );        
+        
+        TaskQueueExecutor purge = (TaskQueueExecutor) wac.getBean( PlexusToSpringUtils
+            .buildSpringId( TaskQueueExecutor.class, "purge" ) );
     }
 
 }

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java Thu Jul 24 15:31:19 2008
@@ -20,7 +20,10 @@
  */
 
 import java.util.Iterator;
+import java.util.List;
 
+import org.apache.continuum.model.repository.LocalRepository;
+import org.apache.continuum.repository.RepositoryServiceException;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
@@ -40,6 +43,10 @@
     private String groupId;
 
     private String description;
+    
+    private int repositoryId;
+    
+    private List<LocalRepository> repositories;
 
     public void validate()
     {
@@ -109,6 +116,21 @@
         projectGroup.setGroupId( groupId );
 
         projectGroup.setDescription( description );
+        
+        try
+        {
+            if ( repositoryId > 0 )
+            {
+                LocalRepository repository = getContinuum().getRepositoryService().getLocalRepository( repositoryId );
+                projectGroup.setLocalRepository( repository );
+            }
+        }
+        catch ( RepositoryServiceException e )
+        {
+            getLogger().error( "Error adding project group" + e.getLocalizedMessage() );
+            
+            return ERROR;
+        }
 
         try
         {
@@ -130,6 +152,8 @@
         {
             checkAddProjectGroupAuthorization();
 
+            repositories = getContinuum().getRepositoryService().getAllLocalRepositories();
+            
             return INPUT;
         }
         catch ( AuthorizationRequiredException authzE )
@@ -168,4 +192,24 @@
     {
         this.name = name;
     }
+    
+    public int getRepositoryId()
+    {
+        return repositoryId;
+    }
+    
+    public void setRepositoryId( int repositoryId )
+    {
+        this.repositoryId = repositoryId;
+    }
+    
+    public List<LocalRepository> getRepositories()
+    {
+        return repositories;
+    }
+    
+    public void setRepositories( List<LocalRepository> repositories )
+    {
+        this.repositories = repositories;
+    }
 }

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/GroupSummaryAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/GroupSummaryAction.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/GroupSummaryAction.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/GroupSummaryAction.java Thu Jul 24 15:31:19 2008
@@ -21,7 +21,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.maven.continuum.ContinuumException;
@@ -61,6 +60,12 @@
                 groupModel.setGroupId( projectGroup.getGroupId() );
                 groupModel.setName( projectGroup.getName() );
                 groupModel.setDescription( projectGroup.getDescription() );
+                
+                if ( projectGroup.getLocalRepository() != null )
+                {
+                    groupModel.setRepositoryId( projectGroup.getLocalRepository().getId() );
+                    groupModel.setRepositoryName( projectGroup.getLocalRepository().getName() );
+                }
 
                 //TODO: Create a summary jpox request so code will be more simple and performance will be better
                 Collection<Project> projects = projectGroup.getProjects();

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java Thu Jul 24 15:31:19 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildResult;
@@ -114,6 +115,10 @@
     
     private String url;
 
+    private int repositoryId;
+    
+    private List<LocalRepository> repositories;
+    
     public String summary()
         throws ContinuumException
     {
@@ -291,7 +296,7 @@
         name = projectGroup.getName();
 
         description = projectGroup.getDescription();
-
+        
         projectList = projectGroup.getProjects();
 
         if ( projectList != null )
@@ -316,11 +321,22 @@
             projectGroups.put( new Integer( pg.getId() ), pg.getName() );
         }
 
+        if ( projectGroup.getLocalRepository() != null)
+        {
+            repositoryId = projectGroup.getLocalRepository().getId();
+        }
+        else
+        {
+            repositoryId = -1;
+        }
+        
+        repositories = getContinuum().getRepositoryService().getAllLocalRepositories();
+        
         return SUCCESS;
     }
 
     public String save()
-        throws ContinuumException
+        throws Exception
     {
         try
         {
@@ -384,7 +400,17 @@
         }
 
         projectGroup.setDescription( description );
-
+        
+        if ( repositoryId > 0 )
+        {
+            LocalRepository repository = getContinuum().getRepositoryService().getLocalRepository( repositoryId );
+            projectGroup.setLocalRepository( repository );
+        }
+        else
+        {
+            projectGroup.setLocalRepository( null );
+        }
+        
         getContinuum().updateProjectGroup( projectGroup );
 
         Iterator keys = projects.keySet().iterator();
@@ -864,4 +890,24 @@
 	{
 		this.url = url;
 	}
+	
+	public int getRepositoryId()
+	{
+	    return repositoryId;
+	}
+	
+	public void setRepositoryId( int repositoryId )
+	{
+	    this.repositoryId = repositoryId;
+	}
+	
+	public List<LocalRepository> getRepositories()
+	{
+	    return repositories;
+	}
+	
+	public void setRepositories( List<LocalRepository> repositories )
+	{
+	    this.repositories = repositories;
+	}
 }

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java Thu Jul 24 15:31:19 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.release.ContinuumReleaseManager;
@@ -112,12 +113,16 @@
 
         ContinuumReleaseManager releaseManager = getContinuum().getReleaseManager();
 
+        Project project = getContinuum().getProject( projectId );
+
         //todo should be configurable
         File performDirectory = new File( getContinuum().getConfiguration().getWorkingDirectory(),
                                           "releases-" + System.currentTimeMillis() );
         performDirectory.mkdirs();
-
-        releaseManager.perform( releaseId, performDirectory, goals, useReleaseProfile, listener );
+        
+        LocalRepository repository = project.getProjectGroup().getLocalRepository();
+        
+        releaseManager.perform( releaseId, performDirectory, goals, useReleaseProfile, listener, repository );
 
         return SUCCESS;
     }

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/mdo/view-models.mdo
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/mdo/view-models.mdo?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/mdo/view-models.mdo (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/mdo/view-models.mdo Thu Jul 24 15:31:19 2008
@@ -254,6 +254,21 @@
           <type>int</type>
           <defaultValue>-1</defaultValue>
         </field>
+        <field>
+          <name>repositoryId</name>
+          <version>1.0.0</version>
+          <required>false</required>
+          <description>local repository id of the project group</description>
+          <type>int</type>
+          <defaultValue>-1</defaultValue>
+        </field>
+        <field>
+          <name>repositoryName</name>
+          <version>1.0.0</version>
+          <required>false</required>
+          <description>local repository name of the project group</description>
+          <type>String</type>
+        </field>
       </fields>
     </class>
     <class>

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/META-INF/plexus/application.xml
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/META-INF/plexus/application.xml?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/META-INF/plexus/application.xml (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/META-INF/plexus/application.xml Thu Jul 24 15:31:19 2008
@@ -331,6 +331,11 @@
             <name>org.jpox.rdbms.stringDefaultLength</name>
             <value>255</value>
           </property>
+          <property>
+            <name>org.jpox.autoCreateColumns</name>
+            <value>true</value>
+          </property>
+			
 <!--
           <property>
             <name>org.jpox.identifier.case</name>

Modified: continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=679588&r1=679587&r2=679588&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ continuum/branches/CONTINUUM-782/continuum-webapp/src/main/resources/localization/Continuum.properties Thu Jul 24 15:31:19 2008
@@ -46,6 +46,7 @@
 unselectAll = Unselect All
 sort.descending = Sort Descending
 sort.ascending = Sort Ascending
+purge = Purge
 
 # ----------------------------------------------------------------------
 # Page: Top
@@ -79,6 +80,8 @@
 menu.account.options = My account
 user.edit.account = Edit user info
 menu.administration.queues = Queues
+menu.administration.repositories = Local Repositories
+menu.administration.purge = Purge Configurations
 
 # ----------------------------------------------------------------------
 # Page: error
@@ -144,6 +147,7 @@
 groups.section.title = Project Group:
 groups.manage.label = Manage Group
 groups.confirmation.message = Are you sure you want to delete the project group "{0}"?
+groups.table.repositoryName = Local Repository
 
 # ----------------------------------------------------------------------
 # Page: Project Group
@@ -174,6 +178,7 @@
 projectGroup.buildsStatut.success = Success
 projectGroup.buildDefinition.label = Default Build Definition
 projectGroup.addProject.label = Add New Project
+projectGroup.repository.label = Local Repository
 
 # ----------------------------------------------------------------------
 # Page: Project Group - Members
@@ -818,3 +823,70 @@
 deleteBuildEnv.page.title = Continuum - Delete Build Environment
 deleteBuildEnv.section.title = Delete Build Environment
 deleteBuildEnv.confirmation.message = Are you sure you want to delete Build Environment "{0}" ?
+
+#-----------------------------------------------------------------------
+# Page: Local Repositories
+#-----------------------------------------------------------------------
+repositories.page.title = Continuum - Local Repositories
+repositories.section.title = Local Repositories
+repositories.table.name = Name
+repositories.table.location = Location
+repositories.table.layout = Layout
+
+#-----------------------------------------------------------------------
+# Page: Add/Edit Local Repository
+#-----------------------------------------------------------------------
+repository.page.title = Continuum - Add/Edit Local Repository
+repository.section.title = Add/Edit Local Repository
+repository.name.label = Name
+repository.location.label = Location
+repository.layout.label = Layout
+repository.error.name.unique = Local repository name must be unique
+repository.error.name.cannot.be.spaces = Local repository name cannot be spaces
+repository.error.location.unique = Local repository location must be unique
+repository.error.location.cannot.be.spaces = Local repository location cannot be spaces
+repository.error.save.in.use = Unable to edit local repository because it is currently in use 
+repository.error.remove.in.use = Unable to remove local repository because it is currently in use
+repository.error.purge.in.use = Unable to purge local repository because it is currently in use
+repository.error.remove.default = Cannot remove default local repository.
+
+#-----------------------------------------------------------------------
+# Page: Delete Local Repository
+#-----------------------------------------------------------------------
+deleteRepository.page.title = Continuum - Delete Local Repository
+deleteRepository.section.title = Delete Local Repository
+deleteRepository.confirmation.message = Are you sure you want to delete Local Repository "{0}" ?
+
+#-----------------------------------------------------------------------
+# Page: Purge Configurations
+#-----------------------------------------------------------------------
+purgeConfigs.page.title = Continuum - Purge Configurations
+purgeConfigs.repo.section.title = Repository Purge Configurations
+purgeConfigs.dir.section.title = Directory Purge Configurations
+purgeConfigs.table.repository = Repository
+purgeConfigs.table.description = Description
+purgeConfigs.table.retentionCount = Retention Count
+purgeConfigs.table.schedule = Schedule
+purgeConfigs.table.daysOlder = Days Older
+purgeConfigs.table.deleteAll = Delete All
+purgeConfigs.table.directoryType = Directory Type
+purgeConfigs.table.default = Default
+purgeConfigs.table.enabled = Enabled
+purgeConfigs.table.deleteReleasedSnapshots = Delete Released Snapshots
+
+#-----------------------------------------------------------------------
+# Page: Add/Edit Purge Configuration
+#-----------------------------------------------------------------------
+purgeConfig.page.title = Continuum - Add/Edit Purge Configuration
+purgeConfig.section.title = Add/Edit Purge Configuration
+purgeConfig.repository.label = Repository
+purgeConfig.directoryType.label = Directory Type
+purgeConfig.retentionCount.label = Retention Count
+purgeConfig.daysOlder.label = Days Older
+purgeConfig.deleteAll.label = Delete All
+purgeConfig.deleteReleasedSnapshots.label = Delete Released Snapshots
+purgeConfig.defaultPurge.label = Is it Default?
+purgeConfig.schedule.label = Schedule
+purgeConfig.description.label = Description
+purgeConfig.enabled.label = Enabled
+purgeConfig.no.repositories = No repositories to purge
\ No newline at end of file



Mime
View raw message