if (config == null) {
throw new Exception("Configuration problem");
}
// prepare command and run
AbstractCommand command = prepareCommand((String) requestParams.get("cmd"), request, response, config);
try {
command.execute();
} catch (ConnectorException e) {
logger.warn("command returned an error", e);
putResponse("error", e.getMessage());
}
// append init info if needed
if (command.mustRunInit()) {
try {
command.initCommand();
} catch (ConnectorException e) {
logger.warn("command returned an error", e);
putResponse("error", e.getMessage());
}
}
// output if command didn't do it
if (!command.isResponseOutputDone()) {
output(response, command.isResponseTextHtml(), json, command.getResponseWriter());
command.setResponseOutputDone(true);
}
} catch (Exception e) {
logger.error("Unknown error", e);
putResponse("error", "Unknown error");