001    /**
002     * Copyright (c) 2000-2010 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 InputStream convert(
025                            String id, InputStream is, String sourceExtension,
026                            String targetExtension)
027                    throws Exception {
028    
029                    Object returnObj = PortalClassInvoker.invoke(
030                            false, _convertMethodKey, id, is, sourceExtension, targetExtension);
031    
032                    if (returnObj != null) {
033                            return (InputStream)returnObj;
034                    }
035                    else {
036                            return null;
037                    }
038            }
039    
040            public static String[] getConversions(String extension) throws Exception {
041                    Object returnObj = PortalClassInvoker.invoke(
042                            false, _getConversionsMethodKey, extension);
043    
044                    if (returnObj != null) {
045                            return (String[])returnObj;
046                    }
047                    else {
048                            return null;
049                    }
050            }
051    
052            private static final String _CLASS_NAME =
053                    "com.liferay.portlet.documentlibrary.util.DocumentConversionUtil";
054    
055            private static MethodKey _convertMethodKey = new MethodKey(
056                    _CLASS_NAME, "convert", String.class, InputStream.class, String.class,
057                    String.class);
058            private static MethodKey _getConversionsMethodKey = new MethodKey(
059                    _CLASS_NAME, "getConversions", String.class);
060    
061    }