javax.jcr.Property.getStream()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中javax.jcr.Property.getStream()方法的一些代码示例,展示了Property.getStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getStream()方法的具体详情如下:
包路径:javax.jcr.Property
类名称:Property
方法名:getStream

Property.getStream介绍

[英]Returns an InputStream representation of the value of this property. A shortcut for Property.getValue().getStream().

It is the responsibility of the caller to close the returned InputStream.
[中]返回此属性值的InputStream表示形式。Property.getValue().getStream()的快捷方式。
调用者有责任关闭返回的InputStream。

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.javascript

public Object jsGet_stream() {
  try {
    return property.getStream();
  } catch (RepositoryException re) {
    return Undefined.instance;
  }
}

代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector

/**
 * @inheritDoc
 */
public InputStream getStream() throws ValueFormatException, RepositoryException {
  return property.getStream();
}

代码示例来源:origin: net.adamcin.oakpal/oakpal-core

@Override
public InputStream getStream() throws RepositoryException {
  return delegate.getStream();
}

代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr

public InputStream getStream() throws RepositoryException
{ return this.item.getStream(); }

代码示例来源:origin: info.magnolia/magnolia-module-workflow

private FlowExpression deserializeExpressionAsXml(final Node c) throws Exception {
  if (!c.hasProperty(WorkflowConstants.NODEDATA_VALUE)) {
    return null;
  }
  final InputStream is = c.getProperty(WorkflowConstants.NODEDATA_VALUE).getStream();
  final SAXBuilder builder = new SAXBuilder();
  final Document doc = builder.build(is);
  return (FlowExpression) XmlBeanCoder.xmlDecode(doc);
}

代码示例来源:origin: apache/jackrabbit-oak

@Override
public void runTest() throws Exception {
  for (int i = 0; i < FILE_COUNT; i++) {
    Node file = root.getNode("file" + i);
    Node content = file.getNode("jcr:content");
    InputStream stream = content.getProperty("jcr:data").getStream();
    try {
      ByteStreams.copy(stream, ByteStreams.nullOutputStream());
    } finally {
      stream.close();
    }
  }
}

代码示例来源:origin: org.openl.rules/org.openl.rules.repository.jcr

protected static InputStream getFileNodeContent(Node node) throws RRepositoryException {
  try {
    return node.getNode(ArtefactProperties.PROP_RES_CONTENT).getProperty(ArtefactProperties.PROP_RES_DATA).getStream();
  } catch (RepositoryException e) {
    throw new RRepositoryException("Failed to get Content!", e);
  }
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public InputStream getStream() throws ValueFormatException, RepositoryException {
  return getWrappedProperty().getStream();
}

代码示例来源:origin: openl-tablets/openl-tablets

protected static InputStream getFileNodeContent(Node node) throws RRepositoryException {
  try {
    return node.getNode(ArtefactProperties.PROP_RES_CONTENT).getProperty(ArtefactProperties.PROP_RES_DATA).getStream();
  } catch (RepositoryException e) {
    throw new RRepositoryException("Failed to get Content!", e);
  }
}

代码示例来源:origin: brix-cms/brix-cms

public InputStream execute() throws Exception {
    return getDelegate().getStream();
  }
});

代码示例来源:origin: apache/jackrabbit

/**
 * Tests the failure of calling Property.getStream() on a multivalue
 * property.
 */
