}
}
public ProcessingContext build(MessageContext msgContext, WsNotificationOperations operation) {
ProcessingContext context = new ProcessingContext();
SOAPEnvelope soapEnvelope = msgContext.getEnvelope();
if (soapEnvelope == null) {
throw new RuntimeException("invalid message context - envelope is not found");
}
SOAPBody soapBody = soapEnvelope.getBody();
if (soapBody == null) {
throw new RuntimeException("invalid message context - soap envelope is not found");
}
SOAPHeader soapHeader = soapEnvelope.getHeader();
if (soapHeader == null) {
throw new RuntimeException("invalid message context - soap header is not found");
}
switch (operation) {
case SUBSCRIBE: {
Iterator<OMElement> iterator = soapBody.getChildrenWithName(new QName(NameSpaceConstants.WSNT_NS
.getNamespaceURI(), "SubscribeRequest"));
if (!iterator.hasNext()) {
throw new RuntimeException("invalid message context - unable to find Subscribe information");
}
onSubscription(context, iterator.next());
}
break;
}
context.setEnvelope(soapEnvelope);
extractInfoFromHeader(context, soapHeader);
context.setMessageConext(msgContext);
String topicFromUrl = BrokerUtil.getTopicFromRequestPath(msgContext.getTo().getAddress());
context.setContextParameter(ContextParameters.TOPIC_FROM_URL, topicFromUrl);
return context;
}