Skip to content

Commit

Permalink
fix path in controllers, update postman collection
Browse files Browse the repository at this point in the history
  • Loading branch information
max402 committed May 6, 2024
1 parent 9c2180d commit b287a84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ public List<String> 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<String> inboxList = dataSafeService.inboxService().list(ListRequest.forDefaultPrivate(userIDAuth, path))
.map(e -> e.getResource().asPrivate().decryptedPath().asString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,7 +54,7 @@ public List<String> 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<String> documentList = versionedDatasafeServices.latestPrivate().listWithDetails(
ListRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path))
Expand All @@ -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<UserIDAuth, PrivateResource> request =
ReadRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path);
Expand All @@ -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<UserIDAuth, PrivateResource> request =
WriteRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path);
Expand All @@ -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<UserIDAuth, PrivateResource> request =
RemoveRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path);
Expand All @@ -136,9 +138,7 @@ public List<String> 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<UserIDAuth, PrivateResource> request =
ListRequest.forPrivate(userIDAuth, new StorageIdentifier(storageId), path);
Expand Down

0 comments on commit b287a84

Please sign in to comment.