001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.sanitizer;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.sanitizer.Sanitizer;
020    import com.liferay.portal.kernel.sanitizer.SanitizerException;
021    import com.liferay.portal.kernel.util.StreamUtil;
022    
023    import java.io.IOException;
024    import java.io.InputStream;
025    import java.io.OutputStream;
026    
027    import java.util.Map;
028    
029    /**
030     * @author Zsolt Balogh
031     * @author Brian Wing Shun Chan
032     */
033    public class DummySanitizerImpl implements Sanitizer {
034    
035            @Override
036            public byte[] sanitize(
037                    long companyId, long groupId, long userId, String className,
038                    long classPK, String contentType, String[] modes, byte[] bytes,
039                    Map<String, Object> options) {
040    
041                    if (_log.isDebugEnabled()) {
042                            _log.debug("Sanitizing " + className + "#" + classPK);
043                    }
044    
045                    return bytes;
046            }
047    
048            @Override
049            public void sanitize(
050                            long companyId, long groupId, long userId, String className,
051                            long classPK, String contentType, String[] modes,
052                            InputStream inputStream, OutputStream outputStream,
053                            Map<String, Object> options)
054                    throws SanitizerException {
055    
056                    if (_log.isDebugEnabled()) {
057                            _log.debug("Sanitizing " + className + "#" + classPK);
058                    }
059    
060                    try {
061                            StreamUtil.transfer(inputStream, outputStream);
062                    }
063                    catch (IOException ioe) {
064                            throw new SanitizerException(ioe);
065                    }
066            }
067    
068            @Override
069            public String sanitize(
070                    long companyId, long groupId, long userId, String className,
071                    long classPK, String contentType, String[] modes, String s,
072                    Map<String, Object> options) {
073    
074                    if (_log.isDebugEnabled()) {
075                            _log.debug("Sanitizing " + className + "#" + classPK);
076                    }
077    
078                    return s;
079            }
080    
081            private static Log _log = LogFactoryUtil.getLog(DummySanitizerImpl.class);
082    
083    }