Package com.streamreduce.util

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


        }
    }

    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

    }

    @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

        credentials.setApiKey(null);
    }

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

TOP

Related Classes of com.streamreduce.util.GitHubClient

Copyright © 2018 www.massapicom. 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.