Examples of RMMsgContext


Examples of org.apache.sandesha2.RMMsgContext

  }

  public static RMMsgContext createTerminateSeqResponseMsg(RMMsgContext terminateSeqRMMsg, MessageContext outMessage,
      StorageManager storageManager) throws AxisFault {
       
    RMMsgContext terminateSeqResponseRMMsg = new RMMsgContext(outMessage);

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(terminateSeqRMMsg
        .getSOAPEnvelope()));

    TerminateSequence terminateSequence = (TerminateSequence) terminateSeqRMMsg
        .getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
    String sequenceID = terminateSequence.getIdentifier().getIdentifier();

    String namespace = terminateSeqRMMsg.getRMNamespaceValue();
    terminateSeqResponseRMMsg.setRMNamespaceValue(namespace);

    TerminateSequenceResponse terminateSequenceResponse = new TerminateSequenceResponse(namespace);
    Identifier identifier = new Identifier(namespace);
    identifier.setIndentifer(sequenceID);
    terminateSequenceResponse.setIdentifier(identifier);

    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    terminateSeqResponseRMMsg.setSOAPEnvelop(envelope);
    terminateSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE,
        terminateSequenceResponse);

    outMessage.setWSAAction(SpecSpecificConstants.getTerminateSequenceResponseAction(SandeshaUtil.getRMVersion(
        sequenceID, storageManager)));
    outMessage.setSoapAction(SpecSpecificConstants.getTerminateSequenceResponseAction(SandeshaUtil.getRMVersion(
        sequenceID, storageManager)));

    initializeCreation(terminateSeqRMMsg.getMessageContext(), outMessage);

    terminateSeqResponseRMMsg.addSOAPEnvelope();

    finalizeCreation(terminateSeqRMMsg.getMessageContext(), outMessage);

