Examples of DocumentFormat


Examples of org.artofsolving.jodconverter.document.DocumentFormat

        // todo: use fileCleaningTracker
        return File.createTempFile("doc-converter", null);
    }

    public String getMimeType(String extension) {
        DocumentFormat df = formatRegistry.getFormatByExtension(extension);
        if (df == null) {
            return null;
        }
        return df.getMediaType();
    }
View Full Code Here

Examples of org.artofsolving.jodconverter.document.DocumentFormat

        }
        return df.getMediaType();
    }

    public String getExtension(String mimeType) {
        DocumentFormat df = formatRegistry.getFormatByMediaType(mimeType);
        if (df == null) {
            return null;
        }
        return df.getExtension();
    }
View Full Code Here

Examples of org.artofsolving.jodconverter.document.DocumentFormat

            return;
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Converting node " + nodeFact.getPath() + " into target MIME type '" + targetMimeType + "'");
        }
        DocumentFormat format = converterService.getFormatByMimeType(targetMimeType);
        if (format == null) {
            logger.warn("Unsupported target MIME type '" + targetMimeType + "'. Skip converting file "
                    + nodeFact.getPath());
            return;
        }

        InputStream is = null;
        try {
            JCRNodeWrapper node = nodeFact.getNode();
            if (node.isNodeType("nt:file")) {
                is = node.getFileContent().downloadFile();
                File temp = File.createTempFile("doc-converter-rule", null);
                FileOutputStream os = new FileOutputStream(temp);
                try {
                    converterService.convert(is, nodeFact.getMimeType(), os, targetMimeType);
                    os.close();

                    JCRNodeWrapper folder = node.getParent();
                    String newName = StringUtils.substringBeforeLast(node.getName(), ".") + "." + format.getExtension();

                    if (!overwriteIfExists) {
                        newName = JCRContentUtils.findAvailableNodeName(folder, newName);
                    }

                    FileInputStream convertedStream = new FileInputStream(temp);
                    try {
                        folder.uploadFile(newName, convertedStream, format.getMediaType());
                        logger.info("Converted node " + nodeFact.getPath() + " to type " + format.getMediaType());
                    } finally {
                        IOUtils.closeQuietly(convertedStream);
                    }
                } finally {
                    IOUtils.closeQuietly(os);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.