Implemented setting current message type on DialogContext; logging job and message type
This commit is contained in:
parent
fba6c2a0d5
commit
6aa03bcad2
|
@ -17,8 +17,6 @@ import net.dankito.banking.fints.response.client.GetUserTanMethodsResponse
|
|||
import net.dankito.banking.fints.response.segments.*
|
||||
import net.dankito.banking.fints.tan.FlickerCodeDecoder
|
||||
import net.dankito.banking.fints.tan.TanImageDecoder
|
||||
import net.dankito.banking.fints.transactions.IAccountTransactionsParser
|
||||
import net.dankito.banking.fints.transactions.Mt940AccountTransactionsParser
|
||||
import net.dankito.banking.fints.util.TanMethodSelector
|
||||
import net.dankito.utils.multiplatform.log.LoggerFactory
|
||||
import net.dankito.utils.multiplatform.Date
|
||||
|
|
|
@ -2,9 +2,13 @@ package net.dankito.banking.fints.log
|
|||
|
||||
import net.dankito.banking.fints.model.AccountData
|
||||
import net.dankito.banking.fints.model.BankData
|
||||
import net.dankito.banking.fints.model.MessageType
|
||||
import net.dankito.banking.fints.model.JobContextType
|
||||
|
||||
|
||||
class MessageContext(
|
||||
val jobType: JobContextType,
|
||||
val dialogType: MessageType,
|
||||
val jobNumber: Int,
|
||||
val dialogNumber: Int,
|
||||
val messageNumber: Int,
|
||||
|
|
|
@ -64,15 +64,16 @@ open class MessageLogCollector {
|
|||
protected open fun createMessageTraceString(type: MessageLogEntryType, context: MessageContext): String {
|
||||
return "${twoDigits(context.jobNumber)}_${twoDigits(context.dialogNumber)}_${twoDigits(context.messageNumber)}_" +
|
||||
"${context.bank.bankCode}_${context.bank.customerId}" +
|
||||
"${ context.account?.let { "_${it.accountIdentifier}" } ?: "" } " +
|
||||
"${getTypeString(type)}:"
|
||||
"${ context.account?.let { "_${it.accountIdentifier}" } ?: "" }_" +
|
||||
"${context.jobType.name}_${context.dialogType.name} " +
|
||||
"${getMessageTypeString(type)}:"
|
||||
}
|
||||
|
||||
protected open fun twoDigits(number: Int): String {
|
||||
return StringHelper.format("%02d", number)
|
||||
}
|
||||
|
||||
protected open fun getTypeString(type: MessageLogEntryType): String {
|
||||
protected open fun getMessageTypeString(type: MessageLogEntryType): String {
|
||||
return when (type) {
|
||||
MessageLogEntryType.Sent -> "Sending message"
|
||||
MessageLogEntryType.Received -> "Received message"
|
||||
|
|
|
@ -60,7 +60,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
*/
|
||||
open fun createAnonymousDialogInitMessage(context: JobContext): MessageBuilderResult {
|
||||
|
||||
return createUnsignedMessageBuilderResult(context, listOf(
|
||||
return createUnsignedMessageBuilderResult(context, MessageType.AnonymousDialogInit, listOf(
|
||||
IdentifikationsSegment(generator.resetSegmentNumber(1), context),
|
||||
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), context)
|
||||
))
|
||||
|
@ -68,7 +68,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
open fun createAnonymousDialogEndMessage(context: JobContext): MessageBuilderResult {
|
||||
|
||||
return createUnsignedMessageBuilderResult(context, listOf(
|
||||
return createUnsignedMessageBuilderResult(context, MessageType.DialogEnd, listOf(
|
||||
Dialogende(generator.resetSegmentNumber(1), context.dialog)
|
||||
))
|
||||
}
|
||||
|
@ -134,12 +134,12 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
segments.add(Synchronisierung(generator.getNextSegmentNumber(), Synchronisierungsmodus.NeueKundensystemIdZurueckmelden))
|
||||
}
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.DialogInit, segments)
|
||||
}
|
||||
|
||||
open fun createSynchronizeCustomerSystemIdMessage(context: JobContext): MessageBuilderResult {
|
||||
|
||||
return createSignedMessageBuilderResult(context, listOf(
|
||||
return createSignedMessageBuilderResult(context, MessageType.SynchronizeCustomerSystemId, listOf(
|
||||
IdentifikationsSegment(generator.resetSegmentNumber(2), context),
|
||||
Verarbeitungsvorbereitung(generator.getNextSegmentNumber(), context),
|
||||
createTwoStepTanSegment(context, CustomerSegmentId.Identification),
|
||||
|
@ -149,7 +149,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
open fun createDialogEndMessage(context: JobContext): MessageBuilderResult {
|
||||
|
||||
return createSignedMessageBuilderResult(context, listOf(
|
||||
return createSignedMessageBuilderResult(context, MessageType.DialogEnd, listOf(
|
||||
Dialogende(generator.resetSegmentNumber(2), context.dialog)
|
||||
))
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(context, CustomerSegmentId.AccountTransactionsMt940, segments)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.GetTransactions, segments)
|
||||
}
|
||||
|
||||
protected open fun determineIsSettingMaxCountEntriesAllowed(bank: BankData, segmentId: ISegmentId, supportedJobVersions: List<Int>): Boolean {
|
||||
|
@ -203,7 +203,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(context, CustomerSegmentId.CreditCardTransactions, segments)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.GetCreditCardTransactions, segments)
|
||||
}
|
||||
|
||||
open fun supportsGetTransactions(account: AccountData): Boolean {
|
||||
|
@ -232,7 +232,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(context, CustomerSegmentId.Balance, segments)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.GetBalance, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -259,7 +259,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
generator.resetSegmentNumber(2), tanMediaKind, tanMediumClass)
|
||||
)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.GetTanMedia, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -277,7 +277,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
context.bank, newActiveTanMedium, tan, atc)
|
||||
)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.ChangeTanMedium, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -292,7 +292,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
tanResponse.jobHashValue, tanResponse.jobReference, false, null, tanResponse.tanMediaIdentifier)
|
||||
)
|
||||
|
||||
return createSignedMessageBuilderResult(context, createSignedMessage(context, enteredTan, segments), segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.Tan, createSignedMessage(context, enteredTan, segments), segments)
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,7 +308,7 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
addTanSegmentIfRequired(context, segmentId, segments)
|
||||
|
||||
return createSignedMessageBuilderResult(context, segments)
|
||||
return createSignedMessageBuilderResult(context, MessageType.TransferMoney, segments)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -359,25 +359,25 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
|||
|
||||
open fun rebuildMessage(context: JobContext, message: MessageBuilderResult): MessageBuilderResult {
|
||||
|
||||
return createSignedMessageBuilderResult(context, message.messageBodySegments)
|
||||
return createSignedMessageBuilderResult(context, context.dialog.messageType, message.messageBodySegments)
|
||||
}
|
||||
|
||||
protected open fun createSignedMessageBuilderResult(context: JobContext, segments: List<Segment>): MessageBuilderResult {
|
||||
return createSignedMessageBuilderResult(context, createSignedMessage(context, segments), segments)
|
||||
protected open fun createSignedMessageBuilderResult(context: JobContext, type: MessageType, segments: List<Segment>): MessageBuilderResult {
|
||||
return createSignedMessageBuilderResult(context, type, createSignedMessage(context, segments), segments)
|
||||
}
|
||||
|
||||
protected open fun createSignedMessageBuilderResult(context: JobContext, createdMessage: String, segments: List<Segment>): MessageBuilderResult {
|
||||
return createMessageBuilderResult(context, createdMessage, segments)
|
||||
protected open fun createSignedMessageBuilderResult(context: JobContext, type: MessageType, createdMessage: String, segments: List<Segment>): MessageBuilderResult {
|
||||
return createMessageBuilderResult(context, type, createdMessage, segments)
|
||||
}
|
||||
|
||||
protected open fun createUnsignedMessageBuilderResult(context: JobContext, segments: List<Segment>): MessageBuilderResult {
|
||||
return createMessageBuilderResult(context, createMessage(context, segments), segments)
|
||||
protected open fun createUnsignedMessageBuilderResult(context: JobContext, type: MessageType, segments: List<Segment>): MessageBuilderResult {
|
||||
return createMessageBuilderResult(context, type, createMessage(context, segments), segments)
|
||||
}
|
||||
|
||||
protected open fun createMessageBuilderResult(context: JobContext, createdMessage: String, segments: List<Segment>): MessageBuilderResult {
|
||||
protected open fun createMessageBuilderResult(context: JobContext, type: MessageType, createdMessage: String, segments: List<Segment>): MessageBuilderResult {
|
||||
val message = MessageBuilderResult(createdMessage, segments)
|
||||
|
||||
context.dialog.setNextMessage(message)
|
||||
context.dialog.setNextMessage(type, message)
|
||||
|
||||
return message
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.dankito.banking.fints.model
|
||||
|
||||
import net.dankito.banking.fints.messages.MessageBuilderResult
|
||||
import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.VersionDesSicherheitsverfahrens
|
||||
import net.dankito.banking.fints.response.BankResponse
|
||||
|
||||
|
||||
|
@ -17,6 +16,10 @@ open class DialogContext(
|
|||
const val InitialMessageNumber = 0
|
||||
}
|
||||
|
||||
|
||||
open var messageType: MessageType = MessageType.AnonymousDialogInit
|
||||
protected set
|
||||
|
||||
open var currentMessage: MessageBuilderResult? = null
|
||||
protected set
|
||||
|
||||
|
@ -37,7 +40,9 @@ open class DialogContext(
|
|||
messageNumber++
|
||||
}
|
||||
|
||||
open fun setNextMessage(message: MessageBuilderResult) {
|
||||
open fun setNextMessage(type: MessageType, message: MessageBuilderResult) {
|
||||
this.messageType = type
|
||||
|
||||
this.previousMessageInDialog = this.currentMessage
|
||||
|
||||
this.currentMessage = message
|
||||
|
|
|
@ -79,7 +79,7 @@ open class JobContext(
|
|||
}
|
||||
|
||||
protected open fun createMessageContext(): MessageContext {
|
||||
return MessageContext(jobNumber, dialog.messageNumber, bank, account)
|
||||
return MessageContext(type, dialog.messageType, jobNumber, dialogNumber, dialog.messageNumber, bank, account)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package net.dankito.banking.fints.model
|
||||
|
||||
|
||||
enum class MessageType {
|
||||
|
||||
AnonymousDialogInit,
|
||||
|
||||
DialogInit,
|
||||
|
||||
DialogEnd,
|
||||
|
||||
GetTanMedia,
|
||||
|
||||
ChangeTanMedium,
|
||||
|
||||
SynchronizeCustomerSystemId,
|
||||
|
||||
Tan,
|
||||
|
||||
AddAccount,
|
||||
|
||||
GetBalance,
|
||||
|
||||
GetTransactions,
|
||||
|
||||
GetCreditCardTransactions,
|
||||
|
||||
TransferMoney
|
||||
|
||||
}
|
Loading…
Reference in New Issue