Package com.joshlong.userregistrationexample.model

Examples of com.joshlong.userregistrationexample.model.User


        ApplicationContext context = new ClassPathXmlApplicationContext("service-context.xml");

        UserManagmentService ums = (UserManagmentService) context.getBean("userManagmentService");

        // are hashes redeemable for a user?
        User user = ums.createUser("josh@joshlong.com", "password", "Josh", "Long");
        String hashForUser = ums.getHashForUser(user.getId());

        assertTrue("a User ID and a user hash should be exchangeable!",
                ums.getUserForHash(hashForUser).getId().equals(user.getId()));

        // does invalid data get across?
        try {
            user = ums.createUser(null, null, "First1", "Last1");
            fail("You shouldnt be allowed to get this far!");
View Full Code Here


    }

    protected ModelAndView handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, BindException e) throws Exception {
        SignupConfirmationControllerParameters params = (SignupConfirmationControllerParameters) o;

        User user = userManagmentService.getUserForHash(params.getUserIdHash());

        Map<String, Object> paramstpl = new HashMap<String, Object>();
        paramstpl.put("userIdHash", params.getUserIdHash());
        paramstpl.put("user", user);

        Map<String, Object> predicates = new HashMap<String, Object>();
        predicates.put("userId", user.getId());

        Long confirmRegistration = workflowService.lockNextTaskInstanceByActorAndCriteria("signup-confirmation-actor", predicates);

        if (null != confirmRegistration) {
            log.debug("Fetched a taskInstance for signup-confirmation-actor");
View Full Code Here

        setCommandClass(User.class);
        setCommandName("user");
    }

    protected ModelAndView onSubmit(Object o) throws Exception {
        User user = (User) o;

        log.debug("Creating user " + user.getEmail() + ":" + user.getPassword() + ":" + user.getFirstName() + ":" + user.getLastName());

        User realUser = userManagmentService.createUser(user.getEmail(), user.getPassword(), user.getFirstName(), user.getLastName());
        userManagmentService.createUserRegistrationProcess(realUser.getId());

        log.debug(String.format("Created a new user; am submitting user having email '%s' and ID %s for user-registration", realUser.getEmail(), realUser.getId().toString()));

        return new ModelAndView(getSuccessView(), "user", realUser);

    }
View Full Code Here

        return aClass.isAssignableFrom(User.class) || aClass.equals(User.class);
    }

    public void validate(Object o, Errors errors) {

        User user = (User) o;

        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "required.firstName", "First Name is required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "required.lastName", "Last Name is required");
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "required.email", "E-Mail is required");
View Full Code Here

            // then we get the user id
            Long userId = (Long) getWorkflowService().getProcessVariable(processInstance, "userId");
            log.info ( "SendWelcomeEmailJob userId:" + userId) ;

            User user = getUserManagmentService().getUserById(userId);

            if (user != null) {

                // then we send them a nice email message

                String email = user.getEmail();

                EmailUtils emailUtils = (EmailUtils) getApplicationContext().getBean("emailUtils");

                Map<String, String> tpl = loadTemplate("welcome_email");
                Map<String, Object> parameters = new HashMap<String, Object>();
                parameters.put("user", user);
                parameters.put("userIdHash", getUserManagmentService().getHashForUser(user.getId()));

                emailUtils.sendEmailMessage("theteam@theteam.com", new String[]{email}, tpl.get("subject"), tpl.get(TXT_KEY), tpl.get(HTML_KEY), parameters);

                getWorkflowService().completeTaskInstance(taskInstanceId);
View Full Code Here

            // get the process instance
            long processInstance = getWorkflowService().getProcessInstanceIdForTaskInstance(taskInstanceId);

            // then we get the user id
            Long userId = (Long) getWorkflowService().getProcessVariable(processInstance, "userId");
            User user = getUserManagmentService().getUserById(userId);

            log.info ( "SendConfirmationEmail userId:"+ userId) ;

            if (user != null) {
                String email = user.getEmail();
                EmailUtils emailUtils = (EmailUtils) getApplicationContext().getBean("emailUtils");
                Map<String, String> tpl = loadTemplate("confirmation_email");
                Map<String, Object> parameters = new HashMap<String, Object>();
                parameters.put("user", user);
                String uidHash = getUserManagmentService().getHashForUser(user.getId());
                parameters.put("userIdHash", uidHash);
                emailUtils.sendEmailMessage("theteam@theteam.com", new String[]{email}, tpl.get("subject"), tpl.get(TXT_KEY), tpl.get(HTML_KEY), parameters);
                getWorkflowService().completeTaskInstance(taskInstanceId);

            }
View Full Code Here

     * @param hash
     * @return
     */
    public User getUserForHash(String hash) {
        long userId = Long.parseLong(hash);
        User user = getUserById(userId);
        return user;
    }
View Full Code Here

        workflowService.startProcessInstance(processInstance.getId());
       
    }

    public User createUser(String email, String password, String firstName, String lastName) {
        User user = new User();
        Date now = new Date();
        user.setCreated(now);
        user.setLastUpdated(now);
        user.setEmail(email);
        user.setPassword(password);
        user.setFirstName(firstName);
        user.setLastName(lastName);
        getHibernateTemplate().saveOrUpdate(user);

        if (StringUtils.isEmpty(email) || StringUtils.isEmpty(password) || StringUtils.isEmpty(firstName) || StringUtils.isEmpty(lastName))
            throw new RuntimeException("Invalid data! This will be rolled back!");
View Full Code Here

    public User createUser(String email, String password) {
        return createUser(email, password, null, null);
    }

    public void updateUser(long userId, String email, String password, String firstName, String lastName) {
        User user = getUserById(userId);
        user.setEmail(email);
        user.setPassword(password);
        user.setFirstName(firstName);
        user.setLastName(lastName);
        getHibernateTemplate().saveOrUpdate(user);
    }
View Full Code Here

TOP

Related Classes of com.joshlong.userregistrationexample.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.