001    /**
002     * Copyright (c) 2000-2010 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.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    }