Codota Logo
Property.getBinary
Code IndexAdd Codota to your IDE (free)

How to use
getBinary
method
in
javax.jcr.Property

Best Java code snippets using javax.jcr.Property.getBinary (Showing top 20 results out of 693)

  • Common ways to obtain Property
private void myMethod () {
Property p =
  • Codota IconNode node;String name;String value;node.setProperty(name, value)
  • Codota IconNode node;String relPath;node.getProperty(relPath)
  • Codota IconPropertyIterator iter;iter.nextProperty()
  • Smart code suggestions by Codota
}
origin: Adobe-Consulting-Services/acs-aem-commons

private InputStream retrieveInputStream() throws RepositoryException
{
  if(entryNode.hasNode(JCRHttpCacheStoreConstants.PATH_CONTENTS)){
    final Node contentsNode = entryNode.getNode(JCRHttpCacheStoreConstants.PATH_CONTENTS);
    final Node jcrContent =   contentsNode.getNode(JcrConstants.JCR_CONTENT);
    final Property binaryProperty = jcrContent.getProperty(JcrConstants.JCR_DATA);
    binary =  binaryProperty.getBinary();
    return binary.getStream();
  }
  return null;
}
origin: ModeShape/modeshape

@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();
}
origin: Adobe-Consulting-Services/acs-aem-commons

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();
}
origin: com.adobe.acs/acs-aem-commons-bundle

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();
}
origin: org.apache.sling/org.apache.sling.jcr.resource

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;
}
origin: Adobe-Consulting-Services/acs-aem-commons

  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;
  }
}
origin: apache/jackrabbit-oak

/** Retrieves the Binary from the jcr:data of an nt:file */
public static Binary getBinary(Session session, String ntFilePath) throws RepositoryException {
  return session.getNode(ntFilePath)
      .getNode(JcrConstants.JCR_CONTENT)
      .getProperty(JcrConstants.JCR_DATA)
      .getBinary();
}
origin: info.magnolia.dam/magnolia-dam-jcr

@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;
}
origin: info.magnolia.resources/magnolia-resources

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;
}
origin: ModeShape/modeshape

@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;
  }
}
origin: org.modeshape/modeshape-sequencer-java

@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;
  }
}
origin: ModeShape/modeshape

@Override
public boolean execute( Property inputProperty,
            Node outputNode,
            Context context ) throws Exception {
  Binary binaryValue = (Binary) inputProperty.getBinary();
  CheckArg.isNotNull(binaryValue, "binary");
  String mimeType = binaryValue.getMimeType();
  Node sequencedNode = getMetadataNode(outputNode);
  setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
  return processBasicMetadata(sequencedNode, binaryValue);
}
origin: apache/jackrabbit

  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();
      }
    }
  }
}
origin: ModeShape/modeshape

@Override
public boolean execute( Property inputProperty,
            Node outputNode,
            Context context ) throws Exception {
  Binary binaryValue = (Binary) inputProperty.getBinary();
  CheckArg.isNotNull(binaryValue, "binary");
  String mimeType = binaryValue.getMimeType();
  Node sequencedNode = getMetadataNode(outputNode);
  setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
  return processBasicMetadata(sequencedNode, binaryValue);
}
origin: ModeShape/modeshape

@Override
public boolean execute( Property inputProperty,
            Node outputNode,
            Context context ) throws Exception {
  Binary binaryValue = (Binary) inputProperty.getBinary();
  CheckArg.isNotNull(binaryValue, "binary");
  String mimeType = binaryValue.getMimeType();
  Node sequencedNode = getMetadataNode(outputNode);
  setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
  return processBasicMetadata(sequencedNode, binaryValue);
}
origin: apache/jackrabbit

public void testCopyJson() throws Exception {
  Node test = createJsonNode("test.json");
  test.getSession().getWorkspace().copy(test.getPath(), test.getParent().getPath() + "/target.json");
  Session s = getHelper().getReadOnlySession();
  try {
    Property p = s.getNode(testRoot).getNode("target.json").getNode(JcrConstants.JCR_CONTENT)
        .getProperty(JcrConstants.JCR_DATA);
    assertEquals(jsondata, IOUtils.toString(p.getBinary().getStream(), "UTF-8"));
  } finally {
    s.logout();
  }
}
origin: apache/jackrabbit

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();
  }
}
origin: apache/jackrabbit

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"));
}
origin: ModeShape/modeshape

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);
}

origin: ModeShape/modeshape

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();
}
javax.jcrPropertygetBinary

Javadoc

Returns a Binary representation of the value of this property. A shortcut for Property.getValue().getBinary().

Popular methods of Property

  • getString
    Returns a String representation of the value of this property. A shortcut for Property.getValue().g
  • getValues
    Returns an array of all the values of this property. Used to access multi-value properties. The arra
  • getValue
    Returns the value of this property as a Value object. The object returned is a copy of the stored va
  • getName
  • getType
    Returns the type of this Property. One of: * PropertyType.STRING * PropertyType.BINARY * Property
  • getBoolean
    Returns a boolean representation of the value of this property. A shortcut for Property.getValue().
  • remove
  • isMultiple
    Returns true if this property is multi-valued andfalse if this property is single-valued.
  • getDate
    Returns a Calendar representation of the value of this property. A shortcut for Property.getValue()
  • getLong
    Returns a long representation of the value of this property. A shortcut for Property.getValue().get
  • getDefinition
    Returns the property definition that applies to this property. In some cases there may appear to be
  • setValue
    Sets the value of this property to the values array. If this property's property type is not constra
  • getDefinition,
  • setValue,
  • getParent,
  • getPath,
  • getNode,
  • getLength,
  • getDouble,
  • getStream,
  • getSession

Popular in Java

  • Making http post requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setContentView (Activity)
  • getSystemService (Context)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • JTextField (javax.swing)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now