Package org.duracloud.sync.config
Class SyncToolConfigParser
- java.lang.Object
-
- org.duracloud.sync.config.SyncToolConfigParser
-
public class SyncToolConfigParser extends Object
Handles reading the configuration parameters for the Sync Tool
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringBACKUP_FILE_NAMEprotected static Stringcontextprotected static intDEFAULT_MAX_FILE_SIZEprotected static intDEFAULT_NUM_THREADSprotected static longDEFAULT_POLL_FREQUENCYprotected static intDEFAULT_PORTprotected static longGIGABYTEprotected static StringPREV_BACKUP_FILE_NAME
-
Constructor Summary
Constructors Constructor Description SyncToolConfigParser()Creates a parser for command line configuration options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbackupConfig(File backupDir, String[] args)protected ConsolePromptgetConsole()protected StringgetPasswordEnvVariable()SyncToolConfigprocessCommandLine(String[] args)Parses command line configuration into an object structure, validates correct values along the way.protected SyncToolConfigprocessConfigFileOptions(String[] args)protected SyncToolConfigprocessStandardOptions(String[] args)protected SyncToolConfigprocessStandardOptions(String[] args, boolean requirePassword)protected String[]retrieveConfig(File configBackupFile)SyncToolConfigretrievePrevConfig(File backupDir)Retrieves the configuration of the previous run of the Sync Tool.
-
-
-
Field Detail
-
GIGABYTE
protected static final long GIGABYTE
- See Also:
- Constant Field Values
-
BACKUP_FILE_NAME
protected static final String BACKUP_FILE_NAME
- See Also:
- Constant Field Values
-
PREV_BACKUP_FILE_NAME
protected static final String PREV_BACKUP_FILE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_PORT
protected static final int DEFAULT_PORT
- See Also:
- Constant Field Values
-
DEFAULT_POLL_FREQUENCY
protected static final long DEFAULT_POLL_FREQUENCY
- See Also:
- Constant Field Values
-
DEFAULT_NUM_THREADS
protected static final int DEFAULT_NUM_THREADS
- See Also:
- Constant Field Values
-
DEFAULT_MAX_FILE_SIZE
protected static final int DEFAULT_MAX_FILE_SIZE
- See Also:
- Constant Field Values
-
context
protected static final String context
- See Also:
- Constant Field Values
-
-
Method Detail
-
processCommandLine
public SyncToolConfig processCommandLine(String[] args)
Parses command line configuration into an object structure, validates correct values along the way. Prints a help message and exits the JVM on parse failure.- Parameters:
args- command line configuration values- Returns:
- populated SyncToolConfig
-
processConfigFileOptions
protected SyncToolConfig processConfigFileOptions(String[] args) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
processStandardOptions
protected SyncToolConfig processStandardOptions(String[] args) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
processStandardOptions
protected SyncToolConfig processStandardOptions(String[] args, boolean requirePassword) throws org.apache.commons.cli.ParseException
- Throws:
org.apache.commons.cli.ParseException
-
retrievePrevConfig
public SyncToolConfig retrievePrevConfig(File backupDir)
Retrieves the configuration of the previous run of the Sync Tool. If there was no previous run, the backup file cannot be found, or the backup file cannot be read, returns null, otherwise returns the parsed configuration- Parameters:
backupDir- the current backup directory- Returns:
- config for previous sync tool run, or null
-
getPasswordEnvVariable
protected String getPasswordEnvVariable()
-
getConsole
protected ConsolePrompt getConsole()
-
-