summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/tps/profile
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/tps/profile')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java24
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java23
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingAddCLI.java24
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java23
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingModifyCLI.java28
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingRemoveCLI.java25
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingShowCLI.java28
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileModifyCLI.java28
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileRemoveCLI.java25
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java28
10 files changed, 164 insertions, 92 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java
index 70e0e8c7f..11fbb21c4 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileAddCLI.java
@@ -41,26 +41,29 @@ public class ProfileAddCLI extends CLI {
public ProfileAddCLI(ProfileCLI profileCLI) {
super("add", "Add profile", profileCLI);
this.profileCLI = profileCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " [OPTIONS...]", options);
+ formatter.printHelp(getFullName() + " --input <file> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
+ public void createOptions() {
+ Option option = new Option(null, "input", true, "Input file containing profile properties.");
+ option.setArgName("file");
+ option.setRequired(true);
+ options.addOption(option);
+ }
- // Check for "--help" prior to parsing due to required option
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
// Display usage
printHelp();
System.exit(0);
}
- Option option = new Option(null, "input", true, "Input file containing profile properties.");
- option.setArgName("file");
- option.setRequired(true);
- options.addOption(option);
-
CommandLine cmd = null;
try {
@@ -69,14 +72,15 @@ public class ProfileAddCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 0) {
+ System.err.println("Error: Too many arguments specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String input = cmd.getOptionValue("input");
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
index 5f6b20c53..b9182620c 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileFindCLI.java
@@ -18,6 +18,7 @@
package com.netscape.cmstools.tps.profile;
+import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.cli.CommandLine;
@@ -38,14 +39,15 @@ public class ProfileFindCLI extends CLI {
public ProfileFindCLI(ProfileCLI profileCLI) {
super("find", "Find profiles", profileCLI);
this.profileCLI = profileCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " [FILTER] [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "start", true, "Page start");
option.setArgName("start");
options.addOption(option);
@@ -53,6 +55,15 @@ public class ProfileFindCLI extends CLI {
option = new Option(null, "size", true, "Page size");
option.setArgName("size");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -62,13 +73,7 @@ public class ProfileFindCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingAddCLI.java
index bf9601ead..65958cb4f 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingAddCLI.java
@@ -41,26 +41,29 @@ public class ProfileMappingAddCLI extends CLI {
public ProfileMappingAddCLI(ProfileMappingCLI profileMappingCLI) {
super("add", "Add profile mapping", profileMappingCLI);
this.profileMappingCLI = profileMappingCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " [OPTIONS...]", options);
+ formatter.printHelp(getFullName() + " --input <file> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
+ public void createOptions() {
+ Option option = new Option(null, "input", true, "Input file containing profile mapping properties.");
+ option.setArgName("file");
+ option.setRequired(true);
+ options.addOption(option);
+ }
- // Check for "--help" prior to parsing due to required option
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
// Display usage
printHelp();
System.exit(0);
}
- Option option = new Option(null, "input", true, "Input file containing profile mapping properties.");
- option.setArgName("file");
- option.setRequired(true);
- options.addOption(option);
-
CommandLine cmd = null;
try {
@@ -69,14 +72,15 @@ public class ProfileMappingAddCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 0) {
+ System.err.println("Error: Too many arguments specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String input = cmd.getOptionValue("input");
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
index 194682002..d3a63f56b 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingFindCLI.java
@@ -18,6 +18,7 @@
package com.netscape.cmstools.tps.profile;
+import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.cli.CommandLine;
@@ -38,14 +39,15 @@ public class ProfileMappingFindCLI extends CLI {
public ProfileMappingFindCLI(ProfileMappingCLI profileMappingCLI) {
super("find", "Find profile mappings", profileMappingCLI);
this.profileMappingCLI = profileMappingCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " [FILTER] [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "start", true, "Page start");
option.setArgName("start");
options.addOption(option);
@@ -53,6 +55,15 @@ public class ProfileMappingFindCLI extends CLI {
option = new Option(null, "size", true, "Page size");
option.setArgName("size");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -62,13 +73,7 @@ public class ProfileMappingFindCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingModifyCLI.java
index 8a4adc569..22466e80e 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingModifyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingModifyCLI.java
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -40,14 +41,15 @@ public class ProfileMappingModifyCLI extends CLI {
public ProfileMappingModifyCLI(ProfileMappingCLI profileMappingCLI) {
super("mod", "Modify profile mapping", profileMappingCLI);
this.profileMappingCLI = profileMappingCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " <Profile Mapping ID> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "action", true, "Action: update (default), approve, reject, enable, disable.");
option.setArgName("action");
options.addOption(option);
@@ -55,6 +57,15 @@ public class ProfileMappingModifyCLI extends CLI {
option = new Option(null, "input", true, "Input file containing profile mapping properties.");
option.setArgName("file");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -64,20 +75,15 @@ public class ProfileMappingModifyCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile Mapping ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileMappingID = cmdArgs[0];
@@ -91,7 +97,7 @@ public class ProfileMappingModifyCLI extends CLI {
if (input == null) {
System.err.println("Error: Missing input file");
printHelp();
- System.exit(1);
+ System.exit(-1);
return;
}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingRemoveCLI.java
index 0fa33b380..484bda2a0 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingRemoveCLI.java
@@ -20,6 +20,8 @@ package com.netscape.cmstools.tps.profile;
import java.util.Arrays;
+import org.apache.commons.cli.CommandLine;
+
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -36,21 +38,34 @@ public class ProfileMappingRemoveCLI extends CLI {
}
public void printHelp() {
- formatter.printHelp(getFullName() + " <Profile Mapping ID>", options);
+ formatter.printHelp(getFullName() + " <Profile Mapping ID> [OPTIONS...]", options);
}
public void execute(String[] args) throws Exception {
-
- // Check for "--help"
+ // Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
// Display usage
printHelp();
System.exit(0);
}
- if (args.length != 1) {
+ CommandLine cmd = null;
+
+ try {
+ cmd = parser.parse(options, args);
+
+ } catch (Exception e) {
+ System.err.println("Error: " + e.getMessage());
+ printHelp();
+ System.exit(-1);
+ }
+
+ String[] cmdArgs = cmd.getArgs();
+
+ if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile Mapping ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileMappingID = args[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingShowCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingShowCLI.java
index b5820661b..39515221d 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileMappingShowCLI.java
@@ -20,6 +20,7 @@ package com.netscape.cmstools.tps.profile;
import java.io.FileWriter;
import java.io.PrintWriter;
+import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -38,17 +39,27 @@ public class ProfileMappingShowCLI extends CLI {
public ProfileMappingShowCLI(ProfileMappingCLI profileMappingCLI) {
super("show", "Show profileMapping", profileMappingCLI);
this.profileMappingCLI = profileMappingCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " <Profile Mapping ID>", options);
+ formatter.printHelp(getFullName() + " <Profile Mapping ID> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "output", true, "Output file to store profile mapping properties.");
option.setArgName("file");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -58,20 +69,15 @@ public class ProfileMappingShowCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile Mapping ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileMappingID = args[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileModifyCLI.java
index 523182869..87580cdaf 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileModifyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileModifyCLI.java
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -40,14 +41,15 @@ public class ProfileModifyCLI extends CLI {
public ProfileModifyCLI(ProfileCLI profileCLI) {
super("mod", "Modify profile", profileCLI);
this.profileCLI = profileCLI;
+
+ createOptions();
}
public void printHelp() {
formatter.printHelp(getFullName() + " <Profile ID> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "action", true, "Action: update (default), approve, reject, enable, disable.");
option.setArgName("action");
options.addOption(option);
@@ -55,6 +57,15 @@ public class ProfileModifyCLI extends CLI {
option = new Option(null, "input", true, "Input file containing profile properties.");
option.setArgName("file");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -64,20 +75,15 @@ public class ProfileModifyCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileID = cmdArgs[0];
@@ -91,7 +97,7 @@ public class ProfileModifyCLI extends CLI {
if (input == null) {
System.err.println("Error: Missing input file");
printHelp();
- System.exit(1);
+ System.exit(-1);
return;
}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileRemoveCLI.java
index 23fceb328..4aca086ec 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileRemoveCLI.java
@@ -20,6 +20,8 @@ package com.netscape.cmstools.tps.profile;
import java.util.Arrays;
+import org.apache.commons.cli.CommandLine;
+
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -36,21 +38,34 @@ public class ProfileRemoveCLI extends CLI {
}
public void printHelp() {
- formatter.printHelp(getFullName() + " <Profile ID>", options);
+ formatter.printHelp(getFullName() + " <Profile ID> [OPTIONS...]", options);
}
public void execute(String[] args) throws Exception {
-
- // Check for "--help"
+ // Always check for "--help" prior to parsing
if (Arrays.asList(args).contains("--help")) {
// Display usage
printHelp();
System.exit(0);
}
- if (args.length != 1) {
+ CommandLine cmd = null;
+
+ try {
+ cmd = parser.parse(options, args);
+
+ } catch (Exception e) {
+ System.err.println("Error: " + e.getMessage());
+ printHelp();
+ System.exit(-1);
+ }
+
+ String[] cmdArgs = cmd.getArgs();
+
+ if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileID = args[0];
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java
index 37d1ed40d..1a4f8a81f 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/profile/ProfileShowCLI.java
@@ -20,6 +20,7 @@ package com.netscape.cmstools.tps.profile;
import java.io.FileWriter;
import java.io.PrintWriter;
+import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -38,17 +39,27 @@ public class ProfileShowCLI extends CLI {
public ProfileShowCLI(ProfileCLI profileCLI) {
super("show", "Show profile", profileCLI);
this.profileCLI = profileCLI;
+
+ createOptions();
}
public void printHelp() {
- formatter.printHelp(getFullName() + " <Profile ID>", options);
+ formatter.printHelp(getFullName() + " <Profile ID> [OPTIONS...]", options);
}
- public void execute(String[] args) throws Exception {
-
+ public void createOptions() {
Option option = new Option(null, "output", true, "Output file to store profile properties.");
option.setArgName("file");
options.addOption(option);
+ }
+
+ public void execute(String[] args) throws Exception {
+ // Always check for "--help" prior to parsing
+ if (Arrays.asList(args).contains("--help")) {
+ // Display usage
+ printHelp();
+ System.exit(0);
+ }
CommandLine cmd = null;
@@ -58,20 +69,15 @@ public class ProfileShowCLI extends CLI {
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
printHelp();
- System.exit(1);
- }
-
- if (cmd.hasOption("help")) {
- // Display usage
- printHelp();
- System.exit(0);
+ System.exit(-1);
}
String[] cmdArgs = cmd.getArgs();
if (cmdArgs.length != 1) {
+ System.err.println("Error: No Profile ID specified.");
printHelp();
- System.exit(1);
+ System.exit(-1);
}
String profileID = args[0];