1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.astrogrid.community.install.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.community.install.loader.CommunityLoader ;
27 import org.astrogrid.community.client.policy.manager.PolicyManagerSoapDelegate ;
28 import org.astrogrid.community.client.security.manager.SecurityManagerSoapDelegate ;
29
30 /***
31 * An Ant task to load data into a Community service.
32 *
33 */
34 public class CommunityLoaderTask
35 extends Task
36 {
37 /***
38 * Our debug flag.
39 *
40 */
41 private static final boolean DEBUG_FLAG = true ;
42
43 /***
44 * Public constructor.
45 *
46 */
47 public CommunityLoaderTask()
48 {
49
50
51 super() ;
52 }
53
54 /***
55 * Public constructor.
56 *
57 */
58 public CommunityLoaderTask(Task parent)
59 {
60
61
62 super() ;
63
64
65 setProject(parent.getProject()) ;
66 }
67
68 /***
69 * Initialise our Task.
70 *
71 */
72 public void init()
73 throws BuildException
74 {
75 if (DEBUG_FLAG) System.out.println("----\"----");
76 if (DEBUG_FLAG) System.out.println("CommunityLoaderTask.init()");
77 }
78
79 /***
80 * Our PolicyManager service endpoint.
81 *
82 */
83 private String policyManager ;
84
85 /***
86 * Get our PolicyManager service endpoint.
87 *
88 */
89 public String getPolicyManager()
90 {
91 return this.policyManager ;
92 }
93
94 /***
95 * Set our PolicyManager service endpoint.
96 *
97 */
98 public void setPolicyManager(String value)
99 {
100 this.policyManager = value ;
101 }
102
103 /***
104 * Our SecurityManager service endpoint.
105 *
106 */
107 private String securityManager ;
108
109 /***
110 * Get our SecurityManager service endpoint.
111 *
112 */
113 public String getSecurityManager()
114 {
115 return this.securityManager ;
116 }
117
118 /***
119 * Set our SecurityManager service endpoint.
120 *
121 */
122 public void setSecurityManager(String value)
123 {
124 this.securityManager = value ;
125 }
126
127 /***
128 * Our data file location.
129 *
130 */
131 private String data ;
132
133 /***
134 * Get our data file location.
135 *
136 */
137 public String getData()
138 {
139 return this.data ;
140 }
141
142 /***
143 * Set our data file location.
144 *
145 */
146 public void setData(String value)
147 {
148 this.data = value ;
149 }
150
151 /***
152 * Execute our Task.
153 *
154 */
155 public void execute()
156 throws BuildException
157 {
158 if (DEBUG_FLAG) System.out.println("----\"----");
159 if (DEBUG_FLAG) System.out.println("CommunityLoaderTask.execute()");
160 if (DEBUG_FLAG) System.out.println(" Data : " + this.data);
161 if (DEBUG_FLAG) System.out.println(" PolicyManager : " + this.policyManager);
162 if (DEBUG_FLAG) System.out.println(" SecurityManager : " + this.securityManager);
163
164
165 try {
166
167
168 CommunityLoader loader = new CommunityLoader(
169 new PolicyManagerSoapDelegate(
170 new URL(
171 this.policyManager
172 )
173 ),
174 new SecurityManagerSoapDelegate(
175 new URL(
176 this.securityManager
177 )
178 )
179 ) ;
180
181
182 loader.load(
183 new URL(
184 this.data
185 )
186 ) ;
187
188
189 loader.upload() ;
190 }
191 catch (Exception ouch)
192 {
193 throw new BuildException(ouch) ;
194 }
195 }
196 }
197