return normalizedPreferences;
}
public Result create() {
Form<CreateUserRequestForm> createUserRequestForm = Tools.bindMultiValueFormFromRequest(CreateUserRequestForm.class);
final CreateUserRequestForm request = createUserRequestForm.get();
if (createUserRequestForm.hasErrors()) {
BreadcrumbList bc = breadcrumbs();
bc.addCrumb("Create new", routes.UsersController.newUserForm());
final List<String> permissions = permissionsService.all();
try {
return badRequest(new_user.render(
createUserRequestForm,
currentUser(),
permissions,
ImmutableSet.copyOf(request.permissions),
DateTools.getGroupedTimezoneIds().asMap(),
DateTools.getApplicationTimeZone(),
streamService.all(),
bc));
} catch (IOException e) {
return status(504, views.html.errors.error.render(ApiClient.ERROR_MSG_IO, e, request()));
} catch (APIException e) {
String message = "Could not fetch streams. We expected HTTP 200, but got a HTTP " + e.getHttpCode() + ".";
return status(504, views.html.errors.error.render(message, e, request()));
}
}
if (request.admin) {
request.permissions = Lists.newArrayList("*");
} else {
request.permissions = permissionsService.readerPermissions(request.username);
}
if (!userService.create(request.toApiRequest())) {
flash("error", "Could not create user due to an internal error.");
}
return redirect(routes.UsersController.index());
}