return;
}
// get correct plugin from list
ICommandPlugin myCommandPlugin = (ICommandPlugin) PluginLoader.getPluginByTitle(PluginType.Command, this.command);
if (myCommandPlugin == null) {
generateAnswer(resp, 400, "invalid command", "command not found in list of command plugins");
return;
}
// hand parameters over to command
Map<String, String[]> map = req.getParameterMap();
HashMap<String, String> params = new HashMap<String, String>();
Iterator<Entry<String, String[]>> i = map.entrySet().iterator();
while (i.hasNext()) {
Entry<String, String[]> entry = i.next();
if (entry.getValue()[0] != null) {
params.put(entry.getKey(), entry.getValue()[0]);
}
}
myCommandPlugin.setParameterMap(params);
// let command validate if all parameters are correct: null means valid
CommandResponse cr = myCommandPlugin.validate();
if (cr != null) {
generateAnswer(resp, cr);
return;
}
// no validation errors, so call the command
if (myCommandPlugin.usesHttpSession()) {
myCommandPlugin.setHttpResponse(resp);
}
cr = myCommandPlugin.execute();
generateAnswer(resp, cr.getStatus(), cr.getTitle(), cr.getMessage());
return;
} else {
generateAnswer(resp, 404, "web api deactivated", "web api not configured");