Search in sources :

Example 31 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class ConfigurePropertiesTask method getRollBackMessage.

public LocalizedMessage getRollBackMessage(IStateAccess stateAccess, Map properties) {
    String productConfigFileName = (String) properties.get(STR_PRODUCT_CONFIG_FILENAME_AGENT_BOOTSTRAP_KEY);
    Object[] args = { productConfigFileName, stateAccess.getInstanceName() };
    LocalizedMessage message = LocalizedMessage.get(LOC_TSK_MSG_CONFIGURE_PRODUCT_PROPS_ROLLBACK, args);
    return message;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 32 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class ConfigurePropertiesTask method getExecutionMessage.

public LocalizedMessage getExecutionMessage(IStateAccess stateAccess, Map properties) {
    String productConfigFileName = (String) properties.get(STR_PRODUCT_CONFIG_FILENAME_AGENT_BOOTSTRAP_KEY);
    Object[] args = { productConfigFileName, stateAccess.getInstanceName() };
    LocalizedMessage message = LocalizedMessage.get(LOC_TSK_MSG_CONFIGURE_PRODUCT_PROPS_EXECUTE, args);
    return message;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 33 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class AdminTool method showUsage.

private void showUsage() {
    LocalizedMessage usageMessage = LocalizedMessage.get(MSG_USAGE);
    LocalizedMessage availableOpts = LocalizedMessage.get(MSG_AVAIL_OPTS);
    Console.println();
    Console.println(usageMessage);
    Console.println();
    Console.println(availableOpts);
    BaseToolsResolver resolver = ToolsConfiguration.getToolsResolver();
    ArrayList options = resolver.getAllSupportedOptions();
    Iterator it = options.iterator();
    while (it.hasNext()) {
        ToolsOptionsInfo info = (ToolsOptionsInfo) it.next();
        Console.println(info.getDescription());
    }
    Console.println(LocalizedMessage.get(MSG_OPTION_DESC_USAGE));
    Console.println(LocalizedMessage.get(MSG_OPTION_DESC_HELP));
    Console.println();
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 34 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class AdminTool method dispatch.

private int dispatch(List filteredArgs) {
    int returnCode = INT_CODE_SUCCESS;
    String optionArg = (String) filteredArgs.remove(0);
    Debug.log("Trying to dispatch to option handler for: " + optionArg);
    BaseToolsResolver resolver = ToolsConfiguration.getToolsResolver();
    ArrayList options = resolver.getAllSupportedOptions();
    if (optionArg.equals(STR_USAGE_OPTION)) {
        showUsage();
    } else if (optionArg.equals(STR_HELP_OPTION)) {
        Iterator it = options.iterator();
        while (it.hasNext()) {
            Console.println();
            ToolsOptionsInfo info = (ToolsOptionsInfo) it.next();
            Console.println(info.getDescription());
            String handlerClass = info.getHandlerClass();
            try {
                IToolsOptionHandler handler = (IToolsOptionHandler) Class.forName(handlerClass).newInstance();
                handler.displayHelp();
            } catch (Exception ex) {
                returnCode += INT_CODE_ERROR_UNKNOWN;
                Debug.log("Exception caught during help dispatch:", ex);
                LocalizedMessage unknownError = LocalizedMessage.get(MSG_UNKNOWN_ERROR);
                Console.println();
                Console.println(unknownError, new Object[] { ex.getMessage() });
                Console.println();
                break;
            }
        }
    } else {
        String handlerClass = null;
        Iterator it = options.iterator();
        boolean optionValid = false;
        while (it.hasNext()) {
            ToolsOptionsInfo info = (ToolsOptionsInfo) it.next();
            if (info.getOption().equals(optionArg)) {
                handlerClass = info.getHandlerClass();
                optionValid = true;
                break;
            }
        }
        if (!optionValid) {
            returnCode += INT_CODE_ERROR_INVALID_OPTS;
            Debug.log("No handler found for option: " + optionArg);
            LocalizedMessage errorInvalidOption = LocalizedMessage.get(MSG_INVALID_OPTION);
            Console.println();
            Console.println(errorInvalidOption, new Object[] { optionArg });
            Console.println();
        } else {
            try {
                IToolsOptionHandler handler = (IToolsOptionHandler) Class.forName(handlerClass).newInstance();
                if (handler.checkArguments(filteredArgs)) {
                    handler.handleRequest(filteredArgs);
                } else {
                    // Invalid arguments specified. Display help!
                    handler.displayHelp();
                }
            } catch (Exception ex) {
                returnCode += INT_CODE_ERROR_UNKNOWN;
                Debug.log("Exception caught during option dispatch", ex);
                LocalizedMessage unknownError = LocalizedMessage.get(MSG_UNKNOWN_ERROR);
                Console.println();
                Console.println(unknownError, new Object[] { ex.getMessage() });
                Console.println();
            }
        }
    }
    return returnCode;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 35 with LocalizedMessage

use of com.sun.identity.install.tools.util.LocalizedMessage in project OpenAM by OpenRock.

the class BackupFileTask method getRollBackMessage.

public LocalizedMessage getRollBackMessage(IStateAccess stateAccess, Map properties) {
    String fileName = getFileName(stateAccess, properties);
    Object[] args = { fileName };
    LocalizedMessage message = LocalizedMessage.get(LOC_TSK_MSG_BACKUP_FILE_ROLLBACK, args);
    return message;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Aggregations

LocalizedMessage (com.sun.identity.install.tools.util.LocalizedMessage)73 Map (java.util.Map)9 File (java.io.File)8 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)6 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 ConnectException (java.net.ConnectException)4 UnknownHostException (java.net.UnknownHostException)4 StringTokenizer (java.util.StringTokenizer)4 FileNotFoundException (java.io.FileNotFoundException)3 RESTUtils (com.sun.identity.install.tools.util.RESTUtils)2 BufferedReader (java.io.BufferedReader)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 URLConnection (java.net.URLConnection)2 TreeMap (java.util.TreeMap)2 Audit (com.sun.identity.install.tools.util.Audit)1 FileReader (java.io.FileReader)1 InputStream (java.io.InputStream)1