Skip to content

Commit b5df4ae

Browse files
authored
(breaking change): Remove API call to query for a user's most recent notification. Code locations by Detect will be created without querying notifications API. (#475)
* WIP: alternative for notification APIs * Update intelligent persistent BDIO upload methods with alternative that doesn't use notification APIs * Binary scan alternative * Add back -SNAPSHOT suffix the version in build.gradle * Remove getLatestuserNotification() method and replace any uses with the current date instead. * Bump major version
1 parent b41a477 commit b5df4ae

9 files changed

Lines changed: 23 additions & 18 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ project.ext.moduleName = 'com.blackduck.integration.blackduck-common'
1414
project.ext.javaUseAutoModuleName = 'true'
1515
project.ext.junitShowStandardStreams = 'true'
1616

17-
version = '67.0.21-SNAPSHOT'
17+
version = '68.0.0-SNAPSHOT'
1818

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

src/main/java/com/blackduck/integration/blackduck/codelocation/CodeLocationCreationService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public <T extends CodeLocationBatchOutput<?>> CodeLocationCreationData<T> create
4747
return new CodeLocationCreationData<>(notificationTaskRange, output);
4848
}
4949

50+
public <T extends CodeLocationBatchOutput<?>> CodeLocationCreationData<T> createCodeLocationsWithoutNotificationTaskRange(CodeLocationCreationRequest<T> codeLocationCreationRequest) throws IntegrationException {
51+
T output = codeLocationCreationRequest.executeRequest();
52+
53+
return new CodeLocationCreationData<>(null, output);
54+
}
55+
5056
public <T extends CodeLocationBatchOutput<?>> T createCodeLocationsAndWait(CodeLocationCreationRequest<T> codeLocationCreationRequest, long timeoutInSeconds) throws IntegrationException, InterruptedException {
5157
return createCodeLocationsAndWait(codeLocationCreationRequest, timeoutInSeconds, DEFAULT_WAIT_INTERVAL_IN_SECONDS);
5258
}
@@ -85,7 +91,7 @@ public NotificationTaskRange calculateCodeLocationRange() throws IntegrationExce
8591

8692
UrlSingleResponse<UserView> userResponse = apiDiscovery.metaSingleResponse(ApiDiscovery.CURRENT_USER_PATH);
8793
UserView currentUser = blackDuckApiClient.getResponse(userResponse);
88-
Date startDate = notificationService.getLatestUserNotificationDate(currentUser);
94+
Date startDate = new Date(System.currentTimeMillis());
8995
Date endDate = Date.from(threeDaysLater.atZone(ZoneOffset.UTC).toInstant());
9096

9197
return new NotificationTaskRange(startTime, startDate, endDate);

src/main/java/com/blackduck/integration/blackduck/codelocation/binaryscanner/BinaryScanUploadService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScan(BinarySc
4242
return uploadBinaryScan(uploadRequest);
4343
}
4444

