Search in sources :

Example 1 with ISolutionActionDefinition

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;
}
Also used : ActionSequenceException(org.pentaho.platform.api.engine.ActionSequenceException) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) ISolutionActionDefinition(org.pentaho.platform.api.engine.ISolutionActionDefinition) IConditionalExecution(org.pentaho.platform.api.engine.IConditionalExecution) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ActionExecutionException(org.pentaho.platform.api.engine.ActionExecutionException) ActionExecutionException(org.pentaho.platform.api.engine.ActionExecutionException) InvalidParameterException(org.pentaho.platform.api.engine.InvalidParameterException) ActionValidationException(org.pentaho.platform.api.engine.ActionValidationException) ActionSequenceException(org.pentaho.platform.api.engine.ActionSequenceException) ActionInitializationException(org.pentaho.platform.api.engine.ActionInitializationException) ActionSequencePromptException(org.pentaho.platform.api.engine.ActionSequencePromptException) FileNotFoundException(java.io.FileNotFoundException) XmlParseException(org.pentaho.platform.api.util.XmlParseException) UnresolvedParameterException(org.pentaho.platform.api.engine.UnresolvedParameterException) PluginBeanException(org.pentaho.platform.api.engine.PluginBeanException) IOException(java.io.IOException)

Example 2 with ISolutionActionDefinition

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);
    }
}
Also used : IActionSequence(org.pentaho.platform.api.engine.IActionSequence) ISolutionActionDefinition(org.pentaho.platform.api.engine.ISolutionActionDefinition) ActionValidationException(org.pentaho.platform.api.engine.ActionValidationException) IComponent(org.pentaho.platform.api.engine.IComponent) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ActionDefinition(org.pentaho.actionsequence.dom.actions.ActionDefinition) ISolutionActionDefinition(org.pentaho.platform.api.engine.ISolutionActionDefinition)

Example 3 with ISolutionActionDefinition

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;
    }
}
Also used : IActionSequence(org.pentaho.platform.api.engine.IActionSequence) ISolutionActionDefinition(org.pentaho.platform.api.engine.ISolutionActionDefinition) Node(org.dom4j.Node) List(java.util.List) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) Document(org.dom4j.Document) SolutionURIResolver(org.pentaho.platform.engine.services.SolutionURIResolver)

Aggregations

List (java.util.List)3 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)3 ISolutionActionDefinition (org.pentaho.platform.api.engine.ISolutionActionDefinition)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 ActionValidationException (org.pentaho.platform.api.engine.ActionValidationException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Document (org.dom4j.Document)1 Node (org.dom4j.Node)1 ActionDefinition (org.pentaho.actionsequence.dom.actions.ActionDefinition)1 ActionExecutionException (org.pentaho.platform.api.engine.ActionExecutionException)1 ActionInitializationException (org.pentaho.platform.api.engine.ActionInitializationException)1 ActionSequenceException (org.pentaho.platform.api.engine.ActionSequenceException)1 ActionSequencePromptException (org.pentaho.platform.api.engine.ActionSequencePromptException)1 IComponent (org.pentaho.platform.api.engine.IComponent)1 IConditionalExecution (org.pentaho.platform.api.engine.IConditionalExecution)1 InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)1 PluginBeanException (org.pentaho.platform.api.engine.PluginBeanException)1 UnresolvedParameterException (org.pentaho.platform.api.engine.UnresolvedParameterException)1