Skip to content

Commit

Permalink
Enhancement to the WebAppCleanup script (IBM#93)
Browse files Browse the repository at this point in the history
* Added support for using a property file supplied through a CLI option.

* Fixed consistency: Updated to use path relative to the script for property file

Signed-off-by: John Nemec <john.nemec@ibm.com>
  • Loading branch information
M-DLB authored and johnmnemec committed Sep 6, 2022
1 parent b908ebe commit 65ff09a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Utilities/WebAppCleanUp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ MortgageApplication-Bug1220-outputs
```

### Web Application Authentication Properties
The `user.properties` file has been provided for a convienient place to store DBB Web Application authentication properties. However its use is optional as the user can provide the required authentication values as script arguments. Example:
A property file can be specified through the --prop parameter. This property file can stored DBB Web Application authentication properties. A sample property file `user.properties` is supplied along this script.
However its use is optional as the user can provide the required authentication values as script arguments. Example:
```
$DBB_HOME/bin/groovyz WebAppCleanUp.groovy --groups Application-FeatureBranch --url https://localhost:9443/dbb --id ADMIN --pw ADMIN
```
Expand All @@ -62,6 +63,9 @@ options:
-i,--id <arg> DBB WebApp ID
-p,--pw <arg> DBB WebApp Password
-P,--pwFile <arg> Absolute or relative (from this script) path
to file containing DBB password
to file containing DBB password
-prop,--propertyFile <arg> Absolute or relative (from this script) path
to property file that contains DBB WebApp
information (Optional)
-u,--url <arg> DBB WebApp URL
```
18 changes: 12 additions & 6 deletions Utilities/WebAppCleanUp/WebAppCleanUp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ collections.each { collection ->

/*
setup :
handle cli arguments, load WebAppCleanUp.properties file,
handle cli arguments, load property file if present,
create repository client, populate deletion lists
*/
def setup(String[] args) {
Expand All @@ -52,8 +52,9 @@ def setup(String[] args) {
cli.i(longOpt:'id', args:1, 'DBB WebApp ID')
cli.p(longOpt:'pw', args:1, 'DBB WebApp Password')
cli.P(longOpt:'pwFile', args:1, 'Absolute or relative (from this script) path to file containing DBB password')
cli.h(longOpt:'help', 'Prints this message')

cli.prop(longOpt:'propertyFile', args:1, 'Absolute or relative (from this script) path to property file that contains DBB WebApp information (Optional)')

cli.h(longOpt:'help', 'Prints this message')
def opts = cli.parse(args)
if (!args || !opts) {
cli.usage()
Expand All @@ -66,9 +67,14 @@ def setup(String[] args) {
System.exit(0)
}

// load user properties file
properties.load(new File("${getScriptDir()}/user.properties"))

// if specified, load user properties file
if (opts.prop) {
String filePath = opts.prop
if (!filePath.trim().startsWith('/'))
filePath = "${getScriptDir()}/$filePath"
properties.load(new File(filePath))
}

// update authentication properties with cli options
if (opts.u) properties.url = opts.url
if (opts.i) properties.id = opts.id
Expand Down

0 comments on commit 65ff09a

Please sign in to comment.