1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.util;
16  
17  import java.io.InputStream;
18  
19  /**
20   * <a href="DocumentConversionUtil.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Bruno Farache
23   */
24  public class DocumentConversionUtil {
25  
26      public static InputStream convert(
27              String id, InputStream is, String sourceExtension,
28              String targetExtension)
29          throws Exception {
30  
31          Object returnObj = PortalClassInvoker.invoke(
32              false, _convertMethodKey, id, is, sourceExtension, targetExtension);
33  
34          if (returnObj != null) {
35              return (InputStream)returnObj;
36          }
37          else {
38              return null;
39          }
40      }
41  
42      public static String[] getConversions(String extension) throws Exception {
43          Object returnObj = PortalClassInvoker.invoke(
44              false, _getConversionsMethodKey, extension);
45  
46          if (returnObj != null) {
47              return (String[])returnObj;
48          }
49          else {
50              return null;
51          }
52      }
53  
54      private static final String _CLASS_NAME =
55          "com.liferay.portlet.documentlibrary.util.DocumentConversionUtil";
56  
57      private static MethodKey _convertMethodKey = new MethodKey(
58          _CLASS_NAME, "convert", String.class, InputStream.class, String.class,
59          String.class);
60      private static MethodKey _getConversionsMethodKey = new MethodKey(
61          _CLASS_NAME, "getConversions", String.class);
62  
63  }