Package org.apache.sandesha2.wsrm

Examples of org.apache.sandesha2.wsrm.CreateSequenceResponse


      createSeqResponse.setFlow(MessageContext.OUT_FLOW);
 
      // for making sure that this won't be processed again
      createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
     
      CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
          .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
 
        // OFFER PROCESSING
      SequenceOffer offer = createSeqPart.getSequenceOffer();
      if (offer != null) {
        Accept accept = createSeqResPart.getAccept();
        if (accept == null) {
          if (log.isDebugEnabled())
            log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart));
          FaultManager.makeCreateSequenceRefusedFault(createSeqRMMsg,
                                                      SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart),
                                                      new Exception());
          // Return false if an Exception hasn't been thrown.
          if (log.isDebugEnabled())
            log.debug("Exit: CreateSeqMsgProcessor::processInMessage " + Boolean.FALSE);       
          return false;
        }
 
        // offered seq id
        String offeredSequenceID = offer.getIdentifer().getIdentifier();
       
        boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);
 
        if (offerEcepted) {
          // Setting the CreateSequence table entry for the outgoing
          // side.
          RMSBean rMSBean = new RMSBean();
          rMSBean.setSequenceID(offeredSequenceID);
          String outgoingSideInternalSequenceId = SandeshaUtil
              .getOutgoingSideInternalSequenceID(rmdBean.getSequenceID());
          rMSBean.setInternalSequenceID(outgoingSideInternalSequenceId);
          // this is a dummy value
          rMSBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
           
          rMSBean.setToEPR(rmdBean.getToEPR());
          rMSBean.setAcksToEPR(rmdBean.getToEPR())// The acks need to flow back into this endpoint
          rMSBean.setReplyToEPR(rmdBean.getReplyToEPR());
          rMSBean.setLastActivatedTime(System.currentTimeMillis());
          rMSBean.setRMVersion(rmdBean.getRMVersion());
          rMSBean.setClientCompletedMessages(new RangeString());
 
          // Setting sequence properties for the outgoing sequence.
          // Only will be used by the server side response path. Will
          // be wasted properties for the client side.
           
          Endpoint endpoint = offer.getEndpoint();
          if (endpoint!=null) {
            // setting the OfferedEndpoint
            rMSBean.setOfferedEndPoint(endpoint.getEPR().getAddress());
          }
   
          rmdBean.setOutboundInternalSequence(outgoingSideInternalSequenceId);
          RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
          rmdBeanMgr.update(rmdBean);
 
          // Store the inbound token (if any) with the new sequence
          rMSBean.setSecurityTokenData(rmdBean.getSecurityTokenData());
         
          // If this new sequence has anonymous acksTo, then we must poll for the acks
          // If the inbound sequence is targetted at the WSRM anonymous URI, we need to start
          // polling for this sequence.
          String acksTo = rMSBean.getAcksToEPR();
          EndpointReference reference = new EndpointReference(acksTo);
          if ((acksTo == null || reference.hasAnonymousAddress()) &&
            Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqRMMsg.getRMSpecVersion())) {
            rMSBean.setPollingMode(true);
          }
         
          // Set the SOAP Version for this sequence.
          rMSBean.setSoapVersion(SandeshaUtil.getSOAPVersion(createSeqRMMsg.getSOAPEnvelope()));
         
          if (isReplayModel(createSeqRMMsg)) {
            rMSBean.setReplayModel(true);
            rmdBean.setReplayModel(true);
          }
         
          storageManager.getRMSBeanMgr().insert(rMSBean);
         
          SandeshaUtil.startWorkersForSequence(context, rMSBean);
         
        } else {
          // removing the accept part.
          createSeqResPart.setAccept(null);
          createSeqResponse.addSOAPEnvelope();
        }
      }
             
      //TODO add createSequenceResponse message as the referenceMessage to the RMDBean.
