Skip to content

Commit

Permalink
Add javadoc to file service
Browse files Browse the repository at this point in the history
  • Loading branch information
tsande16 committed Jan 7, 2025
1 parent 38d62d5 commit eb0c810
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public class FileStorageService {

/**
* FileStorageService Class constructor.
*
* @param ocflRepository ocfl object that is a layer to handle the io of the files
* @param storageProperties properties indicating where and what type of storage is used for persistence.
* @param rootLoc path of the root location used to set up temp working directory for the File Service
*/
public FileStorageService(OcflRepository ocflRepository,
StorageProperties storageProperties,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public class StorageConfiguration {
@Value("${aws.region}")
private String awsRegion;

/**
* Creates and configures an S3TransferManager for managing file transfers to Amazon S3.
*
* @return a configured S3TransferManager instance.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public S3TransferManager s3TransferManager() {
Expand All @@ -72,6 +77,13 @@ public S3TransferManager s3TransferManager() {
.build();
}

/**
* Creates and configures an S3AsyncClient for interacting with Amazon S3 or an S3-compatible storage service.
*
* @param storageProperties the StorageProperties containing the configuration.
* @return a configured S3AsyncClient instance.
* @throws IOException if the S3 bucket name is not set in StorageProperties.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public S3AsyncClient s3Client(StorageProperties storageProperties) throws IOException {
Expand All @@ -93,6 +105,17 @@ public S3AsyncClient s3Client(StorageProperties storageProperties) throws IOExce
return s3Client;
}

/**
* Creates and configures an OcflRepository instance for use with Amazon S3 as the storage backend.
*
* @param s3Client the S3AsyncClient for interacting with Amazon S3.
* @param s3TransferManager the S3TransferManager to manage file transfers to S3.
* @param storageProperties the StorageProperties containing the configuration.
* @param rootLoc the root Path for the file service.
* @return a OcflRepository instance, using S3 as the storage layer.
* @throws IOException if the S3 bucket name is not set in the StorageProperties, or if there are
* issues creating or accessing the working directory.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "S3")
public OcflRepository ocflS3Repository(S3AsyncClient s3Client, S3TransferManager s3TransferManager,
Expand Down Expand Up @@ -121,6 +144,17 @@ public OcflRepository ocflS3Repository(S3AsyncClient s3Client, S3TransferManager
return ocflRepository;
}

/**
* Creates and configures an {@link OcflRepository} instance when the file service storage type
* is set to "FILE_SYSTEM". This method ensures that the OCFL directory exists, is accessible,
* and is properly set up with the required permissions.
*
* @param storageProperties the StorageProperties object containing storage configurations.
* @param rootLoc the root Path where the OCFL directory will be created or accessed.
* @return a fully configured OcflRepository instance backed by a file system storage type.
* @throws IOException if the OCFL directory cannot be created, or if there are insufficient
* read/write permissions.
*/
@Bean
@ConditionalOnProperty(name = "pass.file-service.storage-type", havingValue = "FILE_SYSTEM")
public OcflRepository ocflFileRepository(StorageProperties storageProperties,
Expand All @@ -142,6 +176,13 @@ public OcflRepository ocflFileRepository(StorageProperties storageProperties,
return ocflRepository;
}

/**
* Configures and provides the root Path for the file service storage.
*
* @param storageProperties the StorageProperties object containing storage configuration details.
* @return the root Path for the storage system.
* @throws IOException if an error occurs while creating the temporary directory.
*/
@Bean
@Qualifier("rootPath")
public Path rootPath(StorageProperties storageProperties) throws IOException {
Expand Down

0 comments on commit eb0c810

Please sign in to comment.