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 + "?"));
}
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;
}
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();
}
}
}
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();
}
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);
}
Aggregations