Search in sources :

Example 11 with LogException

use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.

the class HostController method getHostPage.

@GET
@Produces(MediaType.TEXT_HTML)
@LogException(emailAlert = true)
public Response getHostPage(@Context UriInfo uri, @Context HttpServletRequest req, @QueryParam("redirect") boolean redirect) throws Exception {
    if (!authProvider.isAuthenticated()) {
        // Otherwise, go to the default ActivityInfo root page
        return Response.ok(new RootPageModel().asViewable()).type(MediaType.TEXT_HTML).cacheControl(CacheControl.valueOf("no-cache")).build();
    }
    if (redirect) {
        return Response.seeOther(uri.getAbsolutePathBuilder().replacePath(ENDPOINT).build()).build();
    }
    String appUri = uri.getAbsolutePathBuilder().replaceQuery("").build().toString();
    HostPageModel model = new HostPageModel(appUri);
    model.setAppCacheEnabled(checkAppCacheEnabled(req));
    return Response.ok(model.asViewable()).type(MediaType.TEXT_HTML).cacheControl(CacheControl.valueOf("no-cache")).build();
}
Also used : HostPageModel(org.activityinfo.server.login.model.HostPageModel) RootPageModel(org.activityinfo.server.login.model.RootPageModel) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) LogException(org.activityinfo.server.util.logging.LogException)

Example 12 with LogException

use of org.activityinfo.server.util.logging.LogException in project activityinfo by bedatadriven.

the class SignUpConfirmationController method confirm.

@POST
@LogException(emailAlert = true)
public Response confirm(@Context UriInfo uri, @FormParam("key") String key, @FormParam("password") String password, @FormParam("newsletter") boolean newsletter) {
    try {
        // check params
        checkParam(key, true);
        checkParam(password, true);
        // confirm user
        User user = userDAO.get().findUserByChangePasswordKey(key);
        user.changePassword(password);
        user.clearChangePasswordKey();
        user.setEmailNotification(true);
        // add user to default database
        addUserToDefaultDatabase(user);
        if (newsletter) {
            mailingList.subscribe(user);
        }
        // go to the home page
        return Response.seeOther(uri.getAbsolutePathBuilder().replacePath("/").build()).cookie(authTokenProvider.createNewAuthCookies(user)).build();
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Exception during signup process", e);
        return Response.ok(SignUpConfirmationPageModel.genericErrorModel(key).asViewable()).type(MediaType.TEXT_HTML).build();
    }
}
Also used : User(org.activityinfo.server.database.hibernate.entity.User) NoResultException(javax.persistence.NoResultException) LogException(org.activityinfo.server.util.logging.LogException) POST(javax.ws.rs.POST) LogException(org.activityinfo.server.util.logging.LogException)

Aggregations

LogException (org.activityinfo.server.util.logging.LogException)12 POST (javax.ws.rs.POST)6 User (org.activityinfo.server.database.hibernate.entity.User)6 NoResultException (javax.persistence.NoResultException)4 Produces (javax.ws.rs.Produces)4 IOException (java.io.IOException)3 Date (java.util.Date)3 Transactional (org.activityinfo.server.database.hibernate.dao.Transactional)3 CommandException (org.activityinfo.shared.exception.CommandException)3 ServletException (javax.servlet.ServletException)2 InvalidInvitePageModel (org.activityinfo.server.login.model.InvalidInvitePageModel)2 SignUpAddressExistsPageModel (org.activityinfo.server.login.model.SignUpAddressExistsPageModel)2 ResetPasswordMessage (org.activityinfo.server.mail.ResetPasswordMessage)2 CommandResult (org.activityinfo.shared.command.result.CommandResult)2 StringWriter (java.io.StringWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 DataHandler (javax.activation.DataHandler)1