Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 GitHub Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Kevin Sawicki (GitHub Inc.) - initial API and implementation /
 
 package org.eclipse.egit.github.core.service;
 
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USER;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_USERS;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_WATCHED;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_WATCHERS;
 import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_FIRST;
 import static org.eclipse.egit.github.core.client.PagedRequest.PAGE_SIZE;
 
 
 import java.util.List;
 
Service class for dealing with users watching GitHub repositories.

See also:
GitHub watcher API documentation
 
 public class WatcherService extends GitHubService {

Create watcher service
 
 	public WatcherService() {
 		super();
 	}

Create watcher service

Parameters:
client
 
 	public WatcherService(GitHubClient client) {
 		super(client);
 	}

Create page watcher request

Parameters:
repository
start
size
Returns:
request
 
 			IRepositoryIdProvider repositoryint startint size) {
 		String id = getId(repository);
 		PagedRequest<Userrequest = createPagedRequest(startsize);
 		uri.append('/').append(id);
 		request.setUri(uri);
 		request.setType(new TypeToken<List<User>>() {
 		}.getType());
 		return request;
 	}

Get user watching given repository

Parameters:
repository
Returns:
non-null but possibly empty list of users
Throws:
java.io.IOException
 
 	public List<UsergetWatchers(IRepositoryIdProvider repository)
 			throws IOException {
 		PagedRequest<Userrequest = createWatcherRequest(repository,
 		return getAll(request);
 	}

Page watches of given repository

Parameters:
repository
Returns:
page iterator
Throws:
java.io.IOException
 
			throws IOException {
		return pageWatchers(repository);
	}

Page watches of given repository

Parameters:
repository
size
Returns:
page iterator
Throws:
java.io.IOException
			int sizethrows IOException {
		return pageWatchers(repositorysize);
	}

Page watches of given repository

Parameters:
repository
start
size
Returns:
page iterator
Throws:
java.io.IOException
			int startint sizethrows IOException {
		PagedRequest<Userrequest = createWatcherRequest(repositorystart,
				size);
		return createPageIterator(request);
	}

Create page watched request

Parameters:
user
start
size
Returns:
request
			int startint size) {
		if (user == null)
			throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
		if (user.length() == 0)
			throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$
		PagedRequest<Repositoryrequest = createPagedRequest(startsize);
		uri.append('/').append(user);
		request.setUri(uri);
		request.setType(new TypeToken<List<Repository>>() {
		}.getType());
		return request;
	}

Create page watched request

Parameters:
start
size
Returns:
request
	protected PagedRequest<RepositorycreateWatchedRequest(int startint size) {
		PagedRequest<Repositoryrequest = createPagedRequest(startsize);
		request.setType(new TypeToken<List<Repository>>() {
		}.getType());
		return request;
	}

Get repositories watched by the given user

Parameters:
user
Returns:
non-null but possibly empty list of repositories
Throws:
java.io.IOException
	public List<RepositorygetWatched(String userthrows IOException {
		return getAll(request);
	}

Page repositories being watched by given user

Parameters:
user
Returns:
page iterator
Throws:
java.io.IOException
		return pageWatched(user);
	}

Page repositories being watched by given user

Parameters:
user
size
Returns:
page iterator
Throws:
java.io.IOException
	public PageIterator<RepositorypageWatched(String userint size)
			throws IOException {
		return pageWatched(usersize);
	}

Page repositories being watched by given user

Parameters:
user
start
size
Returns:
page iterator
Throws:
java.io.IOException
	public PageIterator<RepositorypageWatched(String userint startint size)
			throws IOException {
		PagedRequest<Repositoryrequest = createWatchedRequest(userstart,
				size);
		return createPageIterator(request);
	}

Get repositories watched by the currently authenticated user

Returns:
non-null but possibly empty list of repositories
Throws:
java.io.IOException
	public List<RepositorygetWatched() throws IOException {
		return getAll(request);
	}

Page repositories being watched by the currently authenticated user

Returns:
page iterator
Throws:
java.io.IOException
	}

Page repositories being watched by the currently authenticated user

Parameters:
size
Returns:
page iterator
Throws:
java.io.IOException
	public PageIterator<RepositorypageWatched(int sizethrows IOException {
		return pageWatched(size);
	}

Page repositories being watched by the currently authenticated user

Parameters:
start
size
Returns:
page iterator
Throws:
java.io.IOException
	public PageIterator<RepositorypageWatched(int startint size)
			throws IOException {
		PagedRequest<Repositoryrequest = createWatchedRequest(startsize);
		return createPageIterator(request);
	}

Is currently authenticated user watching given repository?

Parameters:
repository
Returns:
true if watch, false otherwise
Throws:
java.io.IOException
	public boolean isWatching(IRepositoryIdProvider repository)
			throws IOException {
		String id = getId(repository);
		uri.append('/').append(id);
		return check(uri.toString());
	}

Add currently authenticated user as a watcher of the given repository

Parameters:
repository
Throws:
java.io.IOException
	public void watch(IRepositoryIdProvider repositorythrows IOException {
		String id = getId(repository);
		uri.append('/').append(id);
	}

Remove currently authenticated user as a watcher of the given repository

Parameters:
repository
Throws:
java.io.IOException
	public void unwatch(IRepositoryIdProvider repositorythrows IOException {
		String id = getId(repository);
		uri.append('/').append(id);
	}
New to GrepCode? Check out our FAQ X