View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/install/src/java/org/astrogrid/community/install/ant/CommunityRegistryTask.java,v $</cvs:source>
3    * <cvs:author>$Author: KevinBenson $</cvs:author>
4    * <cvs:date>$Date: 2004/07/23 11:56:09 $</cvs:date>
5    * <cvs:version>$Revision: 1.5 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityRegistryTask.java,v $
9    *   Revision 1.5  2004/07/23 11:56:09  KevinBenson
10   *   Small change to use the new RegistryUpdate delegate and new REgistryUpdate endpoint
11   *
12   *   Revision 1.4  2004/06/18 13:45:20  dave
13   *   Merged development branch, dave-dev-200406081614, into HEAD
14   *
15   *   Revision 1.3.18.1  2004/06/17 13:38:59  dave
16   *   Tidied up old CVS log entries
17   *
18   * </cvs:log>
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          // Initialise our base class.
53          super() ;
54          }
55  
56      /***
57       * Public constructor.
58       *
59       */
60      public CommunityRegistryTask(Task parent)
61          {
62          //
63          // Initialise our base class.
64          super() ;
65          //
66          // Set our project.
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         // Try registering our services.
142         try {
143             //
144             // Create our RegistryAdminService client.
145             /*
146             RegistryAdminService registry = new RegistryAdminService(
147                 new URL(
148                     this.registry
149                     )
150                 ) ;
151                 */
152             UpdateRegistry registry = new UpdateRegistry(
153               new URL(
154                  this.registry
155               )
156             );
157             //
158             // Send the document to the service.
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