// map's the path if a mapping is specified in the descriptor
path = descriptor.mapPath(path);
}
// third, authenticate the user
final Subject user = authenticate(request, response);
if (user == null) {
// You now get a challenge if there is no user
// response.sendError(HttpServletResponse.SC_FORBIDDEN,
// "Permission denied: unknown user or password");
return;
}
DBBroker broker = null;
try {
final XmldbURI dbpath = XmldbURI.create(path);
broker = getPool().get(user);
final Collection collection = broker.getCollection(dbpath);
if (collection != null) {
response.sendError(400, "A PUT request is not allowed against a plain collection path.");
return;
}
srvREST.doPut(broker, dbpath, request, response);
} catch (final BadRequestException e) {
if (response.isCommitted()) {
throw new ServletException(e.getMessage(), e);
}
response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
} catch (final PermissionDeniedException e) {
// If the current user is the Default User and they do not have permission
// then send a challenge request to prompt the client for a username/password.
// Else return a FORBIDDEN Error
if (user != null && user.equals(getDefaultUser())) {
getAuthenticator().sendChallenge(request, response);
} else {
response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
}
} catch (final EXistException e) {