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.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  }