2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
23 package com.pentila.entSavoie.servlet;
\r
25 import java.io.IOException;
\r
26 import java.io.InputStream;
\r
27 import java.io.OutputStream;
\r
30 import javax.servlet.http.HttpServletResponse;
\r
34 * <a href="ServletResponseUtil.java.html"><b><i>View Source</i></b></a>
\r
36 * @author Brian Wing Shun Chan
\r
39 public class ServletResponseServiceUtil {
\r
41 public static void cleanUp(InputStream is){
\r
42 getService().cleanUp(is);
\r
45 public static void cleanUp(OutputStream os){
\r
46 getService().cleanUp(os);
\r
49 public static void cleanUp(OutputStream os, InputStream is){
\r
50 getService().cleanUp(os, is);
\r
53 public static void sendFile(
\r
54 HttpServletResponse response, String fileName, byte[] bytes)
\r
56 getService().sendFile(response, fileName, bytes);
\r
59 public static void sendFile(
\r
60 HttpServletResponse response, String fileName, byte[] bytes,
\r
63 getService().sendFile(response, fileName, bytes, contentType);
\r
66 public static void sendFile(
\r
67 HttpServletResponse response, String fileName, byte[] bytes,
\r
68 String contentType, String forceContentDisposition)
\r
70 getService().sendFile(response, fileName, bytes, contentType, forceContentDisposition);
\r
73 public static void sendFile(
\r
74 HttpServletResponse response, String fileName, InputStream is)
\r
76 getService().sendFile(response, fileName, is);
\r
79 public static void sendFile(
\r
80 HttpServletResponse response, String fileName, InputStream is,
\r
83 getService().sendFile(response, fileName, is, contentType);
\r
86 public static void sendFile(
\r
87 HttpServletResponse response, String fileName, InputStream is,
\r
88 int contentLength, String contentType)
\r
90 getService().sendFile(response, fileName, is, contentLength, contentType);
\r
93 public static void sendFile(
\r
94 HttpServletResponse response, String fileName, InputStream is,
\r
95 int contentLength, String contentType, String forceContentDisposition)
\r
97 getService().sendFile(response, fileName, is, contentLength, contentType, forceContentDisposition);
\r
100 public static void write(HttpServletResponse response, String s)
\r
101 throws IOException{
\r
102 getService().write(response, s);
\r
105 public static void write(HttpServletResponse response, byte[] bytes)
\r
106 throws IOException{
\r
107 getService().write(response, bytes);
\r
110 public static void write(
\r
111 HttpServletResponse response, byte[] bytes, int contentLength)
\r
112 throws IOException{
\r
113 getService().write(response, bytes, contentLength);
\r
115 public static void write(HttpServletResponse response, InputStream is)
\r
116 throws IOException{
\r
117 getService().write(response, is);
\r
120 public static void write(
\r
121 HttpServletResponse response, InputStream is, int contentLength)
\r
122 throws IOException{
\r
123 getService().write(response, is, contentLength);
\r
126 public static void setHeaders(
\r
127 HttpServletResponse response,
\r
129 String contentType,
\r
130 String forceContentDisposition){
\r
131 getService().setHeaders(response, fileName, contentType, forceContentDisposition);
\r
134 public static ServletResponseService getService() {
\r
135 if (_service == null) {
\r
136 throw new RuntimeException("ServletResponseService is not set");
\r
142 public void setService(ServletResponseService service) {
\r
143 _service = service;
\r
146 private static ServletResponseService _service;
\r