diff options
author | Ade Lee <alee@redhat.com> | 2013-11-05 12:12:52 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2013-11-06 11:50:57 -0500 |
commit | 5e748a5b62457210c67f0c05ae3be6247604e988 (patch) | |
tree | 74425aa69fed081be2a9dc3a3e05761a7ada56e8 /base/common/src/com/netscape/certsrv/profile | |
parent | e54785c33474061241caffa67e0880b38f4314fc (diff) | |
download | pki-5e748a5b62457210c67f0c05ae3be6247604e988.tar.gz pki-5e748a5b62457210c67f0c05ae3be6247604e988.tar.xz pki-5e748a5b62457210c67f0c05ae3be6247604e988.zip |
Modify profile resource to return correct response for create or modify op
Ticket 749
Diffstat (limited to 'base/common/src/com/netscape/certsrv/profile')
3 files changed, 35 insertions, 6 deletions
diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileClient.java b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java index 64a53b209..eefd0660e 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileClient.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileClient.java @@ -19,6 +19,8 @@ package com.netscape.certsrv.profile; import java.net.URISyntaxException; +import org.jboss.resteasy.client.ClientResponse; + import com.netscape.certsrv.client.Client; import com.netscape.certsrv.client.PKIClient; @@ -54,12 +56,18 @@ public class ProfileClient extends Client { profileClient.modifyProfileState(id, "disable"); } - public void createProfile(ProfileData data){ - profileClient.createProfile(data); + public ProfileData createProfile(ProfileData data) { + @SuppressWarnings("unchecked") + ClientResponse<ProfileData> response = + (ClientResponse<ProfileData>) profileClient.createProfile(data); + return client.getEntity(response); } - public void modifyProfile(ProfileData data){ - profileClient.modifyProfile(data.getId(), data); + public ProfileData modifyProfile(ProfileData data) { + @SuppressWarnings("unchecked") + ClientResponse<ProfileData> response = + (ClientResponse<ProfileData>) profileClient.modifyProfile(data.getId(), data); + return client.getEntity(response); } public void deleteProfile(String id) { diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileData.java b/base/common/src/com/netscape/certsrv/profile/ProfileData.java index 619a39e67..4b35fee2c 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileData.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileData.java @@ -27,6 +27,9 @@ import java.util.List; import java.util.Map; import java.util.Vector; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; @@ -46,6 +49,19 @@ import org.jboss.resteasy.plugins.providers.atom.Link; @XmlAccessorType(XmlAccessType.FIELD) public class ProfileData { + public static Marshaller marshaller; + public static Unmarshaller unmarshaller; + + static { + try { + marshaller = JAXBContext.newInstance(ProfileData.class).createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + unmarshaller = JAXBContext.newInstance(ProfileData.class).createUnmarshaller(); + } catch (Exception e) { + e.printStackTrace(); + } + } + @XmlAttribute protected String id; diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java index b37b38f32..06dd785c3 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileResource.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileResource.java @@ -10,6 +10,9 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.jboss.resteasy.annotations.ClientResponseType; import com.netscape.certsrv.acls.ACLMapping; import com.netscape.certsrv.authentication.AuthMethodMapping; @@ -30,10 +33,11 @@ public interface ProfileResource { public ProfileData retrieveProfile(@PathParam("id") String id); @POST + @ClientResponseType(entityType=ProfileData.class) @ACLMapping("profile.create") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void createProfile(ProfileData data); + public Response createProfile(ProfileData data); @POST @Path("{id}") @@ -43,10 +47,11 @@ public interface ProfileResource { @PUT @Path("{id}") + @ClientResponseType(entityType=ProfileData.class) @ACLMapping("profile.modify") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public void modifyProfile(@PathParam("id") String id, ProfileData data); + public Response modifyProfile(@PathParam("id") String id, ProfileData data); @DELETE @Path("{id}") |