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 -> { Call<WebTarget, T> call = endpoint -> {
return ResponseCommons.check(endpoint.path(profileID).path(id). return ResponseCommons.check(endpoint.path(profileID).path(id).
queryParam(InterfaceConstants.Parameters.FORCE,force). queryParam(InterfaceConstants.Parameters.FORCE,force).
request(MediaType.APPLICATION_JSON).delete(),getManagedClass()); request(MediaType.APPLICATION_JSON).delete(),null);
}; };
delegate.make(call); delegate.make(call);
log.info("Deleted ID {}  useCaseDescriptor {}  force {} ", id, profileID, force); log.info("Deleted ID {}  useCaseDescriptor {}  force {} ", id, profileID, force);

View File

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