Fix su aggiornamento valori StbExchangeConfig
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good
This commit is contained in:
@@ -48,7 +48,7 @@ public class ExchangeSystemManagerService {
|
||||
@PostContextConstruct(priority = 20)
|
||||
public void init() throws Exception {
|
||||
|
||||
if(!settingsModel.isPrimaryInstance() || UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
if (!settingsModel.isPrimaryInstance() || UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
return;
|
||||
|
||||
for (AdvancedDataSource db : multiDBTransactionManager.getActiveConnections()) {
|
||||
@@ -91,9 +91,6 @@ public class ExchangeSystemManagerService {
|
||||
private void executeExchange(StbExchangeConfig stbExchangeConfig) {
|
||||
logger.info("Avvio EXCHANGE [" + stbExchangeConfig.getDescription() + "]");
|
||||
|
||||
stbExchangeConfig = (StbExchangeConfig) stbExchangeConfig.clone();
|
||||
stbExchangeConfig.setSchedulationCron(null); //Blanco il campo schedulazione per evitare che venga salvato nel DB
|
||||
|
||||
StbExchangeConfigDetail executingStbExchangeConfigDetail = null;
|
||||
|
||||
try (MultiDBTransactionManager internalDb = new MultiDBTransactionManager(stbExchangeConfig.getInternalProfileDb())) {
|
||||
@@ -109,10 +106,7 @@ public class ExchangeSystemManagerService {
|
||||
RequestDataDTO requestDataDTO = new RequestDataDTO();
|
||||
requestDataDTO.setUsername("EXCHANGE");
|
||||
|
||||
stbExchangeConfig.setLastExecution(LocalDateTime.now())
|
||||
.setOperation(OperationType.UPDATE);
|
||||
stbExchangeConfig.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
internalDb.commitAll();
|
||||
saveStartTime(internalDb, stbExchangeConfig, LocalDateTime.now());
|
||||
|
||||
for (StbExchangeConfigDetail stbExchangeConfigDetail : stbExchangeConfigs) {
|
||||
executingStbExchangeConfigDetail = stbExchangeConfigDetail;
|
||||
@@ -212,9 +206,7 @@ public class ExchangeSystemManagerService {
|
||||
|
||||
}
|
||||
|
||||
stbExchangeConfig.setLastExecutionErrorMessage(EmsRestConstants.NULL)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
stbExchangeConfig.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
saveEndTime(internalDb, stbExchangeConfig);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Errore", e);
|
||||
@@ -231,7 +223,32 @@ public class ExchangeSystemManagerService {
|
||||
|
||||
}
|
||||
|
||||
private void saveStartTime(MultiDBTransactionManager internalDb, @NotNull StbExchangeConfig stbExchangeConfig, @NotNull LocalDateTime startTime) throws Exception {
|
||||
StbExchangeConfig stbExchangeConfigClone = new StbExchangeConfig()
|
||||
.setId(stbExchangeConfig.getId());
|
||||
|
||||
stbExchangeConfigClone.setLastExecution(LocalDateTime.now())
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
stbExchangeConfigClone.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
internalDb.commitAll();
|
||||
}
|
||||
|
||||
private void saveEndTime(MultiDBTransactionManager internalDb, @NotNull StbExchangeConfig stbExchangeConfig) throws Exception {
|
||||
StbExchangeConfig stbExchangeConfigClone = new StbExchangeConfig()
|
||||
.setId(stbExchangeConfig.getId());
|
||||
|
||||
stbExchangeConfigClone.setLastExecutionErrorMessage(EmsRestConstants.NULL)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
|
||||
stbExchangeConfigClone.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
internalDb.commitAll();
|
||||
}
|
||||
|
||||
private void saveErrorLog(MultiDBTransactionManager internalDb, @NotNull StbExchangeConfig stbExchangeConfig, @Nullable StbExchangeConfigDetail stbExchangeConfigDetail, @NotNull Exception exceptionToLog) {
|
||||
StbExchangeConfig stbExchangeConfigClone = new StbExchangeConfig()
|
||||
.setId(stbExchangeConfig.getId());
|
||||
|
||||
String logMessage = "";
|
||||
|
||||
if (stbExchangeConfigDetail != null) {
|
||||
@@ -240,10 +257,10 @@ public class ExchangeSystemManagerService {
|
||||
|
||||
logMessage += UtilityException.convertExceptionToHumanReadableText(exceptionToLog);
|
||||
|
||||
stbExchangeConfig.setLastExecutionErrorMessage(logMessage)
|
||||
stbExchangeConfigClone.setLastExecutionErrorMessage(logMessage)
|
||||
.setOperation(OperationType.UPDATE);
|
||||
try {
|
||||
stbExchangeConfig.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
stbExchangeConfigClone.manageWithParentConnection(internalDb.getPrimaryConnection());
|
||||
internalDb.commitAll();
|
||||
} catch (Exception e) {
|
||||
logger.error("Errore durante l'aggiornamento dello stato dell'exchange", e);
|
||||
|
||||
Reference in New Issue
Block a user