001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import java.io.File;
018    import java.io.InputStream;
019    
020    /**
021     * @author Bruno Farache
022     */
023    public class DocumentConversionUtil {
024    
025            public static File convert(
026                            String id, InputStream inputStream, String sourceExtension,
027                            String targetExtension)
028                    throws Exception {
029    
030                    Object returnObj = PortalClassInvoker.invoke(
031                            false, _convertMethodKey, id, inputStream, sourceExtension,
032                            targetExtension);
033    
034                    if (returnObj != null) {
035                            return (File)returnObj;
036                    }
037                    else {
038                            return null;
039                    }
040            }
041    
042            public static String[] getConversions(String extension) throws Exception {
043                    Object returnObj = PortalClassInvoker.invoke(
044                            false, _getConversionsMethodKey, extension);
045    
046                    if (returnObj != null) {
047                            return (String[])returnObj;
048                    }
049                    else {
050                            return null;
051                    }
052            }
053    
054            private static final String _CLASS_NAME =
055                    "com.liferay.portlet.documentlibrary.util.DocumentConversionUtil";
056    
057            private static MethodKey _convertMethodKey = new MethodKey(
058                    ClassResolverUtil.resolveByPortalClassLoader(_CLASS_NAME), "convert",
059                    String.class, InputStream.class, String.class, String.class);
060            private static MethodKey _getConversionsMethodKey = new MethodKey(
061                    ClassResolverUtil.resolveByPortalClassLoader(_CLASS_NAME),
062                    "getConversions", String.class);
063    
064    }