final String moduleName = firstSlash < 0 ? path.substring(1) : path
.substring(1, firstSlash);
path = firstSlash < 0 ? "" : path.substring(firstSlash);
final AtomModule module = modules.get(moduleName);
if (module == null) {
response.sendError(400, "Module " + moduleName + " not found.");
return;
}
Subject user = null;
if (noAuth.get(moduleName) == null) {
// Authenticate
user = authenticate(request, response);
if (user == null) {
// You now get a challenge if there is no user
return;
}
}
// Handle the resource
DBBroker broker = null;
try {
broker = pool.get(user);
module.process(broker, new HttpRequestMessage(request, path,
'/' + moduleName), new HttpResponseMessage(response));
} catch (final NotFoundException ex) {
getLog().info(
"Resource " + path + " not found by " + moduleName, ex);