| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | import org.opends.quicksetup.util.ProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | |
| | | |
| | | private UserData userData; |
| | | |
| | | static private final Logger LOG = |
| | | Logger.getLogger(QuickSetupCli.class.getName()); |
| | | |
| | | /** |
| | | * Creates a QuickSetupCli instance. |
| | | * @param cliApp the application to be run |
| | |
| | | |
| | | /** |
| | | * Parses the user data and prompts the user for data if required. If the |
| | | * user provides all the required data it launches the Uninstaller. |
| | | * user provides all the required data it launches the application. |
| | | * |
| | | * @return the return code (SUCCESSFUL, CANCELLED, USER_DATA_ERROR, |
| | | * ERROR_ACCESSING_FILE_SYSTEM, ERROR_STOPPING_SERVER or BUG. |
| | |
| | | }); |
| | | } |
| | | Thread appThread = new Thread(cliApp, "CLI Application"); |
| | | LOG.log(Level.INFO, "Launching application"); |
| | | appThread.start(); |
| | | while (!Thread.State.TERMINATED.equals(appThread.getState())) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | returnValue = cliApp.getReturnCode(); |
| | | LOG.log(Level.INFO, "Application returnValue: "+returnValue); |
| | | if (returnValue == null) { |
| | | ApplicationException ue = cliApp.getRunError(); |
| | | if (ue != null) |
| | | { |
| | | LOG.log(Level.INFO, "Application run error: "+ue, ue); |
| | | returnValue = ue.getType(); |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (UserDataException uude) |
| | | { |
| | | LOG.log(Level.SEVERE, "UserDataException: "+uude, uude); |
| | | System.err.println(); |
| | | System.err.println(StaticUtils.wrapText(uude.getLocalizedMessage(), |
| | | Utils.getCommandLineMaxLineWidth())); |
| | |
| | | } |
| | | catch (ApplicationException ae) |
| | | { |
| | | LOG.log(Level.SEVERE, "ApplicationException: "+ae, ae); |
| | | System.err.println(); |
| | | System.err.println(ae.getLocalizedMessage()); |
| | | System.err.println(); |
| | | returnValue = ae.getType(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | LOG.log(Level.SEVERE, "Unexpected error: "+t, t); |
| | | returnValue = ReturnCode.UNKNOWN; |
| | | } |
| | | LOG.log(Level.INFO, "returnValue: "+returnValue.getReturnCode()); |
| | | return returnValue; |
| | | } |
| | | |