diff options
author | Ade Lee <alee@redhat.com> | 2013-07-29 12:23:03 -0400 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2013-07-31 16:57:35 -0400 |
commit | ea1d7a70d9fad28a1729d1de4968edafdaeb0889 (patch) | |
tree | fc7a0fcaae390c9d3963c08386af50234be65ffa /base/java-tools/src/com/netscape/cmstools/profile | |
parent | a5326958593a84236879c1bf9cc8b54e86ce089f (diff) | |
download | pki-ea1d7a70d9fad28a1729d1de4968edafdaeb0889.tar.gz pki-ea1d7a70d9fad28a1729d1de4968edafdaeb0889.tar.xz pki-ea1d7a70d9fad28a1729d1de4968edafdaeb0889.zip |
Fix various issues with Profile Interface
1. Fixed REST API as per review.
2. Add output for profile-show and profile-find
Diffstat (limited to 'base/java-tools/src/com/netscape/cmstools/profile')
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java | 54 | ||||
-rw-r--r-- | base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java | 21 |
2 files changed, 62 insertions, 13 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java index 37b88bcb5..1463b096e 100644 --- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileCLI.java @@ -3,8 +3,12 @@ package com.netscape.cmstools.profile; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.net.URI; import java.util.Arrays; +import java.util.Locale; +import java.util.Map; +import javax.ws.rs.core.UriBuilder; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; @@ -12,9 +16,13 @@ import javax.xml.bind.Unmarshaller; import org.apache.commons.lang.StringUtils; +import com.netscape.certsrv.profile.ProfileAttribute; import com.netscape.certsrv.profile.ProfileClient; import com.netscape.certsrv.profile.ProfileData; import com.netscape.certsrv.profile.ProfileDataInfo; +import com.netscape.certsrv.profile.ProfileInput; +import com.netscape.certsrv.profile.ProfileOutput; +import com.netscape.certsrv.profile.ProfileResource; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; @@ -87,11 +95,53 @@ public class ProfileCLI extends CLI { public static void printProfileDataInfo(ProfileDataInfo info) { System.out.println("Profile ID: " + info.getProfileId()); System.out.println("Profile URL: " + info.getProfileURL()); + System.out.println("Profile Name: " + info.getProfileName()); + System.out.println("Profile Description: " + info.getProfileDescription()); } - public static void printProfile(ProfileData profileData) { - // TODO Auto-generated method stub + public static void printProfile(ProfileData data, URI baseUri) { + + UriBuilder profileBuilder = UriBuilder.fromUri(baseUri); + URI uri = profileBuilder.path(ProfileResource.class).path("{id}"). + build(data.getId()); + + System.out.println("Profile ID: " + data.getId()); + System.out.println("Profile URL: " + uri.toString()); + System.out.println("Profile Name: " + data.getName()); + System.out.println("Profile Description: " + data.getDescription() + "\n"); + + System.out.println("Profile Inputs: " + data.getId()); + int count =0; + for (Map.Entry<String, ProfileInput> entry: data.getInputs().entrySet()) { + ProfileInput input = entry.getValue(); + System.out.println("Input " + count + " Id: " + entry.getKey()); + System.out.println("Input " + count + " Name: " + input.getName()); + System.out.println("Input " + count + " Class: " + input.getClassId()); + for (ProfileAttribute attr: input.getAttrs()) { + System.out.println("Input " + count + " Attribute Name: " + attr.getName()); + System.out.println("Input " + count + " Attribute Description: " + + attr.getDescriptor().getDescription(Locale.getDefault())); + System.out.println("Input " + count + " Attribute Syntax: " + + attr.getDescriptor().getSyntax()); + } + count ++; + } + count = 0; + for (Map.Entry<String, ProfileOutput> entry: data.getOutputs().entrySet()) { + ProfileOutput output = entry.getValue(); + System.out.println("Output " + count + " Id: " + entry.getKey()); + System.out.println("Output " + count + " Name: " + output.getName()); + System.out.println("Output " + count + " Class: " + output.getClassId()); + for (ProfileAttribute attr: output.getAttrs()) { + System.out.println("Output " + count + " Attribute Name: " + attr.getName()); + System.out.println("Output " + count + " Attribute Description: " + + attr.getDescriptor().getDescription(Locale.getDefault())); + System.out.println("Output " + count + " Attribute Syntax: " + + attr.getDescriptor().getSyntax()); + } + count ++; + } } public static void saveProfileToFile(String filename, ProfileData data) 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 de83c1eb9..c3f8675f2 100644 --- a/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/profile/ProfileShowCLI.java @@ -48,24 +48,23 @@ public class ProfileShowCLI extends CLI { String filename = null; if (cmd.hasOption("output")) { filename = cmd.getOptionValue("output"); - } else { - System.err.println("Error: Missing output file name."); - printHelp(); - System.exit(-1); - } - if (filename == null || filename.trim().length() == 0) { - System.err.println("Error: Missing output file name."); - printHelp(); - System.exit(-1); + if (filename == null || filename.trim().length() == 0) { + System.err.println("Error: Missing output file name."); + printHelp(); + System.exit(-1); + } } ProfileData profileData = parent.client.retrieveProfile(profileId); MainCLI.printMessage("Profile \"" + profileId + "\""); - ProfileCLI.printProfile(profileData); - ProfileCLI.saveProfileToFile(filename, profileData); + if (filename != null) { + ProfileCLI.saveProfileToFile(filename, profileData); + } else { + ProfileCLI.printProfile(profileData, parent.parent.config.getServerURI()); + } } } |