Skip to content

Commit

Permalink
Merge branch 'develop' into feature/otel-config
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenzo-ingenito committed Mar 15, 2024
2 parents e1f7684 + e0516b6 commit fabd06c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.config.Constants.App.MISSING_WORKFLOW_PLACEHOLDER;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventStatusEnum.BLOCKING_ERROR;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventStatusEnum.SUCCESS;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.EDS_DELETE;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.EDS_UPDATE;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.INI_DELETE;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.INI_UPDATE;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.EDS_DELETE;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.EventTypeEnum.RIFERIMENTI_INI;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.RestExecutionResultEnum.FHIR_MAPPING_ERROR;
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.RestExecutionResultEnum.INI_EXCEPTION;
Expand All @@ -33,6 +33,7 @@
import static it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.StringUtility.isNullOrEmpty;

import java.util.Date;
import java.util.List;
import java.util.Objects;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -102,8 +103,8 @@
import it.finanze.sanita.fse2.ms.gtw.dispatcher.logging.LoggerHelper;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IAccreditamentoSimulationSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IConfigSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IFhirSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IErrorHandlerSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IFhirSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IJwtSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IKafkaSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.ISignSRV;
Expand Down Expand Up @@ -268,10 +269,7 @@ public ResponseEntity<PublicationResDTO> replace(final String idDoc, final Publi
warning = Misc.WARN_EXTRACTION_SELECTION;
}

log.info("[EXIT] {}() with arguments {}={}, {}={}, {}={}","replace",
"traceId", traceInfoDTO.getTraceID(),"wif", validationInfo.getValidationData().getWorkflowInstanceId(),"idDoc", idDoc
);

log.info("[EXIT] {}() with arguments {}={}, {}={}, {}={}","replace","traceId", traceInfoDTO.getTraceID(),"wif", validationInfo.getValidationData().getWorkflowInstanceId(),"idDoc", idDoc);
return new ResponseEntity<>(new PublicationResDTO(traceInfoDTO, warning, validationInfo.getValidationData().getWorkflowInstanceId()), HttpStatus.OK);
}

