Search in sources :

Example 71 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class GeneratorStreamingOutput method createPathParamProvider.

protected IParameterProvider createPathParamProvider() throws IOException {
    SimpleParameterProvider pathParams = null;
    pathParams = new SimpleParameterProvider();
    // $NON-NLS-1$
    pathParams.setParameter("query", httpServletRequest.getQueryString());
    List<String> mediaTypes = new ArrayList<String>(acceptableMediaTypes.size());
    for (MediaType type : acceptableMediaTypes) {
        mediaTypes.add(type.toString());
    }
    // $NON-NLS-1$
    pathParams.setParameter("acceptableMediaTypes", mediaTypes);
    if (mediaTypes.size() > 0) {
        // $NON-NLS-1$
        pathParams.setParameter("contentType", acceptableMediaTypes.get(0));
    }
    // $NON-NLS-1$
    pathParams.setParameter("inputstream", httpServletRequest.getInputStream());
    // $NON-NLS-1$
    pathParams.setParameter("httpresponse", httpServletResponse);
    // $NON-NLS-1$
    pathParams.setParameter("httprequest", httpServletRequest);
    // $NON-NLS-1$
    pathParams.setParameter("remoteaddr", httpServletRequest.getRemoteAddr());
    if (file != null) {
        // $NON-NLS-1$
        pathParams.setParameter("path", URLEncoder.encode(file.getPath(), "UTF-8"));
        // $NON-NLS-1$
        pathParams.setParameter("file", file);
    }
    if (command != null) {
        // path beyond that which matched the GeneratorResource
        // $NON-NLS-1$
        pathParams.setParameter("cmd", command);
    }
    return pathParams;
}
Also used : ArrayList(java.util.ArrayList) MediaType(javax.ws.rs.core.MediaType) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 72 with SimpleParameterProvider

use of org.pentaho.platform.engine.core.solution.SimpleParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceContentGenerator method getRequestParameters.

@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
    if (this.requestParameters != null) {
        return this.requestParameters;
    }
    if (this.parameterProviders == null) {
        return new SimpleParameterProvider();
    }
    // $NON-NLS-1$
    IParameterProvider requestParams = this.parameterProviders.get("request");
    SimpleParameterSetter parameters = new SimpleParameterSetter();
    Iterator requestParamIterator = requestParams.getParameterNames();
    while (requestParamIterator.hasNext()) {
        String param = (String) requestParamIterator.next();
        parameters.setParameter(param, requestParams.getParameter(param));
    }
    this.requestParameters = parameters;
    return parameters;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) SimpleParameterSetter(org.pentaho.platform.engine.services.solution.SimpleParameterSetter) Iterator(java.util.Iterator) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)72 HashMap (java.util.HashMap)32 ArrayList (java.util.ArrayList)23 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)23 OutputStream (java.io.OutputStream)21 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)21 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)21 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)21 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)16 Test (org.junit.Test)13 IOException (java.io.IOException)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 Map (java.util.Map)5 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)5 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)5 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)5 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)5 Iterator (java.util.Iterator)4