Workspace fromWorkspace = fromSession.getWorkspace();
Workspace toWorkspace = toSession.getWorkspace();
String errorMsg = "Cannot copy workspace " + fromWorkspace + " to " + toWorkspace + " via XML.";
-
+
try (PipedInputStream in = new PipedInputStream(1024 * 1024);) {
new Thread(() -> {
try (PipedOutputStream out = new PipedOutputStream(in)) {
}
binary = contentNode.getSession().getValueFactory().createBinary(in);
contentNode.setProperty(Property.JCR_DATA, binary);
+ updateLastModified(contentNode);
return fileNode;
} catch (RepositoryException e) {
throw new JcrException("Cannot create file node " + fileName + " under " + folderNode, e);
return fileNode.getNode(Node.JCR_CONTENT).getProperty(Property.JCR_DATA).getBinary().getStream();
}
+ /**
+ * Set the properties of {@link NodeType#MIX_MIMETYPE} on the content of this
+ * file node.
+ */
+ public static void setFileMimeType(Node fileNode, String mimeType, String encoding) throws RepositoryException {
+ Node contentNode = fileNode.getNode(Node.JCR_CONTENT);
+ if (mimeType != null)
+ contentNode.setProperty(Property.JCR_MIMETYPE, mimeType);
+ if (encoding != null)
+ contentNode.setProperty(Property.JCR_ENCODING, encoding);
+ // TODO remove properties if args are null?
+ }
+
/**
* Computes the checksum of an nt:file.
*