1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.maven.wagon; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.util.List; |
20 |
|
|
21 |
|
import org.apache.maven.wagon.ConnectionException; |
22 |
|
import org.apache.maven.wagon.ResourceDoesNotExistException; |
23 |
|
import org.apache.maven.wagon.TransferFailedException; |
24 |
|
import org.apache.maven.wagon.Wagon; |
25 |
|
import org.apache.maven.wagon.authentication.AuthenticationException; |
26 |
|
import org.apache.maven.wagon.authentication.AuthenticationInfo; |
27 |
|
import org.apache.maven.wagon.authorization.AuthorizationException; |
28 |
|
import org.apache.maven.wagon.events.SessionListener; |
29 |
|
import org.apache.maven.wagon.events.TransferEvent; |
30 |
|
import org.apache.maven.wagon.events.TransferListener; |
31 |
|
import org.apache.maven.wagon.observers.Debug; |
32 |
|
import org.apache.maven.wagon.proxy.ProxyInfo; |
33 |
|
import org.apache.maven.wagon.proxy.ProxyInfoProvider; |
34 |
|
import org.apache.maven.wagon.repository.Repository; |
35 |
|
import org.apache.maven.wagon.resource.Resource; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@author |
41 |
|
@author |
42 |
|
@since |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 130 (130) |
Complexity: 57 |
Complexity Density: 0.61 |
|
44 |
|
public abstract class AbstractWagon implements Wagon { |
45 |
|
|
46 |
|
private int timeout; |
47 |
|
|
48 |
|
private boolean interactive; |
49 |
|
|
50 |
|
private Repository repository; |
51 |
|
|
52 |
|
private final boolean supportsDirectoryCopy; |
53 |
|
|
54 |
|
private final SessionListenerSupport sessionListeners = new SessionListenerSupport(this); |
55 |
|
|
56 |
|
private final TransferListenerSupport transferListeners = new TransferListenerSupport(this); |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0
|
protected AbstractWagon(final boolean supportsDirectoryCopy) {... |
59 |
0
|
this.supportsDirectoryCopy = supportsDirectoryCopy; |
60 |
|
} |
61 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
62 |
0
|
public final void addSessionListener(final SessionListener listener) {... |
63 |
0
|
if (listener.getClass().equals(Debug.class)) { |
64 |
|
|
65 |
0
|
return; |
66 |
|
} |
67 |
0
|
sessionListeners.addListener(listener); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
protected final SessionListenerSupport getSessionListeners() {... |
71 |
0
|
return sessionListeners; |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
0
|
public final boolean hasSessionListener(final SessionListener listener) {... |
75 |
0
|
return sessionListeners.hasListener(listener); |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
0
|
public final void removeSessionListener(final SessionListener listener) {... |
79 |
0
|
sessionListeners.removeListener(listener); |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
0
|
public final void addTransferListener(final TransferListener listener) {... |
83 |
0
|
transferListeners.addListener(listener); |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
0
|
protected final TransferListenerSupport getTransferListeners() {... |
87 |
0
|
return transferListeners; |
88 |
|
} |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0
|
public final boolean hasTransferListener(final TransferListener listener) {... |
91 |
0
|
return transferListeners.hasListener(listener); |
92 |
|
} |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
0
|
public final void removeTransferListener(final TransferListener listener) {... |
95 |
0
|
transferListeners.removeListener(listener); |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0
|
public final Repository getRepository() {... |
99 |
0
|
return repository; |
100 |
|
} |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0
|
public final boolean isInteractive() {... |
103 |
0
|
return interactive; |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
0
|
public final void setInteractive(final boolean interactive) {... |
107 |
0
|
this.interactive = interactive; |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0
|
public final void connect(final Repository source) throws ConnectionException, AuthenticationException {... |
111 |
0
|
doConnect(source, null, null); |
112 |
|
} |
113 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
114 |
0
|
public final void connect(final Repository source, final ProxyInfo proxyInfo) throws ConnectionException,... |
115 |
|
AuthenticationException { |
116 |
0
|
connect(source, null, proxyInfo); |
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
0
|
public final void connect(final Repository source, final AuthenticationInfo authenticationInfo)... |
120 |
|
throws ConnectionException, AuthenticationException { |
121 |
0
|
doConnect(source, authenticationInfo, null); |
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.33 |
|
124 |
0
|
protected void doConnect(final Repository source, final AuthenticationInfo authenticationInfo,... |
125 |
|
final ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException { |
126 |
0
|
repository = source; |
127 |
0
|
sessionListeners.fireSessionOpening(); |
128 |
0
|
try { |
129 |
0
|
connectToRepository(source, authenticationInfo, proxyInfo); |
130 |
|
} catch (ConnectionException e) { |
131 |
0
|
sessionListeners.fireSessionConnectionRefused(); |
132 |
0
|
throw e; |
133 |
|
} catch (AuthenticationException e) { |
134 |
0
|
sessionListeners.fireSessionConnectionRefused(); |
135 |
0
|
throw e; |
136 |
|
} catch (Exception e) { |
137 |
0
|
sessionListeners.fireSessionConnectionRefused(); |
138 |
0
|
throw new ConnectionException("Could not connect to repository", e); |
139 |
|
} |
140 |
0
|
sessionListeners.fireSessionLoggedIn(); |
141 |
0
|
sessionListeners.fireSessionOpened(); |
142 |
|
} |
143 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
144 |
0
|
public final void connect(final Repository source, final AuthenticationInfo authenticationInfo,... |
145 |
|
final ProxyInfo proxyInfo) throws ConnectionException, AuthenticationException { |
146 |
0
|
doConnect(source, authenticationInfo, proxyInfo); |
147 |
|
} |
148 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
|
149 |
0
|
public final void disconnect() throws ConnectionException {... |
150 |
0
|
sessionListeners.fireSessionDisconnecting(); |
151 |
0
|
try { |
152 |
0
|
disconnectFromRepository(); |
153 |
|
} catch (ConnectionException e) { |
154 |
0
|
sessionListeners.fireSessionConnectionRefused(); |
155 |
0
|
throw e; |
156 |
|
} catch (Exception e) { |
157 |
0
|
sessionListeners.fireSessionConnectionRefused(); |
158 |
0
|
throw new ConnectionException("Could not disconnect from repository", e); |
159 |
|
} |
160 |
0
|
sessionListeners.fireSessionLoggedOff(); |
161 |
0
|
sessionListeners.fireSessionDisconnected(); |
162 |
|
} |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.45 |
|
164 |
0
|
public final void get(final String resourceName, final File destination) throws TransferFailedException,... |
165 |
|
ResourceDoesNotExistException, AuthorizationException { |
166 |
0
|
Resource resource = new Resource(resourceName); |
167 |
0
|
transferListeners.fireTransferInitiated(resource, TransferEvent.REQUEST_GET); |
168 |
0
|
transferListeners.fireTransferStarted(resource, TransferEvent.REQUEST_GET); |
169 |
|
|
170 |
0
|
try { |
171 |
0
|
getResource(resourceName, destination, new TransferProgress(resource, TransferEvent.REQUEST_GET, |
172 |
|
transferListeners)); |
173 |
0
|
transferListeners.fireTransferCompleted(resource, TransferEvent.REQUEST_GET); |
174 |
|
} catch (TransferFailedException e) { |
175 |
0
|
throw e; |
176 |
|
} catch (ResourceDoesNotExistException e) { |
177 |
0
|
throw e; |
178 |
|
} catch (AuthorizationException e) { |
179 |
0
|
throw e; |
180 |
|
} catch (Exception e) { |
181 |
0
|
transferListeners.fireTransferError(resource, TransferEvent.REQUEST_GET, e); |
182 |
0
|
throw new TransferFailedException("Transfer of resource " + destination + "failed", e); |
183 |
|
} |
184 |
|
} |
185 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 5 |
Complexity Density: 0.71 |
|
186 |
0
|
@SuppressWarnings("rawtypes")... |
187 |
|
public final List getFileList(final String destinationDirectory) throws TransferFailedException, |
188 |
|
ResourceDoesNotExistException, AuthorizationException { |
189 |
0
|
try { |
190 |
0
|
return listDirectory(destinationDirectory); |
191 |
|
} catch (TransferFailedException e) { |
192 |
0
|
throw e; |
193 |
|
} catch (ResourceDoesNotExistException e) { |
194 |
0
|
throw e; |
195 |
|
} catch (AuthorizationException e) { |
196 |
0
|
throw e; |
197 |
|
} catch (Exception e) { |
198 |
0
|
sessionListeners.fireSessionError(e); |
199 |
0
|
throw new TransferFailedException("Listing of directory " + destinationDirectory + "failed", e); |
200 |
|
} |
201 |
|
} |
202 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 6 |
Complexity Density: 0.55 |
|
203 |
0
|
public final boolean getIfNewer(final String resourceName, final File destination, final long timestamp)... |
204 |
|
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { |
205 |
0
|
Resource resource = new Resource(resourceName); |
206 |
0
|
try { |
207 |
0
|
if (isRemoteResourceNewer(resourceName, timestamp)) { |
208 |
0
|
get(resourceName, destination); |
209 |
0
|
return true; |
210 |
|
} else { |
211 |
0
|
return false; |
212 |
|
} |
213 |
|
} catch (TransferFailedException e) { |
214 |
0
|
throw e; |
215 |
|
} catch (ResourceDoesNotExistException e) { |
216 |
0
|
throw e; |
217 |
|
} catch (AuthorizationException e) { |
218 |
0
|
throw e; |
219 |
|
} catch (Exception e) { |
220 |
0
|
transferListeners.fireTransferError(resource, TransferEvent.REQUEST_GET, e); |
221 |
0
|
throw new TransferFailedException("Transfer of resource " + destination + "failed", e); |
222 |
|
} |
223 |
|
} |
224 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
225 |
0
|
public final void openConnection() throws ConnectionException, AuthenticationException {... |
226 |
|
|
227 |
|
} |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 5 |
Complexity Density: 0.45 |
|
229 |
0
|
public final void put(final File source, final String destination) throws TransferFailedException,... |
230 |
|
ResourceDoesNotExistException, AuthorizationException { |
231 |
0
|
Resource resource = new Resource(destination); |
232 |
0
|
transferListeners.fireTransferInitiated(resource, TransferEvent.REQUEST_PUT); |
233 |
0
|
transferListeners.fireTransferStarted(resource, TransferEvent.REQUEST_PUT); |
234 |
|
|
235 |
0
|
try { |
236 |
0
|
putResource(source, destination, new TransferProgress(resource, TransferEvent.REQUEST_PUT, |
237 |
|
transferListeners)); |
238 |
0
|
transferListeners.fireTransferCompleted(resource, TransferEvent.REQUEST_PUT); |
239 |
|
} catch (TransferFailedException e) { |
240 |
0
|
throw e; |
241 |
|
} catch (ResourceDoesNotExistException e) { |
242 |
0
|
throw e; |
243 |
|
} catch (AuthorizationException e) { |
244 |
0
|
throw e; |
245 |
|
} catch (Exception e) { |
246 |
0
|
transferListeners.fireTransferError(resource, TransferEvent.REQUEST_PUT, e); |
247 |
0
|
throw new TransferFailedException("Transfer of resource " + destination + "failed", e); |
248 |
|
} |
249 |
|
} |
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
257 |
0
|
public final void putDirectory(final File sourceDirectory, final String destinationDirectory)... |
258 |
|
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { |
259 |
|
|
260 |
0
|
for (File f : sourceDirectory.listFiles()) { |
261 |
|
|
262 |
0
|
if (f.isDirectory()) { |
263 |
|
|
264 |
0
|
putDirectory(f, destinationDirectory + "/" + f.getName()); |
265 |
|
} else { |
266 |
|
|
267 |
0
|
put(f, destinationDirectory + "/" + f.getName()); |
268 |
|
} |
269 |
|
} |
270 |
|
} |
271 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 0.67 |
|
272 |
0
|
public final boolean resourceExists(final String resourceName) throws TransferFailedException,... |
273 |
|
AuthorizationException { |
274 |
0
|
try { |
275 |
0
|
return doesRemoteResourceExist(resourceName); |
276 |
|
} catch (TransferFailedException e) { |
277 |
0
|
throw e; |
278 |
|
} catch (AuthorizationException e) { |
279 |
0
|
throw e; |
280 |
|
} catch (Exception e) { |
281 |
0
|
sessionListeners.fireSessionError(e); |
282 |
0
|
throw new TransferFailedException("Listing of resource " + resourceName + "failed", e); |
283 |
|
} |
284 |
|
} |
285 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
286 |
0
|
public final boolean supportsDirectoryCopy() {... |
287 |
0
|
return supportsDirectoryCopy; |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
@param |
294 |
|
|
295 |
|
@param |
296 |
|
|
297 |
|
@param |
298 |
|
|
299 |
|
@throws |
300 |
|
|
301 |
|
|
302 |
|
protected abstract void connectToRepository(Repository source, AuthenticationInfo authenticationInfo, |
303 |
|
ProxyInfo proxyInfo) throws Exception; |
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
@param |
309 |
|
|
310 |
|
@return |
311 |
|
@throws |
312 |
|
|
313 |
|
|
314 |
|
protected abstract boolean doesRemoteResourceExist(String resourceName) throws Exception; |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
@throws |
320 |
|
|
321 |
|
|
322 |
|
protected abstract void disconnectFromRepository() throws Exception; |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
@param |
328 |
|
|
329 |
|
@param |
330 |
|
|
331 |
|
@param |
332 |
|
|
333 |
|
@throws |
334 |
|
|
335 |
|
|
336 |
|
protected abstract void getResource(String resourceName, File destination, TransferProgress progress) |
337 |
|
throws Exception; |
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
@param |
343 |
|
|
344 |
|
@param |
345 |
|
|
346 |
|
@return |
347 |
|
@throws |
348 |
|
|
349 |
|
|
350 |
|
protected abstract boolean isRemoteResourceNewer(String resourceName, long timestamp) throws Exception; |
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
@param |
356 |
|
|
357 |
|
@return |
358 |
|
@throws |
359 |
|
|
360 |
|
|
361 |
|
protected abstract List<String> listDirectory(String directory) throws Exception; |
362 |
|
|
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
@param |
367 |
|
|
368 |
|
@param |
369 |
|
|
370 |
|
@param |
371 |
|
|
372 |
|
@throws |
373 |
|
|
374 |
|
|
375 |
|
protected abstract void putResource(File source, String destination, TransferProgress progress) throws Exception; |
376 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
377 |
0
|
public void connect(final Repository source, final AuthenticationInfo authenticationInfo,... |
378 |
|
final ProxyInfoProvider proxyInfoProvider) throws ConnectionException, AuthenticationException { |
379 |
0
|
doConnect(source, authenticationInfo, null); |
380 |
|
} |
381 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
382 |
0
|
public void connect(final Repository source, final ProxyInfoProvider proxyInfoProvider) throws ConnectionException,... |
383 |
|
AuthenticationException { |
384 |
0
|
doConnect(source, null, null); |
385 |
|
} |
386 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
387 |
0
|
public int getTimeout() {... |
388 |
0
|
return this.timeout; |
389 |
|
} |
390 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
391 |
0
|
public void setTimeout(final int timeoutValue) {... |
392 |
0
|
this.timeout = timeoutValue; |
393 |
|
} |
394 |
|
|
395 |
|
} |