Class COSClient
- java.lang.Object
-
- org.linuxforhealth.fhir.bucket.cos.COSClient
-
public class COSClient extends java.lang.Object
Encapsulates the AmazonS3 client for interaction with IBM Cloud Object Storage (COS)
-
-
Constructor Summary
Constructors Constructor Description COSClient(java.util.Properties cosProperties)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
process(java.lang.String bucketName, java.lang.String itemName, java.util.function.Consumer<java.io.BufferedReader> consumer)
Read and process the object, feeding the content to the given consumer as a BufferedReader.<T> T
read(java.lang.String bucketName, java.lang.String itemName, java.util.function.Function<java.io.PushbackInputStream,T> fn)
Read the object using the given functionvoid
scan(java.lang.String bucketName, java.lang.String pathPrefix, java.util.function.Function<java.lang.String,FileType> fileTyper, java.util.function.Consumer<CosItem> consumer)
Scan the COS bucket, feeding each returned item to the given consumervoid
signalStop()
Tell the scanner to stop.void
write(java.lang.String bucketName, java.lang.String objectName, java.lang.String payload)
Write the payload to the given bundleName as key
-
-
-
Method Detail
-
signalStop
public void signalStop()
Tell the scanner to stop. Can be used to get scan() to finish early
-
read
public <T> T read(java.lang.String bucketName, java.lang.String itemName, java.util.function.Function<java.io.PushbackInputStream,T> fn)
Read the object using the given function- Type Parameters:
T
-- Parameters:
bucketName
-itemName
-fn
-- Returns:
-
process
public void process(java.lang.String bucketName, java.lang.String itemName, java.util.function.Consumer<java.io.BufferedReader> consumer)
Read and process the object, feeding the content to the given consumer as a BufferedReader. We keep control of the stream, and close it when the consumer accept call returns- Parameters:
bucketName
-itemName
-consumer
-
-
scan
public void scan(java.lang.String bucketName, java.lang.String pathPrefix, java.util.function.Function<java.lang.String,FileType> fileTyper, java.util.function.Consumer<CosItem> consumer)
Scan the COS bucket, feeding each returned item to the given consumer- Parameters:
bucketName
-fileType
- function to derive fileType from the item key valueconsumer
- target for each non-empty CosItem we find in the bucket
-
write
public void write(java.lang.String bucketName, java.lang.String objectName, java.lang.String payload)
Write the payload to the given bundleName as key- Parameters:
bundleName
-payload
-
-
-