diff options
author | Fraser Tweedale <ftweedal@redhat.com> | 2014-07-23 02:40:07 -0400 |
---|---|---|
committer | Fraser Tweedale <frase@frase.id.au> | 2015-04-07 22:38:11 -0400 |
commit | c4ee90c89a0b3c61b18f865e6650b27e156a9dcb (patch) | |
tree | 609594bc43d68e67c1d70636ebfc753eaeb26062 /base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java | |
parent | e4869e62f432b510dc99eb7e00d16a23caa6ea64 (diff) | |
download | pki-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/ProfileModifyCLI.java')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java index bbeb91981..cc0f415b7 100644 --- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileModifyCLI.java @@ -1,11 +1,13 @@ package com.netscape.cmstools.profile; -import java.io.FileNotFoundException; +import java.io.IOException; import java.util.Arrays; +import java.util.Properties; import javax.xml.bind.JAXBException; import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Option; import org.apache.commons.cli.ParseException; import com.netscape.certsrv.profile.ProfileData; @@ -19,6 +21,10 @@ public class ProfileModifyCLI extends CLI { public ProfileModifyCLI(ProfileCLI profileCLI) { super("mod", "Modify profiles", profileCLI); this.profileCLI = profileCLI; + + Option optRaw = new Option(null, "raw", false, "Use raw format"); + optRaw.setArgName("raw"); + options.addOption(optRaw); } public void printHelp() { @@ -59,14 +65,20 @@ public class ProfileModifyCLI extends CLI { } try { - ProfileData data = ProfileCLI.readProfileFromFile(filename); - data = profileCLI.profileClient.modifyProfile(data); - - MainCLI.printMessage("Modified profile " + data.getId()); - - ProfileCLI.printProfile(data, profileCLI.getClient().getConfig().getServerURI()); - - } catch (FileNotFoundException | JAXBException e) { + if (cmd.hasOption("raw")) { + Properties properties = ProfileCLI.readRawProfileFromFile(filename); + String profileId = properties.getProperty("profileId"); + profileCLI.profileClient.modifyProfileRaw(profileId, properties).store(System.out, null); + MainCLI.printMessage("Modified profile " + profileId); + } else { + ProfileData data = ProfileCLI.readProfileFromFile(filename); + data = profileCLI.profileClient.modifyProfile(data); + + MainCLI.printMessage("Modified profile " + data.getId()); + + ProfileCLI.printProfile(data, profileCLI.getClient().getConfig().getServerURI()); + } + } catch (IOException | JAXBException e) { System.err.println("Error: " + e.getMessage()); System.exit(-1); } |