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.networkproxy.NetworkProxyAdmin;
24 import org.apache.archiva.rest.api.model.NetworkProxy;
25 import org.apache.archiva.rest.api.services.NetworkProxyService;
26 import org.springframework.stereotype.Service;
28 import javax.inject.Inject;
29 import java.util.ArrayList;
30 import java.util.List;
33 * @author Olivier Lamy
35 @Service( "networkProxyService#rest" )
36 public class DefaultNetworkProxyService
37 extends AbstractRestService
38 implements NetworkProxyService
41 private NetworkProxyAdmin networkProxyAdmin;
43 public List<NetworkProxy> getNetworkProxies()
44 throws RepositoryAdminException
46 List<NetworkProxy> networkProxies = new ArrayList<NetworkProxy>();
47 for ( org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy : networkProxyAdmin.getNetworkProxies() )
49 networkProxies.add( new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class ) );
51 return networkProxies;
54 public NetworkProxy getNetworkProxy( String networkProxyId )
55 throws RepositoryAdminException
57 org.apache.archiva.admin.repository.networkproxy.NetworkProxy networkProxy =
58 networkProxyAdmin.getNetworkProxy( networkProxyId );
59 return networkProxy == null ? null : new BeanReplicator().replicateBean( networkProxy, NetworkProxy.class );
62 public void addNetworkProxy( NetworkProxy networkProxy )
63 throws RepositoryAdminException
65 if ( networkProxy == null )
69 getNetworkProxyAdmin().addNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
70 org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ),
71 getAuditInformation() );
74 public void updateNetworkProxy( NetworkProxy networkProxy )
75 throws RepositoryAdminException
77 if ( networkProxy == null )
81 getNetworkProxyAdmin().updateNetworkProxy( new BeanReplicator().replicateBean( networkProxy,
82 org.apache.archiva.admin.repository.networkproxy.NetworkProxy.class ),
83 getAuditInformation() );
86 public Boolean deleteNetworkProxy( String networkProxyId )
87 throws RepositoryAdminException
89 getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() );
93 public NetworkProxyAdmin getNetworkProxyAdmin()
95 return networkProxyAdmin;
98 public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
100 this.networkProxyAdmin = networkProxyAdmin;