use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.
the class RenderReportHtmlHandler method execute.
@Override
@LogException
public CommandResult execute(RenderReportHtml cmd, User user) throws CommandException {
ReportElement model = cmd.getModel();
LOGGER.fine("Model: " + model);
// don't show the title: it will be rendered by the container
model.setTitle(null);
generator.generateElement(user, model, new Filter(), new DateRange());
StringWriter writer = new StringWriter();
try {
renderer.render(model, writer);
} catch (IOException e) {
throw new CommandException(e);
}
return new HtmlResult(writer.toString());
}
use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.
the class ChangePasswordController method changePassword.
@POST
@LogException(emailAlert = true)
public Response changePassword(@Context UriInfo uri, @FormParam("key") String key, @FormParam("password") String password) throws IOException, ServletException {
User user = null;
try {
user = userDAO.get().findUserByChangePasswordKey(key);
} catch (NoResultException e) {
return Response.ok().entity(new InvalidInvitePageModel().asViewable()).type(MediaType.TEXT_HTML).build();
}
changePassword(user, password);
return Response.seeOther(uri.getAbsolutePathBuilder().replacePath("/").build()).cookie(authTokenProvider.createNewAuthCookies(user)).build();
}
use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.
the class ConfirmInviteController method confirm.
@POST
@LogException(emailAlert = true)
public Response confirm(@Context UriInfo uri, @FormParam("key") String key, @FormParam("locale") String locale, @FormParam("password") String password, @FormParam("name") String name, @FormParam("newsletter") boolean newsletter) throws Exception {
User user = null;
try {
user = userDAO.get().findUserByChangePasswordKey(key);
user.setName(checkNonEmpty(name));
user.setLocale(checkNonEmpty(locale));
user.changePassword(checkNonEmpty(password));
user.clearChangePasswordKey();
user.setEmailNotification(true);
if (newsletter) {
mailingList.subscribe(user);
}
return Response.seeOther(uri.getAbsolutePathBuilder().replacePath("/").build()).cookie(authTokenProvider.createNewAuthCookies(user)).build();
} catch (EntityNotFoundException e) {
return Response.ok(new InvalidInvitePageModel().asViewable()).type(MediaType.TEXT_HTML).build();
} catch (IllegalArgumentException e) {
return Response.ok(ConfirmInvitePageModel.incompleteForm(user).asViewable()).type(MediaType.TEXT_HTML).build();
}
}
use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.
the class SignUpConfirmationController method addUserToDefaultDatabase.
@LogException(emailAlert = true)
protected void addUserToDefaultDatabase(User user) {
UserDatabase database = databaseDAO.get().findById(DEFAULT_DATABASE_ID);
Partner partner = partnerDAO.get().findById(DEFAULT_PARTNER_ID);
UserPermission permission = new UserPermission(database, user);
permission.setPartner(partner);
permission.setAllowView(true);
permission.setAllowViewAll(true);
permission.setLastSchemaUpdate(new Date());
permissionDAO.get().persist(permission);
}
use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.
the class ResetPasswordController method resetPassword.
@POST
@Produces(MediaType.TEXT_HTML)
@LogException(emailAlert = true)
@Transactional
public Viewable resetPassword(@FormParam("email") String email) {
try {
User user = userDAO.get().findUserByEmail(email);
user.setChangePasswordKey(SecureTokenGenerator.generate());
user.setDateChangePasswordKeyIssued(new Date());
mailer.send(new ResetPasswordMessage(user));
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setEmailSent(true);
return model.asViewable();
} catch (NoResultException e) {
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setLoginError(true);
return model.asViewable();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed to send password reset email", e);
ResetPasswordPageModel model = new ResetPasswordPageModel();
model.setEmailError(true);
return model.asViewable();
}
}
Aggregations