001    /**
002     * Copyright (c) 2000-2013 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.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    }