View Javadoc
1   /**
2    * This file Copyright (c) 2003-2018 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.context;
35  
36  import info.magnolia.cms.beans.runtime.MultipartForm;
37  import info.magnolia.cms.core.AggregationState;
38  
39  import java.io.IOException;
40  import java.io.Writer;
41  import java.util.Map;
42  
43  import javax.servlet.ServletContext;
44  import javax.servlet.ServletException;
45  import javax.servlet.http.HttpServletRequest;
46  import javax.servlet.http.HttpServletResponse;
47  
48  
49  /**
50   * Context interface specialized for servlet requests; knows about HttpServletRequest/HttpServletResponse.
51   */
52  public interface WebContext extends Context {
53  
54      /**
55       * Attribute name to get the requests character encoding.
56       *
57       * @deprecated since 5.3.3 use AggregationState
58       */
59      @Deprecated
60      public static final String ATTRIBUTE_REQUEST_CHARACTER_ENCODING = "characterEncoding";
61  
62      /**
63       * Attribute name to get the request uri.
64       *
65       * @deprecated since 5.3.3 use AggregationState
66       */
67      @Deprecated
68      public static final String ATTRIBUTE_REQUEST_URI = "requestURI";
69  
70      /**
71       * Method used to initialize the context.
72       */
73      public void init(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext);
74  
75      /**
76       * Retrieves the Aggregator instance, which gathers all info regarding the current request (paths, etc).
77       */
78      public AggregationState getAggregationState();
79  
80      /**
81       * Resets the current aggregator instance.
82       */
83      void resetAggregationState();
84  
85      /**
86       * Get form object assembled by <code>MultipartRequestFilter</code>.
87       *
88       * @return multipart form object
89       */
90      public MultipartForm getPostedForm();
91  
92      /**
93       * Get a parameter value as string.
94       *
95       * @return parameter value
96       */
97      public String getParameter(String name);
98  
99      /**
100      * Get all parameter values as a Map&lt;String, String&gt;.
101      *
102      * @return parameter values
103      */
104     public Map<String, String> getParameters();
105 
106     /**
107      * Get the current context path.
108      */
109     public String getContextPath();
110 
111     /**
112      * Avoid calls to this method wherever possible.
113      *
114      * @return Returns the request.
115      */
116     public HttpServletRequest getRequest();
117 
118     /**
119      * Avoid depending on this as much as possible.
120      */
121     public HttpServletResponse getResponse();
122 
123     /**
124      * Returns the current servlet context.
125      *
126      * @return ServletContext instance
127      */
128     ServletContext getServletContext();
129 
130     /**
131      * Includes/render the given path into the given Writer, by wrapping it in the current HttpServletResponse.
132      *
133      * @see javax.servlet.ServletRequest#getRequestDispatcher(String)
134      * @see javax.servlet.RequestDispatcher#include(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
135      */
136     void include(final String path, final Writer out) throws ServletException, IOException;
137 
138     public void push(HttpServletRequest request, HttpServletResponse response);
139 
140     /**
141      *
142      */
143     public void pop();
144 
145     /**
146      * Get parameter values as string[].
147      *
148      * @return parameter values
149      */
150     public String[] getParameterValues(String name);
151 
152 }