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