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_COLLABORATORS;
 import static org.eclipse.egit.github.core.client.IGitHubConstants.SEGMENT_REPOS;
 
 
 import java.util.List;
 
Service for interacting with the collaborators on a GitHub repository

See also:
GitHub collaborator API documentation
 
 public class CollaboratorService extends GitHubService {

Create collaborator service
 
 	public CollaboratorService() {
 		super();
 	}

Create collaborator service

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

Get collaborators for given repository

Parameters:
repository
Returns:
non-null list of collaborators
Throws:
java.io.IOException
 
 			throws IOException {
 		String id = getId(repository);
 		uri.append('/').append(id);
 		request.setUri(uri);
 		request.setType(new TypeToken<List<User>>() {
 		}.getType());
 		return getAll(request);
 	}

Create URI for updating collaborators

Parameters:
repository
user
Returns:
URI
 
 	protected String createUpdateUri(IRepositoryIdProvider repository,
 			String user) {
 		String id = getId(repository);
 		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$
 
 		uri.append('/').append(id);
 		uri.append('/').append(user);
 		return uri.toString();
 	}

Is given user a collaborator on the given repository?

Parameters:
repository
user
Returns:
true if collaborator, false otherwise
Throws:
java.io.IOException
 
	public boolean isCollaborator(IRepositoryIdProvider repositoryString user)
			throws IOException {
		return check(createUpdateUri(repositoryuser));
	}

Add given user as a collaborator on the given repository

Parameters:
repository
user
Throws:
java.io.IOException
	public void addCollaborator(IRepositoryIdProvider repositoryString user)
			throws IOException {
		.put(createUpdateUri(repositoryuser));
	}

Remove given user as a collaborator on the given repository

Parameters:
repository
user
Throws:
java.io.IOException
	public void removeCollaborator(IRepositoryIdProvider repositoryString user)
			throws IOException {
		.delete(createUpdateUri(repositoryuser));
	}
New to GrepCode? Check out our FAQ X