1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.astrogrid.community.resolver.ant ;
23
24 import java.net.URL ;
25
26 import org.apache.tools.ant.Task ;
27 import org.apache.tools.ant.BuildException ;
28
29 import org.astrogrid.store.Ivorn ;
30
31 import org.astrogrid.community.resolver.CommunityAccountSpaceResolver ;
32
33 /***
34 * An Ant task to resolve a Community Account home space.
35 *
36 */
37 public class CommunityAccountSpaceResolverTask
38 extends CommunityResolverTask
39 {
40 /***
41 * Our debug flag.
42 *
43 */
44 private static final boolean DEBUG_FLAG = true ;
45
46 /***
47 * Public constructor.
48 *
49 */
50 public CommunityAccountSpaceResolverTask()
51 {
52
53
54 super() ;
55 }
56
57 /***
58 * Public constructor.
59 *
60 */
61 public CommunityAccountSpaceResolverTask(Task parent)
62 {
63
64
65 super() ;
66
67
68 setProject(parent.getProject()) ;
69 }
70
71 /***
72 * Our property name.
73 *
74 */
75 private String property ;
76
77 /***
78 * Get our property name.
79 *
80 */
81 public String getProperty()
82 {
83 return this.property ;
84 }
85
86 /***
87 * Set our property name.
88 *
89 */
90 public void setProperty(String value)
91 {
92 this.property = value ;
93 }
94
95 /***
96 * Our account identifier.
97 *
98 */
99 private String account ;
100
101 /***
102 * Get our account identifier.
103 *
104 */
105 public String getAccount()
106 {
107 return this.account ;
108 }
109
110 /***
111 * Set our account identifier.
112 *
113 */
114 public void setAccount(String value)
115 {
116 this.account = value ;
117 }
118
119 /***
120 * Initialise our Task.
121 *
122 */
123 public void init()
124 throws BuildException
125 {
126 if (DEBUG_FLAG) System.out.println("----\"----");
127 if (DEBUG_FLAG) System.out.println("CommunityAccountSpaceResolverTask.init()");
128 }
129
130 /***
131 * Execute our Task.
132 *
133 */
134 public void execute()
135 throws BuildException
136 {
137 if (DEBUG_FLAG) System.out.println("----\"----");
138 if (DEBUG_FLAG) System.out.println("CommunityAccountSpaceResolverTask.execute()");
139 if (DEBUG_FLAG) System.out.println(" Account : " + this.account);
140
141
142 this.configure() ;
143
144
145 try {
146
147
148 CommunityAccountSpaceResolver resolver ;
149
150
151 if (null != this.getRegistry())
152 {
153 resolver = new CommunityAccountSpaceResolver(
154 new URL(
155 this.getRegistry()
156 )
157 ) ;
158 }
159
160
161 else {
162 resolver = new CommunityAccountSpaceResolver() ;
163 }
164
165
166 Ivorn ivorn = resolver.resolve(
167 new Ivorn(
168 this.account
169 )
170 ) ;
171 if (DEBUG_FLAG) System.out.println("----");
172 if (DEBUG_FLAG) System.out.println("Home : " + ivorn);
173 if (DEBUG_FLAG) System.out.println("----");
174
175
176 if (null != this.getProject())
177 {
178
179
180 if (null != this.property)
181 {
182
183
184 this.getProject().setProperty(
185 this.property,
186 ivorn.toString()
187 ) ;
188 }
189 }
190 }
191 catch (Exception ouch)
192 {
193 throw new BuildException(ouch) ;
194 }
195 }
196 }
197