Fixes requests

This commit is contained in:
Fabio Sinibaldi 2022-05-13 18:41:43 +02:00
parent 3d3f618f50
commit 2bd5336eee
2 changed files with 10 additions and 6 deletions

View File

@ -71,7 +71,7 @@ public class DefaultDocumentsClient<T extends Project> implements Projects<T> {
Call<WebTarget, T> call = endpoint -> {
return ResponseCommons.check(endpoint.path(profileID).path(id).
queryParam(InterfaceConstants.Parameters.FORCE,force).
request(MediaType.APPLICATION_JSON).delete(),getManagedClass());
request(MediaType.APPLICATION_JSON).delete(),null);
};
delegate.make(call);
log.info("Deleted ID {}  useCaseDescriptor {}  force {} ", id, profileID, force);

View File

@ -1,21 +1,25 @@
package org.gcube.application.geoportal.client;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.client.utils.Serialization;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.rmi.RemoteException;
@Slf4j
public class ResponseCommons {
protected static<R> R check(Response resp, Class<R> clazz) throws IOException {
protected static<R> R check(Response resp, Class<R> clazz) throws Exception {
String resString=resp.readEntity(String.class);
if(resp.getStatus()<200||resp.getStatus()>=300)
throw new RemoteException("RESP STATUS IS "+resp.getStatus()+". Message : "+resString);
if(clazz.equals(String.class))
return (R) resString;
throw new Exception("RESP STATUS IS "+resp.getStatus()+". Message : "+resString);
log.debug("Resp String is "+resString);
if(clazz!=null)
return Serialization.read(resString, clazz);
if (clazz==String.class)
return (R) resString;
else
return Serialization.read(resString, clazz);
else return null;
}
}