Package com.ibm.fhir.bucket.cos
Class COSClient
- java.lang.Object
 - 
- com.ibm.fhir.bucket.cos.COSClient
 
 
- 
public class COSClient extends Object
Encapsulates the AmazonS3 client for interaction with IBM Cloud Object Storage (COS) 
- 
- 
Constructor Summary
Constructors Constructor Description COSClient(Properties cosProperties)Public constructor 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidprocess(String bucketName, String itemName, Consumer<BufferedReader> consumer)Read and process the object, feeding the content to the given consumer as a BufferedReader.<T> Tread(String bucketName, String itemName, Function<PushbackInputStream,T> fn)Read the object using the given functionvoidscan(String bucketName, String pathPrefix, Function<String,FileType> fileTyper, Consumer<CosItem> consumer)Scan the COS bucket, feeding each returned item to the given consumervoidsignalStop()Tell the scanner to stop.voidwrite(String bucketName, String objectName, String payload)Write the payload to the given bundleName as key 
 - 
 
- 
- 
Constructor Detail
- 
COSClient
public COSClient(Properties cosProperties)
Public constructor- Parameters:
 cosProperties-
 
 - 
 
- 
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(String bucketName, String itemName, Function<PushbackInputStream,T> fn)
Read the object using the given function- Type Parameters:
 T-- Parameters:
 bucketName-itemName-fn-- Returns:
 
 
- 
process
public void process(String bucketName, String itemName, Consumer<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(String bucketName, String pathPrefix, Function<String,FileType> fileTyper, 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
 
 - 
 
 -