List of usage examples for java.io UncheckedIOException UncheckedIOException
public UncheckedIOException(IOException cause)
From source file:io.github.cdelmas.spike.sparkjava.Main.java
private static void configureUnirest(final ObjectMapper objectMapper) { Unirest.setObjectMapper(new com.mashape.unirest.http.ObjectMapper() { @Override//from w w w . j av a 2 s . c o m public <T> T readValue(String value, Class<T> valueType) { try { return objectMapper.readValue(value, valueType); } catch (IOException e) { throw new UncheckedIOException(e); } } @Override public String writeValue(Object value) { try { return objectMapper.writeValueAsString(value); } catch (JsonProcessingException e) { throw new RuntimeException(e); } } }); }
From source file:com.github.horrorho.inflatabledonkey.requests.ProtoBufsRequestFactory.java
public <T extends GeneratedMessage> HttpUriRequest newRequest(String url, String container, String bundle, String cloudKitUserId, String cloudKitToken, String uuid, List<T> protobufs) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); protobufs.forEach(message -> {//from w ww. j av a2s. c o m try { message.writeDelimitedTo(baos); } catch (IOException ex) { throw new UncheckedIOException(ex); } }); ByteArrayEntity byteArrayEntity = new ByteArrayEntity(baos.toByteArray()); HttpPost post = new HttpPost(url); post.setHeader(Headers.XAPPLEREQUESTUUID.header(uuid)); post.setHeader(Headers.XCLOUDKITUSERID.header(cloudKitUserId)); post.setHeader(Headers.XCLOUDKITAUTHTOKEN.header(cloudKitToken)); post.setHeader(Headers.XCLOUDKITCONTAINERID.header(container)); post.setHeader(Headers.XCLOUDKITBUNDLEID.header(bundle)); post.setHeader(HttpHeaders.ACCEPT, "application/x-protobuf"); post.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-protobuf; desc=\"https://p33-ckdatabase.icloud.com:443/static/protobuf/CloudDB/CloudDBClient.desc\"; messageType=RequestOperation; delimited=true"); post.addHeader(headers.get(Headers.USERAGENT)); post.addHeader(headers.get(Headers.XCLOUDKITPROTOCOLVERSION)); post.addHeader(headers.get(Headers.XMMECLIENTINFO)); post.setEntity(byteArrayEntity); return post; }
From source file:com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup.java
public String etag() { try {//from ww w .ja v a2 s . c o m MessageDigest digest = DigestUtils.getSha256Digest(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter( new DigestOutputStream(new NullOutputStream(), digest)); outputStreamWriter.write(name); outputStreamWriter.write("/"); outputStreamWriter.write(Integer.toString(permissions.hashCode())); outputStreamWriter.write("["); for (Map.Entry<String, GoDashboardPipeline> entry : pipelines.entrySet()) { long lastUpdatedTimeStamp = entry.getValue().getLastUpdatedTimeStamp(); outputStreamWriter.write(entry.getKey()); outputStreamWriter.write(":"); outputStreamWriter.write(Long.toString(lastUpdatedTimeStamp)); } outputStreamWriter.write("]"); outputStreamWriter.flush(); return Hex.encodeHexString(digest.digest()); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:com.github.horrorho.inflatabledonkey.chunk.store.disk.DiskChunk.java
@Override public InputStream inputStream() throws UncheckedIOException { try {//from w w w . j av a 2s.c o m return Files.newInputStream(file, READ); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:objective.taskboard.utils.ZipUtils.java
public static void unzip(Stream<ZipStreamEntry> stream, Path output) { if (output.toFile().isFile()) throw new RuntimeException("Output must be a directory"); try {//from w w w . j a v a 2 s .c o m stream.forEach(ze -> { Path entryPath = output.resolve(ze.getName()); try { if (ze.isDirectory()) { createDirectories(entryPath); } else { createDirectories(entryPath.getParent()); copy(ze.getInputStream(), entryPath); } } catch (IOException e) { throw new UncheckedIOException(e); } }); } finally { stream.close(); } }
From source file:org.cryptomator.filesystem.crypto.Masterkeys.java
private static void readMasterKey(File file, Cryptor cryptor, CharSequence passphrase) throws UncheckedIOException, InvalidPassphraseException { try ( // ReadableByteChannel channel = file.openReadable(); // InputStream in = Channels.newInputStream(channel)) { final byte[] fileContents = IOUtils.toByteArray(in); cryptor.readKeysFromMasterkeyFile(fileContents, passphrase); } catch (IOException e) { throw new UncheckedIOException(e); }//from w ww . j ava 2 s .com }
From source file:com.github.tmyroadctfig.icloud4j.util.ICloudUtils.java
/** * Parses a JSON response from the request. * * @param httpClient the HTTP client.//from ww w.j av a 2s .co m * @param httpGet the request. * @param responseClass the type of JSON object to parse the values into. * @param <T> the type to parse into. * @return the object. * @throws ICloudException if there was an error returned from the request. */ public static <T> T parseJsonResponse(CloseableHttpClient httpClient, HttpGet httpGet, Class<T> responseClass) { try (CloseableHttpResponse response = httpClient.execute(httpGet)) { String rawResponseContent = new StringResponseHandler().handleResponse(response); try { return fromJson(rawResponseContent, responseClass); } catch (JsonSyntaxException e1) { Map<String, Object> errorMap = fromJson(rawResponseContent, Map.class); throw new ICloudException(response, errorMap); } } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:io.werval.modules.json.JacksonJSON.java
@Override public JsonNode toNode(Object object, Class<?> jsonView) { try {//from w w w . java 2s . c om return mapper.readTree(mapper.writerWithView(jsonView).writeValueAsBytes(object)); } catch (JsonProcessingException ex) { throw new JsonPluginException(ex); } catch (IOException ex) { throw new UncheckedIOException(ex); } }
From source file:org.datacleaner.components.machinelearning.MLRegressionTransformer.java
@Initialize public void init() { try {//from w ww . ja v a 2s .c o m final byte[] bytes = Files.toByteArray(modelFile); regressor = (MLRegressor) SerializationUtils.deserialize(bytes); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.fcrepo.camel.ldpath.FedoraProvider.java
@Override public List<String> buildRequestUrl(final String resourceUri, final Endpoint endpoint) { LOGGER.debug("Processing: " + resourceUri); Objects.requireNonNull(resourceUri); try {// ww w . jav a 2s . c o m final Optional<String> nonRdfSourceDescUri = getNonRDFSourceDescribedByUri(resourceUri); if (nonRdfSourceDescUri.isPresent()) { return Collections.singletonList(nonRdfSourceDescUri.get()); } } catch (IOException ex) { throw new UncheckedIOException(ex); } return Collections.singletonList(resourceUri); }