Moved JSON:API to single function to control default
This commit is contained in:
parent
53be7fcd10
commit
29202bf152
|
@ -221,7 +221,7 @@ public class Item extends REST<CKANPackage> implements org.gcube.gcat.api.interf
|
|||
* @responseExample application/json;charset=UTF-8 ["item0","items1",...,"item10"]
|
||||
*/
|
||||
@GET
|
||||
@Produces({GCatConstants.APPLICATION_JSON_CHARSET_UTF_8, "*/*"})
|
||||
@Produces({GCatConstants.APPLICATION_JSON_CHARSET_UTF_8, GCatConstants.APPLICATION_JSON_API})
|
||||
@StatusCodes ({
|
||||
@ResponseCode ( code = 200, condition = "The request succeeded.")
|
||||
})
|
||||
|
@ -238,22 +238,22 @@ public class Item extends REST<CKANPackage> implements org.gcube.gcat.api.interf
|
|||
countOnly = Boolean.parseBoolean(queryParameters.get(GCatConstants.COUNT_QUERY_PARAMETER).get(0));
|
||||
}
|
||||
|
||||
String ret = null;
|
||||
|
||||
if(countOnly) {
|
||||
setCalledMethod("GET /" + COLLECTION_PARAMETER);
|
||||
CKANPackage ckan = getInstance();
|
||||
int size = ckan.count();
|
||||
return createCountJson(size);
|
||||
ret = createCountJson(size);
|
||||
}else {
|
||||
return super.list(limit, offset);
|
||||
ret = super.list(limit, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(GCatConstants.APPLICATION_JSON_API)
|
||||
public String listAsJsonAPI(@QueryParam(GCatConstants.LIMIT_QUERY_PARAMETER) @DefaultValue("10") int limit,
|
||||
@QueryParam(GCatConstants.OFFSET_QUERY_PARAMETER) @DefaultValue("0") int offset) {
|
||||
String ret = this.list(limit, offset);
|
||||
return resultAsJsonAPI(ret);
|
||||
|
||||
String accept = httpHeaders.getHeaderString("Accept");
|
||||
if(accept.contains(GCatConstants.APPLICATION_JSON_API)) {
|
||||
return resultAsJsonAPI(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,22 +35,15 @@ 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)
|
||||
@Produces({MediaType.APPLICATION_JSON,GCatConstants.APPLICATION_JSON_API})
|
||||
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() {
|
||||
String ret = this.list();
|
||||
return resultAsJsonAPI(ret);
|
||||
String ret = super.list(-1, -1);
|
||||
|
||||
String accept = httpHeaders.getHeaderString("Accept");
|
||||
if(accept.contains(GCatConstants.APPLICATION_JSON_API)) {
|
||||
return resultAsJsonAPI(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue