diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-01 19:58:34 -0600 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-03-30 16:54:32 -0500 |
commit | 0b39b68e4e72cbcf0f4d28488d54ce06117efa9c (patch) | |
tree | 1a2cfc235f1f6a062e7c88c554a9f9bf82822f72 /base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java | |
parent | 70fdf22f76494a84b6cbef10598ed897a48f0798 (diff) | |
download | pki-0b39b68e4e72cbcf0f4d28488d54ce06117efa9c.tar.gz pki-0b39b68e4e72cbcf0f4d28488d54ce06117efa9c.tar.xz pki-0b39b68e4e72cbcf0f4d28488d54ce06117efa9c.zip |
Added CMSException.
The CMSException was added to simplify error handling in REST services.
The exception may include an error message and some other attributes.
When the server throws a CMSException (or its subclass), the exception
will be marshalled into XML and unmarshalled by the client, then thrown
again as a new exception which can be caught by the application.
Ticket #100
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java')
-rw-r--r-- | base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java b/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java index 43e58bbdc..b9ba206c1 100644 --- a/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java +++ b/base/common/src/com/netscape/cms/servlet/request/KeyRequestResourceService.java @@ -19,27 +19,24 @@ package com.netscape.cms.servlet.request; import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; + import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.request.RequestId; +import com.netscape.cms.servlet.base.CMSException; import com.netscape.cms.servlet.base.CMSResourceService; import com.netscape.cms.servlet.request.model.ArchivalRequestData; import com.netscape.cms.servlet.request.model.KeyRequestDAO; import com.netscape.cms.servlet.request.model.KeyRequestInfo; import com.netscape.cms.servlet.request.model.RecoveryRequestData; - + /** * @author alee - * + * */ public class KeyRequestResourceService extends CMSResourceService implements KeyRequestResource { - @Context - UriInfo uriInfo; - /** * Used to retrieve key request info for a specific request */ @@ -52,15 +49,15 @@ public class KeyRequestResourceService extends CMSResourceService implements Key } catch (EBaseException e) { // log error e.printStackTrace(); - throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); + throw new CMSException(e.getMessage(), e); } if (info == null) { // request does not exist - throw new WebApplicationException(Response.Status.NOT_FOUND); + throw new RequestNotFoundException(id); } return info; } - + // Archiving - used to test integration with a browser public KeyRequestInfo archiveKey(MultivaluedMap<String, String> form) { ArchivalRequestData data = new ArchivalRequestData(form); @@ -88,7 +85,7 @@ public class KeyRequestResourceService extends CMSResourceService implements Key } return info; } - + //Recovery - used to test integration with a browser public KeyRequestInfo recoverKey(MultivaluedMap<String, String> form) { RecoveryRequestData data = new RecoveryRequestData(form); @@ -117,7 +114,7 @@ public class KeyRequestResourceService extends CMSResourceService implements Key } return info; } - + public void approveRequest(RequestId id) { if (id == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); @@ -132,7 +129,7 @@ public class KeyRequestResourceService extends CMSResourceService implements Key throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } } - + public void rejectRequest(RequestId id) { if (id == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); @@ -147,7 +144,7 @@ public class KeyRequestResourceService extends CMSResourceService implements Key throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); } } - + public void cancelRequest(RequestId id) { if (id == null) { throw new WebApplicationException(Response.Status.BAD_REQUEST); |