From: Olivier Lamy Date: Fri, 9 Sep 2011 14:38:09 +0000 (+0000) Subject: [MRM-1490] REST services : expose repository scanning configuration X-Git-Tag: archiva-1.4-M1~342 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=18a520223132dfc95724c83344f5de556174490e;p=archiva.git [MRM-1490] REST services : expose repository scanning configuration git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167218 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/LegacyArtifactPath.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/LegacyArtifactPath.java index ce4ac95c0..d5e64cf9c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/LegacyArtifactPath.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/LegacyArtifactPath.java @@ -101,4 +101,15 @@ public class LegacyArtifactPath { return artifact.split( ":" )[4]; } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "LegacyArtifactPath" ); + sb.append( "{path='" ).append( path ).append( '\'' ); + sb.append( ", artifact='" ).append( artifact ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java index 209963825..1148b5e3d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java @@ -19,7 +19,9 @@ package org.apache.archiva.rest.api.services; */ import org.apache.archiva.admin.repository.RepositoryAdminException; +import org.apache.archiva.rest.api.model.FileType; 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.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -60,4 +62,97 @@ public interface ArchivaAdministrationService @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path ) throws RepositoryAdminException; + + @Path( "getRepositoryScanning" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + RepositoryScanning getRepositoryScanning() + throws RepositoryAdminException; + + @Path( "updateRepositoryScanning" ) + @POST + @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + void updateRepositoryScanning( RepositoryScanning repositoryScanning ) + throws RepositoryAdminException; + + @Path( "addFileTypePattern" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean addFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, @QueryParam( "pattern" ) String pattern ) + throws RepositoryAdminException; + + @Path( "removeFileTypePattern" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean removeFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, + @QueryParam( "pattern" ) String pattern ) + throws RepositoryAdminException; + + @Path( "getFileType" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + FileType getFileType( String fileTypeId ) + throws RepositoryAdminException; + + @Path( "addFileType" ) + @POST + @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + void addFileType( FileType fileType ) + throws RepositoryAdminException; + + @Path( "removeFileType" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean removeFileType( @QueryParam( "fileTypeId" ) String fileTypeId ) + throws RepositoryAdminException; + + @Path( "addKnownContentConsumer" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean addKnownContentConsumer( @QueryParam( "knownContentConsumer" ) String knownContentConsumer ) + throws RepositoryAdminException; + + @Path( "setKnownContentConsumers" ) + @POST + @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + void setKnownContentConsumers( List knownContentConsumers ) + throws RepositoryAdminException; + + + @Path( "removeKnownContentConsumer" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean removeKnownContentConsumer( @QueryParam( "knownContentConsumer" ) String knownContentConsumer ) + throws RepositoryAdminException; + + @Path( "addInvalidContentConsumer" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean addInvalidContentConsumer(@QueryParam( "invalidContentConsumer" ) String invalidContentConsumer ) + throws RepositoryAdminException; + + @Path( "setInvalidContentConsumers" ) + @POST + @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + void setInvalidContentConsumers( List invalidContentConsumers ) + throws RepositoryAdminException; + + @Path( "removeInvalidContentConsumer" ) + @GET + @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) + @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) + Boolean removeInvalidContentConsumer(@QueryParam( "invalidContentConsumer" ) String invalidContentConsumer ) + throws RepositoryAdminException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java index 8d19a274a..c4b22be36 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java @@ -21,7 +21,9 @@ package org.apache.archiva.rest.services; import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.admin.ArchivaAdministration; +import org.apache.archiva.rest.api.model.FileType; 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.springframework.stereotype.Service; @@ -67,4 +69,100 @@ public class DefaultArchivaAdministrationService archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() ); return Boolean.TRUE; } + + public RepositoryScanning getRepositoryScanning() + throws RepositoryAdminException + { + return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(), + RepositoryScanning.class ); + } + + public void updateRepositoryScanning( RepositoryScanning repositoryScanning ) + throws RepositoryAdminException + { + archivaAdministration.updateRepositoryScanning( new BeanReplicator().replicateBean( getRepositoryScanning(), + org.apache.archiva.admin.repository.admin.RepositoryScanning.class ), + getAuditInformation() ); + } + + public Boolean addFileTypePattern( String fileTypeId, String pattern ) + throws RepositoryAdminException + { + archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() ); + return Boolean.TRUE; + } + + public Boolean removeFileTypePattern( String fileTypeId, String pattern ) + throws RepositoryAdminException + { + archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() ); + return Boolean.TRUE; + } + + public FileType getFileType( String fileTypeId ) + throws RepositoryAdminException + { + org.apache.archiva.admin.repository.admin.FileType fileType = archivaAdministration.getFileType( fileTypeId ); + if ( fileType == null ) + { + return null; + } + return new BeanReplicator().replicateBean( fileType, FileType.class ); + } + + public void addFileType( FileType fileType ) + throws RepositoryAdminException + { + archivaAdministration.addFileType( + new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.repository.admin.FileType.class ), + getAuditInformation() ); + + } + + public Boolean removeFileType( String fileTypeId ) + throws RepositoryAdminException + { + archivaAdministration.removeFileType( fileTypeId, getAuditInformation() ); + return Boolean.TRUE; + } + + public Boolean addKnownContentConsumer( String knownContentConsumer ) + throws RepositoryAdminException + { + archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + + public void setKnownContentConsumers( List knownContentConsumers ) + throws RepositoryAdminException + { + archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() ); + } + + public Boolean removeKnownContentConsumer( String knownContentConsumer ) + throws RepositoryAdminException + { + archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + + public Boolean addInvalidContentConsumer( String invalidContentConsumer ) + throws RepositoryAdminException + { + archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + + public void setInvalidContentConsumers( List invalidContentConsumers ) + throws RepositoryAdminException + { + archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() ); + } + + public Boolean removeInvalidContentConsumer( String invalidContentConsumer ) + throws RepositoryAdminException + { + archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } }