}
}
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.