From 7ab4f2823239961ebe49217a08c11280f2815767 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 9 Sep 2011 14:39:19 +0000 Subject: [PATCH] [MRM-1490] REST services : fix bad design as rest-api introduced a dependency on repo admin api : when using rest services you need to depend only on the remote api not internal to implementation git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167220 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-rest/archiva-rest-api/pom.xml | 5 - .../rest/api/model/RepositoryScanning.java | 5 +- .../ArchivaAdministrationService.java | 33 ++- .../services/ManagedRepositoriesService.java | 5 +- .../api/services/NetworkProxyService.java | 11 +- .../api/services/ProxyConnectorService.java | 12 +- .../services/RemoteRepositoriesService.java | 7 +- .../api/services/RepositoryGroupService.java | 15 +- .../DefaultArchivaAdministrationService.java | 223 +++++++++++++----- .../DefaultManagedRepositoriesService.java | 36 +-- .../services/DefaultNetworkProxyService.java | 80 +++++-- .../DefaultProxyConnectorService.java | 85 +++++-- .../DefaultRemoteRepositoriesService.java | 29 ++- .../DefaultRepositoryGroupService.java | 86 +++++-- 14 files changed, 430 insertions(+), 202 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml index aaf0e26c3..005a95101 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml @@ -33,11 +33,6 @@ archiva-security - - org.apache.archiva - archiva-repository-admin - - org.codehaus.redback redback-authorization-api diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RepositoryScanning.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RepositoryScanning.java index 2810e2065..870b9c3ed 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RepositoryScanning.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/RepositoryScanning.java @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.model; * under the License. */ -import org.apache.archiva.admin.repository.admin.FileType; import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; @@ -52,8 +51,8 @@ public class RepositoryScanning // no op } - public RepositoryScanning( List fileTypes, - List knownContentConsumers, List invalidContentConsumers ) + public RepositoryScanning( List fileTypes, List knownContentConsumers, + List invalidContentConsumers ) { this.fileTypes = fileTypes; this.knownContentConsumers = knownContentConsumers; 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 1148b5e3d..6f24e382d 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 @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -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; @@ -46,7 +45,7 @@ public interface ArchivaAdministrationService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getLegacyArtifactPaths() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addLegacyArtifactPath" ) @POST @@ -54,35 +53,35 @@ public interface ArchivaAdministrationService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteLegacyArtifactPath" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getRepositoryScanning" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) RepositoryScanning getRepositoryScanning() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "updateRepositoryScanning" ) @POST @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void updateRepositoryScanning( RepositoryScanning repositoryScanning ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; @Path( "removeFileTypePattern" ) @GET @@ -90,42 +89,42 @@ public interface ArchivaAdministrationService @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean removeFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, @QueryParam( "pattern" ) String pattern ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; @Path( "addFileType" ) @POST @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void addFileType( FileType fileType ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; @Path( "setKnownContentConsumers" ) @POST @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void setKnownContentConsumers( List knownContentConsumers ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "removeKnownContentConsumer" ) @@ -133,26 +132,26 @@ public interface ArchivaAdministrationService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean removeKnownContentConsumer( @QueryParam( "knownContentConsumer" ) String knownContentConsumer ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; @Path( "setInvalidContentConsumers" ) @POST @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void setInvalidContentConsumers( List invalidContentConsumers ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @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; + throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java index c224c6bd0..af59a972f 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java @@ -19,7 +19,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.rest.api.model.ManagedRepository; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -46,14 +45,14 @@ public interface ManagedRepositoriesService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getManagedRepositories() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getManagedRepository/{repositoryId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) ManagedRepository getManagedRepository( @PathParam( "repositoryId" ) String repositoryId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteManagedRepository" ) @GET diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java index d1850e212..7913cbaf4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.rest.api.model.NetworkProxy; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -44,14 +43,14 @@ public interface NetworkProxyService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getNetworkProxies() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getNetworkProxy/{networkProxyId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) NetworkProxy getNetworkProxy( @PathParam( "networkProxyId" ) String networkProxyId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addNetworkProxy" ) @POST @@ -59,7 +58,7 @@ public interface NetworkProxyService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void addNetworkProxy( NetworkProxy networkProxy ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "updateNetworkProxy" ) @POST @@ -67,12 +66,12 @@ public interface NetworkProxyService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) void updateNetworkProxy( NetworkProxy networkProxy ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteNetworkProxy/{networkProxyId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteNetworkProxy( @PathParam( "networkProxyId" ) String networkProxyId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java index be3a168fd..e55232ec8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.rest.api.model.ProxyConnector; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -46,7 +45,7 @@ public interface ProxyConnectorService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getProxyConnectors() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getProxyConnector" ) @GET @@ -54,7 +53,7 @@ public interface ProxyConnectorService @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) ProxyConnector getProxyConnector( @QueryParam( "sourceRepoId" ) String sourceRepoId, @QueryParam( "targetRepoId" ) String targetRepoId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addProxyConnector" ) @POST @@ -62,7 +61,7 @@ public interface ProxyConnectorService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean addProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteProxyConnector" ) @POST @@ -70,14 +69,13 @@ public interface ProxyConnectorService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; /** * only for enabled/disable or changing bean values except target/source * * @param proxyConnector * @return - * @throws org.apache.archiva.admin.repository.RepositoryAdminException * */ @Path( "updateProxyConnector" ) @@ -86,7 +84,7 @@ public interface ProxyConnectorService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean updateProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java index 20a4b8b37..d5e85eeba 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java @@ -19,8 +19,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; -import org.apache.archiva.rest.api.model.ManagedRepository; import org.apache.archiva.rest.api.model.RemoteRepository; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -31,7 +29,6 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import java.util.List; @@ -47,14 +44,14 @@ public interface RemoteRepositoriesService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getRemoteRepositories() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getRemoteRepository/{repositoryId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) RemoteRepository getRemoteRepository( @PathParam( "repositoryId" ) String repositoryId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteRemoteRepository/{repositoryId}" ) @GET diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java index fd26e24df..4c20da16d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java @@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.services; * under the License. */ -import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.rest.api.model.RepositoryGroup; import org.apache.archiva.security.common.ArchivaRoleConstants; import org.codehaus.plexus.redback.authorization.RedbackAuthorization; @@ -45,14 +44,14 @@ public interface RepositoryGroupService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) List getRepositoriesGroups() - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "getRepositoryGroup/{repositoryGroupId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) RepositoryGroup getRepositoryGroup( @PathParam( "repositoryGroupId" ) String repositoryGroupId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addRepositoryGroup" ) @POST @@ -60,7 +59,7 @@ public interface RepositoryGroupService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean addRepositoryGroup( RepositoryGroup repositoryGroup ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "updateRepositoryGroup" ) @POST @@ -68,14 +67,14 @@ public interface RepositoryGroupService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "deleteRepositoryGroup/{repositoryGroupId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteRepositoryGroup( @PathParam( "repositoryGroupId" ) String repositoryGroupId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addRepositoryToGroup" ) @GET @@ -83,7 +82,7 @@ public interface RepositoryGroupService @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean addRepositoryToGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, @QueryParam( "repositoryId" ) String repositoryId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; @Path( "addRepositoryToGroup" ) @GET @@ -91,7 +90,7 @@ public interface RepositoryGroupService @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) Boolean deleteRepositoryFromGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, @QueryParam( "repositoryId" ) String repositoryId ) - throws RepositoryAdminException; + throws ArchivaRestServiceException; } 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 c4b22be36..880e2d918 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 @@ -25,6 +25,7 @@ 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.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.springframework.stereotype.Service; import javax.inject.Inject; @@ -44,125 +45,237 @@ public class DefaultArchivaAdministrationService private ArchivaAdministration archivaAdministration; public List getLegacyArtifactPaths() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List legacyArtifactPaths = new ArrayList(); - for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() ) + try { - legacyArtifactPaths.add( - new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) ); + List legacyArtifactPaths = new ArrayList(); + for ( org.apache.archiva.admin.repository.admin.LegacyArtifactPath legacyArtifactPath : archivaAdministration.getLegacyArtifactPaths() ) + { + legacyArtifactPaths.add( + new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) ); + } + return legacyArtifactPaths; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - return legacyArtifactPaths; } public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath, - org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ), - getAuditInformation() ); + try + { + archivaAdministration.addLegacyArtifactPath( new BeanReplicator().replicateBean( legacyArtifactPath, + org.apache.archiva.admin.repository.admin.LegacyArtifactPath.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean deleteLegacyArtifactPath( String path ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public RepositoryScanning getRepositoryScanning() - throws RepositoryAdminException + throws ArchivaRestServiceException { - return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(), - RepositoryScanning.class ); + try + { + return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(), + RepositoryScanning.class ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public void updateRepositoryScanning( RepositoryScanning repositoryScanning ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.updateRepositoryScanning( new BeanReplicator().replicateBean( getRepositoryScanning(), - org.apache.archiva.admin.repository.admin.RepositoryScanning.class ), - getAuditInformation() ); + 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 ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean removeFileTypePattern( String fileTypeId, String pattern ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public FileType getFileType( String fileTypeId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - org.apache.archiva.admin.repository.admin.FileType fileType = archivaAdministration.getFileType( fileTypeId ); - if ( fileType == null ) + try + { + org.apache.archiva.admin.repository.admin.FileType fileType = + archivaAdministration.getFileType( fileTypeId ); + if ( fileType == null ) + { + return null; + } + return new BeanReplicator().replicateBean( fileType, FileType.class ); + } + catch ( RepositoryAdminException e ) { - return null; + throw new ArchivaRestServiceException( e.getMessage() ); } - return new BeanReplicator().replicateBean( fileType, FileType.class ); } public void addFileType( FileType fileType ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.addFileType( - new BeanReplicator().replicateBean( fileType, org.apache.archiva.admin.repository.admin.FileType.class ), - getAuditInformation() ); - + try + { + archivaAdministration.addFileType( new BeanReplicator().replicateBean( fileType, + org.apache.archiva.admin.repository.admin.FileType.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean removeFileType( String fileTypeId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.removeFileType( fileTypeId, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.removeFileType( fileTypeId, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean addKnownContentConsumer( String knownContentConsumer ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public void setKnownContentConsumers( List knownContentConsumers ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() ); + try + { + archivaAdministration.setKnownContentConsumers( knownContentConsumers, getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean removeKnownContentConsumer( String knownContentConsumer ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean addInvalidContentConsumer( String invalidContentConsumer ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public void setInvalidContentConsumers( List invalidContentConsumers ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() ); + try + { + archivaAdministration.setInvalidContentConsumers( invalidContentConsumers, getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean removeInvalidContentConsumer( String invalidContentConsumer ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + try + { + archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java index a275f0d4f..f473abc58 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin; import org.apache.archiva.rest.api.model.ManagedRepository; +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ManagedRepositoriesService; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -43,28 +44,35 @@ public class DefaultManagedRepositoriesService private ManagedRepositoryAdmin managedRepositoryAdmin; public List getManagedRepositories() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List repos = - managedRepositoryAdmin.getManagedRepositories(); + try + { + List repos = + managedRepositoryAdmin.getManagedRepositories(); + + List managedRepos = new ArrayList( repos.size() ); - List managedRepos = new ArrayList( repos.size() ); + for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : repos ) + { + // TODO staging repo too + ManagedRepository repo = + new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), + repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(), + repoConfig.isBlockRedeployments(), false, repoConfig.getCronExpression() ); + managedRepos.add( repo ); + } - for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : repos ) + return managedRepos; + } + catch ( RepositoryAdminException e ) { - // TODO staging repo too - ManagedRepository repo = - new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), - repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(), - repoConfig.isBlockRedeployments(), false, repoConfig.getCronExpression() ); - managedRepos.add( repo ); + throw new ArchivaRestServiceException( e.getMessage() ); } - - return managedRepos; } public ManagedRepository getManagedRepository( String repositoryId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { List repos = getManagedRepositories(); for ( ManagedRepository repo : repos ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java index cf046febb..5e23c9ff0 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java @@ -22,6 +22,7 @@ import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.networkproxy.NetworkProxyAdmin; import org.apache.archiva.rest.api.model.NetworkProxy; +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.NetworkProxyService; import org.springframework.stereotype.Service; @@ -41,53 +42,88 @@ public class DefaultNetworkProxyService private NetworkProxyAdmin networkProxyAdmin; public List getNetworkProxies() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List networkProxies = new ArrayList(); - for ( org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() ) + try { - networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) ); + List networkProxies = new ArrayList(); + for ( org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() ) + { + networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) ); + } + return networkProxies; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - return networkProxies; } public NetworkProxy getNetworkProxy( String networkProxyId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy = - networkProxyAdmin.getNetworkProxy( networkProxyId ); - return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ); + try + { + org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy = + networkProxyAdmin.getNetworkProxy( networkProxyId ); + return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public void addNetworkProxy( NetworkProxy networkProxy ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - if ( networkProxy == null ) + try { - return; + if ( networkProxy == null ) + { + return; + } + getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy, + org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy, - org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ), - getAuditInformation() ); } public void updateNetworkProxy( NetworkProxy networkProxy ) - throws RepositoryAdminException + throws ArchivaRestServiceException { if ( networkProxy == null ) { return; } - getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy, - org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ), - getAuditInformation() ); + try + { + getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy, + org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean deleteNetworkProxy( String networkProxyId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() ); - return Boolean.TRUE; + try + { + getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() ); + return Boolean.TRUE; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public NetworkProxyAdmin getNetworkProxyAdmin() diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java index 50cd6b647..24087aa06 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java @@ -22,15 +22,13 @@ import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.rest.api.model.ProxyConnector; +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ProxyConnectorService; import org.springframework.stereotype.Service; import javax.inject.Inject; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * @author Olivier Lamy @@ -44,60 +42,95 @@ public class DefaultProxyConnectorService private ProxyConnectorAdmin proxyConnectorAdmin; public List getProxyConnectors() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List proxyConnectors = new ArrayList(); - for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() ) + try { - proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) ); + List proxyConnectors = new ArrayList(); + for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() ) + { + proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) ); + } + return proxyConnectors; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - return proxyConnectors; } public ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector = - proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId ); - return proxyConnector == null - ? null - : new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ); + try + { + org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector = + proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId ); + return proxyConnector == null + ? null + : new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean addProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException + throws ArchivaRestServiceException { if ( proxyConnector == null ) { return Boolean.FALSE; } - return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector, - org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), - getAuditInformation() ); + try + { + return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector, + org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean deleteProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException + throws ArchivaRestServiceException { if ( proxyConnector == null ) { return Boolean.FALSE; } - return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector, - org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), - getAuditInformation() ); + try + { + return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector, + org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean updateProxyConnector( ProxyConnector proxyConnector ) - throws RepositoryAdminException + throws ArchivaRestServiceException { if ( proxyConnector == null ) { return Boolean.FALSE; } - return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector, - org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), - getAuditInformation() ); + try + { + return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector, + org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ), + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public ProxyConnectorAdmin getProxyConnectorAdmin() diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java index bd808a2e3..9f3eeeb8d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin; import org.apache.archiva.rest.api.model.RemoteRepository; +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RemoteRepositoriesService; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -43,22 +44,30 @@ public class DefaultRemoteRepositoriesService private RemoteRepositoryAdmin remoteRepositoryAdmin; public List getRemoteRepositories() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List remoteRepositories = new ArrayList(); - for ( org.apache.archiva.admin.repository.remote.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() ) + try { - RemoteRepository repo = - new RemoteRepository( remoteRepository.getId(), remoteRepository.getName(), remoteRepository.getUrl(), - remoteRepository.getLayout(), remoteRepository.getUserName(), - remoteRepository.getPassword(), remoteRepository.getTimeout() ); - remoteRepositories.add( repo ); + List remoteRepositories = new ArrayList(); + for ( org.apache.archiva.admin.repository.remote.RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() ) + { + RemoteRepository repo = new RemoteRepository( remoteRepository.getId(), remoteRepository.getName(), + remoteRepository.getUrl(), remoteRepository.getLayout(), + remoteRepository.getUserName(), + remoteRepository.getPassword(), + remoteRepository.getTimeout() ); + remoteRepositories.add( repo ); + } + return remoteRepositories; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - return remoteRepositories; } public RemoteRepository getRemoteRepository( String repositoryId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { List remoteRepositories = getRemoteRepositories(); for ( RemoteRepository repository : remoteRepositories ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java index 500623995..e68bdd1a8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.repository.RepositoryAdminException; import org.apache.archiva.admin.repository.group.RepositoryGroupAdmin; import org.apache.archiva.rest.api.model.RepositoryGroup; +import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RepositoryGroupService; import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; @@ -42,19 +43,26 @@ public class DefaultRepositoryGroupService private RepositoryGroupAdmin repositoryGroupAdmin; public List getRepositoriesGroups() - throws RepositoryAdminException + throws ArchivaRestServiceException { - List repositoriesGroups = new ArrayList(); - for ( org.apache.archiva.admin.repository.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() ) + try { - repositoriesGroups.add( - new RepositoryGroup( repoGroup.getId(), new ArrayList( repoGroup.getRepositories() ) ) ); + List repositoriesGroups = new ArrayList(); + for ( org.apache.archiva.admin.repository.group.RepositoryGroup repoGroup : repositoryGroupAdmin.getRepositoriesGroups() ) + { + repositoriesGroups.add( + new RepositoryGroup( repoGroup.getId(), new ArrayList( repoGroup.getRepositories() ) ) ); + } + return repositoriesGroups; + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); } - return repositoriesGroups; } public RepositoryGroup getRepositoryGroup( String repositoryGroupId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() ) { @@ -67,36 +75,72 @@ public class DefaultRepositoryGroupService } public Boolean addRepositoryGroup( RepositoryGroup repoGroup ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - return repositoryGroupAdmin.addRepositoryGroup( - new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList( - repoGroup.getRepositories() ) ), getAuditInformation() ); + try + { + return repositoryGroupAdmin.addRepositoryGroup( + new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList( + repoGroup.getRepositories() ) ), getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean updateRepositoryGroup( RepositoryGroup repoGroup ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - return repositoryGroupAdmin.updateRepositoryGroup( - new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList( - repoGroup.getRepositories() ) ), getAuditInformation() ); + try + { + return repositoryGroupAdmin.updateRepositoryGroup( + new org.apache.archiva.admin.repository.group.RepositoryGroup( repoGroup.getId(), new ArrayList( + repoGroup.getRepositories() ) ), getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean deleteRepositoryGroup( String repositoryGroupId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() ); + try + { + return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() ); + try + { + return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId ) - throws RepositoryAdminException + throws ArchivaRestServiceException { - return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, getAuditInformation() ); + try + { + return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, + getAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + throw new ArchivaRestServiceException( e.getMessage() ); + } } } -- 2.39.5