diff options
author | Olivier Lamy <olamy@apache.org> | 2011-08-30 22:49:42 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-08-30 22:49:42 +0000 |
commit | 0887d40cd89f7bf99a8be6ff365cd8a2d12b8ceb (patch) | |
tree | e592d21bcb8b83affd3fcdfc5891aa859aea1c28 /archiva-modules/archiva-base | |
parent | 8b766739ad8f7d7909cfa4d125260908646ea0a6 (diff) | |
download | archiva-0887d40cd89f7bf99a8be6ff365cd8a2d12b8ceb.tar.gz archiva-0887d40cd89f7bf99a8be6ff365cd8a2d12b8ceb.zip |
[MRM-1505] api to configure ManagedRepositories : integrate it in webapp for delete action.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1163444 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
4 files changed, 64 insertions, 12 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java index b3750ed25..e0a5b875a 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -193,6 +193,7 @@ public class DefaultArchivaConfiguration } Configuration config = new ConfigurationRegistryReader().read( subset ); + config.getRepositoryGroups(); config.getRepositoryGroupsAsMap(); if ( !config.getRepositories().isEmpty() ) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index 22f89ff8c..69eb0104e 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -263,7 +263,12 @@ public class DefaultManagedRepositoryAdmin } - public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation ) + // FIXME delete stagedRepo if exists !!!! + // find it tru : + // stagingRepository = + // archivaConfiguration.getConfiguration().findManagedRepositoryById( repoid + "-stage" ); + public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation, + boolean deleteContent ) throws RepositoryAdminException { Configuration config = archivaConfiguration.getConfiguration(); @@ -282,6 +287,7 @@ public class DefaultManagedRepositoryAdmin { MetadataRepository metadataRepository = repositorySession.getRepository(); metadataRepository.removeRepository( repository.getId() ); + log.debug( "call repositoryStatisticsManager.deleteStatistics" ); repositoryStatisticsManager.deleteStatistics( metadataRepository, repository.getId() ); repositorySession.save(); } @@ -304,14 +310,19 @@ public class DefaultManagedRepositoryAdmin throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage() ); } - // TODO could be async ? as directory can be huge - File dir = new File( repository.getLocation() ); - if ( !FileUtils.deleteQuietly( dir ) ) + if ( deleteContent ) { - throw new RepositoryAdminException( "Cannot delete repository " + dir ); + // TODO could be async ? as directory can be huge + File dir = new File( repository.getLocation() ); + if ( !FileUtils.deleteQuietly( dir ) ) + { + throw new RepositoryAdminException( "Cannot delete repository " + dir ); + } } - List<ProxyConnectorConfiguration> proxyConnectors = config.getProxyConnectors(); + // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException + List<ProxyConnectorConfiguration> proxyConnectors = + new ArrayList<ProxyConnectorConfiguration>( config.getProxyConnectors() ); for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors ) { if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) ) @@ -408,6 +419,7 @@ public class DefaultManagedRepositoryAdmin saveConfiguration( this.archivaConfiguration.getConfiguration() ); if ( resetStats ) { + log.debug( "call repositoryStatisticsManager.deleteStatistics" ); repositoryStatisticsManager.deleteStatistics( repositorySession.getRepository(), managedRepository.getId() ); repositorySession.save(); @@ -450,7 +462,8 @@ public class DefaultManagedRepositoryAdmin AuditInformation auditInformation ) { User user = auditInformation == null ? null : auditInformation.getUser(); - AuditEvent event = new AuditEvent( repositoryId, user == null ? "null" : user.getUsername(), resource, action ); + AuditEvent event = + new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action ); event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() ); for ( AuditListener listener : auditListeners ) @@ -604,4 +617,34 @@ public class DefaultManagedRepositoryAdmin { this.roleManager = roleManager; } + + public RepositoryStatisticsManager getRepositoryStatisticsManager() + { + return repositoryStatisticsManager; + } + + public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager ) + { + this.repositoryStatisticsManager = repositoryStatisticsManager; + } + + public RepositorySessionFactory getRepositorySessionFactory() + { + return repositorySessionFactory; + } + + public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory ) + { + this.repositorySessionFactory = repositorySessionFactory; + } + + public List<AuditListener> getAuditListeners() + { + return auditListeners; + } + + public void setAuditListeners( List<AuditListener> auditListeners ) + { + this.auditListeners = auditListeners; + } } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdmin.java index 0fc9fa1c0..5bcda0cd0 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdmin.java @@ -21,7 +21,6 @@ package org.apache.archiva.admin.repository.managed; import org.apache.archiva.admin.AuditInformation; import org.apache.archiva.admin.repository.RepositoryAdminException; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; import java.util.List; @@ -37,7 +36,7 @@ public interface ManagedRepositoryAdmin ManagedRepository getManagedRepository( String repositoryId ) throws RepositoryAdminException; - Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation ) + Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation, boolean deleteContent ) throws RepositoryAdminException; Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo, diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java index 64a5eea6c..80831037b 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/managed/ManagedRepositoryAdminTest.java @@ -102,7 +102,7 @@ public class ManagedRepositoryAdminTest assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, "test-new-one" ) ); - managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation() ); + managedRepositoryAdmin.deleteManagedRepository( "test-new-one", getFakeAuditInformation(), false ); repos = managedRepositoryAdmin.getManagedRepositories(); assertNotNull( repos ); @@ -169,7 +169,7 @@ public class ManagedRepositoryAdminTest assertTrue( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, "test-new-one" ) ); - managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation() ); + managedRepositoryAdmin.deleteManagedRepository( repo.getId(), getFakeAuditInformation(), false ); assertFalse( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "test-new-one" ) ); @@ -211,7 +211,16 @@ public class ManagedRepositoryAdminTest User getFakeUser() { - SimpleUser user = new SimpleUser(); + SimpleUser user = new SimpleUser() + { + @Override + public Object getPrincipal() + { + return "root"; + } + + }; + user.setUsername( "root" ); user.setFullName( "The top user" ); return user; |