예제 #1
0
  public Object fromMessage(Message msg) throws JMSException, MessageConversionException {
    log.debug("--OperationlogMsgConverter fromMessage--");
    if (!(msg instanceof MapMessage)) {
      throw new MessageConversionException("Message isn't a MapMessage");
    }

    if ((msg == null) || (msg.getBooleanProperty("NullMessage"))) {
      return null;
    }

    MapMessage mapMessage = (MapMessage) msg;
    OperationLog optLog = new OperationLog();
    @SuppressWarnings("unused")
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    optLog.setMainType(Integer.valueOf(mapMessage.getInt("mainType")));
    optLog.setMinorType(Integer.valueOf(mapMessage.getInt("minorType")));
    optLog.setCtrlUnitId(Integer.valueOf(mapMessage.getInt("ctrlUnitId")));
    optLog.setUserId(Integer.valueOf(mapMessage.getInt("userId")));

    optLog.setTriggerTime(Calendar.getInstance().getTime());

    optLog.setResourceId(Integer.valueOf(mapMessage.getInt("resourceId")));
    try {
      if (mapMessage.getString("logTxt") == null) {
        return null;
      }
      optLog.setLogTxt(new String(mapMessage.getString("logTxt").getBytes("ISO-8859-1"), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      log.error(e.getMessage());
    }

    return optLog;
  }