]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1490] REST services : expose repository scanning configuration
authorOlivier Lamy <olamy@apache.org>
Fri, 9 Sep 2011 14:38:09 +0000 (14:38 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 9 Sep 2011 14:38:09 +0000 (14:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167218 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/LegacyArtifactPath.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java

index ce4ac95c02cbd3023bdc5c91e855e52b654ed34b..d5e64cf9c0ba47be16cf8d3fbfc2d3b9bf3f2fdd 100644 (file)
@@ -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();
+    }
 }
index 209963825083ce015dbc4c33a4c11ce34439284e..1148b5e3d8b82a7783c9559b188d9948c9748b23 100644 (file)
@@ -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<String> 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<String> 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;
 }
index 8d19a274acd9c47e038722e1eedc6091e3b3bd1a..c4b22be36bec342f85235ca036d8753c834f094b 100644 (file)
@@ -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<String> 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<String> invalidContentConsumers )
+        throws RepositoryAdminException
+    {
+        archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() );
+    }
+
+    public Boolean removeInvalidContentConsumer( String invalidContentConsumer )
+        throws RepositoryAdminException
+    {
+        archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() );
+        return Boolean.TRUE;
+    }
 }