Package org.apache.sandesha2.storage.beanmanagers

Examples of org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr


   * @throws SandeshaException
   */
  public static String getRMVersion(String propertyKey, StorageManager storageManager)
      throws SandeshaException {

    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
    SequencePropertyBean specVersionBean = sequencePropertyBeanMgr.retrieve(propertyKey,
        Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);

    if (specVersionBean == null)
      return null;

View Full Code Here


    return specVersionBean.getValue();
  }

  public static String getSequenceProperty(String id, String name, StorageManager storageManager)
      throws SandeshaException {
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();

    SequencePropertyBean sequencePropertyBean = sequencePropertyBeanMgr.retrieve(id, name);
    if (sequencePropertyBean == null)
      return null;
    else
      return sequencePropertyBean.getValue();
  }
View Full Code Here

    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();
View Full Code Here

    Options options = msgContext.getOptions();

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

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = ackRequestRMMsg.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);
View Full Code Here

  private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    ConfigurationContext configContext = rmMsgCtx.getMessageContext().getConfigurationContext();
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, axisConfiguration);
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();

    String sequenceID = null;

    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ);
View Full Code Here

      throw new AxisFault(message);
    }

    ConfigurationContext configurationContext = createSequenceMsg.getMessageContext().getConfigurationContext();

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    SequencePropertyBean receivedMsgBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");

    // setting the addressing version
    String addressingNamespaceValue = createSequenceMsg.getAddressingNamespaceValue();
    SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespaceValue);
    seqPropMgr.insert(addressingNamespaceBean);

    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceValue);

    // If no replyTo value. Send responses as sync.
    SequencePropertyBean toBean = null;
    if (replyTo != null) {
      toBean = new SequencePropertyBean(sequenceId, Sandesha2Constants.SequenceProperties.TO_EPR, replyTo
          .getAddress());
    } else {
      toBean = new SequencePropertyBean(sequenceId, Sandesha2Constants.SequenceProperties.TO_EPR, anonymousURI);
    }

    SequencePropertyBean replyToBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, to.getAddress());
    SequencePropertyBean acksToBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo.getAddress());

    seqPropMgr.insert(receivedMsgBean);
    seqPropMgr.insert(replyToBean);
    seqPropMgr.insert(acksToBean);

    if (toBean != null)
      seqPropMgr.insert(toBean);

    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
    rmdBeanMgr.insert(new RMDBean(sequenceId, 1)); // 1 will be the
                              // next

    // message to invoke. This will apply for only in-order invocations.

    SandeshaUtil.startSenderForTheSequence(configurationContext, sequenceId);

    // stting the RM SPEC version for this sequence.
    String createSequenceMsgAction = createSequenceMsg.getWSAAction();
    if (createSequenceMsgAction == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noWSAACtionValue));

    String messageRMNamespace = createSequence.getNamespaceValue();

    String specVersion = null;
    if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
    } else if (Sandesha2Constants.SPEC_2006_08.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
    } else {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));
    }

    SequencePropertyBean specVerionBean = new SequencePropertyBean();
    specVerionBean.setSequencePropertyKey(sequenceId);
    specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
    specVerionBean.setValue(specVersion);

    seqPropMgr.insert(specVerionBean);

    // TODO get the SOAP version from the create seq message.

    return sequenceId;
  }
