Added support for JSON:API to item list method
This commit is contained in:
parent
39de19d109
commit
72842ff53b
|
@ -248,7 +248,14 @@ public class Item extends REST<CKANPackage> implements org.gcube.gcat.api.interf
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The create API allows to create an item.
|
||||
|
|
|
@ -49,12 +49,8 @@ public class License extends REST<CKANLicense> implements org.gcube.gcat.api.int
|
|||
@GET
|
||||
@Produces(GCatConstants.APPLICATION_JSON_API)
|
||||
public String listAsJsonAPI() {
|
||||
String ret = super.list(-1, -1);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("{ \"data\":");
|
||||
stringBuffer.append(ret);
|
||||
stringBuffer.append("}");
|
||||
return stringBuffer.toString();
|
||||
String ret = this.list();
|
||||
return resultAsJsonAPI(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,4 +98,12 @@ public class REST<C extends CKAN> extends BaseREST implements CRUD<Response,Resp
|
|||
return delete(id, true);
|
||||
}
|
||||
|
||||
protected String resultAsJsonAPI(String data) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("{ \"data\":");
|
||||
stringBuffer.append(data);
|
||||
stringBuffer.append("}");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue