01: package com.sun.portal.portlet.cli;
02:
03: import java.util.Locale;
04: import java.util.logging.Logger;
05: import java.util.logging.Level;
06:
07: import com.sun.portal.common.clip.CLIPParser;
08: import com.sun.portal.log.common.PortalLogger;
09:
10: /**
11: * This class is the Main class for the Portlet Deployment Tool.
12: * This class is invoked from the deployer script with the right
13: * command line options which later will be passed onto PortletDeployerCommand
14: * class for parsing.
15: */
16: class PortletDeployerMain {
17: private static Logger debugLogger = PortalLogger
18: .getLogger(PortletDeployerMain.class);
19:
20: public static final String COMMANDNAME = "pdeploy";
21: public static final String COMMANDVERSION = "1.0";
22:
23: PortletDeployerMain(String[] args) {
24:
25: // first thing first - extract locale information
26: for (int i = 0; i < args.length; i++) {
27: if (args[i].equals("-l")
28: || args[i].equals("--"
29: + PortletDeployerCommand.LOCALE)) {
30: if (i < args.length - 1) {
31: Locale locale = PortletDeployerLocalizer
32: .getLocale(args[i + 1]);
33: PortletDeployerException.setLocale(locale);
34: PortletDeployerLocalizer.setLocale(locale);
35: }
36: }
37: }
38:
39: // set up debug
40: /*
41: debug = Debug.getInstance(LOG_FILENAME);
42: if (debug == null) {
43: Object[] tokens = { LOG_FILENAME };
44: PortletDeployerLocalizer.error("errorLogInitFailed", tokens);
45: } else {
46: debug.setDebug(Debug.ERROR);
47: }
48: */
49: }
50:
51: public static void main(String[] args) {
52: PortletDeployerMain pd = new PortletDeployerMain(args);
53:
54: CLIPParser clipp = null;
55: try {
56: clipp = PortletDeployerCommand.getCLIPParser();
57: PortletDeployerCommand cmd = new PortletDeployerCommand(
58: clipp, args);
59: cmd.runCommand();
60: System.exit(0);
61: } catch (PortletDeployerException pdex) {
62:
63: // output exception message
64: String wrappedMsg = pdex.getWrappedMessage();
65: if (wrappedMsg != null && wrappedMsg.length() > 0) {
66: Object[] tokens = { pdex.getLocalizedMessage(),
67: wrappedMsg };
68: PortletDeployerLocalizer.error("msgWrappedError",
69: tokens);
70: } else {
71: Object[] tokens = { pdex.getLocalizedMessage() };
72: PortletDeployerLocalizer.error("msgError", tokens);
73: }
74: debugLogger.log(Level.SEVERE, "PSPL_CLCSPPC0001", pdex);
75: System.exit(1);
76:
77: } catch (Exception ex) {
78:
79: // output exception message
80: Object[] tokens = { ex.getLocalizedMessage() };
81: PortletDeployerLocalizer.error("msgError", tokens);
82: debugLogger.log(Level.SEVERE, "PSPL_CLCSPPC0001", ex);
83: System.exit(1);
84: }
85:
86: }
87: }
|