Search in sources :

Example 96 with SneakyThrows

use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.

the class MylynGitHubApi method findRepositoryNamesWithAdminPermission.

@Override
@SneakyThrows
public List<String> findRepositoryNamesWithAdminPermission(String accessToken) {
    GitHubClient client = createClient(accessToken);
    WithPermissionsRepositoryService service = new WithPermissionsRepositoryService(client);
    List<WithPermissionsRepository> repositories = service.getPermissionRepositories();
    List<String> repoSlugs = new ArrayList<>();
    for (WithPermissionsRepository r : repositories) {
        if (!r.getPermissions().isAdmin()) {
            continue;
        }
        org.eclipse.egit.github.core.User owner = r.getOwner();
        repoSlugs.add(owner.getLogin() + "/" + r.getName());
    }
    return repoSlugs;
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) WithPermissionsRepository(io.pivotal.cla.egit.github.core.WithPermissionsRepository) WithPermissionsRepositoryService(io.pivotal.cla.egit.github.core.service.WithPermissionsRepositoryService) SneakyThrows(lombok.SneakyThrows)

Example 97 with SneakyThrows

use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.

the class MylynGitHubApi method save.

@SneakyThrows
public void save(PullRequestStatus commitStatus) {
    String repoId = commitStatus.getRepoId();
    String accessToken = commitStatus.getAccessToken();
    if (accessToken == null) {
        return;
    }
    PullRequestId pullRequestId = PullRequestId.of(RepositoryId.createFromId(repoId), commitStatus.getPullRequestId());
    boolean hasSignedCla = commitStatus.isSuccess();
    GitHubClient client = createClient(accessToken);
    String claUserLogin = getGitHubClaUserLogin();
    List<Comment> comments = getComments(pullRequestId, getIssueService());
    boolean obviousFix = isObviousFix(pullRequestId, comments, claUserLogin, commitStatus.getPullRequestBody());
    ContextCommitStatus status = createCommitStatusIfNecessary(pullRequestId, commitStatus, hasSignedCla, obviousFix, client);
    createOrUpdatePullRequestComment(pullRequestId, commitStatus, hasSignedCla, obviousFix, status, comments, claUserLogin);
}
Also used : Comment(org.eclipse.egit.github.core.Comment) CommitComment(org.eclipse.egit.github.core.CommitComment) GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) PullRequestId(io.pivotal.cla.egit.github.core.PullRequestId) ContextCommitStatus(io.pivotal.cla.egit.github.core.ContextCommitStatus) SneakyThrows(lombok.SneakyThrows)

Example 98 with SneakyThrows

use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.

the class MylynGitHubApi method getOrganizations.

@SneakyThrows
public List<String> getOrganizations(String username) {
    OrganizationService orgs = new OrganizationService(createClient(oauthConfig.getPivotalClaAccessToken()));
    List<org.eclipse.egit.github.core.User> organizations = orgs.getOrganizations(username);
    return organizations.stream().map(o -> o.getLogin()).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList());
}
Also used : OrganizationService(org.eclipse.egit.github.core.service.OrganizationService) User(io.pivotal.cla.data.User) SneakyThrows(lombok.SneakyThrows)

Example 99 with SneakyThrows

use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.

the class MylynGitHubApi method getCurrentGitHubUser.

@SneakyThrows
private org.eclipse.egit.github.core.User getCurrentGitHubUser(String accessToken) {
    GitHubClient client = createClient(accessToken);
    org.eclipse.egit.github.core.service.UserService githubUsers = new org.eclipse.egit.github.core.service.UserService(client);
    return githubUsers.getUser();
}
Also used : GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) SneakyThrows(lombok.SneakyThrows)

Example 100 with SneakyThrows

use of lombok.SneakyThrows in project pivotal-cla by pivotalsoftware.

the class MylynGitHubApi method findPullRequest.

@Override
@SneakyThrows
public Optional<PullRequest> findPullRequest(String repoId, int pullRequestId, String accessToken) {
    GitHubClient client = createClient(accessToken);
    PullRequestService service = new PullRequestService(client);
    try {
        return Optional.ofNullable(service.getPullRequest(RepositoryId.createFromId(repoId), pullRequestId));
    } catch (RequestException e) {
        if (e.getStatus() == HttpStatus.NOT_FOUND.value()) {
            return Optional.empty();
        }
        throw e;
    }
}
Also used : PullRequestService(org.eclipse.egit.github.core.service.PullRequestService) GitHubClient(org.eclipse.egit.github.core.client.GitHubClient) RequestException(org.eclipse.egit.github.core.client.RequestException) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)706 lombok.val (lombok.val)314 Test (org.junit.Test)91 ArrayList (java.util.ArrayList)75 HashMap (java.util.HashMap)63 List (java.util.List)53 Cleanup (lombok.Cleanup)38 Map (java.util.Map)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)34 Collectors (java.util.stream.Collectors)34 LinkedHashMap (java.util.LinkedHashMap)30 File (java.io.File)28 Path (java.nio.file.Path)28 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 URL (java.net.URL)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)17