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