本文整理了Java中javax.jcr.Property.getBinary()
方法的一些代码示例,展示了Property.getBinary()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getBinary()
方法的具体详情如下:
包路径:javax.jcr.Property
类名称:Property
方法名:getBinary
[英]Returns a Binary
representation of the value of this property. A shortcut for Property.getValue().getBinary()
.
[中]返回此属性值的Binary
表示形式。Property.getValue().getBinary()
的快捷方式。
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!