mirror of https://github.com/apache/archiva.git
[MRM-1512] api to configure RepositoryScanningConfiguration : refactor to remove full access to bean with a large tree of nesteed beans. use simple methods to update fields of RepositoryScanningConfiguration.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167224 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
97de6d3118
commit
b31467ae8d
|
@ -39,18 +39,15 @@ public interface ArchivaAdministration
|
||||||
void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
|
void deleteLegacyArtifactPath( String path, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
RepositoryScanning getRepositoryScanning()
|
|
||||||
throws RepositoryAdminException;
|
|
||||||
|
|
||||||
void updateRepositoryScanning( RepositoryScanning repositoryScanning, AuditInformation auditInformation )
|
|
||||||
throws RepositoryAdminException;
|
|
||||||
|
|
||||||
void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
|
List<FileType> getFileTypes()
|
||||||
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
FileType getFileType( String fileTypeId )
|
FileType getFileType( String fileTypeId )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
|
@ -66,6 +63,8 @@ public interface ArchivaAdministration
|
||||||
void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
|
void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
|
List<String> getKnownContentConsumers()
|
||||||
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
|
void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
@ -76,6 +75,9 @@ public interface ArchivaAdministration
|
||||||
void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
|
void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
|
List<String> getInvalidContentConsumers()
|
||||||
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
|
void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException;
|
throws RepositoryAdminException;
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
import org.apache.archiva.audit.AuditEvent;
|
import org.apache.archiva.audit.AuditEvent;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,27 +78,6 @@ public class DefaultArchivaAdministration
|
||||||
triggerAuditEvent( "", "", AuditEvent.REMOVE_LEGACY_PATH, auditInformation );
|
triggerAuditEvent( "", "", AuditEvent.REMOVE_LEGACY_PATH, auditInformation );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRepositoryScanning( RepositoryScanning repositoryScanning, AuditInformation auditInformation )
|
|
||||||
throws RepositoryAdminException
|
|
||||||
{
|
|
||||||
Configuration configuration = getArchivaConfiguration().getConfiguration();
|
|
||||||
|
|
||||||
configuration.setRepositoryScanning(
|
|
||||||
new BeanReplicator().replicateBean( repositoryScanning, RepositoryScanningConfiguration.class ) );
|
|
||||||
|
|
||||||
saveConfiguration( configuration );
|
|
||||||
}
|
|
||||||
|
|
||||||
public RepositoryScanning getRepositoryScanning()
|
|
||||||
throws RepositoryAdminException
|
|
||||||
{
|
|
||||||
|
|
||||||
RepositoryScanning repositoryScanning =
|
|
||||||
new BeanReplicator().replicateBean( getArchivaConfiguration().getConfiguration().getRepositoryScanning(),
|
|
||||||
RepositoryScanning.class )
|
|
||||||
|
|
||||||
return repositoryScanning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
|
@ -242,6 +221,37 @@ public class DefaultArchivaAdministration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FileType> getFileTypes()
|
||||||
|
throws RepositoryAdminException
|
||||||
|
{
|
||||||
|
List<org.apache.maven.archiva.configuration.FileType> configFileTypes =
|
||||||
|
getArchivaConfiguration().getConfiguration().getRepositoryScanning().getFileTypes();
|
||||||
|
if ( configFileTypes == null || configFileTypes.isEmpty() )
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<FileType> fileTypes = new ArrayList<FileType>();
|
||||||
|
for ( org.apache.maven.archiva.configuration.FileType fileType : configFileTypes )
|
||||||
|
{
|
||||||
|
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
|
||||||
|
}
|
||||||
|
return fileTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getKnownContentConsumers()
|
||||||
|
throws RepositoryAdminException
|
||||||
|
{
|
||||||
|
return new ArrayList<String>(
|
||||||
|
getArchivaConfiguration().getConfiguration().getRepositoryScanning().getKnownContentConsumers() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getInvalidContentConsumers()
|
||||||
|
throws RepositoryAdminException
|
||||||
|
{
|
||||||
|
return new ArrayList<String>(
|
||||||
|
getArchivaConfiguration().getConfiguration().getRepositoryScanning().getInvalidContentConsumers() );
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//
|
//
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
@ -257,4 +267,5 @@ public class DefaultArchivaAdministration
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class ArchivaAdministrationTest
|
||||||
public void addAndUpdateAndDeleteFileType()
|
public void addAndUpdateAndDeleteFileType()
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
int initialSize = archivaAdministration.getRepositoryScanning().getFileTypes().size();
|
int initialSize = archivaAdministration.getFileTypes().size();
|
||||||
|
|
||||||
FileType fileType = new FileType();
|
FileType fileType = new FileType();
|
||||||
fileType.setId( "foo" );
|
fileType.setId( "foo" );
|
||||||
|
@ -77,11 +77,11 @@ public class ArchivaAdministrationTest
|
||||||
|
|
||||||
archivaAdministration.addFileType( fileType, getFakeAuditInformation() );
|
archivaAdministration.addFileType( fileType, getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
|
assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
|
||||||
|
|
||||||
archivaAdministration.addFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
|
archivaAdministration.addFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
|
assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
|
||||||
|
|
||||||
assertEquals( 3, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
|
assertEquals( 3, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class ArchivaAdministrationTest
|
||||||
|
|
||||||
archivaAdministration.removeFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
|
archivaAdministration.removeFileTypePattern( "foo", "zorro", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
|
assertEquals( initialSize + 1, archivaAdministration.getFileTypes().size() );
|
||||||
|
|
||||||
assertEquals( 2, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
|
assertEquals( 2, archivaAdministration.getFileType( "foo" ).getPatterns().size() );
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ public class ArchivaAdministrationTest
|
||||||
|
|
||||||
archivaAdministration.removeFileType( "foo", getFakeAuditInformation() );
|
archivaAdministration.removeFileType( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize, archivaAdministration.getRepositoryScanning().getFileTypes().size() );
|
assertEquals( initialSize, archivaAdministration.getFileTypes().size() );
|
||||||
assertNull( archivaAdministration.getFileType( "foo" ) );
|
assertNull( archivaAdministration.getFileType( "foo" ) );
|
||||||
mockAuditListener.clearEvents();
|
mockAuditListener.clearEvents();
|
||||||
}
|
}
|
||||||
|
@ -110,27 +110,23 @@ public class ArchivaAdministrationTest
|
||||||
public void knownContentConsumersTest()
|
public void knownContentConsumersTest()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int initialSize = archivaAdministration.getRepositoryScanning().getKnownContentConsumers().size();
|
int initialSize = archivaAdministration.getKnownContentConsumers().size();
|
||||||
|
|
||||||
archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1,
|
assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
|
||||||
archivaAdministration.getRepositoryScanning().getKnownContentConsumers().size() );
|
assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
|
||||||
assertTrue( archivaAdministration.getRepositoryScanning().getKnownContentConsumers().contains( "foo" ) );
|
|
||||||
|
|
||||||
// ensure we don't add it twice as it's an ArrayList as storage
|
// ensure we don't add it twice as it's an ArrayList as storage
|
||||||
archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.addKnownContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1,
|
assertEquals( initialSize + 1, archivaAdministration.getKnownContentConsumers().size() );
|
||||||
archivaAdministration.getRepositoryScanning().getKnownContentConsumers().size() );
|
assertTrue( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
|
||||||
assertTrue( archivaAdministration.getRepositoryScanning().getKnownContentConsumers().contains( "foo" ) );
|
|
||||||
|
|
||||||
archivaAdministration.removeKnownContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.removeKnownContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
|
assertEquals( initialSize, archivaAdministration.getKnownContentConsumers().size() );
|
||||||
assertEquals( initialSize ,
|
assertFalse( archivaAdministration.getKnownContentConsumers().contains( "foo" ) );
|
||||||
archivaAdministration.getRepositoryScanning().getKnownContentConsumers().size() );
|
|
||||||
assertFalse( archivaAdministration.getRepositoryScanning().getKnownContentConsumers().contains( "foo" ) );
|
|
||||||
|
|
||||||
assertEquals( 2, mockAuditListener.getAuditEvents().size() );
|
assertEquals( 2, mockAuditListener.getAuditEvents().size() );
|
||||||
assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
|
assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
|
||||||
|
@ -144,25 +140,23 @@ public class ArchivaAdministrationTest
|
||||||
public void invalidContentConsumersTest()
|
public void invalidContentConsumersTest()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int initialSize = archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().size();
|
int initialSize = archivaAdministration.getInvalidContentConsumers().size();
|
||||||
|
|
||||||
archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1,
|
assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
|
||||||
archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().size() );
|
assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
|
||||||
assertTrue( archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().contains( "foo" ) );
|
|
||||||
|
|
||||||
// ensure we don't add it twice as it's an ArrayList as storage
|
// ensure we don't add it twice as it's an ArrayList as storage
|
||||||
archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.addInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize + 1,
|
assertEquals( initialSize + 1, archivaAdministration.getInvalidContentConsumers().size() );
|
||||||
archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().size() );
|
assertTrue( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
|
||||||
assertTrue( archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().contains( "foo" ) );
|
|
||||||
|
|
||||||
archivaAdministration.removeInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
archivaAdministration.removeInvalidContentConsumer( "foo", getFakeAuditInformation() );
|
||||||
|
|
||||||
assertEquals( initialSize, archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().size() );
|
assertEquals( initialSize, archivaAdministration.getInvalidContentConsumers().size() );
|
||||||
assertFalse( archivaAdministration.getRepositoryScanning().getInvalidContentConsumers().contains( "foo" ) );
|
assertFalse( archivaAdministration.getInvalidContentConsumers().contains( "foo" ) );
|
||||||
|
|
||||||
assertEquals( 2, mockAuditListener.getAuditEvents().size() );
|
assertEquals( 2, mockAuditListener.getAuditEvents().size() );
|
||||||
assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
|
assertEquals( AuditEvent.ENABLE_REPO_CONSUMER, mockAuditListener.getAuditEvents().get( 0 ).getAction() );
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.archiva.rest.api.services;
|
||||||
|
|
||||||
import org.apache.archiva.rest.api.model.FileType;
|
import org.apache.archiva.rest.api.model.FileType;
|
||||||
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
|
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
|
||||||
import org.apache.archiva.rest.api.model.RepositoryScanning;
|
|
||||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||||
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
||||||
|
|
||||||
|
@ -62,20 +61,6 @@ public interface ArchivaAdministrationService
|
||||||
Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path )
|
Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
@Path( "getRepositoryScanning" )
|
|
||||||
@GET
|
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
|
||||||
RepositoryScanning getRepositoryScanning()
|
|
||||||
throws ArchivaRestServiceException;
|
|
||||||
|
|
||||||
@Path( "updateRepositoryScanning" )
|
|
||||||
@POST
|
|
||||||
@Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
|
||||||
void updateRepositoryScanning( RepositoryScanning repositoryScanning )
|
|
||||||
throws ArchivaRestServiceException;
|
|
||||||
|
|
||||||
@Path( "addFileTypePattern" )
|
@Path( "addFileTypePattern" )
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
|
@ -95,7 +80,7 @@ public interface ArchivaAdministrationService
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
FileType getFileType( String fileTypeId )
|
FileType getFileType( @QueryParam( "fileTypeId" ) String fileTypeId )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
@Path( "addFileType" )
|
@Path( "addFileType" )
|
||||||
|
@ -131,14 +116,14 @@ public interface ArchivaAdministrationService
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
Boolean removeKnownContentConsumer( @QueryParam( "knownContentConsumer" ) String knownContentConsumer )
|
Boolean removeKnownContentConsumer( @QueryParam( "knownContentConsumer" ) String knownContentConsumer )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
@Path( "addInvalidContentConsumer" )
|
@Path( "addInvalidContentConsumer" )
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
Boolean addInvalidContentConsumer(@QueryParam( "invalidContentConsumer" ) String invalidContentConsumer )
|
Boolean addInvalidContentConsumer( @QueryParam( "invalidContentConsumer" ) String invalidContentConsumer )
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
@Path( "setInvalidContentConsumers" )
|
@Path( "setInvalidContentConsumers" )
|
||||||
|
@ -152,6 +137,27 @@ public interface ArchivaAdministrationService
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
Boolean removeInvalidContentConsumer(@QueryParam( "invalidContentConsumer" ) String invalidContentConsumer )
|
Boolean removeInvalidContentConsumer( @QueryParam( "invalidContentConsumer" ) String invalidContentConsumer )
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path( "getFileTypes" )
|
||||||
|
@GET
|
||||||
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
|
List<FileType> getFileTypes()
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path( "getKnownContentConsumers" )
|
||||||
|
@GET
|
||||||
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
|
List<String> getKnownContentConsumers()
|
||||||
|
throws ArchivaRestServiceException;
|
||||||
|
|
||||||
|
@Path( "getInvalidContentConsumers" )
|
||||||
|
@GET
|
||||||
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
|
||||||
|
List<String> getInvalidContentConsumers()
|
||||||
throws ArchivaRestServiceException;
|
throws ArchivaRestServiceException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,11 @@
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>archiva-repository-admin</artifactId>
|
<artifactId>archiva-repository-admin</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-configuration</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.archiva</groupId>
|
<groupId>org.apache.archiva</groupId>
|
||||||
<artifactId>audit</artifactId>
|
<artifactId>audit</artifactId>
|
||||||
|
|
|
@ -18,19 +18,18 @@ package org.apache.archiva.rest.services;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import net.sf.beanlib.provider.BeanTransformer;
|
|
||||||
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
||||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
||||||
import org.apache.archiva.rest.api.model.FileType;
|
import org.apache.archiva.rest.api.model.FileType;
|
||||||
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
|
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
|
||||||
import org.apache.archiva.rest.api.model.RepositoryScanning;
|
|
||||||
import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
|
import org.apache.archiva.rest.api.services.ArchivaAdministrationService;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,51 +92,6 @@ public class DefaultArchivaAdministrationService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RepositoryScanning getRepositoryScanning()
|
|
||||||
throws ArchivaRestServiceException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
BeanTransformer beanTransformer = new BeanTransformer()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected <T> T createToInstance( Object from, Class<T> toClass )
|
|
||||||
throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
|
|
||||||
{
|
|
||||||
if ( from.getClass().equals( org.apache.maven.archiva.configuration.FileType.class ) )
|
|
||||||
{
|
|
||||||
return (T) new FileType();
|
|
||||||
}
|
|
||||||
return super.createToInstance( from, toClass );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
BeanReplicator beanReplicator = new BeanReplicator( beanTransformer );
|
|
||||||
|
|
||||||
RepositoryScanning repositoryScanning =
|
|
||||||
beanReplicator.replicateBean( archivaAdministration.getRepositoryScanning(), RepositoryScanning.class );
|
|
||||||
|
|
||||||
return repositoryScanning;
|
|
||||||
}
|
|
||||||
catch ( RepositoryAdminException e )
|
|
||||||
{
|
|
||||||
throw new ArchivaRestServiceException( e.getMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateRepositoryScanning( RepositoryScanning repositoryScanning )
|
|
||||||
throws ArchivaRestServiceException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
archivaAdministration.updateRepositoryScanning( new BeanReplicator().replicateBean( getRepositoryScanning(),
|
|
||||||
org.apache.archiva.admin.repository.admin.RepositoryScanning.class ),
|
|
||||||
getAuditInformation() );
|
|
||||||
}
|
|
||||||
catch ( RepositoryAdminException e )
|
|
||||||
{
|
|
||||||
throw new ArchivaRestServiceException( e.getMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean addFileTypePattern( String fileTypeId, String pattern )
|
public Boolean addFileTypePattern( String fileTypeId, String pattern )
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
|
@ -296,4 +250,54 @@ public class DefaultArchivaAdministrationService
|
||||||
throw new ArchivaRestServiceException( e.getMessage() );
|
throw new ArchivaRestServiceException( e.getMessage() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<FileType> getFileTypes()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<org.apache.archiva.admin.repository.admin.FileType> modelfileTypes =
|
||||||
|
archivaAdministration.getFileTypes();
|
||||||
|
if ( modelfileTypes == null || modelfileTypes.isEmpty() )
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<FileType> fileTypes = new ArrayList<FileType>( modelfileTypes.size() );
|
||||||
|
for ( org.apache.archiva.admin.repository.admin.FileType fileType : modelfileTypes )
|
||||||
|
{
|
||||||
|
fileTypes.add( new BeanReplicator().replicateBean( fileType, FileType.class ) );
|
||||||
|
}
|
||||||
|
return fileTypes;
|
||||||
|
}
|
||||||
|
catch ( RepositoryAdminException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaRestServiceException( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getKnownContentConsumers()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new ArrayList<String>( archivaAdministration.getKnownContentConsumers() );
|
||||||
|
}
|
||||||
|
catch ( RepositoryAdminException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaRestServiceException( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getInvalidContentConsumers()
|
||||||
|
throws ArchivaRestServiceException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return new ArrayList<String>( archivaAdministration.getInvalidContentConsumers() );
|
||||||
|
}
|
||||||
|
catch ( RepositoryAdminException e )
|
||||||
|
{
|
||||||
|
throw new ArchivaRestServiceException( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,9 @@ package org.apache.archiva.rest.services;
|
||||||
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
|
||||||
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
import org.apache.archiva.metadata.repository.RepositorySessionFactory;
|
||||||
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
|
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
|
||||||
import org.apache.archiva.rest.api.model.RemoteRepository;
|
|
||||||
import org.apache.archiva.rest.api.services.RepositoriesService;
|
import org.apache.archiva.rest.api.services.RepositoriesService;
|
||||||
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
|
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
|
||||||
import org.apache.archiva.scheduler.repository.RepositoryTask;
|
import org.apache.archiva.scheduler.repository.RepositoryTask;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
|
||||||
import org.apache.maven.archiva.configuration.Configuration;
|
|
||||||
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
|
||||||
import org.codehaus.plexus.redback.role.RoleManager;
|
import org.codehaus.plexus.redback.role.RoleManager;
|
||||||
import org.codehaus.plexus.registry.Registry;
|
import org.codehaus.plexus.registry.Registry;
|
||||||
import org.codehaus.plexus.taskqueue.TaskQueueException;
|
import org.codehaus.plexus.taskqueue.TaskQueueException;
|
||||||
|
@ -39,8 +35,6 @@ import org.springframework.stereotype.Service;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.ws.rs.PathParam;
|
import javax.ws.rs.PathParam;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
|
@ -53,36 +47,13 @@ public class DefaultRepositoriesService
|
||||||
{
|
{
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||||
|
|
||||||
// FIXME duplicate from xmlrpc
|
|
||||||
// olamy move this to a common remote services api
|
|
||||||
private static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
|
|
||||||
|
|
||||||
private static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$";
|
|
||||||
|
|
||||||
private static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&=\\\\]+$";
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected RoleManager roleManager;
|
protected RoleManager roleManager;
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected ArchivaConfiguration archivaConfiguration;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named( value = "archivaTaskScheduler#repository" )
|
@Named( value = "archivaTaskScheduler#repository" )
|
||||||
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
|
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@Named( value = "commons-configuration" )
|
|
||||||
private Registry registry;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private RepositoryStatisticsManager repositoryStatisticsManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private RepositorySessionFactory repositorySessionFactory;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
|
||||||
|
|
||||||
// FIXME olamy move this to repository admin component !
|
// FIXME olamy move this to repository admin component !
|
||||||
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
||||||
|
|
|
@ -57,16 +57,21 @@ public class ArchivaAdministrationServiceTest
|
||||||
public void addAndDeleteFileType()
|
public void addAndDeleteFileType()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int initialSize = getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size();
|
int initialSize = getArchivaAdministrationService().getFileTypes().size();
|
||||||
FileType fileType = new FileType();
|
FileType fileType = new FileType();
|
||||||
fileType.setId( "foo" );
|
fileType.setId( "footwo" );
|
||||||
fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
|
fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
|
||||||
getArchivaAdministrationService().addFileType( fileType );
|
getArchivaAdministrationService().addFileType( fileType );
|
||||||
assertEquals( initialSize + 1,
|
assertEquals( initialSize + 1, getArchivaAdministrationService().getFileTypes().size() );
|
||||||
getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size() );
|
|
||||||
|
|
||||||
assertNotNull( getArchivaAdministrationService().getFileType( "foo" ) );
|
assertNotNull( getArchivaAdministrationService().getFileType( "footwo" ) );
|
||||||
assertEquals( Arrays.asList( "foo", "bar" ),
|
assertEquals( Arrays.asList( "foo", "bar" ),
|
||||||
getArchivaAdministrationService().getFileType( "foo" ).getPatterns() );
|
getArchivaAdministrationService().getFileType( "footwo" ).getPatterns() );
|
||||||
|
|
||||||
|
getArchivaAdministrationService().removeFileType( "footwo" );
|
||||||
|
|
||||||
|
assertEquals( initialSize , getArchivaAdministrationService().getFileTypes().size() );
|
||||||
|
|
||||||
|
assertNull( getArchivaAdministrationService().getFileType( "footwo" ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,20 +191,20 @@ public class RepositoryScanningAction
|
||||||
public void prepare()
|
public void prepare()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
RepositoryScanning reposcanning = archivaAdministration.getRepositoryScanning();
|
|
||||||
|
|
||||||
FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
|
FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
|
||||||
|
|
||||||
CollectionUtils.forAllDo( reposcanning.getFileTypes(), filetypeToMapClosure );
|
CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
|
||||||
fileTypeMap = filetypeToMapClosure.getMap();
|
fileTypeMap = filetypeToMapClosure.getMap();
|
||||||
|
|
||||||
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
AddAdminRepoConsumerClosure addAdminRepoConsumer =
|
||||||
new AddAdminRepoConsumerClosure( reposcanning.getKnownContentConsumers() );
|
new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
|
||||||
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
|
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
|
||||||
this.knownContentConsumers = addAdminRepoConsumer.getList();
|
this.knownContentConsumers = addAdminRepoConsumer.getList();
|
||||||
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||||
|
|
||||||
addAdminRepoConsumer = new AddAdminRepoConsumerClosure( reposcanning.getInvalidContentConsumers() );
|
addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
|
||||||
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
|
CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
|
||||||
this.invalidContentConsumers = addAdminRepoConsumer.getList();
|
this.invalidContentConsumers = addAdminRepoConsumer.getList();
|
||||||
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
|
||||||
|
@ -229,7 +229,7 @@ public class RepositoryScanningAction
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<String> oldConsumers = getArchivaAdministration().getRepositoryScanning().getInvalidContentConsumers();
|
List<String> oldConsumers = getArchivaAdministration().getInvalidContentConsumers();
|
||||||
|
|
||||||
if ( enabledInvalidContentConsumers != null )
|
if ( enabledInvalidContentConsumers != null )
|
||||||
{
|
{
|
||||||
|
@ -270,7 +270,7 @@ public class RepositoryScanningAction
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<String> oldConsumers = getArchivaAdministration().getRepositoryScanning().getKnownContentConsumers();
|
List<String> oldConsumers = getArchivaAdministration().getKnownContentConsumers();
|
||||||
|
|
||||||
if ( enabledKnownContentConsumers != null )
|
if ( enabledKnownContentConsumers != null )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue