1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.sanitizer;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.sanitizer.Sanitizer;
20  import com.liferay.portal.kernel.sanitizer.SanitizerException;
21  import com.liferay.portal.kernel.util.StreamUtil;
22  
23  import java.io.IOException;
24  import java.io.InputStream;
25  import java.io.OutputStream;
26  
27  import java.util.Map;
28  
29  /**
30   * <a href="DummySanitizerImpl.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Zsolt Balogh
33   * @author Brian Wing Shun Chan
34   */
35  public class DummySanitizerImpl implements Sanitizer {
36  
37      public byte[] sanitize(
38          long companyId, long groupId, long userId, String className,
39          long classPK, String contentType, String[] modes, byte[] byteArray,
40          Map<String, Object> options) {
41  
42          if (_log.isDebugEnabled()) {
43              _log.debug("Sanitizing " + className + "#" + classPK);
44          }
45  
46          return byteArray;
47      }
48  
49      public void sanitize(
50              long companyId, long groupId, long userId, String className,
51              long classPK, String contentType, String[] modes,
52              InputStream inputStream, OutputStream outputStream,
53              Map<String, Object> options)
54          throws SanitizerException {
55  
56          if (_log.isDebugEnabled()) {
57              _log.debug("Sanitizing " + className + "#" + classPK);
58          }
59  
60          try {
61              StreamUtil.transfer(inputStream, outputStream);
62          }
63          catch (IOException ioe) {
64              throw new SanitizerException(ioe);
65          }
66      }
67  
68      public String sanitize(
69          long companyId, long groupId, long userId, String className,
70          long classPK, String contentType, String[] modes, String s,
71          Map<String, Object> options) {
72  
73          if (_log.isDebugEnabled()) {
74              _log.debug("Sanitizing " + className + "#" + classPK);
75          }
76  
77          return s;
78      }
79  
80      private static Log _log = LogFactoryUtil.getLog(DummySanitizerImpl.class);
81  
82  }