package org.gcube.application.geoportal.client; import org.gcube.application.geoportal.client.utils.Serialization; import javax.ws.rs.core.Response; import java.io.IOException; import java.rmi.RemoteException; public class ResponseCommons { protected static R check(Response resp, Class clazz) throws IOException { 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; if(clazz!=null) return Serialization.read(resString, clazz); else return null; } }