Search in sources :

Example 16 with SimpleOutputHandler

use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.

the class WsdlPageTest method setUp.

@Before
public void setUp() {
    beforeTestCfg = AxisWebServiceManager.currentAxisConfiguration;
    beforeTestCtx = AxisWebServiceManager.currentAxisConfigContext;
    AxisConfiguration axisCfg = new AxisConfiguration();
    AxisWebServiceManager.currentAxisConfiguration = axisCfg;
    AxisWebServiceManager.currentAxisConfigContext = new ConfigurationContext(axisCfg);
    out = new ByteArrayOutputStream();
    IOutputHandler outputHandler = new SimpleOutputHandler(out, false);
    outputHandler.setMimeTypeListener(new MimeTypeListener());
    StandaloneSession session = new StandaloneSession("test");
    StubServiceSetup serviceSetup = new StubServiceSetup();
    serviceSetup.setSession(session);
    contentGenerator = new AxisServiceWsdlGenerator();
    contentGenerator.setOutputHandler(outputHandler);
    contentGenerator.setMessagesList(new ArrayList<String>());
    contentGenerator.setSession(session);
    contentGenerator.setUrlFactory(new SimpleUrlFactory(BASE_URL + "?"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisServiceWsdlGenerator(org.pentaho.platform.plugin.services.webservices.content.AxisServiceWsdlGenerator) IOutputHandler(org.pentaho.platform.api.engine.IOutputHandler) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) Before(org.junit.Before)

Example 17 with SimpleOutputHandler

use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.

the class ActionComponent method getContentAsStream.

protected ByteArrayOutputStream getContentAsStream(final String mimeType) {
    IPentahoSession userSession = getSession();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    outputHandler.setOutputPreference(outputPreference);
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, getSession());
    solutionEngine.setLoggingLevel(getLoggingLevel());
    solutionEngine.init(userSession);
    IRuntimeContext context = null;
    try {
        String actionSeqPath = ActionInfo.buildSolutionPath(solutionName, actionPath, actionName);
        context = solutionEngine.execute(actionSeqPath, Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_TEST"), false, true, instanceId, false, getParameterProviders(), outputHandler, null, urlFactory, // $NON-NLS-1$
        getMessages());
    } finally {
        if (context != null) {
            context.dispose();
        }
    }
    return outputStream;
}
Also used : ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext)

Example 18 with SimpleOutputHandler

use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.

the class ActionFilterDefinition method getResultSet.

/**
 * If the <data-output> element is present in the xml file, its text specifies the name of the output parameter
 * in the runtime context containing the result set.
 *
 * However, the <data-output> element is not required. If this element is not in the xml file, then the first
 * parameter in the runtime context's output of type "resultset" contains the result set.
 */
@Override
protected IPentahoResultSet getResultSet(final Map parameterProviders) {
    // create an instance of the solution engine to execute the specified
    // action
    // TODO we need to ensure that this data is cached (not live) so that we
    // can validate selections
    // $NON-NLS-1$
    String solution = XmlDom4JHelper.getNodeText("data-solution", node);
    // $NON-NLS-1$
    String actionPath = XmlDom4JHelper.getNodeText("data-path", node);
    // $NON-NLS-1$
    String actionName = XmlDom4JHelper.getNodeText("data-action", node);
    // $NON-NLS-1$
    String listSource = XmlDom4JHelper.getNodeText("data-output", node);
    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setLoggingLevel(ILogger.DEBUG);
    solutionEngine.init(session);
    OutputStream outputStream = null;
    SimpleOutputHandler outputHandler = null;
    outputHandler = new SimpleOutputHandler(outputStream, false);
    ArrayList messages = new ArrayList();
    String processId = this.getClass().getName();
    String instanceId = null;
    IRuntimeContext context = null;
    try {
        String actionSeqPath = ActionInfo.buildSolutionPath(solution, actionPath, actionName);
        context = solutionEngine.execute(actionSeqPath, processId, false, true, instanceId, false, parameterProviders, outputHandler, null, null, messages);
        if (listSource != null) {
            if (context.getOutputNames().contains(listSource)) {
                IActionParameter output = context.getOutputParameter(listSource);
                IPentahoResultSet results = output.getValueAsResultSet();
                if (results != null) {
                    results = results.memoryCopy();
                }
                return results;
            } else {
                // this is an error
                return null;
            }
        } else {
            // return the first list that we find...
            Iterator it = context.getOutputNames().iterator();
            while (it.hasNext()) {
                IActionParameter output = (IActionParameter) it.next();
                if (output.getType().equalsIgnoreCase(IActionParameter.TYPE_RESULT_SET)) {
                    IPentahoResultSet results = output.getValueAsResultSet();
                    if (results != null) {
                        results = results.memoryCopy();
                    }
                    return results;
                }
            }
        }
        return null;
    } finally {
        if (context != null) {
            context.dispose();
        }
    }
}
Also used : IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) IRuntimeContext(org.pentaho.platform.api.engine.IRuntimeContext) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 19 with SimpleOutputHandler

