@Test public void testGetProfileFirstTime() throws Exception { Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now(); assertNull(profile); profile = conferenceApi.getProfile(user); assertNull(profile); }
@ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); Key key = Key.create(Profile.class, userId); Profile profile = (Profile) ofy().load().key(key).now(); return profile; }
ConferenceApi { @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); Key key = Key.create(Profile.class, userId); Profile profile = (Profile) ofy().load().key(key).now(); return profile; } }
ConferenceApi { @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); Key key = Key.create(Profile.class, userId); Profile profile = (Profile) ofy().load().key(key).now(); return profile; }  }
ConferenceApi { @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); Key key = Key.create(Profile.class, userId); Profile profile = (Profile) ofy().load().key(key).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); }
ConferenceApi { @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) public Profile getProfile(final User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException("Authorization required"); } String userId = user.getUserId(); Key key = Key.create(Profile.class, userId); Profile profile = (Profile) ofy().load().key(key).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);  }