|
| 1 | +package ca.gc.aafc.objectstore.api.config; |
| 2 | + |
| 3 | +import java.util.Map; |
| 4 | + |
| 5 | +import org.springframework.beans.factory.annotation.Value; |
| 6 | +import org.springframework.boot.info.BuildProperties; |
| 7 | +import org.springframework.context.annotation.Configuration; |
| 8 | + |
| 9 | +import ca.gc.aafc.dina.dto.ApiInfoDto; |
| 10 | +import ca.gc.aafc.objectstore.api.image.ImageConverter; |
| 11 | + |
| 12 | +@Configuration |
| 13 | +public class ApiInfoConfiguration { |
| 14 | + |
| 15 | + @Value("${dina.fileStorage.implementation:}") |
| 16 | + private String storageImplementation; |
| 17 | + |
| 18 | + @Value("${dina.messaging.isProducer:false}") |
| 19 | + private Boolean isProducer; |
| 20 | + |
| 21 | + @Value("${dina.messaging.isConsumer:false}") |
| 22 | + private Boolean isConsumer; |
| 23 | + |
| 24 | + private final String apiVersion; |
| 25 | + private final boolean magickCommandAvailable; |
| 26 | + |
| 27 | + public ApiInfoConfiguration(BuildProperties buildProperties) { |
| 28 | + this.apiVersion = buildProperties.getVersion(); |
| 29 | + this.magickCommandAvailable = ImageConverter.isToolAvailable(); |
| 30 | + } |
| 31 | + |
| 32 | + public ApiInfoDto buildApiInfoDto() { |
| 33 | + ApiInfoDto infoDto = new ApiInfoDto(); |
| 34 | + infoDto.setModuleVersion(apiVersion); |
| 35 | + infoDto.setMessageProducer(isProducer); |
| 36 | + infoDto.setMessageConsumer(isConsumer); |
| 37 | + |
| 38 | + Map<String, Object> moduleInfo = Map.of( |
| 39 | + "storageImplementation", storageImplementation, |
| 40 | + "magickCommandAvailable", magickCommandAvailable); |
| 41 | + |
| 42 | + infoDto.setModuleInfo(moduleInfo); |
| 43 | + return infoDto; |
| 44 | + } |
| 45 | +} |
0 commit comments