45+
public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScanWithoutNotificationsQuery(BinaryScanBatch uploadBatch) throws IntegrationException {
46+
BinaryScanCodeLocationCreationRequest uploadRequest = createUploadRequest(uploadBatch);
47+
return codeLocationCreationService.createCodeLocationsWithoutNotificationTaskRange(uploadRequest);
48+
}
49+
4550
public CodeLocationCreationData<BinaryScanBatchOutput> uploadBinaryScan(BinaryScan binaryScan) throws IntegrationException {
4651
BinaryScanBatch uploadBatch = new BinaryScanBatch();
4752
uploadBatch.addBinaryScan(binaryScan);

src/main/java/com/blackduck/integration/blackduck/codelocation/intelligentpersistence/IntelligentPersistenceService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public CodeLocationCreationData<UploadBatchOutput> uploadBdio(UploadBatch upload
4646
return uploadBdio(uploadRequest);
4747
}
4848

49+
public CodeLocationCreationData<UploadBatchOutput> uploadBdioWithoutNotificationsQuery(UploadBatch uploadBatch, long timeoutInSeconds, long clientStartTime) throws IntegrationException {
50+
IntelligentPersistenceCodeLocationCreationRequest uploadRequest = this.createUploadRequest(uploadBatch, timeoutInSeconds, clientStartTime);
51+
return codeLocationCreationService.createCodeLocationsWithoutNotificationTaskRange(uploadRequest);
52+
}
53+
4954
public UploadBatchOutput uploadBdioAndWait(CodeLocationCreationRequest<UploadBatchOutput> uploadRequest, long timeoutInSeconds) throws IntegrationException, InterruptedException {
5055
return codeLocationCreationService.createCodeLocationsAndWait(uploadRequest, timeoutInSeconds);
5156
}

src/main/java/com/blackduck/integration/blackduck/service/dataservice/NotificationService.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ public Date getLatestNotificationDate() throws IntegrationException {
8080
return getFirstCreatedAtDate(notifications);
8181
}
8282

83-
/**
84-
* @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.
85-
* @throws IntegrationException
86-
*/
87-
public Date getLatestUserNotificationDate(UserView userView) throws IntegrationException {
88-
BlackDuckRequestBuilder blackDuckRequestBuilder = createLatestDateRequestBuilder();
89-
BlackDuckMultipleRequest<NotificationUserView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(userNotificationsResponses.apply(userView));
90-
List<NotificationUserView> userNotifications = blackDuckApiClient.getSomeResponses(requestMultiple, 1);
91-
return getFirstCreatedAtDate(userNotifications);
92-
}
93-
9483
private Date getFirstCreatedAtDate(List<? extends NotificationView> notifications) {
9584
if (notifications.size() == 1) {
9685
return notifications.get(0).getCreatedAt();

src/test/java/com/blackduck/integration/blackduck/codelocation/binaryscanner/BinaryScanUploadServiceTestIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private File getTestBinaryFile() {
104104

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

110110
return new BinaryScanData(currentUser, userStartDate, systemStartDate, binaryScan);

src/test/java/com/blackduck/integration/blackduck/comprehensive/ComprehensiveCookbookTestIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void testPolicyStatusFromBdioImport() throws Exception {
163163
setupPolicyCheck(blackDuckServices, checkPolicyData);
164164

165165
UserView currentUser = blackDuckServices.userService.findCurrentUser();
166-
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
166+
Date userStartDate = new Date(System.currentTimeMillis());
167167
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();
168168

169169
// import the bdio
@@ -197,7 +197,7 @@ public void testPolicyStatusFromSignatureScan() throws Exception {
197197
setupPolicyCheck(blackDuckServices, checkPolicyData);
198198

199199
UserView currentUser = blackDuckServices.userService.findCurrentUser();
200-
Date userStartDate = blackDuckServices.notificationService.getLatestUserNotificationDate(currentUser);
200+
Date userStartDate = new Date(System.currentTimeMillis());
201201
Date systemStartDate = blackDuckServices.notificationService.getLatestNotificationDate();
202202

203203
File scanFile = intHttpClientTestHelper.getFile("hub-artifactory-1.0.1-RC.zip");

src/test/java/com/blackduck/integration/blackduck/comprehensive/CreateProjectWithBdioAndVerifyBOMTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void testCreatingProject() throws IntegrationException, InterruptedExcept
113113
}
114114

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

src/test/java/com/blackduck/integration/blackduck/comprehensive/NotificationsTestIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testProjectNotifications() throws IntegrationException, InterruptedE
5050
ProjectSyncModel projectSyncModel = ProjectSyncModel.createWithDefaults(projectName, projectVersionName);
5151

5252
UserView currentUser = userService.findCurrentUser();
53-
Date startDate = notificationService.getLatestUserNotificationDate(currentUser);
53+
Date startDate = new Date(System.currentTimeMillis());
5454
Date endDate = Date.from(startDate.toInstant().plus(1, ChronoUnit.DAYS));
5555
List<String> notificationTypes = new ArrayList<>();
5656
notificationTypes.add(NotificationType.PROJECT.name());

0 commit comments

Comments
 (0)