Search in sources :

Example 21 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterContentGenerator method createContent.

@Override
public void createContent(OutputStream outputStream) throws Exception {
    IParameterProvider requestParams = getRequestParameters();
    IParameterProvider pathParams = getPathParameters();
    if ((requestParams != null) && (requestParams.getStringParameter("path", null) != null)) {
        path = URLDecoder.decode(requestParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    } else if ((pathParams != null) && (pathParams.getStringParameter("path", null) != null)) {
        // $NON-NLS-1$
        path = URLDecoder.decode(pathParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    }
    if (path != null && path.length() > 0) {
        IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, null);
        RepositoryFile file = unifiedRepository.getFile(path);
        String buffer = XactionUtil.doParameter(file, requestParams, PentahoSessionHolder.getSession());
        outputStream.write(buffer.toString().getBytes(LocaleHelper.getSystemEncoding()));
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 22 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterUiContentGenerator method createContent.

@Override
public void createContent(OutputStream outputStream) throws Exception {
    IParameterProvider requestParams = getRequestParameters();
    IParameterProvider pathParams = getPathParameters();
    if ((requestParams != null) && (requestParams.getStringParameter("path", null) != null)) {
        path = URLDecoder.decode(requestParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    } else if ((pathParams != null) && (pathParams.getStringParameter("path", null) != null)) {
        // $NON-NLS-1$
        path = URLDecoder.decode(pathParams.getStringParameter("path", ""), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "UTF-8");
    }
    if (path != null && path.length() > 0) {
        IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, null);
        RepositoryFile file = unifiedRepository.getFile(path);
        // $NON-NLS-1$
        HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter("httprequest");
        // $NON-NLS-1$
        HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter("httpresponse");
        String buffer = XactionUtil.executeScheduleUi(file, httpRequest, httpResponse, PentahoSessionHolder.getSession(), outputHandler.getMimeTypeListener());
        outputStream.write(buffer.toString().getBytes(LocaleHelper.getSystemEncoding()));
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 23 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterUiContentGenerator method getRequestParameters.

@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
    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)

Example 24 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class WsdlPageTest method testBadServiceName.

@Test
public void testBadServiceName() throws Exception {
    // $NON-NLS-1$
    assertNotNull("Logger is null", contentGenerator.getLogger());
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    parameterProviders.put(IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider());
    SimpleParameterProvider pathParams = new SimpleParameterProvider();
    // $NON-NLS-1$//$NON-NLS-2$
    pathParams.setParameter("path", "/bogus");
    // $NON-NLS-1$
    parameterProviders.put("path", pathParams);
    contentGenerator.setParameterProviders(parameterProviders);
    contentGenerator.createContent();
    String content = new String(out.toByteArray());
    assertTrue(content, content.contains(Messages.getInstance().getErrorString("WebServiceContentGenerator.ERROR_0006_SERVICE_IS_INVALID", // $NON-NLS-1$ //$NON-NLS-2$
    "bogus")));
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Example 25 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class RuntimeContextTest method makeParameterProviders.

private Map<String, IParameterProvider> makeParameterProviders(final IPentahoSession session) {
    final Map<String, IParameterProvider> res = new HashMap<>();
    res.put("jvm", new JVMParameterProvider());
    res.put(SecurityParameterProvider.SCOPE_SECURITY, new SecurityParameterProvider(session));
    return res;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) Matchers.anyString(org.mockito.Matchers.anyString) SecurityParameterProvider(org.pentaho.platform.engine.security.SecurityParameterProvider)

Aggregations

IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)57 HashMap (java.util.HashMap)27 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 ArrayList (java.util.ArrayList)14 List (java.util.List)11 Test (org.junit.Test)11 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 IOException (java.io.IOException)9 Iterator (java.util.Iterator)8 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)8 HttpRequestParameterProvider (org.pentaho.platform.web.http.request.HttpRequestParameterProvider)8 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)6 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)6 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)6 SimpleParameterSetter (org.pentaho.platform.engine.services.solution.SimpleParameterSetter)6 OutputStream (java.io.OutputStream)5