コード例 #1
0
  public static String postExecute(
      IRuntimeContext runtime,
      boolean debugMessages,
      boolean doWrapper,
      IOutputHandler outputHandler,
      Map<String, IParameterProvider> parameterProviders,
      HttpServletRequest request,
      HttpServletResponse response,
      List<?> messages,
      boolean deleteGeneratedFiles)
      throws Exception {
    StringBuffer buffer = new StringBuffer();

    boolean hasResponse = outputHandler.isResponseExpected();
    IContentItem responseContentItem =
        outputHandler.getOutputContentItem(
            IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null);

    boolean success =
        (runtime != null && runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS);
    boolean printSuccess = (runtime != null) && success && (!hasResponse || debugMessages);
    boolean printError = (runtime != null) && !success && !response.isCommitted();

    if (printSuccess || printError) {
      final String htmlMimeType = "text/html"; // $NON-NLS-1$
      responseContentItem.setMimeType(htmlMimeType);
      response.setContentType(htmlMimeType);
      IMessageFormatter formatter =
          PentahoSystem.get(IMessageFormatter.class, PentahoSessionHolder.getSession());

      if (printSuccess) {
        formatter.formatSuccessMessage(htmlMimeType, runtime, buffer, debugMessages, doWrapper);
      } else {
        response.resetBuffer();
        formatter.formatFailureMessage(htmlMimeType, runtime, buffer, messages);
      }
    }
    // clear files which was generated during action execution
    // http://jira.pentaho.com/browse/BISERVER-12639
    IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, null);
    if (unifiedRepository != null) {
      for (IContentItem contentItem : runtime.getOutputContentItems()) {
        if (contentItem != null) {
          try {
            contentItem.closeOutputStream();
            if (deleteGeneratedFiles) {
              deleteContentItem(contentItem, unifiedRepository);
            }
          } catch (Exception e) {
            logger.warn(
                Messages.getInstance()
                    .getString("XactionUtil.CANNOT_REMOVE_OUTPUT_FILE", contentItem.getPath()),
                e);
          }
        }
      }
    }
    return buffer.toString();
  }
コード例 #2
0
  public static Document createSoapResponseDocument(
      IRuntimeContext context,
      IOutputHandler outputHandler,
      OutputStream contentStream,
      List messages) {
    Document document = createSoapDocument();
    if ((context == null) || (context.getStatus() != IRuntimeContext.RUNTIME_STATUS_SUCCESS)) {
      document
          .getRootElement()
          .element("SOAP-ENV:Body")
          .add(createSoapFaultElement(messages)); // $NON-NLS-1$
    } else {
      Element activityResponse = createActivityResponseElement();
      document.getRootElement().element("SOAP-ENV:Body").add(activityResponse); // $NON-NLS-1$

      IContentItem contentItem = outputHandler.getFeedbackContentItem();

      // hmm do we need this to be ordered?
      Set outputNames = context.getOutputNames();

      Iterator outputNameIterator = outputNames.iterator();
      while (outputNameIterator.hasNext()) {
        String outputName = (String) outputNameIterator.next();
        contentItem =
            outputHandler.getOutputContentItem(
                IOutputHandler.RESPONSE,
                IOutputHandler.CONTENT,
                context.getInstanceId(),
                "text/xml"); //$NON-NLS-1$
        if ((outputNames.size() == 1) && (contentItem != null)) {
          String mimeType = contentItem.getMimeType();
          if ((mimeType != null) && mimeType.startsWith("text/")) { // $NON-NLS-1$
            if (mimeType.equals("text/xml")) { // $NON-NLS-1$
              activityResponse.addElement(outputName).setText(contentStream.toString());
            } else if (mimeType.startsWith("text/")) { // $NON-NLS-1$
              activityResponse.addElement(outputName).addCDATA(contentStream.toString());
            }
          } else {
            Object value = context.getOutputParameter(outputName).getValue();
            if (value == null) {
              value = ""; // $NON-NLS-1$
            }
            activityResponse.add(createSoapElement(outputName, value));
          }
        } else {
          Object value = context.getOutputParameter(outputName).getValue();
          if (value == null) {
            value = ""; // $NON-NLS-1$
          }
          activityResponse.add(createSoapElement(outputName, value));
        }
      }
    }
    return document;
  }
コード例 #3
0
  public static String postExecute(
      IRuntimeContext runtime,
      boolean debugMessages,
      boolean doWrapper,
      IOutputHandler outputHandler,
      Map<String, IParameterProvider> parameterProviders,
      HttpServletRequest request,
      HttpServletResponse response,
      List<?> messages)
      throws Exception {
    StringBuffer buffer = new StringBuffer();

    boolean hasResponse = outputHandler.isResponseExpected();
    IContentItem responseContentItem =
        outputHandler.getOutputContentItem(
            IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null);

    boolean success =
        (runtime != null && runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS);
    boolean printSuccess = (runtime != null) && success && (!hasResponse || debugMessages);
    boolean printError = (runtime != null) && !success && !response.isCommitted();

    if (printSuccess || printError) {
      final String htmlMimeType = "text/html"; // $NON-NLS-1$
      responseContentItem.setMimeType(htmlMimeType);
      response.setContentType(htmlMimeType);
      IMessageFormatter formatter =
          PentahoSystem.get(IMessageFormatter.class, PentahoSessionHolder.getSession());

      if (printSuccess) {
        formatter.formatSuccessMessage(htmlMimeType, runtime, buffer, debugMessages, doWrapper);
      } else {
        response.resetBuffer();
        formatter.formatFailureMessage(htmlMimeType, runtime, buffer, messages);
      }
    }
    return buffer.toString();
  }