View Full Code Here

  public static void setupNewClientSequence(MessageContext firstAplicationMsgCtx, String sequencePropertyKey,
      String specVersion, StorageManager storageManager) throws SandeshaException {

    ConfigurationContext configurationContext = firstAplicationMsgCtx.getConfigurationContext();

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    // setting the addressing version
    String addressingNamespace = (String) firstAplicationMsgCtx
        .getProperty(AddressingConstants.WS_ADDRESSING_VERSION);

    if (addressingNamespace == null) {
      OperationContext opCtx = firstAplicationMsgCtx.getOperationContext();
      if (opCtx != null) {
        try {
          MessageContext requestMsg = opCtx.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
          if (requestMsg != null)
            addressingNamespace = (String) requestMsg
                .getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
        } catch (AxisFault e) {
          throw new SandeshaException(e);
        }
      }
    }

    if (addressingNamespace == null)
      addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE; // defaults
                                      // to
                                      // Final.
                                      // Make
                                      // sure
                                      // this
                                      // is
                                      // synchronized
                                      // with
                                      // addressing.

    SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespace);
    seqPropMgr.insert(addressingNamespaceBean);
   
   
    //setting the SOAPVersion Bean.
    String SOAPVersion = firstAplicationMsgCtx.getOptions().getSoapVersionURI();
    SequencePropertyBean SOAPVersionBean = new SequencePropertyBean (sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.SOAP_VERSION, SOAPVersion);
   
    seqPropMgr.insert(SOAPVersionBean);
   

    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);

    EndpointReference toEPR = firstAplicationMsgCtx.getTo();
    String acksTo = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.AcksTo);

    if (toEPR == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
      log.debug(message);
      throw new SandeshaException(message);
    }

    SequencePropertyBean toBean = new SequencePropertyBean(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.TO_EPR, toEPR.getAddress());
    SequencePropertyBean replyToBean = null;
    SequencePropertyBean acksToBean = null;

    if (firstAplicationMsgCtx.isServerSide()) {
      // setting replyTo value, if this is the server side.
      OperationContext opContext = firstAplicationMsgCtx.getOperationContext();
      try {
        MessageContext requestMessage = opContext
            .getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
        if (requestMessage == null) {
          String message = SandeshaMessageHelper
              .getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
          log.error(message);
          throw new SandeshaException(message);
        }

        EndpointReference replyToEPR = requestMessage.getTo(); // 'replyTo'
                                    // of
                                    // the
                                    // response
                                    // msg
                                    // is
                                    // the
                                    // 'to'
                                    // value
                                    // of
                                    // the
                                    // req
                                    // msg.
        if (replyToEPR != null) {
          replyToBean = new SequencePropertyBean(sequencePropertyKey,
              Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, replyToEPR.getAddress());
          acksToBean = new SequencePropertyBean(sequencePropertyKey,
              Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, replyToEPR.getAddress());
        } else {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
          log.error(message);
          throw new SandeshaException(message);
        }
      } catch (AxisFault e) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
        log.error(message);
        log.error(e.getStackTrace());
        throw new SandeshaException(message);
      }
    } else {
     
      EndpointReference replyToEPR = firstAplicationMsgCtx.getReplyTo();
      //setting replyTo and acksTo beans.
         
      if (replyToEPR!=null)   
        replyToBean = new SequencePropertyBean(sequencePropertyKey,
            Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, replyToEPR.getAddress());
     
   
      //TODO set AcksToBean.
    }
   
    // Default value for acksTo is anonymous (this happens only for the
    // client side)
    if (acksTo == null) {
      acksTo = anonymousURI;
    }

    acksToBean = new SequencePropertyBean(sequencePropertyKey, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
        acksTo);

    // start the in listner for the client side, if acksTo is not anonymous.
    if (!firstAplicationMsgCtx.isServerSide() && !anonymousURI.equals(acksTo)) {

      String transportInProtocol = firstAplicationMsgCtx.getOptions().getTransportInProtocol();
      if (transportInProtocol == null) {
        throw new SandeshaException(SandeshaMessageHelper
            .getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
      }

      try {
        ListenerManager listenerManager = firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
        TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext()
            .getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
        // if acksTo is not anonymous start the in-transport
        if (!listenerManager.isListenerRunning(transportIn.getName().getLocalPart())) {
          listenerManager.addListener(transportIn, false);
        }
      } catch (AxisFault e) {
        throw new SandeshaException(SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString()), e);
      }

    }

    SequencePropertyBean msgsBean = new SequencePropertyBean();
    msgsBean.setSequencePropertyKey(sequencePropertyKey);
    msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
    msgsBean.setValue("");

    seqPropMgr.insert(msgsBean);

    seqPropMgr.insert(toBean);
    if (acksToBean != null)
      seqPropMgr.insert(acksToBean);
    if (replyToBean != null)
      seqPropMgr.insert(replyToBean);

    // saving transportTo value;
    String transportTo = (String) firstAplicationMsgCtx.getProperty(MessageContextConstants.TRANSPORT_URL);
    if (transportTo != null) {
      SequencePropertyBean transportToBean = new SequencePropertyBean();
      transportToBean.setSequencePropertyKey(sequencePropertyKey);
      transportToBean.setName(Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
      transportToBean.setValue(transportTo);

      seqPropMgr.insert(transportToBean);
    }

    // setting the spec version for the client side.
    SequencePropertyBean specVerionBean = new SequencePropertyBean();
    specVerionBean.setSequencePropertyKey(sequencePropertyKey);
    specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
    specVerionBean.setValue(specVersion);
    seqPropMgr.insert(specVerionBean);

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

    SandeshaUtil.startSenderForTheSequence(configurationContext, sequencePropertyKey);
View Full Code Here

    String sequenceId = closeSequence.getIdentifier().getIdentifier();
    String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(rmMsgCtx);
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());
    SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropertyBeanMgr();
   
    // Check that the sender of this CloseSequence holds the correct token
    SequencePropertyBean tokenBean = sequencePropMgr.retrieve(sequenceId, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(msgCtx.getConfigurationContext());
      OMElement body = msgCtx.getEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
      secManager.checkProofOfPossession(token, body, msgCtx);
    }

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

    SequencePropertyBean sequenceClosedBean = new SequencePropertyBean();
    sequenceClosedBean.setSequencePropertyKey(sequencePropertyKey);
    sequenceClosedBean.setName(Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED);
    sequenceClosedBean.setValue(Sandesha2Constants.VALUE_TRUE);

    sequencePropMgr.insert(sequenceClosedBean);

    RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx, sequencePropertyKey, sequenceId, storageManager);

    MessageContext ackMsgCtx = ackRMMsgCtx.getMessageContext();
