count=true
the API returns total number of profile instead of the list.
* @return a JSON Array.
*
* @pathExample /profiles
* @responseExample application/json;charset=UTF-8 ["EmptyProfile","TestProfile",...,"ComplexProfile"]
*
* @pathExample /profiles?count=true
* @responseExample application/json;charset=UTF-8 {"count":5}
*
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public String listOrCount(@QueryParam(GCatConstants.COUNT_QUERY_PARAMETER) @DefaultValue("false") Boolean count) {
setCalledMethod("GET /" + PROFILES);
try {
ISProfile isProfile = new ISProfile();
if(count) {
return createCountJson(isProfile.count());
}else{
ArrayNode arrayNode = isProfile.list();
return isProfile.getMapper().writeValueAsString(arrayNode);
}
} catch(WebApplicationException e) {
throw e;
} catch(Exception e) {
throw new InternalServerErrorException(e);
}
}
/*
* Not used as REST method, implemented to respect {@link org.gcube.gcat.api.interfaces.Item} interface
*/
@Override
public String list() {
try {
ISProfile isProfile = new ISProfile();
ArrayNode arrayNode = isProfile.list();
return isProfile.getMapper().writeValueAsString(arrayNode);
} catch(WebApplicationException e) {
throw e;
} catch(Exception e) {
throw new InternalServerErrorException(e);
}
}
public static int PRETTY_PRINT_INDENT_FACTOR = 4;
/**
* This API allow to read a profile definition.
* It is possible reading a profile in JSON by specifing the HTTP Header:
* Accept: application/json
*