1 11 package org.eclipse.help.internal.standalone; 12 13 import java.net.Authenticator ; 14 import java.net.HttpURLConnection ; 15 import java.net.PasswordAuthentication ; 16 import java.util.List ; 17 18 import org.eclipse.help.internal.base.*; 19 20 23 public class StandaloneInfocenter extends EclipseController { 24 private static final String INFOCENTER_APPLICATION_ID = HelpBasePlugin.PLUGIN_ID 26 + ".infocenterApplication"; 28 38 public StandaloneInfocenter(String [] args) { 39 super(INFOCENTER_APPLICATION_ID, args); 40 } 41 42 45 public static void main(String [] args) { 46 try { 47 StandaloneInfocenter infocenter = new StandaloneInfocenter(args); 48 49 List helpCommand = Options.getHelpCommand(); 50 51 final String adminId = Options.getAdminId(); 52 final String adminPassword = Options.getAdminPassword(); 53 Authenticator.setDefault(new Authenticator () { 54 protected PasswordAuthentication getPasswordAuthentication() { 55 return new PasswordAuthentication (adminId, adminPassword.toCharArray()); 56 } 57 }); 58 HttpURLConnection.setFollowRedirects(true); 59 60 if (infocenter.executeCommand(helpCommand)) { 61 return; 62 } 63 printMainUsage(); 64 } catch (Exception e) { 65 e.printStackTrace(); 66 } 67 } 68 69 72 private boolean executeCommand(List helpCommand) throws Exception { 73 if (helpCommand.size() <= 0) { 74 return false; 75 } 76 String command = (String ) helpCommand.get(0); 77 if ("start".equalsIgnoreCase(command)) { start(); 79 return true; 80 } else if ("shutdown".equalsIgnoreCase(command)) { shutdown(); 82 return true; 83 } else if (CMD_INSTALL.equalsIgnoreCase(command) 84 || CMD_ENABLE.equalsIgnoreCase(command) 85 || CMD_DISABLE.equalsIgnoreCase(command) 86 || CMD_UNINSTALL.equalsIgnoreCase(command) 87 || CMD_UPDATE.equalsIgnoreCase(command) 88 || CMD_SEARCH.equalsIgnoreCase(command) 89 || CMD_LIST.equalsIgnoreCase(command) 90 || CMD_ADDSITE.equalsIgnoreCase(command) 91 || CMD_REMOVESITE.equalsIgnoreCase(command) 92 || CMD_APPLY.equalsIgnoreCase(command)) { 93 return executeUpdateCommand(command); 94 } 95 return false; 96 } 97 98 101 private static void printMainUsage() { 102 System.out.println("Parameters syntax:"); System.out.println(); 104 System.out 105 .println("-command start | shutdown | [update command [update parameters]] [-eclipsehome eclipseInstallPath] [-host helpServerHost] [-port helpServerPort] [-adminId administratorUserId] [-adminPassword administratorPassword] [-trustStoreLocation trustStoreLocation] [-trustStorePassword trustStorePassword][-noexec] [platform options] [-vmargs [Java VM arguments]]"); System.out.println(); 107 System.out.println("where:"); System.out 109 .println(" eclipseInstallPath specifies Eclipse installation directory; this directory is a parent to \"plugins\" directory and eclipse executable; the option must be provided, when current directory from which infocenter is launched, is not the same as Eclipse installation directory,"); System.out 111 .println(" helpServerHost specifies host name of the interface that help server will use,"); System.out 113 .println(" helpServerPort specifies port number that help server will use,"); System.out 115 .println(" administratorUserId specifies the administrator user id to use when secure access is enabled"); System.out 117 .println(" administratorPassword specifies the administrator password to use when secure access is enabled"); System.out 119 .println(" trustStoreLocation specifies the location of the truststore file to use when secure access is enabled"); System.out 121 .println(" trustStorePassword specifies the password of the truststore file when secure access is enabled"); System.out 123 .println(" noexec option indicates that Eclipse executable should not be used, "); System.out 125 .println(" platform options are other options that are supported by Eclipse Executable,"); System.out 127 .println(" update command is one of install, update, enable, disable, uninstall, search, listFeatures, addSite, removeSite, or apply,"); System.out 129 .println(" update parameters are -featureId, -version, -from, -to, -verifyOnly as required by update commands used."); } 131 132 } 133 | Popular Tags |