Search in sources :

Example 46 with LocalizedMessage

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

the class AdminTool method run.

public void run(List args) {
    int returnCode = INT_CODE_SUCCESS;
    Debug.log("AdminTool is now starting up.");
    if (acquireLock()) {
        boolean licenseRequired = !checkImplicitLicenseAcceptance(args);
        if (licenseRequired && args.size() > 0) {
            ToolsOptionsInfo info = getOptionsInfo((String) args.get(0));
            if (info != null) {
                licenseRequired = info.isLicenseCheckRequired();
                Debug.log("AdminTool.run(): License check for " + "option: " + info.getOption() + ", required: " + licenseRequired);
            }
        }
        Debug.log("AdminTool.run(): License check required: " + licenseRequired);
        boolean licenseAccepted = false;
        try {
            if (licenseRequired) {
                LicenseChecker lc = InjectorHolder.getInstance(LicenseChecker.class);
                licenseAccepted = lc.checkLicenseAcceptance();
            } else {
                Debug.log("AdminTool.run(): Skipping license check");
                licenseAccepted = true;
            }
        } catch (Exception ex) {
            Debug.log("License check failed with exception:", ex);
        }
        if (licenseAccepted) {
            if (args.size() == 0) {
                returnCode += INT_CODE_ERROR_NO_OPTS;
                Debug.log("No options specified.");
                showUsage();
            } else {
                returnCode += dispatch(args);
            }
        } else {
            returnCode += INT_CODE_ERROR_LICENSE;
        }
    } else {
        returnCode += INT_CODE_ERROR_CONCURRENT_EXEC;
        LocalizedMessage concurrentRunError = LocalizedMessage.get(MSG_CONCURRENT_RUN_ERROR);
        Console.println();
        Console.println(concurrentRunError);
        Console.println();
    }
    Debug.log("Exiting with code: " + returnCode);
    System.exit(returnCode);
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 47 with LocalizedMessage

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

the class MultipleMigrateDriver method migrate.

/**
     * start migrate product instances. keep this method's signature for 
     * future expansion.
     *
     * @param fileName
     * @param operationType
     * @param migrateLog
     */
public void migrate(String fileName, int operationType, InstallLogger migrateLog) throws InstallException {
    Debug.log("MultipleMigrateDriver.migrate() - Starting migrate");
    // Set the install type
    setOperationType(operationType);
    // Show the welcome message
    printConsoleMessageWithMarkers(getRunInfo().getWelcomeMessageInfo());
    // read previous product home input by the user.
    String migrateFromProductHome = getMigrateFromProductHome();
    MigrateFromInstFinderStore.setProductHome(migrateFromProductHome);
    MigrateFromInstallDataStore.setProductHome(migrateFromProductHome);
    // Write the Version info to the log file
    writeVersionInfoToLog(migrateLog, LOC_DR_MSG_INSTALL_LOG_VERSION_DESC, LOC_DR_MSG_INSTALL_LOG_VERSION_DESC_LINE);
    // This object has to be created before we iterate
    InstFinderInteractionsRunner iFinderRunner = new InstFinderInteractionsRunner(getRunInfo(), null, getServerLocatorHandler());
    // Retrieve the instance finder keys to get all product details
    ArrayList instFinderKeys = iFinderRunner.getAllInteractionKeys();
    // get previous (or migrate from) product instance finder store.
    MigrateFromInstFinderStore migrateFromInstFinderStore = MigrateFromInstFinderStore.getInstance();
    Map allProductsDetails = migrateFromInstFinderStore.getAllProductDetails(instFinderKeys);
    if (allProductsDetails == null || allProductsDetails.isEmpty()) {
        LocalizedMessage productsNotFoundMsg = LocalizedMessage.get(LOC_HR_MSG_MIGRATE_NONE_FOUND);
        Console.println(productsNotFoundMsg);
        Debug.log(productsNotFoundMsg.toString());
    } else {
        // Start migrating products one at a time
        Iterator iter = allProductsDetails.keySet().iterator();
        boolean firstTime = true;
        while (iter.hasNext()) {
            String instanceName = (String) iter.next();
            Map productDetails = (Map) allProductsDetails.get(instanceName);
            Console.println();
            Console.println();
            LocalizedMessage productMigrateBeginMsg = LocalizedMessage.get(LOC_HR_MSG_MIGRATE_PRODUCT_BEGIN_MSG);
            Console.println(productMigrateBeginMsg);
            Debug.log(productMigrateBeginMsg.toString());
            Console.println();
            // Now set the transient state access with product
            // details of the instance being migrated
            TransientStateAccess stateAccess = new TransientStateAccess(productDetails);
            iFinderRunner.setStateAccess(new TransientStateAccess(productDetails));
            if (firstTime) {
                checkActiveProductHome(migrateFromProductHome, stateAccess);
                firstTime = false;
            }
            // create install state for previous product install
            MigrateFromInstallState migrateInstallState = new MigrateFromInstallState(productDetails, instFinderKeys);
            // create and set new Install State
            InstallState installState = new InstallState(productDetails, instFinderKeys);
            setInstallState(installState);
            // Migrate the instance state data, do some mappings.
            prepareMigrate(migrateInstallState, installState);
            // Execute the migration
            migrateInternal(operationType, iFinderRunner, installState, migrateLog);
        }
    }
    // Show the exit message
    printConsoleMessage(getRunInfo().getExitMessageInfo());
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 48 with LocalizedMessage

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

the class MultipleMigrateDriver method getMigrateFromProductHome.

/**
     * read from the user the product home to be migrated.
     *
     * @return
     * @throws InstallException
     */
private String getMigrateFromProductHome() throws InstallException {
    String migrateFromProductHome = null;
    I18NInfo i18Info = new I18NInfo(LOC_MIGRATE_FROM_PRODUCT_HOME, STR_GROUP);
    InteractionInfo interactionInfo = new InteractionInfo(STR_MIGRATE_FROM_PRODUCT_HOME, null, i18Info, null, true, false, "install", true, null);
    ValidationInfo validationInfo = new ValidationInfo("DIR_EXISTS", new HashMap(), "com.sun.identity.install.tools.configurator.FileSystemValidator");
    interactionInfo.addValidationInfo(validationInfo);
    UserDataInteraction interaction = InteractionFactory.createInteraction(interactionInfo);
    TransientStateAccess stateAccess = new TransientStateAccess(new HashMap());
    boolean done = false;
    while (!done) {
        done = false;
        InteractionResult interactionResult = interaction.interact(stateAccess);
        switch(interactionResult.getStatus().getIntValue()) {
            case InteractionResultStatus.INT_STATUS_CONTINUE:
                done = true;
                break;
            case InteractionResultStatus.INT_STATUS_BACK:
                stateAccess.clear();
                continue;
            case InteractionResultStatus.INT_STATUS_ABORT:
                Debug.log("MultipleMigrateDriver: ABORT requested ");
                LocalizedMessage lMessage = LocalizedMessage.get(LOC_DR_MSG_USER_ABORT);
                throw new InstallAbortException(lMessage);
        }
        // end of switch
        migrateFromProductHome = (String) stateAccess.get(interactionInfo.getLookupKey());
        // normalize the input product home
        File file = new File(migrateFromProductHome);
        if (file.isDirectory()) {
            migrateFromProductHome = file.getAbsolutePath();
        }
        // convert Windows path
        migrateFromProductHome = migrateFromProductHome.replace('\\', '/');
        if (!verifyMigrateFromProductHome(migrateFromProductHome)) {
            stateAccess.clear();
            continue;
        }
    }
    return migrateFromProductHome;
}
Also used : HashMap(java.util.HashMap) File(java.io.File) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 49 with LocalizedMessage

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

the class MigrateFromInstFinderStore method getInstanceName.

/**
     * return the instance name to be migrated from.
     *
     * @param map
     * @param keysToUse
     * @return
     * @throws InstallException
     */
public String getInstanceName(Map map, ArrayList keysToUse) throws InstallException {
    String uniqueKey = createUniqueKey(map, keysToUse);
    String instanceName = getProperty(uniqueKey);
    if (instanceName == null) {
        Debug.log("MigrateFromInstFinderStore.getInstanceName(): " + "instanceName not " + "found in the properties. Returning null value");
        Object[] args = { instanceName };
        LocalizedMessage message = LocalizedMessage.get(LOC_IS_ERR_IFINDER_INSTANCE_NOT_FOUND, args);
        throw new InstallException(message);
    } else {
        Debug.log("MigrateFromInstFinderStore.getInstanceName(): " + instanceName + " found in the properties.");
    }
    return instanceName;
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 50 with LocalizedMessage

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

the class FileSystemValidator method isFileValid.

/**
     * Method isFileValid
     *
     *
     * @param filename File path
     * @param props Map for name value pairs
     * @param IStateAccess 
     *
     * @return ValidationResult
     *
     */
public ValidationResult isFileValid(String filename, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    if (isStringValid(filename)) {
        File file = new File(filename);
        if (file.exists() && file.isFile()) {
            returnMessage = LocalizedMessage.get(LOC_VA_MSG_VAL_FILE, new Object[] { filename });
            validRes = ValidationResultStatus.STATUS_SUCCESS;
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_FILE, new Object[] { filename });
    }
    Debug.log("FileSystemValidator : Is File : " + filename + " valid ? " + validRes.isSuccessful());
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : File(java.io.File) 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