Exemplo n.º 1
0
  public Object fromHeaderBlock(SOAPHeaderBlock sequenceAckElement)
      throws OMException, SandeshaException {
    originalSequenceAckElement = sequenceAckElement;
    OMElement identifierPart = null;
    Iterator childElements = sequenceAckElement.getChildElements();
    while (childElements.hasNext()) {
      OMElement element = (OMElement) childElements.next();
      String elementNamespace = element.getQName().getNamespaceURI();
      String elementLocalName = element.getQName().getLocalPart();
      if (namespaceValue.equals(elementNamespace)) {
        if (Sandesha2Constants.WSRM_COMMON.ACK_RANGE.equals(elementLocalName)) {
          String lowerAttribValue =
              element.getAttributeValue(new QName(Sandesha2Constants.WSRM_COMMON.LOWER));
          String upperAttribValue =
              element.getAttributeValue(new QName(Sandesha2Constants.WSRM_COMMON.UPPER));

          if (lowerAttribValue == null || upperAttribValue == null)
            throw new OMException(
                SandeshaMessageHelper.getMessage(
                    SandeshaMessageKeys.noUpperOrLowerAttributesInElement, element.toString()));

          try {
            long lower = Long.parseLong(lowerAttribValue);
            long upper = Long.parseLong(upperAttribValue);
            acknowledgementRangeList.add(new Range(lower, upper));
          } catch (Exception ex) {
            throw new OMException(
                SandeshaMessageHelper.getMessage(
                    SandeshaMessageKeys.ackRandDoesNotHaveCorrectValues, element.toString()));
          }
        } else if (Sandesha2Constants.WSRM_COMMON.NACK.equals(elementLocalName)) {
          try {
            Long nack = Long.valueOf(element.getText());
            nackList.add(nack);
          } catch (Exception ex) {
            throw new OMException(
                SandeshaMessageHelper.getMessage(
                    SandeshaMessageKeys.nackDoesNotContainValidLongValue));
          }
        } else if (Sandesha2Constants.WSRM_COMMON.IDENTIFIER.equals(elementLocalName)) {
          identifierPart = element;
        } else {
          String rmSpecVersion = SpecSpecificConstants.getSpecVersionString(namespaceValue);
          if (SpecSpecificConstants.isAckFinalAllowed(rmSpecVersion)) {
            if (Sandesha2Constants.WSRM_COMMON.FINAL.equals(elementLocalName)) {
              ackFinal = true;
            }
          }
          if (SpecSpecificConstants.isAckNoneAllowed(rmSpecVersion)) {
            if (Sandesha2Constants.WSRM_COMMON.NONE.equals(elementLocalName)) {
              ackNone = true;
            }
          }
        }
      }
    }

    identifier = new Identifier(namespaceValue);
    identifier.fromOMElement(identifierPart);

    // Indicate that we have processed this part of the message.
    sequenceAckElement.setProcessed();
    return this;
  }