KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > staticexport > CmsStaticExportResponseWrapper


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/staticexport/CmsStaticExportResponseWrapper.java,v $
3  * Date : $Date: 2005/06/23 11:11:28 $
4  * Version: $Revision: 1.5 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.staticexport;
33
34 import java.io.IOException JavaDoc;
35
36 import javax.servlet.http.HttpServletResponse JavaDoc;
37 import javax.servlet.http.HttpServletResponseWrapper JavaDoc;
38
39 /**
40  * Response wrapper for static export requests, required to access the status code of the response.<p>
41  *
42  * The <code>{@link org.opencms.loader.I_CmsResourceLoader#export(org.opencms.file.CmsObject, org.opencms.file.CmsResource, javax.servlet.http.HttpServletRequest, HttpServletResponse)}</code>
43  * method is called by the static export manager. Many inmplementations set the http status codes for the response.
44  * This wrapper enabled the export manager to return the status code set on the response
45  * in <code>{@link org.opencms.staticexport.CmsStaticExportManager#export(javax.servlet.http.HttpServletRequest, HttpServletResponse, org.opencms.file.CmsObject, CmsStaticExportData)}</code>.<p>
46  *
47  * @author Alexander Kandzior
48  *
49  * @version $Revision: 1.5 $
50  *
51  * @since 6.0.0
52  */

53 public class CmsStaticExportResponseWrapper extends HttpServletResponseWrapper JavaDoc {
54
55     /** The status code. */
56     protected int m_status;
57
58     /**
59      * Creates a new export response wrapper.<p>
60      *
61      * @param res the original response to wrap
62      */

63     public CmsStaticExportResponseWrapper(HttpServletResponse JavaDoc res) {
64
65         super(res);
66         m_status = -1;
67     }
68
69     /**
70      * Returns the status code of this export response, if no status code was set so far,
71      * <code>-1</code> is returned.<p>
72      *
73      * @return the status code of this exportresponse
74      */

75     public int getStatus() {
76
77         return m_status;
78     }
79
80     /**
81      * @see javax.servlet.http.HttpServletResponse#sendError(int)
82      */

83     public void sendError(int status) throws IOException JavaDoc {
84
85         m_status = status;
86         super.sendError(status);
87     }
88
89     /**
90      * @see javax.servlet.http.HttpServletResponse#sendError(int, java.lang.String)
91      */

92     public void sendError(int status, String JavaDoc message) throws IOException JavaDoc {
93
94         m_status = status;
95         super.sendError(status, message);
96     }
97
98     /**
99      * @see javax.servlet.http.HttpServletResponseWrapper#setStatus(int)
100      */

101     public void setStatus(int status) {
102
103         m_status = status;
104         super.setStatus(status);
105     }
106
107     /**
108      * @see javax.servlet.http.HttpServletResponseWrapper#setStatus(int, java.lang.String)
109      */

110     public void setStatus(int status, String JavaDoc message) {
111
112         m_status = status;
113         super.setStatus(status, message);
114     }
115 }
Popular Tags