Moving JSON:API reply separate methods

This commit is contained in:
Luca Frosini 2023-02-17 17:39:38 +01:00
parent cbcb4804b7
commit 2d9f469a46
1 changed files with 21 additions and 12 deletions

View File

@ -39,11 +39,21 @@ public class License extends REST<CKANLicense> implements org.gcube.gcat.api.int
* @responseExample application/json classpath:/api-docs-examples/license/list-license-response.json
*/
@GET
@Produces({MediaType.APPLICATION_JSON, GCatConstants.APPLICATION_JSON_API})
@Produces(MediaType.APPLICATION_JSON)
public String list() throws WebServiceException {
return super.list(-1, -1);
}
/**
* @return the json array containing the licenses available in the catalogue
*
* @pathExample /licenses
* @responseExample application/json classpath:/api-docs-examples/license/list-license-response.json
*/
@GET
@Produces(GCatConstants.APPLICATION_JSON_API)
public String listAsJsonAPI() throws WebServiceException {
String ret = super.list(-1, -1);
String accept = httpHeaders.getHeaderString("Accept");
if(accept.startsWith(GCatConstants.APPLICATION_JSON_API)) {
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode objectNode = objectMapper.createObjectNode();
try {
@ -53,7 +63,6 @@ public class License extends REST<CKANLicense> implements org.gcube.gcat.api.int
}catch (Exception e) {
throw new InternalServerErrorException(e);
}
}
return ret;
}