From b287a84832d56dae0c46bec442f016da86733852 Mon Sep 17 00:00:00 2001 From: Maxim Grischenko Date: Mon, 19 Feb 2024 13:36:43 +0100 Subject: [PATCH] fix path in controllers, update postman collection --- .../datasafe/rest/impl/controller/InboxController.java | 3 --- .../rest/impl/controller/VersionController.java | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/InboxController.java b/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/InboxController.java index e17f0121a..5f86a1f1b 100644 --- a/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/InboxController.java +++ b/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/InboxController.java @@ -113,9 +113,6 @@ public List listInbox(@RequestHeader String user, @PathVariable(required = false) String path) { path = path.replaceAll("^/", ""); UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); - path = Optional.ofNullable(path) - .map(it -> it.replaceAll("^\\.$", "")) - .orElse("./"); try { List inboxList = dataSafeService.inboxService().list(ListRequest.forDefaultPrivate(userIDAuth, path)) .map(e -> e.getResource().asPrivate().decryptedPath().asString()) diff --git a/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/VersionController.java b/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/VersionController.java index a373e31d2..ac91da98e 100644 --- a/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/VersionController.java +++ b/datasafe-rest-impl/src/main/java/de/adorsys/datasafe/rest/impl/controller/VersionController.java @@ -32,7 +32,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.List; -import java.util.Optional; import static org.springframework.http.HttpHeaders.CONTENT_TYPE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -55,7 +54,7 @@ public List listVersionedDocuments(@RequestHeader String user, @RequestHeader(defaultValue = StorageIdentifier.DEFAULT_ID) String storageId, @PathVariable(required = false) String path) { UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); - path = Optional.ofNullable(path).orElse("./"); + path = path.replaceAll("^/", ""); try { List documentList = versionedDatasafeServices.latestPrivate().listWithDetails( ListRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path)) @@ -79,6 +78,7 @@ public void readVersionedDocument(@RequestHeader String user, @RequestHeader(defaultValue = StorageIdentifier.DEFAULT_ID) String storageId, @PathVariable String path, HttpServletResponse response) { + path = path.replaceAll("^/", ""); UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); ReadRequest request = ReadRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path); @@ -102,6 +102,7 @@ public void writeVersionedDocument(@RequestHeader String user, @RequestHeader(defaultValue = StorageIdentifier.DEFAULT_ID) String storageId, @PathVariable String path, @RequestParam("file") MultipartFile file) { + path = path.replaceAll("^/", ""); UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); WriteRequest request = WriteRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path); @@ -120,6 +121,7 @@ public void deleteVersionedDocument(@RequestHeader String user, @RequestHeader String password, @RequestHeader(defaultValue = StorageIdentifier.DEFAULT_ID) String storageId, @PathVariable String path) { + path = path.replaceAll("^/", ""); UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); RemoveRequest request = RemoveRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path); @@ -136,9 +138,7 @@ public List versionsOf(@RequestHeader String user, @RequestHeader(defaultValue = StorageIdentifier.DEFAULT_ID) String storageId, @PathVariable(required = false) String path) { UserIDAuth userIDAuth = new UserIDAuth(new UserID(user), ReadKeyPasswordHelper.getForString(password)); - path = Optional.ofNullable(path) - .map(it -> it.replaceAll("^\\.$", "")) - .orElse("./"); + path = path.replaceAll("^/", ""); ListRequest request = ListRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path);