|
20 | 20 | import javax.ws.rs.GET; |
21 | 21 | import javax.ws.rs.Path; |
22 | 22 | import javax.ws.rs.PathParam; |
23 | | -import javax.ws.rs.core.MediaType; |
24 | 23 | import javax.ws.rs.core.Response; |
25 | | -import org.glassfish.jersey.server.mvc.Viewable; |
26 | | -import com.authlete.common.api.AuthleteApi; |
27 | 24 | import com.authlete.common.api.AuthleteApiFactory; |
28 | 25 | import com.authlete.common.dto.CredentialOfferInfoRequest; |
29 | | -import com.authlete.common.dto.CredentialOfferInfoResponse; |
30 | | -import com.authlete.jaxrs.BaseEndpoint; |
31 | | -import com.authlete.jaxrs.server.util.ExceptionUtil; |
| 26 | +import com.authlete.jaxrs.BaseCredentialOfferUriEndpoint; |
32 | 27 |
|
33 | 28 |
|
34 | 29 | @Path("/api/offer/{identifier}") |
35 | | -public class CredentialOfferEndpoint extends BaseEndpoint |
| 30 | +public class CredentialOfferEndpoint extends BaseCredentialOfferUriEndpoint |
36 | 31 | { |
37 | 32 | @GET |
38 | 33 | public Response get( |
39 | 34 | @PathParam("identifier") String identifier) |
40 | 35 | { |
41 | | - final AuthleteApi api = AuthleteApiFactory.getDefaultApi(); |
42 | | - |
43 | | - final CredentialOfferInfoRequest infoRequest = new CredentialOfferInfoRequest() |
44 | | - .setIdentifier(identifier); |
45 | | - final CredentialOfferInfoResponse response = api.credentialOfferInfo(infoRequest); |
46 | | - |
47 | | - switch(response.getAction()) |
48 | | - { |
49 | | - default: |
50 | | - throw ExceptionUtil.badRequestException("An exception occured: " + response.getResultMessage()); |
51 | | - case OK: |
52 | | - final CredentialOfferPageModel model = new CredentialOfferPageModel(); |
53 | | - model.setInfo(response.getInfo()); |
54 | | - |
55 | | - // Create a Viewable instance that represents the credential offer page. |
56 | | - // Viewable is a class provided by Jersey for MVC. |
57 | | - final Viewable viewable = new Viewable("/credential-offer", model); |
58 | | - |
59 | | - // Create a response that has the viewable as its content. |
60 | | - return Response.ok(viewable, MediaType.TEXT_HTML_TYPE.withCharset("UTF-8")).build(); |
61 | | - } |
| 36 | + return this.handle(AuthleteApiFactory.getDefaultApi(), |
| 37 | + new CredentialOfferInfoRequest().setIdentifier(identifier)); |
62 | 38 | } |
63 | 39 | } |
0 commit comments