@Test public void testSaveProfile() throws Exception { Profile profile = conferenceApi.saveProfile( user, new ProfileForm(DISPLAY_NAME, TEE_SHIRT_SIZE)); assertEquals(USER_ID, profile.getUserId()); assertEquals(EMAIL, profile.getMainEmail()); assertEquals(TEE_SHIRT_SIZE, profile.getTeeShirtSize()); assertEquals(DISPLAY_NAME, profile.getDisplayName()); 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()); }
@ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String mainEmail = user.getEmail(); String userId = user.getUserId(); String displayName = profileForm.getDisplayName(); TeeShirtSize teeShirtSize = profileForm.getTeeShirtSize(); Profile profile = ofy().load().key(Key.create(Profile.class, userId)) .now(); if (profile == null) { if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user .getEmail()); } if (teeShirtSize == null) { teeShirtSize = TeeShirtSize.NOT_SPECIFIED; } profile = new Profile(userId, displayName, mainEmail, teeShirtSize); } else { profile.update(displayName, teeShirtSize); } ofy().save().entity(profile).now(); return profile; }
ConferenceApi { @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String mainEmail = user.getEmail(); String userId = user.getUserId(); String displayName = profileForm.getDisplayName(); TeeShirtSize teeShirtSize = profileForm.getTeeShirtSize(); Profile profile = ofy().load().key(Key.create(Profile.class, userId)) .now(); if (profile == null) { if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user .getEmail()); } if (teeShirtSize == null) { teeShirtSize = TeeShirtSize.NOT_SPECIFIED; } profile = new Profile(userId, displayName, mainEmail, teeShirtSize); } else { profile.update(displayName, teeShirtSize); } ofy().save().entity(profile).now(); return profile; } }
ConferenceApi { @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String mainEmail = user.getEmail(); String userId = user.getUserId(); String displayName = profileForm.getDisplayName(); TeeShirtSize teeShirtSize = profileForm.getTeeShirtSize(); Profile profile = ofy().load().key(Key.create(Profile.class, userId)) .now(); if (profile == null) { if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user .getEmail()); } if (teeShirtSize == null) { teeShirtSize = TeeShirtSize.NOT_SPECIFIED; } profile = new Profile(userId, displayName, mainEmail, teeShirtSize); } else { profile.update(displayName, teeShirtSize); } ofy().save().entity(profile).now(); return profile; }  }
ConferenceApi { @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String mainEmail = user.getEmail(); String userId = user.getUserId(); String displayName = profileForm.getDisplayName(); TeeShirtSize teeShirtSize = profileForm.getTeeShirtSize(); Profile profile = ofy().load().key(Key.create(Profile.class, userId)) .now(); if (profile == null) { if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user .getEmail()); } if (teeShirtSize == null) { teeShirtSize = TeeShirtSize.NOT_SPECIFIED; } profile = new Profile(userId, displayName, mainEmail, teeShirtSize); } else { profile.update(displayName, teeShirtSize); } ofy().save().entity(profile).now(); return profile; }  @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) // The request that invokes this method should provide data that // conforms to the fields defined in ProfileForm // TODO 1 Pass the ProfileForm parameter // TODO 2 Pass the User parameter Profile saveProfile(final User user, ProfileForm profileForm); @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) Profile getProfile(final User user); @ApiMethod(name = "createConference", path = "conference", httpMethod = HttpMethod.POST) Conference createConference(final User user, final ConferenceForm conferenceForm); @ApiMethod( name = "queryConferences_nofilters", path = "queryConferences_nofilters", httpMethod = HttpMethod.POST ) List<Conference> queryConferences_nofilters(); @ApiMethod( name = "queryConferences", path = "queryConferences", httpMethod = HttpMethod.POST ) List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm); List<Conference> filterPlayground(); @ApiMethod( name = "getConferencesCreated", path = "getConferencesCreated", httpMethod = HttpMethod.POST ) List<Conference> getConferencesCreated(final User user); @ApiMethod( name = "getConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.GET ) Conference getConference(
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "registerForConference", path = "conference/{websafeConferenceKey}/registration", httpMethod = HttpMethod.POST ) WrappedBoolean registerForConference(final User user,
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "unregisterFromConference", path = "conference/{websafeConferenceKey}/registration", httpMethod = HttpMethod.DELETE ) WrappedBoolean unregisterFromConference(final User user,
                                            @Named("websafeConferenceKey")
                                            final String websafeConferenceKey); @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) Collection<Conference> getConferencesToAttend(final User user); @ApiMethod( name = "getAnnouncement", path = "announcement", httpMethod = HttpMethod.GET ) Announcement getAnnouncement(); }
ConferenceApi { @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) public Profile saveProfile(final User user, ProfileForm profileForm) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String mainEmail = user.getEmail(); String userId = user.getUserId(); String displayName = profileForm.getDisplayName(); TeeShirtSize teeShirtSize = profileForm.getTeeShirtSize(); Profile profile = ofy().load().key(Key.create(Profile.class, userId)) .now(); if (profile == null) { if (displayName == null) { displayName = extractDefaultDisplayNameFromEmail(user .getEmail()); } if (teeShirtSize == null) { teeShirtSize = TeeShirtSize.NOT_SPECIFIED; } profile = new Profile(userId, displayName, mainEmail, teeShirtSize); } else { profile.update(displayName, teeShirtSize); } ofy().save().entity(profile).now(); return profile; }  @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) // The request that invokes this method should provide data that // conforms to the fields defined in ProfileForm // TODO 1 Pass the ProfileForm parameter // TODO 2 Pass the User parameter Profile saveProfile(final User user, ProfileForm profileForm); @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) Profile getProfile(final User user); @ApiMethod(name = "createConference", path = "conference", httpMethod = HttpMethod.POST) Conference createConference(final User user, final ConferenceForm conferenceForm); @ApiMethod( name = "queryConferences_nofilters", path = "queryConferences_nofilters", httpMethod = HttpMethod.POST ) List<Conference> queryConferences_nofilters(); @ApiMethod( name = "queryConferences", path = "queryConferences", httpMethod = HttpMethod.POST ) List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm); List<Conference> filterPlayground(); @ApiMethod( name = "getConferencesCreated", path = "getConferencesCreated", httpMethod = HttpMethod.POST ) List<Conference> getConferencesCreated(final User user); @ApiMethod( name = "getConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.GET ) Conference getConference(
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "registerForConference", path = "conference/{websafeConferenceKey}/registration", httpMethod = HttpMethod.POST ) WrappedBoolean registerForConference(final User user,
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "unregisterFromConference", path = "conference/{websafeConferenceKey}/registration", httpMethod = HttpMethod.DELETE ) WrappedBoolean unregisterFromConference(final User user,
                                            @Named("websafeConferenceKey")
                                            final String websafeConferenceKey); @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) Collection<Conference> getConferencesToAttend(final User user); @ApiMethod( name = "getAnnouncement", path = "announcement", httpMethod = HttpMethod.GET ) Announcement getAnnouncement();  }