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