mirror of https://github.com/apache/archiva.git
[MRM-1509] change xmlrpc to use new repository administration management api
use new api for ManagedRepository git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1164392 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
56587c1e6d
commit
75f7fab6d4
|
@ -105,7 +105,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
List<ManagedRepositoryConfiguration> managedRepoConfigs =
|
List<ManagedRepositoryConfiguration> managedRepoConfigs =
|
||||||
archivaConfiguration.getConfiguration().getManagedRepositories();
|
getArchivaConfiguration().getConfiguration().getManagedRepositories();
|
||||||
|
|
||||||
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
|
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
|
|
||||||
Configuration config = archivaConfiguration.getConfiguration();
|
Configuration config = getArchivaConfiguration().getConfiguration();
|
||||||
|
|
||||||
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
|
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
throw new RepositoryAdminException( "Cron expression cannot be empty." );
|
throw new RepositoryAdminException( "Cron expression cannot be empty." );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isBlank( repoId ))
|
if ( StringUtils.isBlank( repoId ) )
|
||||||
{
|
{
|
||||||
throw new RepositoryAdminException( "Repository ID cannot be empty." );
|
throw new RepositoryAdminException( "Repository ID cannot be empty." );
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
boolean deleteContent )
|
boolean deleteContent )
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
Configuration config = archivaConfiguration.getConfiguration();
|
Configuration config = getArchivaConfiguration().getConfiguration();
|
||||||
|
|
||||||
ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repositoryId );
|
ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repositoryId );
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
|
|
||||||
// stage repo exists ?
|
// stage repo exists ?
|
||||||
ManagedRepositoryConfiguration stagingRepository =
|
ManagedRepositoryConfiguration stagingRepository =
|
||||||
archivaConfiguration.getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
|
getArchivaConfiguration().getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
|
||||||
if ( stagingRepository != null )
|
if ( stagingRepository != null )
|
||||||
{
|
{
|
||||||
// do not trigger event when deleting the staged one
|
// do not trigger event when deleting the staged one
|
||||||
|
@ -320,13 +320,13 @@ public class DefaultManagedRepositoryAdmin
|
||||||
{
|
{
|
||||||
if ( !stagedOne )
|
if ( !stagedOne )
|
||||||
{
|
{
|
||||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||||
metadataRepository.removeRepository( repository.getId() );
|
metadataRepository.removeRepository( repository.getId() );
|
||||||
log.debug( "call repositoryStatisticsManager.deleteStatistics" );
|
log.debug( "call repositoryStatisticsManager.deleteStatistics" );
|
||||||
repositoryStatisticsManager.deleteStatistics( metadataRepository, repository.getId() );
|
getRepositoryStatisticsManager().deleteStatistics( metadataRepository, repository.getId() );
|
||||||
repositorySession.save();
|
repositorySession.save();
|
||||||
}
|
}
|
||||||
catch ( MetadataRepositoryException e )
|
catch ( MetadataRepositoryException e )
|
||||||
|
@ -357,7 +357,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
{
|
{
|
||||||
if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
|
if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
|
||||||
{
|
{
|
||||||
archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector );
|
config.removeProxyConnector( proxyConnector );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
List<String> repoGroups = repoToGroupMap.get( repository.getId() );
|
List<String> repoGroups = repoToGroupMap.get( repository.getId() );
|
||||||
for ( String repoGroup : repoGroups )
|
for ( String repoGroup : repoGroups )
|
||||||
{
|
{
|
||||||
archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository(
|
config.findRepositoryGroupById( repoGroup ).removeRepository(
|
||||||
repository.getId() );
|
repository.getId() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,9 @@ public class DefaultManagedRepositoryAdmin
|
||||||
throw new RepositoryAdminException(
|
throw new RepositoryAdminException(
|
||||||
"fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
|
"fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveConfiguration( config );
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +396,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
// Ensure that the fields are valid.
|
// Ensure that the fields are valid.
|
||||||
Configuration configuration = archivaConfiguration.getConfiguration();
|
Configuration configuration = getArchivaConfiguration().getConfiguration();
|
||||||
|
|
||||||
log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ",
|
log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ",
|
||||||
Arrays.asList( managedRepository, needStageRepo, resetStats ).toArray() );
|
Arrays.asList( managedRepository, needStageRepo, resetStats ).toArray() );
|
||||||
|
@ -426,18 +429,18 @@ public class DefaultManagedRepositoryAdmin
|
||||||
managedRepository.getCronExpression(), auditInformation );
|
managedRepository.getCronExpression(), auditInformation );
|
||||||
|
|
||||||
// Save the repository configuration.
|
// Save the repository configuration.
|
||||||
RepositorySession repositorySession = repositorySessionFactory.createSession();
|
RepositorySession repositorySession = getRepositorySessionFactory().createSession();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
triggerAuditEvent( managedRepositoryConfiguration.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
|
triggerAuditEvent( managedRepositoryConfiguration.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
|
||||||
auditInformation );
|
auditInformation );
|
||||||
|
|
||||||
saveConfiguration( this.archivaConfiguration.getConfiguration() );
|
saveConfiguration( this.getArchivaConfiguration().getConfiguration() );
|
||||||
if ( resetStats )
|
if ( resetStats )
|
||||||
{
|
{
|
||||||
log.debug( "call repositoryStatisticsManager.deleteStatistics" );
|
log.debug( "call repositoryStatisticsManager.deleteStatistics" );
|
||||||
repositoryStatisticsManager.deleteStatistics( repositorySession.getRepository(),
|
getRepositoryStatisticsManager().deleteStatistics( repositorySession.getRepository(),
|
||||||
managedRepositoryConfiguration.getId() );
|
managedRepositoryConfiguration.getId() );
|
||||||
repositorySession.save();
|
repositorySession.save();
|
||||||
}
|
}
|
||||||
|
@ -467,7 +470,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action );
|
new AuditEvent( repositoryId, user == null ? "null" : (String) user.getPrincipal(), resource, action );
|
||||||
event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() );
|
event.setRemoteIP( auditInformation == null ? "null" : auditInformation.getRemoteAddr() );
|
||||||
|
|
||||||
for ( AuditListener listener : auditListeners )
|
for ( AuditListener listener : getAuditListeners() )
|
||||||
{
|
{
|
||||||
listener.auditEvent( event );
|
listener.auditEvent( event );
|
||||||
}
|
}
|
||||||
|
@ -477,9 +480,9 @@ public class DefaultManagedRepositoryAdmin
|
||||||
public String removeExpressions( String directory )
|
public String removeExpressions( String directory )
|
||||||
{
|
{
|
||||||
String value = StringUtils.replace( directory, "${appserver.base}",
|
String value = StringUtils.replace( directory, "${appserver.base}",
|
||||||
registry.getString( "appserver.base", "${appserver.base}" ) );
|
getRegistry().getString( "appserver.base", "${appserver.base}" ) );
|
||||||
value = StringUtils.replace( value, "${appserver.home}",
|
value = StringUtils.replace( value, "${appserver.home}",
|
||||||
registry.getString( "appserver.home", "${appserver.home}" ) );
|
getRegistry().getString( "appserver.home", "${appserver.home}" ) );
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +491,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
archivaConfiguration.save( config );
|
getArchivaConfiguration().save( config );
|
||||||
}
|
}
|
||||||
catch ( RegistryException e )
|
catch ( RegistryException e )
|
||||||
{
|
{
|
||||||
|
@ -542,7 +545,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
|
|
||||||
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
||||||
{
|
{
|
||||||
if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) )
|
if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
|
||||||
{
|
{
|
||||||
log.info( "scanning of repository with id {} already scheduled", repositoryId );
|
log.info( "scanning of repository with id {} already scheduled", repositoryId );
|
||||||
}
|
}
|
||||||
|
@ -551,7 +554,7 @@ public class DefaultManagedRepositoryAdmin
|
||||||
task.setScanAll( fullScan );
|
task.setScanAll( fullScan );
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
repositoryTaskScheduler.queueTask( task );
|
getRepositoryTaskScheduler().queueTask( task );
|
||||||
}
|
}
|
||||||
catch ( TaskQueueException e )
|
catch ( TaskQueueException e )
|
||||||
{
|
{
|
||||||
|
@ -569,14 +572,14 @@ public class DefaultManagedRepositoryAdmin
|
||||||
// TODO: double check these are configured on start up
|
// TODO: double check these are configured on start up
|
||||||
// TODO: belongs in the business logic
|
// TODO: belongs in the business logic
|
||||||
|
|
||||||
if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
|
if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
|
||||||
{
|
{
|
||||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
|
if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
|
||||||
{
|
{
|
||||||
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,14 +588,14 @@ public class DefaultManagedRepositoryAdmin
|
||||||
{
|
{
|
||||||
String repoId = existingRepository.getId();
|
String repoId = existingRepository.getId();
|
||||||
|
|
||||||
if ( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
|
if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
|
||||||
{
|
{
|
||||||
roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
|
if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
|
||||||
{
|
{
|
||||||
roleManager.removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug( "removed user roles associated with repository {}", repoId );
|
log.debug( "removed user roles associated with repository {}", repoId );
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>stage-repository-merge</artifactId>
|
<artifactId>stage-repository-merge</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-repository-admin</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.atlassian.xmlrpc</groupId>
|
<groupId>com.atlassian.xmlrpc</groupId>
|
||||||
<artifactId>atlassian-xmlrpc-binder-annotations</artifactId>
|
<artifactId>atlassian-xmlrpc-binder-annotations</artifactId>
|
||||||
|
|
|
@ -19,12 +19,13 @@ package org.apache.archiva.web.xmlrpc.api;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.atlassian.xmlrpc.ServiceObject;
|
import com.atlassian.xmlrpc.ServiceObject;
|
||||||
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
||||||
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@ServiceObject( "AdministrationService" )
|
@ServiceObject( "AdministrationService" )
|
||||||
public interface AdministrationService
|
public interface AdministrationService
|
||||||
{
|
{
|
||||||
|
@ -35,7 +36,7 @@ public interface AdministrationService
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public Boolean executeRepositoryScanner( String repoId )
|
Boolean executeRepositoryScanner( String repoId )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,9 +44,10 @@ public interface AdministrationService
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getAllRepositoryConsumers();
|
List<String> getAllRepositoryConsumers();
|
||||||
|
|
||||||
// TODO should we already implement config of consumers per repository?
|
// TODO should we already implement config of consumers per repository?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures (enable or disable) repository consumer.
|
* Configures (enable or disable) repository consumer.
|
||||||
*
|
*
|
||||||
|
@ -55,7 +57,7 @@ public interface AdministrationService
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable )
|
Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,14 +65,15 @@ public interface AdministrationService
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<ManagedRepository> getAllManagedRepositories();
|
List<ManagedRepository> getAllManagedRepositories()
|
||||||
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all remote repositories.
|
* Gets all remote repositories.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<RemoteRepository> getAllRemoteRepositories();
|
List<RemoteRepository> getAllRemoteRepositories();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes given artifact from the specified repository.
|
* Deletes given artifact from the specified repository.
|
||||||
|
@ -82,7 +85,7 @@ public interface AdministrationService
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version )
|
Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,9 +102,9 @@ public interface AdministrationService
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public Boolean addManagedRepository( String repoId, String layout, String name, String location,
|
Boolean addManagedRepository( String repoId, String layout, String name, String location,
|
||||||
boolean blockRedeployments, boolean releasesIncluded,
|
boolean blockRedeployments, boolean releasesIncluded, boolean snapshotsIncluded,
|
||||||
boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression )
|
boolean stageRepoNeeded, String cronExpression )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,7 +113,7 @@ public interface AdministrationService
|
||||||
* @param repoId
|
* @param repoId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Boolean deleteManagedRepository( String repoId )
|
Boolean deleteManagedRepository( String repoId )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,16 +123,18 @@ public interface AdministrationService
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public Boolean deleteManagedRepositoryContent( String repoId )
|
Boolean deleteManagedRepositoryContent( String repoId )
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a managed repository with the given repository id.
|
* Get a managed repository with the given repository id.
|
||||||
|
*
|
||||||
* @param repoId
|
* @param repoId
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public ManagedRepository getManagedRepository(String repoId) throws Exception;
|
ManagedRepository getManagedRepository( String repoId )
|
||||||
|
throws Exception;
|
||||||
// TODO
|
// TODO
|
||||||
// consider the following as additional services:
|
// consider the following as additional services:
|
||||||
// - getAllConfiguredRepositoryConsumers( String repoId ) - list all enabled consumers for the repo
|
// - getAllConfiguredRepositoryConsumers( String repoId ) - list all enabled consumers for the repo
|
||||||
|
@ -137,11 +142,13 @@ public interface AdministrationService
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge staging repository with the managed repository and skips if there are conflicts
|
* Merge staging repository with the managed repository and skips if there are conflicts
|
||||||
|
*
|
||||||
* @param repoId
|
* @param repoId
|
||||||
* @param skipConflicts
|
* @param skipConflicts
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public boolean merge( String repoId, boolean skipConflicts ) throws Exception;
|
boolean merge( String repoId, boolean skipConflicts )
|
||||||
|
throws Exception;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-repository-admin</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-xmlrpc-security</artifactId>
|
<artifactId>archiva-xmlrpc-security</artifactId>
|
||||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.archiva.web.xmlrpc.services;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.admin.AuditInformation;
|
||||||
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
|
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
||||||
import org.apache.archiva.audit.AuditEvent;
|
import org.apache.archiva.audit.AuditEvent;
|
||||||
import org.apache.archiva.audit.AuditListener;
|
import org.apache.archiva.audit.AuditListener;
|
||||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||||
|
@ -38,7 +41,6 @@ import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
|
||||||
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.validator.GenericValidator;
|
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
|
import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
|
||||||
|
@ -54,9 +56,7 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||||
import org.apache.maven.archiva.repository.RepositoryException;
|
import org.apache.maven.archiva.repository.RepositoryException;
|
||||||
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
import org.apache.maven.archiva.repository.RepositoryNotFoundException;
|
||||||
import org.codehaus.plexus.registry.Registry;
|
|
||||||
import org.codehaus.plexus.registry.RegistryException;
|
import org.codehaus.plexus.registry.RegistryException;
|
||||||
import org.codehaus.redback.components.scheduler.CronExpressionValidator;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class AdministrationServiceImpl
|
||||||
|
|
||||||
private RepositorySessionFactory repositorySessionFactory;
|
private RepositorySessionFactory repositorySessionFactory;
|
||||||
|
|
||||||
private Registry registry;
|
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||||
|
|
||||||
private static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
|
private static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class AdministrationServiceImpl
|
||||||
Collection<RepositoryListener> listeners,
|
Collection<RepositoryListener> listeners,
|
||||||
RepositoryStatisticsManager repositoryStatisticsManager,
|
RepositoryStatisticsManager repositoryStatisticsManager,
|
||||||
RepositoryMerger repositoryMerger, AuditListener auditListener,
|
RepositoryMerger repositoryMerger, AuditListener auditListener,
|
||||||
Registry registry )
|
ManagedRepositoryAdmin managedRepositoryAdmin )
|
||||||
{
|
{
|
||||||
this.archivaConfiguration = archivaConfig;
|
this.archivaConfiguration = archivaConfig;
|
||||||
this.repoConsumersUtil = repoConsumersUtil;
|
this.repoConsumersUtil = repoConsumersUtil;
|
||||||
|
@ -124,7 +124,7 @@ public class AdministrationServiceImpl
|
||||||
this.repositoryStatisticsManager = repositoryStatisticsManager;
|
this.repositoryStatisticsManager = repositoryStatisticsManager;
|
||||||
this.repositoryMerger = repositoryMerger;
|
this.repositoryMerger = repositoryMerger;
|
||||||
this.auditListener = auditListener;
|
this.auditListener = auditListener;
|
||||||
this.registry = registry;
|
this.managedRepositoryAdmin = managedRepositoryAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,8 +214,8 @@ public class AdministrationServiceImpl
|
||||||
repoContent.deleteVersion( ref );
|
repoContent.deleteVersion( ref );
|
||||||
|
|
||||||
MetadataRepository metadataRepository = repositorySession.getRepository();
|
MetadataRepository metadataRepository = repositorySession.getRepository();
|
||||||
Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, groupId, artifactId,
|
Collection<ArtifactMetadata> artifacts =
|
||||||
version );
|
metadataRepository.getArtifacts( repoId, groupId, artifactId, version );
|
||||||
|
|
||||||
for ( ArtifactMetadata artifact : artifacts )
|
for ( ArtifactMetadata artifact : artifacts )
|
||||||
{
|
{
|
||||||
|
@ -307,18 +307,15 @@ public class AdministrationServiceImpl
|
||||||
* @see AdministrationService#getAllManagedRepositories()
|
* @see AdministrationService#getAllManagedRepositories()
|
||||||
*/
|
*/
|
||||||
public List<ManagedRepository> getAllManagedRepositories()
|
public List<ManagedRepository> getAllManagedRepositories()
|
||||||
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>();
|
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>();
|
||||||
|
|
||||||
Configuration config = archivaConfiguration.getConfiguration();
|
for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : managedRepositoryAdmin.getManagedRepositories() )
|
||||||
List<ManagedRepositoryConfiguration> managedRepoConfigs = config.getManagedRepositories();
|
|
||||||
|
|
||||||
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
|
|
||||||
{
|
{
|
||||||
// TODO fix resolution of repo url!
|
ManagedRepository repo =
|
||||||
ManagedRepository repo = new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL",
|
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
|
||||||
repoConfig.getLayout(), repoConfig.isSnapshots(),
|
repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases() );
|
||||||
repoConfig.isReleases() );
|
|
||||||
managedRepos.add( repo );
|
managedRepos.add( repo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,89 +365,12 @@ public class AdministrationServiceImpl
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
Configuration config = archivaConfiguration.getConfiguration();
|
org.apache.archiva.admin.repository.managed.ManagedRepository repository =
|
||||||
|
new org.apache.archiva.admin.repository.managed.ManagedRepository( repoId, name, location, layout,
|
||||||
|
snapshotsIncluded, releasesIncluded,
|
||||||
|
blockRedeployments, cronExpression );
|
||||||
|
return managedRepositoryAdmin.addManagedRepository( repository, stageRepoNeeded, getAuditInformation() );
|
||||||
|
|
||||||
CronExpressionValidator validator = new CronExpressionValidator();
|
|
||||||
|
|
||||||
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Unable to add new repository with id [" + repoId +
|
|
||||||
"], that id already exists as a managed repository." );
|
|
||||||
}
|
|
||||||
else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Unable to add new repository with id [" + repoId +
|
|
||||||
"], that id already exists as a remote repository." );
|
|
||||||
}
|
|
||||||
else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Unable to add new repository with id [" + repoId +
|
|
||||||
"], that id already exists as a repository group." );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !validator.validate( cronExpression ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Invalid cron expression." );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !GenericValidator.matchRegexp( repoId, REPOSITORY_ID_VALID_EXPRESSION ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Invalid repository ID. Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !GenericValidator.matchRegexp( name, REPOSITORY_NAME_VALID_EXPRESSION ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Invalid repository name. Repository Name must only contain alphanumeric characters, white-spaces(' '), " +
|
|
||||||
"forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
|
|
||||||
}
|
|
||||||
|
|
||||||
String repoLocation = removeExpressions( location );
|
|
||||||
|
|
||||||
if( !GenericValidator.matchRegexp( repoLocation, REPOSITORY_LOCATION_VALID_EXPRESSION ) )
|
|
||||||
{
|
|
||||||
throw new Exception( "Invalid repository location. Directory must only contain alphanumeric characters, equals(=), question-marks(?), " +
|
|
||||||
"exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
|
|
||||||
}
|
|
||||||
|
|
||||||
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
|
|
||||||
|
|
||||||
repository.setId( repoId );
|
|
||||||
repository.setBlockRedeployments( blockRedeployments );
|
|
||||||
repository.setReleases( releasesIncluded );
|
|
||||||
repository.setSnapshots( snapshotsIncluded );
|
|
||||||
repository.setName( name );
|
|
||||||
repository.setLocation( repoLocation );
|
|
||||||
repository.setLayout( layout );
|
|
||||||
repository.setRefreshCronExpression( cronExpression );
|
|
||||||
|
|
||||||
addRepository( repository, config );
|
|
||||||
|
|
||||||
if ( stageRepoNeeded )
|
|
||||||
{
|
|
||||||
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
|
|
||||||
addRepository( stagingRepository, config );
|
|
||||||
}
|
|
||||||
|
|
||||||
saveConfiguration( config );
|
|
||||||
|
|
||||||
//MRM-1342 Repository statistics report doesn't appear to be working correctly
|
|
||||||
//scan repository when adding of repository is successful
|
|
||||||
try
|
|
||||||
{
|
|
||||||
executeRepositoryScanner( repoId );
|
|
||||||
if ( stageRepoNeeded )
|
|
||||||
{
|
|
||||||
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
|
|
||||||
executeRepositoryScanner( stagingRepository.getId() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( Exception e )
|
|
||||||
{
|
|
||||||
log.warn( new StringBuilder( "Unable to scan repository [" ).append( repoId ).append( "]: " ).append(
|
|
||||||
e.getMessage() ).toString(), e );
|
|
||||||
}
|
|
||||||
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean deleteManagedRepository( String repoId )
|
public Boolean deleteManagedRepository( String repoId )
|
||||||
|
@ -608,16 +528,16 @@ public class AdministrationServiceImpl
|
||||||
log.info( "Repository to be merged contains releases only.." );
|
log.info( "Repository to be merged contains releases only.." );
|
||||||
if ( skipConflicts )
|
if ( skipConflicts )
|
||||||
{
|
{
|
||||||
List<ArtifactMetadata> conflicts = repositoryMerger.getConflictingArtifacts(
|
List<ArtifactMetadata> conflicts =
|
||||||
metadataRepository, repoId, stagingId );
|
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
|
||||||
|
|
||||||
if ( log.isDebugEnabled() )
|
if ( log.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
log.debug( "Artifacts in conflict.." );
|
log.debug( "Artifacts in conflict.." );
|
||||||
for ( ArtifactMetadata metadata : conflicts )
|
for ( ArtifactMetadata metadata : conflicts )
|
||||||
{
|
{
|
||||||
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" +
|
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":"
|
||||||
metadata.getProjectVersion() );
|
+ metadata.getProjectVersion() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,16 +557,16 @@ public class AdministrationServiceImpl
|
||||||
log.info( "Repository to be merged has snapshot artifacts.." );
|
log.info( "Repository to be merged has snapshot artifacts.." );
|
||||||
if ( skipConflicts )
|
if ( skipConflicts )
|
||||||
{
|
{
|
||||||
List<ArtifactMetadata> conflicts = repositoryMerger.getConflictingArtifacts(
|
List<ArtifactMetadata> conflicts =
|
||||||
metadataRepository, repoId, stagingId );
|
repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
|
||||||
|
|
||||||
if ( log.isDebugEnabled() )
|
if ( log.isDebugEnabled() )
|
||||||
{
|
{
|
||||||
log.debug( "Artifacts in conflict.." );
|
log.debug( "Artifacts in conflict.." );
|
||||||
for ( ArtifactMetadata metadata : conflicts )
|
for ( ArtifactMetadata metadata : conflicts )
|
||||||
{
|
{
|
||||||
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" +
|
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":"
|
||||||
metadata.getProjectVersion() );
|
+ metadata.getProjectVersion() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,19 +574,19 @@ public class AdministrationServiceImpl
|
||||||
|
|
||||||
log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
|
log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
|
||||||
|
|
||||||
Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>(
|
Filter<ArtifactMetadata> artifactsWithOutConflicts =
|
||||||
sourceArtifacts );
|
new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
|
||||||
repositoryMerger.merge( metadataRepository, stagingId, repoId, artifactsWithOutConflicts );
|
repositoryMerger.merge( metadataRepository, stagingId, repoId, artifactsWithOutConflicts );
|
||||||
|
|
||||||
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" +
|
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '"
|
||||||
repoId + "'." );
|
+ repoId + "'." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
repositoryMerger.merge( metadataRepository, stagingId, repoId );
|
repositoryMerger.merge( metadataRepository, stagingId, repoId );
|
||||||
|
|
||||||
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" +
|
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '"
|
||||||
repoId + "'." );
|
+ repoId + "'." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -705,25 +625,6 @@ public class AdministrationServiceImpl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
// Normalize the path
|
|
||||||
File file = new File( repository.getLocation() );
|
|
||||||
repository.setLocation( file.getCanonicalPath() );
|
|
||||||
if ( !file.exists() )
|
|
||||||
{
|
|
||||||
file.mkdirs();
|
|
||||||
}
|
|
||||||
if ( !file.exists() || !file.isDirectory() )
|
|
||||||
{
|
|
||||||
throw new IOException(
|
|
||||||
"Unable to add repository - no write access, can not create the root directory: " + file );
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration.addManagedRepository( repository );
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo: setting userid of audit event
|
// todo: setting userid of audit event
|
||||||
private AuditEvent createAuditEvent( ManagedRepositoryConfiguration repoConfig )
|
private AuditEvent createAuditEvent( ManagedRepositoryConfiguration repoConfig )
|
||||||
{
|
{
|
||||||
|
@ -779,12 +680,9 @@ public class AdministrationServiceImpl
|
||||||
return stagingRepository;
|
return stagingRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String removeExpressions( String directory )
|
// FIXME find a way to get user id and adress
|
||||||
|
private AuditInformation getAuditInformation()
|
||||||
{
|
{
|
||||||
String value = StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base",
|
return new AuditInformation( null, null );
|
||||||
"${appserver.base}" ) );
|
|
||||||
value = StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home",
|
|
||||||
"${appserver.home}" ) );
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.archiva.web.xmlrpc.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
|
||||||
|
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
||||||
import org.apache.archiva.audit.AuditEvent;
|
import org.apache.archiva.audit.AuditEvent;
|
||||||
import org.apache.archiva.audit.AuditListener;
|
import org.apache.archiva.audit.AuditListener;
|
||||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||||
|
@ -53,6 +55,8 @@ import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryConte
|
||||||
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
||||||
import org.apache.maven.archiva.repository.content.PathParser;
|
import org.apache.maven.archiva.repository.content.PathParser;
|
||||||
import org.apache.maven.archiva.repository.layout.LayoutException;
|
import org.apache.maven.archiva.repository.layout.LayoutException;
|
||||||
|
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||||
|
import org.codehaus.plexus.redback.role.RoleManager;
|
||||||
import org.codehaus.plexus.registry.Registry;
|
import org.codehaus.plexus.registry.Registry;
|
||||||
import org.easymock.MockControl;
|
import org.easymock.MockControl;
|
||||||
import org.easymock.classextension.MockClassControl;
|
import org.easymock.classextension.MockClassControl;
|
||||||
|
@ -65,6 +69,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -140,12 +145,18 @@ public class AdministrationServiceImplTest
|
||||||
|
|
||||||
private AuditListener auditListener;
|
private AuditListener auditListener;
|
||||||
|
|
||||||
|
private MockControl roleManagerControl;
|
||||||
|
|
||||||
|
private RoleManager roleManager;
|
||||||
|
|
||||||
private MockControl registryControl;
|
private MockControl registryControl;
|
||||||
|
|
||||||
private Registry registry;
|
private Registry registry;
|
||||||
|
|
||||||
private static final String STAGE = "-stage";
|
private static final String STAGE = "-stage";
|
||||||
|
|
||||||
|
private DefaultManagedRepositoryAdmin managedRepositoryAdmin;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp()
|
public void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
@ -189,6 +200,9 @@ public class AdministrationServiceImplTest
|
||||||
listenerControl = MockControl.createControl( RepositoryListener.class );
|
listenerControl = MockControl.createControl( RepositoryListener.class );
|
||||||
listener = (RepositoryListener) listenerControl.getMock();
|
listener = (RepositoryListener) listenerControl.getMock();
|
||||||
|
|
||||||
|
roleManagerControl = MockControl.createControl( RoleManager.class );
|
||||||
|
roleManager = (RoleManager) roleManagerControl.getMock();
|
||||||
|
|
||||||
repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
|
repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
|
||||||
repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
|
repositoryStatisticsManager = (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
|
||||||
|
|
||||||
|
@ -201,10 +215,20 @@ public class AdministrationServiceImplTest
|
||||||
registryControl = MockControl.createControl( Registry.class );
|
registryControl = MockControl.createControl( Registry.class );
|
||||||
registry = (Registry) registryControl.getMock();
|
registry = (Registry) registryControl.getMock();
|
||||||
|
|
||||||
|
|
||||||
|
managedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
|
||||||
|
managedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
|
||||||
|
managedRepositoryAdmin.setRegistry( registry );
|
||||||
|
managedRepositoryAdmin.setRepositoryStatisticsManager( repositoryStatisticsManager );
|
||||||
|
managedRepositoryAdmin.setRepositoryTaskScheduler( repositoryTaskScheduler );
|
||||||
|
managedRepositoryAdmin.setRepositorySessionFactory( repositorySessionFactory );
|
||||||
|
managedRepositoryAdmin.setAuditListeners( Arrays.asList( auditListener ) );
|
||||||
|
managedRepositoryAdmin.setRoleManager( roleManager );
|
||||||
|
|
||||||
service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory,
|
service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory,
|
||||||
repositorySessionFactory, repositoryTaskScheduler,
|
repositorySessionFactory, repositoryTaskScheduler,
|
||||||
Collections.singletonList( listener ), repositoryStatisticsManager,
|
Collections.singletonList( listener ), repositoryStatisticsManager,
|
||||||
repositoryMerger, auditListener, registry );
|
repositoryMerger, auditListener, managedRepositoryAdmin );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tests for repository consumers */
|
/* Tests for repository consumers */
|
||||||
|
@ -948,6 +972,27 @@ public class AdministrationServiceImplTest
|
||||||
configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
|
configControl.expectAndReturn( config.getManagedRepositoriesAsMap(), managedRepoMap );
|
||||||
configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
|
configControl.expectAndReturn( config.getRemoteRepositoriesAsMap(), remoteRepoMap );
|
||||||
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
|
configControl.expectAndReturn( config.getRepositoryGroupsAsMap(), repoGroupMap );
|
||||||
|
|
||||||
|
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
||||||
|
roleManagerControl.setReturnValue( false );
|
||||||
|
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
|
||||||
|
roleManagerControl.setVoidCallable();
|
||||||
|
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
||||||
|
roleManagerControl.setReturnValue( false );
|
||||||
|
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
|
||||||
|
roleManagerControl.setVoidCallable();
|
||||||
|
|
||||||
|
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId + "-stage" );
|
||||||
|
roleManagerControl.setReturnValue( false );
|
||||||
|
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId + "-stage" );
|
||||||
|
roleManagerControl.setVoidCallable();
|
||||||
|
roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId + "-stage" );
|
||||||
|
roleManagerControl.setReturnValue( false );
|
||||||
|
roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId + "-stage" );
|
||||||
|
roleManagerControl.setVoidCallable();
|
||||||
|
|
||||||
|
roleManagerControl.replay();
|
||||||
|
|
||||||
registryControl.expectAndReturn( registry.getString( "appserver.base", "${appserver.base}" ), appserverBase );
|
registryControl.expectAndReturn( registry.getString( "appserver.base", "${appserver.base}" ), appserverBase );
|
||||||
registryControl.expectAndReturn( registry.getString( "appserver.home", "${appserver.home}" ), appserverBase );
|
registryControl.expectAndReturn( registry.getString( "appserver.home", "${appserver.home}" ), appserverBase );
|
||||||
config.addManagedRepository( managedRepo );
|
config.addManagedRepository( managedRepo );
|
||||||
|
@ -959,6 +1004,9 @@ public class AdministrationServiceImplTest
|
||||||
archivaConfig.save( config );
|
archivaConfig.save( config );
|
||||||
archivaConfigControl.setVoidCallable();
|
archivaConfigControl.setVoidCallable();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//managed repo
|
//managed repo
|
||||||
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( repoId ), false );
|
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( repoId ), false );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue