{
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);
// Looking for such elements in the root MIME part
NodeList elems = root.getDocumentElement().getElementsByTagNameNS(
elemName.getNamespaceURI(), elemName.getLocalPart());
// Going through all the ref:swaRef references
for (int j = 0; j < elems.getLength(); j++)
{
Node elem = elems.item(j);
// Getting a value of this reference
String ref = elem.getFirstChild() == null ? null
: elem.getFirstChild().getNodeValue();
// If the value is invalid, the assertion failed
if (ref == null)
throw new AssertionFailException("The element " + elem.getNodeName()
+ " of the ref:swaRef schema type is specified, but its vaule"
+ " is invalid.");
// If the URI does not start with the "cid:" content-id prefix
// The assertion failed
if (!ref.startsWith("cid:"))
{
throw new AssertionFailException("The URI " + ref
+ " of the ref:swaRef schema type must use the cid: prefix.");
}
boolean refFound = false;
Iterator iMimeParts = mimeParts.getParts().iterator();
// Going through all the MIME parts of the SOAP message
while (iMimeParts.hasNext())
{
MimePart mimePart = (MimePart)iMimeParts.next();
// Getting part's Content-ID header