Skip to content

Commit

Permalink
Creato throwErrorMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
asioleLab committed Nov 9, 2023
1 parent 6587978 commit d4ca1f8
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public Uni<ResourceFile> uploadFile(ResourceEntity resourceEntity, File file, St
return this.resourceFileService.findByStorageKey(storageKey)
.onItem()
.transformToUni(resource -> {
if(resource.isPresent()){
String errorMessage = String.format("Cannot upload %s: resource with same file name and path already exists", storageKey);
throw new AtmLayerException(errorMessage, Response.Status.BAD_REQUEST, AppErrorCodeEnum.RESOURCE_WITH_SAME_NAME_AND_PATH_ALREADY_SAVED);
}

if(resource.isPresent()){
throwErrorMessage(String.format("Cannot upload %s: resource with same file name and path already exists", storageKey), Response.Status.BAD_REQUEST, AppErrorCodeEnum.RESOURCE_WITH_SAME_NAME_AND_PATH_ALREADY_SAVED );
}
log.info("Requesting to write file {} in Object Store at path {}", file.getName(), finalPath);
Context context = Vertx.currentContext();
return objectStoreService.uploadFile(file, finalPath, resourceType, completeName)
Expand All @@ -77,6 +77,10 @@ public Uni<ResourceFile> uploadFile(ResourceEntity resourceEntity, File file, St
});
}

private void throwErrorMessage(String errorMessage, Response.Status status, AppErrorCodeEnum appError){
throw new AtmLayerException(errorMessage, status, appError);
}

@Override
public Uni<URL> generatePresignedUrl(String storageKey) {
return this.objectStoreService.generatePresignedUrl(storageKey);
Expand Down

0 comments on commit d4ca1f8

Please sign in to comment.