Fixes requests
This commit is contained in:
parent
3d3f618f50
commit
2bd5336eee
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue