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.kernel.sanitizer;
16  
17  import java.io.InputStream;
18  import java.io.OutputStream;
19  
20  import java.util.Map;
21  
22  /**
23   * <a href="SanitizerWrapper.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Zsolt Balogh
26   * @author Brian Wing Shun Chan
27   */
28  public class SanitizerWrapper implements Sanitizer {
29  
30      public SanitizerWrapper(Sanitizer sanitizer) {
31          _originalSanitizer = sanitizer;
32          _sanitizer = sanitizer;
33      }
34  
35      public byte[] sanitize(
36              long companyId, long groupId, long userId, String className,
37              long classPK, String contentType, String[] modes, byte[] byteArray,
38              Map<String, Object> options)
39          throws SanitizerException {
40  
41          return _sanitizer.sanitize(
42              companyId, groupId, userId, className, classPK, contentType, modes,
43              byteArray, options);
44      }
45  
46      public void sanitize(
47              long companyId, long groupId, long userId, String className,
48              long classPK, String contentType, String[] modes,
49              InputStream inputStream, OutputStream outputStream,
50              Map<String, Object> options)
51          throws SanitizerException {
52  
53          _sanitizer.sanitize(
54              companyId, groupId, userId, className, classPK, contentType, modes,
55              inputStream, outputStream, options);
56      }
57  
58      public String sanitize(
59              long companyId, long groupId, long userId, String className,
60              long classPK, String contentType, String[] modes, String s,
61              Map<String, Object> options)
62          throws SanitizerException {
63  
64          return _sanitizer.sanitize(
65              companyId, groupId, userId, className, classPK, contentType, modes,
66              s, options);
67      }
68  
69      public void setSanitizer(Sanitizer sanitizer) {
70          if (sanitizer == null) {
71              _sanitizer = _originalSanitizer;
72          }
73          else {
74              _sanitizer = sanitizer;
75          }
76      }
77  
78      private Sanitizer _originalSanitizer;
79      private Sanitizer _sanitizer;
80  
81  }