@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
@Override @NotNull public Binary getBinary() throws RepositoryException { return getValue().getBinary(); }
/** * @see Property#getBinary() */ public Binary getBinary() throws RepositoryException { return getValue().getBinary(); }
@Override @NotNull public Binary getBinary() throws RepositoryException { return getValue().getBinary(); }
@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
@Override public Object transform( Value value ) throws ValueFormatException, RepositoryException { return new JcrBlob(value.getBinary()); } }
/** * Returns the binary value of this property. Implemented as * getValue().getBinary(). * * {@inheritDoc} */ public Binary getBinary() throws RepositoryException { return getValue().getBinary(); }
@Override @Nonnull public Binary getBinary() throws RepositoryException { return getValue().getBinary(); }
@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
/** 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; }
/** 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; }
/** 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(); } }; }
static Blob getBlob(Value value) throws RepositoryException { if (value instanceof OakValue) { return ((OakValue) value).getBlob(); } else { return new BinaryBasedBlob(value.getBinary()); } }
static Blob getBlob(Value value) throws RepositoryException { if (value instanceof OakValue) { return ((OakValue) value).getBlob(); } else { return new BinaryBasedBlob(value.getBinary()); } }
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(); } }
public void testGetBinaryFromValue() throws RepositoryException, IOException { Value v = superuser.getValueFactory().createValue("/a/b/c", PropertyType.PATH); Binary binary = v.getBinary(); byte[] bytes = new byte[(int) binary.getSize()]; binary.read(bytes, 0); binary.dispose(); assertEquals(prop.getString(), new String(bytes, "UTF-8")); }
@Test public void addAlienBinaryProperty() throws RepositoryException, IOException { Session session = getAdminSession(); QValue qValue = QValueFactoryImpl.getInstance().create("binaryValue".getBytes()); Value value = new QValueValue(qValue, new DefaultNamePathResolver(session)); getNode(TEST_PATH).setProperty("binary", value); session.save(); Value valueAgain = getNode(TEST_PATH).getProperty("binary").getValue(); assertEqualStream(value.getBinary().getStream(), valueAgain.getBinary().getStream()); }
@Test public void testCreateValueFromBytesArray() throws Exception { byte[] bytes = new byte[]{'a', 'b'}; ByteArrayInputStream is = new ByteArrayInputStream(bytes); Binary binary = valueFactory.createBinary(is); Value v = syncCtx.createValue(bytes); assertNotNull(v); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(binary, v.getBinary()); }