@Override public void free() { binary.dispose(); }
@Override public void dispose() { binary.dispose(); }
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
@Override public void close() throws IOException { super.close(); binary.dispose(); } };
private void addFile(Node parent, String fileName) throws RepositoryException { Node file = getOrAddNode(parent, fileName, NodeType.NT_FILE); Node content = getOrAddNode(file, Node.JCR_CONTENT, contentNodeType); content.setProperty(Property.JCR_MIMETYPE, "text/plain"); content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance()); Binary binary = parent.getSession().getValueFactory().createBinary(new ByteArrayInputStream("hello".getBytes())); content.setProperty(Property.JCR_DATA, binary); binary.dispose(); }
public void testBinaryLength() throws RepositoryException { byte[] data = "abc".getBytes(); Binary b = vf.createBinary(new ByteArrayInputStream(data)); try { node.setProperty(propertyName1, b); } finally { b.dispose(); } superuser.save(); checkOperators(propertyName1, node.getProperty(propertyName1).getLength()); }
public void testLengthBinaryLiteral() throws RepositoryException { node.setProperty(propertyName1, "abc"); superuser.save(); String length = String.valueOf(node.getProperty(propertyName1).getLength()); Binary b = vf.createBinary(new ByteArrayInputStream(length.getBytes())); try { executeQueries(propertyName1, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, vf.createValue(b)); } finally { b.dispose(); } }
String pdfUUID = "put-uuid-here"; Node pdfNode = session.getNodeByIdentifier(pdfUUID); Node jcrContent = pdfNode.getNode("jcr:content"); Property dataProperty = jcrContent.getProperty("jcr:data"); Binary dataBinary = dataProperty.getBinary(); InputStream dataInputStream = dataBinary.getStream(); //do something dataInputStream.close(); dataBinary.dispose();
protected Property setProperty(Node node, int length) throws RepositoryException { Random rand = new Random(); byte[] data = new byte[length]; rand.nextBytes(data); Binary b = vf.createBinary(new ByteArrayInputStream(data)); //System.out.println(b.getClass() + ": " + System.identityHashCode(b)); try { return node.setProperty(propertyName1, b); } finally { b.dispose(); } }
protected void checkBinary(Property p) throws Exception { for (int i = 0; i < 3; i++) { Binary bin = p.getBinary(); try { //System.out.println(bin.getClass() + "@" + System.identityHashCode(bin)); bin.read(new byte[1], 0); } finally { bin.dispose(); } } } }
protected void checkProperty(Property prop) throws Exception { for (int i = 0; i < 3; i++) { Binary b = prop.getBinary(); try { //System.out.println(b.getClass() + ": " + System.identityHashCode(b)); b.read(new byte[1], 0); } finally { b.dispose(); } } } }
/** Wrapper around {@link #setValue(Value)} */ public void setValue(InputStream value) throws RepositoryException { if (value != null) { Binary binary = getValueFactory().createBinary(value); try { setValue(getValueFactory().createValue(binary)); } finally { binary.dispose(); } } else { setValue((Value) null); } }
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")); }
/** Wrapper around {@link #setProperty(String, Value)} */ public Property setProperty(String name, InputStream value) throws RepositoryException { if (value != null) { Binary binary = getValueFactory().createBinary(value); try { return setProperty(name, getValueFactory().createValue(binary)); } finally { binary.dispose(); } } else { return setProperty(name, (Value) null); } }
/** Wrapper around {@link #setValue(Value)} */ public void setValue(InputStream value) throws RepositoryException { if (value != null) { Binary binary = getValueFactory().createBinary(value); try { setValue(getValueFactory().createValue(binary)); } finally { binary.dispose(); } } else { setValue((Value) null); } }
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")); }