X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.jcr%2Fsrc%2Forg%2Fargeo%2Fjcr%2FJcrUtils.java;h=cb9fe6e471797a9289a7ff945c53d4530221ff33;hb=7424eb206521b32871b8267110628b35257762af;hp=d66293d9652c4542713f98e4fd2ca841d6eff484;hpb=623a35d1a39522cf8b6a1d6c860ac60a2646f03d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java b/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java index d66293d96..cb9fe6e47 100644 --- a/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java +++ b/org.argeo.jcr/src/org/argeo/jcr/JcrUtils.java @@ -727,7 +727,7 @@ public class JcrUtils { 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)) { @@ -1621,6 +1621,7 @@ public class JcrUtils { } 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); @@ -1634,6 +1635,19 @@ public class JcrUtils { 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. *