Examples of GitHubClient


Examples of com.streamreduce.util.GitHubClient

    private void validateGitHubProjectHostingInventoryItems(Connection connection) throws Exception {
        // Let the project inventory refresh process finish
        Thread.sleep(60000);

        final GitHubClient gitHubClient = (GitHubClient)
                connectionProviderFactory.externalIntegrationConnectionProviderFromId(
                        connection.getProviderId()).getClient(connection);

        final List<JSONObject> rawGitHubProjects = gitHubClient.getRepositories();
        final Map<String, JSONObject> rawGitHubProjectsMap = new HashMap<>();

        /* Create a map for easier project retrieval */
        for (JSONObject project : rawGitHubProjects) {
            String key = project.getJSONObject("owner").getString("login") + "/" + project.getString("name");
View Full Code Here

Examples of com.streamreduce.util.GitHubClient

        }
    }

    private void pullGitHubActivity(Connection connection)
            throws ConnectionNotFoundException, InvalidCredentialsException, IOException {
        GitHubClient client = (GitHubClient)getClient(connection);
        Map<String, InventoryItem> inventoryItemMap = getInventoryItemMap(connection);
        List<JSONObject> feedEntries = client.getActivity(inventoryItemMap.keySet());
        Date lastActivityPoll = connection.getLastActivityPollDate();
        Date lastActivity = lastActivityPoll;

        try {
            for (JSONObject entry : feedEntries) {
                String projectKey = entry.getJSONObject("repo").getString("name");
                InventoryItem inventoryItem = inventoryItemMap.get(projectKey);

                if (inventoryItem == null) {
                    continue;
                }

                Date pubDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(entry.getString("created_at"));

                // Only create messages newer than the last activity poll date
                if (pubDate.before(lastActivityPoll)) {
                    continue;
                }

                if (pubDate.after(lastActivity)) {
                    lastActivity = pubDate;
                }

                Map<String, Object> activityParts = client.getPartsForActivity(inventoryItem, entry);

                // This can happen for unknown events which we log
                if (activityParts == null) {
                    // We have ran into a GitHub activity we do not know how to handle. Log the issue with as much
                    // detail as possible.
View Full Code Here

Examples of com.streamreduce.util.GitHubClient

    }

    @Override
    public String getIdentityFromProvider(Connection c) {
        try {
            GitHubClient gitHubClient = getClient(c);
            JSONObject jsonObject = gitHubClient.getUser();
            return jsonObject.getString("login");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

Examples of com.streamreduce.util.GitHubClient

        credentials.setApiKey(null);
    }

    @Override
    public GitHubClient  getClient(Connection connection) {
        return new GitHubClient(connection,getOAuthService());
    }
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

   */
  protected GitHubClient createClient(String host, String userName,
      String password, String oauth2Token, String serverId,
      Settings settings, MavenSession session)
      throws MojoExecutionException {
    GitHubClient client;
    if (!StringUtils.isEmpty(host)) {
      if (isDebug())
        debug("Using custom host: " + host);
      client = createClient(host);
    } else
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

   * @throws MojoExecutionException
   */
  protected GitHubClient createClient(String hostname)
      throws MojoExecutionException {
    if (!hostname.contains("://"))
      return new GitHubClient(hostname);
    try {
      URL hostUrl = new URL(hostname);
      return new GitHubClient(hostUrl.getHost(), hostUrl.getPort(),
          hostUrl.getProtocol());
    } catch (MalformedURLException e) {
      throw new MojoExecutionException("Could not parse host URL "
          + hostname, e);
    }
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

   * Subclasses can override to do any custom client configuration
   *
   * @return non-null client
   */
  protected GitHubClient createClient() {
    return new GitHubClient();
  }
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

    }
   
    String[] paths = getPaths(outputDirectory);
    String prefix = getPrefix(destinationDirectory);
   
    GitHubClient client = createClient(host, userName, password, oauth2Token);
    DataService service = new DataService(client);
   
    boolean createNoJekyll = noJekyll;
   
    if(createNoJekyll){
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

      throw new GitHubException("Error creating blob from '" + path + "': " + e.getMessage(), e);
    }
  }

  private GitHubClient createClient(String host, String userName, String password, String oauth2Token) throws GitHubException {
    GitHubClient client;
    if (!StringUtils.isEmpty(host)) {
      if (log.isDebugEnabled()){
        log.debug("Using custom host: " + host);
      }
      client = createClient(host);
    } else{
      client = new GitHubClient();
    }
   
    if(!StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password)){
      if (log.isDebugEnabled()){
        log.debug("Using basic authentication with username: " + userName);
      }
      client.setCredentials(userName, password);
      return client;
    }else if(!StringUtils.isEmpty(oauth2Token)){
      if (log.isDebugEnabled()){
        log.debug("Using OAuth2 access token authentication");
      }
      client.setOAuth2Token(oauth2Token);
      return client;
    }else if(StringUtils.isEmpty(userName) && !StringUtils.isEmpty(password)){
      if (log.isDebugEnabled()){
        log.debug("Using OAuth2 access token authentication");
      }
      client.setOAuth2Token(password);
      return client;
    }else if(!StringUtils.isEmpty(userName) && System.console() != null){
      Console console = System.console();
      while(StringUtils.isEmpty(password)){
        password = new String(console.readPassword("Input the password for '" + userName + "': "));
      }
      client.setCredentials(userName, password);
      return client;
    }

    throw new GitHubException("No authentication credentials configured");
  }
View Full Code Here

Examples of org.eclipse.egit.github.core.client.GitHubClient

   * @return non-null client
   * @throws MojoExecutionException
   */
  private GitHubClient createClient(String hostnamethrows GitHubException {
    if (!hostname.contains("://"))
      return new GitHubClient(hostname);
    try {
      URL hostUrl = new URL(hostname);
      return new GitHubClient(hostUrl.getHost(), hostUrl.getPort(), hostUrl.getProtocol());
    } catch (MalformedURLException e) {
      throw new GitHubException("Could not parse host URL " + hostname, e);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.