Search in sources :

Example 1 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper in project pentaho-platform by pentaho.

the class XactionUtil method doParameter.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static String doParameter(final RepositoryFile file, IParameterProvider parameterProvider, final IPentahoSession userSession) throws IOException {
    ActionSequenceJCRHelper helper = new ActionSequenceJCRHelper();
    final IActionSequence actionSequence = helper.getActionSequence(file.getPath(), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
    final Document document = DocumentHelper.createDocument();
    try {
        final Element parametersElement = document.addElement("parameters");
        // noinspection unchecked
        final Map<String, IActionParameter> params = actionSequence.getInputDefinitionsForParameterProvider(IParameterProvider.SCOPE_REQUEST);
        for (final Map.Entry<String, IActionParameter> entry : params.entrySet()) {
            final String paramName = entry.getKey();
            final IActionParameter paramDef = entry.getValue();
            final String value = paramDef.getStringValue();
            final Class type;
            // defined as constant (string)
            if (IActionParameter.TYPE_LIST.equalsIgnoreCase(paramDef.getType())) {
                type = String[].class;
            } else {
                type = String.class;
            }
            final String label = paramDef.getSelectionDisplayName();
            final String[] values;
            if (StringUtils.isEmpty(value)) {
                values = new String[0];
            } else {
                values = new String[] { value };
            }
            createParameterElement(parametersElement, paramName, type, label, "user", "parameters", values);
        }
        createParameterElement(parametersElement, "path", String.class, null, "system", "system", new String[] { file.getPath() });
        createParameterElement(parametersElement, "prompt", String.class, null, "system", "system", new String[] { "yes", "no" });
        createParameterElement(parametersElement, "instance-id", String.class, null, "system", "system", new String[] { parameterProvider.getStringParameter("instance-id", null) });
        // no close, as far as I know tomcat does not like it that much ..
        OutputFormat format = OutputFormat.createCompactFormat();
        format.setSuppressDeclaration(true);
        // $NON-NLS-1$
        format.setEncoding("utf-8");
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        XMLWriter writer = new XMLWriter(outputStream, format);
        writer.write(document);
        writer.flush();
        return outputStream.toString("utf-8");
    } catch (Exception e) {
        logger.warn(Messages.getInstance().getString("HttpWebService.ERROR_0003_UNEXPECTED"), e);
        return null;
    }
}
Also used : IActionSequence(org.pentaho.platform.api.engine.IActionSequence) Element(org.dom4j.Element) OutputFormat(org.dom4j.io.OutputFormat) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.dom4j.Document) XMLWriter(org.dom4j.io.XMLWriter) ServletException(javax.servlet.ServletException) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) IOException(java.io.IOException) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper 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)

Example 3 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper in project pentaho-platform by pentaho.

the class ChartHelper method doChart.

/**
 * doChart generates the images and html necessary to render various charts within a web page.
 *
 * @param actionPath
 *          full path including the name of the action sequence or resource
 * @param parameterProvider
 *          the collection of parameters to customize the chart
 * @param outputStream
 *          the output string buffer for the content
 * @param userSession
 *          the user session object
 * @param messages
 *          a collection to store error and logging messages
 * @param logger
 *          logging object
 *
 * @return true if successful
 */
