@Override public long getSize() throws RepositoryException { return binary.getSize(); }
/** * Delegates to {@link Binary#getSize()} and returns -1 if that fails. */ @Override public long length() { try { return binary.getSize(); } catch (RepositoryException e) { LOG.warn("Error determining length of binary", e); return -1; } }
/** * Delegates to {@link Binary#getSize()} and returns -1 if that fails. */ @Override public long length() { try { return binary.getSize(); } catch (RepositoryException e) { LOG.warn("Error determining length of binary", e); return -1; } }
@Override public long length() throws SQLException { try { return binary.getSize(); } catch (RepositoryException e) { throw new SQLException(e); } }
@Override public long length() throws SQLException { try { return binary.getSize(); } catch (RepositoryException e) { throw new SQLException(e); } }
/** * @see org.apache.jackrabbit.spi.QValue#getLength() */ @Override public long getLength() throws RepositoryException { if (PropertyType.BINARY == type) { return ((Binary) val).getSize(); } else { return super.getLength(); } }
@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
@Override public long getContentLength() { long size = this.contentLength; try { size = binary != null ? binary.getSize() : this.contentLength; } catch (RepositoryException e) { logger.info(e.toString()); } return size; }
@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
/** * @see org.apache.jackrabbit.spi.QValue#getLength() */ @Override public long getLength() throws RepositoryException { if (PropertyType.BINARY == type) { return ((Binary) val).getSize(); } else { return super.getLength(); } }
@Override protected Long getValue(Value value) throws RepositoryException { return value.getBinary().getSize(); } }
/** * Return the length of the specified JCR value object. * * @param value The value. * @return The length of the given value. * @throws RepositoryException If an error occurs. */ private static long getLength(Value value) throws RepositoryException { if (value.getType() == PropertyType.BINARY) { return value.getBinary().getSize(); } else { return value.getString().length(); } }
/** * Convenience method. */ protected long getLength() throws RepositoryException { if (PropertyType.BINARY == type) { return ((Binary) value).getSize(); } return value.toString().length(); }
public long getSize() { int size = 0; final Property p = renditionData.getValueMap().get(JCR_DATA, Property.class); try { return (null != p) ? p.getBinary().getSize() : 0; } catch (RepositoryException e) { LOG.error("Failed to get the Rendition binary size in bytes [{}]: ", getPath(), e); } return size; } }
@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()) { new JdtRecorder().record(context, stream, binaryValue.getSize(), null, outputNode); return true; } } }
@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()) { new JdtRecorder().record(context, stream, binaryValue.getSize(), null, outputNode); return true; } } }
public void testGetBinary() throws RepositoryException, IOException { Binary binary = prop.getBinary(); byte[] bytes = new byte[(int) binary.getSize()]; binary.read(bytes, 0); binary.dispose(); assertEquals(prop.getString(), new String(bytes, "UTF-8")); }
private void readLargeBinary() throws Exception { Node commit = session.getNode("/repos/git-modeshape-remote/tree/master/modeshape-jcr/src/test/resources/docs/postgresql-8.4.1-US.pdf"); assertNotNull(commit); Binary data = commit.getNode("jcr:content").getProperty("jcr:data").getBinary(); long size = data.getSize(); assertTrue(size > 0); //simply read the stream to make sure it's valid ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); IoUtil.write(data.getStream(), bos); assertEquals("invalid binary stream", size, baos.toByteArray().length); }
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 testGetBinaryFromString() throws Exception { // GIVEN Object objectValue = "Hallo"; MockValue jcrValue = new MockValue(objectValue); // WHEN Binary result = jcrValue.getBinary(); // THEN assertEquals(5, result.getSize()); }