use of org.pentaho.platform.engine.services.solution.ActionSequenceCompatibilityFormatter in project pentaho-platform by pentaho.
the class ActionRunner method callImpl.
private ExecutionResult callImpl() throws Exception {
boolean executionStatus = true;
final Object locale = params.get(LocaleHelper.USER_LOCALE_PARAM);
if (locale instanceof Locale) {
LocaleHelper.setLocaleOverride((Locale) locale);
} else {
LocaleHelper.setLocaleOverride(new Locale((String) locale));
}
// sync job params to the action bean
ActionHarness actionHarness = new ActionHarness(actionBean);
boolean updateJob = false;
final Map<String, Object> actionParams = new HashMap<String, Object>();
actionParams.putAll(params);
if (streamProvider != null) {
actionParams.put("inputStream", streamProvider.getInputStream());
}
actionHarness.setValues(actionParams, new ActionSequenceCompatibilityFormatter());
if (actionBean instanceof IVarArgsAction) {
actionParams.remove("inputStream");
actionParams.remove("outputStream");
((IVarArgsAction) actionBean).setVarArgs(actionParams);
}
boolean waitForFileCreated = false;
OutputStream stream = null;
if (streamProvider != null) {
actionParams.remove("inputStream");
if (actionBean instanceof IStreamingAction) {
streamProvider.setStreamingAction((IStreamingAction) actionBean);
}
// BISERVER-9414 - validate that output path still exist
SchedulerOutputPathResolver resolver = new SchedulerOutputPathResolver(streamProvider.getOutputPath(), actionUser);
String outputPath = resolver.resolveOutputFilePath();
actionParams.put("useJcr", Boolean.TRUE);
actionParams.put("jcrOutputPath", outputPath.substring(0, outputPath.lastIndexOf("/")));
if (!outputPath.equals(streamProvider.getOutputPath())) {
// set fallback path
streamProvider.setOutputFilePath(outputPath);
// job needs to be deleted and recreated with the new output path
updateJob = true;
}
stream = streamProvider.getOutputStream();
if (stream instanceof ISourcesStreamEvents) {
((ISourcesStreamEvents) stream).addListener(new IStreamListener() {
public void fileCreated(final String filePath) {
synchronized (lock) {
outputFilePath = filePath;
lock.notifyAll();
}
}
});
waitForFileCreated = true;
}
actionParams.put("outputStream", stream);
// The lineage_id is only useful for the metadata and not needed at this level see PDI-10171
ActionUtil.removeKeyFromMap(actionParams, ActionUtil.QUARTZ_LINEAGE_ID);
actionHarness.setValues(actionParams);
}
actionBean.execute();
executionStatus = actionBean.isExecutionSuccessful();
if (stream != null) {
IOUtils.closeQuietly(stream);
}
if (waitForFileCreated) {
synchronized (lock) {
if (outputFilePath == null) {
lock.wait();
}
}
ActionUtil.sendEmail(actionParams, params, outputFilePath);
deleteEmptyFile();
}
if (actionBean instanceof IPostProcessingAction) {
closeContentOutputStreams((IPostProcessingAction) actionBean);
markContentAsGenerated((IPostProcessingAction) actionBean);
}
// Create the ExecutionResult to return the status and whether the update is required or not
ExecutionResult executionResult = new ExecutionResult(updateJob, executionStatus);
return executionResult;
}
Aggregations