View Full Code Here


          createSeqRMMsg, outMessage,newSequenceId);    // converting the blank out message in to a create
                                                            // sequence response.
      createSeqResponse.setFlow(MessageContext.OUT_FLOW);
     
      createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true")//for making sure that this wont be processed again.
      CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);

     
      //OFFER PROCESSING
      SequenceOffer offer = createSeqPart.getSequenceOffer();
      if (offer != null) {
        Accept accept = createSeqResPart.getAccept();
        if (accept == null) {
          String message = "An accept part has not been generated for the create seq request with an offer part";
          log.debug(message);
          throw new SandeshaException(message);
        }

        String offeredSequenceID = offer.getIdentifer().getIdentifier(); //offered seq. id.
       
        boolean offerEcepted = offerAccepted (offeredSequenceID,context,createSeqRMMsg);
       
        if (offerEcepted)  {
          //Setting the CreateSequence table entry for the outgoing side.
          CreateSeqBean createSeqBean = new CreateSeqBean();
          createSeqBean.setSequenceID(offeredSequenceID);
          String outgoingSideInternalSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(newSequenceId);
          createSeqBean.setInternalSequenceID(outgoingSideInternalSequenceID);
          createSeqBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); //this is a dummy value.
       
          CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
          createSeqMgr.insert(createSeqBean);
       
          //Setting sequence properties for the outgoing sequence.
          //Only will be used by the server side response path. Will be wasted properties for the client side.
       
          //setting the out_sequence_id
          SequencePropertyBean outSequenceBean = new SequencePropertyBean();
          outSequenceBean.setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
          outSequenceBean.setValue(offeredSequenceID);
          outSequenceBean.setSequenceID(outgoingSideInternalSequenceID);
          seqPropMgr.insert(outSequenceBean);

          //setting the internal_sequence_id
          SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
          internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
          internalSequenceBean.setSequenceID(offeredSequenceID);
          internalSequenceBean.setValue(outgoingSideInternalSequenceID);
          seqPropMgr.insert(internalSequenceBean);
        } else {
          //removing the accept part.
          createSeqResPart.setAccept(null);
          createSeqResponse.addSOAPEnvelope();
        }
      }

      EndpointReference acksTo = createSeqPart.getAcksTo().getAddress().getEpr();
View Full Code Here

      throw new SandeshaException ("Cant find the rmVersion of the given message");
   
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);   
    String addressingNamespaceValue = SandeshaUtil.getSequenceProperty(newSequenceID,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configurationContext);
   
    CreateSequenceResponse response = new CreateSequenceResponse(factory,rmNamespaceValue,addressingNamespaceValue);

    Identifier identifier = new Identifier(factory,rmNamespaceValue);
    identifier.setIndentifer(newSequenceID);

    response.setIdentifier(identifier);

    SequenceOffer offer = cs.getSequenceOffer();
    if (offer != null) {
      String outSequenceId = offer.getIdentifer().getIdentifier();

      if (outSequenceId != null && !"".equals(outSequenceId)) {

        Accept accept = new Accept(factory,rmNamespaceValue,addressingNamespaceValue);
        EndpointReference acksToEPR = createSeqMessage.getTo();
        AcksTo acksTo = new AcksTo(factory,rmNamespaceValue,addressingNamespaceValue);
        Address address = new Address(factory,addressingNamespaceValue);
        address.setEpr(acksToEPR);
        acksTo.setAddress(address);
        accept.setAcksTo(acksTo);
        response.setAccept(accept);
      }

    }

    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    response.toOMElement(envelope.getBody());
    outMessage.setWSAAction(SpecSpecificConstants.getCreateSequenceResponseAction(SandeshaUtil.getRMVersion(newSequenceID,configurationContext)));
    outMessage.setSoapAction(SpecSpecificConstants.getCreateSequenceResponseSOAPAction(SandeshaUtil.getRMVersion(newSequenceID,configurationContext)));
    outMessage.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,addressingNamespaceValue);
   
    String newMessageId = SandeshaUtil.getUUID();
