View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/community/resolver/src/java/org/astrogrid/community/resolver/ant/CommunityAccountResolverTask.java,v $</cvs:source>
3    * <cvs:author>$Author: dave $</cvs:author>
4    * <cvs:date>$Date: 2004/06/18 13:45:20 $</cvs:date>
5    * <cvs:version>$Revision: 1.4 $</cvs:version>
6    *
7    * <cvs:log>
8    *   $Log: CommunityAccountResolverTask.java,v $
9    *   Revision 1.4  2004/06/18 13:45:20  dave
10   *   Merged development branch, dave-dev-200406081614, into HEAD
11   *
12   *   Revision 1.3.18.1  2004/06/17 13:38:59  dave
13   *   Tidied up old CVS log entries
14   *
15   * </cvs:log>
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          // Initialise our base class.
53          super() ;
54          }
55  
56      /***
57       * Public constructor.
58       *
59       */
60      public CommunityAccountResolverTask(Task parent)
61          {
62          //
63          // Initialise our base class.
64          super() ;
65          //
66          // Set our project.
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         // Load our config properties.
117         this.configure() ;
118         //
119         // Try login to the account.
120         try {
121             //
122             // Create our resolver.
123             CommunityAccountResolver resolver ;
124             //
125             // Use our registry endpoint, if we have one.
126             if (null != this.getRegistry())
127                 {
128                 resolver = new CommunityAccountResolver(
129                     new URL(
130                         this.getRegistry()
131                         )
132                     ) ;
133                 }
134             //
135             // Otherwise, just create a default resolver.
136             else {
137                 resolver = new CommunityAccountResolver() ;
138                 }
139             //
140             // Ask our resolver to get the Account details.
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