public void testMultiValue() throws RepositoryException, IOException {
  if (multiple) {
    InputStream in = null;
    try {
      in = prop.getStream();
      fail("Calling getStream() on a multivalue property " +
          "should throw a ValueFormatException.");
    } catch (ValueFormatException vfe) {
      // ok
    } finally {
      if (in != null) {
        in.close();
      }
    }
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * InputStream)</code> works with <code>Session.save()</code>
 */
public void testNewInputStreamPropertySession() throws Exception {
  testNode.setProperty(propertyName1, is1);
  superuser.save();
  is1 = new ByteArrayInputStream(bytes1);
  InputStream in = testNode.getProperty(propertyName1).getStream();
  try {
    assertTrue("Setting property with Node.setProperty(String, InputStream) and Session.save() not working",
        compareInputStreams(is1, in));
  } finally {
    try { in.close(); } catch (IOException ignore) {}
   }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Tests if adding a property with <code>Node.setProperty(String,
 * InputStream)</code> works with <code>parentNode.save()</code>
 */
public void testNewInputStreamPropertyParent() throws Exception {
  testNode.setProperty(propertyName1, is1);
  testRootNode.getSession().save();
  is1 = new ByteArrayInputStream(bytes1);
  InputStream in = testNode.getProperty(propertyName1).getStream();
  try {
    assertTrue("Setting property with Node.setProperty(String, InputStream) and parentNode.save() not working",
        compareInputStreams(is1, in));
  } finally {
    try { in.close(); } catch (IOException ignore) {}
  }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Tests if modifying a property with <code>Node.setProperty(String,
 * InputStream)</code> works with <code>parentNode.save()</code>
 */
public void testModifyInputStreamPropertyParent() throws Exception {
  testNode.setProperty(propertyName1, is1);
  testRootNode.getSession().save();
  testNode.setProperty(propertyName1, is2);
  testRootNode.getSession().save();
  is2 = new ByteArrayInputStream(bytes2);
  InputStream in = testNode.getProperty(propertyName1).getStream();
  try {
    assertTrue("Modifying property with Node.setProperty(String, InputStream) and parentNode.save() not working",
        compareInputStreams(is2, in));
  } finally {
    try { in.close(); } catch (IOException ignore) {}
   }
}

代码示例来源:origin: apache/jackrabbit

/**
 * Checks if the given content node contains a jcr:data property
 * and spools its value to the output stream of the export context.<br>
 * Please note, that subclasses that define a different structure of the
 * content node should create their own
 * {@link  #exportData(ExportContext, boolean, Node) exportData} method.
 *
 * @param context export context
 * @param isCollection <code>true</code> if collection
 * @param contentNode the content node
 * @throws IOException if an I/O error occurs
 */
protected void exportData(ExportContext context, boolean isCollection, Node contentNode) throws IOException, RepositoryException {
  if (contentNode.hasProperty(JcrConstants.JCR_DATA)) {
    Property p = contentNode.getProperty(JcrConstants.JCR_DATA);
    IOUtil.spool(p.getStream(), context.getOutputStream());
  } // else: stream undefined -> content length was not set
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public InputStream getStream() {
  if (isExist()) {
    try {
      return getJCRProperty().getStream();
    } catch (RepositoryException e) {
      throw new RuntimeException("Can't read value of nodedata " + toString(), e);
    }
  }
  return null;
}

代码示例来源:origin: info.magnolia/magnolia-core

@Override
public InputStream getStream() {
  if (isExist()) {
    try {
      return getJCRProperty().getStream();
    } catch (RepositoryException e) {
      throw new RuntimeException("Can't read value of node data " + toString(), e);
    }
  }
  return null;
}

代码示例来源:origin: brix-cms/brix-cms

/**
 * @deprecated
 */
@Deprecated
public InputStream getStream(Property property) throws RepositoryException {
  if (getPrevious() != null) {
    return getPrevious().getStream(property);
  } else {
    return property.getStream();
  }
}

代码示例来源:origin: com.github.livesense/org.liveSense.service.xssRemove

public void removeXSSsecurityVulnerability(String parentFolder, String fileName) throws RepositoryException, Exception {
  if (!session.isLive()) session = repository.loginAdministrative(null);
  Node node = session.getRootNode().getNode(parentFolder+"/"+fileName);
  if (isValidMimeType(node)) {
    log.info("Removing XSS Vulnerability codes for node {}", node.getPath());
    StringWriter sw = new StringWriter();
    XMLWriter xmlWriter = new XMLWriter(sw);
    xmlWriter.setOutputProperty(XMLWriter.OMIT_XML_DECLARATION, "yes");
    xmlWriter.setOutputProperty(XMLWriter.ENCODING, configurator.getEncoding());
    parser.setContentHandler(xmlWriter);
    parser.parse(new InputSource(new InputStreamReader(node.getNode("jcr:content").getProperty("jcr:data").getStream(), configurator.getEncoding())));
    node.getNode("jcr:content").setProperty("jcr:data", new ByteArrayInputStream(sw.toString().getBytes(configurator.getEncoding())));
  } else {
    log.info("No XSS  Vulnerability remove, not a HTML: {} - {}", node.getPath(), node.getNode("jcr:content").getProperty("jcr:mimeType"));
  }
  session.save();
}

代码示例来源:origin: apache/jackrabbit

public void testGetStream() throws RepositoryException, IOException {
  InputStream in = prop.getStream();
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  IOUtils.copy(in, out);
  IOUtils.closeQuietly(in);
  assertEquals(prop.getString(), new String(out.toByteArray(), "UTF-8"));
}

相关文章