X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2FJcrUtils.java;h=3e3789aab3e42e05c56ab6564e2aafb98d603227;hb=74787102ae9a8533927cee62238d7e78a22dff63;hp=3e7c8737403ed969378e9c93972508abea85293b;hpb=726748983890c7f6d1be2e652a234dd2ada47ed9;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java b/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java index 3e7c87374..3e3789aab 100644 --- a/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java +++ b/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java @@ -1509,6 +1509,11 @@ public class JcrUtils { } } + /** Read an an nt:file as an {@link InputStream}. */ + public static InputStream getFileAsStream(Node fileNode) throws RepositoryException { + return fileNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream(); + } + /** * Computes the checksum of an nt:file. * @@ -1516,14 +1521,11 @@ public class JcrUtils { */ @Deprecated public static String checksumFile(Node fileNode, String algorithm) { - Binary data = null; try (InputStream in = fileNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary() .getStream()) { return digest(algorithm, in); } catch (RepositoryException | IOException e) { throw new ArgeoJcrException("Cannot checksum file " + fileNode, e); - } finally { - closeQuietly(data); } }