Skip to content

Commit 6f18c79

Browse files
shusheerUbuntu
authored andcommitted
Refine binary storage configuration handling
1 parent 1773c89 commit 6f18c79

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigCommon.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ public JpaStorageSettings jpaStorageSettings(AppProperties appProperties) {
225225
jpaStorageSettings.setLastNEnabled(true);
226226
}
227227

228-
Integer inlineResourceThreshold = appProperties.getInline_resource_storage_below_size();
229-
if (inlineResourceThreshold == null
230-
&& appProperties.getBinary_storage_mode() == AppProperties.BinaryStorageMode.FILESYSTEM) {
231-
inlineResourceThreshold = resolveFilesystemMinimumBinarySize(appProperties);
232-
}
228+
Integer inlineResourceThreshold = resolveInlineResourceThreshold(appProperties);
233229
if (inlineResourceThreshold != null && inlineResourceThreshold != 0) {
234230
jpaStorageSettings.setInlineResourceTextBelowSize(inlineResourceThreshold);
235231
}
@@ -352,35 +348,43 @@ public HibernatePropertiesProvider jpaStarterDialectProvider(
352348
public IBinaryStorageSvc binaryStorageSvc(AppProperties appProperties) {
353349
IBinaryStorageSvc binaryStorageSvc;
354350

351+
Integer maxBinarySize = appProperties.getMax_binary_size();
352+
Integer inlineResourceThreshold = resolveInlineResourceThreshold(appProperties);
353+
355354
if (appProperties.getBinary_storage_mode() == AppProperties.BinaryStorageMode.FILESYSTEM) {
356355
String baseDirectory = appProperties.getBinary_storage_filesystem_base_directory();
357356
Assert.hasText(
358357
baseDirectory,
359358
"binary_storage_filesystem_base_directory must be provided when binary_storage_mode=FILESYSTEM");
360359

361360
FilesystemBinaryStorageSvcImpl filesystemSvc = new FilesystemBinaryStorageSvcImpl(baseDirectory);
362-
int minimumBinarySize = resolveFilesystemMinimumBinarySize(appProperties);
361+
int minimumBinarySize =
362+
inlineResourceThreshold == null ? DEFAULT_FILESYSTEM_INLINE_THRESHOLD : inlineResourceThreshold;
363363
filesystemSvc.setMinimumBinarySize(minimumBinarySize);
364364

365-
if (appProperties.getMax_binary_size() != null) {
366-
filesystemSvc.setMaximumBinarySize(appProperties.getMax_binary_size().longValue());
365+
if (maxBinarySize != null) {
366+
filesystemSvc.setMaximumBinarySize(maxBinarySize.longValue());
367367
}
368368

369369
binaryStorageSvc = filesystemSvc;
370370
} else {
371371
DatabaseBinaryContentStorageSvcImpl databaseSvc = new DatabaseBinaryContentStorageSvcImpl();
372-
if (appProperties.getMax_binary_size() != null) {
373-
databaseSvc.setMaximumBinarySize(appProperties.getMax_binary_size());
372+
if (maxBinarySize != null) {
373+
databaseSvc.setMaximumBinarySize(maxBinarySize.longValue());
374374
}
375375
binaryStorageSvc = databaseSvc;
376376
}
377377

378378
return binaryStorageSvc;
379379
}
380380

381-
private int resolveFilesystemMinimumBinarySize(AppProperties appProperties) {
382-
Integer inlineThreshold = appProperties.getInline_resource_storage_below_size();
383-
return inlineThreshold == null ? DEFAULT_FILESYSTEM_INLINE_THRESHOLD : inlineThreshold;
381+
private Integer resolveInlineResourceThreshold(AppProperties appProperties) {
382+
Integer inlineResourceThreshold = appProperties.getInline_resource_storage_below_size();
383+
if (inlineResourceThreshold == null
384+
&& appProperties.getBinary_storage_mode() == AppProperties.BinaryStorageMode.FILESYSTEM) {
385+
return DEFAULT_FILESYSTEM_INLINE_THRESHOLD;
386+
}
387+
return inlineResourceThreshold;
384388
}
385389

386390
@Bean

0 commit comments

Comments
 (0)