001
014
015 package com.liferay.portal.kernel.sanitizer;
016
017 import java.io.ByteArrayInputStream;
018 import java.io.ByteArrayOutputStream;
019 import java.io.InputStream;
020 import java.io.OutputStream;
021
022 import java.util.Map;
023
024
028 public abstract class BaseSanitizer implements Sanitizer {
029
030 public byte[] sanitize(
031 long companyId, long groupId, long userId, String className,
032 long classPK, String contentType, String[] modes, byte[] byteArray,
033 Map<String, Object> options)
034 throws SanitizerException {
035
036 ByteArrayOutputStream byteArrayOutputStream =
037 new ByteArrayOutputStream();
038
039 sanitize(
040 companyId, groupId, userId, className, classPK, contentType,
041 modes, new ByteArrayInputStream(byteArray), byteArrayOutputStream,
042 options);
043
044 return byteArrayOutputStream.toByteArray();
045 }
046
047 public abstract 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 public String sanitize(
055 long companyId, long groupId, long userId, String className,
056 long classPK, String contentType, String[] modes, String s,
057 Map<String, Object> options)
058 throws SanitizerException {
059
060 ByteArrayOutputStream byteArrayOutputStream =
061 new ByteArrayOutputStream();
062
063 sanitize(
064 companyId, groupId, userId, className, classPK, contentType,
065 modes, new ByteArrayInputStream(s.getBytes()),
066 byteArrayOutputStream, options);
067
068 return byteArrayOutputStream.toString();
069 }
070
071 }