private void processDocument(ArtificerDocumentArtifact artificerArtifact, ArtifactContent content) throws Exception { InputStream inputStream = null; try { if (content != null) { artificerArtifact.setContentSize(content.getSize()); inputStream = content.getInputStream(); String sha1Hash = DigestUtils.shaHex(inputStream); artificerArtifact.setContentHash(sha1Hash); } else { artificerArtifact.setContentSize(0); artificerArtifact.setContentHash(""); } } finally { if (inputStream != null) { IOUtils.closeQuietly(inputStream); } } } }