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"]
|
* @responseExample application/json;charset=UTF-8 ["item0","items1",...,"item10"]
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces({GCatConstants.APPLICATION_JSON_CHARSET_UTF_8, "*/*"})
|
@Produces({GCatConstants.APPLICATION_JSON_CHARSET_UTF_8, GCatConstants.APPLICATION_JSON_API})
|
||||||
@StatusCodes ({
|
@StatusCodes ({
|
||||||
@ResponseCode ( code = 200, condition = "The request succeeded.")
|
@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));
|
countOnly = Boolean.parseBoolean(queryParameters.get(GCatConstants.COUNT_QUERY_PARAMETER).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ret = null;
|
||||||
|
|
||||||
if(countOnly) {
|
if(countOnly) {
|
||||||
setCalledMethod("GET /" + COLLECTION_PARAMETER);
|
setCalledMethod("GET /" + COLLECTION_PARAMETER);
|
||||||
CKANPackage ckan = getInstance();
|
CKANPackage ckan = getInstance();
|
||||||
int size = ckan.count();
|
int size = ckan.count();
|
||||||
return createCountJson(size);
|
ret = createCountJson(size);
|
||||||
}else {
|
}else {
|
||||||
return super.list(limit, offset);
|
ret = super.list(limit, offset);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
String accept = httpHeaders.getHeaderString("Accept");
|
||||||
@Produces(GCatConstants.APPLICATION_JSON_API)
|
if(accept.contains(GCatConstants.APPLICATION_JSON_API)) {
|
||||||
public String listAsJsonAPI(@QueryParam(GCatConstants.LIMIT_QUERY_PARAMETER) @DefaultValue("10") int limit,
|
return resultAsJsonAPI(ret);
|
||||||
@QueryParam(GCatConstants.OFFSET_QUERY_PARAMETER) @DefaultValue("0") int offset) {
|
}
|
||||||
String ret = this.list(limit, offset);
|
return ret;
|
||||||
return resultAsJsonAPI(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
|
* @responseExample application/json classpath:/api-docs-examples/license/list-license-response.json
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces({MediaType.APPLICATION_JSON,GCatConstants.APPLICATION_JSON_API})
|
||||||
public String list() throws WebServiceException {
|
public String list() throws WebServiceException {
|
||||||
return super.list(-1, -1);
|
String ret = super.list(-1, -1);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String accept = httpHeaders.getHeaderString("Accept");
|
||||||
* @return the json array containing the licenses available in the catalogue
|
if(accept.contains(GCatConstants.APPLICATION_JSON_API)) {
|
||||||
*
|
return resultAsJsonAPI(ret);
|
||||||
* @pathExample /licenses
|
}
|
||||||
* @responseExample application/json classpath:/api-docs-examples/license/list-license-response.json
|
return ret;
|
||||||
*/
|
|
||||||
@GET
|
|
||||||
@Produces(GCatConstants.APPLICATION_JSON_API)
|
|
||||||
public String listAsJsonAPI() {
|
|
||||||
String ret = this.list();
|
|
||||||
return resultAsJsonAPI(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue