fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * The contents of this file are subject to the terms
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * of the Common Development and Distribution License
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * (the License). You may not use this file except in
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * compliance with the License.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * You can obtain a copy of the License at
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * https://opensso.dev.java.net/public/CDDLv1.0.html or
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * See the License for the specific language governing
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * permission and limitations under the License.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * When distributing Covered Code, include this CDDL
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Header Notice in each file and include the License file
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * If applicable, add the following below the CDDL Header,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * with the fields enclosed by brackets [] replaced by
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * your own identifying information:
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * "Portions Copyrighted [year] [name of copyright owner]"
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * $Id: InstallInteraction.java,v 1.3 2008/06/25 05:51:20 qcheng Exp $
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorpackage com.sun.identity.install.tools.configurator;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.Console;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.Debug;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorimport com.sun.identity.install.tools.util.LocalizedMessage;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Interaction class to handle user input. This interaction class can handle
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * all user data input related interactions including password interactions.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * This class extends UserDataInteraction and implements all the necessary
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * hooks to process options and user input in interactive mode.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Majorpublic class InstallInteraction extends UserDataInteraction implements
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Constructor for Interaction class
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public InstallInteraction(InteractionInfo info) throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Method to be called for interact install @param state IStateAccess
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @return InteractionResult
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public InteractionResult interact(IStateAccess state)
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Method to be process user input for interactive mode
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @pararm userInput User input @param state IStateAccess
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @return InteractionResult
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public InteractionResult processData(String userInput, IStateAccess state)
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major boolean isReq = getInteractionInfo().getRequiredFlag();
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major String procInput = preProcessUserInput(userInput, state, isReq);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Invalid user input
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major if ((!isReq) && (procInput.equals(STR_IN_EMPTY_STRING))) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major result = InteractionResultStatus.STATUS_CONTINUE;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major state.put(getKey(), getNormalizedValue(procInput));
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major CumulativeValResult cumRes = processValidators(procInput,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Specific warning message
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major result = InteractionResultStatus.STATUS_CONTINUE;
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Store the user input
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major state.put(getKey(), getNormalizedValue(procInput));
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Now copy the calc keys only if cum res = true
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Specific error message
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major summaryDesc = LocalizedMessage.get(LOC_IN_MESS_SUMMARY_DESC_FORMAT,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major interResult = new InteractionResult(result, null, summaryDesc);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * Method to be process user option in interactive mode
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @pararm option UserOptionItem @param state IStateAccess
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @return InteractionResult
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public InteractionResult processOption(UserOptionItem option,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major if (option.getDisplayItem().equals(STR_IN_MSG_OPTION_HELP)) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major } else if (option.getDisplayItem().equals(STR_IN_MSG_OPTION_BACK)) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major result = new InteractionResult(InteractionResultStatus.STATUS_BACK,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major } else if (option.getDisplayItem().equals(STR_IN_MSG_OPTION_EXIT)) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major InteractionResultStatus.STATUS_ABORT, null, null);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major } else if (option.getDisplayItem().equals(STR_IN_MSG_OPTION_CLR_DEF)) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Put empty value for this interaction in IStateAccess
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major LocalizedMessage summaryDesc = LocalizedMessage.get(
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * This function need to now display an extra option depending on whether
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * default value is present ir not. @param state
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major * @return BaseOptions
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public BaseOptions getUserOptions(IStateAccess state)
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // create this option only for this case
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major clearDefOpt = new UserOptionItem(STR_IN_MSG_OPTION_CLR_DEF,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major LOC_IN_MSG_OPTION_CLR_DEF, LOC_IN_MSG_OPTION_CLR_DEF
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major if (defaultValue != null && defaultValue.length() > 0
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public LocalizedMessage getPromptMessage(IStateAccess state) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public String getPromptValue(IStateAccess state) throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Remove the back option, beacause it was already added while
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // initialization.
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major public String getDefaultValue(IStateAccess state) throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // Only for isreq = false, re-process the default value
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major defValue = processDefaultValFromAllSources(state);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major Debug.log("InstallInteraction.getDefaultValue() : Is Required "
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major && (defaultValue.equals(STR_IN_EMPTY_STRING))) {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major private void setDefaultValue(IStateAccess state) throws InstallException {
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major defValue = processDefaultValFromAllSources(state);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major defValue = processDefaultValFromStateOnly(state);
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major options.add(new UserOptionItem(STR_IN_MSG_OPTION_HELP,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major backOption = new UserOptionItem(STR_IN_MSG_OPTION_BACK,
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // At this point isFirst flag is not set. So, the back option will be
fb379c70e3fd8a537f311b99be4759ae41e02750Peter Major // added and it will be removed later