コード例 #1
0
ファイル: RTFGenerator.java プロジェクト: harishgupta111/SOA
  /////// for testing
  public static void main(String[] args) {

    if (args.length != 4) {
      System.out.println("usage: java RTFGenerator dtabaseurl dbuser password xmlfile");
      return;
    }
    RTFGenerator rt = new RTFGenerator();
    try {
      DBInterface.initialize(args[0], args[1], args[2]);
    } catch (Exception exp) {
      String e = exp.toString();
      e = exp.getMessage();
      e = "";
    }
    try {
      rt.initialize("BS_ORDER", "RTF_GENERATOR");
    } catch (Exception exp) {
      exp.printStackTrace();
    }

    try {
      String xmlmessage = FileUtils.readFile(args[3]);

      rt.execute(null, xmlmessage);
    } catch (Exception exp) {
      exp.printStackTrace();
    }
  }
コード例 #2
0
ファイル: RTFGenerator.java プロジェクト: harishgupta111/SOA
  /**
   * This method reads RTF template file.
   *
   * @return String - string of rtf template.
   * @exception - ProcessingException - thrown if FrameworkException is reported from FileUtil class
   */
  private String getRTFTemplate() throws ProcessingException {
    String template = "";
    Debug.log(this, Debug.BENCHMARK, "RTFGenerator: Reading template file.");
    try {
      template = FileUtils.readFile(rtfTemplate);
    } catch (FrameworkException exp) {
      Debug.log(this, Debug.ALL_ERRORS, "ERROR: RTFGenerator: Template file cannot be located.");
      throw new ProcessingException(rtfTemplate + " file cannot be located");
    }

    return template;
  }
コード例 #3
0
ファイル: RTFGenerator.java プロジェクト: harishgupta111/SOA
  /**
   * This method is called from driver. It does all processing to generate RTF document.
   *
   * @param context - MessageProcessorContext.
   * @param type - input - this contains XML message that needs to e converted to RTF document.
   * @return NVPair[] - this array contains only one instance of NVPair. name - value of
   *     NEXT_PROCESSOR_NAME; value - generated RTF document.
   * @exception - MessageException, ProcessingException - messageException is thrown if parsing of
   *     XML fails ProcessingException is thrown for any other significant error.
   */
  public NVPair[] execute(MessageProcessorContext context, Object input)
      throws MessageException, ProcessingException {

    Debug.log(this, Debug.BENCHMARK, "RTFGenerator: Starting conversion of XML to RTF document");
    if (input == null) {
      return null;
    }

    String xmlMessage = Converter.getString(input);

    TokenDataSource tds = new XMLTokenDataSourceAdapter(xmlMessage);

    String template = getRTFTemplate();
    com.nightfire.framework.util.TokenReplacer tr =
        new com.nightfire.framework.util.TokenReplacer(template);
    tr.setTokenStartIndicator(startDelimiter);
    tr.setTokenEndIndicator(endDelimiter);
    tr.setAllDataOptional(true);
    String result = "";
    try {
      result = tr.generate(tds);
    } catch (FrameworkException exp) {
      throw new ProcessingException(
          "ERROR: RTFGenerator: Error in translating XML to RTF document");
    }

    Debug.log(this, Debug.BENCHMARK, "RTFGenerator: Done conversion of XML to RTF document");
    // Generate NVPair to return

    NVPair nvpair = new NVPair(nextProcessor, result);
    NVPair array[] = new NVPair[] {nvpair};

    // for testing only
    if (testing) {
      try {
        FileUtils.writeFile("e:\\OP.rtf", result);
      } catch (Exception exp) {
        exp.printStackTrace();
      }
    }

    return array;
  }
コード例 #4
0
  public static void main(String[] args) {
    Debug.enableAll();
    String HEADER =
        "<HEADER>"
            + "<REQUEST value=\"LSR_ORDER\"/>"
            + "<SUB_REQUEST value=\"loop\"/>"
            + "<SUPPLIER value=\"VZE\"/>"
            + "</HEADER>";
    RequestHandlerClient sr = null;

    try {
      String xml = FileUtils.readFile(args[0]);
      MessageProcessorContext ctx = new MessageProcessorContext();
      ctx.set("NF_HEADER_LOCATION_PROP", HEADER);
      sr = new RequestHandlerClient();
      sr.serverName = "Nightfire.Router";
      NVPair[] result = sr.process(ctx, new MessageObject((Object) xml));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }