01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: *
13: * @created Jun 18, 2005
14: * @author James Dixon
15: *
16: */
17:
18: package org.pentaho.ui.servlet;
19:
20: import java.io.IOException;
21: import java.io.OutputStream;
22: import java.util.Set;
23:
24: import javax.servlet.http.HttpServletRequest;
25:
26: import org.pentaho.core.repository.IContentItem;
27: import org.pentaho.core.services.BaseRequestHandler;
28: import org.pentaho.core.session.IPentahoSession;
29: import org.pentaho.core.solution.HttpRequestParameterProvider;
30: import org.pentaho.core.solution.HttpSessionParameterProvider;
31: import org.pentaho.core.solution.IOutputHandler;
32: import org.pentaho.core.solution.IParameterProvider;
33: import org.pentaho.core.ui.IPentahoUrlFactory;
34: import org.pentaho.ui.BaseUIComponent;
35:
36: public class HttpServletRequestHandler extends BaseRequestHandler {
37:
38: private HttpServletRequest request;
39:
40: public HttpServletRequestHandler(IPentahoSession session,
41: String instanceId, HttpServletRequest request,
42: IOutputHandler outputHandler, IPentahoUrlFactory urlFactory) {
43: super (session, instanceId, outputHandler, null, urlFactory);
44: HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider(
45: session);
46: setParameterProvider(
47: HttpSessionParameterProvider.SCOPE_SESSION,
48: sessionParameters);
49: setRequest(request);
50: }
51:
52: public void handleUIRequest(BaseUIComponent component,
53: String contentType) throws IOException {
54: IContentItem contentItem = getOutputHandler()
55: .getOutputContentItem(IOutputHandler.RESPONSE,
56: IOutputHandler.CONTENT, getSolutionName(),
57: getInstanceId(), null);
58: OutputStream outputStream = contentItem.getOutputStream(this
59: .getActionName());
60: component.handleRequest(outputStream, this , contentType,
61: getParameterProviders());
62:
63: }
64:
65: public void setRequest(HttpServletRequest request) {
66: this .request = request;
67: IParameterProvider requestParameters = new HttpRequestParameterProvider(
68: request);
69: setParameterProvider(
70: HttpRequestParameterProvider.SCOPE_REQUEST,
71: requestParameters);
72:
73: }
74:
75: public String getStringParameter(String name) {
76: return request.getParameter(name);
77: }
78:
79: public Set getParameterNames() {
80: return request.getParameterMap().keySet();
81: }
82:
83: }
|