View Javadoc

1   /*
2    * GUMS2MapUser.java
3    *
4    * Created on June 9, 2004, 1:44 PM
5    */
6   package gov.bnl.gums.admin;
7   
8   import org.apache.commons.cli.*;
9   
10  /**
11   * @author carcassi
12   */
13  public class PoolAddRange extends RemoteCommand {
14      static {
15          command = new PoolAddRange();
16      }
17  
18      /**
19       * Creates a new PoolAddRange object.
20       */
21      public PoolAddRange() {
22          syntax = "[-g GUMSURL] POOLACCOUNTMAPPER RANGE";
23          description = "Adds range of accounts to a pool. " +
24          	"ACCOUNTMAPPER is the name of the account mapper. " +
25              "RANGE is the group of accounts to be added (i.e. grid0050-0125).";
26      }
27  
28      protected org.apache.commons.cli.Options buildOptions() {
29          Options options = new Options();
30  
31          Option gumsUrl = new Option("g", "gumsUrl", true,
32          "Fully Qualified GUMS URL to override gums.location within the gums-client.properties file");
33          options.addOption(gumsUrl);
34          
35          return options;
36      }
37  
38      protected void execute(org.apache.commons.cli.CommandLine cmd)
39          throws Exception {
40          if (cmd.getArgs().length < 2) {
41              failForWrongParameters("Missing parameters...");
42          }
43  
44          String accountMapper = cmd.getArgs()[0];
45          
46          String gumsUrl = (cmd.getOptionValue("g", null));
47  
48          for (int nArg = 1; nArg < cmd.getArgs().length; nArg++) {
49          	getGums(gumsUrl).addAccountRange2(accountMapper, cmd.getArgs()[nArg]);
50          }
51      }
52  }