private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new RuntimeException(e); } }
public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final Csv.Context ctx = (Csv.Context) config.actualContext(fromServer.getContentType(), Csv.Context.ID); return ctx.makeReader(fromServer.getReader()).readAll(); } catch(IOException e) { throw new RuntimeException(e); } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }
private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new TransportingException(e); } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }
private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new TransportingException(e); } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }
/** * Used to parse the server response content using the Jackson JSON parser. * * @param config the configuration * @param fromServer the server content accessor * @return the parsed object */ @SuppressWarnings("WeakerAccess") public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final ObjectMapper mapper = (ObjectMapper) config.actualContext(fromServer.getContentType(), OBJECT_MAPPER_ID); return mapper.readValue(fromServer.getReader(), config.getChainedResponse().getType()); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Object apply(ChainedHttpConfig requestConfig, FromServer fromServer) { try { final BiFunction<ChainedHttpConfig, FromServer, Object> parser = requestConfig.findParser(fromServer.getContentType()); final BiFunction<FromServer, Object, ?> action = requestConfig.getChainedResponse().actualAction(fromServer.getStatusCode()); return action.apply(fromServer, fromServer.getHasBody() ? parser.apply(requestConfig, fromServer) : null); } finally { fromServer.finish(); } } }
@Override public Object apply(ChainedHttpConfig requestConfig, FromServer fromServer) { try { final BiFunction<ChainedHttpConfig, FromServer, Object> parser = requestConfig.findParser(fromServer.getContentType()); final BiFunction<FromServer, Object, ?> action = requestConfig.getChainedResponse().actualAction(fromServer.getStatusCode()); return action.apply(fromServer, fromServer.getHasBody() ? parser.apply(requestConfig, fromServer) : null); } finally { fromServer.finish(); } } }
@Override public Object apply(ChainedHttpConfig requestConfig, FromServer fromServer) { try { final BiFunction<ChainedHttpConfig, FromServer, Object> parser = requestConfig.findParser(fromServer.getContentType()); final BiFunction<FromServer, Object, ?> action = requestConfig.getChainedResponse().actualAction(fromServer.getStatusCode()); return action.apply(fromServer, fromServer.getHasBody() ? parser.apply(requestConfig, fromServer) : null); } finally { fromServer.finish(); } } }
/** * Used to parse the server response content using the Jackson JSON parser. * * @param config the configuration * @param fromServer the server content accessor * @return the parsed object */ @SuppressWarnings("WeakerAccess") public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final ObjectMapper mapper = (ObjectMapper) config.actualContext(fromServer.getContentType(), OBJECT_MAPPER_ID); return mapper.readValue(fromServer.getReader(), config.getChainedResponse().getType()); } catch (IOException e) { throw new TransportingException(e); } }
/** * Used to parse the server response content using the OpenCsv parser. * * @param config the configuration * @param fromServer the server content accessor * @return the parsed object */ public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final Csv.Context ctx = (Csv.Context) config.actualContext(fromServer.getContentType(), Csv.Context.ID); return ctx.makeReader(fromServer.getReader()).readAll(); } catch (IOException e) { throw new TransportingException(e); } }
/** * Used to parse the server response content using the Jackson JSON parser. * * @param config the configuration * @param fromServer the server content accessor * @return the parsed object */ @SuppressWarnings("WeakerAccess") public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final ObjectMapper mapper = (ObjectMapper) config.actualContext(fromServer.getContentType(), OBJECT_MAPPER_ID); return mapper.readValue(fromServer.getReader(), config.getChainedResponse().getType()); } catch (IOException e) { throw new TransportingException(e); } }
/** * Used to parse the server response content using the OpenCsv parser. * * @param config the configuration * @param fromServer the server content accessor * @return the parsed object */ public static Object parse(final ChainedHttpConfig config, final FromServer fromServer) { try { final Csv.Context ctx = (Csv.Context) config.actualContext(fromServer.getContentType(), Csv.Context.ID); return ctx.makeReader(fromServer.getReader()).readAll(); } catch (IOException e) { throw new TransportingException(e); } }