001    /**
002     * Copyright (c) 2000-2011 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            public byte[] sanitize(
036                    long companyId, long groupId, long userId, String className,
037                    long classPK, String contentType, String[] modes, byte[] byteArray,
038                    Map<String, Object> options) {
039    
040                    if (_log.isDebugEnabled()) {
041                            _log.debug("Sanitizing " + className + "#" + classPK);
042                    }
043    
044                    return byteArray;
045            }
046    
047            public void sanitize(
048                            long companyId, long groupId, long userId, String className,
049                            long classPK, String contentType, String[] modes,
050                            InputStream inputStream, OutputStream outputStream,
051                            Map<String, Object> options)
052                    throws SanitizerException {
053    
054                    if (_log.isDebugEnabled()) {
055                            _log.debug("Sanitizing " + className + "#" + classPK);
056                    }
057    
058                    try {
059                            StreamUtil.transfer(inputStream, outputStream);
060                    }
061                    catch (IOException ioe) {
062                            throw new SanitizerException(ioe);
063                    }
064            }
065    
066            public String sanitize(
067                    long companyId, long groupId, long userId, String className,
068                    long classPK, String contentType, String[] modes, String s,
069                    Map<String, Object> options) {
070    
071                    if (_log.isDebugEnabled()) {
072                            _log.debug("Sanitizing " + className + "#" + classPK);
073                    }
074    
075                    return s;
076            }
077    
078            private static Log _log = LogFactoryUtil.getLog(DummySanitizerImpl.class);
079    
080    }