001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import java.io.InputStream;
018    
019    /**
020     * @author Bruno Farache
021     */
022    public class DocumentConversionUtil {
023    
024            public static File convert(
025                            String id, InputStream inputStream, String sourceExtension,
026                            String targetExtension)
027                    throws Exception {
028    
029                    Object returnObj = PortalClassInvoker.invoke(
030                            false, _convertMethodKey, id, inputStream, sourceExtension,
031                            targetExtension);
032    
033                    if (returnObj != null) {
034                            return (File)returnObj;
035                    }
036                    else {
037                            return null;
038                    }
039            }
040    
041            public static String[] getConversions(String extension) throws Exception {
042                    Object returnObj = PortalClassInvoker.invoke(
043                            false, _getConversionsMethodKey, extension);
044    
045                    if (returnObj != null) {
046                            return (String[])returnObj;
047                    }
048                    else {
049                            return null;
050                    }
051            }
052    
053            private static final String _CLASS_NAME =
054                    "com.liferay.portlet.documentlibrary.util.DocumentConversionUtil";
055    
056            private static MethodKey _convertMethodKey = new MethodKey(
057                    _CLASS_NAME, "convert", String.class, InputStream.class, String.class,
058                    String.class);
059            private static MethodKey _getConversionsMethodKey = new MethodKey(
060                    _CLASS_NAME, "getConversions", String.class);
061    
062    }