Example usage for com.liferay.portal.util PropsUtil getArray

List of usage examples for com.liferay.portal.util PropsUtil getArray

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsUtil getArray.

Prototype

public static String[] getArray(String key, Filter filter) 

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);
            }/*from  www. ja v a  2 s  . 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(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);
            }//from w  ww  .ja  v  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()]));
        }
    }
}