KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > cli > SetupSetBaseURLCommand


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.ui.cli;
15
16 import javax.naming.InitialContext JavaDoc;
17
18 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionHome;
19 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionRemote;
20 import org.ejbca.core.model.log.Admin;
21
22 /**
23  * Sets the base url of the web interface
24  *
25  * @version $Id: SetupSetBaseURLCommand.java,v 1.4 2007/01/03 14:49:35 anatom Exp $
26  */

27 public class SetupSetBaseURLCommand extends BaseAdminCommand {
28     /**
29      * Creates a new instance of CaCreateCrlCommand
30      *
31      * @param args command line arguments
32      */

33     public SetupSetBaseURLCommand(String JavaDoc[] args) {
34         super(args, Admin.TYPE_CACOMMANDLINE_USER, "cli");
35     }
36
37     /**
38      * Runs the command
39      *
40      * @throws IllegalAdminCommandException Error in command args
41      * @throws ErrorAdminCommandException Error running command
42      */

43     public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException {
44         if (args.length < 3) {
45            throw new IllegalAdminCommandException("Usage: SETUP setdefaultbaseurl <computername> <applicationname>\n" +
46                                                                                "Example: setup setbaseurl localhost ejbca \n\n");
47         }
48         try {
49             //InitialContext jndicontext = new InitialContext();
50
InitialContext JavaDoc jndicontext = getInitialContext();
51             
52             String JavaDoc computername = args[1];
53             String JavaDoc applicationpath = args[2];
54             IRaAdminSessionHome raadminsessionhome = (IRaAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(jndicontext.lookup("RaAdminSession"),
55                     IRaAdminSessionHome.class);
56             
57             IRaAdminSessionRemote raadminsession = raadminsessionhome.create();
58             
59             raadminsession.initGlobalConfigurationBaseURL(new Admin(Admin.TYPE_CACOMMANDLINE_USER), computername, applicationpath);
60             
61             
62         } catch (Exception JavaDoc e) {
63             throw new ErrorAdminCommandException(e);
64         }
65     }
66
67     // execute
68
}
69
Popular Tags