1
14
15 package com.liferay.portal.kernel.sanitizer;
16
17 import java.io.ByteArrayInputStream;
18 import java.io.ByteArrayOutputStream;
19 import java.io.InputStream;
20 import java.io.OutputStream;
21
22 import java.util.Map;
23
24
30 public abstract class BaseSanitizer implements Sanitizer {
31
32 public byte[] sanitize(
33 long companyId, long groupId, long userId, String className,
34 long classPK, String contentType, String[] modes, byte[] byteArray,
35 Map<String, Object> options)
36 throws SanitizerException {
37
38 ByteArrayOutputStream byteArrayOutputStream =
39 new ByteArrayOutputStream();
40
41 sanitize(
42 companyId, groupId, userId, className, classPK, contentType,
43 modes, new ByteArrayInputStream(byteArray), byteArrayOutputStream,
44 options);
45
46 return byteArrayOutputStream.toByteArray();
47 }
48
49 public abstract void sanitize(
50 long companyId, long groupId, long userId, String className,
51 long classPK, String contentType, String[] modes,
52 InputStream inputStream, OutputStream outputStream,
53 Map<String, Object> options)
54 throws SanitizerException;
55
56 public String sanitize(
57 long companyId, long groupId, long userId, String className,
58 long classPK, String contentType, String[] modes, String s,
59 Map<String, Object> options)
60 throws SanitizerException {
61
62 ByteArrayOutputStream byteArrayOutputStream =
63 new ByteArrayOutputStream();
64
65 sanitize(
66 companyId, groupId, userId, className, classPK, contentType,
67 modes, new ByteArrayInputStream(s.getBytes()),
68 byteArrayOutputStream, options);
69
70 return byteArrayOutputStream.toString();
71 }
72
73 }