1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.util.repository;
20
21 import org.eclipse.aether.RepositorySystemSession;
22 import org.eclipse.aether.artifact.Artifact;
23 import org.eclipse.aether.metadata.Metadata;
24 import org.eclipse.aether.resolution.ResolutionErrorPolicy;
25 import org.eclipse.aether.resolution.ResolutionErrorPolicyRequest;
26
27 import static java.util.Objects.requireNonNull;
28
29
30
31
32 public final class SimpleResolutionErrorPolicy implements ResolutionErrorPolicy {
33
34 private final int artifactPolicy;
35
36 private final int metadataPolicy;
37
38
39
40
41
42
43
44 public SimpleResolutionErrorPolicy(boolean cacheNotFound, boolean cacheTransferErrors) {
45 this((cacheNotFound ? CACHE_NOT_FOUND : 0) | (cacheTransferErrors ? CACHE_TRANSFER_ERROR : 0));
46 }
47
48
49
50
51
52
53 public SimpleResolutionErrorPolicy(int policy) {
54 this(policy, policy);
55 }
56
57
58
59
60
61
62
63 public SimpleResolutionErrorPolicy(int artifactPolicy, int metadataPolicy) {
64 this.artifactPolicy = artifactPolicy;
65 this.metadataPolicy = metadataPolicy;
66 }
67
68 public int getArtifactPolicy(RepositorySystemSession session, ResolutionErrorPolicyRequest<Artifact> request) {
69 requireNonNull(session, "session cannot be null");
70 requireNonNull(request, "request cannot be null");
71 return artifactPolicy;
72 }
73
74 public int getMetadataPolicy(RepositorySystemSession session, ResolutionErrorPolicyRequest<Metadata> request) {
75 requireNonNull(session, "session cannot be null");
76 requireNonNull(request, "request cannot be null");
77 return metadataPolicy;
78 }
79 }