Expand Down Expand Up @@ -323,11 +321,13 @@ public ResponseWifDTO updateMetadata(final String idDoc, final PublicationMetada
if(regimeDiMock) {
kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, SUCCESS, jwtPayloadToken, "Regime di mock", INI_UPDATE);
} else {
IniTraceResponseDTO res = iniClient.update(new IniMetadataUpdateReqDTO(metadatiToUpdate.getMarshallResponse(), jwtPayloadToken,metadatiToUpdate.getDocumentType(),wif,"ADM_REQ","AUTH_INST"));
IniTraceResponseDTO res = iniClient.update(new IniMetadataUpdateReqDTO(metadatiToUpdate.getMarshallResponse(), jwtPayloadToken,metadatiToUpdate.getDocumentType(),wif,
metadatiToUpdate.getAdministrativeRequest(), metadatiToUpdate.getAuthorInstitution()));
// Check response errors
if(!StringUtility.isNullOrEmpty(res.getErrorMessage())) {
// Send to indexer
kafkaSRV.sendUpdateRequest(wif, new IniMetadataUpdateReqDTO(metadatiToUpdate.getMarshallResponse(), jwtPayloadToken, metadatiToUpdate.getDocumentType(), wif,"ADM_REQ","AUTH_INST"));
kafkaSRV.sendUpdateRequest(wif, new IniMetadataUpdateReqDTO(metadatiToUpdate.getMarshallResponse(), jwtPayloadToken, metadatiToUpdate.getDocumentType(), wif,
metadatiToUpdate.getAdministrativeRequest(), metadatiToUpdate.getAuthorInstitution()));
kafkaSRV.sendUpdateStatus(logTraceDTO.getTraceID(), wif, idDoc, EventStatusEnum.ASYNC_RETRY, jwtPayloadToken, "Transazione presa in carico", INI_UPDATE);
warning = Misc.WARN_ASYNC_TRANSACTION;
} else {
Expand All @@ -337,8 +337,7 @@ public ResponseWifDTO updateMetadata(final String idDoc, final PublicationMetada

}

logger.info(Constants.App.LOG_TYPE_CONTROL,wif,String.format("Update of CDA metadata completed for document with identifier %s", idDoc), OperationLogEnum.UPDATE_METADATA_CDA2, ResultLogEnum.OK, startDateOperation, MISSING_DOC_TYPE_PLACEHOLDER,
jwtPayloadToken,null);
logger.info(Constants.App.LOG_TYPE_CONTROL,wif,String.format("Update of CDA metadata completed for document with identifier %s", idDoc), OperationLogEnum.UPDATE_METADATA_CDA2, ResultLogEnum.OK, startDateOperation, MISSING_DOC_TYPE_PLACEHOLDER, jwtPayloadToken,null);
} catch (MockEnabledException me) {
throw me;
} catch (final ValidationException e) {
Expand All @@ -349,13 +348,11 @@ public ResponseWifDTO updateMetadata(final String idDoc, final PublicationMetada
errorInstance = get(((ValidationException) e).getError().getType());
}

logger.error(Constants.App.LOG_TYPE_CONTROL,wif,String.format("Error while updating CDA metadata of document with identifier %s", idDoc), OperationLogEnum.UPDATE_METADATA_CDA2, ResultLogEnum.KO, startDateOperation, errorInstance.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER,
jwtPayloadToken);
logger.error(Constants.App.LOG_TYPE_CONTROL,wif,String.format("Error while updating CDA metadata of document with identifier %s", idDoc), OperationLogEnum.UPDATE_METADATA_CDA2, ResultLogEnum.KO, startDateOperation, errorInstance.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER,jwtPayloadToken);
throw e;
}

log.info("[EXIT] {}() with arguments {}={}, {}={}, {}={}","update",
"traceId", logTraceDTO.getTraceID(),"wif", wif,"idDoc", idDoc);
log.info("[EXIT] {}() with arguments {}={}, {}={}, {}={}","update","traceId", logTraceDTO.getTraceID(),"wif", wif,"idDoc", idDoc);

return new ResponseWifDTO(wif, logTraceDTO, warning);
}
Expand Down Expand Up @@ -571,8 +568,7 @@ public ResponseWifDTO delete(String idDoc, HttpServletRequest request) {
} catch(MockEnabledException me) {
throw me;
} catch(IniException inEx) {
logger.error(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId,String.format("Error while delete record from ini %s", idDoc), OperationLogEnum.DELETE_CDA2, ResultLogEnum.KO, startOperation, INI_EXCEPTION.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER,
jwtPayloadToken);
logger.error(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId,String.format("Error while delete record from ini %s", idDoc), OperationLogEnum.DELETE_CDA2, ResultLogEnum.KO, startOperation, INI_EXCEPTION.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER, jwtPayloadToken);
throw inEx;

} catch (Exception e) {
Expand All @@ -581,8 +577,7 @@ public ResponseWifDTO delete(String idDoc, HttpServletRequest request) {
errorInstance = get(((ValidationException) e).getError().getType());
}

logger.error(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId,String.format("Error while deleting CDA of document with identifier %s", idDoc), OperationLogEnum.DELETE_CDA2, ResultLogEnum.KO, startOperation, errorInstance.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER,
jwtPayloadToken);
logger.error(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId,String.format("Error while deleting CDA of document with identifier %s", idDoc), OperationLogEnum.DELETE_CDA2, ResultLogEnum.KO, startOperation, errorInstance.getErrorCategory(), MISSING_DOC_TYPE_PLACEHOLDER, jwtPayloadToken);
throw e;
}

