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
12
13
14
15
16
17
18
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
39 URL url = URLFactory.createURL(command.m_nonOptionValues[0]);
40
41
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 }