Examples of MakeConnection


Examples of org.apache.sandesha2.wsrm.MakeConnection

    messageContext = makeConnectionRMMessage.getMessageContext();
    messageContext
            .setWSAAction(SpecSpecificConstants
                    .getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));

    MakeConnection makeConnectionPart = makeConnectionRMMessage.getMakeConnection();

    QName name = new QName(AddressingConstants.Final.WSA_NAMESPACE, "BAD_ONE");
    makeConnectionPart.setUnexpectedElement(name);

    // Update the SOAP Envelope of the message
    makeConnectionRMMessage.addSOAPEnvelope();

    SOAPEnvelope envelope = makeConnectionRMMessage.getMessageContext()
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

    messageContext = makeConnectionRMMessage.getMessageContext();
    messageContext
            .setWSAAction(SpecSpecificConstants
                    .getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));

    MakeConnection makeConnectionPart = makeConnectionRMMessage.getMakeConnection();

    makeConnectionPart.setIdentifier(null);
    makeConnectionPart.setAddress(null);

    // Update the SOAP Envelope of the message
    makeConnectionRMMessage.addSOAPEnvelope();

    SOAPEnvelope envelope = makeConnectionRMMessage.getMessageContext()
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

        referenceMessage.getAxisService());

    MessageContext makeConnectionMessageCtx = SandeshaUtil.createNewRelatedMessageContext(referenceRMMessage,makeConnectionOperation);
    RMMsgContext makeConnectionRMMessageCtx = MsgInitializer.initializeMessage(makeConnectionMessageCtx);
   
    MakeConnection makeConnection = new MakeConnection();
    if (makeConnectionSeqId!=null) {
      Identifier identifier = new Identifier (rmNamespaceValue);
      identifier.setIndentifer(makeConnectionSeqId);
      makeConnection.setIdentifier(identifier);
    }
   
    if (makeConnectionAnonURI!=null) {
      makeConnection.setAddress(makeConnectionAnonURI);
    }
   
    // Setting the addressing properties. As this is a poll we must send it to an non-anon
    // EPR, so we check both To and ReplyTo from the reference message
    EndpointReference epr = referenceMessage.getTo();
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

    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);
      sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
    } else if (sequence != null) {
     
      Sequence seq = rmMsgContext.getSequence();
      boolean lastMessage = seq.getLastMessage();
      SOAPEnvelope envelope = rmMsgContext.getSOAPEnvelope();
     
      if (lastMessage && envelope.getBody().getFirstOMChild()==null) {
        //the message is an empty body last message
        rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
      }else
        rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
     
      sequenceID = sequence.getIdentifier().getIdentifier();
    } else if (makeConnection != null){
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);
      if (makeConnection.getIdentifier()!=null) {
        sequenceID = makeConnection.getIdentifier().getIdentifier();
      } else if (makeConnection.getAddress()!=null){
        //TODO get sequenceId based on the anonymous address.
      }
    } else if (ackRequestedIter.hasNext()) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
      AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

    if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
      log.debug("Enter: MakeConnectionProcessor::processInMessage " + rmMsgCtx.getSOAPEnvelope().getBody());

    try {

      MakeConnection makeConnection = rmMsgCtx.getMakeConnection();

      String address = makeConnection.getAddress();
      Identifier identifier = makeConnection.getIdentifier();

      // If there is no address or identifier - make the MissingSelection Fault.
      if (address == null && identifier == null)
        FaultManager.makeMissingSelectionFault(rmMsgCtx);

      if (makeConnection.getUnexpectedElement() != null)
        FaultManager.makeUnsupportedSelectionFault(rmMsgCtx, makeConnection.getUnexpectedElement());

      //some initial setup
      ConfigurationContext configurationContext = rmMsgCtx.getConfigurationContext();
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext, configurationContext.getAxisConfiguration());
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configurationContext);
      SecurityToken token = secManager.getSecurityToken(rmMsgCtx.getMessageContext());

      //we want to find valid sender beans
      List<RMSequenceBean> possibleBeans = new ArrayList<RMSequenceBean>();
      int possibleBeanIndex = -10;
      SenderBean findSenderBean = new SenderBean();
      boolean secured = false;
      if (token != null && identifier == null) {
        secured = true;
        if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("token found " + token);
        //this means we have to scope our search for sender beans that belong to sequences that own the same token
        String data = secManager.getTokenRecoveryData(token);
        //first look for RMS beans
        RMSBean finderRMS = new RMSBean();
        finderRMS.setSecurityTokenData(data);
        finderRMS.setToEPR(address);
        List<RMSBean> tempList2 = storageManager.getRMSBeanMgr().find(finderRMS);
        possibleBeans.addAll(tempList2);

        //try looking for RMD beans too
        RMDBean finderRMD = new RMDBean();
        finderRMD.setSecurityTokenData(data);
        finderRMD.setToAddress(address);
        List<RMDBean> tempList = storageManager.getRMDBeanMgr().find(finderRMD);

        //combine these two into one list
        possibleBeans.addAll(tempList);

        int size = possibleBeans.size();

        if (size > 0) {
          //select one at random: TODO better method?
          Random random = new Random();
          possibleBeanIndex = random.nextInt(size);
          RMSequenceBean selectedSequence = (RMSequenceBean) possibleBeans.get(possibleBeanIndex);
          findSenderBean.setSequenceID(selectedSequence.getSequenceID());
          if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
            log.debug("sequence selected " + findSenderBean.getSequenceID());
        } else {
          //we cannot match a RMD with the correct security credentials so we cannot process this msg under RSP
          if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
            log.debug("Exit: MakeConnectionProcessor::processInMessage : no RM sequence bean with security credentials");
          return false;
        }

        // Commit this transaction to clear up held RMS/RMDBeans
        if (transaction != null && transaction.isActive())
          transaction.commit();

        // Get a new transaction
        transaction = storageManager.getTransaction();
      }

      //lookup a sender bean
      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      //selecting the set of SenderBeans that suit the given criteria.
      findSenderBean.setSend(true);
      findSenderBean.setTransportAvailable(false);

      if (address != null)
        findSenderBean.setToAddress(address);

      if (identifier != null) {
        if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
          log.debug("identifier set, this violates RSP " + identifier);
        findSenderBean.setSequenceID(identifier.getIdentifier());
      }

      SenderBean senderBean = null;
      boolean pending = false;
      while (true) {
        // Set the time to send field to be now
        findSenderBean.setTimeToSend(System.currentTimeMillis());

        //finding the beans that go with the criteria of the passed SenderBean
        //The reSend flag is ignored for this selection, so there is no need to
        //set it.
        Collection<SenderBean> collection = senderBeanMgr.find(findSenderBean);

        //removing beans that does not pass the resend test
        for (Iterator<SenderBean> it = collection.iterator(); it.hasNext();) {
          SenderBean bean = (SenderBean) it.next();
          if (!bean.isReSend() && bean.getSentCount() > 0)
            it.remove();
        }

        //selecting a bean to send RANDOMLY. TODO- Should use a better mechanism.
        int size = collection.size();
        int itemToPick = -1;

        pending = false;
        if (size > 0) {
          Random random = new Random();
          itemToPick = random.nextInt(size);
        }

        if (size > 1)
          pending = true//there are more than one message to be delivered using the makeConnection.
        //So the MessagePending header should have value true;

        Iterator<SenderBean> it = collection.iterator();

        senderBean = null;
        for (int item = 0; item < size; item++) {
          senderBean = (SenderBean) it.next();
          if (item == itemToPick)
            break;
        }

        if (senderBean == null) {
          //If secured try another sequence
          //Remove old one from the list and pick another random one
          if (secured) {
            possibleBeans.remove(possibleBeanIndex);
            int possBeansSize = possibleBeans.size();

            if (possBeansSize > 0) {
              //select one at random: TODO better method?
              Random random = new Random();
              possibleBeanIndex = random.nextInt(possBeansSize);
              RMSequenceBean selectedSequence = (RMSequenceBean) possibleBeans.get(possibleBeanIndex);
              findSenderBean.setSequenceID(selectedSequence.getSequenceID());
              if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
                log.debug("sequence selected " + findSenderBean.getSequenceID());
            } else {
              if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
                log.debug("Exit: MakeConnectionProcessor::processInMessage, no matching message found");
              return false;
            }
          } else {
            if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
              log.debug("Exit: MakeConnectionProcessor::processInMessage, no matching message found");
            // this property indicate synapse nhttp transport to send a 202 Accepted header
                        rmMsgCtx.getMessageContext().setProperty("FORCE_SC_ACCEPTED", Constants.VALUE_TRUE);
            return false;
          }
        } else {
          break;
        }
      }

      if (transaction != null && transaction.isActive()) {
        transaction.commit();
        transaction = storageManager.getTransaction();
      }
      replyToPoll(rmMsgCtx, senderBean, storageManager, pending, makeConnection.getNamespaceValue(), transaction);

    } finally {
      if (transaction != null && transaction.isActive()) {
        transaction.rollback();
      }
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

        } else if(Sandesha2Constants.SPEC_2005_02.QNames.TerminateSequenceResponse.equals(firstBodyQName)) {
          terminateSequenceResponse = new TerminateSequenceResponse(namespace);
          terminateSequenceResponse.fromOMElement(body);
        }
      }else if(Sandesha2Constants.SPEC_2007_02.QNames.MakeConnection.equals(firstBodyQName)) {
        makeConnection = new MakeConnection();
        makeConnection.fromOMElement(firstBodyElement);
      }
    }
    }
  }
View Full Code Here

Examples of org.apache.sandesha2.wsrm.MakeConnection

        } else if(Sandesha2Constants.SPEC_2005_02.QNames.TerminateSequenceResponse.equals(firstBodyQName)) {
          terminateSequenceResponse = new TerminateSequenceResponse(namespace);
          terminateSequenceResponse.fromOMElement(body);
        }
      }else if(Sandesha2Constants.SPEC_2007_02.QNames.MakeConnection.equals(firstBodyQName)) {
        makeConnection = new MakeConnection();
        makeConnection.fromOMElement(firstBodyElement);
      }
    }
    }
  }
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.