View Full Code Here

    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropretyBeanMgr();
   
    String sequenceID = null;
   
    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
    TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
    TerminateSequenceResponse terminateSequenceResponse = (TerminateSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
    SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    AckRequested ackRequest = (AckRequested) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
    CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
    CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
   
    //Setting message type.
    if (createSequence != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
    }else if (createSequenceResponse != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
      sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
    }else if (terminateSequence != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
      sequenceID = terminateSequence.getIdentifier().getIdentifier();
    }else if (terminateSequenceResponse != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
View Full Code Here

   
    //Processing the create sequence response.
   
    Transaction createSeqResponseTransaction = storageManager.getTransaction();
   
    CreateSequenceResponse createSeqResponsePart = (CreateSequenceResponse) createSeqResponseRMMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
    if (createSeqResponsePart == null) {
      String message = "Create Sequence Response part is null";
      log.debug(message);
      throw new SandeshaException(message);
    }

    String newOutSequenceId = createSeqResponsePart.getIdentifier()
        .getIdentifier();
    if (newOutSequenceId == null) {
      String message = "New sequence Id is null";
      log.debug(message);
      throw new SandeshaException(message);
    }

    RelatesTo relatesTo = createSeqResponseRMMsgCtx.getMessageContext()
                    .getRelatesTo();
    if (relatesTo==null) {
      String message = "Invalid create sequence message. RelatesTo part is not available";
      log.error("Invalid create sequence response message. RelatesTo part is not available");
      throw new SandeshaException ("Invalid create sequence message. RelatesTo part is not available");
    }
    String createSeqMsgId = relatesTo.getValue();


    SenderBeanMgr retransmitterMgr = storageManager
        .getRetransmitterBeanMgr();
    CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();

    CreateSeqBean createSeqBean = createSeqMgr.retrieve(createSeqMsgId);
    if (createSeqBean == null) {
      String message = "Create Sequence entry is not found";
      log.debug(message);
      throw new SandeshaException(message);
    }

    String internalSequenceId = createSeqBean.getInternalSequenceID();
    if (internalSequenceId == null || "".equals(internalSequenceId)) {
      String message = "TempSequenceId has is not set";
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    createSeqBean.setSequenceID(newOutSequenceId);
    createSeqMgr.update(createSeqBean);

    //deleting the create sequence entry.
    retransmitterMgr.delete(createSeqMsgId);

    //storing new out sequence id
    SequencePropertyBeanMgr sequencePropMgr = storageManager
        .getSequencePropretyBeanMgr();
    SequencePropertyBean outSequenceBean = new SequencePropertyBean(
        internalSequenceId, Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID,
        newOutSequenceId);
    SequencePropertyBean internalSequenceBean = new SequencePropertyBean(
        newOutSequenceId,
        Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, internalSequenceId);
   
   
    sequencePropMgr.insert(outSequenceBean);
    sequencePropMgr.insert(internalSequenceBean);

    createSeqResponseTransaction.commit();
   
   
    Transaction offerProcessTransaction = storageManager.getTransaction();
   
    //processing for accept (offer has been sent)
    Accept accept = createSeqResponsePart.getAccept();
    if (accept != null) {
      //Find offered sequence from internal sequence id.
      SequencePropertyBean offeredSequenceBean = sequencePropMgr
          .retrieve(internalSequenceId,
              Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
View Full Code Here

    if(log.isDebugEnabled()) log.debug("Entry: RMMsgCreator::createCreateSeqResponseMsg " + rmSequenceBean);
   
    CreateSequence cs = createSeqMessage.getCreateSequence();
    String namespace = createSeqMessage.getRMNamespaceValue();

    CreateSequenceResponse response = new CreateSequenceResponse(namespace);
    Identifier identifier = new Identifier(namespace);
    identifier.setIndentifer(rmSequenceBean.getSequenceID());
    response.setIdentifier(identifier);

    SequenceOffer offer = cs.getSequenceOffer();
    if (offer != null) {
      if(log.isDebugEnabled()) log.debug("RMMsgCreator:: " + offer);
      String outSequenceId = offer.getIdentifer().getIdentifier();

      if (outSequenceId != null && !"".equals(outSequenceId)) {

        Accept accept = new Accept(namespace);

        // Putting the To EPR as the AcksTo for the response sequence. We echo back the
        // addressing version that the create used.
        String addressingNamespace = cs.getAddressingNamespaceValue();
        EndpointReference acksToEPR = createSeqMessage.getTo();
        if(acksToEPR != null) {
          acksToEPR = SandeshaUtil.cloneEPR(acksToEPR);
        } else {
          String anon = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
          acksToEPR = new EndpointReference(anon);
        }
       
        AcksTo acksTo = new AcksTo(acksToEPR, namespace, cs.getAddressingNamespaceValue());
        accept.setAcksTo(acksTo);
        response.setAccept(accept);
      }
    }

    String version = SpecSpecificConstants.getSpecVersionString(namespace);
    String action = SpecSpecificConstants.getCreateSequenceResponseAction(version);
View Full Code Here

    rmMsgContext.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());

    String sequenceID = null;

    CreateSequence createSequence = rmMsgContext.getCreateSequence();
    CreateSequenceResponse createSequenceResponse = rmMsgContext.getCreateSequenceResponse();
    TerminateSequence terminateSequence = rmMsgContext.getTerminateSequence();
    TerminateSequenceResponse terminateSequenceResponse = rmMsgContext.getTerminateSequenceResponse();
    Iterator<SequenceAcknowledgement> sequenceAcknowledgementsIter = rmMsgContext.getSequenceAcknowledgements();
    Sequence sequence = rmMsgContext.getSequence();
    Iterator<AckRequested> ackRequestedIter = rmMsgContext.getAckRequests();
    CloseSequence closeSequence = rmMsgContext.getCloseSequence();
    CloseSequenceResponse closeSequenceResponse = rmMsgContext.getCloseSequenceResponse();
    MakeConnection makeConnection = rmMsgContext.getMakeConnection();
   
    String rmNamespace = null;

    if (createSequence != null) {
      rmNamespace = createSequence.getNamespaceValue();
    }

    if (createSequenceResponse != null) {
      rmNamespace = createSequenceResponse.getNamespaceValue();
    }

    if (sequence != null) {
      rmNamespace = sequence.getNamespaceValue();
    }

    //In case of ack messages RM Namespace is decided based on the sequenceId of the last
    //sequence Ack. In other words Sandesha2 does not expect to receive two SequenceAcknowledgements
    //of different RM specifications in the same incoming message
    while(sequenceAcknowledgementsIter.hasNext()){
      SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) sequenceAcknowledgementsIter.next();
      rmNamespace = sequenceAck.getNamespaceValue();
    }

    if (terminateSequence != null) {
      rmNamespace = terminateSequence.getNamespaceValue();
    }

    if (terminateSequenceResponse != null) {
      rmNamespace = terminateSequenceResponse.getNamespaceValue();
    }

    //In case of ack request messages RM Namespace is decided based on the sequenceId of the last
    //ack request.
    while(ackRequestedIter.hasNext()){
      AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
      rmNamespace = ackRequest.getNamespaceValue();
    }

    if (closeSequence != null) {
      rmNamespace = closeSequence.getNamespaceValue();
    }

    if (closeSequenceResponse != null) {
      rmNamespace = closeSequenceResponse.getNamespaceValue();
    }
   
    if (makeConnection != null) {
      if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnection.getNamespaceValue()))
        rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
    }
   
    if (rmMsgContext.getMessagePending() != null) {
      //MessagePending only supported in 1.1 namespace... no need to check the namespace value
      rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
    }
    if (rmNamespace!=null)
      rmMsgContext.setRMNamespaceValue(rmNamespace);
     
    sequenceAcknowledgementsIter = rmMsgContext.getSequenceAcknowledgements();
    ackRequestedIter = rmMsgContext.getAckRequests();
   
    // Setting message type.
    if (createSequence != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
    } else if (createSequenceResponse != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
      sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
    } else if (terminateSequence != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
      sequenceID = terminateSequence.getIdentifier().getIdentifier();
    } else if (terminateSequenceResponse != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
View Full Code Here

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

    // Processing the create sequence response.

    CreateSequenceResponse createSeqResponsePart = createSeqResponseRMMsgCtx.getCreateSequenceResponse();
    if (createSeqResponsePart == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqResponse);
      log.debug(message);
      throw new SandeshaException(message);
    }

    String newOutSequenceId = createSeqResponsePart.getIdentifier().getIdentifier();
    if (newOutSequenceId == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.newSeqIdIsNull);
      log.debug(message);
      throw new SandeshaException(message);
    }

    RelatesTo relatesTo = createSeqResponseRMMsgCtx.getMessageContext().getRelatesTo();
    String createSeqMsgId = null;
    if (relatesTo != null) {
      createSeqMsgId = relatesTo.getValue();
    } else {
      // Work out the related message from the operation context
      OperationContext context = createSeqResponseRMMsgCtx.getMessageContext().getOperationContext();
      MessageContext createSeq = context.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
      if(createSeq != null) createSeqMsgId = createSeq.getMessageID();
    }
    if(createSeqMsgId == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.relatesToNotAvailable);
      log.error(message);
      throw new SandeshaException(message);
    }

    SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();
    RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();

    RMSBean rmsBean = rmsBeanMgr.retrieve(createSeqMsgId);
    if (rmsBean == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    //Need to see if the seqID is a dupe of one that already exists
    //If it is we can't accept the CSR, so will do nothing so that a new CreateSeq msg is sent
    RMSBean finderBean = new RMSBean ();
    finderBean.setSequenceID(newOutSequenceId);
    RMSBean rmsBeanWithDuplicateSeqID = storageManager.getRMSBeanMgr().findUnique(finderBean);
    if(rmsBeanWithDuplicateSeqID != null){
      if (log.isDebugEnabled())
        log.debug("Duplicate SeqID: " + newOutSequenceId + " so we can't accept the CSR, will terminate this seq and reallocate to a new seq");
      return false;
    }

    // Check that the create sequence response message proves possession of the correct token
    MessageContext msgCtx = createSeqResponseRMMsgCtx.getMessageContext();
    SandeshaUtil.assertProofOfPossession(rmsBean, msgCtx, msgCtx.getEnvelope().getBody());

    String internalSequenceId = rmsBean.getInternalSequenceID();
    if (internalSequenceId == null || "".equals(internalSequenceId)) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.tempSeqIdNotSet);
      log.debug(message);
      throw new SandeshaException(message);
    }
    createSeqResponseRMMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceId);
   
    // Check to see if we have already received a sequence id. If we have then this response is redundant,
    // and we can forget about it.
    // TODO: Should we terminate or close the extra sequence? We can only do that if the new sequence
    // id is different from the one we got back the first time. For now it should be enough to just
    // ignore it, and let it time out.
    if(rmsBean.getSequenceID() != null) {
      if(log.isDebugEnabled())
        log.debug("Exit: CreateSeqResponseMsgProcessor::processInMessage, sequence id is already set. " +
            "Existing id:" + rmsBean.getSequenceID() + ", new id:" + newOutSequenceId);
      return false;
    }
     
    // Store the new sequence id
    rmsBean.setSequenceID(newOutSequenceId);

    // We should poll for any reply-to that uses the anonymous URI, when MakeConnection
    // is enabled.
    if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqResponseRMMsgCtx.getRMSpecVersion())) {
      SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(configCtx.getAxisConfiguration());
      if(policy.isEnableMakeConnection()) {
        EndpointReference reference = rmsBean.getAcksToEndpointReference();
        if(reference == null || reference.hasAnonymousAddress()) {
          rmsBean.setPollingMode(true);
        }
      }
    }
     
    rmsBean.setLastActivatedTime(System.currentTimeMillis());
   
    if(!rmsBeanMgr.update(rmsBean)){     
      //Im not setting the createSeqBean sender bean to resend true as the reallocation of msgs will do this
      try{
        TerminateManager.terminateSendingSide(rmsBean, storageManager, true, transaction);
      } catch(Exception e){
        if (log.isDebugEnabled())
          log.debug(e);         
      }
    } else {
      // processing for accept (offer has been sent)
      Accept accept = createSeqResponsePart.getAccept();
      if (accept != null) {

        // TODO this should be detected in the Fault manager.
        if (rmsBean.getOfferedSequence() == null) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.accptButNoSequenceOffered);
View Full Code Here

      createSeqResponse.setFlow(MessageContext.OUT_FLOW);
 
      // for making sure that this won't be processed again
      createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
     
      CreateSequenceResponse createSeqResPart = createSeqResponse.getCreateSequenceResponse();
 
      // OFFER PROCESSING
      SequenceOffer offer = createSeqPart.getSequenceOffer();
      if (offer != null) {
        Accept accept = createSeqResPart.getAccept();
        if (accept == null) {
          if (log.isDebugEnabled())
            log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart));
          FaultManager.makeCreateSequenceRefusedFault(createSeqRMMsg, SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart),
                                new Exception(),
                                null);
          // Return false if an Exception hasn't been thrown.
          if (log.isDebugEnabled())
            log.debug("Exit: CreateSeqMsgProcessor::processInMessage " + Boolean.FALSE);       
          return false;
        }
 
        // offered seq id
        String offeredSequenceID = offer.getIdentifer().getIdentifier();

        //Need to see if this is a duplicate offer.
        //If it is we can't accept the offer as we can't be sure it has come from the same client.
        RMSBean finderBean = new RMSBean ();
        finderBean.setSequenceID(offeredSequenceID);
        RMSBean rMSBean = storageManager.getRMSBeanMgr().findUnique(finderBean);
        boolean offerAccepted = false;
        String outgoingSideInternalSequenceId = SandeshaUtil
          .getOutgoingSideInternalSequenceID(rmdBean.getSequenceID());

        if(rMSBean != null){
          if (log.isDebugEnabled())
            log.debug("Duplicate offer so we can't accept as we can't be sure it's from the same client: " + offeredSequenceID);
          offerAccepted = false;
        } else {
          boolean isValidseqID = isValidseqID(offeredSequenceID, context, createSeqRMMsg, storageManager);
          offerAccepted = true;
       
          //Before processing this offer any further we need to perform some extra checks
          //on the offered EP if WS-RM Spec 1.1 is being used
          if(isValidseqID && Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(rmdBean.getRMVersion())){
            Endpoint endpoint = offer.getEndpoint();
            if (endpoint!=null) {
              //Check to see if the offer endpoint has a value of WSA Anonymous
              String addressingNamespace = (String) createSeqRMMsg.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
              String endpointAddress = endpoint.getEPR().getAddress();
              if(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace).equals(endpointAddress)){
                //We will still accept this offer but we should warn the user that this MEP is not always reliable or efficient
                if (log.isDebugEnabled())
                  log.debug("CSeq msg contains offer with an anonymous EPR")
                log.warn(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.sequenceMEPWarning, createSeqRMMsg.getMessageContext().getMessageID(),
                    offeredSequenceID));
              }
              rMSBean = new RMSBean();
              //Set the offered EP
              rMSBean.setOfferedEndPointEPR(endpoint.getEPR());
           
            } else {
              //Don't accept the offer
              if (log.isDebugEnabled())
                log.debug("Offer Refused as it included a null endpoint")
              offerAccepted = false;
            }
          } else if (isValidseqID && Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(rmdBean.getRMVersion())){
            rMSBean = new RMSBean();
          }
          if(isValidseqID){
            // Setting the CreateSequence table entry for the outgoing
            // side.
            rMSBean.setSequenceID(offeredSequenceID)
            rMSBean.setInternalSequenceID(outgoingSideInternalSequenceId);
            // this is a dummy value
            rMSBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
         
            //Try inserting the new RMSBean
            if(!storageManager.getRMSBeanMgr().insert(rMSBean)){
              offerAccepted = false;
            }
          }
        }

        if (offerAccepted) {
          if(rmdBean.getToEndpointReference() != null){
            rMSBean.setToEndpointReference(rmdBean.getToEndpointReference());
          } else {
            //It's Sync2Way so set to address to anonymous when spec 1.0 is used
            String specVersion = rmdBean.getRMVersion();
            if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(specVersion)) {
              rMSBean.setToEndpointReference(new EndpointReference(AddressingConstants.Submission.WSA_ANONYMOUS_URL));
            }  
          }
         
          rMSBean.setAcksToEndpointReference(rmdBean.getReplyToEndpointReference())// The acks need to flow back into this endpoint
          rMSBean.setReplyToEndpointReference(rmdBean.getReplyToEndpointReference());
          rMSBean.setLastActivatedTime(System.currentTimeMillis());
          rMSBean.setRMVersion(rmdBean.getRMVersion());
          rMSBean.setClientCompletedMessages(new RangeString());
 
          // Setting sequence properties for the outgoing sequence.
          // Only will be used by the server side response path. Will
          // be wasted properties for the client side.
   
          rmdBean.setOutboundInternalSequence(outgoingSideInternalSequenceId);
          RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
          rmdBeanMgr.update(rmdBean);
 
          // Store the inbound token (if any) with the new sequence
          rMSBean.setSecurityTokenData(rmdBean.getSecurityTokenData());
         
          // If this new sequence has anonymous acksTo, then we must poll for the acks
          // If the inbound sequence is targetted at the WSRM anonymous URI, we need to start
          // polling for this sequence.
          EndpointReference reference = rMSBean.getAcksToEndpointReference();
          if ((reference == null || reference.hasAnonymousAddress()) &&
            Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqRMMsg.getRMSpecVersion())) {
            rMSBean.setPollingMode(true);
          }
         
          // Set the SOAP Version for this sequence.
          rMSBean.setSoapVersion(SandeshaUtil.getSOAPVersion(createSeqRMMsg.getSOAPEnvelope()));

          storageManager.getRMSBeanMgr().update(rMSBean);
         
          SandeshaUtil.startWorkersForSequence(context, rMSBean);
         
        } else {
          // removing the accept part.
          createSeqResPart.setAccept(null);
          createSeqResponse.addSOAPEnvelope();
        }
      }
             
      //TODO add createSequenceResponse message as the referenceMessage to the RMDBean.
View Full Code Here

          createSequence.fromOMElement(body);
        } else if(Sandesha2Constants.SPEC_2005_02.QNames.CreateSequence.equals(firstBodyQName)) {
          createSequence = new CreateSequence(namespace);
          createSequence.fromOMElement(body);
        } else if(Sandesha2Constants.SPEC_2007_02.QNames.CreateSequenceResponse.equals(firstBodyQName)) {
          createSequenceResponse = new CreateSequenceResponse(namespace);
          createSequenceResponse.fromOMElement(body);
        } else if(Sandesha2Constants.SPEC_2005_02.QNames.CreateSequenceResponse.equals(firstBodyQName)) {
          createSequenceResponse = new CreateSequenceResponse(namespace);
          createSequenceResponse.fromOMElement(body);
        } else if(Sandesha2Constants.SPEC_2007_02.QNames.CloseSequence.equals(firstBodyQName)) {
          closeSequence = new CloseSequence(namespace);
          closeSequence.fromOMElement(body);
        } else if(Sandesha2Constants.SPEC_2005_02.QNames.CloseSequence.equals(firstBodyQName)) {
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.wsrm.CreateSequenceResponse

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.