private static void createStaticSubscriptions(OMElement elem,
SynapseEventSource synapseEventSource)
throws EventException {
for (Iterator iterator = elem.getChildrenWithName(SUBSCRIPTION_QNAME);
iterator.hasNext();) {
SynapseSubscription synapseSubscription = new SynapseSubscription();
OMElement elmSubscription = (OMElement) iterator.next();
synapseSubscription.setId(elmSubscription.getAttribute(ID_QNAME).getAttributeValue());
//process the filter
OMElement elmFilter = elmSubscription.getFirstChildWithName(FILTER_QNAME);
OMAttribute dialectAttr = elmFilter.getAttribute(FILTER_DIALECT_QNAME);
if (dialectAttr != null && dialectAttr.getAttributeValue() != null) {
OMAttribute sourceAttr = elmFilter.getAttribute(FILTER_SOURCE_QNAME);
if (sourceAttr != null) {
synapseSubscription.setFilterDialect(dialectAttr.getAttributeValue());
synapseSubscription.setFilterValue(sourceAttr.getAttributeValue());
} else {
handleException(
"Error in creating static subscription. Filter source not defined");
}
} else {
handleException(
"Error in creating static subscription. Filter dialect not defined");
}
OMElement elmEndpoint = elmSubscription.getFirstChildWithName(ENDPOINT_QNAME);
if (elmEndpoint != null) {
OMElement elmAddress = elmEndpoint.getFirstChildWithName(ADDRESS_QNAME);
if (elmAddress != null) {
OMAttribute uriAttr = elmAddress.getAttribute(EP_URI_QNAME);
if (uriAttr != null) {
synapseSubscription.setEndpointUrl(uriAttr.getAttributeValue());
synapseSubscription.setAddressUrl(uriAttr.getAttributeValue());
} else {
handleException("Error in creating static subscription. URI not defined");
}
} else {
handleException("Error in creating static subscription. Address not defined");
}
} else {
handleException("Error in creating static subscription. Endpoint not defined");
}
OMElement elmExpires = elmSubscription.getFirstChildWithName(EXPIRES_QNAME);
if (elmExpires != null) {
try {
if (elmExpires.getText().startsWith("P")) {
synapseSubscription.setExpires(ConverterUtil
.convertToDuration(elmExpires.getText()).getAsCalendar());
} else {
synapseSubscription
.setExpires(ConverterUtil.convertToDateTime(elmExpires.getText()));
}
} catch (Exception e) {
handleException("Error in creating static subscription. invalid date format",
e);
}
} else {
synapseSubscription.setExpires(null);
}
synapseSubscription.setStaticEntry(true);
synapseEventSource.getSubscriptionManager().subscribe(synapseSubscription);
}
}