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                            _CLASS, "convert",
031                            new Object[] {id, is, sourceExtension, targetExtension}, false);
032    
033                    if (returnObj != null) {
034                            return (InputStream)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                            _CLASS, "getConversions", new Object[] {extension}, false);
044    
045                    if (returnObj != null) {
046                            return (String[])returnObj;
047                    }
048                    else {
049                            return null;
050                    }
051            }
052    
053            private static final String _CLASS =
054                    "com.liferay.portlet.documentlibrary.util.DocumentConversionUtil";
055    
056    }