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