Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ project.ext.moduleName = 'com.blackduck.integration.blackduck-common'
project.ext.javaUseAutoModuleName = 'true'
project.ext.junitShowStandardStreams = 'true'

version = '67.0.21-SNAPSHOT'
version = '68.0.0-SNAPSHOT'

description = 'A library for using various capabilities of Black Duck, notably the REST API and signature scanning.'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public <T extends CodeLocationBatchOutput<?>> CodeLocationCreationData<T> create
return new CodeLocationCreationData<>(notificationTaskRange, output);
}

public <T extends CodeLocationBatchOutput<?>> CodeLocationCreationData<T> createCodeLocationsWithoutNotificationTaskRange(CodeLocationCreationRequest<T> codeLocationCreationRequest) throws IntegrationException {
T output = codeLocationCreationRequest.executeRequest();

return new CodeLocationCreationData<>(null, output);
}

public <T extends CodeLocationBatchOutput<?>> T createCodeLocationsAndWait(CodeLocationCreationRequest<T> codeLocationCreationRequest, long timeoutInSeconds) throws IntegrationException, InterruptedException {
return createCodeLocationsAndWait(codeLocationCreationRequest, timeoutInSeconds, DEFAULT_WAIT_INTERVAL_IN_SECONDS);
}
Expand Down Expand Up @@ -85,7 +91,7 @@ public NotificationTaskRange calculateCodeLocationRange() throws IntegrationExce

UrlSingleResponse<UserView> userResponse = apiDiscovery.metaSingleResponse(ApiDiscovery.CURRENT_USER_PATH);
UserView currentUser = blackDuckApiClient.getResponse(userResponse);
Date startDate = notificationService.getLatestUserNotificationDate(currentUser);
Date startDate = new Date(System.currentTimeMillis());
Date endDate = Date.from(threeDaysLater.atZone(ZoneOffset.UTC).toInstant());

return new NotificationTaskRange(startTime, startDate, endDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScan(BinarySc
return uploadBinaryScan(uploadRequest);
}

public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScanWithoutNotificationsQuery(BinaryScanBatch uploadBatch) throws IntegrationException {
BinaryScanCodeLocationCreationRequest uploadRequest = createUploadRequest(uploadBatch);
return codeLocationCreationService.createCodeLocationsWithoutNotificationTaskRange(uploadRequest);
}

public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScan(BinaryScan binaryScan) throws IntegrationException {
BinaryScanBatch uploadBatch = new BinaryScanBatch();
uploadBatch.addBinaryScan(binaryScan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public CodeLocationCreationData<UploadBatchOutput> uploadBdio(UploadBatch upload
return uploadBdio(uploadRequest);
}

public CodeLocationCreationData<UploadBatchOutput> uploadBdioWithoutNotificationsQuery(UploadBatch uploadBatch, long timeoutInSeconds, long clientStartTime) throws IntegrationException {
IntelligentPersistenceCodeLocationCreationRequest uploadRequest = this.createUploadRequest(uploadBatch, timeoutInSeconds, clientStartTime);
return codeLocationCreationService.createCodeLocationsWithoutNotificationTaskRange(uploadRequest);
}

public UploadBatchOutput uploadBdioAndWait(CodeLocationCreationRequest<UploadBatchOutput> uploadRequest, long timeoutInSeconds) throws IntegrationException, InterruptedException {
return codeLocationCreationService.createCodeLocationsAndWait(uploadRequest, timeoutInSeconds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ public Date getLatestNotificationDate() throws IntegrationException {
return getFirstCreatedAtDate(notifications);
}

/**
* @return The java.util.Date of the most recent notification in the user's stream. If there are no notifications, the current date will be returned. This can set an initial start time window for all future notifications.
* @throws IntegrationException
*/
public Date getLatestUserNotificationDate(UserView userView) throws IntegrationException {
BlackDuckRequestBuilder blackDuckRequestBuilder = createLatestDateRequestBuilder();
BlackDuckMultipleRequest<NotificationUserView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(userNotificationsResponses.apply(userView));
List<NotificationUserView> userNotifications = blackDuckApiClient.getSomeResponses(requestMultiple, 1);
return getFirstCreatedAtDate(userNotifications);
}

private Date getFirstCreatedAtDate(List<? extends NotificationView> notifications) {
if (notifications.size() == 1) {
return notifications.get(0).getCreatedAt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private File getTestBinaryFile() {

private BinaryScanData createBinaryScanData(BlackDuckServices blackDuckServices, BinaryScan binaryScan) throws IntegrationException {
UserView currentUser = blackDuckServices.userService.findCurrentUser();
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
Date userStartDate = new Date(System.currentTimeMillis());
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();

return new BinaryScanData(currentUser, userStartDate, systemStartDate, binaryScan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void testPolicyStatusFromBdioImport() throws Exception {
setupPolicyCheck(blackDuckServices, checkPolicyData);

UserView currentUser = blackDuckServices.userService.findCurrentUser();
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
Date userStartDate = new Date(System.currentTimeMillis());
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();

// import the bdio
Expand Down Expand Up @@ -197,7 +197,7 @@ public void testPolicyStatusFromSignatureScan() throws Exception {
setupPolicyCheck(blackDuckServices, checkPolicyData);

UserView currentUser = blackDuckServices.userService.findCurrentUser();
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
Date userStartDate = new Date(System.currentTimeMillis());
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();

File scanFile = intHttpClientTestHelper.getFile("hub-artifactory-1.0.1-RC.zip");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testCreatingProject() throws IntegrationException, InterruptedExcept
}

private void uploadAndVerifyBdio(UploadBatch uploadBatch, Set<String> expectedCodeLocationNames) throws IntegrationException, InterruptedException {
Date startDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
Date startDate = new Date(System.currentTimeMillis());
System.out.println("start date: ");
System.out.println(RestConstants.formatDate(startDate));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testProjectNotifications() throws IntegrationException, InterruptedE
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectName, projectVersionName);

UserView currentUser = userService.findCurrentUser();
Date startDate = notificationService.getLatestUserNotificationDate(currentUser);
Date startDate = new Date(System.currentTimeMillis());
Date endDate = Date.from(startDate.toInstant().plus(1, ChronoUnit.DAYS));
List<String> notificationTypes = new ArrayList<>();
notificationTypes.add(NotificationType.PROJECT.name());
Expand Down