Search in sources :

Example 6 with LocalizedMessage

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

the class StringValidator method isPositiveInteger.

public ValidationResult isPositiveInteger(String str, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    if ((str != null) && (str.trim().length() >= 0)) {
        try {
            int strVal = Integer.parseInt(str);
            if (strVal >= 0) {
                returnMessage = LocalizedMessage.get(LOC_VA_MSG_NUM_STR, new Object[] { str });
                validRes = ValidationResultStatus.STATUS_SUCCESS;
            } else {
                Debug.log("StringValidator : " + "Value passed is a negative integer");
            }
        } catch (NumberFormatException nfe) {
            Debug.log("StringValidator.isPositiveInteger(..) " + "threw exception :", nfe);
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_NON_NUM_STR, new Object[] { str });
    }
    Debug.log("StringValidator : Is string : " + str + " valid ? " + validRes.isSuccessful());
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 7 with LocalizedMessage

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

the class MigrateFromInstFinderStore method getInstance.

/**
     * get the singleton of MigrateFromInstFinderStore.
     *
     * @return MigrateFromInstFinderStore
     * @throws InstallException thrown if reading instance finder file fails.
     */
public static synchronized MigrateFromInstFinderStore getInstance() throws InstallException {
    if (instanceIdentifier == null) {
        instanceIdentifier = new MigrateFromInstFinderStore();
        File file = new File(getTranslateFile());
        if (file.exists() && file.canRead()) {
            Debug.log("MigrateFromInstFinderStore : " + "initializing instance by loading" + " the properties");
            instanceIdentifier.load();
        } else {
            Debug.log("MigrateFromInstFinderStore : " + "Error - can not find old product finder store. " + "File Name:" + getTranslateFile());
            Object[] args = { getTranslateFile() };
            LocalizedMessage message = LocalizedMessage.get(LOC_IS_ERR_IFINDER_FILE_NOT_EXIST, args);
            throw new InstallException(message);
        }
    }
    return instanceIdentifier;
}
Also used : File(java.io.File) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 8 with LocalizedMessage

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

the class MigrateFromInstFinderStore method extractInstanceFinderValues.

private Map extractInstanceFinderValues(String key, String instanceName, ArrayList mapKeys) throws InstallException {
    Map iFinderValues = new TreeMap();
    StringTokenizer st = new StringTokenizer(key, STR_IS_LOOK_UP_KEY_FIELD_SEP);
    int count = mapKeys.size();
    if (count != st.countTokens()) {
        Debug.log("MigrateFromInstFinderStore." + "extractInstanceFinderValues(): " + "Error - size of mapKeys and number of tokens " + "are not same. key = " + key + ", mapKeys = " + mapKeys.toString());
        Object[] args = { instanceName };
        LocalizedMessage message = LocalizedMessage.get(LOC_IS_ERR_EXTRACT_IFINDER_DATA);
        throw new InstallException(message);
    }
    for (int i = 0; i < count; i++) {
        String mapKey = (String) mapKeys.get(i);
        iFinderValues.put(mapKey, st.nextElement());
    }
    return iFinderValues;
}
Also used : StringTokenizer(java.util.StringTokenizer) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 9 with LocalizedMessage

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

the class NetworkValidator method isFullyQualifiedHost.

/**
     * Checks whether the host name is fully qualified
     * 
     * @param host
     * @param props
     * @param state
     * 
     * @return ValidationResult
     * 
     */
public ValidationResult isFullyQualifiedHost(String host, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    if ((host != null) && (host.length() > 0)) {
        if ((!host.startsWith(".")) && (!host.endsWith("."))) {
            StringTokenizer tokens = new StringTokenizer(host, ".");
            if (tokens.countTokens() >= 3) {
                validRes = ValidationResultStatus.STATUS_SUCCESS;
            }
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_FULLY_QUAL_HOST, new Object[] { host });
    }
    Debug.log("NetworkValidator : Is Host name : " + host + " fully " + "qualified ? " + validRes.isSuccessful());
    return new ValidationResult(validRes, null, returnMessage);
}
Also used : StringTokenizer(java.util.StringTokenizer) LocalizedMessage(com.sun.identity.install.tools.util.LocalizedMessage)

Example 10 with LocalizedMessage

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

the class NetworkValidator method isValidProtocol.

/**
     * Method validateProtocol
     * 
     * 
     * @param proto
     * @param props
     * @param state
     * 
     * @return ValidationResult
     * 
     */
public ValidationResult isValidProtocol(String proto, Map props, IStateAccess state) {
    ValidationResultStatus validRes = ValidationResultStatus.STATUS_FAILED;
    LocalizedMessage returnMessage = null;
    if ((proto != null) && (proto.length() > 0)) {
        if ((proto.compareToIgnoreCase(STR_VA_HTTP_PROTO) == 0) || (proto.compareToIgnoreCase(STR_VA_HTTPS_PROTO) == 0)) {
            returnMessage = LocalizedMessage.get(LOC_VA_MSG_VAL_PROTO, new Object[] { proto });
            validRes = ValidationResultStatus.STATUS_SUCCESS;
        }
    }
    if (validRes.getIntValue() == ValidationResultStatus.INT_STATUS_FAILED) {
        returnMessage = LocalizedMessage.get(LOC_VA_WRN_IN_VAL_PROTO, new Object[] { proto });
    }
    Debug.log("NetworkValidator : Is protocol : " + proto + " valid ? " + validRes.isSuccessful());
    return new ValidationResult(validRes, null, returnMessage);
}
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