@Override
  public NVPair[] process(MessageProcessorContext mpContext, MessageObject inputObject)
      throws MessageException, ProcessingException {
    if (inputObject == null) return null;
    /*
     * Load the value of configured properties
     */
    for (PPDataHolder holder : ppData) {
      String propertyValue = null;
      try {
        boolean useCustomerId = StringUtils.getBoolean(holder.getUseCustomerId());

        if (useCustomerId)
          propertyValue =
              PersistentProperty.get(
                  holder.getKey(), holder.getPropertyType(), holder.getPropertyName());
        else {
          String customerId = CustomerContext.getInstance().getCustomerID();
          CustomerContext.getInstance().setCustomerID(CustomerContext.DEFAULT_CUSTOMER_ID);
          propertyValue =
              PersistentProperty.get(
                  holder.getKey(), holder.getPropertyType(), holder.getPropertyName());
          CustomerContext.getInstance().setCustomerID(customerId);
        }

      } catch (Exception ex) {
        Debug.warning(
            "Unable to get configured property from persistent property :" + holder.toString());
      }

      /*
       * set the value into message processor context
       */
      if (StringUtils.hasValue(propertyValue)) {
        if (Debug.isLevelEnabled(Debug.DB_DATA))
          Debug.log(
              Debug.DB_DATA,
              " setting value :" + propertyValue + " on location :" + holder.getOutputLoc());

        mpContext.set(holder.getOutputLoc(), propertyValue);
      }
    }

    /* Always return input value to provide pass-through semantics. */
    return (formatNVPair(inputObject));
  }
  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();
    }
  }
Example #3
0
  public static void main(String[] args) {

    Debug.enable(Debug.UNIT_TEST);
    Debug.enable(Debug.BENCHMARK);
    Debug.showLevels();
    if (args.length != 3) {
      Debug.log(
          Debug.ALL_ERRORS,
          "UnBatcher: USAGE:  " + " jdbc:oracle:thin:@192.168.164.238:1521:e911 e911 e911 ");
      return;
    }
    try {

      DBInterface.initialize(args[0], args[1], args[2]);
    } catch (DatabaseException e) {
      Debug.log(
          Debug.MAPPING_ERROR,
          "UnBatcher: " + "Database initialization failure: " + e.getMessage());
    }

    Splitter spl = new Splitter();

    try {
      MessageProcessorContext mpx = new MessageProcessorContext();
      mpx.set("FileName", "MANS9999");

      String s = FileUtils.readFile("D:\\Response\\DECCCORR.txt");
      System.out.println("length----------->>>>>" + s.length());
      MessageObject msob = new MessageObject();
      msob.set(s);
      spl.initialize("E911BATCHER", "FAX_MESSAGE_SPLITTER");
      spl.process(mpx, msob);

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
  }