当前位置: 首页>>代码示例>>Java>>正文


Java UserService.getUser方法代码示例

本文整理汇总了Java中org.eclipse.egit.github.core.service.UserService.getUser方法的典型用法代码示例。如果您正苦于以下问题:Java UserService.getUser方法的具体用法?Java UserService.getUser怎么用?Java UserService.getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.egit.github.core.service.UserService的用法示例。


在下文中一共展示了UserService.getUser方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccountInfo

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
public AccountInfo getAccountInfo(String hostUrl, String accountName)
{
    UserService userService = new UserService(githubClientProvider.createClient(hostUrl));
    try
    {
        userService.getUser(accountName);
        return new AccountInfo(GithubCommunicator.GITHUB);

    }
    catch (IOException e)
    {
        log.debug("Unable to retrieve account information. hostUrl: {}, account: {} " + e.getMessage(), hostUrl,
                accountName);
    }
    return null;
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:18,代码来源:GithubCommunicator.java

示例2: isUsernameCorrect

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
public boolean isUsernameCorrect(String hostUrl, String accountName)
{
    UserService userService = userServiceFactory.createUserService(githubClientProvider.createClient(hostUrl));
    User user = null;
    try
    {
        user = userService.getUser(accountName);
    }
    catch (IOException e)
    {
        log.warn("Unable to retrieve account information. hostUrl: {}, account: {} " + e.getMessage(), hostUrl,
                accountName);
    }
    if (user != null)
    {
        return true;
    }
    else
    {
        // if we have blown the rate limit, we give them the benefit of the doubt
        return hasExceededRateLimit(userService.getClient());
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:24,代码来源:GithubCommunicator.java

示例3: getUser

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
public DvcsUser getUser(Repository repository, String username)
{
    try
    {
        UserService userService = githubClientProvider.getUserService(repository);
        User ghUser = userService.getUser(username);
        String login = ghUser.getLogin();
        String name = ghUser.getName();
        String displayName = StringUtils.isNotBlank(name) ? name : login;
        String gravatarUrl = ghUser.getAvatarUrl();

        return new DvcsUser(login, displayName, null, gravatarUrl, repository.getOrgHostUrl() + "/" + login);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:20,代码来源:GithubCommunicator.java

示例4: getTokenOwner

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
public DvcsUser getTokenOwner(Organization organization)
{
    try
    {
        UserService userService = githubClientProvider.getUserService(organization);
        User ghUser = userService.getUser();
        String login = ghUser.getLogin();
        String name = ghUser.getName();
        String displayName = StringUtils.isNotBlank(name) ? name : login;
        String gravatarUrl = ghUser.getAvatarUrl();

        return new DvcsUser(login, displayName, null, gravatarUrl, organization.getHostUrl() + "/" + login);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:20,代码来源:GithubCommunicator.java

示例5: registerCredentials

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
/**
 * Blindly accepts user credentials, no validation with github.
 *
 * @param user
 * @param password
 * @return primary github email for the user
 * @throws se.kth.karamel.common.exception.KaramelException
 */
public synchronized static GithubUser registerCredentials(String user, String password) throws KaramelException {
  try {
    GithubApi.user = user;
    GithubApi.password = password;
    client.setCredentials(user, password);
    client.getUser();
    Confs confs = Confs.loadKaramelConfs();
    confs.put(Settings.GITHUB_USER_KEY, user);
    confs.put(Settings.GITHUB_PASSWORD_KEY, password);
    confs.writeKaramelConfs();
    UserService us = new UserService(client);
    if (us == null) {
      throw new KaramelException("Could not find user or password incorret: " + user);
    }
    User u = us.getUser();
    if (u == null) {
      throw new KaramelException("Could not find user or password incorret: " + user);
    }
    GithubApi.email = u.getEmail();
  } catch (IOException ex) {
    logger.warn("Problem connecting to GitHub: " + ex.getMessage());
  }
  return new GithubUser(GithubApi.user, GithubApi.password, GithubApi.email);
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:33,代码来源:GithubApi.java

示例6: doGet

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	UserService userService = new UserService();
	userService.getClient().setOAuth2Token(req.getParameter("access_token"));
	User user = userService.getUser();
	
	String avatarUrl = user.getAvatarUrl();
	String login = user.getLogin();
	
	JSONObject json = new JSONObject();
	try {
		json.put("avatar", avatarUrl);
		json.put("login", login);
	} catch(JSONException e) {}
	
	resp.setContentType("application/json");
	resp.getWriter().write(json.toString());
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:19,代码来源:AvatarServlet.java

示例7: doGet

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	GitHubClient client = new GitHubClient();
	client.setOAuth2Token(req.getParameter("access_token"));
	UserService userService = new UserService(client);
	
	String login = req.getParameter("user");
	
	User user = userService.getUser(login);
	
	JSONObject userJ = new JSONObject();

	try {
		userJ.put("login", user.getLogin());
		userJ.put("email", user.getEmail());
		userJ.put("name", user.getName());
		
		resp.setContentType("application/json");
		resp.getWriter().write(userJ.toString());
	} catch(JSONException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:24,代码来源:UserServlet.java

示例8: doGet

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	GitHubClient client = new GitHubClient();
	client.setOAuth2Token(req.getParameter("access_token"));
	
	UserService userService = new UserService(client);
	User user = userService.getUser();
	OrganizationService orgService = new OrganizationService(client);
	List<User> users = orgService.getOrganizations(user.getLogin());
	
	JSONArray logins = new JSONArray();
	logins.put(user.getLogin());
	for(User u : users) {
		logins.put(u.getLogin());
	}
	
	resp.setContentType("application/json");
	resp.getWriter().write(logins.toString());
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:20,代码来源:RepoSourceServlet.java

示例9: run

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
public void run() {
		try {
			GitHubClient client = new GitHubClient();
			client.setOAuth2Token(accessToken);
			
			DBAbstraction database = DatabaseFactory.getDatabase();
			UserService userService = new UserService(client);
			User reviewer = userService.getUser();
			List<Label> customLabels = createCustomLabels(client);
			
			createIssues(client, customLabels);
			
			String closeComment = "@" + reviewer.getLogin() + " has reviewed this paper.";
			
                  closeReviewIssue(client, repo, reviewer.getLogin(), closeComment);
			
			database.removeReviewFromDatastore(reviewer.getLogin(), repo);
			
		} catch(IOException e) {
		    e.printStackTrace();
			System.err.println("Error processing Pdf.");
		}
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:25,代码来源:ReviewSubmitServlet.java

示例10: pushAllChangesToGit

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
/**
 * Must be called after #{createGitRepository()}
 */
public void pushAllChangesToGit() throws IOException {
    if (localRepository == null) {
        throw new IOException("Git has not been created, call createGitRepositoryFirst");
    }
    try {
        UserService userService = new UserService();
        userService.getClient().setOAuth2Token(oAuthToken);
        User user = userService.getUser();
        String name = user.getLogin();
        String email = user.getEmail();
        if (email == null) {
            // This is the e-mail addressed used by GitHub on web commits where the users mail is private. See:
            // https://github.com/settings/emails
            email = name + "@users.noreply.github.com";
        }

        localRepository.add().addFilepattern(".").call();
        localRepository.commit()
                .setMessage("Initial commit")
                .setCommitter(name, email)
                .call();
        PushCommand pushCommand = localRepository.push();
        addAuth(pushCommand);
        pushCommand.call();
    } catch (GitAPIException e) {
        throw new IOException("Error pushing changes to GitHub", e);
    }
}
 
开发者ID:WASdev,项目名称:tool.accelerate.core,代码行数:32,代码来源:GitHubConnector.java

示例11: getBasicUserInfo

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Cacheable(value = "github",key="#accessToken + 'userInfo'")
public User getBasicUserInfo(String accessToken) throws Exception
{
	UserService uService=new UserService();
	uService.getClient().setOAuth2Token(accessToken);
	return uService.getUser();
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:8,代码来源:PageManager.java

示例12: index

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@GET
public View index(@Auth final GitHubClient client) throws IOException {
    final UserService users = new UserService(client);
    return new IndexView(users.getUser(), this.repositories, this.githubHostname);
}
 
开发者ID:plan3,项目名称:stoneboard,代码行数:6,代码来源:Milestones.java

示例13: doPost

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
@Override
protected void doPost(final HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    final ServletFileUpload upload = new ServletFileUpload();

    Repo repo = new Repo(req.getParameter("writer"), req.getParameter("repoName"));
    String accessToken = req.getParameter("access_token");

    if (repo.repoOwner == null || repo.repoName == null || accessToken == null) {
        System.out.println("Something blank");
        resp.sendError(500);
        return;
    }
    
    GitHubClient client = new GitHubClient();
    client.setOAuth2Token(accessToken);
    UserService userService = new UserService(client);
    User reviewer = userService.getUser();
    
    Review fulfilledReview = DatabaseFactory.getDatabase().findReview(reviewer.getLogin(), repo);
    if (fulfilledReview == null) {
        //either they already uploaded the pdf or it doesn't exist
        resp.sendError(409);  //409 = conflict
        return;
    }

    UploadIssuesRunnable task = new UploadIssuesRunnable();
    String urlToPdfInRepo = "";
    Pdf pdf = null;
    try {
        FileItemIterator iter = upload.getItemIterator(req);
        FileItemStream file = iter.next();
        pdf = new Pdf(file.openStream(), getServletContext());
        
        int totalIssues = getNumTotalIssues(client, repo);      //TODO perhaps involve database to avoid race conditions

        List<PdfComment> comments = updatePdfWithNumberedAndColoredAnnotations(pdf, repo, totalIssues);
        urlToPdfInRepo = addPdfToRepo(pdf, reviewer, client, repo, accessToken);
        task.setter(comments, accessToken, repo, totalIssues, fulfilledReview.customLabels);
        
    } catch (Exception e) {
        e.printStackTrace();
        resp.sendError(500, "There has been an error uploading your Pdf.");
        return;
    } finally {
        if (pdf != null) {
            pdf.close();
        }
    }

    resp.getWriter().write(urlToPdfInRepo);
    Thread thread = new Thread(task);
    thread.start();
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:54,代码来源:ReviewSubmitServlet.java

示例14: userFromLogin

import org.eclipse.egit.github.core.service.UserService; //导入方法依赖的package包/类
public static PDFUser userFromLogin(String login, UserService userService) throws IOException {
    User user = userService.getUser(login);
    return new PDFUser(login, user.getEmail(), user.getName());
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:5,代码来源:PDFUser.java


注:本文中的org.eclipse.egit.github.core.service.UserService.getUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。