private static String uriEncode(String s) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
private static String uriDecode(String s) { try { return URLDecoder.decode(s, "UTF-8"); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
private static String uriEncode(String s) { try { return URLEncoder.encode(s, "UTF-8"); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
private static String uriDecode(String s) { try { return URLDecoder.decode(s, "UTF-8"); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
/** * Gets a stream for the given string. */ public static InputStream getStream(String string) { try { return new ByteArrayInputStream(string.getBytes("UTF-8")); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
/** * Gets a stream for the given string. */ public static InputStream getStream(String string) { try { return new ByteArrayInputStream(string.getBytes("UTF-8")); } catch (UnsupportedEncodingException wontHappen) { throw new FaultException(wontHappen); } }
private static Blob rename(Blob blob, String newId) { try { return blob.moveTo(new URI(newId), null); } catch (IOException e) { throw new FaultException(e); } catch (URISyntaxException wontHappen) { throw new FaultException(wontHappen); } }
private static Blob rename(Blob blob, String newId) { try { return blob.moveTo(new URI(newId), null); } catch (IOException e) { throw new FaultException(e); } catch (URISyntaxException wontHappen) { throw new FaultException(wontHappen); } }
private static long copy(InputStream source, OutputStream sink) { try { return IOUtils.copyLarge(source, sink); } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error copying stream", e); } finally { IOUtils.closeQuietly(source); IOUtils.closeQuietly(sink); } }
private static long copy(InputStream source, OutputStream sink) { try { return IOUtils.copyLarge(source, sink); } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error copying stream", e); } finally { IOUtils.closeQuietly(source); IOUtils.closeQuietly(sink); } }
private static BlobStoreConnection getConnection(BlobStore store, Map<String, String> hints) { try { return store.openConnection(null, hints); } catch (IOException e) { throw new FaultException( "System error getting blob store connection", e); } }
private static InputStream openInputStream(Blob blob) throws MissingBlobException { try { return blob.openInputStream(); } catch (MissingBlobException e) { // subclass of IOException throw e; } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error opening input stream", e); } }
private static Blob getBlob(BlobStoreConnection connection, URI blobId, Map<String, String> hints) { try { return connection.getBlob(blobId, hints); } catch (Exception e) { logger.error(e.toString(),e); throw new FaultException("System error getting blob handle", e); } }
private static boolean exists(Blob blob) { try { return blob.exists(); } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException( "System error determining existence of blob", e); } }
private static OutputStream openOutputStream(Blob blob, long estimatedSize, boolean overwrite) throws DuplicateBlobException { try { return blob.openOutputStream(estimatedSize, overwrite); } catch (DuplicateBlobException e) { // subclass of IOException throw e; } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error opening output stream", e); } }
private static InputStream openInputStream(Blob blob) throws MissingBlobException { try { return blob.openInputStream(); } catch (MissingBlobException e) { // subclass of IOException throw e; } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error opening input stream", e); } }
private static Iterator<URI> listBlobIds(BlobStoreConnection connection) { try { return connection.listBlobIds(null); // all } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException("System error listing blob ids", e); } }
private static boolean exists(Blob blob) { try { return blob.exists(); } catch (IOException e) { logger.error(e.toString(),e); throw new FaultException( "System error determining existence of blob", e); } }
private static BlobStoreConnection getConnection(BlobStore store, Map<String, String> hints) { try { return store.openConnection(null, hints); } catch (IOException e) { throw new FaultException( "System error getting blob store connection", e); } }
private static Blob getBlob(BlobStoreConnection connection, URI blobId, Map<String, String> hints) { try { return connection.getBlob(blobId, hints); } catch (Exception e) { logger.error(e.toString(),e); throw new FaultException("System error getting blob handle", e); } }