Package org.eclipse.wst.wsi.internal.core.analyzer

Examples of org.eclipse.wst.wsi.internal.core.analyzer.AssertionNotApplicableException


  {
    try
    {
      if (!entryContext.getMessageEntry().isMimeContent())
      {
        throw new AssertionNotApplicableException();
      }
      // get the rrot part of a multipart/related message
      Document root = entryContext.getMessageEntryDocument();
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();

      // get an operation matched for the message
      BindingOperation bindingOperation = validator.getOperationMatch(
        entryContext.getEntry().getEntryType(), root);
      // if no one operation matches, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // get the corresponding extensibility elements and message
      List extElems;
      Message message;
      if (MessageEntry.TYPE_REQUEST
        .equals(entryContext.getEntry().getEntryType()))
      {
        extElems = bindingOperation.getBindingInput() == null ? null
          : bindingOperation.getBindingInput().getExtensibilityElements();
        message = bindingOperation.getOperation().getInput() == null ? null
          : bindingOperation.getOperation().getInput().getMessage();
      }
      else
      {
        extElems = bindingOperation.getBindingOutput() == null ? null
          : bindingOperation.getBindingOutput().getExtensibilityElements();
        message = bindingOperation.getOperation().getOutput() == null ? null
          : bindingOperation.getOperation().getOutput().getMessage();
      }

      // If there are no extensibility elements in the WSDL binding operation,
      // the assertion is not applicable
      if (extElems == null || extElems.size() < 1)
        throw new AssertionNotApplicableException();

      // Collecting the names of schema elements that are defined
      // with the ref:swaRef schema type
      List swaRefs = getSwaRefs((ExtensibilityElement)extElems.get(0), message);
      // If such schema elements are not found, the assertion is not applicable
      if (swaRefs.isEmpty())
        throw new AssertionNotApplicableException();

      // Going through all the schema element names
      for (int i = 0; i < swaRefs.size(); i++)
      {
        QName elemName = (QName) swaRefs.get(i);
View Full Code Here


    throws WSIException
  {
    try
    {
      if (validator.isOneWayResponse(entryContext))
        throw new AssertionNotApplicableException();

      // Getting a message document
      Document doc = entryContext.getMessageEntryDocument();

      Element soapOperation = null;
      // If there is a Fault entry or no body entries,
      // the assertion is not applicable
      if (validator.isFault(doc)
        || (soapOperation = validator.getSoapBodyChild(doc)) == null)
        throw new AssertionNotApplicableException();

      // Creating a qualified name of potential SOAP operation
      QName operationQName = new QName(
        soapOperation.getNamespaceURI(), soapOperation.getLocalName());

      // Retrieving all the RPC binding operations from wsdl:binding
      BindingOperation[] rpcBindingOperations =
        validator.getMatchingBindingOps(
          WSIConstants.ATTRVAL_SOAP_BIND_STYLE_RPC,
          validator.analyzerContext.getCandidateInfo().getBindings());

      // Retrieving binding operation by given operation name
      BindingOperation bindingOperation = validator.getOperationMatch(
        entryContext.getEntry().getEntryType(),
        operationQName,
        rpcBindingOperations);

      // If there is no matched operation, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // Finding operation extensibility elems
      // in the binding depending on message type
      List extElems = null;
      if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_REQUEST)
        && bindingOperation.getBindingInput() != null)
      {
        extElems =
          bindingOperation.getBindingInput().getExtensibilityElements();
      }
      else if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_RESPONSE)
        && bindingOperation.getBindingOutput() != null)
      {
        extElems =
          bindingOperation.getBindingOutput().getExtensibilityElements();
      }

      // If the message is not literal, the assertion is not applicable
      if (!validator.isLiteral(extElems))
        throw new AssertionNotApplicableException();

      // Getting the parts attribute from soapbind:body
      List parts = null;
      SOAPBody soapBody = validator.getSOAPBody(extElems);
      if (soapBody != null)
View Full Code Here

  {
    try
    {
      if (!entryContext.getMessageEntry().isMimeContent())
      {
        throw new AssertionNotApplicableException();
      }
      else
      {
        MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();
     
        // If the message does not contain non-root MIME parts
        // the assertion is not applicable
        if (mimeParts.count()< 2)
          throw new AssertionNotApplicableException();
     
        // Getting an operation matched for a message
        BindingOperation bindingOperation = validator.getOperationMatch(
          entryContext.getEntry().getEntryType(),
          entryContext.getMessageEntryDocument());
        // If no one operation matches, the assertion is not applicable
        if (bindingOperation == null)
        throw new AssertionNotApplicableException();
        // Getting the corresponding extensibility elements and message
        List extElems;
        Message message;
        if (MessageEntry.TYPE_REQUEST
          .equals(entryContext.getEntry().getEntryType()))
        {
          extElems = bindingOperation.getBindingInput() == null ? null
            : bindingOperation.getBindingInput().getExtensibilityElements();
          message = bindingOperation.getOperation().getInput() == null ? null
            : bindingOperation.getOperation().getInput().getMessage();
        }
        else
        {
          extElems = bindingOperation.getBindingOutput() == null ? null
            : bindingOperation.getBindingOutput().getExtensibilityElements();
          message = bindingOperation.getOperation().getOutput() == null ? null
            : bindingOperation.getOperation().getOutput().getMessage();
        }
        // A variable that indicates a binding contains at least one
        // mime:content element that refers to global element declaration
        boolean mimeContentFound = false;
        // Going through the message MIME parts
        Iterator iMimeParts = mimeParts.getParts().iterator();
        int i = 0;
        while (iMimeParts.hasNext())
        {
          i = i + 1;
          // Getting a MIME part
          MimePart mimePart = (MimePart)iMimeParts.next();
          // Getting a part name form the Content-ID header
          String partName = MIMEUtils.getMimeHeaderAttribute(
            mimePart.getHeaders(), MIMEConstants.HEADER_CONTENT_ID);
          try
          {
            int idx = partName.indexOf("=");
            if((idx != -1) && partName.startsWith("<"))
              partName = encodePartName(partName.substring(1, idx));
          }
          catch (Exception e)
          {
            // Could not extract a part name from the header,
            // proceed with the next MIME part
            continue;
          }

          // If the part is bound by a mime:content element
          if (boundToMimeContent(extElems, partName) && message != null)
          {
            // Getting the corresponding part
            Part part = (Part) message.getParts().get(partName);
            QName refName;
            // If the part refers to global element declaration
            if (part != null && (refName = part.getElementName()) != null)
            {
              mimeContentFound = true;
              // Trying to parse part content
              Document doc = null;
              try
              {
                doc = XMLUtils.parseXML(mimePart.getContent());
              }
              catch (Exception e) {}
              // If the message is not an XML infoset, the assertion failed
              if (doc == null)
              {
                throw new AssertionFailException("The bound message part of the "
                  + "MIME part number " + (i + 1) + " is invalid XML infoset.");
              }
              // Creating a QName object of the root element
              QName rootName = new QName(
                doc.getDocumentElement().getNamespaceURI(),
                doc.getDocumentElement().getLocalName());
              // If the names of the root element and the referenced element
              // are not equal, the assertion failed
              if (!refName.equals(rootName))
              {
                throw new AssertionFailException("The root element name is "
                  + rootName + ", the name of the referenced element is "
                  + refName + ".");
              }
            }
          }
        }
        // If no mime:contentS found, the assertion is not applicable
        if (!mimeContentFound)
          throw new AssertionNotApplicableException();
      }
    }
    catch (AssertionNotApplicableException anae)
    {
      result = AssertionResult.RESULT_NOT_APPLICABLE;
View Full Code Here

      Document doc = entryContext.getMessageEntryDocument();

      // If the message is empty or invalid, the assertion is not applicable
      if (doc == null)
      {
        throw new AssertionNotApplicableException();
      }

      // Getting header elements from envelope
      Element root = doc.getDocumentElement();
      NodeList headerList = root.getElementsByTagNameNS(
        WSIConstants.NS_URI_SOAP, XMLUtils.SOAP_ELEM_HEADER);

      // If there is no header, the assertion is not applicable
      if (headerList == null || headerList.getLength() == 0)
      {
        throw new AssertionNotApplicableException();
      }

      // Getting the header element
      Node header = headerList.item(0);

      // Getting the immediate child elements of the header
      NodeList elems = header.getChildNodes();

      // If there are no child elements of the header
      // the assertion is not applicable
      if (elems == null || elems.getLength() == 0)
      {
        throw new AssertionNotApplicableException();
      }

      // Walking through child elements
      for (int i = 0; i < elems.getLength(); i++)
      {
View Full Code Here

    throws WSIException
  {
    try
    {
      if (validator.isOneWayResponse(entryContext))
        throw new AssertionNotApplicableException();

      // Getting a message document
      Document doc = entryContext.getMessageEntryDocument();

      Element soapOperation = null;
      // If there is a Fault entry or no body entries,
      // the assertion is not applicable
      if (validator.isFault(doc)
        || (soapOperation = validator.getSoapBodyChild(doc)) == null)
        throw new AssertionNotApplicableException();

      // Creating a qualified name of potential SOAP operation
      QName operationQName = new QName(
        soapOperation.getNamespaceURI(), soapOperation.getLocalName());

      // Retrieving all the RPC binding operations from wsdl:binding
      BindingOperation[] rpcBindingOperations =
        validator.getMatchingBindingOps(
          WSIConstants.ATTRVAL_SOAP_BIND_STYLE_RPC,
          validator.analyzerContext.getCandidateInfo().getBindings());

      // Retrieving binding operation by given operation name
      BindingOperation bindingOperation = validator.getOperationMatch(
        entryContext.getEntry().getEntryType(),
        operationQName,
        rpcBindingOperations);

      // If there is no matched operation, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // Finding operation message parts and extensibility elems
      // in the binding depending on message type
      List operationMessageParts = null;
      List extElems = null;
View Full Code Here

      }

      // If there is no wsdl:partS defined with the ref:swaRef
      // schema type, the assertion is not applicable
      if (!swaRefFound)
        throw new AssertionNotApplicableException();
    }
    catch (AssertionNotApplicableException anae)
    {
      result = AssertionResult.RESULT_NOT_APPLICABLE;
    }
View Full Code Here

  {
    try
    {

      if (this.validator.isOneWayResponse(entryContext))
        throw new AssertionNotApplicableException();

      // Parse message
      Document doc =
        XMLUtils.parseXML(entryContext.getMessageEntry().getMessage());
View Full Code Here

    throws WSIException
  {
    try
    {
      if (validator.isOneWayResponse(entryContext))
        throw new AssertionNotApplicableException();

      // Getting a message document
      Document doc = entryContext.getMessageEntryDocument();

      Element messageElement = null;
      // If the message is empty or invalid or there is a Fault entry
      // or there is no body entries, the assertion is not applicable
      if (doc == null
        || validator.isFault(doc)
        || (messageElement = validator.getSoapBodyChild(doc)) == null)
        throw new AssertionNotApplicableException();

      // Getting a qualified name of message element
      QName messagePartElementQName = new QName(
        messageElement.getNamespaceURI(), messageElement.getLocalName());

      // Retrieving all the document binding operations from wsdl:binding
      BindingOperation[] docBindingOperations =
        validator.getMatchingBindingOps(
          WSIConstants.ATTRVAL_SOAP_BIND_STYLE_DOC,
          validator.analyzerContext.getCandidateInfo().getBindings());

      // Retrieving binding operation by given element name
      BindingOperation[] potentialDocLitOps =
        validator.getDocLitOperations(
          entryContext.getEntry().getEntryType(),
          messagePartElementQName,
          docBindingOperations);

      // If there is not exactly one operation matched,
      // the assertion is not applicable
      if (potentialDocLitOps.length != 1)
        throw new AssertionNotApplicableException();

      // Finding operation extensibility elems
      // in the binding depending on message type
      List extElems = null;
      if (entryContext.getMessageEntry().getType().equals(
View Full Code Here

    try
    {
      if(!entryContext.getMessageEntry().isMimeContent())
      {
        throw new AssertionNotApplicableException();
      }
     
      // get message mime parts
      MimeParts mimeParts = entryContext.getMessageEntry().getMimeParts();
     
      BindingOperation bindingOperation = validator.getOperationMatch(
          entryContext.getEntry().getEntryType(),
          entryContext.getMessageEntryDocument());

      // If there is no matched operation, the assertion is not applicable
      if (bindingOperation == null)
        throw new AssertionNotApplicableException();

      // Finding operation extensibility elems
      // in the binding depending on message type
      List extElems = null;
      if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_REQUEST)
        && bindingOperation.getBindingInput() != null)
      {
        extElems = bindingOperation
          .getBindingInput().getExtensibilityElements();
      }
      else if (entryContext.getMessageEntry().getType().equals(
        MessageEntry.TYPE_RESPONSE)
        && bindingOperation.getBindingOutput() != null)
      {
        extElems = bindingOperation
          .getBindingOutput().getExtensibilityElements();
      }
      // check list for the first element
      if((extElems == null) || (extElems.size() == 0) ||
         !(extElems.get(0) instanceof MIMEMultipartRelated))
        throw new AssertionNotApplicableException();
     
      // get list mime parts from definition
      MIMEMultipartRelated mime = (MIMEMultipartRelated) extElems.get(0);
      List parts = mime.getMIMEParts();
     
View Full Code Here

      // Getting a message document
      Document doc = entryContext.getMessageEntryDocument();
      // If the message is empty or invalid, the assertion is not applicable
      if (doc == null)
      {
        throw new AssertionNotApplicableException();
      }

      // Getting the root element
      Element elem = doc.getDocumentElement();
      // If it is not the soap:Envelope, the assertion is not applicable
      if (!elem.getNamespaceURI().equals(WSIConstants.NS_URI_SOAP)
        || !elem.getLocalName().equals(XMLUtils.SOAP_ELEM_ENVELOPE))
      {
        throw new AssertionNotApplicableException();
      }

      // If the envelope contains the xmlns:xml namespace declaration,
      // the assertion failed
      String incorrectElementName = getIncorrectElementName(elem);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.wsi.internal.core.analyzer.AssertionNotApplicableException

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.