overture-stack / score

Secure Cloud Object REsource: file transfer microservice
https://www.overture.bio/products/score
GNU Affero General Public License v3.0
18 stars 10 forks source link

Improve String Handling for Empty and Whitespace Parameters in Key and Bucket Methods #410

Closed Azher2Ali closed 1 month ago

Azher2Ali commented 1 month ago

All three code changes introduced the use of the isBlank() method to handle empty strings in different contexts:

getKey and getMetaKey methods: These methods now check if the dir variable is empty. If it is empty, they return only the objectId. Otherwise, they maintain the original behavior of concatenating the directory path and object identifier. This provides more flexibility in handling scenarios where the data might not have a specific directory structure.

getObjectMetaKey method: Similar to the previous change, this method now checks if the dataDir parameter is empty. If it's empty, it creates a key using only the objectId with the ".meta" extension. This allows the method to function even when no directory path is provided.

readBucket method: This method now checks if the prefix parameter is empty. If it's empty, it retrieves all objects from the specified S3 bucket. Otherwise, it continues to filter objects based on the provided prefix. This change offers more control over how you list S3 objects, allowing you to retrieve all objects within a bucket if needed.

In summary, these changes enhance the code's ability to handle empty strings, making it more adaptable to various situations where directory paths or prefixes might be absent.