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.sanitizer;
016    
017    import java.io.InputStream;
018    import java.io.OutputStream;
019    
020    import java.util.Map;
021    
022    /**
023     * @author Zsolt Balogh
024     * @author Brian Wing Shun Chan
025     */
026    public class SanitizerWrapper implements Sanitizer {
027    
028            public SanitizerWrapper(Sanitizer sanitizer) {
029                    _originalSanitizer = sanitizer;
030                    _sanitizer = sanitizer;
031            }
032    
033            public byte[] sanitize(
034                            long companyId, long groupId, long userId, String className,
035                            long classPK, String contentType, String[] modes, byte[] byteArray,
036                            Map<String, Object> options)
037                    throws SanitizerException {
038    
039                    return _sanitizer.sanitize(
040                            companyId, groupId, userId, className, classPK, contentType, modes,
041                            byteArray, options);
042            }
043    
044            public void sanitize(
045                            long companyId, long groupId, long userId, String className,
046                            long classPK, String contentType, String[] modes,
047                            InputStream inputStream, OutputStream outputStream,
048                            Map<String, Object> options)
049                    throws SanitizerException {
050    
051                    _sanitizer.sanitize(
052                            companyId, groupId, userId, className, classPK, contentType, modes,
053                            inputStream, outputStream, options);
054            }
055    
056            public String sanitize(
057                            long companyId, long groupId, long userId, String className,
058                            long classPK, String contentType, String[] modes, String s,
059                            Map<String, Object> options)
060                    throws SanitizerException {
061    
062                    return _sanitizer.sanitize(
063                            companyId, groupId, userId, className, classPK, contentType, modes,
064                            s, options);
065            }
066    
067            public void setSanitizer(Sanitizer sanitizer) {
068                    if (sanitizer == null) {
069                            _sanitizer = _originalSanitizer;
070                    }
071                    else {
072                            _sanitizer = sanitizer;
073                    }
074            }
075    
076            private Sanitizer _originalSanitizer;
077            private Sanitizer _sanitizer;
078    
079    }