03-12-2008 10:54 AM
03-14-2008 10:42 AM
03-17-2008 05:22 AM
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");
}
}
03-17-2008 06:29 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.