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 org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.beans.NetworkProxy;
23 import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
24 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
25 import org.apache.archiva.rest.api.services.NetworkProxyService;
26 import org.springframework.stereotype.Service;
28 import javax.inject.Inject;
29 import java.util.Collections;
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;
44 public List<NetworkProxy> getNetworkProxies()
45 throws ArchivaRestServiceException
49 List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
50 return networkProxies == null ? Collections.<NetworkProxy>emptyList() : networkProxies;
52 catch ( RepositoryAdminException e )
54 throw new ArchivaRestServiceException( e.getMessage(), e );
59 public NetworkProxy getNetworkProxy( String networkProxyId )
60 throws ArchivaRestServiceException
64 return networkProxyAdmin.getNetworkProxy( networkProxyId );
66 catch ( RepositoryAdminException e )
68 throw new ArchivaRestServiceException( e.getMessage(), e );
73 public void addNetworkProxy( NetworkProxy networkProxy )
74 throws ArchivaRestServiceException
78 if ( networkProxy == null )
82 getNetworkProxyAdmin().addNetworkProxy( networkProxy, getAuditInformation() );
84 catch ( RepositoryAdminException e )
86 throw new ArchivaRestServiceException( e.getMessage(), e );
91 public void updateNetworkProxy( NetworkProxy networkProxy )
92 throws ArchivaRestServiceException
94 if ( networkProxy == null )
100 getNetworkProxyAdmin().updateNetworkProxy( networkProxy, getAuditInformation() );
102 catch ( RepositoryAdminException e )
104 throw new ArchivaRestServiceException( e.getMessage(), e );
109 public Boolean deleteNetworkProxy( String networkProxyId )
110 throws ArchivaRestServiceException
114 getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() );
117 catch ( RepositoryAdminException e )
119 throw new ArchivaRestServiceException( e.getMessage(), e );
123 public NetworkProxyAdmin getNetworkProxyAdmin()
125 return networkProxyAdmin;
128 public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
130 this.networkProxyAdmin = networkProxyAdmin;