Example usage for com.liferay.portal.kernel.util PropsKeys OPENOFFICE_CONVERSION_TARGET_EXTENSIONS

List of usage examples for com.liferay.portal.kernel.util PropsKeys OPENOFFICE_CONVERSION_TARGET_EXTENSIONS

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys OPENOFFICE_CONVERSION_TARGET_EXTENSIONS.

Prototype

String OPENOFFICE_CONVERSION_TARGET_EXTENSIONS

To view the source code for com.liferay.portal.kernel.util PropsKeys OPENOFFICE_CONVERSION_TARGET_EXTENSIONS.

Click Source Link

Usage

From source file:com.liferay.document.library.document.conversion.internal.DocumentConversionImpl.java

License:Open Source License

private void _populateConversionsMap(String documentFamily) {
    Filter filter = new Filter(documentFamily);

    DocumentFormatRegistry documentFormatRegistry = new DefaultDocumentFormatRegistry();

    String[] sourceExtensions = PropsUtil.getArray(PropsKeys.OPENOFFICE_CONVERSION_SOURCE_EXTENSIONS, filter);
    String[] targetExtensions = PropsUtil.getArray(PropsKeys.OPENOFFICE_CONVERSION_TARGET_EXTENSIONS, filter);

    for (String sourceExtension : sourceExtensions) {
        List<String> conversions = new SortedArrayList<>();

        DocumentFormat sourceDocumentFormat = documentFormatRegistry.getFormatByFileExtension(sourceExtension);

        if (sourceDocumentFormat == null) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid source extension " + sourceExtension);
            }//  w  w  w  .  j  a  v  a 2s . com

            continue;
        }

        for (String targetExtension : targetExtensions) {
            DocumentFormat targetDocumentFormat = documentFormatRegistry
                    .getFormatByFileExtension(targetExtension);

            if (targetDocumentFormat == null) {
                if (_log.isWarnEnabled()) {
                    _log.warn("Invalid target extension " + targetDocumentFormat);
                }

                continue;
            }

            if (sourceDocumentFormat.isExportableTo(targetDocumentFormat)) {
                conversions.add(targetExtension);
            }
        }

        if (conversions.isEmpty()) {
            if (_log.isInfoEnabled()) {
                _log.info("There are no conversions supported from " + sourceExtension);
            }
        } else {
            if (_log.isInfoEnabled()) {
                _log.info(StringBundler.concat("Conversions supported from ", sourceExtension, " to ",
                        String.valueOf(conversions)));
            }

            _conversionsMap.put(sourceExtension, conversions.toArray(new String[conversions.size()]));
        }
    }
}

From source file:com.liferay.portlet.documentlibrary.util.DocumentConversionUtil.java

License:Open Source License

private void _populateConversionsMap(String documentFamily) {
    Filter filter = new Filter(documentFamily);

    DocumentFormatRegistry documentFormatRegistry = new DefaultDocumentFormatRegistry();

    String[] sourceExtensions = PropsUtil.getArray(PropsKeys.OPENOFFICE_CONVERSION_SOURCE_EXTENSIONS, filter);
    String[] targetExtensions = PropsUtil.getArray(PropsKeys.OPENOFFICE_CONVERSION_TARGET_EXTENSIONS, filter);

    for (String sourceExtension : sourceExtensions) {
        List<String> conversions = new SortedArrayList<String>();

        DocumentFormat sourceDocumentFormat = documentFormatRegistry.getFormatByFileExtension(sourceExtension);

        if (sourceDocumentFormat == null) {
            if (_log.isWarnEnabled()) {
                _log.warn("Invalid source extension " + sourceExtension);
            }/*w  w w  .  jav a2s .  c  o  m*/

            continue;
        }

        for (String targetExtension : targetExtensions) {
            DocumentFormat targetDocumentFormat = documentFormatRegistry
                    .getFormatByFileExtension(targetExtension);

            if (targetDocumentFormat == null) {
                if (_log.isWarnEnabled()) {
                    _log.warn("Invalid target extension " + targetDocumentFormat);
                }

                continue;
            }

            if (sourceDocumentFormat.isExportableTo(targetDocumentFormat)) {
                conversions.add(targetExtension);
            }
        }

        if (conversions.isEmpty()) {
            if (_log.isInfoEnabled()) {
                _log.info("There are no conversions supported from " + sourceExtension);
            }
        } else {
            if (_log.isInfoEnabled()) {
                _log.info("Conversions supported from " + sourceExtension + " to " + conversions);
            }

            _conversionsMap.put(sourceExtension, conversions.toArray(new String[conversions.size()]));
        }
    }
}