//    terminateSeqResponseRMMsg.getMessageContext().setServerSide(true);
    return terminateSeqResponseRMMsg;
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

  }

  public static RMMsgContext createCloseSeqResponseMsg(RMMsgContext closeSeqRMMsg, MessageContext outMessage,
      StorageManager storageManager) throws AxisFault {

    RMMsgContext closeSeqResponseRMMsg = new RMMsgContext(outMessage);

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(closeSeqRMMsg
        .getSOAPEnvelope()));

    CloseSequence closeSequence = (CloseSequence) closeSeqRMMsg
        .getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
    String sequenceID = closeSequence.getIdentifier().getIdentifier();

    String namespace = closeSeqRMMsg.getRMNamespaceValue();
    closeSeqResponseRMMsg.setRMNamespaceValue(namespace);

    CloseSequenceResponse closeSequenceResponse = new CloseSequenceResponse(namespace);
    Identifier identifier = new Identifier(namespace);
    identifier.setIndentifer(sequenceID);
    closeSequenceResponse.setIdentifier(identifier);

    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    closeSeqResponseRMMsg.setSOAPEnvelop(envelope);
    closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE,
        closeSequenceResponse);

    outMessage.setWSAAction(SpecSpecificConstants.getCloseSequenceResponseAction(SandeshaUtil.getRMVersion(
        sequenceID, storageManager)));
    outMessage.setSoapAction(SpecSpecificConstants.getCloseSequenceResponseAction(SandeshaUtil.getRMVersion(
        sequenceID, storageManager)));

    initializeCreation(closeSeqRMMsg.getMessageContext(), outMessage);

    closeSeqResponseRMMsg.addSOAPEnvelope();

    finalizeCreation(closeSeqRMMsg.getMessageContext(), outMessage);
    closeSeqResponseRMMsg.getMessageContext().setServerSide(true);
    return closeSeqResponseRMMsg;
  }
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

     
    makeConnectionOperation = AxisOperationFactory.getAxisOperation(
        WSDL20_2004Constants.MEP_CONSTANT_OUT_IN);
   
    MessageContext makeConnectionMessageCtx = SandeshaUtil.createNewRelatedMessageContext(referenceRMMessage,makeConnectionOperation);
    RMMsgContext makeConnectionRMMessageCtx = MsgInitializer.initializeMessage(makeConnectionMessageCtx);
   
    MakeConnection makeConnection = new MakeConnection (rmNamespaceValue);
    if (makeConnectionSeqId!=null) {
      Identifier identifier = new Identifier (rmNamespaceValue);
      identifier.setIndentifer(makeConnectionSeqId);
      makeConnection.setIdentifier(identifier);
    }
   
    if (makeConnectionAnonURI!=null) {
      Address address = new Address (rmNamespaceValue);
      address.setAddress (makeConnectionAnonURI);
      makeConnection.setAddress(address);
    }
   
    //setting the addressing properties
    makeConnectionMessageCtx.setTo(new EndpointReference (referenceMessage.getTo().getAddress()));
    makeConnectionMessageCtx.setWSAAction(SpecSpecificConstants.getMakeConnectionAction(rmVersion));
    makeConnectionMessageCtx.setMessageID(SandeshaUtil.getUUID());
   
    makeConnectionRMMessageCtx.setMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION,
        makeConnection);
   
    //generating the SOAP Envelope.
    makeConnectionRMMessageCtx.addSOAPEnvelope();
   
    return makeConnectionRMMessageCtx;
  }
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

   
    // TODO: Note that this RMMessageContext is not really any use - but we need to create it
    // so that it can be passed to the fault handling chain. It's really no more than a
    // container for the correct addressing and RM spec levels, so we'd be better off passing
    // them in directly. Unfortunately that change ripples through the codebase...
    RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);

    ConfigurationContext configCtx = msgCtx.getConfigurationContext();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String outSequenceId = sequenceAck.getIdentifier().getIdentifier();
    if (outSequenceId == null || "".equals(outSequenceId)) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.outSeqIDIsNull);
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    String internalSequenceId = SandeshaUtil.getSequenceProperty(outSequenceId,
        Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, storageManager);

    //here we cannot get the property key using the usual SandeshaUtil.getSequencePropertyKey function,
    //because this can be a applicationMessage, which piggybacks the acknowledgement.
    String sequencePropertyKey = internalSequenceId;

    // Check that the sender of this Ack holds the correct token
    SequencePropertyBean tokenBean = seqPropMgr.retrieve(outSequenceId, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
     
      secManager.checkProofOfPossession(token, soapHeader, msgCtx);
    }
   
    Iterator ackRangeIterator = sequenceAck.getAcknowledgementRanges().iterator();
    Iterator nackIterator = sequenceAck.getNackList().iterator();

    FaultManager faultManager = new FaultManager();
    SandeshaException fault = faultManager
        .checkForUnknownSequence(rmMsgCtx, outSequenceId, storageManager);
    if(fault == null) {
      fault = faultManager.checkForInvalidAcknowledgement(rmMsgCtx, storageManager);
    }
    if (fault != null) {
      throw fault;
    }

    // updating the last activated time of the sequence.
    SequenceManager.updateLastActivatedTime(sequencePropertyKey, storageManager);

    SenderBean input = new SenderBean();
    input.setSend(true);
    input.setReSend(true);
    Collection retransmitterEntriesOfSequence = senderBeanMgr.find(input);

    ArrayList ackedMessagesList = new ArrayList();
    while (ackRangeIterator.hasNext()) {
      AcknowledgementRange ackRange = (AcknowledgementRange) ackRangeIterator.next();
      long lower = ackRange.getLowerValue();
      long upper = ackRange.getUpperValue();

      for (long messageNo = lower; messageNo <= upper; messageNo++) {
        SenderBean retransmitterBean = getSenderEntry(retransmitterEntriesOfSequence, messageNo);
        if (retransmitterBean != null) {
          senderBeanMgr.delete(retransmitterBean.getMessageID());

          // removing the application message from the storage.
          String storageKey = retransmitterBean.getMessageContextRefKey();
          storageManager.removeMessageContext(storageKey);
        }

        ackedMessagesList.add(new Long(messageNo));
      }
    }

    while (nackIterator.hasNext()) {
      Nack nack = (Nack) nackIterator.next();
      long msgNo = nack.getNackNumber();

      // TODO - Process Nack
    }
   
    //adding a MakeConnection for the response sequence if needed.
    String offeredSequenceId = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE, storageManager);
    if (offeredSequenceId!=null) {

      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rmdBean = rmdBeanMgr.retrieve(outSequenceId);
     
      if (rmdBean!=null && rmdBean.isPollingMode())
        SandeshaUtil.shedulePollingRequest(offeredSequenceId, configCtx);
     
    }
   
    // setting acked message date.
    // TODO add details specific to each message.
    long noOfMsgsAcked = getNoOfMessagesAcked(sequenceAck.getAcknowledgementRanges().iterator());
    SequencePropertyBean noOfMsgsAckedBean = seqPropMgr.retrieve(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.NO_OF_OUTGOING_MSGS_ACKED);
    boolean added = false;

    if (noOfMsgsAckedBean == null) {
      added = true;
      noOfMsgsAckedBean = new SequencePropertyBean();
      noOfMsgsAckedBean.setSequencePropertyKey(sequencePropertyKey);
      noOfMsgsAckedBean.setName(Sandesha2Constants.SequenceProperties.NO_OF_OUTGOING_MSGS_ACKED);
    }

    noOfMsgsAckedBean.setValue(Long.toString(noOfMsgsAcked));

    if (added)
      seqPropMgr.insert(noOfMsgsAckedBean);
    else
      seqPropMgr.update(noOfMsgsAckedBean);

    // setting the completed_messages list. This gives all the messages of
    // the sequence that were acked.
    SequencePropertyBean allCompletedMsgsBean = seqPropMgr.retrieve(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
    if (allCompletedMsgsBean == null) {
      allCompletedMsgsBean = new SequencePropertyBean();
      allCompletedMsgsBean.setSequencePropertyKey(sequencePropertyKey);
      allCompletedMsgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);

      seqPropMgr.insert(allCompletedMsgsBean);
    }

    String str = ackedMessagesList.toString();
    allCompletedMsgsBean.setValue(str);

    seqPropMgr.update(allCompletedMsgsBean);

    String lastOutMsgNoStr = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO, storageManager);
    if (lastOutMsgNoStr != null) {
      long highestOutMsgNo = 0;
      if (lastOutMsgNoStr != null) {
        highestOutMsgNo = Long.parseLong(lastOutMsgNoStr);
      }

      if (highestOutMsgNo > 0) {
        boolean complete = AcknowledgementManager.verifySequenceCompletion(sequenceAck
            .getAcknowledgementRanges().iterator(), highestOutMsgNo);

        if (complete) {
         
          //using create sequence message as the reference message.
//          CreateSeqBeanMgr createSeqBeanMgr = storageManager.getCreateSeqBeanMgr();
//          CreateSeqBean createSeqBean = createSeqBeanMgr.retrieve(msgId);
//         
          TerminateManager.addTerminateSequenceMessage(rmMsgCtx, outSequenceId, sequencePropertyKey,
              storageManager);
        }
      }
    }


    String action = msgCtx.getOptions().getAction();
    if (action!=null && action.equals(SpecSpecificConstants.getAckRequestAction(rmMsgCtx.getRMSpecVersion()))) {
      returnValue = true;
      rmMsgCtx.pause();
    }

    if (log.isDebugEnabled())
      log.debug("Exit: AcknowledgementProcessor::processAckHeader " + returnValue);
    return returnValue;
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

    ackMsgCtx.setServerSide(referenceMsg.isServerSide());
   
    ackMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    RMMsgContext ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
    ackRMMsgCtx.setRMNamespaceValue(referenceRMMessage.getRMNamespaceValue());

    ackMsgCtx.setMessageID(SandeshaUtil.getUUID());

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(referenceMsg.getEnvelope()));
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

      if (rmVersion == null)
        throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));

      String assumedRMNamespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);

      RMMsgContext applicaionRMMsg = MsgInitializer.initializeMessage(applicationMsg);

      Sequence sequencePart = (Sequence) applicaionRMMsg.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (sequencePart == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.seqPartIsNull);
        log.debug(message);
        throw new SandeshaException(message);
      }

      Identifier identifier = new Identifier(assumedRMNamespace);
      identifier.setIndentifer(newOutSequenceId);

      sequencePart.setIdentifier(identifier);

      try {
        applicaionRMMsg.addSOAPEnvelope();
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage(), e);
      }

      // asking to send the application msssage
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

    // TODO: Note that this RMMessageContext is not really any use - but we need to create it
    // so that it can be passed to the fault handling chain. It's really no more than a
    // container for the correct addressing and RM spec levels, so we'd be better off passing
    // them in directly. Unfortunately that change ripples through the codebase...
    RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgContext);

    String sequenceId = ackRequested.getIdentifier().getIdentifier();

    ConfigurationContext configurationContext = msgContext.getConfigurationContext();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,
        configurationContext.getAxisConfiguration());

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    //not getting the sequencePropertyKey from the usual method since the ackRequest may be embedded in a message
    //of a different sequence. (usual method SandeshaUtil.getSequencePropertyKey)
    String sequencePropertyKey = sequenceId;
   
    // Check that the sender of this AckRequest holds the correct token
    SequencePropertyBean tokenBean = seqPropMgr.retrieve(sequencePropertyKey, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configurationContext);
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
     
      secManager.checkProofOfPossession(token, soapHeader, msgContext);
    }

    // Setting the ack depending on AcksTo.
    SequencePropertyBean acksToBean = seqPropMgr.retrieve(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);

    EndpointReference acksTo = new EndpointReference(acksToBean.getValue());
    String acksToStr = acksTo.getAddress();

    if (acksToStr == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.acksToStrNotSet));

    AxisOperation ackOperation = null;

    try {
      ackOperation = AxisOperationFactory.getOperationDescription(WSDL20_2004Constants.MEP_URI_IN_ONLY);
    } catch (AxisFault e) {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.axisOperationError, e
          .toString()));
    }

    AxisOperation rmMsgOperation = rmMsgCtx.getMessageContext().getAxisOperation();
    if (rmMsgOperation != null) {
      ArrayList outFlow = rmMsgOperation.getPhasesOutFlow();
      if (outFlow != null) {
        ackOperation.setPhasesOutFlow(outFlow);
        ackOperation.setPhasesOutFaultFlow(outFlow);
      }
    }

    MessageContext ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);

    ackMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    RMMsgContext ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
    ackRMMsgCtx.setRMNamespaceValue(rmMsgCtx.getRMNamespaceValue());

    ackMsgCtx.setMessageID(SandeshaUtil.getUUID());

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(msgContext.getEnvelope()));

    // Setting new envelope
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    try {
      ackMsgCtx.setEnvelope(envelope);
    } catch (AxisFault e3) {
      throw new SandeshaException(e3.getMessage());
    }

    ackMsgCtx.setTo(acksTo);
    ackMsgCtx.setReplyTo(msgContext.getTo());
    RMMsgCreator.addAckMessage(ackRMMsgCtx,sequencePropertyKey,sequenceId, storageManager);
    ackRMMsgCtx.getMessageContext().setServerSide(true);
    ackMsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, msgContext
        .getProperty(AddressingConstants.WS_ADDRESSING_VERSION)); // TODO
                                      // do
                                      // this
                                      // in
                                      // the
                                      // RMMsgCreator

    String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);

    if (anonymousURI.equals(acksTo.getAddress())) {

      AxisEngine engine = new AxisEngine(ackRMMsgCtx.getMessageContext().getConfigurationContext());

      // setting CONTEXT_WRITTEN since acksto is anonymous
      if (rmMsgCtx.getMessageContext().getOperationContext() == null) {
        // operation context will be null when doing in a GLOBAL
        // handler.
        try {
          AxisOperation op = AxisOperationFactory.getAxisOperation(WSDL20_2004Constants.MEP_CONSTANT_IN_OUT);
          OperationContext opCtx = new OperationContext(op);
          rmMsgCtx.getMessageContext().setAxisOperation(op);
          rmMsgCtx.getMessageContext().setOperationContext(opCtx);
        } catch (AxisFault e2) {
          throw new SandeshaException(e2.getMessage());
        }
      }

      rmMsgCtx.getMessageContext().getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN,
          Constants.VALUE_TRUE);

      rmMsgCtx.getMessageContext().setProperty(Sandesha2Constants.ACK_WRITTEN, "true");

      try {
        engine.send(ackRMMsgCtx.getMessageContext());
      } catch (AxisFault e1) {
        throw new SandeshaException(e1.getMessage());
      }

    } else {
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

   *
   * @return
   * @throws SandeshaException
   */
  public static RMMsgContext initializeMessage(MessageContext ctx) throws AxisFault {
    RMMsgContext rmMsgCtx = new RMMsgContext(ctx);

    populateRMMsgContext(ctx, rmMsgCtx);
    validateMessage(rmMsgCtx);
    return rmMsgCtx;
  }
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

    if (log.isDebugEnabled())
      log.debug("Enter: MessagePendingProcessor::processMessagePendingHeaders");

    boolean messagePaused = false;
   
    RMMsgContext rmMsgContext = MsgInitializer.initializeMessage(message);
    Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    MessagePending messagePending = (MessagePending) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.MESSAGE_PENDING);
   
    if (sequence!=null) {
      String sequenceId = sequence.getIdentifier().getIdentifier();
     
      if (messagePending!=null) {
View Full Code Here

Examples of org.apache.sandesha2.RMMsgContext

      throw new SandeshaException (message);
    }
     
    String messageStorageKey = senderBean.getMessageContextRefKey();
    MessageContext returnMessage = storageManager.retrieveMessageContext(messageStorageKey,configurationContext);
    RMMsgContext returnRMMsg = MsgInitializer.initializeMessage(returnMessage);
   
   
    addMessagePendingHeader (returnRMMsg,pending);
   
    setTransportProperties (returnMessage, rmMsgCtx);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.