diff --git a/src/main/java/org/mskcc/smile/service/impl/PromotedRequestMsgHandlingServiceImpl.java b/src/main/java/org/mskcc/smile/service/impl/PromotedRequestMsgHandlingServiceImpl.java index 50e638e..808b650 100644 --- a/src/main/java/org/mskcc/smile/service/impl/PromotedRequestMsgHandlingServiceImpl.java +++ b/src/main/java/org/mskcc/smile/service/impl/PromotedRequestMsgHandlingServiceImpl.java @@ -18,7 +18,6 @@ import org.mskcc.cmo.messaging.MessageConsumer; import org.mskcc.smile.service.PromotedRequestMsgHandlingService; import org.mskcc.smile.service.ValidRequestChecker; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -45,9 +44,6 @@ public class PromotedRequestMsgHandlingServiceImpl implements PromotedRequestMsg @Autowired private ValidRequestChecker validRequestChecker; - @Autowired - private RequestStatusLogger requestStatusLogger; - private final ObjectMapper mapper = new ObjectMapper(); private static boolean initialized = false; private static volatile boolean shutdownInitiated; @@ -162,12 +158,6 @@ public void onMessage(Message msg, Object message) { } catch (Exception e) { LOG.error("Exception during processing of request on topic: " + VALIDATE_PROMOTED_REQUEST_TOPIC, e); - try { - requestStatusLogger.logRequestStatus(message.toString(), - RequestStatusLogger.StatusType.REQUEST_PARSING_ERROR); - } catch (IOException ex) { - LOG.error("Error during attempt to write request status to logger file", ex); - } } } }); diff --git a/src/main/java/org/mskcc/smile/service/impl/RequestFilterMsgHandlingServiceIml.java b/src/main/java/org/mskcc/smile/service/impl/RequestFilterMsgHandlingServiceIml.java index 1531999..300dde0 100644 --- a/src/main/java/org/mskcc/smile/service/impl/RequestFilterMsgHandlingServiceIml.java +++ b/src/main/java/org/mskcc/smile/service/impl/RequestFilterMsgHandlingServiceIml.java @@ -17,7 +17,6 @@ import org.mskcc.cmo.messaging.MessageConsumer; import org.mskcc.smile.service.RequestFilterMessageHandlingService; import org.mskcc.smile.service.ValidRequestChecker; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -44,9 +43,6 @@ public class RequestFilterMsgHandlingServiceIml implements RequestFilterMessageH @Autowired private ValidRequestChecker validRequestChecker; - @Autowired - private RequestStatusLogger requestStatusLogger; - private final ObjectMapper mapper = new ObjectMapper(); private static boolean initialized = false; private static volatile boolean shutdownInitiated; @@ -183,12 +179,6 @@ public void onMessage(Message msg, Object message) { } catch (Exception e) { LOG.error("Exception during processing of request on topic: " + IGO_REQUEST_FILTER_TOPIC, e); - try { - requestStatusLogger.logRequestStatus(message.toString(), - RequestStatusLogger.StatusType.REQUEST_PARSING_ERROR); - } catch (IOException ex) { - LOG.error("Error during attempt to write request status to logger file", ex); - } } } }); diff --git a/src/main/java/org/mskcc/smile/service/impl/ValidRequestCheckerImpl.java b/src/main/java/org/mskcc/smile/service/impl/ValidRequestCheckerImpl.java index fcd3907..72e7bd5 100644 --- a/src/main/java/org/mskcc/smile/service/impl/ValidRequestCheckerImpl.java +++ b/src/main/java/org/mskcc/smile/service/impl/ValidRequestCheckerImpl.java @@ -19,7 +19,6 @@ import org.mskcc.smile.commons.enums.SampleType; import org.mskcc.smile.commons.enums.SpecimenType; import org.mskcc.smile.service.ValidRequestChecker; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -27,9 +26,6 @@ @Component public class ValidRequestCheckerImpl implements ValidRequestChecker { - @Autowired - private RequestStatusLogger requestStatusLogger; - @Value("${igo.cmo_request_filter:false}") private Boolean igoCmoRequestFilter; @@ -136,11 +132,11 @@ public Map generatePromotedRequestValidationMap(String requestJs } } if (validPromotedSampleCount < sampleList.length) { + String requestId = getRequestId(requestJson); LOG.warn("One or more sample(s) is missing one or a combination of the following: igoId or " + "primaryId, cmoPatientId or cmoSampleIdFields --> normalizedPatientId - this " - + "information must be added for promoted requests & samples"); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.PROMOTED_SAMPLES_MISSING_IDS); + + "information must be added for promoted requests & samples: requestId = " + + requestId + ", " + requestJson); } if (validPromotedSampleCount == 0) { requestStatus.put("validationStatus", Boolean.FALSE); @@ -206,9 +202,7 @@ public Map generateRequestStatusValidationMap(String requestJson // if requestId is blank then nothing to do, return null if (!hasRequestId) { - LOG.warn("CMO request failed sanity checking - missing requestId..."); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.REQUEST_MISSING_REQUEST_ID); + LOG.warn("CMO request failed sanity checking - missing requestId. " + requestJson); validationReport.put("requestId", "IGO Request ID is missing from the request JSON received."); validationStatus = Boolean.FALSE; } @@ -216,9 +210,7 @@ public Map generateRequestStatusValidationMap(String requestJson // if cmo filter is enabled then skip request if it is non-cmo if (igoCmoRequestFilter && !isCmoRequest) { LOG.warn("CMO request filter enabled - skipping non-CMO request: " - + getRequestId(requestJsonMap)); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.CMO_REQUEST_FILTER_SKIPPED_REQUEST); + + getRequestId(requestJsonMap) + ", " + requestJson); validationReport.put("isCmo", "SMILE CMO request filter is enabled and request JSON received has" + " 'cmoRequest': false. This value must be set to true for import into SMILE."); validationStatus = Boolean.FALSE; @@ -599,11 +591,11 @@ private Boolean hasNormalizedPatientId(Map sampleMap) } private Boolean requestHasSamples(String requestJson) throws JsonProcessingException, IOException { + String requestId = getRequestId(requestJson); Map requestJsonMap = mapper.readValue(requestJson, Map.class); if (!requestJsonMap.containsKey("samples")) { - LOG.warn("Skipping request that is missing 'samples' in JSON"); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.REQUEST_WITH_MISSING_SAMPLES); + LOG.warn("Skipping request that is missing 'samples' in JSON for request ID: " + + requestId + ", " + requestJson); return Boolean.FALSE; } @@ -611,9 +603,8 @@ private Boolean requestHasSamples(String requestJson) throws JsonProcessingExcep Object[] sampleList = mapper.convertValue(requestJsonMap.get("samples"), Object[].class); if (sampleList.length == 0) { - LOG.warn("Skipping request without any sample data in 'samples' JSON field"); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.REQUEST_WITH_MISSING_SAMPLES); + LOG.warn("Skipping request without any sample data in 'samples' JSON field: " + + requestId + ", " + requestJson); return Boolean.FALSE; } return Boolean.TRUE; diff --git a/src/main/java/org/mskcc/smile/service/impl/ValidateUpdatesMsgHandlingServiceImpl.java b/src/main/java/org/mskcc/smile/service/impl/ValidateUpdatesMsgHandlingServiceImpl.java index b19db12..6baebc9 100644 --- a/src/main/java/org/mskcc/smile/service/impl/ValidateUpdatesMsgHandlingServiceImpl.java +++ b/src/main/java/org/mskcc/smile/service/impl/ValidateUpdatesMsgHandlingServiceImpl.java @@ -17,7 +17,6 @@ import org.mskcc.cmo.messaging.MessageConsumer; import org.mskcc.smile.service.ValidRequestChecker; import org.mskcc.smile.service.ValidateUpdatesMessageHandlingService; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -45,9 +44,6 @@ public class ValidateUpdatesMsgHandlingServiceImpl implements ValidateUpdatesMes @Autowired private ValidRequestChecker validRequestChecker; - @Autowired - private RequestStatusLogger requestStatusLogger; - private static boolean initialized = false; private static Gateway messagingGateway; private static final Log LOG = LogFactory.getLog(RequestFilterMsgHandlingServiceIml.class); @@ -123,8 +119,6 @@ public void run() { } else { LOG.error("Sanity check failed on Request updates: " + validRequestChecker.getRequestId(requestJson)); - requestStatusLogger.logRequestStatus(requestJson, - RequestStatusLogger.StatusType.REQUEST_UPDATE_FAILED_SANITY_CHECK); } } if (interrupted && requestUpdateFilterQueue.isEmpty()) { @@ -158,9 +152,8 @@ public void run() { Map sampleMap = mapper.readValue(sampleJson, Map.class); Boolean hasRequestId = validRequestChecker.hasRequestId(sampleJson); if (!hasRequestId) { - LOG.warn("Cannot extract request ID information from sample update message"); - requestStatusLogger.logRequestStatus(sampleJson, - RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK); + LOG.warn("Cannot extract request ID information from sample update message: " + + sampleJson); continue; } @@ -175,9 +168,7 @@ public void run() { messagingGateway.publish(CMO_LABEL_UPDATE_TOPIC, sampleJson); } else { - LOG.error("Sanity check failed on CMO sample updates "); - requestStatusLogger.logRequestStatus(sampleJson, - RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK); + LOG.error("Sanity check failed on CMO sample updates: " + sampleJson); } } else { Map sampleStatus = @@ -190,9 +181,8 @@ public void run() { SERVER_SAMPLE_UPDATE_TOPIC, sampleJson); } else { - LOG.error("Sanity check failed on non-CMO sample update received."); - requestStatusLogger.logRequestStatus(sampleJson, - RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK); + LOG.error("Sanity check failed on non-CMO sample update received: " + + sampleJson); } } } diff --git a/src/main/java/org/mskcc/smile/service/util/RequestStatusLogger.java b/src/main/java/org/mskcc/smile/service/util/RequestStatusLogger.java deleted file mode 100644 index ac49b41..0000000 --- a/src/main/java/org/mskcc/smile/service/util/RequestStatusLogger.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.mskcc.smile.service.util; - -import java.io.File; -import java.io.IOException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import org.apache.commons.lang3.StringUtils; -import org.mskcc.smile.commons.FileUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -/** - * Class for logging request statuses to the provided - * Request Handling filepath. - * @author ochoaa - */ -@Component -public class RequestStatusLogger { - @Value("${req_filter.request_logger_filepath}") - private String requestLoggerFilepath; - - @Autowired - private FileUtil fileUtil; - - private File requestStatusLoggerFile; - - private static final String[] REQUEST_LOGGER_FILE_HEADER = new String[]{"DATE", "STATUS", "MESSAGE"}; - - /** - * Request StatusType descriptions: - * - REQUEST_WITH_MISSING_SAMPLES: a request that came in with no sample metadata - * - REQUEST_MISSING_REQUEST_ID: a request missing a request id - * - CMO_REQUEST_WITH_SAMPLES_MISSING_CMO_LABEL_FIELDS: a CMO request with sample metadata - * that is missing required fields (cmoPatientId, baitSet) - * - REQUEST_PARSING_ERROR: json parsing exception thrown - * - CMO_REQUEST_FILTER_SKIPPED_REQUEST: applies if smile server is running - * with the cmoRequestFilter enabled and a non-cmo request is encountered - * - CMO_REQUEST_FAILED_SANITY_CHECK: request failed cmo-specific sanity check on - * required fields for generating cmo labels - * - REQUEST_UPDATE_FAILED_SANITY_CHECK: request metadata update failed sanity check on - * required fields - * - SAMPLE_UPDATE_FAILED_SANITY_CHECK: sample metadata update failed sanity check on - * required fields. This can be for either cmo samples missing required - * fields to generate cmo label or non-cmo samples - * - PROMOTED_REQUEST_FAILED_SANITY_CHECK: a promoted request which has failed sanity - * check on the minimally required fields - * - PROMOTED_SAMPLES_MISSING_IDS: at least one sample in the promoted request is missing - * key identifier information (igoId and/or primaryId) - */ - public enum StatusType { - REQUEST_WITH_MISSING_SAMPLES, - REQUEST_MISSING_REQUEST_ID, - CMO_REQUEST_WITH_SAMPLES_MISSING_CMO_LABEL_FIELDS, - REQUEST_PARSING_ERROR, - CMO_REQUEST_FILTER_SKIPPED_REQUEST, - CMO_REQUEST_FAILED_SANITY_CHECK, - REQUEST_UPDATE_FAILED_SANITY_CHECK, - SAMPLE_UPDATE_FAILED_SANITY_CHECK, - PROMOTED_REQUEST_FAILED_SANITY_CHECK, - PROMOTED_SAMPLES_MISSING_IDS - } - - /** - * Writes request contents and status to the request status logger file. - * @param message - * @param status - * @throws IOException - */ - public void logRequestStatus(String message, StatusType status) throws IOException { - if (requestStatusLoggerFile == null) { - this.requestStatusLoggerFile = fileUtil.getOrCreateFileWithHeader(requestLoggerFilepath, - StringUtils.join(REQUEST_LOGGER_FILE_HEADER, "\t") + "\n"); - } - String currentDate = LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE); - StringBuilder builder = new StringBuilder(); - builder.append(currentDate) - .append("\t") - .append(status.toString()) - .append("\t") - .append(message) - .append("\n"); - fileUtil.writeToFile(requestStatusLoggerFile, builder.toString()); - } -} diff --git a/src/main/resources/application.properties.EXAMPLE b/src/main/resources/application.properties.EXAMPLE index 72161e5..dfb7b49 100644 --- a/src/main/resources/application.properties.EXAMPLE +++ b/src/main/resources/application.properties.EXAMPLE @@ -45,5 +45,3 @@ num.promoted_request_handler_threads= # publishing failures filepath smile.publishing_failures_filepath= -# detailed consistency checking logger filepath -req_filter.request_logger_filepath= diff --git a/src/test/java/org/mskcc/smile/config/MockDataConfig.java b/src/test/java/org/mskcc/smile/config/MockDataConfig.java index 868ac0f..5f20eae 100644 --- a/src/test/java/org/mskcc/smile/config/MockDataConfig.java +++ b/src/test/java/org/mskcc/smile/config/MockDataConfig.java @@ -14,7 +14,6 @@ import org.mskcc.smile.commons.FileUtil; import org.mskcc.smile.model.MockJsonTestData; import org.mskcc.smile.service.impl.ValidRequestCheckerImpl; -import org.mskcc.smile.service.util.RequestStatusLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -48,17 +47,12 @@ public ValidRequestCheckerImpl validRequestCheckerImpl() { return new ValidRequestCheckerImpl(); } - @Bean - public RequestStatusLogger requestStatusLogger() { - return Mockito.mock(RequestStatusLogger.class); - } - private Map mockedRequestJsonDataMap; /** * Generates the mocked request json data map; * @return Map - * @throws IOException + * @throws IOException */ @Bean(name = "mockedRequestJsonDataMap") public Map mockedRequestJsonDataMap() throws IOException {