String patternStr = configurationService.getStringConfiguration("content."+configName+".pattern");
String enabledStr = configurationService.getStringConfiguration("content."+configName+".enabled");
if(Boolean.parseBoolean(enabledStr)) {
ContentReader reader = null;
ContentWriter writer = null;
Pattern pattern = null;
if(readerClass != null) {
for(ContentReader r : readers) {
if(r.getClass().getCanonicalName().startsWith(readerClass)) {
reader = r;
break;
}
}
}
if(writerClass != null) {
for(ContentWriter w : writers) {
if(w.getClass().getCanonicalName().startsWith(writerClass)) {
writer = w;
break;
}
}
}
try {
pattern = Pattern.compile(patternStr);
} catch(Exception ex) {
log.warn("pattern {} is not a valid regular expression; disabling reader/writer {} (message was {})", patternStr,configName,ex.getMessage());
continue;
}
if(pattern != null && reader != null) {
readerMap.put(pattern,reader);
log.info("enabled content reader '{}' for pattern {}",reader.getName(), pattern);
}
if(pattern != null && writer != null) {
writerMap.put(pattern,writer);
log.info("enabled content writer '{}' for pattern {}", writer.getName(), pattern);
}
} else {
log.info("content reader/writer {} disabled",configName);