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.community.resolver.CommunityTokenResolver ;
27
28 /***
29 * An Ant task to validate a Community toekn.
30 *
31 */
32 public class CommunityTokenResolverTask
33 extends CommunityResolverTask
34 {
35 /***
36 * Our debug flag.
37 *
38 */
39 private static final boolean DEBUG_FLAG = true ;
40
41 /***
42 * Public constructor.
43 *
44 */
45 public CommunityTokenResolverTask()
46 {
47
48
49 super() ;
50 }
51
52 /***
53 * Public constructor.
54 *
55 */
56 public CommunityTokenResolverTask(Task parent)
57 {
58
59
60 super() ;
61
62
63 setProject(parent.getProject()) ;
64 }
65
66 /***
67 * Initialise our Task.
68 *
69 */
70 public void init()
71 throws BuildException
72 {
73 if (DEBUG_FLAG) System.out.println("----\"----");
74 if (DEBUG_FLAG) System.out.println("CommunityTokenResolverTask.init()");
75 }
76
77 /***
78 * Execute our Task.
79 *
80 */
81 public void execute()
82 throws BuildException
83 {
84 if (DEBUG_FLAG) System.out.println("----\"----");
85 if (DEBUG_FLAG) System.out.println("CommunityTokenResolverTask.execute()");
86 if (DEBUG_FLAG) System.out.println(" Token : " + this.getToken());
87
88
89 this.configure() ;
90
91
92 try {
93
94
95 CommunityTokenResolver resolver ;
96
97
98 if (null != this.getRegistry())
99 {
100 resolver = new CommunityTokenResolver(
101 new URL(
102 this.getRegistry()
103 )
104 ) ;
105 }
106
107
108 else {
109 resolver = new CommunityTokenResolver() ;
110 }
111
112
113 this.setToken(
114 resolver.checkToken(
115 this.getToken()
116 )
117 ) ;
118 }
119 catch (Exception ouch)
120 {
121 throw new BuildException(ouch) ;
122 }
123 if (DEBUG_FLAG) System.out.println("----");
124 if (DEBUG_FLAG) System.out.println("Token : " + this.getToken());
125 if (DEBUG_FLAG) System.out.println("----");
126 }
127 }
128