1 package org.apache.archiva.rest.services;
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 net.sf.beanlib.provider.replicator.BeanReplicator;
22 import org.apache.archiva.admin.repository.RepositoryAdminException;
23 import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
24 import org.apache.archiva.rest.api.model.ProxyConnector;
25 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
26 import org.apache.archiva.rest.api.services.ProxyConnectorService;
27 import org.springframework.stereotype.Service;
29 import javax.inject.Inject;
30 import java.util.ArrayList;
31 import java.util.List;
34 * @author Olivier Lamy
36 @Service( "proxyConnectorService#rest" )
37 public class DefaultProxyConnectorService
38 extends AbstractRestService
39 implements ProxyConnectorService
42 private ProxyConnectorAdmin proxyConnectorAdmin;
44 public List<ProxyConnector> getProxyConnectors()
45 throws ArchivaRestServiceException
49 List<ProxyConnector> proxyConnectors = new ArrayList<ProxyConnector>();
50 for ( org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() )
52 proxyConnectors.add( new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class ) );
54 return proxyConnectors;
56 catch ( RepositoryAdminException e )
58 throw new ArchivaRestServiceException( e.getMessage() );
62 public ProxyConnector getProxyConnector( String sourceRepoId, String targetRepoId )
63 throws ArchivaRestServiceException
67 org.apache.archiva.admin.repository.proxyconnector.ProxyConnector proxyConnector =
68 proxyConnectorAdmin.getProxyConnector( sourceRepoId, targetRepoId );
69 return proxyConnector == null
71 : new BeanReplicator().replicateBean( proxyConnector, ProxyConnector.class );
73 catch ( RepositoryAdminException e )
75 throw new ArchivaRestServiceException( e.getMessage() );
79 public Boolean addProxyConnector( ProxyConnector proxyConnector )
80 throws ArchivaRestServiceException
82 if ( proxyConnector == null )
88 return proxyConnectorAdmin.addProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
89 org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
90 getAuditInformation() );
92 catch ( RepositoryAdminException e )
94 throw new ArchivaRestServiceException( e.getMessage() );
98 public Boolean deleteProxyConnector( ProxyConnector proxyConnector )
99 throws ArchivaRestServiceException
101 if ( proxyConnector == null )
103 return Boolean.FALSE;
107 return proxyConnectorAdmin.deleteProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
108 org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
109 getAuditInformation() );
111 catch ( RepositoryAdminException e )
113 throw new ArchivaRestServiceException( e.getMessage() );
117 public Boolean updateProxyConnector( ProxyConnector proxyConnector )
118 throws ArchivaRestServiceException
120 if ( proxyConnector == null )
122 return Boolean.FALSE;
126 return proxyConnectorAdmin.updateProxyConnector( new BeanReplicator().replicateBean( proxyConnector,
127 org.apache.archiva.admin.repository.proxyconnector.ProxyConnector.class ),
128 getAuditInformation() );
130 catch ( RepositoryAdminException e )
132 throw new ArchivaRestServiceException( e.getMessage() );
136 public ProxyConnectorAdmin getProxyConnectorAdmin()
138 return proxyConnectorAdmin;
141 public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
143 this.proxyConnectorAdmin = proxyConnectorAdmin;