1 /***
2 *
3 */
4 package org.telscenter.pas.authortool.ws;
5
6 import java.io.IOException;
7 import java.net.MalformedURLException;
8 import java.net.URL;
9
10 import javax.swing.JOptionPane;
11
12 import org.doomdark.uuid.UUID;
13 import org.telscenter.pas.authortool.context.CurnitAuthoringContext;
14 import org.telscenter.pas.authortool.context.IAuthoringSessionManager;
15 import org.telscenter.pas.authortool.main.AuthoringShellMain;
16
17 /***
18 * @author aperritano
19 *
20 */
21 public class AuthoringSessionShellMain extends AuthoringShellMain {
22
23 /***
24 *
25 */
26 static final String DEFAULT_SERVICE_URL = "http://localhost:8080/RevisePasProject/services/RemoteAuthoring";
27
28 /***
29 *
30 */
31 public AuthoringSessionShellMain(
32 final CurnitAuthoringContext curnitAuthoringContext) {
33 super(curnitAuthoringContext);
34 }
35
36 /***
37 * @param args
38 * @throws IOException
39 */
40 public static void main(String[] args) {
41 UUID tokenUuid;
42 String tokenUuidStr = args[0];
43 tokenUuid = new org.doomdark.uuid.UUID(tokenUuidStr);
44 assert (tokenUuid != null);
45
46 URL url;
47 if (args.length == 1) {
48 try {
49 url = new URL(DEFAULT_SERVICE_URL);
50 } catch (MalformedURLException e) {
51
52 throw new Error("DEFAULT_SERVICE_URL is malformed");
53 }
54 } else {
55 String urlArg = args[1];
56 try {
57 url = new URL(urlArg);
58 } catch (MalformedURLException e) {
59 url = null;
60 e.printStackTrace();
61 JOptionPane.showMessageDialog(null, "URL argument malformed: "+urlArg);
62 System.exit(1);
63 }
64 }
65
66 final CurnitAuthoringContext curnitAuthoringContext;
67 try {
68 final IAuthoringSessionManager sessionManager = new WebServiceSessionManager(
69 url, tokenUuid);
70
71 curnitAuthoringContext = new CurnitAuthoringContext(
72 sessionManager);
73
74
75
76 javax.swing.SwingUtilities.invokeLater(new Runnable() {
77 public void run() {
78 new AuthoringShellMain(curnitAuthoringContext);
79 }
80 });
81 } catch (IOException e) {
82
83 e.printStackTrace();
84 JOptionPane.showMessageDialog(null, "Error connecting to service at "+url);
85 System.exit(1);
86 }
87
88 }
89 }