use of org.apache.commons.chain.CatalogFactory in project sonarqube by SonarSource.
the class WrappingLookupCommand method getCommand.
/**
* <p>Return the Command to process for this Context.</p>
*
* @param context The Context we are processing
* @return The Command to process for this Context
*/
protected Command getCommand(Context context) {
CatalogFactory catalogFactory = CatalogFactory.getInstance();
String catalogName = getCatalogName();
Catalog catalog;
if (catalogName == null) {
catalog = catalogFactory.getCatalog();
// for debugging purposes
catalogName = "{default}";
} else {
catalog = catalogFactory.getCatalog(catalogName);
}
if (catalog == null) {
throw new IllegalArgumentException("Cannot find catalog '" + catalogName + "'");
}
Command command;
String name = getName();
if (name == null) {
name = (String) context.get(getNameKey());
}
if (name != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Lookup command " + name + " in catalog " + catalogName);
}
command = catalog.getCommand(name);
if (LOG.isDebugEnabled()) {
LOG.debug("Found command " + command + ";" + " optional: " + isOptional());
}
if ((command == null) && !isOptional()) {
throw new IllegalArgumentException("Cannot find command " + "'" + name + "' in catalog '" + catalogName + "'");
} else {
return command;
}
} else {
throw new IllegalArgumentException("No command name");
}
}
use of org.apache.commons.chain.CatalogFactory in project sonar-java by SonarSource.
the class WrappingLookupCommand method getCommand.
/**
* <p>Return the Command to process for this Context.</p>
*
* @param context The Context we are processing
* @return The Command to process for this Context
*/
protected Command getCommand(Context context) {
CatalogFactory catalogFactory = CatalogFactory.getInstance();
String catalogName = getCatalogName();
Catalog catalog;
if (catalogName == null) {
catalog = catalogFactory.getCatalog();
// for debugging purposes
catalogName = "{default}";
} else {
catalog = catalogFactory.getCatalog(catalogName);
}
if (catalog == null) {
throw new IllegalArgumentException("Cannot find catalog '" + catalogName + "'");
}
Command command;
String name = getName();
if (name == null) {
name = (String) context.get(getNameKey());
}
if (name != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Lookup command " + name + " in catalog " + catalogName);
}
command = catalog.getCommand(name);
if (LOG.isDebugEnabled()) {
LOG.debug("Found command " + command + ";" + " optional: " + isOptional());
}
if ((command == null) && !isOptional()) {
throw new IllegalArgumentException("Cannot find command " + "'" + name + "' in catalog '" + catalogName + "'");
} else {
return command;
}
} else {
throw new IllegalArgumentException("No command name");
}
}
Aggregations