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