View Full Code Here

    Options options = msgContext.getOptions();

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

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = rmMsgCtx.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);
View Full Code Here

      if (sequenceId != null && msgNo > 0) {
        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(rmMsgContext
                .getMessageContext().getConfigurationContext());
        SequencePropertyBeanMgr seqPropMgr = storageManager
            .getSequencePropretyBeanMgr();
        SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
            sequenceId,
            Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
        if (receivedMsgsBean != null) {
          String receivedMsgStr = (String) receivedMsgsBean
              .getValue();
          ArrayList msgNoArrList = SandeshaUtil
              .getSplittedMsgNoArraylist(receivedMsgStr);

          Iterator iterator = msgNoArrList.iterator();
          while (iterator.hasNext()) {
            String temp = (String) iterator.next();
            String msgNoStr = new Long(msgNo).toString();
            if (msgNoStr.equals(temp)) {
              drop = true;
            }
          }
        }

        if (drop == false) {
          //Checking for RM specific EMPTY_BODY LASTMESSAGE.
          SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
          boolean emptyBody = false;
          if (body.getChildElements().hasNext() == false) {
            emptyBody = true;
          }

          if (emptyBody) {
            if (sequence.getLastMessage() != null) {
              log.info ("Empty Body LastMessage Received");
              drop = true;

              if (receivedMsgsBean == null) {
                receivedMsgsBean = new SequencePropertyBean(
                    sequenceId,
                    Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES,
                    "");
                seqPropMgr.insert(receivedMsgsBean);
              }

              String receivedMsgStr = (String) receivedMsgsBean
                  .getValue();
              if (receivedMsgStr != "" && receivedMsgStr != null)
                receivedMsgStr = receivedMsgStr + ","
                    + Long.toString(msgNo);
              else
                receivedMsgStr = Long.toString(msgNo);

              receivedMsgsBean.setValue(receivedMsgStr);
             
              //TODO correct the syntac into '[received msgs]'
             
              seqPropMgr.update(receivedMsgsBean);

              ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
              ackProcessor.sendAckIfNeeded(rmMsgContext,
                  receivedMsgStr);
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr

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.