1 package org.apache.archiva.webapp.ui.services.api;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.group.RepositoryGroupAdmin;
23 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
24 import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
25 import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
26 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
27 import org.springframework.stereotype.Service;
29 import javax.inject.Inject;
32 * @author Olivier Lamy
35 @Service( "dataValidatorService#rest" )
36 public class DefaultDataValidatorService
37 implements DataValidatorService
41 private ManagedRepositoryAdmin managedRepositoryAdmin;
44 private RemoteRepositoryAdmin remoteRepositoryAdmin;
47 private NetworkProxyAdmin networkProxyAdmin;
50 private RepositoryGroupAdmin repositoryGroupAdmin;
53 public Boolean managedRepositoryIdNotExists( String id )
54 throws ArchivaRestServiceException
58 return !idExist( id );
60 catch ( RepositoryAdminException e )
62 throw new ArchivaRestServiceException( e.getMessage(), e );
66 public Boolean remoteRepositoryIdNotExists( String id )
67 throws ArchivaRestServiceException
71 return !idExist( id );
73 catch ( RepositoryAdminException e )
75 throw new ArchivaRestServiceException( e.getMessage(), e );
79 public Boolean networkProxyIdNotExists( String id )
80 throws ArchivaRestServiceException
84 return networkProxyAdmin.getNetworkProxy( id ) == null;
86 catch ( RepositoryAdminException e )
88 throw new ArchivaRestServiceException( e.getMessage(), e );
93 * check if managedRepo, remoteRepo ou group exists with this id
96 * @return true if something exists with this id.
98 private Boolean idExist( String id )
99 throws RepositoryAdminException
101 return ( managedRepositoryAdmin.getManagedRepository( id ) != null ) || (
102 remoteRepositoryAdmin.getRemoteRepository( id ) != null ) || ( repositoryGroupAdmin.getRepositoryGroup( id )