Skip to content

Commit

Permalink
NOD-690: optional repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fparisitas committed Feb 16, 2024
1 parent a1f2139 commit d0cea38
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public class ApiConfigCacheService extends CommonCacheService {

private final ApiConfigCacheClient apiConfigCacheClient;

@Autowired
private PagoPACachePostgreRepository pagoPACachePostgreRepository;
@Autowired(required = false)
private Optional<PagoPACachePostgreRepository> pagoPACachePostgreRepository;
@Autowired(required = false)
private Optional<NexiCachePostgreRepository> nexiCachePostgreRepository;
@Autowired(required = false)
Expand Down Expand Up @@ -98,33 +98,33 @@ public Map<String, SyncStatusEnum> forceCacheUpdate() {
ConfigCache configCache = composeCache(cacheId, ZonedDateTime.parse(cacheTimestamp).toLocalDateTime(), cacheVersion, response.body().asInputStream().readAllBytes());

try {
if( pagopaPostgreCacheEnabled ) {
pagoPACachePostgreRepository.save(configCache);
if( pagopaPostgreCacheEnabled && pagoPACachePostgreRepository.isPresent() ) {
pagoPACachePostgreRepository.get().save(configCache);
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done);
} else {
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.disabled);
}
} catch(Exception ex) {
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error);
}
// try {
// if (nexiPostgreCacheEnabled) {
// nexiCachePostgreRepository.save(configCache);
// } else {
// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled);
// }
// } catch(Exception ex) {
// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error);
// }
// try {
// if( nexiOracleCacheEnabled ) {
// nexiCacheOracleRepository.save(configCache);
// } else {
// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled);
// }
// } catch(Exception ex) {
// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error);
// }
try {
if ( nexiPostgreCacheEnabled && nexiCachePostgreRepository.isPresent() ) {
nexiCachePostgreRepository.get().save(configCache);
} else {
syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled);
}
} catch(Exception ex) {
syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error);
}
try {
if( nexiOracleCacheEnabled && nexiCacheOracleRepository.isPresent() ) {
nexiCacheOracleRepository.get().save(configCache);
} else {
syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled);
}
} catch(Exception ex) {
syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error);
}
} catch (FeignException.GatewayTimeout e) {
log.error("SyncService api-config-cache get cache error: Gateway timeout", e);
throw new AppException(AppError.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Map<String, SyncStatusEnum> forceStandIn() {
List<StandInStations> stationsEntities = stations.getStations().stream().map(StandInStations::new).collect(Collectors.toList());

try {
if (pagopaPostgreStandInEnabled) {
if ( pagopaPostgreStandInEnabled && pagoPAStandInPostgreRepository.isPresent() ) {
pagoPAStandInPostgreRepository.get().deleteAll();
pagoPAStandInPostgreRepository.get().saveAll(stationsEntities);
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.done);
Expand All @@ -97,28 +97,28 @@ public Map<String, SyncStatusEnum> forceStandIn() {
} catch(Exception ex) {
syncStatusMap.put(pagopaPostgreServiceIdentifier, SyncStatusEnum.error);
}
// try {
// if (nexiPostgreStandInEnabled) {
// nexiStandInPostgreRepository.deleteAll();
// nexiStandInPostgreRepository.saveAll(stationsEntities);
// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done);
// } else {
// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled);
// }
// } catch(Exception ex) {
// syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error);
// }
// try {
// if( nexiOracleStandInEnabled ) {
// nexiStandInOracleRepository.deleteAll();
// nexiStandInOracleRepository.saveAll(stationsEntities);
// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done);
// } else {
// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled);
// }
// } catch(Exception ex) {
// syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error);
// }
try {
if ( nexiPostgreStandInEnabled && nexiStandInPostgreRepository.isPresent() ) {
nexiStandInPostgreRepository.get().deleteAll();
nexiStandInPostgreRepository.get().saveAll(stationsEntities);
syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.done);
} else {
syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.disabled);
}
} catch(Exception ex) {
syncStatusMap.put(nexiPostgreServiceIdentifier, SyncStatusEnum.error);
}
try {
if( nexiOracleStandInEnabled && nexiStandInOracleRepository.isPresent() ) {
nexiStandInOracleRepository.get().deleteAll();
nexiStandInOracleRepository.get().saveAll(stationsEntities);
syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.done);
} else {
syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.disabled);
}
} catch(Exception ex) {
syncStatusMap.put(nexiOracleServiceIdentifier, SyncStatusEnum.error);
}
} catch (FeignException.GatewayTimeout e) {
log.error("SyncService stand-in-manager get stations error: Gateway timeout", e);
throw new AppException(AppError.INTERNAL_SERVER_ERROR);
Expand Down

0 comments on commit d0cea38

Please sign in to comment.