use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.

the class SolutionEngineAgent method execute.

public int execute() {
    PentahoSystem.systemEntryPoint();
    try {
        // create a generic session object
        StandaloneSession session = new StandaloneSession(userId);
        solutionEngine = PentahoSystem.get(SolutionEngine.class, session);
        solutionEngine.init(session);
        SimpleParameterProvider parameterProvider = new SimpleParameterProvider(parameters);
        HashMap<String, IParameterProvider> parameterProviderMap = new HashMap<String, IParameterProvider>();
        parameterProviderMap.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
        IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
        // $NON-NLS-1$
        IPentahoUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath());
        String processName = description;
        boolean persisted = false;
        List messages = new ArrayList();
        outputStream = new ByteArrayOutputStream(0);
        SimpleOutputHandler outputHandler = null;
        if (outputStream != null) {
            outputHandler = new SimpleOutputHandler(outputStream, false);
            outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_DEFAULT);
        }
        solutionEngine.execute(actionSequence, processName, false, true, null, persisted, parameterProviderMap, outputHandler, null, urlFactory, messages);
    } finally {
        PentahoSystem.systemExitPoint();
    }
    return solutionEngine.getStatus();
}
Also used : IPentahoUrlFactory(org.pentaho.platform.api.engine.IPentahoUrlFactory) StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ISolutionEngine(org.pentaho.platform.api.engine.ISolutionEngine) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) ArrayList(java.util.ArrayList) List(java.util.List) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Example 20 with SimpleOutputHandler

use of org.pentaho.platform.engine.core.output.SimpleOutputHandler in project pentaho-platform by pentaho.

the class SolutionHelper method doActionInternal.

private static IRuntimeContext doActionInternal(final String actionPath, final String processId, final IParameterProvider parameterProvider, final OutputStream outputStream, final IPentahoSession userSession, final ArrayList messages, final ILogger logger) {
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
    BaseRequestHandler requestHandler = new BaseRequestHandler(userSession, null, outputHandler, parameterProvider, null);
    requestHandler.setProcessId(processId);
    requestHandler.setActionPath(actionPath);
    return requestHandler.handleActionRequest(0, 0);
}
Also used : SimpleOutputHandler(org.pentaho.platform.engine.core.output.SimpleOutputHandler) BaseRequestHandler(org.pentaho.platform.engine.services.BaseRequestHandler)

Aggregations

SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)43 OutputStream (java.io.OutputStream)25 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)24 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)22 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 ByteArrayOutputStream (java.io.ByteArrayOutputStream)17 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)17 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)15 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)12 IOException (java.io.IOException)8 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)8 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)6 IContentItem (org.pentaho.platform.api.repository.IContentItem)6 BaseRequestHandler (org.pentaho.platform.engine.services.BaseRequestHandler)6 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)5 Iterator (java.util.Iterator)4 List (java.util.List)4 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)4