01: package hero.util;
02:
03: import javax.security.auth.login.LoginContext;
04: import hero.client.test.SimpleCallbackHandler;
05:
06: import hero.interfaces.*;
07:
08: import java.util.*;
09:
10: public class Delete_model {
11:
12: static public void main(String[] args) throws Exception {
13:
14: try {
15: char[] password = { 't', 'o', 't', 'o' };
16: SimpleCallbackHandler handler = new SimpleCallbackHandler(
17: "admin", password);
18: LoginContext lc = new LoginContext("TestClient", handler);
19: lc.login();
20:
21: UserSessionHome userSessionh = UserSessionUtil.getHome();
22: UserSession us = userSessionh.create();
23:
24: Collection instances = us.getProjectInstancesNames(args[0]);
25: Iterator i = instances.iterator();
26: while (i.hasNext()) {
27: String instName = (String) i.next();
28: us.removeProject(instName);
29: System.out
30: .println(" Deleting instance : " + instName);
31: }
32:
33: us.removeProject(args[0]);
34: System.out.println(" Deleting previous model : "
35: + args[0] + "\n");
36: } catch (Exception e) {
37: throw new Exception("An error was produced during the "
38: + args[0] + " model delete: " + e.getMessage());
39: }
40: }
41: }
|