Using gCat API interface

This commit is contained in:
Luca Frosini 2021-12-20 14:12:57 +01:00
parent 8c3b4b5495
commit 917e50b684
1 changed files with 11 additions and 4 deletions

View File

@ -8,31 +8,38 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.xml.ws.WebServiceException;
import org.gcube.gcat.ResourceInitializer;
import org.gcube.gcat.annotation.PURGE;
import org.gcube.gcat.api.GCatConstants;
import org.gcube.gcat.persistence.ckan.CKANPackageTrash;
/**
* @author Luca Frosini (ISTI - CNR)
*/
@Path("trash")
public class Trash extends BaseREST {
@Path(Trash.TRASH)
public class Trash extends BaseREST implements org.gcube.gcat.api.interfaces.Trash<Response> {
@GET
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String list() {
@Override
public String list(@QueryParam(GCatConstants.OWN_ONLY_QUERY_PARAMETER) @DefaultValue("true") Boolean ownOnly) throws WebServiceException {
CKANPackageTrash ckanPackageTrash = new CKANPackageTrash();
ckanPackageTrash.setOwnOnly(ownOnly);
return ckanPackageTrash.list();
}
@DELETE
public Response delete(@QueryParam(GCatConstants.OWN_ONLY_QUERY_PARAMETER) @DefaultValue("true") Boolean own_only) {
@PURGE
@Override
public Response empty(@QueryParam(GCatConstants.OWN_ONLY_QUERY_PARAMETER) @DefaultValue("true") Boolean ownOnly) throws WebServiceException {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
CKANPackageTrash ckanPackageTrash = new CKANPackageTrash();
ckanPackageTrash.setOwnOnly(ownOnly);
ckanPackageTrash.empty();
}
});