Skip to content

Commit

Permalink
♻️ s3 rest client refactor interface naming
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir committed Aug 12, 2024
1 parent bd38b61 commit 7896b38
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
import java.io.InputStream;
import reactor.core.publisher.Mono;

public interface IDocumentStorageFileRepository {
public interface DocumentStorageFileRepository {
/**
* Gets the file specified in the parameter from the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the file.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
byte[] getFile(String pathToFile, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;
Expand All @@ -28,99 +26,85 @@ byte[] getFile(String pathToFile, int expireInMinutes)
* @param pathToFile defines the path to the file.
* @return the file size.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
Mono<Long> getFileSize(String pathToFile)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;

/**
* Gets an InputStream for the file specified in the parameter from the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the InputStream for the file.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
InputStream getFileInputStream(String pathToFile, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;

/**
* Saves the file specified in the parameter to the document storage.
*
* @param pathToFile defines the path to the file.
* @param file to save.
* @param pathToFile defines the path to the file.
* @param file to save.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
void saveFile(String pathToFile, byte[] file, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;

/**
* Saves the file specified in the parameter to the document storage.
*
* @param pathToFile defines the path to the file.
* @param file to save.
* @param pathToFile defines the path to the file.
* @param file to save.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
void saveFileInputStream(String pathToFile, InputStream file, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;

/**
* Updates the file specified in the parameter to the document storage.
*
* @param pathToFile defines the path to the file.
* @param file which overwrites the file in the document storage.
* @param pathToFile defines the path to the file.
* @param file which overwrites the file in the document storage.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
void updateFile(String pathToFile, byte[] file, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;

/**
* Updates the file specified in the parameter withinq the document storage.
*
* @param pathToFile defines the path to the file.
* @param file which overwrites the file in the document storage.
* @param pathToFile defines the path to the file.
* @param file which overwrites the file in the document storage.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
void updateFileInputStream(String pathToFile, InputStream file, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;

/**
* Deletes the file specified in the parameter from the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3
* storage or the document storage.
* @throws DocumentStorageServerErrorException if the problem is with the S3 storage or document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the S3 storage or the document storage.
*/
void deleteFile(String pathToFile, int expireInMinutes)
throws DocumentStorageException, DocumentStorageClientErrorException, DocumentStorageServerErrorException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import java.util.Set;
import reactor.core.publisher.Mono;

public interface IDocumentStorageFolderRepository {
public interface DocumentStorageFolderRepository {
/**
* Deletes the folder with all containing files on document storage.
*
* @param pathToFolder which defines the folder in the document storage.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document storage.
*/
void deleteFolder(String pathToFolder)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;
Expand All @@ -26,8 +25,7 @@ void deleteFolder(String pathToFolder)
* @param pathToFolder which defines the folder in the document storage.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document storage.
*/
Mono<Set<String>> getAllFilesInFolderRecursively(String pathToFolder)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;
Expand All @@ -39,8 +37,7 @@ Mono<Set<String>> getAllFilesInFolderRecursively(String pathToFolder)
* @return file paths with their file sizes.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document
* storage.
* @throws DocumentStorageException if the problem cannot be assigned directly to the document storage.
*/
Mono<Map<String, Long>> getAllFileSizesInFolderRecursively(String pathToFolder)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,56 @@
import de.muenchen.refarch.integration.s3.client.exception.DocumentStorageServerErrorException;
import reactor.core.publisher.Mono;

public interface IPresignedUrlRepository {
public interface PresignedUrlRepository {

/**
* Fetches a presignedURL for the file named in the parameter to get a file from the document
* storage.
* Fetches a presignedURL for the file named in the parameter to get a file from the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the presignedURL.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the
* document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the document storage.
*/
Mono<String> getPresignedUrlGetFile(String pathToFile, int expireInMinutes)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;

/**
* Fetches a presignedURL for the file named in the parameter to store a file in the document
* storage.
* Fetches a presignedURL for the file named in the parameter to store a file in the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the presignedURL.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the
* document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the document storage.
*/
String getPresignedUrlSaveFile(String pathToFile, int expireInMinutes)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;

/**
* Fetches a presignedURL for the file named in the parameter to update a file in the document
* storage.
* Fetches a presignedURL for the file named in the parameter to update a file in the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the presignedURL.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the
* document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the document storage.
*/
String getPresignedUrlUpdateFile(String pathToFile, int expireInMinutes)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;

/**
* Fetches a presignedURL for the file named in the parameter to delete a file from the document
* storage.
* Fetches a presignedURL for the file named in the parameter to delete a file from the document storage.
*
* @param pathToFile defines the path to the file.
* @param pathToFile defines the path to the file.
* @param expireInMinutes the expiration time of the presignedURL in minutes.
* @return the presignedURL.
* @throws DocumentStorageClientErrorException if the problem is with the client.
* @throws DocumentStorageServerErrorException if the problem is with the document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the
* document storage.
* @throws DocumentStorageException if the problem cannot be assigned to either the client or the document storage.
*/
String getPresignedUrlDeleteFile(String pathToFile, int expireInMinutes)
throws DocumentStorageClientErrorException, DocumentStorageServerErrorException, DocumentStorageException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Slf4j
@Repository
@RequiredArgsConstructor
public class DocumentStorageFileRepository implements IDocumentStorageFileRepository {
public class DocumentStorageFileRestRepository implements DocumentStorageFileRepository {

private final PresignedUrlRepository presignedUrlRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Slf4j
@Repository
@RequiredArgsConstructor
public class DocumentStorageFolderRepository implements IDocumentStorageFolderRepository {
public class DocumentStorageFolderRestRepository implements DocumentStorageFolderRepository {
private final FolderApiApi folderApi;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Slf4j
@Repository
@RequiredArgsConstructor
public class PresignedUrlRepository implements IPresignedUrlRepository {
public class PresignedUrlRestRepository implements PresignedUrlRepository {

private final FileApiApi fileApi;

Expand Down
Loading

0 comments on commit 7896b38

Please sign in to comment.