View Javadoc

1   package fr.in2p3.jsaga.command;
2   
3   import org.apache.commons.cli.*;
4   import org.ogf.saga.namespace.*;
5   import org.ogf.saga.session.Session;
6   import org.ogf.saga.session.SessionFactory;
7   import org.ogf.saga.url.URL;
8   import org.ogf.saga.url.URLFactory;
9   
10  /* ***************************************************
11  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
12  * ***             http://cc.in2p3.fr/             ***
13  * ***************************************************
14  * File:   NamespaceRmdir
15  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
16  * Date:   28 sept. 2007
17  * ***************************************************
18  * Description:                                      */
19  /**
20   *
21   */
22  public class NamespaceRmdir extends AbstractCommand {
23      private static final String OPT_HELP = "h", LONGOPT_HELP = "help";
24  
25      public NamespaceRmdir() {
26          super("jsaga-rmdir", new String[]{"URL"}, new String[]{OPT_HELP, LONGOPT_HELP});
27      }
28  
29      public static void main(String[] args) throws Exception {
30          NamespaceRmdir command = new NamespaceRmdir();
31          CommandLine line = command.parse(args);
32          if (line.hasOption(OPT_HELP))
33          {
34              command.printHelpAndExit(null);
35          }
36          else
37          {
38              // get arguments
39              URL url = URLFactory.createURL(command.m_nonOptionValues[0]);
40  
41              // execute command
42              Session session = SessionFactory.createSession(true);
43              NSDirectory dir = NSFactory.createNSDirectory(session, url, Flags.NONE.getValue());
44              dir.remove(Flags.NONE.getValue());
45              dir.close();
46              System.exit(0);
47          }
48      }
49  
50      protected Options createOptions() {
51          Options opt = new Options();
52          opt.addOption(OptionBuilder.withDescription("Display this help and exit")
53                  .withLongOpt(LONGOPT_HELP)
54                  .create(OPT_HELP));
55          return opt;
56      }
57  }