/** * Remove currently authenticated user as a watcher of the given repository * * @param repository * @throws IOException */ public void unwatch(IRepositoryIdProvider repository) throws IOException { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_USER); uri.append(SEGMENT_WATCHED); uri.append('/').append(id); client.delete(uri.toString()); } }
/** * Add currently authenticated user as a watcher of the given repository * * @param repository * @throws IOException */ public void watch(IRepositoryIdProvider repository) throws IOException { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_USER); uri.append(SEGMENT_WATCHED); uri.append('/').append(id); client.put(uri.toString()); }
/** * Is currently authenticated user watching given repository? * * @param repository * @return true if watch, false otherwise * @throws IOException */ public boolean isWatching(IRepositoryIdProvider repository) throws IOException { String id = getId(repository); StringBuilder uri = new StringBuilder(SEGMENT_USER); uri.append(SEGMENT_WATCHED); uri.append('/').append(id); return check(uri.toString()); }
/** * Create page watcher request * * @param repository * @param start * @param size * @return request */ protected PagedRequest<User> createWatcherRequest( IRepositoryIdProvider repository, int start, int size) { String id = getId(repository); PagedRequest<User> request = createPagedRequest(start, size); StringBuilder uri = new StringBuilder(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_WATCHERS); request.setUri(uri); request.setType(new TypeToken<List<User>>() { }.getType()); return request; }