Package org.apache.sandesha2

Examples of org.apache.sandesha2.RMMsgContext


    MessageContext applicationMsg = applicationRMMsg.getMessageContext();
    ConfigurationContext configCtx = applicationMsg.getConfigurationContext();
   
    //generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(applicationRMMsg, internalSequenceId, acksTo);
   
    createSeqRMMessage.setFlow(MessageContext.OUT_FLOW);
    CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    //retrieving the storage manager.
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
    CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
    SenderBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();
   
    SequenceOffer offer = createSequencePart.getSequenceOffer();
    if (offer != null) {
      String offeredSequenceId = offer.getIdentifer().getIdentifier();

      SequencePropertyBean offeredSequenceBean = new SequencePropertyBean();
      offeredSequenceBean.setName(Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
      offeredSequenceBean.setSequenceID(internalSequenceId);
      offeredSequenceBean.setValue(offeredSequenceId);

      seqPropMgr.insert(offeredSequenceBean);
    }

    MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
    createSeqMsg.setRelationships(null); // create seq msg does not relateTo anything

    CreateSeqBean createSeqBean = new CreateSeqBean(internalSequenceId,createSeqMsg.getMessageID(), null);
    createSeqMgr.insert(createSeqBean);

    String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configCtx);
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
   
    if (createSeqMsg.getReplyTo() == null)
      createSeqMsg.setReplyTo(new EndpointReference(anonymousURI));

    String key = SandeshaUtil.getUUID();   //the key used to store the create sequence message.

    SenderBean createSeqEntry = new SenderBean();
    createSeqEntry.setMessageContextRefKey(key);
    createSeqEntry.setTimeToSend(System.currentTimeMillis());
    createSeqEntry.setMessageID(createSeqRMMessage.getMessageId());
    createSeqEntry.setInternalSequenceID(internalSequenceId);
    // this will be set to true in the sender
    createSeqEntry.setSend(true);

    createSeqMsg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,Sandesha2Constants.VALUE_FALSE);
View Full Code Here


        requestMsg = msg.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage());
      }

      RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
      Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (requestSequence == null) {
        String message = "Request Sequence is null";
        log.debug(message);
        throw new SandeshaException(message);
      }
View Full Code Here

   * @throws SandeshaException
   */
  public RMMsgContext checkForCreateSequenceRefused(
      MessageContext createSequenceMessage) throws SandeshaException {

    RMMsgContext createSequenceRMMsg = MsgInitializer
        .initializeMessage(createSequenceMessage);

    CreateSequence createSequence = (CreateSequence) createSequenceRMMsg
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    if (createSequence == null)
      throw new SandeshaException(
          "Passed message does not have a CreateSequence part");

    ConfigurationContext context = createSequenceMessage.getConfigurationContext();
    StorageManager storageManager = (StorageManager) SandeshaUtil
        .getSandeshaStorageManager(context);
    if (storageManager == null)
      throw new SandeshaException("Storage Manager is null");

    boolean refuseSequence = false;
    String reason = "";

    if (refuseSequence) {
      FaultData data = new FaultData();
      data.setType(Sandesha2Constants.SOAPFaults.FaultType.CREATE_SEQUENCE_REFUSED);
      int SOAPVersion = SandeshaUtil.getSOAPVersion(createSequenceRMMsg.getSOAPEnvelope());
      if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
        data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
      else
        data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

      data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.CREATE_SEQUENCE_REFUSED);
      data.setReason(reason);
      return getFault(createSequenceRMMsg, data,createSequenceRMMsg.getAddressingNamespaceValue());
    }

    return null;

  }
View Full Code Here

      }

      int SOAPVersion = SandeshaUtil.getSOAPVersion(referenceMessage.getEnvelope());
      SOAPFaultEnvelopeCreator.addSOAPFaultEnvelope(faultMsgContext,SOAPVersion, data,referenceRMMsgContext.getRMNamespaceValue());

      RMMsgContext faultRMMsgCtx = MsgInitializer.initializeMessage(faultMsgContext);

      return faultRMMsgCtx;

    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage());
