Package ca.uhn.fhir.jpa.binary.svc
Class BaseBinaryStorageSvcImpl
java.lang.Object
ca.uhn.fhir.jpa.binary.svc.BaseBinaryStorageSvcImpl
- All Implemented Interfaces:
IBinaryStorageSvc
- Direct Known Subclasses:
FilesystemBinaryStorageSvcImpl
,MemoryBinaryStorageSvcImpl
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.commons.io.input.CountingInputStream
createCountingInputStream
(InputStream theInputStream) protected com.google.common.hash.HashingInputStream
createHashingInputStream
(InputStream theInputStream) byte[]
fetchDataByteArrayFromBinary
(org.hl7.fhir.instance.model.api.IBaseBinary theBaseBinary) Fetch the byte[] contents of a given Binary resource's `data` element.long
Gets the maximum number of bytes that can be stored in a single binary file by this service.int
Gets the minimum number of bytes that will be stored.protected boolean
isBinaryContentIdPrefixApplied
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) boolean
isValidBinaryContentId
(String theNewBinaryContentId) Default implementation is to return true for any binary content ID.Generate a new binaryContent ID that will be passed toIBinaryStorageSvc.storeBinaryContent(IIdType, String, String, InputStream)
laterprotected String
provideIdForNewBinaryContent
(String theBinaryContentIdOrNull) Deprecated, for removal: This API element is subject to removal in a future version.protected String
provideIdForNewBinaryContent
(String theBinaryContentIdOrNull, byte[] theBytes, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theContentType) static void
setBinaryContentIdPrefixApplied
(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) void
setFhirContextForTests
(ca.uhn.fhir.context.FhirContext theFhirContext) void
setInterceptorBroadcasterForTests
(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster) void
setMaximumBinarySize
(long theMaximumBinarySize) Sets the maximum number of bytes that can be stored in a single binary file by this service.void
setMinimumBinarySize
(int theMinimumBinarySize) Sets the minimum number of bytes that will be stored.boolean
shouldStoreBinaryContent
(long theSize, org.hl7.fhir.instance.model.api.IIdType theResourceId, String theContentType) Give the storage service the ability to veto items from storageMethods 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
expungeBinaryContent, fetchBinaryContent, fetchBinaryContentDetails, storeBinaryContent, storeBinaryContent, writeBinaryContent
-
Field Details
-
DEFAULT_MAXIMUM_BINARY_SIZE
-
BINARY_CONTENT_ID_PREFIX_APPLIED
-
-
Constructor Details
-
BaseBinaryStorageSvcImpl
public BaseBinaryStorageSvcImpl()
-
-
Method Details
-
getMaximumBinarySize
Description copied from interface:IBinaryStorageSvc
Gets the maximum number of bytes that can be stored in a single binary file by this service. The default isLong.MAX_VALUE
- Specified by:
getMaximumBinarySize
in interfaceIBinaryStorageSvc
-
setMaximumBinarySize
Description copied from interface:IBinaryStorageSvc
Sets the maximum number of bytes that can be stored in a single binary file by this service. The default isLong.MAX_VALUE
- Specified by:
setMaximumBinarySize
in interfaceIBinaryStorageSvc
- Parameters:
theMaximumBinarySize
- The maximum size
-
getMinimumBinarySize
Description copied from interface:IBinaryStorageSvc
Gets the minimum number of bytes that will be stored. Binary content smaller * than this threshold may be inlined even if a binary storage service * is active.- Specified by:
getMinimumBinarySize
in interfaceIBinaryStorageSvc
-
setMinimumBinarySize
Description copied from interface:IBinaryStorageSvc
Sets the minimum number of bytes that will be stored. Binary content smaller than this threshold may be inlined even if a binary storage service is active.- Specified by:
setMinimumBinarySize
in interfaceIBinaryStorageSvc
-
newBinaryContentId
Description copied from interface:IBinaryStorageSvc
Generate a new binaryContent ID that will be passed toIBinaryStorageSvc.storeBinaryContent(IIdType, String, String, InputStream)
later- Specified by:
newBinaryContentId
in interfaceIBinaryStorageSvc
-
isValidBinaryContentId
Default implementation is to return true for any binary content ID.- Specified by:
isValidBinaryContentId
in interfaceIBinaryStorageSvc
- Parameters:
theNewBinaryContentId
- the blob ID to validate- Returns:
- true if the blob ID is valid, false otherwise.
-
shouldStoreBinaryContent
public boolean shouldStoreBinaryContent(long theSize, org.hl7.fhir.instance.model.api.IIdType theResourceId, String theContentType) Description copied from interface:IBinaryStorageSvc
Give the storage service the ability to veto items from storage- Specified by:
shouldStoreBinaryContent
in interfaceIBinaryStorageSvc
- Parameters:
theSize
- How large is the itemtheResourceId
- What is the resource ID it will be associated withtheContentType
- What is the content type- Returns:
true
if the storage service should store the item
-
createHashingInputStream
@Nonnull protected com.google.common.hash.HashingInputStream createHashingInputStream(InputStream theInputStream) -
createCountingInputStream
@Nonnull protected org.apache.commons.io.input.CountingInputStream createCountingInputStream(InputStream theInputStream) -
provideIdForNewBinaryContent
@Deprecated(since="6.6.0 - Maintained for interface backwards compatibility. Note that invokes interceptor pointcut with empty parameters", forRemoval=true) protected String provideIdForNewBinaryContent(String theBinaryContentIdOrNull) Deprecated, for removal: This API element is subject to removal in a future version. -
provideIdForNewBinaryContent
@Nonnull protected String provideIdForNewBinaryContent(String theBinaryContentIdOrNull, byte[] theBytes, ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails, String theContentType) -
isBinaryContentIdPrefixApplied
protected boolean isBinaryContentIdPrefixApplied(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) -
setBinaryContentIdPrefixApplied
public static void setBinaryContentIdPrefixApplied(ca.uhn.fhir.rest.api.server.RequestDetails theRequestDetails) -
fetchDataByteArrayFromBinary
public byte[] fetchDataByteArrayFromBinary(org.hl7.fhir.instance.model.api.IBaseBinary theBaseBinary) throws IOException Description copied from interface:IBinaryStorageSvc
Fetch the byte[] contents of a given Binary resource's `data` element. If the data is a standard base64encoded string that is embedded, return it. Otherwise, attempt to load the externalized binary blob via the the externalized binary storage service.- Specified by:
fetchDataByteArrayFromBinary
in interfaceIBinaryStorageSvc
- Parameters:
theBaseBinary
- The Binary resource you want to extract data bytes from- Returns:
- The binary data blob as a byte array
- Throws:
IOException
-
setInterceptorBroadcasterForTests
public void setInterceptorBroadcasterForTests(ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster theInterceptorBroadcaster) -
setFhirContextForTests
-