use of org.pentaho.platform.api.engine.ISolutionActionDefinition in project pentaho-platform by pentaho.
the class RuntimeContext method performActions.
private void performActions(final IActionSequence sequence, final IActionCompleteListener doneListener, final IExecutionListener execListener, final boolean async) throws ActionSequenceException {
IConditionalExecution conditional = sequence.getConditionalExecution();
if (conditional != null) {
try {
if (!conditional.shouldExecute(paramManager.getAllParameters(), RuntimeContext.logger)) {
// audit(MessageTypes.ACTION_SEQUENCE_EXECUTE_CONDITIONAL, MessageTypes.NOT_EXECUTED, "", 0); //$NON-NLS-1$ //$NON-NLS-2$
if (RuntimeContext.debug) {
// $NON-NLS-1$
this.debug(Messages.getInstance().getString("RuntimeContext.INFO_ACTION_NOT_EXECUTED"));
}
status = IRuntimeContext.RUNTIME_STATUS_SUCCESS;
return;
}
} catch (Exception ex) {
// $NON-NLS-1$
currentComponent = "";
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
throw new ActionExecutionException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0032_CONDITIONAL_EXECUTION_FAILED"), // $NON-NLS-1$
ex, session.getName(), instanceId, getActionSequence().getSequenceName(), null);
}
}
List defList = sequence.getActionDefinitionsAndSequences();
Object listItem;
for (Iterator actIt = defList.iterator(); actIt.hasNext(); ) {
listItem = actIt.next();
if (listItem instanceof IActionSequence) {
executeSequence((IActionSequence) listItem, doneListener, execListener, async);
} else if (listItem instanceof ISolutionActionDefinition) {
ISolutionActionDefinition actionDef = (ISolutionActionDefinition) listItem;
currentComponent = actionDef.getComponentName();
paramManager.setCurrentParameters(actionDef);
try {
executeAction(actionDef, parameterProviders, doneListener, execListener, async);
paramManager.addOutputParameters(actionDef);
} catch (ActionSequenceException ex) {
// $NON-NLS-1$
currentComponent = "";
status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
throw ex;
}
}
if (promptStatus == IRuntimeContext.PROMPT_NOW) {
break;
}
// $NON-NLS-1$
currentComponent = "";
}
status = IRuntimeContext.RUNTIME_STATUS_SUCCESS;
}
use of org.pentaho.platform.api.engine.ISolutionActionDefinition in project pentaho-platform by pentaho.
the class RuntimeContext method validateComponents.
private void validateComponents(final IActionSequence sequence, final IExecutionListener execListener) throws ActionValidationException {
List defList = sequence.getActionDefinitionsAndSequences();
Object listItem;
for (Iterator it = defList.iterator(); it.hasNext(); ) {
listItem = it.next();
if (listItem instanceof IActionSequence) {
validateComponents((IActionSequence) listItem, execListener);
} else if (listItem instanceof ISolutionActionDefinition) {
ISolutionActionDefinition actionDef = (ISolutionActionDefinition) listItem;
if (RuntimeContext.debug) {
// $NON-NLS-1$
debug(Messages.getInstance().getString("RuntimeContext.DEBUG_VALIDATING_COMPONENT", actionDef.getComponentName()));
}
IComponent component = null;
try {
component = resolveComponent(actionDef, instanceId, processId, session);
component.setLoggingLevel(loggingLevel);
// allow the ActionDefinition to cache the component
actionDef.setComponent(component);
paramManager.setCurrentParameters(actionDef);
/*
* We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
* contextual information, including the root cause. Allowing unchecked exceptions to pass through would
* prevent valuable feedback in the log or response.
*/
} catch (Throwable ex) {
ActionDefinition actionDefinition = new ActionDefinition((Element) actionDef.getNode(), null);
throw new ActionValidationException(Messages.getInstance().getErrorString("RuntimeContext.ERROR_0009_COULD_NOT_CREATE_COMPONENT", // $NON-NLS-1$
actionDef.getComponentName().trim()), // $NON-NLS-1$
ex, session.getName(), instanceId, getActionSequence().getSequenceName(), actionDefinition.getDescription(), actionDefinition.getComponentName());
}
int validateResult = IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK;
try {
validateResult = component.validate();
/*
* We need to catch checked and unchecked exceptions here so we can create an ActionSequeceException with
* contextual information, including the root cause. Allowing unchecked exceptions to pass through would
* prevent valuable feedback in the log or response.
*/
} catch (Throwable t) {
throw new ActionValidationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0035_ACTION_VALIDATION_FAILED"), // $NON-NLS-1$
t, session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition());
}
if (validateResult != IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK) {
throw new ActionValidationException(Messages.getInstance().getErrorString(// $NON-NLS-1$
"RuntimeContext.ERROR_0035_ACTION_VALIDATION_FAILED"), session.getName(), instanceId, getActionSequence().getSequenceName(), component.getActionDefinition());
}
paramManager.addOutputParameters(actionDef);
// $NON-NLS-1$
setCurrentComponent("");
setCurrentActionDef(null);
}
}
if (execListener != null) {
execListener.validated(this);
}
}
use of org.pentaho.platform.api.engine.ISolutionActionDefinition in project pentaho-platform by pentaho.
the class InputFormComponent method getXmlContent.
/*
* (non-Javadoc)
*
* @see org.pentaho.core.ui.component.BaseUIComponent#getXmlContent()
*/
@Override
public Document getXmlContent() {
ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(getSession());
IActionSequence actionSequence = actionHelper.getActionSequence(ActionInfo.buildSolutionPath(solution, path, actionName), getLoggingLevel(), RepositoryFilePermission.READ);
if (actionSequence == null) {
// TODO log this
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0004_ACTION_NOT_FOUND") + solution + path + actionName);
return null;
}
List actions = actionSequence.getActionDefinitionsAndSequences();
ISolutionActionDefinition action = (ISolutionActionDefinition) actions.get(0);
Node node = action.getComponentSection();
if (node == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0005_INBOX_DEFINITION_MISSING") + solution + path + actionName);
return null;
}
if (templateName == null) {
// see if the template is specified in the action document
// $NON-NLS-1$
Node templateNode = node.selectSingleNode("//template");
if (templateNode != null) {
templateName = templateNode.getText();
}
if (templateName == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0006_TEMPLATE_NOT_SPECIFIED"));
return null;
}
}
// $NON-NLS-1$
Node xFormNode = node.selectSingleNode("//xForm");
try {
String actionTitle = actionSequence.getTitle();
if (actionTitle != null) {
// $NON-NLS-1$
setXslProperty("title", actionTitle);
}
String description = actionSequence.getDescription();
if (description != null) {
// $NON-NLS-1$
setXslProperty("description", description);
}
String xFormHtml = XForm.transformSnippet(xFormNode, getSession(), new SolutionURIResolver());
if (xFormHtml == null) {
// $NON-NLS-1$
error(Messages.getInstance().getString("InputForm.ERROR_0007_INBOX_DEFINITION_INVALID") + solution + path + actionName);
return null;
}
Document document = DocumentHelper.parseText(xFormHtml);
// $NON-NLS-1$
Node xFormHtmlNode = document.selectSingleNode("//xForm");
// $NON-NLS-1$
setXslProperty("xForm", xFormHtmlNode.asXML());
if ((stylesheetName != null) && !"".equals(stylesheetName)) {
// $NON-NLS-1$
// $NON-NLS-1$
setXslProperty("css", stylesheetName);
}
// $NON-NLS-1$
setXsl("text/html", templateName);
return document;
} catch (Exception e) {
return null;
}
}
Aggregations