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[] bytes,
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, modes,
041 new ByteArrayInputStream(bytes), byteArrayOutputStream, options);
042
043 return byteArrayOutputStream.toByteArray();
044 }
045
046 public abstract void sanitize(
047 long companyId, long groupId, long userId, String className,
048 long classPK, String contentType, String[] modes,
049 InputStream inputStream, OutputStream outputStream,
050 Map<String, Object> options)
051 throws SanitizerException;
052
053 public String sanitize(
054 long companyId, long groupId, long userId, String className,
055 long classPK, String contentType, String[] modes, String s,
056 Map<String, Object> options)
057 throws SanitizerException {
058
059 ByteArrayOutputStream byteArrayOutputStream =
060 new ByteArrayOutputStream();
061
062 sanitize(
063 companyId, groupId, userId, className, classPK, contentType, modes,
064 new ByteArrayInputStream(s.getBytes()), byteArrayOutputStream,
065 options);
066
067 return byteArrayOutputStream.toString();
068 }
069
070 }