1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.resolver.internal.ant.types;
20
21 import org.apache.maven.resolver.internal.ant.AntRepoSys;
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.Project;
24 import org.apache.tools.ant.types.DataType;
25 import org.apache.tools.ant.types.Reference;
26
27
28
29 public class Mirror extends DataType {
30
31 private String id;
32
33 private String url;
34
35 private String type;
36
37 private String mirrorOf;
38
39 private Authentication authentication;
40
41 @Override
42 public void setProject(Project project) {
43 super.setProject(project);
44
45 AntRepoSys.getInstance(project).addMirror(this);
46 }
47
48 protected Mirror getRef() {
49 return getCheckedRef(Mirror.class);
50 }
51
52 @Override
53 public void setRefid(Reference ref) {
54 if (id != null || url != null || mirrorOf != null || type != null) {
55 throw tooManyAttributes();
56 }
57 super.setRefid(ref);
58 }
59
60 public String getId() {
61 if (isReference()) {
62 return getRef().getId();
63 }
64 return id;
65 }
66
67 public void setId(String id) {
68 this.id = id;
69 }
70
71 public String getUrl() {
72 if (isReference()) {
73 return getRef().getUrl();
74 }
75 return url;
76 }
77
78 public void setUrl(String url) {
79 checkAttributesAllowed();
80 this.url = url;
81 }
82
83 public String getType() {
84 if (isReference()) {
85 return getRef().getType();
86 }
87 return (type != null) ? type : "default";
88 }
89
90 public void setType(String type) {
91 checkAttributesAllowed();
92 this.type = type;
93 }
94
95 public String getMirrorOf() {
96 if (isReference()) {
97 return getRef().getMirrorOf();
98 }
99 return mirrorOf;
100 }
101
102 public void setMirrorOf(String mirrorOf) {
103 checkAttributesAllowed();
104 this.mirrorOf = mirrorOf;
105 }
106
107 public void addAuthentication(Authentication authentication) {
108 checkChildrenAllowed();
109 if (this.authentication != null) {
110 throw new BuildException("You must not specify multiple <authentication> elements");
111 }
112 this.authentication = authentication;
113 }
114
115 public Authentication getAuthentication() {
116 if (isReference()) {
117 getRef().getAuthentication();
118 }
119 return authentication;
120 }
121
122 public void setAuthRef(Reference ref) {
123 if (authentication == null) {
124 authentication = new Authentication();
125 authentication.setProject(getProject());
126 }
127 authentication.setRefid(ref);
128 }
129 }