Skip to content

Commit 7e2e584

Browse files
committed
Requested changes
1 parent b499994 commit 7e2e584

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/GroundingController.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Object createDocument(
172172

173173
/** Delete all items from a given grounding document collection. */
174174
@GetMapping("/vector/collection/by-id/{id}/clear")
175-
Object deleteDocuments(
175+
Object deleteCollection(
176176
@Nonnull @PathVariable("id") final UUID collectionId,
177177
@Nullable @RequestParam(value = "format", required = false) final String format) {
178178
final var dayOfWeek = now().getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.ENGLISH);
@@ -192,7 +192,6 @@ Object deleteDocuments(
192192
if (del.getStatusCode() >= 400) {
193193
final var msg = "Document {} could not be deleted, status code [{}], headers: {}";
194194
log.error(msg, documentId, del.getStatusCode(), del.getHeaders());
195-
throw new IllegalStateException("Document deletion failed for id " + documentId);
196195
}
197196
}
198197
final var response = CLIENT_VECTOR.deleteCollectionById(RESOURCE_GROUP, collectionId + "");
@@ -225,15 +224,11 @@ Object deleteCollections(
225224
final var collectionsList = ((CollectionsListResponse) collections).getResources();
226225
var statusCode = 0;
227226
final var deletions = new java.util.ArrayList<>(List.of());
228-
229227
for (final var collection : collectionsList) {
230228
if (COLLECTION_TITLE.equals(collection.getTitle())) {
231-
final var deletion = this.deleteDocuments(collection.getId(), "json");
232-
if (deletion instanceof OpenApiResponse) {
233-
final var status = ((OpenApiResponse) deletion).getStatusCode();
234-
deletions.add(deletion);
235-
statusCode = Math.max(status, statusCode);
236-
}
229+
final var deletion = (OpenApiResponse) this.deleteCollection(collection.getId(), "json");
230+
deletions.add(deletion);
231+
statusCode = Math.max(deletion.getStatusCode(), statusCode);
237232
}
238233
}
239234
if ("json".equals(format)) {

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/GroundingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void testCreateDeleteCollection() {
9090
this.assertDocumentSearchResult((RetievalSearchResults) search, dayOfWeek);
9191

9292
// (5) CLEAN UP
93-
Object deletion = controller.deleteDocuments(collectionUuid, JSON_FORMAT);
93+
Object deletion = controller.deleteCollection(collectionUuid, JSON_FORMAT);
9494
assertThat(deletion).isInstanceOf(OpenApiResponse.class);
9595
assertThat(((OpenApiResponse) deletion).getStatusCode()).isEqualTo(202);
9696

0 commit comments

Comments
 (0)