@Deprecated
public static boolean doChart(final String actionPath, final IParameterProvider parameterProvider, final StringBuffer outputStream, final IPentahoSession userSession, final ArrayList messages, ILogger logger) {
    deprecateWarning();
    boolean result = true;
    String content = null;
    StringBuffer messageBuffer = new StringBuffer();
    if (logger == null) {
        // No logger? The usersession extends ILogger, use it for logging
        logger = userSession;
    }
    // Retrieve all parameters from parameter provider
    // $NON-NLS-1$
    String outerParams = parameterProvider.getStringParameter("outer-params", null);
    // $NON-NLS-1$
    String innerParam = parameterProvider.getStringParameter("inner-param", null);
    // $NON-NLS-1$
    String urlDrillTemplate = parameterProvider.getStringParameter("drill-url", null);
    // $NON-NLS-1$
    String imageUrl = parameterProvider.getStringParameter("image-url", null);
    // Very likely null; allow API users to continue to pass the dial value via parameters
    // $NON-NLS-1$
    String dialValue = parameterProvider.getStringParameter("value", null);
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    if (imageUrl == null) {
        // $NON-NLS-1$
        imageUrl = requestContext.getContextPath();
    }
    if (urlDrillTemplate == null) {
        // $NON-NLS-1$
        urlDrillTemplate = "";
    }
    // $NON-NLS-1$
    int width = (int) parameterProvider.getLongParameter("image-width", 150);
    // $NON-NLS-1$
    int height = (int) parameterProvider.getLongParameter("image-height", 150);
    SimpleUrlFactory urlFactory = new SimpleUrlFactory(urlDrillTemplate);
    // Determine the type of chart we are building; these values can come from the chart xml definition, or
    // from the parameter provider. Try the parameter provider first, for performance reasons.
    String chartTypeStr = parameterProvider.getStringParameter(ChartDefinition.TYPE_NODE_NAME, null);
    String datasetType = ChartDefinition.CATEGORY_DATASET_STR;
    if ((chartTypeStr == null) || (chartTypeStr.length() == 0)) {
        try {
            // attempt to get the chart type and possibly data type from the xml doc
            ActionSequenceJCRHelper jcrHelper = new ActionSequenceJCRHelper(userSession);
            Document chartDefinition = jcrHelper.getSolutionDocument(actionPath, RepositoryFilePermission.READ);
            // $NON-NLS-1$
            Node chartAttributes = chartDefinition.selectSingleNode("//" + AbstractChartComponent.CHART_NODE_NAME);
            chartTypeStr = chartAttributes.selectSingleNode(ChartDefinition.TYPE_NODE_NAME).getText();
            Node datasetTypeNode = chartAttributes.selectSingleNode(ChartDefinition.DATASET_TYPE_NODE_NAME);
            if (datasetTypeNode != null) {
                datasetType = datasetTypeNode.getText();
            }
        } catch (Exception e) {
            logger.error(Messages.getInstance().getErrorString("ChartHelper.ERROR_0001_IO_PROBLEM_GETTING_CHART_TYPE"), // $NON-NLS-1$
            e);
            PentahoSystem.get(IMessageFormatter.class, userSession).formatErrorMessage("text/html", Messages.getInstance().getString("ChartHelper.ERROR_0001_IO_PROBLEM_GETTING_CHART_TYPE"), messages, // $NON-NLS-1$ //$NON-NLS-2$
            messageBuffer);
            content = messageBuffer.toString();
            result = false;
        }
    }
    // Check again - do we have a chart type now? If not, bail out, we have no idea what to try to generate
    if ((chartTypeStr == null) || (chartTypeStr.length() == 0)) {
        // $NON-NLS-1$
        logger.error(Messages.getInstance().getString("ChartHelper.ERROR_0002_COULD_NOT_DETERMINE_CHART_TYPE"));
        PentahoSystem.get(IMessageFormatter.class, userSession).formatErrorMessage("text/html", Messages.getInstance().getString("ChartHelper.ERROR_0002_COULD_NOT_DETERMINE_CHART_TYPE"), messages, // $NON-NLS-1$ //$NON-NLS-2$
        messageBuffer);
        content = messageBuffer.toString();
        result = false;
    }
    if (!result) {
        outputStream.append(content);
        return result;
    }
    int chartType = JFreeChartEngine.getChartType(chartTypeStr);
    AbstractJFreeChartComponent chartComponent = null;
    try {
        // Some charts are determined by the dataset that is passed in; check these first...
        if (datasetType.equalsIgnoreCase(ChartDefinition.TIME_SERIES_COLLECTION_STR)) {
            chartComponent = new TimeSeriesCollectionChartComponent(chartType, actionPath, width, height, urlFactory, messages);
        } else if (datasetType.equalsIgnoreCase(ChartDefinition.XY_SERIES_COLLECTION_STR)) {
            chartComponent = new XYSeriesCollectionChartComponent(chartType, actionPath, width, height, urlFactory, messages);
        } else if (datasetType.equalsIgnoreCase(ChartDefinition.XYZ_SERIES_COLLECTION_STR)) {
            chartComponent = new XYZSeriesCollectionChartComponent(chartType, actionPath, width, height, urlFactory, messages);
        }
        // Didn't find a dataset, so try to create the component based on chart type.
        if (chartComponent == null) {
            switch(chartType) {
                case JFreeChartEngine.BAR_CHART_TYPE:
                case JFreeChartEngine.AREA_CHART_TYPE:
                case JFreeChartEngine.BAR_LINE_CHART_TYPE:
                case JFreeChartEngine.LINE_CHART_TYPE:
                case JFreeChartEngine.DIFFERENCE_CHART_TYPE:
                case JFreeChartEngine.DOT_CHART_TYPE:
                case JFreeChartEngine.STEP_AREA_CHART_TYPE:
                case JFreeChartEngine.STEP_CHART_TYPE:
                case JFreeChartEngine.PIE_GRID_CHART_TYPE:
                    chartComponent = new CategoryDatasetChartComponent(chartType, actionPath, width, height, urlFactory, messages);
                    break;
                case JFreeChartEngine.PIE_CHART_TYPE:
                    chartComponent = new PieDatasetChartComponent(chartType, actionPath, width, height, urlFactory, messages);
                    break;
                case JFreeChartEngine.DIAL_CHART_TYPE:
                    chartComponent = new DialChartComponent(chartType, actionPath, width, height, urlFactory, messages);
                    if (dialValue != null) {
                        Number numericDialValue = DataUtilities.toNumber(dialValue, LocaleHelper.getCurrencyFormat(), LocaleHelper.getNumberFormat());
                        ((DialChartComponent) chartComponent).setValue(numericDialValue.doubleValue());
                    }
                    break;
                case JFreeChartEngine.BUBBLE_CHART_TYPE:
                    chartComponent = new XYZSeriesCollectionChartComponent(chartType, actionPath, width, height, urlFactory, messages);
                    break;
                case JFreeChartEngine.UNDEFINED_CHART_TYPE:
                default:
                    // Unsupported chart type, bail out
                    logger.error(Messages.getInstance().getString("ChartHelper.ERROR_0003_INVALID_CHART_TYPE", chartTypeStr, // $NON-NLS-1$
                    Integer.toString(chartType)));
                    PentahoSystem.get(IMessageFormatter.class, userSession).formatErrorMessage("text/html", // $NON-NLS-1$ //$NON-NLS-2$
                    Messages.getInstance().getString(// $NON-NLS-1$ //$NON-NLS-2$
                    "ChartHelper.ERROR_0003_INVALID_CHART_TYPE", chartTypeStr, Integer.toString(chartType)), messages, messageBuffer);
                    content = messageBuffer.toString();
                    result = false;
            }
        }
        if (result && (chartComponent != null)) {
            try {
                chartComponent.setLoggingLevel(logger.getLoggingLevel());
                chartComponent.validate(userSession, null);
                chartComponent.setDataAction(actionPath);
                chartComponent.setUrlTemplate(urlDrillTemplate);
                // $NON-NLS-1$
                String seriesName = parameterProvider.getStringParameter("series-name", null);
                if (chartComponent instanceof CategoryDatasetChartComponent) {
                    ((CategoryDatasetChartComponent) chartComponent).setSeriesName(seriesName);
                }
                // WARNING!!! This is an atypical way to access data for the chart... these parameters and their
                // usage are undocumented, and only left in here to support older solutions that may be using them.
                // *************** START QUESTIONABLE CODE ********************************************************
                // $NON-NLS-1$
                String connectionName = parameterProvider.getStringParameter("connection", null);
                // $NON-NLS-1$
                String query = parameterProvider.getStringParameter("query", null);
                // $NON-NLS-1$
                String dataAction = parameterProvider.getStringParameter("data-process", null);
                IPentahoConnection connection = null;
                try {
                    chartComponent.setParamName(innerParam);
                    chartComponent.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
                    if ((connectionName != null) && (query != null)) {
                        // connection = new SQLConnection(connectionName, logger)
                        // TODO support non-SQL data sources. Much easier now using the factory
                        connection = PentahoConnectionFactory.getConnection(IPentahoConnection.SQL_DATASOURCE, connectionName, userSession, logger);
                        try {
                            query = TemplateUtil.applyTemplate(query, TemplateUtil.parametersToProperties(parameterProvider), null);
                            IPentahoResultSet results = connection.executeQuery(query);
                            chartComponent.setValues(results);
                        } finally {
                            boolean ignored = true;
                        }
                        chartComponent.setUrlTemplate(urlDrillTemplate);
                        if (outerParams != null) {
                            // $NON-NLS-1$
                            StringTokenizer tokenizer = new StringTokenizer(outerParams, ";");
                            while (tokenizer.hasMoreTokens()) {
                                chartComponent.addOuterParamName(tokenizer.nextToken());
                            }
                        }
                    } else if (dataAction != null) {
                        chartComponent.setDataAction(dataAction);
                    }
                    // ***************** END QUESTIONABLE CODE ********************************************************
                    // $NON-NLS-1$
                    content = chartComponent.getContent("text/html");
                } finally {
                    if (connection != null) {
                        connection.close();
                    }
                }
            } catch (Throwable e) {
                // $NON-NLS-1$
                logger.error(Messages.getInstance().getErrorString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), e);
            }
        }
        try {
            if (content == null) {
                PentahoSystem.get(IMessageFormatter.class, userSession).formatErrorMessage("text/html", Messages.getInstance().getErrorString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), messages, // $NON-NLS-1$ //$NON-NLS-2$
                messageBuffer);
                content = messageBuffer.toString();
                result = false;
            }
            outputStream.append(content);
        } catch (Exception e) {
            // $NON-NLS-1$
            logger.error(Messages.getInstance().getErrorString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), e);
        }
    } finally {
        if (chartComponent != null) {
            chartComponent.dispose();
        }
    }
    return result;
}
Also used : Node(org.dom4j.Node) Document(org.dom4j.Document) IPentahoConnection(org.pentaho.commons.connection.IPentahoConnection) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) StringTokenizer(java.util.StringTokenizer) IMessageFormatter(org.pentaho.platform.api.engine.IMessageFormatter) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper)