View Full Code Here

    createSeqmsgContext.setAxisOperation(createSeqOperation);

    createSeqmsgContext.setTo(applicationRMMsg.getTo());
    createSeqmsgContext.setReplyTo(applicationRMMsg.getReplyTo());

    RMMsgContext createSeqRMMsg = new RMMsgContext(createSeqmsgContext);

    String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId,context);
    if (rmVersion==null)
      throw new SandeshaException ("Cant find the rmVersion of the given message");
   
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
   
    String addressingNamespaceValue = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,context);
   
    CreateSequence createSequencePart = new CreateSequence(factory,rmNamespaceValue,addressingNamespaceValue);

    // Adding sequence offer - if present
    OperationContext operationcontext = applicationMsgContext
        .getOperationContext();
    if (operationcontext != null) {
      String offeredSequence = (String) applicationMsgContext
          .getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
      if (offeredSequence != null && !"".equals(offeredSequence)) {
        SequenceOffer offerPart = new SequenceOffer(factory,rmNamespaceValue);
        Identifier identifier = new Identifier(factory,rmNamespaceValue);
        identifier.setIndentifer(offeredSequence);
        offerPart.setIdentifier(identifier);
        createSequencePart.setSequenceOffer(offerPart);
      }
    }

    SequencePropertyBean replyToBean = seqPropMgr.retrieve(
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
    SequencePropertyBean toBean = seqPropMgr.retrieve(internalSequenceId,
        Sandesha2Constants.SequenceProperties.TO_EPR);

    if (toBean == null || toBean.getValue() == null)
      throw new SandeshaException("To EPR is not set.");

    EndpointReference toEPR = new EndpointReference(toBean.getValue());
    EndpointReference replyToEPR = null;
    EndpointReference acksToEPR = null;

    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceValue);
   
    if (acksTo == null || "".equals(acksTo))
      acksTo = anonymousURI;

    acksToEPR = new EndpointReference(acksTo);

    if (replyToBean != null && replyToBean.getValue() != null)
      replyToEPR = new EndpointReference(replyToBean.getValue());

    if(createSeqRMMsg.getTo()==null)
      createSeqRMMsg.setTo(toEPR);

    // ReplyTo will be set only if not null.
    if (replyToEPR != null)
      createSeqRMMsg.setReplyTo(replyToEPR);

    createSequencePart.setAcksTo(new AcksTo(
        new Address(acksToEPR, factory, addressingNamespaceValue), factory,rmNamespaceValue,addressingNamespaceValue));

    createSeqRMMsg.setMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ, createSequencePart);

    try {
      createSeqRMMsg.addSOAPEnvelope();
    } catch (AxisFault e1) {
      throw new SandeshaException(e1.getMessage());
    }
   

    createSeqRMMsg.setAction(SpecSpecificConstants.getCreateSequenceAction(SandeshaUtil.getRMVersion(internalSequenceId,context)));
    createSeqRMMsg.setSOAPAction(SpecSpecificConstants.getCreateSequenceSOAPAction(SandeshaUtil.getRMVersion(internalSequenceId,context)));

    finalizeCreation(applicationMsgContext, createSeqmsgContext);
   
    return createSeqRMMsg;
  }