Expand All @@ -592,7 +587,7 @@ public ResponseWifDTO delete(String idDoc, HttpServletRequest request) {

private DeleteRequestDTO buildRequestForIni(final String identificativoDocumento, final String uuid, final JWTPayloadDTO jwtPayloadToken,
final String documentType, String applicationId, String applicationVendor, String applicationVersion,
final String workflowInstanceId, String authorInstitution, String administrativeRequest) {
final String workflowInstanceId, String authorInstitution, List<String> administrativeRequest) {
DeleteRequestDTO out = null;
try {
out = DeleteRequestDTO.builder().
Expand Down Expand Up @@ -643,12 +638,9 @@ public ResponseEntity<PublicationResDTO> validateAndCreate(ValidateAndCreateDTO
String issuer = validationResult.getJwtPayloadToken().getIss();
warning = validate(validationResult.getCda(), ActivityEnum.VALIDATION, workflowInstanceId,issuer);

kafkaSRV.sendValidationStatus(traceInfoDTO.getTraceID(), workflowInstanceId, EventStatusEnum.SUCCESS,null, validationResult.getJwtPayloadToken(), EventTypeEnum.VALIDATION_FOR_PUBLICATION);

kafkaSRV.sendValidationStatus(traceInfoDTO.getTraceID(), workflowInstanceId, EventStatusEnum.SUCCESS,null, validationResult.getJwtPayloadToken(),
EventTypeEnum.VALIDATION_FOR_PUBLICATION);

logger.info(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId, "Validation CDA completed for workflow instance Id " + workflowInstanceId, OperationLogEnum.VAL_CDA2, ResultLogEnum.OK, startDateOperationValidation, CdaUtility.getDocumentType(docT),validationResult.getJwtPayloadToken(),
null);
logger.info(Constants.App.LOG_TYPE_CONTROL,workflowInstanceId, "Validation CDA completed for workflow instance Id " + workflowInstanceId, OperationLogEnum.VAL_CDA2, ResultLogEnum.OK, startDateOperationValidation, CdaUtility.getDocumentType(docT),validationResult.getJwtPayloadToken(), null);
request.setAttribute("JWT_ISSUER", validationResult.getJwtPayloadToken().getIss());
} catch (final ValidationException e) {
errorHandlerSRV.validationExceptionHandler(startDateOperationValidation, traceInfoDTO, workflowInstanceId, validationResult.getJwtPayloadToken(), e, CdaUtility.getDocumentType(docT));
Expand All @@ -657,9 +649,7 @@ public ResponseEntity<PublicationResDTO> validateAndCreate(ValidateAndCreateDTO
final Date startDateOperationPublication = new Date();
try {
//Eseguo le operazione di creazione
ValidationDataDTO dto = executePublicationReplace(validationResult,
validationResult.getJwtPayloadToken(), validationResult.getJsonObj(), validationResult.getFile(),
validationResult.getCda());
ValidationDataDTO dto = executePublicationReplace(validationResult, validationResult.getJwtPayloadToken(), validationResult.getJsonObj(), validationResult.getFile(), validationResult.getCda());
validationResult.setValidationData(dto);

//Eseguo le operazione post creazione
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DocumentEntryDTO {
private String creationTime;
private String hash;
private Integer size;
private String administrativeRequest;
private List<String> administrativeRequest;
private String author;
private String authorRole;
private String authorInstitution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -39,6 +41,6 @@ public class DeleteRequestDTO {
private String subject_application_vendor;
private String subject_application_version;
private String workflow_instance_id;
private String administrative_request;
private List<String> administrative_request;
private String author_institution;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request;

import java.util.List;

import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.JWTPayloadDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -27,7 +29,7 @@ public class IniMetadataUpdateReqDTO {

private String workflow_instance_id;

private String administrative_request;
private List<String> administrative_request;

private String author_institution;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class PublicationMetadataReqDTO {
private List<String> descriptions;

@Schema(description = "Administrative")
private AdministrativeReqEnum administrativeRequest;
private List<AdministrativeReqEnum> administrativeRequest;


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response;

import java.util.List;

import lombok.Data;

@Data
Expand All @@ -21,5 +23,8 @@ public class GetMergedMetadatiDTO {
private String marshallResponse;

private String documentType;

private String authorInstitution;

private List<String> administrativeRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -26,7 +28,7 @@ public class IniReferenceResponseDTO extends ResponseDTO {

private String errorMessage;

private String administrativeRequest;
private List<String> administrativeRequest;

private String authorInstitution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
*/
package it.finanze.sanita.fse2.ms.gtw.dispatcher.service.impl;

import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Date;
import java.util.List;

import org.bson.Document;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;


import it.finanze.sanita.fse2.ms.gtw.dispatcher.client.impl.FhirMappingClient;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.config.Constants;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.AuthorSlotDTO;
Expand All @@ -34,11 +35,11 @@
import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.SubmissionSetEntryDTO;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.request.PublicationCreateReplaceMetadataDTO;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.dto.response.client.TransformResDTO;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.AdministrativeReqEnum;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.AttivitaClinicaEnum;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.enums.LowLevelDocEnum;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.exceptions.BusinessException;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.service.IFhirSRV;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.FileUtility;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.StringUtility;
import it.finanze.sanita.fse2.ms.gtw.dispatcher.utility.ValidationUtility;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -199,7 +200,12 @@ private DocumentEntryDTO createDocumentEntry(final org.jsoup.nodes.Document docC
de.setHash(hash);
de.setSize(size);
if(requestBody.getAdministrativeRequest() != null) {
de.setAdministrativeRequest(requestBody.getAdministrativeRequest().getCode() + "^" + requestBody.getAdministrativeRequest().getDescription());
List<String> administrativeRequestList = new ArrayList<>();
for(AdministrativeReqEnum en : requestBody.getAdministrativeRequest()) {
administrativeRequestList.add(en.getCode() + "^" + en.getDescription());
}
de.setAdministrativeRequest(administrativeRequestList);

}

de.setAuthorRole(authorSlotDTO.getAuthorRole());
Expand Down

0 comments on commit fabd06c

Please sign in to comment.