summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java
diff options
context:
space:
mode:
authorFraser Tweedale <ftweedal@redhat.com>2014-07-23 02:40:07 -0400
committerFraser Tweedale <frase@frase.id.au>2015-04-07 22:38:11 -0400
commitc4ee90c89a0b3c61b18f865e6650b27e156a9dcb (patch)
tree609594bc43d68e67c1d70636ebfc753eaeb26062 /base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java
parente4869e62f432b510dc99eb7e00d16a23caa6ea64 (diff)
downloadpki-c4ee90c89a0b3c61b18f865e6650b27e156a9dcb.tar.gz
pki-c4ee90c89a0b3c61b18f865e6650b27e156a9dcb.tar.xz
pki-c4ee90c89a0b3c61b18f865e6650b27e156a9dcb.zip
Update pki-profile CLI commands to work with "raw" format
Update CLI commands for working with the (now LDAP-based) profiles in the same format as was used by the files, by way of the --raw option. Also add the "edit" command to interactively edit a profile.
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java34
1 files changed, 25 insertions, 9 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java
index f5b636c1a..1dd85f43b 100644
--- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java
@@ -1,6 +1,8 @@
package com.netscape.cmstools.profile;
+import java.io.FileOutputStream;
import java.util.Arrays;
+import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -26,9 +28,13 @@ public class ProfileShowCLI extends CLI {
}
public void createOptions() {
- Option option = new Option(null, "output", true, "Output filename");
- option.setArgName("filename");
- options.addOption(option);
+ Option optFilename = new Option(null, "output", true, "Output filename");
+ optFilename.setArgName("filename");
+ options.addOption(optFilename);
+
+ Option optRaw = new Option(null, "raw", false, "Use raw format");
+ optRaw.setArgName("raw");
+ options.addOption(optRaw);
}
public void execute(String[] args) throws Exception {
@@ -70,14 +76,24 @@ public class ProfileShowCLI extends CLI {
}
}
- ProfileData profileData = profileCLI.profileClient.retrieveProfile(profileId);
-
- MainCLI.printMessage("Profile \"" + profileId + "\"");
+ if (cmd.hasOption("raw")) {
+ Properties profileConfig = profileCLI.profileClient.retrieveProfileRaw(profileId);
- if (filename != null) {
- ProfileCLI.saveProfileToFile(filename, profileData);
+ if (filename != null) {
+ profileConfig.store(new FileOutputStream(filename), null);
+ MainCLI.printMessage("Saved profile " + profileId + " to " + filename);
+ } else {
+ profileConfig.store(System.out, null);
+ }
} else {
- ProfileCLI.printProfile(profileData, profileCLI.getClient().getConfig().getServerURI());
+ MainCLI.printMessage("Profile \"" + profileId + "\"");
+ ProfileData profileData = profileCLI.profileClient.retrieveProfile(profileId);
+
+ if (filename != null) {
+ ProfileCLI.saveProfileToFile(filename, profileData);
+ } else {
+ ProfileCLI.printProfile(profileData, profileCLI.getClient().getConfig().getServerURI());
+ }
}
}