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.install.ant ;
23
24 import java.io.File ;
25 import java.net.URL ;
26
27 import org.apache.tools.ant.Task ;
28 import org.apache.tools.ant.BuildException ;
29
30 import org.astrogrid.registry.client.admin.UpdateRegistry ;
31
32 /***
33 * An Ant task to register a Community service woth a remote Registry.
34 *
35 */
36 public class CommunityRegistryTask
37 extends Task
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 CommunityRegistryTask()
50 {
51
52
53 super() ;
54 }
55
56 /***
57 * Public constructor.
58 *
59 */
60 public CommunityRegistryTask(Task parent)
61 {
62
63
64 super() ;
65
66
67 setProject(parent.getProject()) ;
68 }
69
70 /***
71 * Initialise our Task.
72 *
73 */
74 public void init()
75 throws BuildException
76 {
77 if (DEBUG_FLAG) System.out.println("----\"----");
78 if (DEBUG_FLAG) System.out.println("CommunityRegistryTask.init()");
79 }
80
81 /***
82 * Our Registry service endpoint.
83 *
84 */
85 private String registry ;
86
87 /***
88 * Get our Registry service endpoint.
89 *
90 */
91 public String getRegistry()
92 {
93 return this.registry ;
94 }
95
96 /***
97 * Set our Registry service endpoint.
98 *
99 */
100 public void setRegistry(String value)
101 {
102 this.registry = value ;
103 }
104
105 /***
106 * Our Registry data file.
107 *
108 */
109 private String data ;
110
111 /***
112 * Get our Registry data file.
113 *
114 */
115 public String getData()
116 {
117 return this.data ;
118 }
119
120 /***
121 * Set our Registry data file.
122 *
123 */
124 public void setData(String value)
125 {
126 this.data = value ;
127 }
128
129 /***
130 * Execute our Task.
131 *
132 */
133 public void execute()
134 throws BuildException
135 {
136 if (DEBUG_FLAG) System.out.println("----\"----");
137 if (DEBUG_FLAG) System.out.println("CommunityRegistryTask.execute()");
138 if (DEBUG_FLAG) System.out.println(" Data : " + this.data);
139 if (DEBUG_FLAG) System.out.println(" Registry : " + this.registry);
140
141
142 try {
143
144
145
146
147
148
149
150
151
152 UpdateRegistry registry = new UpdateRegistry(
153 new URL(
154 this.registry
155 )
156 );
157
158
159 registry.updateFromFile(
160 new File(
161 this.data
162 )
163 ) ;
164 }
165 catch (Exception ouch)
166 {
167 throw new BuildException(ouch) ;
168 }
169 }
170 }
171