@Override public <T2> T2 getEntity(Class<T2> type) { return getEntity(type, null); }
@Override public <T2> T2 getEntity(Class<T2> type) { return getEntity(type, null); }
private String getResponseData(BaseClientResponse response) { try { return (String) response.getEntity(String.class); } catch (Exception e) { LOG.error("Error trying to obtain response data as String.", e); } return null; } };
private String getResponseData(BaseClientResponse response) { try { return (String) response.getEntity(String.class); } catch (Exception e) { LOG.error("Error trying to obtain response data as String.", e); } return null; } };
@Override public T getEntity() { if (returnType == null) { throw new RuntimeException(Messages.MESSAGES.noTypeInformationForEntity()); } return (T) getEntity(returnType, genericReturnType, this.annotations); }
@Override public <T2> T2 getEntity(Class<T2> type, Type genericType) { return getEntity(type, genericType, getAnnotations(type, genericType)); }
@Override public <T2> T2 getEntity(Class<T2> type, Type genericType) { return getEntity(type, genericType, getAnnotations(type, genericType)); }
@Override public T getEntity() { if (returnType == null) { throw new RuntimeException(Messages.MESSAGES.noTypeInformationForEntity()); } return (T) getEntity(returnType, genericReturnType, this.annotations); }
String fileServiceUrl = "http://localhost:8081/RESTfulDemoApplication/files"; RestEasyFileServiceRestfulClient fileServiceClient = ProxyFactory.create(RestEasyFileServiceRestfulClient.class,fileServiceUrl); BaseClientResponse response = (BaseClientResponse)fileServiceClient.getFile("SpringAnnontationsCheatSheet.pdf"); File s = (File)response.getEntity(File.class); File ff = new File("C:\\RestFileUploadTest\\SpringAnnontationsCheatSheet_Downloaded.pdf"); s.renameTo(ff); FileWriter fr = new FileWriter(s); fr.flush(); System.out.println("FileDownload Response = "+ response.getStatus());
Class RestTest { public static void main(String[] args) throws Exception { String fileServiceUrl = "http://rama-local:8081/RESTfulDemoApplication/files"; RestEasyFileServiceRestfulClient fileServiceClient = ProxyFactory.create(RestEasyFileServiceRestfulClient.class,fileServiceUrl); BaseClientResponse response = (BaseClientResponse)fileServiceClient.getFile("ASD.zip"); File s = (File)response.getEntity(File.class); File ff = new File("C:\\ASD.zip"); s.renameTo(ff); FileWriter fr = new FileWriter(s); fr.flush(); System.out.println("FileDownload Response = "+ response.getStatus()); } }
@Override public <T2> T2 getEntity(GenericType<T2> genericType, Annotation[] ann) { return getEntity(genericType.getType(), genericType.getGenericType(), ann); }
@Override public <T2> T2 getEntity(GenericType<T2> genericType) { return getEntity(genericType.getType(), genericType.getGenericType()); }
@Override public <T2> T2 getEntity(GenericType<T2> genericType) { return getEntity(genericType.getType(), genericType.getGenericType()); }
@Override public <T2> T2 getEntity(GenericType<T2> genericType, Annotation[] ann) { return getEntity(genericType.getType(), genericType.getGenericType(), ann); }
public <T> T postTarget(Class<T> returnType) throws Exception { BaseClientResponse<T> response = (BaseClientResponse<T>) post(returnType); if (response.getStatus() == 204) return null; if (response.getStatus() != 200) throw new ClientResponseFailure(response); T obj = response.getEntity(); if (obj instanceof InputStream) { response.setWasReleased(true); } return obj; }
public <T> T postTarget(Class<T> returnType) throws Exception { BaseClientResponse<T> response = (BaseClientResponse<T>) post(returnType); if (response.getStatus() == 204) return null; if (response.getStatus() != 200) throw new ClientResponseFailure(response); T obj = response.getEntity(); if (obj instanceof InputStream) { response.setWasReleased(true); } return obj; }
/** * Tries to automatically unmarshal to target type. * * @param returnType * @param <T> * @return * @throws Exception */ public <T> T getTarget(Class<T> returnType) throws Exception { BaseClientResponse<T> response = (BaseClientResponse<T>) get(returnType); if (response.getStatus() == 204) return null; if (response.getStatus() != 200) throw new ClientResponseFailure(response); T obj = response.getEntity(); if (obj instanceof InputStream) { response.setWasReleased(true); } return obj; }
/** * Tries to automatically unmarshal to target type. * * @param returnType * @param <T> * @return * @throws Exception */ public <T> T getTarget(Class<T> returnType) throws Exception { BaseClientResponse<T> response = (BaseClientResponse<T>) get(returnType); if (response.getStatus() == 204) return null; if (response.getStatus() != 200) throw new ClientResponseFailure(response); T obj = response.getEntity(); if (obj instanceof InputStream) { response.setWasReleased(true); } return obj; }
Object obj = response.getEntity(method.getReturnType(), method.getGenericReturnType()); if (obj instanceof InputStream)
Object obj = response.getEntity(method.getReturnType(), method.getGenericReturnType()); if (obj instanceof InputStream)