Search in sources :

Example 1 with RepositoryBranchesRequest

use of com.atlassian.stash.repository.RepositoryBranchesRequest in project stash-codesearch-plugin by palantir.

the class RepositoryServiceManagerImpl method getBranchMap.

@Override
public ImmutableMap<String, Branch> getBranchMap(Repository repository) {
    PageRequest req = new PageRequestImpl(0, PAGE_SIZE);
    Map<String, Branch> branchMap = new HashMap<String, Branch>();
    RepositoryBranchesRequest rbr = new RepositoryBranchesRequest.Builder().repository(repository).order(RefOrder.ALPHABETICAL).build();
    while (true) {
        Page<? extends Branch> branchPage = repositoryMetadataService.getBranches(rbr, req);
        for (Branch b : branchPage.getValues()) {
            if (branchMap.containsKey(b)) {
                log.error("Tryting to insert existing key '" + b.getId() + "' into branchMap with value '" + b + "'");
                continue;
            }
            branchMap.put(b.getId(), b);
        }
        if (branchPage.getIsLastPage()) {
            break;
        }
        req = branchPage.getNextPageRequest();
    }
    return ImmutableMap.copyOf(branchMap);
}
Also used : PageRequest(com.atlassian.stash.util.PageRequest) HashMap(java.util.HashMap) Branch(com.atlassian.stash.repository.Branch) RepositoryBranchesRequest(com.atlassian.stash.repository.RepositoryBranchesRequest) PageRequestImpl(com.atlassian.stash.util.PageRequestImpl)

Aggregations

Branch (com.atlassian.stash.repository.Branch)1 RepositoryBranchesRequest (com.atlassian.stash.repository.RepositoryBranchesRequest)1 PageRequest (com.atlassian.stash.util.PageRequest)1 PageRequestImpl (com.atlassian.stash.util.PageRequestImpl)1 HashMap (java.util.HashMap)1