Examples of ProfileForm


Examples of cn.edu.zju.acm.onlinejudge.form.ProfileForm

            context.getResponse().sendError(404);
            return null;
        }
        UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();

        ProfileForm profileForm = (ProfileForm) form;
        if (profileForm.getHandle() == null) {
            return this.handleSuccess(mapping, context, "failure");
        }
        context.getRequest().getSession().invalidate();
        ActionMessages errors = this.validate(userPersistence, profileForm);

        if (errors.size() > 0) {
            return this.handleFailure(mapping, context, errors);
        }
        // create user profile
        UserProfile profile = profileForm.toUserProfile();
        userPersistence.createUserProfile(profile, 0);

        // create user perference
        UserPreference perference = profileForm.toUserPreference();
        perference.setId(profile.getId());
        userPersistence.createUserPreference(perference, 0);

        AuthorizationPersistence authorizationPersistence =
                PersistenceManager.getInstance().getAuthorizationPersistence();
View Full Code Here

Examples of cn.edu.zju.acm.onlinejudge.form.ProfileForm

        if (!this.isLogin(context)) {
            return this.handleSuccess(mapping, context, "login");
        }
        UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
        ProfileForm profileForm = (ProfileForm) form;
        UserProfile profile = context.getUserProfile();
        UserPreference perference = userPersistence.getUserPreference(profile.getId());
        if (profileForm.getHandle() == null) {
            profileForm.populate(profile, perference);
            context.setAttribute("ProfileForm", profileForm);
            return this.handleSuccess(mapping, context, "failure");
        }

        if (userPersistence.login(profileForm.getHandle(), profileForm.getPassword()) == null) {
            return this.handleFailure(mapping, context, "password", "ProfileForm.password.invalid");
        }

        UserProfile newProfile = profileForm.toUserProfile();
        newProfile.setId(profile.getId());
        newProfile.setRegDate(profile.getRegDate());

        if (!profile.getHandle().equals(newProfile.getHandle())) {
            return this.handleFailure(mapping, context, "handle", "ProfileForm.handle.changed");
        }

        if (!profile.getEmail().equals(newProfile.getEmail())) {
            UserProfile temp = userPersistence.getUserProfileByEmail(newProfile.getEmail());
            if (temp != null && temp.getId() != profile.getId()) {
                return this.handleFailure(mapping, context, "email", "ProfileForm.email.used");
            }
        }

        userPersistence.updateUserProfile(newProfile, profile.getId());
        UserPreference newPerference = profileForm.toUserPreference();
        newPerference.setId(profile.getId());
        userPersistence.updateUserPreference(newPerference, profile.getId());
        context.setUserProfile(newProfile);
        context.getRequest().setAttribute("Countries",
                                          PersistenceManager.getInstance().getUserPersistence().getAllCountries());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

    @Test
    public void testSaveProfile() throws Exception {
        // Save the profile for the first time.
        Profile profile = conferenceApi.saveProfile(
                user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        // Check the return value first.
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
        assertEquals(DISPLAY_NAME, profile.getDisplayName());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

    }

    @Test
    public void testSaveProfileWithNull() throws Exception {
        // Save the profile for the first time with null values.
        Profile profile = conferenceApi.saveProfile(user, new ProfileForm(null, null));
        String displayName = EMAIL.substring(0, EMAIL.indexOf("@"));
        // Check the return value first.
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

        assertEquals(displayName, profile.getDisplayName());
    }

    @Test
    public void testGetProfile() throws Exception {
        conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        // Fetch the Profile via the API.
        Profile profile = conferenceApi.getProfile(user);
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

    }

    @Test
    public void testUpdateProfile() throws Exception {
        // Save for the first time.
        conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
        assertEquals(DISPLAY_NAME, profile.getDisplayName());
        // Then try to update it.
        String newDisplayName = "Kay's Daddy";
        TeeShirtSize newTeeShirtSize = TeeShirtSize.L;
        conferenceApi.saveProfile(user, new ProfileForm(newDisplayName, newTeeShirtSize));
        profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(newTeeShirtSize, profile.getTeeShirtSize());
        assertEquals(newDisplayName, profile.getDisplayName());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

        assertEquals(newDisplayName, profile.getDisplayName());
    }

    @Test
    public void testUpdateProfileWithNulls() throws Exception {
        conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        // Update the Profile with null values.
        Profile profile = conferenceApi.saveProfile(user, new ProfileForm(null, null));
        // Expected behavior is that the existing properties do not get overwritten

        // Check the return value first.
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

    @Test
    public void testSaveProfile() throws Exception {
        // Save the profile for the first time.
        Profile profile = conferenceApi.saveProfile(
                user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        // Check the return value first.
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
        assertEquals(DISPLAY_NAME, profile.getDisplayName());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

    }

    @Test
    public void testSaveProfileWithNull() throws Exception {
        // Save the profile for the first time with null values.
        Profile profile = conferenceApi.saveProfile(user, new ProfileForm(null, null));
        String displayName = EMAIL.substring(0, EMAIL.indexOf("@"));
        // Check the return value first.
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
View Full Code Here

Examples of com.google.devrel.training.conference.form.ProfileForm

        assertEquals(displayName, profile.getDisplayName());
    }

    @Test
    public void testGetProfile() throws Exception {
        conferenceApi.saveProfile(user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE));
        // Fetch the Profile via the API.
        Profile profile = conferenceApi.getProfile(user);
        assertEquals(USER_ID, profile.getUserId());
        assertEquals(EMAIL, profile.getMainEmail());
        assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.