*/
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;
@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 )
{
{
try
{
- return remoteRepositoryAdmin.getRemoteRepository( id ) == null;
+ return !idExist( id );
}
catch ( RepositoryAdminException e )
{
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 );
+ }
}