|
Lines 104-110
Link Here
|
| 104 |
throws IOException |
104 |
throws IOException |
| 105 |
{ |
105 |
{ |
| 106 |
setJsonResponseHeaders( response ); |
106 |
setJsonResponseHeaders( response ); |
| 107 |
if( isSessionShutdown() ) { |
107 |
if( !isContentTypeValid( request ) ) { |
|
|
108 |
writeInvalidContentType( response ); |
| 109 |
} else if( isSessionShutdown() ) { |
| 108 |
shutdownUISession(); |
110 |
shutdownUISession(); |
| 109 |
} else if( isSessionTimeout() ) { |
111 |
} else if( isSessionTimeout() ) { |
| 110 |
writeSessionTimeoutError( response ); |
112 |
writeSessionTimeoutError( response ); |
|
Lines 159-164
Link Here
|
| 159 |
return sentRequestId != null && sentRequestId.asInt() == currentRequestId - 1; |
161 |
return sentRequestId != null && sentRequestId.asInt() == currentRequestId - 1; |
| 160 |
} |
162 |
} |
| 161 |
|
163 |
|
|
|
164 |
private static boolean isContentTypeValid( ServletRequest request ) { |
| 165 |
String contentType = request.getContentType(); |
| 166 |
return contentType != null && contentType.startsWith( HTTP.CONTENT_TYPE_JSON ); |
| 167 |
} |
| 168 |
|
| 162 |
private static void shutdownUISession() { |
169 |
private static void shutdownUISession() { |
| 163 |
UISessionImpl uiSession = ( UISessionImpl )ContextProvider.getUISession(); |
170 |
UISessionImpl uiSession = ( UISessionImpl )ContextProvider.getUISession(); |
| 164 |
uiSession.shutdown(); |
171 |
uiSession.shutdown(); |
|
Lines 176-181
Link Here
|
| 176 |
writeError( response, HttpServletResponse.SC_FORBIDDEN, errorType ); |
183 |
writeError( response, HttpServletResponse.SC_FORBIDDEN, errorType ); |
| 177 |
} |
184 |
} |
| 178 |
|
185 |
|
|
|
186 |
private static void writeInvalidContentType( HttpServletResponse response ) throws IOException { |
| 187 |
String errorType = "invalid content type"; |
| 188 |
writeError( response, HttpServletResponse.SC_BAD_REQUEST, errorType ); |
| 189 |
} |
| 190 |
|
| 179 |
private static void writeError( HttpServletResponse response, |
191 |
private static void writeError( HttpServletResponse response, |
| 180 |
int statusCode, |
192 |
int statusCode, |
| 181 |
String errorType ) throws IOException |
193 |
String errorType ) throws IOException |