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);
}
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;
}
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;
}
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);
}
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);
}
Aggregations