This project has retired. For details please refer to its
Attic page.
DefaultNetworkProxyService xref
1 package org.apache.archiva.rest.services;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
27
28 import javax.inject.Inject;
29 import java.util.Collections;
30 import java.util.List;
31
32
33
34
35 @Service( "networkProxyService#rest" )
36 public class DefaultNetworkProxyService
37 extends AbstractRestService
38 implements NetworkProxyService
39 {
40 @Inject
41 private NetworkProxyAdmin networkProxyAdmin;
42
43 @Override
44 public List<NetworkProxy> getNetworkProxies()
45 throws ArchivaRestServiceException
46 {
47 try
48 {
49 List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
50 return networkProxies == null ? Collections.<NetworkProxy>emptyList() : networkProxies;
51 }
52 catch ( RepositoryAdminException e )
53 {
54 throw new ArchivaRestServiceException( e.getMessage(), e );
55 }
56 }
57
58 @Override
59 public NetworkProxy getNetworkProxy( String networkProxyId )
60 throws ArchivaRestServiceException
61 {
62 try
63 {
64 return networkProxyAdmin.getNetworkProxy( networkProxyId );
65 }
66 catch ( RepositoryAdminException e )
67 {
68 throw new ArchivaRestServiceException( e.getMessage(), e );
69 }
70 }
71
72 @Override
73 public void addNetworkProxy( NetworkProxy networkProxy )
74 throws ArchivaRestServiceException
75 {
76 try
77 {
78 if ( networkProxy == null )
79 {
80 return;
81 }
82 getNetworkProxyAdmin().addNetworkProxy( networkProxy, getAuditInformation() );
83 }
84 catch ( RepositoryAdminException e )
85 {
86 throw new ArchivaRestServiceException( e.getMessage(), e );
87 }
88 }
89
90 @Override
91 public void updateNetworkProxy( NetworkProxy networkProxy )
92 throws ArchivaRestServiceException
93 {
94 if ( networkProxy == null )
95 {
96 return;
97 }
98 try
99 {
100 getNetworkProxyAdmin().updateNetworkProxy( networkProxy, getAuditInformation() );
101 }
102 catch ( RepositoryAdminException e )
103 {
104 throw new ArchivaRestServiceException( e.getMessage(), e );
105 }
106 }
107
108 @Override
109 public Boolean deleteNetworkProxy( String networkProxyId )
110 throws ArchivaRestServiceException
111 {
112 try
113 {
114 getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() );
115 return Boolean.TRUE;
116 }
117 catch ( RepositoryAdminException e )
118 {
119 throw new ArchivaRestServiceException( e.getMessage(), e );
120 }
121 }
122
123 public NetworkProxyAdmin getNetworkProxyAdmin()
124 {
125 return networkProxyAdmin;
126 }
127
128 public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
129 {
130 this.networkProxyAdmin = networkProxyAdmin;
131 }
132 }