diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/IIniClient.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/IIniClient.java index c5d866d..d70b072 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/IIniClient.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/IIniClient.java @@ -11,7 +11,6 @@ */ package it.finanze.sanita.fse2.ms.gtw.dispatcher.client; -import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.IniAuditDto; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.IniAuditsDto; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.DeleteRequestDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.IniMetadataUpdateReqDTO; @@ -29,7 +28,7 @@ public interface IIniClient { IniReferenceResponseDTO reference(IniReferenceRequestDTO iniReferenceRequestDTO, String workflowInstanceId); - GetMergedMetadatiDTO metadata(MergedMetadatiRequestDTO iniReq, String workflowInstanceId); + GetMergedMetadatiDTO metadata(MergedMetadatiRequestDTO request); IniAuditsDto callSearchEventByWorkflowInstanceId(String workflowInstanceId); diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/IniClient.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/IniClient.java index 22cbe37..d9d09fc 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/IniClient.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/client/impl/IniClient.java @@ -89,7 +89,7 @@ public IniReferenceResponseDTO reference(IniReferenceRequestDTO request, String try { Map requestBody = new HashMap<>(); - requestBody.put("token", request); + requestBody.put("token", request.getToken()); requestBody.put("workflowInstanceId", workflowInstanceId); // Execute request ResponseEntity response = restTemplateIni.exchange(endpoint,POST,new HttpEntity<>(requestBody),IniReferenceResponseDTO.class); @@ -124,7 +124,7 @@ public IniTraceResponseDTO update(IniMetadataUpdateReqDTO request) { @Override - public GetMergedMetadatiDTO metadata(final MergedMetadatiRequestDTO request, String workflowInstanceId) { + public GetMergedMetadatiDTO metadata(final MergedMetadatiRequestDTO request) { String endpoint = routes.metadata(); GetMergedMetadatiDTO output = null; @@ -132,11 +132,7 @@ public GetMergedMetadatiDTO metadata(final MergedMetadatiRequestDTO request, Str log.debug("{} - Executing request: {}", routes.identifier(), endpoint); try { - Map requestBody = new HashMap<>(); - requestBody.put("token", request); - requestBody.put("workflowInstanceId", workflowInstanceId); - - ResponseEntity response = restTemplateIni.exchange(endpoint,PUT,new HttpEntity<>(requestBody),GetMergedMetadatiDTO.class); + ResponseEntity response = restTemplateIni.exchange(endpoint,PUT,new HttpEntity<>(request),GetMergedMetadatiDTO.class); output = response.getBody(); } catch (ResourceAccessException ex) { throw new BusinessException("Timeout error while call merge metadati"); diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java index 30cffb0..ade2d02 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/controller/impl/PublicationCTL.java @@ -240,8 +240,7 @@ public ResponseEntity replace(final String idDoc, final Publi log.info("[START] {}() with arguments {}={}, {}={}, {}={}","replace","traceId", traceInfoDTO.getTraceID(),"wif", validationInfo.getValidationData().getWorkflowInstanceId(),"idDoc", idDoc); IniReferenceRequestDTO iniReq = new IniReferenceRequestDTO(idDoc, validationInfo.getJwtPayloadToken()); - //TODO: verify wii - IniReferenceResponseDTO response = iniClient.reference(iniReq, null); + IniReferenceResponseDTO response = iniClient.reference(iniReq, validationInfo.getValidationData().getWorkflowInstanceId()); if(!isNullOrEmpty(response.getErrorMessage())) { log.error("Errore. Nessun riferimento trovato."); @@ -301,7 +300,7 @@ public ResponseWifDTO updateMetadata(final String idDoc, final PublicationMetada validateUpdateMetadataReq(requestBody); wif = createWorkflowInstanceId(idDoc); - final GetMergedMetadatiDTO metadatiToUpdate = iniClient.metadata(new MergedMetadatiRequestDTO(idDoc,jwtPayloadToken, requestBody), wif); + final GetMergedMetadatiDTO metadatiToUpdate = iniClient.metadata(new MergedMetadatiRequestDTO(idDoc,jwtPayloadToken, requestBody,wif)); if(!StringUtility.isNullOrEmpty(metadatiToUpdate.getErrorMessage()) && !metadatiToUpdate.getErrorMessage().contains("Invalid region ip")) { kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, BLOCKING_ERROR, jwtPayloadToken, metadatiToUpdate.getErrorMessage(), RIFERIMENTI_INI); throw new IniException(metadatiToUpdate.getErrorMessage()); diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/dto/request/MergedMetadatiRequestDTO.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/dto/request/MergedMetadatiRequestDTO.java index b09d957..64023eb 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/dto/request/MergedMetadatiRequestDTO.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/dto/request/MergedMetadatiRequestDTO.java @@ -26,5 +26,8 @@ public class MergedMetadatiRequestDTO { private JWTPayloadDTO token; private PublicationMetadataReqDTO body; + + private String workflow_instance_id; + } \ No newline at end of file diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/TransactionInspectSRV.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/TransactionInspectSRV.java index 8e5176d..196f855 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/TransactionInspectSRV.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/dispatcher/service/impl/TransactionInspectSRV.java @@ -11,12 +11,16 @@ */ package it.finanze.sanita.fse2.ms.gtw.dispatcher.service.impl; +import java.util.Comparator; +import java.util.stream.Collectors; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IIniClient; import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.IStatusCheckClient; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.IniAuditsDto; +import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.StatusCheckDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response.TransactionInspectResDTO; import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IConfigSRV; import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.ITransactionInspectSRV; @@ -42,7 +46,7 @@ public TransactionInspectResDTO callSearchEventByWorkflowInstanceId(final String out.getTransactionData().addAll(auditsIniDto.getAudit()); } } - + out.setTransactionData(out.getTransactionData().stream().sorted(Comparator.comparing(StatusCheckDTO::getEventDate)).collect(Collectors.toList())); return out; }