use of org.pentaho.actionsequence.dom.actions.SubActionAction in project pentaho-platform by pentaho.
the class SubActionComponent method validateAction.
@Override
protected boolean validateAction() {
boolean value = false;
SubActionAction subAction = null;
if (getActionDefinition() instanceof SubActionAction) {
subAction = (SubActionAction) getActionDefinition();
if ((subAction.getAction() != ActionInputConstant.NULL_INPUT) && (subAction.getPath() != ActionInputConstant.NULL_INPUT) && (subAction.getSolution() != ActionInputConstant.NULL_INPUT)) {
value = true;
} else if (subAction.getPath() != ActionInputConstant.NULL_INPUT) {
// for backwards compatibility we will retain action/path/solution
// however, in 5.0 and beyond we only need the path element, eg /home/user/folder/file.xaction
value = true;
}
} else {
error(Messages.getInstance().getErrorString("ComponentBase.ERROR_0001_UNKNOWN_ACTION_TYPE", // $NON-NLS-1$
getActionDefinition().getElement().asXML()));
}
return value;
}
use of org.pentaho.actionsequence.dom.actions.SubActionAction in project pentaho-platform by pentaho.
the class SubActionComponent method executeAction.
@SuppressWarnings("deprecation")
@Override
protected boolean executeAction() throws Throwable {
SubActionAction subAction = (SubActionAction) getActionDefinition();
List<Object> ignoreParameters = new ArrayList<Object>();
String actionPath = buildActionPath(subAction.getSolution().getStringValue(), subAction.getPath().getStringValue(), subAction.getAction().getStringValue());
// see if we are supposed to proxy the session
IPentahoSession session = getSession();
if (subAction.getSessionProxy() != ActionInputConstant.NULL_INPUT) {
String sessionName = subAction.getSessionProxy().getStringValue();
// TODO support user-by-user locales
PentahoSessionParameterProvider params = new PentahoSessionParameterProvider(session);
session = new UserSession(sessionName, LocaleHelper.getLocale(), params);
}
// create a parameter provider
HashMap<String, Object> parameters = new HashMap<String, Object>();
Iterator<?> iterator = getInputNames().iterator();
while (iterator.hasNext()) {
String inputName = (String) iterator.next();
if (!StandardSettings.SOLUTION.equals(inputName) && !StandardSettings.PATH.equals(inputName) && !StandardSettings.ACTION.equals(inputName)) {
Object value = getInputValue(inputName);
ignoreParameters.add(value);
parameters.put(inputName, value);
}
}
parameters.put(StandardSettings.ACTION_URL_COMPONENT, getInputStringValue(StandardSettings.ACTION_URL_COMPONENT));
// get the ouptut stream
// TODO verify this with MB and JD
// getDefaultOutputStream();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ISolutionEngine solutionEngine = null;
try {
solutionEngine = SolutionHelper.execute(getProcessId(), session, actionPath, parameters, outputStream, null, true, false);
if (outputStream.size() > 0) {
getDefaultOutputStream(null).write(outputStream.toByteArray());
}
int status = solutionEngine.getStatus();
if (status == IRuntimeContext.RUNTIME_STATUS_SUCCESS) {
// now pass any outputs back
Iterator<?> it = this.getOutputNames().iterator();
while (it.hasNext()) {
String outputName = (String) it.next();
IActionParameter param = solutionEngine.getExecutionContext().getOutputParameter(outputName);
if (param != null) {
setOutputValue(outputName, param.getValue());
ignoreParameters.add(param.getValue());
}
}
return true;
} else {
return false;
}
} finally {
if (solutionEngine != null) {
solutionEngine.getExecutionContext().dispose(ignoreParameters);
}
}
}
Aggregations