public class LibraryUpdate
extends java.lang.Object
For example, users can use this to grab centrally located build assets to update the SAFS\lib JAR files. Or, it can be used to update TCAFS libraries located in TCAFS\TCAFS\Script.
The support for this is narrowly focused to SAFS assets at this time.
Specifically, only the following file types are supported:
In addition, only source assets dated newer than Aug 01, 2012 are considered for update.
The class supports backing up older files into any specified directory. It also supports directory recursion, and an option to override the prompting for file replacement.
There are no SAFS dependencies in this class and can be packaged stand-alone in an executable JAR file.
Command-line options:
-q (quiet mode, no prompt dialog), it should be put before other argument if present"
"-prompt:titlebar" (alternate prompt title bar message)
This parameter should appear before other parameters (at this time)
-b:backupdir **(backup dir for replaced files)
-s:sourcedir * (source dir containing newer files, or an HTTP URL to a ZIP)
Supports HTTP URL to a ZIP file that would be downloaded and extracted into a temporary directory
to be used as the sourcedir for the update.
Note: Any spaces in the URL should be retained as spaces--not URLEncoded.
The code will handle URL encoding of spaces.
Ex: -s:http://sourceforge.net/projects/safsdev/files/SAFS Updates/SAFS.LIB Updates/SAFS.LIB.UPDATE.LATEST.ZIP
-t:targetdir * (target dir receiving newer files)
-f (force w/o prompting for each file)
-r (recurse into sub-directories)
-a (file of all types will be copy, default false)
-e:dir1;dir2 -e: followed by excluded folders separated by semi-colon, such as jre;Java;Java64
These folders can be relative to the target directory or can be absolute directory.
These folders will be excluded when updating, which means they and their sub-folders will not be updated.
-nob (no file backups required)
* - required parameter.
** - only required if -nob not provided.
Entry points are:
processArgs
main
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
_VERSION_
1.0 current version
|
(package private) boolean |
allfilecopy |
static java.lang.String |
ARG_PREFIX_A
-a all file types; if not specified, only .JAR, .SVB, and .DAT will be updated, see
fileIncluded(File) |
static java.lang.String |
ARG_PREFIX_B
-b: followed by backup directory
|
static java.lang.String |
ARG_PREFIX_E
-e: followed by excluded folders (can be relative to target directory) separated by semi-colon, such as jre;Java;Java64
|
static java.lang.String |
ARG_PREFIX_E_SEP |
static java.lang.String |
ARG_PREFIX_F
-f Force Overwrite
|
static java.lang.String |
ARG_PREFIX_NOB
-nob Do NOT Backup older files
|
static java.lang.String |
ARG_PREFIX_P
-prompt: followed by Title
|
static java.lang.String |
ARG_PREFIX_Q
-q quiet mode
|
static java.lang.String |
ARG_PREFIX_R
-r Recurse Directories
|
static java.lang.String |
ARG_PREFIX_S
-s: followed by source (an URL or a file path)
|
static java.lang.String |
ARG_PREFIX_T
-t: followed by target directory
|
static java.lang.String |
ARG_PREFIX_TOOLS
-tools: followed by tools' name separated by semi-colon, such as GhostScript;Tool2;Tool3, to be updated or installed
|
(package private) java.io.File |
backupdir |
(package private) int |
backupFiles |
(package private) java.util.HashMap<java.io.File,java.io.File> |
backups |
boolean |
canceled
Gets set TRUE if the user cancelled the update from a dialog prompt.
|
java.lang.String |
canceledMSG |
(package private) java.io.PrintStream |
console |
(package private) boolean |
dobackup |
(package private) boolean |
downloadDone
If we need to download file from Internet in a separate thread,
we need to set this field to false in the main thread. |
(package private) java.io.PrintStream |
errors |
(package private) java.util.List<java.io.File> |
excludedFolderList |
(package private) java.lang.String |
excludedFolderString |
(package private) boolean |
force |
static java.lang.String |
HELP_STRING |
(package private) static java.lang.String |
LC_DAT |
(package private) static java.lang.String |
LC_EXE |
(package private) static java.lang.String |
LC_JAR |
(package private) static java.lang.String |
LC_SVB |
(package private) static java.lang.String |
LC_TSCRIPT |
(package private) int |
modifiedFiles |
static long |
OLDEST_DATE |
protected SePlusInstallInfo |
productInfo
Used to get the information of the current installed product.
|
(package private) int |
progress |
(package private) ProgressIndicator |
progressor |
(package private) java.lang.String |
prompt |
(package private) boolean |
quiet
quiet mode, if true then no dialog will prompt for confirmation, default is 'false'.
|
(package private) boolean |
recurse |
(package private) java.io.File |
sourcedir |
(package private) java.io.File |
targetdir |
(package private) java.lang.String[] |
toolsToUpdate |
(package private) boolean |
unzipDone
If we need to download zip file from Internet and unzip it in a separate thread,
we need to set this field to false in the main thread. |
protected FileUtilities.Predicate<java.lang.String> |
unzipSkipPredicator
Used to skip any files when un-zip file.
|
Constructor and Description |
---|
LibraryUpdate()
Default constructor using standard System.out and System.err console streams.
|
LibraryUpdate(java.io.PrintStream console,
java.io.PrintStream errors)
Alternate constructor provide different console and error output streams.
|
Modifier and Type | Method and Description |
---|---|
(package private) boolean |
allFileIncluded(java.io.File file)
Include all Files newer than OLDEST_DATE
|
(package private) void |
backupFile(java.io.File targetfile,
java.io.File backupdir)
Uses copyFile to backup a targetfile to a backup directory.
|
protected void |
close() |
(package private) void |
copyFile(java.io.File sourcefile,
java.io.File targetfile)
Copy a sourcefile to a targetfile location.
|
static boolean |
download(java.lang.String url,
java.io.File outfile) |
(package private) void |
downloadURL(java.lang.String url,
java.io.File outfile) |
(package private) boolean |
fileIncluded(java.io.File file)
Include only .JAR, .SVB, and .DAT Files newer than OLDEST_DATE
|
(package private) static void |
help(java.io.PrintStream out) |
protected void |
init() |
boolean |
isQuiet() |
static void |
main(java.lang.String[] args)
The main entry point for the application when invoked via the command-line.
|
(package private) java.io.File |
prepareTempSourceDirectory()
Prepare temporary directory for holding files downloaded from Internet.
|
boolean |
processArgs(java.lang.String[] args)
Main entry point for an instance of the class not executing from the command-line.
|
(package private) void |
updateDirectory(java.io.File targetdir,
java.io.File sourcedir,
java.io.File backupdir)
Re-entrant routine to process the provided directories.
|
public static final java.lang.String _VERSION_
public static final java.lang.String ARG_PREFIX_B
public static final java.lang.String ARG_PREFIX_NOB
public static final java.lang.String ARG_PREFIX_P
public static final java.lang.String ARG_PREFIX_T
public static final java.lang.String ARG_PREFIX_S
public static final java.lang.String ARG_PREFIX_R
public static final java.lang.String ARG_PREFIX_F
public static final java.lang.String ARG_PREFIX_A
fileIncluded(File)
public static final java.lang.String ARG_PREFIX_Q
public static final java.lang.String ARG_PREFIX_E
public static final java.lang.String ARG_PREFIX_E_SEP
public static final java.lang.String ARG_PREFIX_TOOLS
public static final long OLDEST_DATE
java.io.PrintStream console
java.io.PrintStream errors
java.lang.String prompt
boolean recurse
boolean force
boolean quiet
boolean dobackup
boolean allfilecopy
public boolean canceled
public java.lang.String canceledMSG
java.io.File targetdir
java.io.File sourcedir
java.io.File backupdir
int modifiedFiles
int backupFiles
java.lang.String excludedFolderString
java.util.List<java.io.File> excludedFolderList
java.lang.String[] toolsToUpdate
boolean unzipDone
updateDirectory(File, File, File)
.updateDirectory(File, File, File)
boolean downloadDone
processArgs(String[])
final ProgressIndicator progressor
int progress
protected FileUtilities.Predicate<java.lang.String> unzipSkipPredicator
init()
.init()
protected SePlusInstallInfo productInfo
public static final java.lang.String HELP_STRING
static final java.lang.String LC_JAR
static final java.lang.String LC_SVB
static final java.lang.String LC_DAT
static final java.lang.String LC_EXE
static final java.lang.String LC_TSCRIPT
java.util.HashMap<java.io.File,java.io.File> backups
public LibraryUpdate()
public LibraryUpdate(java.io.PrintStream console, java.io.PrintStream errors)
protected void init()
protected void close()
public boolean processArgs(java.lang.String[] args) throws java.lang.Exception
args
- command-line argsjava.lang.Exception
static void help(java.io.PrintStream out)
boolean fileIncluded(java.io.File file)
file
- boolean allFileIncluded(java.io.File file)
file
- void backupFile(java.io.File targetfile, java.io.File backupdir) throws java.lang.Exception
targetfile
- backupdir
- java.lang.Exception
void copyFile(java.io.File sourcefile, java.io.File targetfile) throws java.lang.Exception
sourcefile
- targetfile
- java.lang.Exception
void updateDirectory(java.io.File targetdir, java.io.File sourcedir, java.io.File backupdir) throws java.lang.Exception
targetdir
- sourcedir
- backupdir
- java.lang.Exception
java.io.File prepareTempSourceDirectory() throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
void downloadURL(java.lang.String url, java.io.File outfile) throws java.io.IOException
java.io.IOException
public boolean isQuiet()
public static boolean download(java.lang.String url, java.io.File outfile)
public static void main(java.lang.String[] args)
args
- Command-line options:
-q (quiet mode, no prompt dialog), it should be put before other argument if present"
"-prompt:titlebar" (alternate prompt title bar message)
This parameter should appear before other parameters (at this time)
-b:backupdir **(backup dir for replaced files)
-s:sourcedir * (source dir containing newer files, or an HTTP URL to a ZIP)
Supports HTTP URL to a ZIP file that would be downloaded and extracted into a temporary directory
to be used as the sourcedir for the update.
Note: Any spaces in the URL should be retained as spaces--not URLEncoded.
The code will handle URL encoding of spaces.
Ex: -s:http://sourceforge.net/projects/safsdev/files/SAFS Updates/SAFS.LIB Updates/SAFS.LIB.UPDATE.LATEST.ZIP
-t:targetdir * (target dir receiving newer files)
-f (force w/o prompting for each file)
-r (recurse into sub-directories)
-a (file of all types will be copy, default false)
-e:dir1;dir2 -e: followed by excluded folders separated by semi-colon, such as jre;Java;Java64
These folders can be relative to the target directory or can be absolute directory.
These folders will be excluded when updating, which means they and their sub-folders will not be updated.
-nob (no file backups required)
-tools:t1;t2 (tools to update or install, default "", example -tools:GHOSTSCRIPT;Tool2;Tool3)
* - required parameter.
** - only required if -nob not provided.
Copyright © SAS Institute. All Rights Reserved.