@Override public void create(Node parent, String name) throws RepositoryException { byte[] randomBytes = new byte[10 * 1024]; RANDOM.nextBytes(randomBytes); InputStream stream = new ByteArrayInputStream(randomBytes); JcrUtils.putFile(parent, name, "application/octet-stream", stream); } @Override
Node parent, String name, String mime, InputStream data) throws RepositoryException { return putFile(parent, name, mime, data, Calendar.getInstance());
Node parent, String name, String mime, InputStream data) throws RepositoryException { return putFile(parent, name, mime, data, Calendar.getInstance());
Node parent, String name, String mime, InputStream data) throws RepositoryException { return putFile(parent, name, mime, data, Calendar.getInstance());
@Override public void run() { try { parent.getSession().refresh(false); Node file = JcrUtils.putFile( parent, "file-" + counter++, "application/octet-stream", new TestInputStream(FILE_SIZE * 1024)); parent.getSession().save(); addPath(file.getPath()); } catch (Exception e) { e.printStackTrace(); } }
private static Node addFile(Node parent, String name) throws RepositoryException { return JcrUtils.putFile(parent, name, "application/octet-stream", new ByteArrayInputStream(DATA)); }
public void testNtFile() throws RepositoryException, IOException { while (testRootNode.hasNode(nodeName1)) { testRootNode.getNode(nodeName1).remove(); } String content = "The quick brown fox jumps over the lazy dog."; Node file = JcrUtils.putFile(testRootNode, nodeName1, "text/plain", new ByteArrayInputStream(content.getBytes("UTF-8"))); testRootNode.getSession().save(); String xpath = testPath + "/*[jcr:contains(jcr:content, 'lazy')]"; executeXPathQuery(xpath, new Node[] { file }); }
JcrUtils.putFile( node, "testFile", "text/plain", new ByteArrayInputStream("Hello, World!".getBytes(StandardCharsets.UTF_8)));
JcrUtils.putFile( node, "testFile", "text/plain", new ByteArrayInputStream("Hello, World!".getBytes(StandardCharsets.UTF_8)));
public void testNtFile() throws RepositoryException, IOException { while (testRootNode.hasNode(nodeName1)) { testRootNode.getNode(nodeName1).remove(); } String content = "The quick brown fox jumps over the lazy dog."; Node file = JcrUtils.putFile(testRootNode, nodeName1, "text/plain", new ByteArrayInputStream(content.getBytes("UTF-8"))); testRootNode.getSession().save(); String xpath = testPath + "/*[jcr:contains(jcr:content, 'lazy')]"; executeXPathQuery(xpath, new Node[] { file }); }
JcrUtils.putFile(targetParent, targetName, mimeType, stream); node.getSession().save(); } catch (RepositoryException e) {
JcrUtils.putFile(targetParent, targetName, mimeType, stream); node.getSession().save(); } catch (RepositoryException e) {
root.getNode(jarName).remove(); JcrUtils.putFile(root, jarName, "application/octet-stream", in, Calendar.getInstance()); } catch (IOException e) { throw new VltException("Error while installing bundle", e);
/** * Update the Assets original rendition. * * @param asset the Asset to update * @param fileInputStream the new binary representation of the Asset * @param mimeType the MIME Type of the asset * @return the updated asset * @throws CsvAssetImportException */ private Asset updateAssetOriginal(Asset asset, InputStream fileInputStream, String mimeType) throws CsvAssetImportException { try { if (asset != null) { final Node originalNode = asset.getOriginal().adaptTo(Node.class); if (originalNode != null) { JcrUtils.putFile(originalNode.getParent(), "original", mimeType, fileInputStream, Calendar.getInstance()); log.info("Updated existing Asset's [ {} ] original rendition.", asset.getPath()); } else { log.warn("Could not find original rendition for Asset [ {} ] to update.", asset.getPath()); } } else { log.warn("Could not update a null asset"); } } catch (Exception e) { throw new CsvAssetImportException("Could not update Asset at [ " + asset.getPath() + " ]", e); } return asset; }
Node imageNode = JcrUtils.putFile(imagesParent.adaptTo(Node.class), name, mimeType, stream); resolver.commit();
@SuppressWarnings("deprecation") @Test public void nodeTypeConstraint() throws Exception { Session session = getAdminSession(); Node root = session.getRootNode(); Node folder1 = root.addNode("folder1", "nt:folder"); Node folder2 = root.addNode("folder2", "nt:folder"); JcrUtils.putFile(folder1, "file", "text/plain", new ByteArrayInputStream("foo bar".getBytes("UTF-8"))); folder2.addNode("folder3", "nt:folder"); session.save(); QueryManager qm = session.getWorkspace().getQueryManager(); Query q = qm.createQuery("//element(*, nt:folder)", Query.XPATH); Set<String> paths = new HashSet<String>(); for (RowIterator it = q.execute().getRows(); it.hasNext();) { paths.add(it.nextRow().getPath()); } assertEquals(new HashSet<String>(Arrays.asList("/folder1", "/folder2", "/folder2/folder3")), paths); }
JcrUtils.putFile(node, "testFile", "text/plain", new ByteArrayInputStream("Hello, World!".getBytes("UTF-8")));
try { Node parent = testRootNode.addNode("parent"); Node n = JcrUtils.putFile(parent, "file", "text/plain", new ByteArrayInputStream("data".getBytes())); parentPath = parent.getPath(); filePath = n.getPath();