congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Property.getBinary
Code IndexAdd Tabnine 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)

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

  • Finding current android device location
  • getExternalFilesDir (Context)
  • getSystemService (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now