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 (Mirror) getCheckedRef();
50 }
51
52 public void setRefid(Reference ref) {
53 if (id != null || url != null || mirrorOf != null || type != null) {
54 throw tooManyAttributes();
55 }
56 super.setRefid(ref);
57 }
58
59 public String getId() {
60 if (isReference()) {
61 return getRef().getId();
62 }
63 return id;
64 }
65
66 public void setId(String id) {
67 this.id = id;
68 }
69
70 public String getUrl() {
71 if (isReference()) {
72 return getRef().getUrl();
73 }
74 return url;
75 }
76
77 public void setUrl(String url) {
78 checkAttributesAllowed();
79 this.url = url;
80 }
81
82 public String getType() {
83 if (isReference()) {
84 return getRef().getType();
85 }
86 return (type != null) ? type : "default";
87 }
88
89 public void setType(String type) {
90 checkAttributesAllowed();
91 this.type = type;
92 }
93
94 public String getMirrorOf() {
95 if (isReference()) {
96 return getRef().getMirrorOf();
97 }
98 return mirrorOf;
99 }
100
101 public void setMirrorOf(String mirrorOf) {
102 checkAttributesAllowed();
103 this.mirrorOf = mirrorOf;
104 }
105
106 public void addAuthentication(Authentication authentication) {
107 checkChildrenAllowed();
108 if (this.authentication != null) {
109 throw new BuildException("You must not specify multiple <authentication> elements");
110 }
111 this.authentication = authentication;
112 }
113
114 public Authentication getAuthentication() {
115 if (isReference()) {
116 getRef().getAuthentication();
117 }
118 return authentication;
119 }
120
121 public void setAuthRef(Reference ref) {
122 if (authentication == null) {
123 authentication = new Authentication();
124 authentication.setProject(getProject());
125 }
126 authentication.setRefid(ref);
127 }
128 }