View Full Code Here

    if (!SpecSpecificConstants.isTerminateSequenceResponseRequired(rmVersion)) {
      terminateMessage.setProperty(MessageContext.TRANSPORT_IN,null);
    }
   
    RMMsgContext terminateRMMessage = MsgInitializer
        .initializeMessage(terminateMessage);

    if (terminateMessage == null)
      throw new SandeshaException("MessageContext is null");

    // setUpMessage(referenceMessage, terminateMessage);
   
    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(referenceMessage.getEnvelope()));

    terminateMessage.setMessageID(SandeshaUtil.getUUID());

    AxisOperation referenceMsgOperation = referenceMessage
        .getAxisOperation();
    if (referenceMsgOperation != null) {
      ArrayList outPhases = referenceMsgOperation.getPhasesOutFlow();
      if (outPhases != null) {
        terminateOperation.setPhasesOutFlow(outPhases);
        terminateOperation.setPhasesOutFaultFlow(outPhases);
      }
    }
   
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    terminateRMMessage.setSOAPEnvelop(envelope);
   
    TerminateSequence terminateSequencePart = new TerminateSequence(factory,rmNamespaceValue);
    Identifier identifier = new Identifier(factory,rmNamespaceValue);
    identifier.setIndentifer(sequenceId);
    terminateSequencePart.setIdentifier(identifier);
    terminateRMMessage.setMessagePart(
        Sandesha2Constants.MessageParts.TERMINATE_SEQ,
        terminateSequencePart);

    finalizeCreation(referenceMessage, terminateMessage);
   
View Full Code Here

    outMessage.setEnvelope(envelope);

    initializeCreation(createSeqMessage.getMessageContext(), outMessage);

    RMMsgContext createSeqResponse = null;
    try {
      createSeqResponse = MsgInitializer.initializeMessage(outMessage);
    } catch (SandeshaException ex) {
      throw new AxisFault("Cant initialize the message",ex);
    }
   
    createSeqResponse.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE,response);

    finalizeCreation(createSeqMessage.getMessageContext(), outMessage);

    createSeqMessage.getMessageContext().setServerSide(true);
    return createSeqResponse;
View Full Code Here

  }
 
 
  public static RMMsgContext createTerminateSeqResponseMsg (RMMsgContext terminateSeqRMMsg, MessageContext outMessage) throws SandeshaException {
   
    RMMsgContext terminateSeqResponseRMMsg = new RMMsgContext (outMessage);
    ConfigurationContext configurationContext = terminateSeqRMMsg.getMessageContext().getConfigurationContext();
   
    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 (factory,namespace);
    Identifier identifier = new Identifier (factory,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,configurationContext)));
    outMessage.setSoapAction(SpecSpecificConstants.getTerminateSequenceResponseAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));

    initializeCreation(terminateSeqRMMsg.getMessageContext(),outMessage);
   
    terminateSeqResponseRMMsg.addSOAPEnvelope();
   
   
    finalizeCreation(terminateSeqRMMsg.getMessageContext(), outMessage);
   
    terminateSeqResponseRMMsg.getMessageContext().setServerSide(true);
    return terminateSeqResponseRMMsg;
  }
View Full Code Here

  }
 
 
  public static RMMsgContext createCloseSeqResponseMsg (RMMsgContext closeSeqRMMsg, MessageContext outMessage) throws SandeshaException {
   
    RMMsgContext closeSeqResponseRMMsg = new RMMsgContext (outMessage);
    ConfigurationContext configurationContext = closeSeqRMMsg.getMessageContext().getConfigurationContext();
   
    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 (factory,namespace);
    Identifier identifier = new Identifier (factory,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,configurationContext)));
    outMessage.setSoapAction(SpecSpecificConstants.getCloseSequenceResponseAction(SandeshaUtil.getRMVersion(sequenceID,configurationContext)));

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

     
      MessageContext ackMsgCtx = SandeshaUtil
          .createNewRelatedMessageContext(relatedRMMessage,
              ackOperation);
     
      RMMsgContext ackRMMsgCtx = MsgInitializer
          .initializeMessage(ackMsgCtx);

      initializeCreation(applicationMsgCtx, ackMsgCtx);

      addAckMessage(ackRMMsgCtx, sequenceID);

      ackMsgCtx.setProperty(MessageContext.TRANSPORT_IN,null);
     
      finalizeCreation(applicationMsgCtx, ackMsgCtx);

      ackRMMsgCtx.getMessageContext().setServerSide(true);
      return ackRMMsgCtx;
    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage());
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.RMMsgContext

Copyright © 2018 www.massapicom. 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.