コード例 #1
0
  public void testGetMessageId() {
    context.setUuidGenerator(new SimpleUuidGenerator());
    Exchange exchange = new DefaultExchange(context);
    Message in = exchange.getIn();

    assertEquals("1", in.getMessageId());
  }
コード例 #2
0
  @Override
  public void copyFrom(org.apache.camel.Message that) {
    // must initialize headers before we set the JmsMessage to avoid Camel
    // populating it before we do the copy
    getHeaders().clear();

    boolean copyMessageId = true;
    if (that instanceof JmsMessage) {
      JmsMessage thatMessage = (JmsMessage) that;
      this.jmsMessage = thatMessage.jmsMessage;
      if (this.jmsMessage != null) {
        // for performance lets not copy the messageID if we are a JMS message
        copyMessageId = false;
      }
    }

    if (copyMessageId) {
      setMessageId(that.getMessageId());
    }
    setBody(that.getBody());
    getHeaders().putAll(that.getHeaders());
    getAttachments().putAll(that.getAttachments());
  }
コード例 #3
0
  public MediationMessage createMessage(CamelMediationMessage message) {

    // Get HTTP Exchange from SPML Exchange
    CamelMediationExchange spmlR2exchange = message.getExchange();
    Exchange exchange = spmlR2exchange.getExchange();

    logger.debug("Create Message Body from exchange " + exchange.getClass().getName());

    // Converting from CXF Message to SPML Message
    // Is this a CXF message?
    Message in = exchange.getIn();

    if (in.getBody() instanceof MessageContentsList) {

      MessageContentsList mclIn = (MessageContentsList) in.getBody();
      logger.debug("Using CXF Message Content : " + mclIn.get(0));

      MediationMessage body;
      LocalState lState = null;
      MediationState state = null;

      /*
      if (mclIn.get(0) instanceof RequestType) {
          // Process Saml Request in SOAP Channel
          // Try to restore provider state based on sessionIndex
          RequestType samlReq = (RequestType) mclIn.get(0);
          try {

              Method getSessionIndex = samlReq.getClass().getMethod("getSessionIndex");
              List<String> sessionIndexes = (List<String>) getSessionIndex.invoke(samlReq);

              if (sessionIndexes != null) {
                  if (sessionIndexes.size() > 0) {
                      // TODO : Right now we support only one session index!
                      String sessionIndex = sessionIndexes.get(0);

                      ProviderStateContext ctx = createProviderStateContext();
                      lState = ctx.retrieve("idpSsoSessionId", sessionIndex);

                      if (logger.isDebugEnabled())
                          logger.debug("Local state was" + (lState == null ? " NOT" : "") + " retrieved for ssoSessionId " + sessionIndex);
                  }
              }

          } catch (NoSuchMethodException e) {
              // Ignore this ...
              if (logger.isTraceEnabled())
                  logger.trace("SAML Request does not have session index : " + e.getMessage());

          } catch (InvocationTargetException e) {
              logger.error("Cannot recover local state : " + e.getMessage(), e);
          } catch (IllegalAccessException e) {
              logger.error("Cannot recover local state : " + e.getMessage(), e);
          }

      }

      if (lState == null) {
          // Create a new local state instance ?
          state = createMediationState(exchange);
      } else {
          state = new MediationStateImpl(lState);

      } */

      // Process Saml Response in SOAP Channel
      body = new MediationMessageImpl(in.getMessageId(), mclIn.get(0), null, null, null, state);

      return body;

    } else {
      throw new IllegalArgumentException("Unknown message type " + in.getBody());
    }
  }
コード例 #4
0
  public void testGetMessageIdWithoutAnExchange() {
    Message in = new DefaultMessage();

    assertNotNull(in.getMessageId());
  }
コード例 #5
0
 /** Return the file name that will be auto-generated for the given message if none is provided */
 public String getGeneratedFileName(Message message) {
   return StringHelper.sanitize(message.getMessageId());
 }