View Javadoc

1   /**
2    * Copyright (C) 2005-2009 Alfresco Software Limited.
3    *
4    * This file is part of the Spring Surf Extension project.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *  http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.springframework.extensions.webscripts;
20  
21  import org.springframework.extensions.surf.util.Content;
22  import org.springframework.extensions.webscripts.Description.FormatStyle;
23  
24  
25  /**
26   * Web Script Request
27   * 
28   * @author davidc
29   */
30  public interface WebScriptRequest
31  {
32      /**
33       * Gets the matching API Service for this request
34       * 
35       * @return  the service match
36       */
37      public Match getServiceMatch();
38      
39      /**
40       * Get server portion of the request
41       *
42       * e.g. scheme://host:port
43       *  
44       * @return  server path
45       */
46      public String getServerPath();
47      
48      /**
49       * Gets the Alfresco Context Path
50       * 
51       * @return  context url e.g. /alfresco
52       */
53      public String getContextPath();
54      
55      /**
56       * Gets the Alfresco Web Script Context Path
57       * 
58       * @return  service url  e.g. /alfresco/service
59       */
60      public String getServiceContextPath();
61  
62      /**
63       * Gets the Alfresco Service Path
64       * 
65       * @return  service url  e.g. /alfresco/service/search/keyword
66       */
67      public String getServicePath();
68  
69      /**
70       * Gets the full request URL
71       * 
72       * @return  request url e.g. /alfresco/service/search/keyword?q=term
73       */
74      public String getURL();
75  
76      /**
77       * Gets the service specific path
78       * 
79       * @return  request path e.g. /search/keyword
80       */
81      public String getPathInfo();
82      
83      /**
84       * Gets the query String
85       * 
86       * @return  query string  e.g. q=alfresco&format=atom
87       */
88      public String getQueryString();
89      
90      /**
91       * Gets the names of all parameters on the Url
92       * 
93       * @return  the names (empty, if none)
94       */
95      public String[] getParameterNames();
96  
97      /**
98       * Gets the value of the named parameter
99       *
100      * @param name  parameter name
101      * @return  parameter value (or null, if parameter does not exist)
102      */
103     public String getParameter(String name);
104 
105     /**
106      * Gets the (array) value of the named parameter
107      * 
108      * Note: An array of one item is returned when a "single value" named parameter 
109      *       is requested
110      *       
111      * @param  name  parameter name
112      * @return  array of values (or null, if parameter does not exist)
113      */
114     public String[] getParameterValues(String name);
115         
116     /**
117      * Gets the names of all headers for this request
118      * 
119      * @return  the names (empty, if none)
120      */
121     public String[] getHeaderNames();
122 
123     /**
124      * Gets the value of the named header
125      *
126      * @param name  header name
127      * @return  header value (or null, if header does not exist)
128      */
129     public String getHeader(String name);
130 
131     /**
132      * Gets the (array) value of the named header
133      * 
134      * Note: An array of one item is returned when a "single value" named header 
135      *       is requested
136      *       
137      * @param  name  header name
138      * @return  array of values (or null, if header does not exist)
139      */
140     public String[] getHeaderValues(String name);
141     
142     /**
143      * Gets the path extension beyond the path registered for this service
144      * 
145      * e.g.
146      * a) service registered path = /search/engine
147      * b) request path = /search/engine/external
148      * 
149      * => /external
150      * 
151      * @return  extension path
152      */
153     public String getExtensionPath();
154     
155     /**
156      * Gets the mimetype of the request
157      * 
158      * @return  request content mimetype
159      */
160     public String getContentType();
161     
162     /**
163      * Gets the request body as content
164      * 
165      * @return  request content (or null, if none)
166      */
167     public Content getContent();
168     
169     /**
170      * Gets the request body as a parsed entity
171      * 
172      * @return  the parsed entity (or null, if no content, or the content type cannot be parsed)
173      */
174     public Object parseContent();
175     
176     /**
177      * Determine if Guest User?
178      * 
179      * @return  true => guest user
180      */
181     public boolean isGuest();
182     
183     /**
184      * Get Requested Format
185      * 
186      * @return  content type requested
187      */
188     public String getFormat();
189  
190     /**
191      * Get the style the Format was specified in
192      * 
193      * @return  format style (excludes any)
194      */
195     public FormatStyle getFormatStyle();
196  
197     /**
198      * Get User Agent
199      * 
200      * TODO: Expand on known agents
201      * 
202      * @return  MSIE / Firefox
203      */
204     public String getAgent();
205 
206     /**
207      * Get the JSON callback method
208      * 
209      * @return  method (or null, if not specified)
210      */
211     public String getJSONCallback();
212 
213     /**
214      * Force response to return SUCCESS (200) code
215      * 
216      * Note: This is to support clients who cannot support non-success codes
217      *       e.g. Flash player
218      *       
219      * @return true => force return of 200, otherwise return status explicitly set
220      */
221     public boolean forceSuccessStatus();
222     
223     /**
224      * Gets the initiating runtime
225      * 
226      * @return  runtime that constructed this request
227      */
228     public Runtime getRuntime();
229 }