@Test(expected = NotFoundException.class) public void testGetConferenceToAttendWithoutProfile() throws Exception { conferenceApi.getConferencesToAttend( new User("anotheruser@example.com", "gmail.com", "anotheruserid")); }
@ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) public Collection<Conference> getConferencesToAttend(final User user) throws UnauthorizedException, NotFoundException { if (user == null) { throw new UnauthorizedException("Authorization required"); } Profile profile = ofy().load().key(Key.create(Profile.class, getUserId(user))).now(); if (profile == null) { throw new NotFoundException("Profile doesn't exist."); } List<String> keyStringsToAttend = profile.getConferenceKeysToAttend(); List<Key<Conference>> keysToAttend = new ArrayList<>(); for (String keyString : keyStringsToAttend) { keysToAttend.add(Key.<Conference>create(keyString)); } return ofy().load().keys(keysToAttend).values(); }
ConferenceApi { @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) public Collection<Conference> getConferencesToAttend(final User user) throws UnauthorizedException, NotFoundException { if (user == null) { throw new UnauthorizedException("Authorization required"); } Profile profile = ofy().load().key(Key.create(Profile.class, getUserId(user))).now(); if (profile == null) { throw new NotFoundException("Profile doesn't exist."); } List<String> keyStringsToAttend = profile.getConferenceKeysToAttend(); List<Key<Conference>> keysToAttend = new ArrayList<>(); for (String keyString : keyStringsToAttend) { keysToAttend.add(Key.<Conference>create(keyString)); } return ofy().load().keys(keysToAttend).values(); } }
ConferenceApi { @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) public Collection<Conference> getConferencesToAttend(final User user) throws UnauthorizedException, NotFoundException { if (user == null) { throw new UnauthorizedException("Authorization required"); } Profile profile = ofy().load().key(Key.create(Profile.class, getUserId(user))).now(); if (profile == null) { throw new NotFoundException("Profile doesn't exist."); } List<String> keyStringsToAttend = profile.getConferenceKeysToAttend(); List<Key<Conference>> keysToAttend = new ArrayList<>(); for (String keyString : keyStringsToAttend) { keysToAttend.add(Key.<Conference>create(keyString)); } return ofy().load().keys(keysToAttend).values(); }  }
ConferenceApi { @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) public Collection<Conference> getConferencesToAttend(final User user) throws UnauthorizedException, NotFoundException { if (user == null) { throw new UnauthorizedException("Authorization required"); } Profile profile = ofy().load().key(Key.create(Profile.class, getUserId(user))).now(); if (profile == null) { throw new NotFoundException("Profile doesn't exist."); } List<String> keyStringsToAttend = profile.getConferenceKeysToAttend(); List<Key<Conference>> keysToAttend = new ArrayList<>(); for (String keyString : keyStringsToAttend) { keysToAttend.add(Key.<Conference>create(keyString)); } return ofy().load().keys(keysToAttend).values(); }  @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) Profile getProfile(final User user); @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) Profile saveProfile(final User user, final ProfileForm profileForm); @ApiMethod(name = "createConference", path = "conference", httpMethod = HttpMethod.POST) Conference createConference(final User user, final ConferenceForm conferenceForm); @ApiMethod( name = "updateConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.PUT ) Conference updateConference(final User user, final ConferenceForm conferenceForm,
                                       @Named("websafeConferenceKey")
                                       final String websafeConferenceKey); @ApiMethod( name = "getAnnouncement", path = "announcement", httpMethod = HttpMethod.GET ) Announcement getAnnouncement(); @ApiMethod( name = "getConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.GET ) Conference getConference(
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) Collection<Conference> getConferencesToAttend(final User user); @ApiMethod( name = "queryConferences", path = "queryConferences", httpMethod = HttpMethod.POST ) List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm); @ApiMethod( name = "getConferencesCreated", path = "getConferencesCreated", httpMethod = HttpMethod.POST ) List<Conference> getConferencesCreated(final User user); @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); }
ConferenceApi { @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) public Collection<Conference> getConferencesToAttend(final User user) throws UnauthorizedException, NotFoundException { if (user == null) { throw new UnauthorizedException("Authorization required"); } Profile profile = ofy().load().key(Key.create(Profile.class, getUserId(user))).now(); if (profile == null) { throw new NotFoundException("Profile doesn't exist."); } List<String> keyStringsToAttend = profile.getConferenceKeysToAttend(); List<Key<Conference>> keysToAttend = new ArrayList<>(); for (String keyString : keyStringsToAttend) { keysToAttend.add(Key.<Conference>create(keyString)); } return ofy().load().keys(keysToAttend).values(); }  @ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET) Profile getProfile(final User user); @ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST) Profile saveProfile(final User user, final ProfileForm profileForm); @ApiMethod(name = "createConference", path = "conference", httpMethod = HttpMethod.POST) Conference createConference(final User user, final ConferenceForm conferenceForm); @ApiMethod( name = "updateConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.PUT ) Conference updateConference(final User user, final ConferenceForm conferenceForm,
                                       @Named("websafeConferenceKey")
                                       final String websafeConferenceKey); @ApiMethod( name = "getAnnouncement", path = "announcement", httpMethod = HttpMethod.GET ) Announcement getAnnouncement(); @ApiMethod( name = "getConference", path = "conference/{websafeConferenceKey}", httpMethod = HttpMethod.GET ) Conference getConference(
            @Named("websafeConferenceKey") final String websafeConferenceKey); @ApiMethod( name = "getConferencesToAttend", path = "getConferencesToAttend", httpMethod = HttpMethod.GET ) Collection<Conference> getConferencesToAttend(final User user); @ApiMethod( name = "queryConferences", path = "queryConferences", httpMethod = HttpMethod.POST ) List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm); @ApiMethod( name = "getConferencesCreated", path = "getConferencesCreated", httpMethod = HttpMethod.POST ) List<Conference> getConferencesCreated(final User user); @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);  }