From: Olivier Lamy Date: Fri, 3 Feb 2012 18:07:38 +0000 (+0000) Subject: when validating if a repo id exists we must validated against managed,remote and... X-Git-Tag: archiva-1.4-M3~1370 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2bd6b1b039cd2c42fa1cb19a1a8d210571f3a354;p=archiva.git when validating if a repo id exists we must validated against managed,remote and group git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1240272 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultDataValidatorService.java b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultDataValidatorService.java index 90f5eb07a..5f98c5a19 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultDataValidatorService.java +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultDataValidatorService.java @@ -19,6 +19,7 @@ package org.apache.archiva.webapp.ui.services.api; */ import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; @@ -45,13 +46,16 @@ public class DefaultDataValidatorService @Inject private NetworkProxyAdmin networkProxyAdmin; + @Inject + private RepositoryGroupAdmin repositoryGroupAdmin; + public Boolean managedRepositoryIdNotExists( String id ) throws ArchivaRestServiceException { try { - return managedRepositoryAdmin.getManagedRepository( id ) == null; + return !idExist( id ); } catch ( RepositoryAdminException e ) { @@ -64,7 +68,7 @@ public class DefaultDataValidatorService { try { - return remoteRepositoryAdmin.getRemoteRepository( id ) == null; + return !idExist( id ); } catch ( RepositoryAdminException e ) { @@ -84,4 +88,18 @@ public class DefaultDataValidatorService throw new ArchivaRestServiceException( e.getMessage() ); } } + + /** + * check if managedRepo, remoteRepo ou group exists with this id + * + * @param id + * @return true if something exists with this id. + */ + private Boolean idExist( String id ) + throws RepositoryAdminException + { + return ( managedRepositoryAdmin.getManagedRepository( id ) != null ) || ( + remoteRepositoryAdmin.getRemoteRepository( id ) != null ) || ( repositoryGroupAdmin.getRepositoryGroup( id ) + != null ); + } }