Package com.sun.identity.tools.bundles
Class SetupUtils
- java.lang.Object
-
- com.sun.identity.tools.bundles.SetupUtils
-
- All Implemented Interfaces:
SetupConstants
public class SetupUtils extends Object implements SetupConstants
-
-
Field Summary
-
Fields inherited from interface com.sun.identity.tools.bundles.SetupConstants
ACCEPT_LICENSE, AIX, ALL, AM_VERSION, AM_VERSION_CURRENT, AM_VERSION_EXPECTED, AMCONFIG_PATH, BASE_DIR, BUFFER_SIZE, CHECK_VERSION, CONFIG_FILE, CONFIG_LOAD, CURRENT_PLATFORM, DEBUG_PATH, DEFAULT_PROPERTIES_FILE, DEFAULT_WILD_CARD, FILE_SEPARATOR, FROM_DIR, FROM_FILE, GZIP_EXT, JAVA_VERSION_CURRENT, JAVA_VERSION_EXPECTED, LINUX, LOG_PATH, OS_ARCH, OS_NAME, PATH_DEST, PRINT_HELP, QUESTION, REX_VAR_PREFIX, REX_VAR_SUFFIX, SETUP_PROPERTIES_FILE, SOLARIS, SUNOS, TO_DIR, TO_FILE, TOKEN, TOOLS_VERSION, USER_INPUT, VAR_PREFIX, VAR_SUFFIX, VERSION_FILE, WINDOWS, X64, X86, X86SOLARIS, XML_CONFIG, YES
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyAndFilterScripts(ResourceBundle bundle, Properties lookupProp)Copy and replace the variables in the scripts.static StringdetermineOS()Determines the current operating system.static voidevaluateBundleValues(ResourceBundle bundle, Properties lookupProp)Lookups and set the resource bundle variables to the Propertiesstatic StringevaluatePropertiesValue(String value, Properties lookupProp)Lookups and replaces the variables in the stringstatic voidgetFiles(File fromDir, File toDir, String fromFilePattern, String toFilePattern, LinkedList fromFilesList, LinkedList toFilesList)Get the from files list and the to file list.static PropertiesgetTokens(ResourceBundle bundle, Properties confProp)Gets the map for text replacement.static StringgetUserInput(String message)Prompts user for input from system in.static StringgetUserInput(String message, String def)static PropertiesloadProperties(String fileName)Loads properties from file.static voidprintUsage(ResourceBundle bundle)Prints the usage through system out.static StringtransformFileName(String from, String to, File file)Transform the file name by using string patterns.static StringtransformFileName(String from, String to, File file, char wildCard)Transform the file name by using string patterns.static voidungzip(String srcFile, String destDir)Ungzip the gzip archive from source file to destinated directory.
-
-
-
Method Detail
-
loadProperties
public static Properties loadProperties(String fileName) throws IOException
Loads properties from file.- Parameters:
fileName- The path to the properties file.- Returns:
- The Properties object of the specified propertoes file.
- Throws:
IOException
-
getUserInput
public static String getUserInput(String message) throws IOException
Prompts user for input from system in.- Parameters:
message- The text message to prompt the user.- Returns:
- The user input.
- Throws:
IOException
-
getUserInput
public static String getUserInput(String message, String def) throws IOException
- Throws:
IOException
-
getTokens
public static Properties getTokens(ResourceBundle bundle, Properties confProp)
Gets the map for text replacement.- Parameters:
bundle- The ResourceBundle which contains the tokens' name.confProp- The properties which may contain the tokens value.- Returns:
- The properties object as a map for text replacement.
-
evaluatePropertiesValue
public static String evaluatePropertiesValue(String value, Properties lookupProp)
Lookups and replaces the variables in the string- Parameters:
value- The string may contain variables which need to be replaced.lookupProp- The properties may contain the real values.- Returns:
- The String with variables replaced by correct value.
-
getFiles
public static void getFiles(File fromDir, File toDir, String fromFilePattern, String toFilePattern, LinkedList fromFilesList, LinkedList toFilesList)
Get the from files list and the to file list.- Parameters:
fromDir- The directory of the source files locatedtoDir- The directory of the destinated files locatedfromFilePattern- The pattern of the name of source files.toFilePattern- The pattern of the name of destinated files.fromFilesList- (as return) List of files from the source directory.toFilesList- (as return) List of files of the destinated directory.
-
determineOS
public static String determineOS()
Determines the current operating system.- Returns:
- The string to represent the current operating system.
-
transformFileName
public static String transformFileName(String from, String to, File file)
Transform the file name by using string patterns.- Parameters:
from- The pattern of the source file.to- The pattern of the destinated file.file- The file to be transform.- Returns:
- The transformed name of the file.
-
transformFileName
public static String transformFileName(String from, String to, File file, char wildCard)
Transform the file name by using string patterns.- Parameters:
from- The pattern of the source file.to- The pattern of the destinated file.file- The file to be transform.wildCard- The wildcard character is used in the string pattern.- Returns:
- The transformed name of the file.
-
ungzip
public static void ungzip(String srcFile, String destDir) throws IOException
Ungzip the gzip archive from source file to destinated directory.- Parameters:
srcFile- The path to the source gzip archive.destDir- The destinated directory for the decompression.- Throws:
IOException
-
printUsage
public static void printUsage(ResourceBundle bundle)
Prints the usage through system out.- Parameters:
bundle- The ResourceBundle which contains the message.
-
evaluateBundleValues
public static void evaluateBundleValues(ResourceBundle bundle, Properties lookupProp)
Lookups and set the resource bundle variables to the Properties- Parameters:
bundle- The ResourceBundle is going to be evaluated.lookupProp- The properties may contain the real values and the storage of the results.
-
copyAndFilterScripts
public static void copyAndFilterScripts(ResourceBundle bundle, Properties lookupProp) throws IOException
Copy and replace the variables in the scripts.- Parameters:
bundle- The ResourceBundle which contains the prompt messages.lookupProp- The properties which contains the variables map, file patterns, source directory, and destinated directory.- Throws:
IOException
-
-