コード例 #1
0
ファイル: SapSender.java プロジェクト: smhoekstra/iaf-1
  public String sendMessage(String correlationID, String message, ParameterResolutionContext prc)
      throws SenderException, TimeOutException {
    String tid = null;
    try {
      ParameterValueList pvl = null;
      if (prc != null) {
        pvl = prc.getValues(paramList);
      }
      SapSystem sapSystem = getSystem(pvl);

      JCO.Function function = getFunction(sapSystem, pvl);

      if (StringUtils.isEmpty(getSapSystemName())) {
        pvl.removeParameterValue(getSapSystemNameParam());
      }
      if (StringUtils.isEmpty(getFunctionName())) {
        pvl.removeParameterValue(getFunctionNameParam());
      }
      message2FunctionCall(function, message, correlationID, pvl);
      if (log.isDebugEnabled())
        log.debug(getLogPrefix() + " function call [" + functionCall2message(function) + "]");
      JCO.Client client = getClient(prc.getSession(), sapSystem);
      try {
        tid = getTid(client, sapSystem);
        if (StringUtils.isEmpty(tid)) {
          client.execute(function);
        } else {
          client.execute(function, tid);
        }
      } finally {
        releaseClient(client, sapSystem);
      }
      if (isSynchronous()) {
        return functionResult2message(function);
      } else {
        return tid;
      }
    } catch (Exception e) {
      throw new SenderException(e);
    }
  }
コード例 #2
0
ファイル: ZipWriterSender.java プロジェクト: smhoekstra/iaf
  public String sendMessage(String correlationID, String message, ParameterResolutionContext prc)
      throws SenderException, TimeOutException {
    ParameterValueList pvl;
    try {
      pvl = prc.getValues(paramList);
    } catch (ParameterException e) {
      throw new SenderException("cannot determine filename and/or contents of zip entry", e);
    }

    IPipeLineSession session = prc.getSession();
    ZipWriter sessionData = ZipWriter.getZipWriter(session, getZipWriterHandle());
    if (sessionData == null) {
      throw new SenderException(
          "zipWriterHandle in session key [" + getZipWriterHandle() + "] is not open");
    }
    String filename =
        filenameParameter == null
            ? message
            : (String) pvl.getParameterValue(PARAMETER_FILENAME).getValue();
    try {
      if (contentsParameter == null) {
        if (message != null) {
          sessionData.writeEntry(filename, message, isCloseInputstreamOnExit(), getCharset());
        }
      } else {
        Object paramValue = pvl.getParameterValue(PARAMETER_CONTENTS).getValue();
        sessionData.writeEntry(filename, paramValue, isCloseInputstreamOnExit(), getCharset());
      }
      return message;
    } catch (UnsupportedEncodingException e) {
      throw new SenderException(getLogPrefix() + "cannot encode zip entry", e);
    } catch (CompressionException e) {
      throw new SenderException(getLogPrefix() + "cannot store zip entry", e);
    } catch (IOException e) {
      throw new SenderException(getLogPrefix() + "cannot store zip entry", e);
    }
  }