public synchronized InputStream getStream() throws RepositoryException { if (stream == null) { stream = value.getStream(); } return stream; }
public Value createValue(Binary value) { // TODO review/optimize/refactor try { return createValue(value.getStream()); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
public Value createValue(Binary value) { // TODO review/optimize/refactor try { return createValue(value.getStream()); } catch (RepositoryException ex) { throw new RuntimeException(ex); } }
@Override public InputStream getResourceContent( Node node ) throws RepositoryException { if (!node.hasNode(CONTENT_NODE_NAME)) return null; return node.getProperty(CONTENT_NODE_NAME + "/" + DATA_PROP_NAME).getBinary().getStream(); }
@Override public InputStream getBinaryStream( String columnLabel ) throws SQLException { Object o = updateCurrentValueFromColumn(columnLabel, PropertyType.BINARY); if (o != null) { try { return ((Binary) o).getStream(); } catch (RepositoryException e) { throw new SQLException(e); } } return null; }
/** Actually retrieves the input stream from the underlying JCR Value */ private InputStream getStream() throws IOException { if (delegatee == null) { try { delegatee = value.getBinary().getStream(); } catch (RepositoryException re) { throw (IOException) new IOException(re.getMessage()).initCause(re); } } return delegatee; }
public static InputStream getNTFileAsInputStream(final Resource resource) throws RepositoryException { final Node node = resource.adaptTo(Node.class); final Node jcrContent = node.getNode(JcrConstants.JCR_CONTENT); return jcrContent.getProperty(JcrConstants.JCR_DATA).getBinary().getStream(); }
/** Actually retrieves the input stream from the underlying JCR Value */ private InputStream getStream() throws IOException { if (delegatee == null) { try { delegatee = value.getBinary().getStream(); } catch (RepositoryException re) { throw (IOException) new IOException(re.getMessage()).initCause(re); } } return delegatee; }
/** Actually retrieves the input stream from the underlying JCR Value */ private InputStream getStream() throws IOException { if (delegatee == null) { try { delegatee = value.getBinary().getStream(); } catch (RepositoryException re) { throw (IOException) new IOException(re.getMessage()).initCause(re); } } return delegatee; }
private boolean outputIsSystemNodeTypes( Node outputNode, Binary binaryValue ) throws RepositoryException, IOException { String systemNodesPath = JcrLexicon.SYSTEM.getString() + "/" + JcrLexicon.NODE_TYPES.getString(); if (outputNode.getPath().contains(systemNodesPath)) { NodeTypeManager nodeTypeManager = (NodeTypeManager)outputNode.getSession().getWorkspace().getNodeTypeManager(); nodeTypeManager.registerNodeTypes(binaryValue.getStream(), true); return true; } return false; }
/** Wrapper around {@link #getValue()} */ public InputStream getStream() throws RepositoryException { final Binary binary = getValue().getBinary(); // make sure binary is disposed after stream had been consumed return new AutoCloseInputStream(binary.getStream()) { @Override public void close() throws IOException { super.close(); binary.dispose(); } }; }
/** Wrapper around {@link #getValue()} */ public InputStream getStream() throws RepositoryException { final Binary binary = getValue().getBinary(); // make sure binary is disposed after stream had been consumed return new AutoCloseInputStream(binary.getStream()) { @Override public void close() throws IOException { super.close(); binary.dispose(); } }; }
private boolean outputIsSystemNodeTypes( Node outputNode, Binary binaryValue ) throws RepositoryException, IOException { String systemNodesPath = JcrLexicon.SYSTEM.getString() + "/" + JcrLexicon.NODE_TYPES.getString(); if (outputNode.getPath().contains(systemNodesPath)) { NodeTypeManager nodeTypeManager = (NodeTypeManager)outputNode.getSession().getWorkspace().getNodeTypeManager(); nodeTypeManager.registerNodeTypes(binaryValue.getStream(), true); return true; } return false; }
private InputStream getInputStream() { Property prop = getProperty(); try { return prop.getBinary().getStream(); } catch (RepositoryException re) { LOGGER.error("getInputStream: Problem accessing the property " + getPath() + " stream", re); } // fall back to none in case of an error return null; }
@Override public InputStream getContentStream() { try { Node node = AssetNodeTypes.AssetResource.getResourceNodeFromAsset(getNode()); if (node != null) { return node.getProperty(AssetNodeTypes.AssetResource.DATA).getBinary().getStream(); } } catch (RepositoryException e) { throw new RuntimeRepositoryException(e); } return null; }
private boolean equalBinaryContents(Node binaryNode, Resource binaryResource) throws RepositoryException { try (final InputStream nodeStream = binaryNode.getProperty(JcrConstants.JCR_DATA).getBinary().getStream(); final InputStream resourceStream = binaryResource.openStream()) { return IOUtils.contentEquals(nodeStream, resourceStream); } catch (IOException e) { log.error("Cannot read contents of '{}:{}'.", binaryResource.getOrigin().getName(), binaryResource.getName(), e); } return false; }
@Override public boolean execute( Property inputProperty, Node outputNode, Context context ) throws Exception { Binary binaryValue = inputProperty.getBinary(); CheckArg.isNotNull(binaryValue, "binary"); try (InputStream stream = binaryValue.getStream()) { ClassMetadata classMetadata = ClassFileMetadataReader.instance(stream); classFileRecorder.recordClass(context, outputNode, classMetadata); return true; } }
public void testCreateJson() throws Exception { createJsonNode("test.json"); Session s = getHelper().getReadOnlySession(); try { Property p = s.getNode(testRoot).getNode("test.json").getNode(JcrConstants.JCR_CONTENT) .getProperty(JcrConstants.JCR_DATA); assertEquals(jsondata, IOUtils.toString(p.getBinary().getStream(), "UTF-8")); } finally { s.logout(); } }
public static void verifyBlob(Session session) throws IOException, RepositoryException { Property p = session.getProperty("/sling-logo.png/jcr:content/jcr:data"); InputStream is = p.getValue().getBinary().getStream(); String expectedMD5 = "35504d8c59455ab12a31f3d06f139a05"; try { assertEquals(expectedMD5, DigestUtils.md5Hex(is)); } finally { is.close(); } }
private InputStream storeBinaryProperty( byte[] data, String nodeName ) throws RepositoryException { Node testRoot = jcrSession().getRootNode().addNode(nodeName); testRoot.setProperty("binary", session.getValueFactory().createValue(new ByteArrayInputStream(data))); jcrSession().save(); Property binary = jcrSession().getNode("/" + nodeName).getProperty("binary"); Assert.assertNotNull(binary); return binary.getBinary().getStream(); }