source = resolver.resolveURI(configurationFile);
SAXConfigurationHandler handler = new SAXConfigurationHandler();
SourceUtil.toSAX(source, handler);
config = handler.getConfiguration();
} catch (ProcessingException se) {
throw new ParameterException("Unable to read configuration from " + configurationFile, se);
} catch (SAXException se) {
throw new ParameterException("Unable to read configuration from " + configurationFile, se);
} catch (IOException ioe) {
throw new ParameterException("Unable to read configuration from " + configurationFile, ioe);
} finally {
resolver.release(source);
}
} catch (ServiceException se) {
throw new ParameterException("Unable to lookup source resolver.", se);
} finally {
this.manager.release(resolver);
}
Configuration[] events = config.getChild("events").getChildren("event");
if ( events != null ) {
for(int i=0; i<events.length;i++) {
try {
final String type = events[i].getAttribute("type");
final String id = events[i].getAttribute("id");
if ( "jxpath".equals(type) ) {
if ( this.eventMap.containsKey(id)) {
throw new ParameterException("The id for the event " + id + " is not unique.");
}
final String targetType = events[i].getChild("targettype").getValue();
final String targetId = events[i].getChild("targetid").getValue();
final String path = events[i].getChild("path").getValue();
if ( "layout".equals(targetType) ) {
LayoutMapping mapping = new LayoutMapping();
mapping.layoutId = targetId;
mapping.path = path;
this.eventMap.put(id, mapping);
} else if ( "coplet".equals(targetType) ) {
CopletMapping mapping = new CopletMapping();
mapping.copletId = targetId;
mapping.path = path;
this.eventMap.put(id, mapping);
} else {
throw new ParameterException("Unknown target type " + targetType);
}
} else if ( "fullscreen".equals(type) ) {
if ( this.eventMap.containsKey(id)) {
throw new ParameterException("The id for the event " + id + " is not unique.");
}
final String targetId = events[i].getChild("targetid").getValue();
final String layoutId = events[i].getChild("layoutid").getValue();
FullScreenMapping mapping = new FullScreenMapping();
mapping.copletId = targetId;
mapping.layoutId = layoutId;
this.eventMap.put(id, mapping);
} else {
throw new ParameterException("Unknown event type for event " + id + ": " + type);
}
} catch (ConfigurationException ce) {
throw new ParameterException("Configuration exception" ,ce);
}
}
}
// Nullify config filename so as not to reload it.