List<Extension> extList = new ArrayList<Extension>();
if (plugins != null) {
for (String parsePluginId : plugins) {
Extension ext = getExtension(extensions, parsePluginId, contentType);
// the extension returned may be null
// that means that it was not enabled in the plugin.includes
// nutch conf property, but it was mapped in the
// parse-plugins.xml
// file.
// OR it was enabled in plugin.includes, but the plugin's plugin.xml
// file does not claim that the plugin supports the specified mimeType
// in either case, LOG the appropriate error message to WARN level
if (ext == null) {
//try to get it just by its pluginId
ext = getExtension(extensions, parsePluginId);
if (LOG.isWarnEnabled()) {
if (ext != null) {
// plugin was enabled via plugin.includes
// its plugin.xml just doesn't claim to support that
// particular mimeType
LOG.warn("ParserFactory:Plugin: " + parsePluginId +
" mapped to contentType " + contentType +
" via parse-plugins.xml, but " + "its plugin.xml " +
"file does not claim to support contentType: " +
contentType);
} else {
// plugin wasn't enabled via plugin.includes
LOG.warn("ParserFactory: Plugin: " + parsePluginId +
" mapped to contentType " + contentType +
" via parse-plugins.xml, but not enabled via " +
"plugin.includes in nutch-default.xml");
}
}
}
if (ext != null) {
// add it to the list
extList.add(ext);
}
}
} else {
// okay, there were no list of plugins defined for
// this mimeType, however, there may be plugins registered
// via the plugin.includes nutch conf property that claim
// via their plugin.xml file to support this contentType
// so, iterate through the list of extensions and if you find
// any extensions where this is the case, throw a
// NotMappedParserException
for (int i=0; i<extensions.length; i++) {
if ("*".equals(extensions[i].getAttribute("contentType"))){
extList.add(0, extensions[i]);
}
else if (extensions[i].getAttribute("contentType") != null
&& contentType.matches(escapeContentType(extensions[i].getAttribute("contentType")))) {
extList.add(extensions[i]);
}
}
if (extList.size() > 0) {
if (LOG.isInfoEnabled()) {
StringBuffer extensionsIDs = new StringBuffer("[");
boolean isFirst = true;
for (Extension ext : extList){
if (!isFirst) extensionsIDs.append(" - ");
else isFirst=false;
extensionsIDs.append(ext.getId());
}
extensionsIDs.append("]");
LOG.info("The parsing plugins: " + extensionsIDs.toString() +
" are enabled via the plugin.includes system " +
"property, and all claim to support the content type " +