public QueryResult<User> update(String userId, ObjectMap parameters, QueryOptions options, String sessionId)
throws CatalogException {
ParamUtils.checkParameter(userId, "userId");
ParamUtils.checkObj(parameters, "parameters");
if (sessionId != null && !sessionId.isEmpty()) {
ParamUtils.checkParameter(sessionId, "sessionId");
checkSessionId(userId, sessionId);
for (String s : parameters.keySet()) {
if (!s.matches("name|email|organization|attributes")) {
throw new CatalogDBException("Parameter '" + s + "' can't be changed");
}
}
} else {
if (configuration.getAdmin().getPassword() == null || configuration.getAdmin().getPassword().isEmpty()) {
throw new CatalogException("Nor the administrator password nor the session id could be found. The user could not be "
+ "updated.");
}
authenticationManagerMap.get(INTERNAL_AUTHORIZATION).authenticate("admin", configuration.getAdmin().getPassword(), true);
}
if (parameters.containsKey("email")) {
checkEmail(parameters.getString("email"));
}
userDBAdaptor.updateUserLastModified(userId);
QueryResult<User> queryResult = userDBAdaptor.update(userId, parameters);
auditManager.recordUpdate(AuditRecord.Resource.user, userId, userId, parameters, null, null);
return queryResult;
}