本文整理汇总了Java中org.eclipse.egit.github.core.client.PageIterator类的典型用法代码示例。如果您正苦于以下问题:Java PageIterator类的具体用法?Java PageIterator怎么用?Java PageIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageIterator类属于org.eclipse.egit.github.core.client包,在下文中一共展示了PageIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pageComments2
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
public PageIterator<ExtendedCommitComment> pageComments2(final IRepositoryIdProvider repository,
final String sha,
final int start,
final int size) {
Objects.requireNonNull(sha, "sha cannot be null");
if(sha.isEmpty()) {
throw new IllegalArgumentException("sha cannot be empty");
}
String id = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(id);
uri.append("/commits");
uri.append('/').append(sha);
uri.append("/comments");
PagedRequest<ExtendedCommitComment> request = createPagedRequest(start, size);
request.setUri(uri);
request.setType((new TypeToken<List<ExtendedCommitComment>>() {}).getType());
return createPageIterator(request);
}
示例2: nullProcessedPRsAreHandledGracefully
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
@Test
public void nullProcessedPRsAreHandledGracefully() throws IOException
{
final Long[] prIds = new Long[] {1L, 2L, 3L};
final PageIterator<PullRequest> prIterator = mockPageIterator(ImmutableList.copyOf(prIds));
when(gitHubPullRequestService.pagePullRequests(any(IRepositoryIdProvider.class), eq(STATE_ALL), eq(SORT_UPDATED), eq(DIRECTION_DESC), eq(DEFAULT_PAGE), eq(DEFAULT_PAGELEN)))
.thenReturn(prIterator);
when(gitHubPullRequestProcessor.processPullRequestIfNeeded(eq(repository), any(PullRequest.class))).thenReturn(true);
testedClass.onReceive(message, mockPayload(true, DEFAULT_PAGE, DEFAULT_PAGELEN, null));
verify(gitHubPullRequestProcessor, times(3)).processPullRequestIfNeeded(eq(repository), any(PullRequest.class));
// next msg is fired
verify(messagingService).publish(any(MessageAddress.class), matchMessageWithProcessedPrIds(prIds), any(String[].class));
}
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:17,代码来源:GitHubPullRequestPageMessageConsumerTest.java
示例3: getPagedItems
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* A specialised version of GitHubService::getPage that does logging.
*
* @param iterator the paged request to iterate through
* @return a list of items
* @throws IOException
*/
protected List<T> getPagedItems(String resourceDesc, PageIterator<T> iterator) throws IOException {
List<T> elements = new ArrayList<>();
int length = 0;
int page = 0;
try {
while (iterator.hasNext()) {
elements.addAll(iterator.next());
int diff = elements.size() - length;
length = elements.size();
logger.info(resourceDesc + " | page " + (page++) + ": " + diff + " items");
}
} catch (NoSuchPageException pageException) {
throw pageException.getCause();
}
return elements;
}
示例4: getUpdatedItems
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Overrides the parent's method to remove ETags checking step and use the specialized
* method get
*
* @param repoId the repository to get the items from
* @return
*/
@Override
public ArrayList<PullRequest> getUpdatedItems(IRepositoryIdProvider repoId) {
if (updatedItems != null) {
return updatedItems;
}
ArrayList<PullRequest> result = new ArrayList<>();
String resourceDesc = repoId.generateId() + apiSuffix;
logger.info(String.format("Updating %s", resourceDesc));
try {
PagedRequest<PullRequest> request = createUpdatedRequest(repoId);
result = new ArrayList<>(getPagedItems(resourceDesc, new PageIterator<>(request, client)));
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
return result;
}
updatedItems = result;
return result;
}
示例5: getPagedItems
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Overrides parent's method to stop getting items if some items in a page has
* updatedAt time before the lastIssueCheckTime
*
* @param resourceDesc
* @param iterator the paged request to iterate through
* @return
* @throws IOException
*/
@Override
protected List<PullRequest> getPagedItems(String resourceDesc, PageIterator<PullRequest> iterator)
throws IOException {
List<PullRequest> elements = new ArrayList<>();
int page = 0;
try {
while (iterator.hasNext()) {
Collection<PullRequest> newPullRequests = iterator.next();
int numAddedItems = addItemsUpdatedSince(elements, newPullRequests, lastIssueCheckTime);
logger.info(resourceDesc + " | page " + (page++) + ": " + numAddedItems + " items");
if (numAddedItems < newPullRequests.size()) {
break;
}
}
} catch (NoSuchPageException pageException) {
throw pageException.getCause();
}
return elements;
}
示例6: run
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
@Override
protected Gist run(Account account) throws Exception {
PageIterator<Gist> pages = service.pagePublicGists(1);
pages.next();
int randomPage = 1 + (int) (Math.random() * ((pages.getLastPage() - 1) + 1));
Collection<Gist> gists = service.pagePublicGists(randomPage, 1).next();
// Make at least two tries since page numbers are volatile
if (gists.isEmpty()) {
randomPage = 1 + (int) (Math.random() * ((pages.getLastPage() - 1) + 1));
gists = service.pagePublicGists(randomPage, 1).next();
}
if (gists.isEmpty())
throw new IllegalArgumentException(getContext().getString(
string.no_gists_found));
return store.addGist(gists.iterator().next());
}
示例7: pageOrgRepositories
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page repositories for the given organization
*
* @param organization
* @param filterData
* @param start
* @param size
* @return iterator over pages of repositories
*/
public PageIterator<Repository> pageOrgRepositories(String organization,
Map<String, String> filterData, int start, int size) {
if (organization == null)
throw new IllegalArgumentException("Organization cannot be null"); //$NON-NLS-1$
if (organization.length() == 0)
throw new IllegalArgumentException("Organization cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_ORGS);
uri.append('/').append(organization);
uri.append(SEGMENT_REPOS);
PagedRequest<Repository> request = createPagedRequest(start, size);
request.setParams(filterData);
request.setUri(uri);
request.setType(new TypeToken<List<Repository>>() {
}.getType());
return createPageIterator(request);
}
示例8: pageCommits
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page commits in given repository
*
* @param repository
* @param sha
* @param path
* @param size
* @return page iterator
*/
public PageIterator<RepositoryCommit> pageCommits(
IRepositoryIdProvider repository, String sha, String path, int size) {
String id = getId(repository);
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_COMMITS);
PagedRequest<RepositoryCommit> request = createPagedRequest(PAGE_FIRST,
size);
request.setUri(uri);
request.setType(new TypeToken<List<RepositoryCommit>>() {
}.getType());
if (sha != null || path != null) {
Map<String, String> params = new HashMap<String, String>();
if (sha != null)
params.put("sha", sha); //$NON-NLS-1$
if (path != null)
params.put("path", path); //$NON-NLS-1$
request.setParams(params);
}
return createPageIterator(request);
}
示例9: pageComments
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page comments on commit with given SHA-1
*
* @param repository
* @param sha
* @param start
* @param size
* @return page iterator over comments
*/
public PageIterator<CommitComment> pageComments(
IRepositoryIdProvider repository, String sha, int start, int size) {
String id = getId(repository);
if (sha == null)
throw new IllegalArgumentException("Sha cannot be null"); //$NON-NLS-1$
if (sha.length() == 0)
throw new IllegalArgumentException("Sha cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_COMMITS);
uri.append('/').append(sha);
uri.append(SEGMENT_COMMENTS);
PagedRequest<CommitComment> request = createPagedRequest(start, size);
request.setUri(uri);
request.setType(new TypeToken<List<CommitComment>>() {
}.getType());
return createPageIterator(request);
}
示例10: pageIssueEvents
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page issue events for repository
*
* @param user
* @param repository
* @param issueId
* @param start
* @param size
* @return iterator over issue event pages
*/
public PageIterator<IssueEvent> pageIssueEvents(String user,
String repository, int issueId, int start, int size) {
verifyRepository(user, repository);
PagedRequest<IssueEvent> request = createPagedRequest(start, size);
StringBuilder uri = new StringBuilder(SEGMENT_REPOS);
uri.append('/').append(user).append('/').append(repository);
uri.append(SEGMENT_ISSUES);
uri.append('/').append(issueId);
uri.append(SEGMENT_EVENTS);
request.setUri(uri);
request.setType(new TypeToken<List<IssueEvent>>() {
}.getType());
return createPageIterator(request);
}
示例11: pageRepositories
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page repositories for given user
*
* @param user
* @param start
* @param size
* @return iterator over repository page
*/
public PageIterator<Repository> pageRepositories(String user, int start,
int size) {
if (user == null)
throw new IllegalArgumentException("User cannot be null"); //$NON-NLS-1$
if (user.length() == 0)
throw new IllegalArgumentException("User cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder(SEGMENT_USERS);
uri.append('/').append(user);
uri.append(SEGMENT_REPOS);
PagedRequest<Repository> request = createPagedRequest(start, size);
request.setUri(uri);
request.setType(new TypeToken<List<Repository>>() {
}.getType());
return createPageIterator(request);
}
示例12: getLabels
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
public PageIterator<Label> getLabels(final IRepositoryIdProvider repository, final int issueNumber) {
String repoId = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(repoId);
uri.append("/issues");
uri.append('/').append(issueNumber);
uri.append("/labels");
PagedRequest<Label> request = this.createPagedRequest();
request.setUri(uri);
request.setType((new TypeToken<List<Label>>() {}).getType());
return this.createPageIterator(request);
}
示例13: pageComments2
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
public PageIterator<ExtendedCommitComment> pageComments2(final IRepositoryIdProvider repository,
final int id) {
String repoId = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(repoId);
uri.append("/pulls");
uri.append('/').append(id);
uri.append("/comments");
PagedRequest<ExtendedCommitComment> request = this.createPagedRequest(1, 100);
request.setUri(uri);
request.setType((new TypeToken<List<ExtendedCommitComment>>(){}).getType());
return this.createPageIterator(request);
}
示例14: pageRequestedReviewers
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
public PageIterator<User> pageRequestedReviewers(final IRepositoryIdProvider repository, final int id) {
String repoId = this.getId(repository);
StringBuilder uri = new StringBuilder("/repos");
uri.append('/').append(repoId);
uri.append("/pulls");
uri.append('/').append(id);
uri.append("/requested_reviewers");
PagedRequest<User> request = this.createPagedRequest(1, 100);
request.setResponseContentType(BLACK_CAT_PREVIEW);
request.setUri(uri);
request.setType((new TypeToken<List<User>>(){}).getType());
return this.createPageIterator(request);
}
示例15: pageRepositories
import org.eclipse.egit.github.core.client.PageIterator; //导入依赖的package包/类
/**
* Page repositories for currently authenticated user
*
* @param filterData
* @param start
* @param size
* @return iterator over pages of repositories
*/
public PageIterator<Repository> pageRepositories(
Map<String, String> filterData, int start, int size) {
PagedRequest<Repository> request = createPagedRequest(start, size);
request.setUri(SEGMENT_USER + SEGMENT_REPOS);
request.setParams(filterData);
request.setType(new TypeToken<List<WithPermissionsRepository>>() {
}.getType());
return createPageIterator(request);
}