Skip to content

Commit

Permalink
log ebics resonse
Browse files Browse the repository at this point in the history
  • Loading branch information
vladae36 committed Feb 13, 2024
1 parent 3a9140f commit 5528d2d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ __pycache__
*.mk
util/src/main/resources/version.txt
.gitconfig
*/spx/*
spx
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ RUN npm install -g npm@6.9.0
RUN npm install --global yarn@1.22.4
RUN yarn --cwd /app/frontend/ install
# RUN yarnpkg --cwd /app/frontend/ build
RUN yarnpkg global add serve
RUN yarnpkg global add serve@13.0.4
58 changes: 29 additions & 29 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/history": "^4.7.6",
"@types/jest": "^24.0.0",
"@types/node": "^12.0.0",
"@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"@types/redux": "^3.6.0",
"@types/redux-thunk": "^2.1.0",
"antd": "^4.2.4",
"craco": "^0.0.3",
"@ant-design/icons": "~4.2.1",
"@testing-library/jest-dom": "~4.2.4",
"@testing-library/react": "~9.3.2",
"@testing-library/user-event": "~7.1.2",
"@types/history": "~4.7.6",
"@types/jest": "~24.0.0",
"@types/node": "~12.0.0",
"@types/react": "~16.9.0",
"@types/react-dom": "~16.9.0",
"@types/react-redux": "~7.1.9",
"@types/react-router-dom": "~5.1.5",
"@types/redux": "~3.6.0",
"@types/redux-thunk": "~2.1.0",
"antd": "~4.2.4",
"craco": "~0.0.3",
"craco-less": "1.16",
"history": "^4.10.1",
"js-base64": "^2.5.2",
"lodash": "^4.17.19",
"map-keys-deep-lodash": "^1.2.2",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-json-tree": "^0.11.2",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"history": "~4.10.1",
"js-base64": "~2.5.2",
"lodash": "~4.17.19",
"map-keys-deep-lodash": "~1.2.2",
"prettier": "~2.0.5",
"react": "~16.13.1",
"react-dom": "~16.13.1",
"react-json-tree": "~0.11.2",
"react-redux": "~7.2.0",
"react-router-dom": "~5.2.0",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"redux-thunk-recursion-detect": "^1.1.4",
"redux": "~4.0.5",
"redux-thunk": "~2.3.0",
"redux-thunk-recursion-detect": "~1.1.4",
"typescript": "~3.7.2"
},
"scripts": {
Expand Down Expand Up @@ -60,6 +60,6 @@
]
},
"devDependencies": {
"eslint-config-airbnb-typescript-prettier": "^2.1.1"
"eslint-config-airbnb-typescript-prettier": "~2.1.1"
}
}
31 changes: 31 additions & 0 deletions nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import org.slf4j.LoggerFactory
import tech.libeufin.nexus.NexusError
import tech.libeufin.util.*
import java.util.*
import java.io.File
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

private val logger: Logger = LoggerFactory.getLogger("tech.libeufin.util")

Expand Down Expand Up @@ -66,6 +69,32 @@ class EbicsDownloadBankErrorResult(
val returnCode: EbicsReturnCode
) : EbicsDownloadResult()


fun writeResponseToFile(initResponseStr: String, transactionId: String) {
// Get base directory from environment variable TRACE_DIR
val baseDirectory = System.getenv("TRACE_DIR") ?: System.getProperty("user.dir")

// Check if directory "trace" exists, create it if not
val traceDirectory = File("$baseDirectory/trace")
if (!traceDirectory.exists()) {
traceDirectory.mkdirs()
}

// Get current date and time
val currentDateTime = LocalDateTime.now()
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")
val formattedDateTime = currentDateTime.format(formatter)

// Construct file name with transactionId and current date/time
val fileName = "${traceDirectory.absolutePath}/${transactionId}_$formattedDateTime.xml"

// Write response to file
val file = File(fileName)
file.writeText(initResponseStr)
println("Response written to file: $fileName")
}


/**
* Do an EBICS download transaction. This includes the initialization phase, transaction phase
* and receipt phase.
Expand Down Expand Up @@ -110,6 +139,8 @@ suspend fun doEbicsDownloadTransaction(
HttpStatusCode.InternalServerError,
"initial response must contain transaction ID"
)

writeResponseToFile(transactionID,initResponseStr)

val encryptionInfo = initResponse.dataEncryptionInfo
?: throw NexusError(HttpStatusCode.InternalServerError, "initial response did not contain encryption info")
Expand Down

0 comments on commit 5528d2d

Please sign in to comment.