use of io.jenkins.blueocean.blueocean_bitbucket_pipeline.server.model.BbServerUser in project blueocean-plugin by jenkinsci.
the class BitbucketServerApi method getOrgs.
@Override
@Nonnull
public BbPage<BbOrg> getOrgs(int pageNumber, int pageSize) {
try {
if (pageNumber <= 0) {
pageNumber = 1;
}
if (pageSize <= 0) {
pageSize = PagedResponse.DEFAULT_LIMIT;
}
InputStream inputStream = request.get(String.format("%s?start=%s&limit=%s", baseUrl + "projects/", toStart(pageNumber, pageSize), pageSize)).getContent();
BbPage<BbOrg> page = om.readValue(inputStream, new TypeReference<BbServerPage<BbServerProject>>() {
});
if (pageNumber == 1) {
// add user org as the first org on first page
BbServerUser user = getUser(userName);
List<BbOrg> teams = new ArrayList<>();
teams.add(user.toPersonalProject());
teams.addAll(page.getValues());
return new BbServerPage<>(page.getStart(), page.getLimit(), page.getSize() + 1, teams, page.isLastPage());
}
return page;
} catch (IOException e) {
throw handleException(e);
}
}
Aggregations