Esempio n. 1
0
  private void checkFailedLogEntries(LogInterfaceTo intFace) {
    int failedCount = prefs.getInt(intFace.getLogInterfaceName(), 0);
    if (failedCount > 0) {

      LogEntryTo entry = new LogEntryTo();
      entry.setInstanceVersion("0");
      entry.setLogEntryId(random.nextInt());
      entry.setLogLevel((String) SoaMessageHandler.logLevels.get("ERROR"));
      entry.setIntegrationInstanceId("0");
      entry.setLogMsg(failedCount + " instances not logged");

      entry.setLogDate(this.getToday());
      intFace.getLogEntryList().add(entry);
    }
  }
Esempio n. 2
0
  private void checkValues() {

    try {
      // Get payload of the message
      Map payload = getCalloutMediatorMessage().getPayload();
      // Try to get the message key
      String key = null;

      Iterator it = payload.keySet().iterator();
      while (it.hasNext()) {
        key = (String) it.next();
      }
      Element payloadElement = (Element) payload.get(key);

      try {

        if (li.getLogMessageFlag() != null && li.getLogMessageFlag().trim().equals("Y")) {
          MsgWriter writer = new MsgWriter();

          writer.setPayload(payloadElement);

          writer.setLi(li);
          writer.setEntry(entry);
          writer.setSoaLogger(soaLogger);
          writer.run();
          /* This code is moved to another thread
          LogMsgTo msg = new LogMsgTo();
          msg.setBase64Flag(li.getApplyBase64());
          msg.setEnv(li.getEnvironmentFlag());
          msg.setInstanceId(entry.getIntegrationInstanceId());
          msg.setInterfaceName(li.getLogInterfaceName());
          msg.setLogMsg(msgString);
          int retval = soaLogger.addLogMessage(msg);
          if (retval != 0) {
            logger.severe("Writing message to web service did not succeed: " + retval);
          }
            */
        }
      } catch (Exception expp) {
        expp.printStackTrace();
        logger.severe("Exception writing message to web service : " + expp.toString());
      }
      List<LogFieldTo> lfs = null;
      try {
        lfs = soaLogger.getInterfaceFields(li);
        if (lfs != null) {

          ArrayList<EntryValueTo> values = new ArrayList<EntryValueTo>();
          for (LogFieldTo field : lfs) {

            if (field.getXmlXpath() != null) {
              try {

                XPathFactory factory = XPathFactory.newInstance();
                XPath xpath = factory.newXPath();
                XPathExpression expr = xpath.compile(field.getXmlXpath());
                String xpathResult = (String) expr.evaluate(payloadElement, XPathConstants.STRING);
                EntryValueTo value = new EntryValueTo();
                value.setValueName(field.getLogFieldName());
                value.setValueId(random.nextInt());
                value.setEntryValue(xpathResult);

                values.add(value);
              } catch (Exception exp) {
                logger.severe("Exception parsing Xpath : " + exp.toString());
              }
            } else {

              NodeList nl = payloadElement.getElementsByTagNameNS("*", field.getElementName());

              for (int i = 0; i < nl.getLength(); i++) {
                Element valEl = (Element) nl.item(i);

                List<String> elementValues = MessageProcesser.getStringFromElement(valEl);
                for (String elementValue : elementValues) {
                  EntryValueTo value = new EntryValueTo();
                  value.setValueName(field.getLogFieldName());
                  value.setValueId(random.nextInt());
                  value.setEntryValue(elementValue);
                  values.add(value);
                }
              }
            }
          }
          entry.setEntryValuesList(values);
          ArrayList<LogEntryTo> logEntries = new ArrayList<LogEntryTo>();
          logEntries.add(entry);

          soaLogger.addLogEntryValues(logEntries);
        }
      } catch (Exception ex) {
        logger.severe("Exception occurred adding logfield value: " + ex.toString());
      }

    } catch (Exception eexp) {
      eexp.printStackTrace();
      logger.severe("Exception occurred in preRouting : " + eexp.toString());
    }
  }