@RequestMapping(method = RequestMethod.POST)
    public String processSubmit(@ModelAttribute("user") User user,
                                BindingResult result,
                                SessionStatus status,
                                HttpSession session,
                                ModelMap model) {

        model.addAttribute("ADMINISTRATOR_URL", administratorGroupURL);
        model.addAttribute("PREMIUM_URL", premiumGroupURL);

        profileValidator.validate(user, result);

        if (!result.hasErrors()) {

            try {

                // For account update, we just retrieve the current account and
                // call Account.save() after setting the modified properties.
                // An account can also be retrieved from the DataStore,
                // like the way we do it to get an Application or Directory object,
                // if the account's Rest URL is known to the application.

                User sessionUser = (User) session.getAttribute("sessionUser");
                Account account = sessionUser.getAccount();
                account.setGivenName(user.getFirstName());
                account.setSurname(user.getLastName());
                account.setEmail(user.getEmail());
                account.setUsername(user.getFirstName().toLowerCase() + user.getLastName().toLowerCase());

                String existingGroupUrl = null;
                if (account.getGroupMemberships().iterator().hasNext()) {
                    GroupMembership groupMembership = account.getGroupMemberships().iterator().next();
                    existingGroupUrl = groupMembership.getGroup().getHref();
                    if (!existingGroupUrl.equals(user.getGroupUrl())) {
                        groupMembership.delete();
                        existingGroupUrl = null;
                    }
                }

                if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty() && existingGroupUrl == null) {
                    account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class));
                }

                account.save();

                user.setAccount(account);
                user.setUserName(sessionUser.getUserName());
                user.setTootList(sessionUser.getTootList());

                model.addAttribute("messageKey", "updated");
                model.addAttribute("user", user);
            } catch (ResourceException re) {
                ObjectError error = new ObjectError("user", re.getMessage());
                result.addError(error);
                re.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }

            status.setComplete();
        }
        return "profile";
    }