001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2025 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.camel; 011 012import ca.cdr.api.model.enm.TransactionLogBodyTypeEnum; 013import ca.cdr.api.model.enm.TransactionLogOutcomeEnum; 014import ca.cdr.api.model.enm.TransactionLogStepTypeEnum; 015import ca.cdr.api.model.json.TransactionLogStepJson; 016import ca.cdr.api.transactionlog.ITransactionLogCommonSettings; 017import org.apache.camel.Exchange; 018import org.apache.commons.lang3.tuple.Pair; 019 020import java.util.List; 021 022public interface ICamelProcessorTxLogHelper { 023 024 /** 025 * Requests to include message body in the transaction log step 026 * Default value is true 027 */ 028 String TX_LOG_PARAM_SHOW_BODY = "showMsgBody"; 029 030 /** 031 * If transaction logging was initiated (smile:txLogStart procedure, present before current procedure in 032 * route), adds a log step to the transaction log 033 * @param theExchange the camel exchange 034 * @param theProcedureName the log-producing procedure name 035 */ 036 void addStepIfTxLogActive(Exchange theExchange, String theProcedureName); 037 038 /** 039 * If transaction logging was initiated (smile:txLogStart procedure, present before current procedure in 040 * route), adds step from provider to the transaction log 041 * @param theExchange the camel exchange 042 * @param theStepsProvider the provider of the corresponding transaction log steps 043 */ 044 void addStepIfTxLogActive(Exchange theExchange, ITxLogStepsProvider theStepsProvider); 045 046 /** 047 * If transaction logging was initiated (smile:txLogStart procedure, present before current procedure in 048 * route), adds step from provider to the transaction log, adds the list of steps to the transaction log 049 * @param theExchange the camel exchange 050 * @param theLogSteps the log steps to be added to the transaction log 051 */ 052 void addStepIfTxLogActive(Exchange theExchange, List<TransactionLogStepJson> theLogSteps); 053 054 /** 055 * Builds a new transaction log step considering received exchange properties and parameters. 056 * @param theExchange the camel exchange 057 * @param theLogStepType the transaction log step type 058 * @param theBodyAndType A Pair containing the body and the body type or null 059 * @param theOutcome The desired step outcome 060 * @return the built transaction log step 061 */ 062 TransactionLogStepJson buildTxLogStep( 063 Exchange theExchange, 064 TransactionLogStepTypeEnum theLogStepType, 065 Pair<String, TransactionLogBodyTypeEnum> theBodyAndType, 066 TransactionLogOutcomeEnum theOutcome); 067 068 /** 069 * Builds a string containing the received procedure name, including the module id if present in the exchange 070 * @param theExchange the camel exchange 071 * @param theProcedureName the log-producing procedure name 072 * @return a string with the built executing procedure URI 073 */ 074 String getRequestUrl(Exchange theExchange, String theProcedureName); 075 076 /** 077 * Informs if 'showMsgBody' parameter is present 078 * @param theExchange the camel exchange 079 * @return boolean indicating if 'showMsgBody' parameter is present 080 */ 081 boolean isTxLogShowBody(Exchange theExchange); 082 083 /** 084 * informs if a transaction log is active for the route 085 * @param theExchange the camel exchange 086 * @return boolean indicating if transaction log is active for the route 087 */ 088 boolean isTxLogStarted(Exchange theExchange); 089 090 /** 091 * Requests transaction log initiation for the route 092 * @param theExchange the camel exchange 093 */ 094 void startTxLog(Exchange theExchange); 095 096 /** 097 * Commits the transaction log to configured writers 098 * @param theExchange the camel exchange 099 */ 100 void commitTxLog(Exchange theExchange); 101 102 /** 103 * Discards current transaction logging and marks logging not initiated for the route 104 * @param theExchange the camel exchange 105 */ 106 void clearTxLog(Exchange theExchange); 107 108 /** 109 * Returns the settings associated with this writer. Event sources can use this to optimize whether to 110 * include specific elements in their log entries. 111 */ 112 ITransactionLogCommonSettings getSettings(); 113}