Search in sources :

Example 1 with IParameterProvider

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

the class PentahoSessionStartupAuthenticationSuccessListener method onApplicationEvent.

// ~ Methods
// =========================================================================================================
public void onApplicationEvent(final ApplicationEvent event) {
    if (event instanceof InteractiveAuthenticationSuccessEvent) {
        // $NON-NLS-1$
        logger.debug("received InteractiveAuthenticationSuccessEvent");
        // $NON-NLS-1$
        logger.debug("calling PentahoSystem.sessionStartup");
        try {
            IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
            Assert.notNull(pentahoSession, "PentahoSessionHolder doesn't have a session");
            IParameterProvider sessionParameters = new PentahoSessionParameterProvider(pentahoSession);
            PentahoSystem.sessionStartup(pentahoSession, sessionParameters);
        } catch (Exception e) {
            logger.error(e.getLocalizedMessage(), e);
        }
    }
}
Also used : InteractiveAuthenticationSuccessEvent(org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) PentahoSessionParameterProvider(org.pentaho.platform.engine.core.solution.PentahoSessionParameterProvider) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession)

Example 2 with IParameterProvider

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

the class AxisServiceExecutorTest method testRunPost.

@Test
public void testRunPost() throws Exception {
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    SimpleParameterProvider pathParams = new SimpleParameterProvider();
    pathParams.setParameter("path", "/StubService");
    pathParams.setParameter("remoteaddr", "http:test");
    parameterProviders.put("path", pathParams);
    contentGenerator.setParameterProviders(parameterProviders);
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("POST");
    request.setRequestURI("/pentaho/content/ws-run/StubService");
    request.setRequestURL("http://localhost:8080/pentaho/content/ws-run/StubService");
    request.setRemoteAddr(REMOTE_ADDRESS);
    request.setContentType("application/soap+xml; charset=UTF-8; action=\"urn:getString\"");
    String xml = "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://www.w3" + ".org/2003/05/soap-envelope\"><soapenv:Body><ns2:getString xmlns:ns2=\"http://webservice.pentaho" + ".com\"></ns2:getString></soapenv:Body></soapenv:Envelope>";
    request.setBodyContent(xml);
    pathParams.setParameter("httprequest", request);
    pathParams.setParameter("httpresponse", response);
    try {
        StubTransportSender.transportOutStr = null;
        StubService.getStringCalled = false;
        contentGenerator.createContent();
        assertTrue(StubService.getStringCalled);
        String content = StubTransportSender.transportOutStr;
        assertEquals("result are wrong", "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://www.w3" + ".org/2003/05/soap-envelope\"><soapenv:Body><ns:getStringResponse xmlns:ns=\"" + "http://webservices.services" + ".plugin.platform.test.pentaho.org\"><return>test " + "result</return></ns:getStringResponse></soapenv:Body></soapenv:Envelope>", content);
    } catch (Exception e) {
        assertTrue("Exception occurred", false);
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) MockHttpServletRequest(com.mockrunner.mock.web.MockHttpServletRequest) MockHttpServletResponse(com.mockrunner.mock.web.MockHttpServletResponse) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Example 3 with IParameterProvider

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

the class AxisServiceExecutorTest method testRunGet.

@Test
public void testRunGet() throws Exception {
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    SimpleParameterProvider pathParams = new SimpleParameterProvider();
    pathParams.setParameter("path", "/StubService/getString");
    pathParams.setParameter("remoteaddr", "http:test");
    parameterProviders.put("path", pathParams);
    contentGenerator.setParameterProviders(parameterProviders);
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("GET");
    request.setRequestURI("/pentaho/content/ws-run/StubService/getString");
    request.setRequestURL("http://localhost:8080/pentaho/content/ws-run/StubService/getString");
    request.setRemoteAddr(REMOTE_ADDRESS);
    pathParams.setParameter("httprequest", request);
    pathParams.setParameter("httpresponse", response);
    try {
        StubTransportSender.transportOutStr = null;
        StubService.getStringCalled = false;
        contentGenerator.createContent();
        assertTrue(StubService.getStringCalled);
        String content = StubTransportSender.transportOutStr;
        assertEquals("result are wrong", "<ns:getStringResponse xmlns:ns=\"http://webservices.services.plugin.platform.test.pentaho.org\"><return>test" + " result</return></ns:getStringResponse>", content);
    } catch (Exception e) {
        assertTrue("Exception occurred", false);
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) MockHttpServletRequest(com.mockrunner.mock.web.MockHttpServletRequest) MockHttpServletResponse(com.mockrunner.mock.web.MockHttpServletResponse) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Example 4 with IParameterProvider

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

the class AxisServiceExecutorTest method testRunGetThrowError.

@Test
public void testRunGetThrowError() throws Exception {
    Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
    SimpleParameterProvider pathParams = new SimpleParameterProvider();
    pathParams.setParameter("path", "/StubService/throwsError1");
    parameterProviders.put("path", pathParams);
    contentGenerator.setParameterProviders(parameterProviders);
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    request.setMethod("GET");
    request.setRequestURI("/pentaho/content/ws-run/StubService/throwsError1");
    request.setRequestURL("http://localhost:8080/pentaho/content/ws-run/StubService/throwsError1");
    request.setRemoteAddr(REMOTE_ADDRESS);
    pathParams.setParameter("httprequest", request);
    pathParams.setParameter("httpresponse", response);
    try {
        StubService.throwsError1Called = false;
        StubTransportSender.transportOutStr = null;
        contentGenerator.createContent();
        assertTrue(StubService.throwsError1Called);
        String content = StubTransportSender.transportOutStr;
        assertNull("Content should be empty", content);
    } catch (Exception e) {
        assertTrue("Exception occurred", false);
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) MockHttpServletRequest(com.mockrunner.mock.web.MockHttpServletRequest) MockHttpServletResponse(com.mockrunner.mock.web.MockHttpServletResponse) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider) Test(org.junit.Test)

Example 5 with IParameterProvider

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

the class SolutionEngine method applyParameterMappers.

/**
 * FIXME: This is in dire need of fixing
 *
 * @param parameterProviderMap
 */
@SuppressWarnings({ "unchecked" })
protected void applyParameterMappers(final Map parameterProviderMap) {
    IParameterProvider request = (IParameterProvider) parameterProviderMap.get(IParameterProvider.SCOPE_REQUEST);
    if (request != null) {
        IParameterProvider chartRequest = new FlashChartRequestMapper(request);
        parameterProviderMap.remove(IParameterProvider.SCOPE_REQUEST);
        parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST, chartRequest);
    }
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider)

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