Example 4 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper in project pentaho-platform by pentaho.

the class SolutionEngineInteractivityService method doGet.

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
    PentahoSystem.systemEntryPoint();
    try {
        IPentahoSession userSession = getPentahoSession(request);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        // $NON-NLS-1$
        String solutionName = request.getParameter("solution");
        // $NON-NLS-1$
        String actionPath = request.getParameter("path");
        // $NON-NLS-1$
        String actionName = request.getParameter("action");
        IActionSequence actionSequence = new ActionSequenceJCRHelper().getActionSequence(ActionInfo.buildSolutionPath(solutionName, actionPath, actionName), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
        String fileName = null;
        if (actionSequence != null) {
            String title = actionSequence.getTitle();
            if ((title != null) && (title.length() > 0)) {
                fileName = title;
            } else {
                String sequenceName = actionSequence.getSequenceName();
                if ((sequenceName != null) && (sequenceName.length() > 0)) {
                    fileName = sequenceName;
                } else {
                    List actionDefinitionsList = actionSequence.getActionDefinitionsAndSequences();
                    int i = 0;
                    boolean done = false;
                    while ((actionDefinitionsList.size() > i) && !done) {
                        IActionDefinition actionDefinition = (IActionDefinition) actionDefinitionsList.get(i);
                        String componentName = actionDefinition.getComponentName();
                        if ((componentName != null) && (componentName.length() > 0)) {
                            fileName = componentName;
                            done = true;
                        } else {
                            i++;
                        }
                    }
                }
            }
        }
        IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
        HttpOutputHandler outputHandler = createOutputHandler(response, outputStream);
        outputHandler.setSession(userSession);
        IMimeTypeListener listener = new HttpMimeTypeListener(request, response);
        listener.setName(fileName);
        outputHandler.setMimeTypeListener(listener);
        SimpleUrlFactory urlFactory = new SimpleUrlFactory(requestContext.getContextPath() + // $NON-NLS-1$
        "SolutionEngineInteractivityService?");
        IParameterProvider requestParameters = new HttpRequestParameterProvider(request);
        setupOutputHandler(outputHandler, requestParameters);
        HttpServletRequestHandler requestHandler = getRequestHandler(request, response, userSession, requestParameters, outputStream, outputHandler, urlFactory);
        handleActionRequest(request, response, outputHandler, requestHandler, requestParameters, outputStream, null);
    } finally {
        PentahoSystem.systemExitPoint();
    }
}
Also used : IMimeTypeListener(org.pentaho.platform.api.engine.IMimeTypeListener) IActionSequence(org.pentaho.platform.api.engine.IActionSequence) IActionDefinition(org.pentaho.actionsequence.dom.IActionDefinition) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) HttpOutputHandler(org.pentaho.platform.web.http.HttpOutputHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HttpRequestParameterProvider(org.pentaho.platform.web.http.request.HttpRequestParameterProvider) List(java.util.List) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 5 with ActionSequenceJCRHelper

use of org.pentaho.platform.engine.services.ActionSequenceJCRHelper in project pentaho-platform by pentaho.

the class HttpWebService method doParameter.

private void doParameter(final String solutionName, final String actionPath, final String actionName, final IParameterProvider parameterProvider, final OutputStream outputStream, final IPentahoSession userSession, final HttpServletResponse response) throws IOException {
    final IActionSequence actionSequence = new ActionSequenceJCRHelper().getActionSequence(ActionInfo.buildSolutionPath(solutionName, actionPath, actionName), PentahoSystem.loggingLevel, RepositoryFilePermission.READ);
    if (actionSequence == null) {
        logger.debug(Messages.getInstance().getString("HttpWebService.ERROR_0002_NOTFOUND", solutionName, actionPath, actionName));
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
    }
    final Document document = DocumentHelper.createDocument();
    try {
        final Element parametersElement = document.addElement("parameters");
        // noinspection unchecked
        final Map<String, IActionParameter> params = actionSequence.getInputDefinitionsForParameterProvider(IParameterProvider.SCOPE_REQUEST);
        for (final Map.Entry<String, IActionParameter> entry : params.entrySet()) {
            final String paramName = entry.getKey();
            final IActionParameter paramDef = entry.getValue();
            final String value = paramDef.getStringValue();
            final Class type;
            // defined as constant (string)
            if (IActionParameter.TYPE_LIST.equalsIgnoreCase(paramDef.getType())) {
                type = String[].class;
            } else {
                type = String.class;
            }
            final String label = paramDef.getSelectionDisplayName();
            final String[] values;
            if (StringUtils.isEmpty(value)) {
                values = new String[0];
            } else {
                values = new String[] { value };
            }
            createParameterElement(parametersElement, paramName, type, label, "user", "parameters", values);
        }
        // built in parameters: solution, path, action, prompt, instance-id
        createParameterElement(parametersElement, "solution", String.class, null, "system", "system", new String[] { solutionName });
        createParameterElement(parametersElement, "path", String.class, null, "system", "system", new String[] { actionPath });
        createParameterElement(parametersElement, "action", String.class, null, "system", "system", new String[] { actionName });
        createParameterElement(parametersElement, "prompt", String.class, null, "system", "system", new String[] { "yes", "no" });
        createParameterElement(parametersElement, "instance-id", String.class, null, "system", "system", new String[] { parameterProvider.getStringParameter("instance-id", null) });
    } catch (Exception e) {
        logger.warn(Messages.getInstance().getString("HttpWebService.ERROR_0003_UNEXPECTED"), e);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        return;
    }
    // no close, as far as I know tomcat does not like it that much ..
    final XMLWriter writer = new XMLWriter(outputStream, OutputFormat.createPrettyPrint());
    writer.write(document);
    writer.flush();
}
Also used : IActionSequence(org.pentaho.platform.api.engine.IActionSequence) DefaultElement(org.dom4j.tree.DefaultElement) Element(org.dom4j.Element) Document(org.dom4j.Document) XMLWriter(org.dom4j.io.XMLWriter) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) XmlParseException(org.pentaho.platform.api.util.XmlParseException) ActionSequenceJCRHelper(org.pentaho.platform.engine.services.ActionSequenceJCRHelper) IActionParameter(org.pentaho.platform.api.engine.IActionParameter) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ActionSequenceJCRHelper (org.pentaho.platform.engine.services.ActionSequenceJCRHelper)7 IActionSequence (org.pentaho.platform.api.engine.IActionSequence)6 List (java.util.List)4 Document (org.dom4j.Document)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IActionDefinition (org.pentaho.actionsequence.dom.IActionDefinition)3 IMimeTypeListener (org.pentaho.platform.api.engine.IMimeTypeListener)3 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)3 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ServletException (javax.servlet.ServletException)2 Element (org.dom4j.Element)2 Node (org.dom4j.Node)2 XMLWriter (org.dom4j.io.XMLWriter)2 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)2 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)2 HttpOutputHandler (org.pentaho.platform.web.http.HttpOutputHandler)2