As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) { if (this.nodeService.exists(actionedUponNodeRef) == true) { String name = (String) nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME); String mime = mimetypeService.guessMimetype(name); logger.debug("Guessed mimetype to be: "+mime); // guess the mimetype ContentData oldContent = (ContentData) nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_CONTENT); ContentData newContent = ContentData.setMimetype(oldContent, mime); // guess the encoding ContentReader reader = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT); InputStream is = reader.getContentInputStream(); Charset charset = contentCharsetFinder.getCharset(is, mime); logger.debug("Guessed charset to be: "+charset.name()); newContent = ContentData.setEncoding(newContent, charset.name()); nodeService.setProperty(actionedUponNodeRef, ContentModel.PROP_CONTENT, newContent); logger.debug("Setting new mimetype and charset"); } }