View Javadoc

1   package fr.in2p3.jsaga.command;
2   
3   import org.apache.commons.cli.CommandLine;
4   import org.ogf.saga.error.AlreadyExistsException;
5   import org.ogf.saga.error.DoesNotExistException;
6   import org.ogf.saga.namespace.Flags;
7   import org.ogf.saga.namespace.NSFactory;
8   import org.ogf.saga.session.Session;
9   import org.ogf.saga.url.URL;
10  
11  /* ***************************************************
12  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
13  * ***             http://cc.in2p3.fr/             ***
14  * ***************************************************
15  * File:   NamespaceRename
16  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
17  * Date:   13 oct. 2008
18  * ***************************************************
19  * Description:                                      */
20  /**
21   *
22   */
23  public class NamespaceRename extends NamespaceMove {
24      public static void main(String[] args) throws Exception {
25          NamespaceRename command = new NamespaceRename();
26          CommandLine line = command.parse(args);
27          command.execute(line);
28      }
29  
30      protected void changeBehavior(Session session, URL target) throws Exception {
31          try {
32              NSFactory.createNSEntry(session, target, Flags.NONE.getValue());
33              throw new AlreadyExistsException("Target entry already exists: "+target);
34          } catch(DoesNotExistException e) {
35              // do nothing
36          }
37      }
38  }