Search in sources :

Example 1 with BookmarkedSession

use of com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession in project iosched by google.

the class UserdataEndpoint method addBookmarkedSessions.

/**
 * Add a bookmarked session for the current user. If the session is already in the user's feed,
 * it will be annotated with inSchedule=true.
 *
 * @param user         Current user (injected by Endpoints)
 * @param sessionIds   Session IDs to mark as bookmarked.
 * @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
 *                     different than the time this method is called if offline sync is
 *                     implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
 * @return The list of bookmarked sessions for the user
 */
@ApiMethod(name = "addBookmarkedSessions", path = "bookmarked/batch", httpMethod = ApiMethod.HttpMethod.POST)
public Map<String, BookmarkedSession> addBookmarkedSessions(User user, @Named("sessionIds") String[] sessionIds, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
    UserData data = getUser(user);
    for (String session : sessionIds) {
        BookmarkedSession s = new BookmarkedSession(session, true, timestampUTC);
        data.bookmarkedSessions.put(session, s);
    }
    save(data);
    return data.bookmarkedSessions;
}
Also used : BookmarkedSession(com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession) UserData(com.google.samples.apps.iosched.server.userdata.db.UserData) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Example 2 with BookmarkedSession

use of com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession in project iosched by google.

the class UserdataEndpoint method removeBookmarkedSessions.

/**
 * Remove a bookmarked session for the current user. The session will still be
 * attached to the user's feed, but will be annotated with inSchedule=false.
 *
 * @param user          Current user (injected by Endpoints)
 * @param sessionIds    Session IDs to mark as not bookmarked.
 * @param timestampUTC  The time (in millis, UTC) when the user performed this action. May be
 *                      different than the time this method is called if offline sync is
 *                      implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
 */
@ApiMethod(name = "removeBookmarkedSessions", path = "bookmarked/batch", httpMethod = ApiMethod.HttpMethod.DELETE)
public void removeBookmarkedSessions(User user, @Named("sessionIds") String[] sessionIds, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
    UserData data = getUser(user);
    for (String session : sessionIds) {
        BookmarkedSession s = new BookmarkedSession(session, false, timestampUTC);
        data.bookmarkedSessions.put(session, s);
    }
    save(data);
}
Also used : BookmarkedSession(com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession) UserData(com.google.samples.apps.iosched.server.userdata.db.UserData) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Example 3 with BookmarkedSession

use of com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession in project iosched by google.

the class UserdataEndpoint method removeBookmarkedSession.

/**
 * Remove a bookmarked session for the current user. The session will still be
 * attached to the user's feed, but will be annotated with inSchedule=false.
 *
 * @param user         Current user (injected by Endpoints)
 * @param sessionId    Session ID to mark as not bookmarked.
 * @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
 *                     different than the time this method is called if offline sync is
 *                     implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
 */
@ApiMethod(name = "removeBookmarkedSession", path = "bookmarked", httpMethod = ApiMethod.HttpMethod.DELETE)
public void removeBookmarkedSession(User user, @Named("sessionId") String sessionId, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
    UserData data = getUser(user);
    BookmarkedSession s = new BookmarkedSession(sessionId, false, timestampUTC);
    data.bookmarkedSessions.put(sessionId, s);
    save(data);
}
Also used : BookmarkedSession(com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession) UserData(com.google.samples.apps.iosched.server.userdata.db.UserData) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Example 4 with BookmarkedSession

use of com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession in project iosched by google.

the class UserdataEndpoint method addBookmarkedSession.

/**
 * Add a bookmarked session for the current user. If the session is already in the user's feed,
 * it will be annotated with inSchedule=true.
 *
 * @param user         Current user (injected by Endpoints)
 * @param sessionId    Session ID to mark as bookmarked.
 * @param timestampUTC The time (in millis, UTC) when the user performed this action. May be
 *                     different than the time this method is called if offline sync is
 *                     implemented. MUST BE ACCURATE - COMPENSATE FOR CLOCK DRIFT!
 * @return The list of bookmarked sessions for the user
 */
@ApiMethod(name = "addBookmarkedSession", path = "bookmarked", httpMethod = ApiMethod.HttpMethod.PUT)
public Map<String, BookmarkedSession> addBookmarkedSession(User user, @Named("sessionId") String sessionId, @Named("timestampUTC") long timestampUTC) throws UnauthorizedException {
    UserData data = getUser(user);
    BookmarkedSession s = new BookmarkedSession(sessionId, true, timestampUTC);
    data.bookmarkedSessions.put(sessionId, s);
    save(data);
    return data.bookmarkedSessions;
}
Also used : BookmarkedSession(com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession) UserData(com.google.samples.apps.iosched.server.userdata.db.UserData) ApiMethod(com.google.api.server.spi.config.ApiMethod)

Aggregations

ApiMethod (com.google.api.server.spi.config.ApiMethod)4 BookmarkedSession (com.google.samples.apps.iosched.server.userdata.db.BookmarkedSession)4 UserData (com.google.samples.apps.iosched.server.userdata.db.UserData)4