@Override public Status getResponseStatus() { return Status.fromStatusCode(getStatus()); }
@Override public Status getResponseStatus() { return Status.fromStatusCode(getStatus()); }
public Integer extractEntity(ClientRequestContext context, Object... args) { return context.getClientResponse().getStatus(); } };
public Integer extractEntity(ClientRequestContext context, Object... args) { return context.getClientResponse().getStatus(); } };
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()); } }
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; }
/** * Automatically does POST/Create pattern. Will throw a ClientResponseFailure * if status is something other than 201 * * @return Link to created resource * @throws Exception, ClientResponseFailure */ public Link create() throws Exception, ClientResponseFailure { BaseClientResponse response = (BaseClientResponse) post(); if (response.getStatus() != 201) throw new ClientResponseFailure(response); return response.getLocationLink(); }
/** * Automatically does POST/Create pattern. Will throw a ClientResponseFailure * if status is something other than 201 * * @return Link to created resource * @throws Exception, ClientResponseFailure */ public Link create() throws Exception, ClientResponseFailure { BaseClientResponse response = (BaseClientResponse) post(); if (response.getStatus() != 201) throw new ClientResponseFailure(response); return response.getLocationLink(); }
public Object extractEntity(ClientRequestContext context, Object... args) { EntityTypeFactory factory = null; try { factory = entityTypeFactory.newInstance(); } catch (InstantiationException e) { throw context.getClientResponse().createResponseFailure(Messages.MESSAGES.couldNotCreateEntityFactory(entityTypeFactory.getClass().getName())); } catch (IllegalAccessException e) { throw ((BaseClientResponse<?>)context.getClientResponse()) .createResponseFailure(Messages.MESSAGES.couldNotCreateEntityFactoryMessage(entityTypeFactory.getClass().getName(), e.getMessage())); } context.getClientResponse().setReturnType( factory.getEntityType(((BaseClientResponse<?>) context.getClientResponse()).getStatus(), ((BaseClientResponse<?>) context.getClientResponse()).getMetadata())); return context.getClientResponse(); } };
public Object extractEntity(ClientRequestContext context, Object... args) { EntityTypeFactory factory = null; try { factory = entityTypeFactory.newInstance(); } catch (InstantiationException e) { throw context.getClientResponse().createResponseFailure(Messages.MESSAGES.couldNotCreateEntityFactory(entityTypeFactory.getClass().getName())); } catch (IllegalAccessException e) { throw ((BaseClientResponse<?>)context.getClientResponse()) .createResponseFailure(Messages.MESSAGES.couldNotCreateEntityFactoryMessage(entityTypeFactory.getClass().getName(), e.getMessage())); } context.getClientResponse().setReturnType( factory.getEntityType(((BaseClientResponse<?>) context.getClientResponse()).getStatus(), ((BaseClientResponse<?>) context.getClientResponse()).getMetadata())); return context.getClientResponse(); } };
restResponse.setStatusCode(clientResponse.getStatus()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Incoming Headers to SwitchYard through OutboundHandler [");
restResponse.setStatusCode(clientResponse.getStatus()); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Incoming Headers to SwitchYard through OutboundHandler [");