]> source.dussan.org Git - archiva.git/commitdiff
when validating if a repo id exists we must validated against managed,remote and...
authorOlivier Lamy <olamy@apache.org>
Fri, 3 Feb 2012 18:07:38 +0000 (18:07 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 3 Feb 2012 18:07:38 +0000 (18:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1240272 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/java/org/apache/archiva/webapp/ui/services/api/DefaultDataValidatorService.java

index 90f5eb07a66607a32ee1c329dd1661bcab9b18e2..5f98c5a19074ea5a6892dd51c1ca0f93ea8f78e6 100644 (file)
@@ -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 );
+    }
 }