Package ca.uhn.fhir.jpa.binstore
Class MemoryBinaryStorageSvcImpl
java.lang.Object
ca.uhn.fhir.jpa.binary.svc.BaseBinaryStorageSvcImpl
ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl
- All Implemented Interfaces:
IBinaryStorageSvc
public class MemoryBinaryStorageSvcImpl
extends BaseBinaryStorageSvcImpl
implements IBinaryStorageSvc
Purely in-memory implementation of binary storage service. This is really
only appropriate for testing, since it doesn't persist anywhere and is
limited by the amount of available RAM.
-
Field Summary
Fields inherited from class ca.uhn.fhir.jpa.binary.svc.BaseBinaryStorageSvcImpl
BINARY_CONTENT_ID_PREFIX_APPLIED, DEFAULT_MAXIMUM_BINARY_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
void
expungeBinaryContent
(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) byte[]
fetchBinaryContent
(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) Fetch the contents of the given blobfetchBinaryContentDetails
(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) storeBinaryContent
(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobIdOrNull, String theContentType, InputStream theInputStream, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) Store a new binary blobboolean
writeBinaryContent
(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId, OutputStream theOutputStream) Methods inherited from class ca.uhn.fhir.jpa.binary.svc.BaseBinaryStorageSvcImpl
createCountingInputStream, createHashingInputStream, fetchDataByteArrayFromBinary, getMaximumBinarySize, getMinimumBinarySize, isBinaryContentIdPrefixApplied, isValidBinaryContentId, newBinaryContentId, provideIdForNewBinaryContent, provideIdForNewBinaryContent, setBinaryContentIdPrefixApplied, setFhirContextForTests, setInterceptorBroadcasterForTests, setMaximumBinarySize, setMinimumBinarySize, shouldStoreBinaryContent
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ca.uhn.fhir.jpa.binary.api.IBinaryStorageSvc
fetchDataByteArrayFromBinary, getMaximumBinarySize, getMinimumBinarySize, isValidBinaryContentId, newBinaryContentId, setMaximumBinarySize, setMinimumBinarySize, shouldStoreBinaryContent, storeBinaryContent
-
Constructor Details
-
MemoryBinaryStorageSvcImpl
public MemoryBinaryStorageSvcImpl()Constructor
-
-
Method Details
-
storeBinaryContent
@Nonnull public StoredDetails storeBinaryContent(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobIdOrNull, String theContentType, InputStream theInputStream, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) throws IOException Description copied from interface:IBinaryStorageSvc
Store a new binary blob- Specified by:
storeBinaryContent
in interfaceIBinaryStorageSvc
- Parameters:
theResourceId
- The resource ID that owns this blob. Note that it should not be possible to retrieve a blob without both the resource ID and the blob ID being correct.theBlobIdOrNull
- If set, forcestheContentType
- The content type to associate with this blobtheInputStream
- An InputStream to read from. This method should close the stream when it has been fully consumed.theRequestDetails
- The operation request details.- Returns:
- Returns details about the stored data
- Throws:
IOException
-
fetchBinaryContentDetails
public StoredDetails fetchBinaryContentDetails(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) - Specified by:
fetchBinaryContentDetails
in interfaceIBinaryStorageSvc
-
writeBinaryContent
public boolean writeBinaryContent(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId, OutputStream theOutputStream) throws IOException - Specified by:
writeBinaryContent
in interfaceIBinaryStorageSvc
- Returns:
- Returns
true
if the blob was found and written, offalse
if the blob was not found (i.e. it was expunged or the ID was invalid) - Throws:
IOException
-
expungeBinaryContent
public void expungeBinaryContent(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) - Specified by:
expungeBinaryContent
in interfaceIBinaryStorageSvc
-
fetchBinaryContent
public byte[] fetchBinaryContent(org.hl7.fhir.instance.model.api.IIdType theResourceId, String theBlobId) Description copied from interface:IBinaryStorageSvc
Fetch the contents of the given blob- Specified by:
fetchBinaryContent
in interfaceIBinaryStorageSvc
- Parameters:
theResourceId
- The resource IDtheBlobId
- The blob ID- Returns:
- The payload as a byte array
-
clear
-