Triggering asset rendition updates
We have run into an issue with one of our major integrations that runs every two hours. The system updates nodes with new images when needed. Unfortunately, the renditions get out of sync as this update does not trigger rendition updates. What is the best way to modify this method to trigger the renditions to update?
private Node uploadImageToDam(Session session, String imageUrl, Node node, String imagePath) throws URISyntaxException, IOException, RepositoryException { Node imageNode = getNode(session.getRootNode(), imagePath, "dam:Asset"); imageNode.addMixin("mix:versionable"); Node imageContentNode = getNode(imageNode, "jcr:content", "dam:AssetContent"); // Node relatedNode = getNode(imageContentNode, "related", "nt:unstructured"); Node metadataNode = getNode(imageContentNode, "metadata", "nt:unstructured"); metadataNode.addMixin("cq:Taggable"); Node renditionsNode = getNode(imageContentNode, "renditions", "nt:folder"); Node originalNode = getNode(renditionsNode, "original", "nt:file"); Node dataNode = getNode(originalNode, "jcr:content", "nt:resource"); URI uri = new URI(imageUrl); URLConnection conn = uri.toURL().openConnection(); Binary binary = session.getValueFactory().createBinary(new BufferedInputStream(conn.getInputStream())); String mimeType = conn.getContentType(); if (mimeType.contains(";")) { mimeType = mimeType.substring(0, mimeType.indexOf(";")); } dataNode.setProperty("jcr:data", binary); dataNode.setProperty("jcr:mimeType", mimeType); return imageNode; }