protocol = new Protocol();
nameElement = element.getFirstChildWithName(new QName(NAME));
if (nameElement == null) {
throw new SavanException("Protocol must have a 'Name' subelement");
}
name = nameElement.getText();
protocol.setName(name);
utilFactoryNameElement = element.getFirstChildWithName(new QName(UTIL_FACTORY));
if (utilFactoryNameElement == null) {
throw new SavanException("Protocol must have a 'UtilFactory' subelement");
}
utilFactoryName = utilFactoryNameElement.getText();
utilFactory = getObject(utilFactoryName);
if (!(utilFactory instanceof UtilFactory)) {
throw new SavanException("UtilFactory element" + utilFactoryName
+ "is not a subtype of the UtilFactory class");
}
protocol.setUtilFactory((UtilFactory) utilFactory);
mappingRulesElement = element.getFirstChildWithName(new QName(MAPPING_RULES));
if (mappingRulesElement == null) {
throw new SavanException("Protocol must have a 'mappingRules' sub-element");
}
processMappingRules(mappingRulesElement, protocol);
defaultSubscriberElement = element.getFirstChildWithName(new QName(DEFAULT_SUBSCRIBER));
if (defaultSubscriberElement == null) {
throw new SavanException("Protocols must have a 'defaultSubscriber' sub-element");
}
defaultSubscriber = defaultSubscriberElement.getText();
protocol.setDefaultSubscriber(defaultSubscriber);
defaultFilterElement = element.getFirstChildWithName(new QName(DEFAULT_FILTER));
if (defaultFilterElement == null) {
throw new SavanException("Protocols must have a 'defaultFilter' sub-element");
}
defaultFilter = defaultFilterElement.getText();
protocol.setDefaultFilter(defaultFilter);
protocolMap.put(protocol.getName(), protocol);