use of org.eclipse.dash.licenses.extended.ExtendedContentData in project dash-licenses by eclipse.
the class GitLabSupport method createReviews.
public void createReviews(List<LicenseData> needsReview, BiConsumer<IContentId, String> monitor) {
execute(connection -> {
var count = 0;
for (LicenseData licenseData : needsReview) {
if (count >= MAXIMUM_REVIEWS)
break;
count++;
if (!licenseData.getId().isValid()) {
logger.info("I don't know what to do with {}.", licenseData.getId().toString());
continue;
}
logger.info("A review is required for {}.", licenseData.getId().toString());
Stream<ExtendedContentData> extendedData = dataService.findFor(licenseData.getId());
/*
* Ideally, we need a way to "create if does not already exist" feature in the
* GitLab API. But since we don't have that, we'll leverage the expectation that
* concurrent requests to review the same content will be relatively rare (there
* is some risk that between asking if we have an existing issue for a review
* for a particular bit of content and creating a new one, that somebody else
* might be doing the same). Our expectation is that the potential additional
* churn on the backend should require significantly less effort than that
* required to prevent rare duplication.
*/
try {
GitLabReview review = new GitLabReview(settings.getProjectId(), licenseData, extendedData);
Issue existing = connection.findIssue(review);
if (existing != null) {
monitor.accept(licenseData.getId(), existing.getWebUrl());
logger.info("A review request already exists {}.", existing.getWebUrl());
continue;
}
Issue created = connection.createIssue(review);
if (created == null) {
logger.error("An error occurred while attempting to create a review request. Aborting.");
// TODO If we break creating a review, then don't try to create any more.
break;
}
monitor.accept(licenseData.getId(), created.getWebUrl());
logger.info("A review request was created {}.", created.getWebUrl());
} catch (GitLabApiException e) {
throw new RuntimeException(e);
}
}
if (count < needsReview.size()) {
logger.info("More content needs to be reviewed.");
logger.info("For now, however, this experimental feature only submits the first {}.\n", count);
}
});
}
use of org.eclipse.dash.licenses.extended.ExtendedContentData in project dash-licenses by eclipse.
the class GitLabSupport method createReviews.
public void createReviews(List<LicenseData> needsReview, PrintWriter output) {
execute(connection -> {
var count = 0;
for (LicenseData licenseData : needsReview) {
if (count >= MAXIMUM_REVIEWS)
break;
count++;
output.println(String.format("Setting up a review for %s.", licenseData.getId().toString()));
if (!licenseData.getId().isValid()) {
output.println(" - Don't know what to do with this.");
continue;
}
Stream<ExtendedContentData> extendedData = dataService.findFor(licenseData.getId());
/*
* Ideally, we need a way to "create if does not already exist" feature in the
* GitLab API. But since we don't have that, we'll leverage the expectation that
* concurrent requests to review the same content will be relatively rare (there
* is some risk that between asking if we have an existing issue for a review
* for a particular bit of content and creating a new one, that somebody else
* might be doing the same). Our expectation is that the potential additional
* churn on the backend should require significantly less effort than that
* required to prevent rare duplication.
*/
try {
GitLabReview review = new GitLabReview(settings.getProjectId(), licenseData, extendedData);
Issue existing = connection.findIssue(review);
if (existing != null) {
output.println(String.format(" - Existing: %s", existing.getWebUrl()));
continue;
}
Issue created = connection.createIssue(review);
if (created == null) {
output.println(" - An error occurred while attempting to create a review request");
// TODO If we break creating a review, then don't try to create any more.
break;
}
output.println(String.format(" - Created: %s", created.getWebUrl()));
output.flush();
} catch (GitLabApiException e) {
throw new RuntimeException(e);
}
}
if (count < needsReview.size()) {
output.println();
output.println("More content needs to be reviewed.");
output.printf("For now, however, this experimental feature only submits the first %d.\n", count);
output.println();
}
});
}
Aggregations