From a566c7de26d01f284b7e80be0e5dc12b799f32de Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 13:58:48 +0530 Subject: [PATCH 001/100] feat: add gradle files and compose file code --- edc-chat-app-backend/build.gradle | 67 +++++++++++++++++++ edc-chat-app-backend/compose.yaml | 9 +++ edc-chat-app-backend/gradle.properties | 12 ++++ edc-chat-app-backend/settings.gradle | 1 + .../src/main/resources/application.yaml | 17 ++++- 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 edc-chat-app-backend/build.gradle create mode 100644 edc-chat-app-backend/compose.yaml create mode 100644 edc-chat-app-backend/gradle.properties create mode 100644 edc-chat-app-backend/settings.gradle diff --git a/edc-chat-app-backend/build.gradle b/edc-chat-app-backend/build.gradle new file mode 100644 index 0000000..d280a64 --- /dev/null +++ b/edc-chat-app-backend/build.gradle @@ -0,0 +1,67 @@ +plugins { + id 'java' + id 'war' + id 'org.springframework.boot' version '3.3.5' + id 'io.spring.dependency-management' version '1.1.6' + id 'org.hibernate.orm' version '6.5.3.Final' + id 'org.graalvm.buildtools.native' version '0.10.3' +} + +group = 'com.smartsense' +version = '0.0.1-SNAPSHOT' + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenCentral() +} + +ext { + set('springCloudVersion', "2023.0.3") +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-actuator' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-websocket' + implementation 'org.liquibase:liquibase-core' + implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + compileOnly 'org.projectlombok:lombok' + developmentOnly 'org.springframework.boot:spring-boot-devtools' + developmentOnly 'org.springframework.boot:spring-boot-docker-compose' + runtimeOnly 'org.postgresql:postgresql' + annotationProcessor 'org.projectlombok:lombok' + providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.boot:spring-boot-testcontainers' + testImplementation 'org.testcontainers:junit-jupiter' + testImplementation 'org.testcontainers:postgresql' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +dependencyManagement { + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } +} + +hibernate { + enhancement { + enableAssociationManagement = true + } +} + +tasks.named('test') { + useJUnitPlatform() +} diff --git a/edc-chat-app-backend/compose.yaml b/edc-chat-app-backend/compose.yaml new file mode 100644 index 0000000..7c8044f --- /dev/null +++ b/edc-chat-app-backend/compose.yaml @@ -0,0 +1,9 @@ +services: + postgres: + image: 'postgres:latest' + environment: + - 'POSTGRES_DB=mydatabase' + - 'POSTGRES_PASSWORD=secret' + - 'POSTGRES_USER=myuser' + ports: + - '5432' diff --git a/edc-chat-app-backend/gradle.properties b/edc-chat-app-backend/gradle.properties new file mode 100644 index 0000000..6b3af26 --- /dev/null +++ b/edc-chat-app-backend/gradle.properties @@ -0,0 +1,12 @@ +springBootVersion=3.3.5 +springDependencyManagementVersion=1.1.6 +springCloudVersion=2023.0.3 +openApiVersion=2.5.0 +commonsDaoVersion=1.0.2 +jacksonVersion=2.17.1 +#Test property +jacocoVersion=0.8.12 +testContainerVersion=1.19.8 +keycloakTestContainerVersion=3.3.1 +keycloakAdminClientVersion=24.0.4 +liquibaseVersion=4.28.0 diff --git a/edc-chat-app-backend/settings.gradle b/edc-chat-app-backend/settings.gradle new file mode 100644 index 0000000..0972b64 --- /dev/null +++ b/edc-chat-app-backend/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'edc-chat-app-backend' diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index d6bf036..998f85e 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -3,7 +3,6 @@ chat: authCode: password assetId: edc-chat-app - spring: application: name: EDC based chat application @@ -11,8 +10,9 @@ spring: virtual: enabled: true jpa: + database-platform: org.hibernate.dialect.PostgreSQLDialect hibernate: - ddl-auto: none + ddl-auto: update properties: hibernate.default_schema: public show-sql: true @@ -24,3 +24,16 @@ spring: liquibase: change-log: classpath:db/changelog/changelog-master.yaml +springdoc: + swagger-ui: + disable-swagger-default-url: true + path: /ui/swagger-ui + show-common-extensions: true + csrf: + enabled: true +# api-docs: +# path: /docs/api-docs + +logging: + level: + root: INFO From a2cbf0256c06ebecf30084b397ee33fb050b665f Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 13:59:30 +0530 Subject: [PATCH 002/100] feat: add gradle files --- .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43453 bytes .../gradle/wrapper/gradle-wrapper.properties | 7 + edc-chat-app-backend/gradlew | 249 ++++++++++++++++++ edc-chat-app-backend/gradlew.bat | 92 +++++++ 4 files changed, 348 insertions(+) create mode 100644 edc-chat-app-backend/gradle/wrapper/gradle-wrapper.jar create mode 100644 edc-chat-app-backend/gradle/wrapper/gradle-wrapper.properties create mode 100755 edc-chat-app-backend/gradlew create mode 100644 edc-chat-app-backend/gradlew.bat diff --git a/edc-chat-app-backend/gradle/wrapper/gradle-wrapper.jar b/edc-chat-app-backend/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..e6441136f3d4ba8a0da8d277868979cfbc8ad796 GIT binary patch literal 43453 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia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b45;{AKM%v99}{{FfC zz709%u0mC=1KXTo(=TqmZQ;c?$M3z(!xah>aywrj40sc2y3rKFw4jCq+Y+u=CH@_V zxz|qeTwa>+<|H%8Dz5u>ZI5MmjTFwXS-Fv!TDd*`>3{krWoNVx$<133`(ftS?ZPyY z&4@ah^3^i`vL$BZa>O|Nt?ucewzsF)0zX3qmM^|waXr=T0pfIb0*$AwU=?Ipl|1Y; z*Pk6{C-p4MY;j@IJ|DW>QHZQJcp;Z~?8(Q+Kk3^0qJ}SCk^*n4W zu9ZFwLHUx-$6xvaQ)SUQcYd6fF8&x)V`1bIuX@>{mE$b|Yd(qomn3;bPwnDUc0F=; zh*6_((%bqAYQWQ~odER?h>1mkL4kpb3s7`0m@rDKGU*oyF)$j~Ffd4fXV$?`f~rHf zB%Y)@5SXZvfwm10RY5X?TEo)PK_`L6qgBp=#>fO49$D zDq8Ozj0q6213tV5Qq=;fZ0$|KroY{Dz=l@lU^J)?Ko@ti20TRplXzphBi>XGx4bou zEWrkNjz0t5j!_ke{g5I#PUlEU$Km8g8TE|XK=MkU@PT4T><2OVamoK;wJ}3X0L$vX zgd7gNa359*nc)R-0!`2X@FOTB`+oETOPc=ubp5R)VQgY+5BTZZJ2?9QwnO=dnulIUF3gFn;BODC2)65)HeVd%t86sL7Rv^Y+nbn+&l z6BAJY(ETvwI)Ts$aiE8rht4KD*qNyE{8{x6R|%akbTBzw;2+6Echkt+W+`u^XX z_z&x%n '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/edc-chat-app-backend/gradlew.bat b/edc-chat-app-backend/gradlew.bat new file mode 100644 index 0000000..7101f8e --- /dev/null +++ b/edc-chat-app-backend/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega From 9a001cd92acb814b6fd23286c772ce5361abd926 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 15:17:21 +0530 Subject: [PATCH 003/100] feat: create query catalog logic --- .../edc/operation/QueryCatalogService.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java index b7d4b2e..9b4c7fe 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java @@ -1,4 +1,49 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.edc.client.EDCConnectorClient; +import com.smartsense.chat.edc.settings.EDCConfigurations; +import com.smartsense.chat.service.BusinessPartnerService; +import jakarta.validation.constraints.NotNull; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.net.URI; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j public class QueryCatalogService { + + private final EDCConfigurations configurations; + private final BusinessPartnerService partnerService; + private final EDCConnectorClient edc; + + public void QueryCatalog(@NotNull String bpn) { + log.info("Creating Query Catalog process started..."); + // TODO fetching edcUrl by bpn + String edcUrl = partnerService.getBusinessPartnerByBpn(bpn); + Map request = prepareQueryCatalog(edcUrl, bpn, configurations.assetId()); + Map response = edc.queryCatalog(URI.create(edcUrl), request, configurations.authCode()); + log.info("Response of catalog creation: {}", response); + + // TODO handle and process response + } + + private Map prepareQueryCatalog(String counterPartyAddress, String counterPartyId, String assetId) { + Map queryCatalog = new HashMap<>(); + queryCatalog.put("@context", Map.of("edc", "https://w3id.org/edc/v0.0.1/ns/", "odrl", "http://www.w3.org/ns/odrl/2/", "dct", "https://purl.org/dc/terms/")); + queryCatalog.put("@type", "edc:CatalogRequest"); + queryCatalog.put("counterPartyAddress", counterPartyAddress); + queryCatalog.put("counterPartyId", counterPartyId); + queryCatalog.put("protocol", "dataspace-protocol-http"); + queryCatalog.put("querySpec", Map.of("filterExpression", List.of(Map.of("operandLeft", "https://w3id.org/edc/v0.0.1/ns/id", + "operator", "=", + "operandRight", assetId)))); + log.info("Create Query Catalog request looks like: {}", queryCatalog); + return queryCatalog; + } } From 049070d3fe16e72ed64c39dae5c2ce74bad207c2 Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 15:25:54 +0530 Subject: [PATCH 004/100] feat: handle edc operations --- edc-chat-app-backend/build.gradle | 1 + .../repository/BusinessPartnerRepository.java | 2 + .../com/smartsense/chat/edc/EDCService.java | 35 ++++++----- .../operation/AgreementFetcherService.java | 42 +++++++++++++ .../operation/ContractNegotiationService.java | 60 +++++++++++++++++++ .../operation/PublicUrlHandlerService.java | 9 ++- .../edc/operation/QueryCatalogService.java | 26 ++++---- .../edc/operation/TransferProcessService.java | 10 ++-- .../chat/edc/settings/EDCConfigurations.java | 9 ++- .../chat/service/BusinessPartnerService.java | 9 +++ 10 files changed, 165 insertions(+), 38 deletions(-) diff --git a/edc-chat-app-backend/build.gradle b/edc-chat-app-backend/build.gradle index d280a64..2222b7c 100644 --- a/edc-chat-app-backend/build.gradle +++ b/edc-chat-app-backend/build.gradle @@ -43,6 +43,7 @@ dependencies { runtimeOnly 'org.postgresql:postgresql' annotationProcessor 'org.projectlombok:lombok' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' + implementation 'org.json:json:20240303' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-testcontainers' testImplementation 'org.testcontainers:junit-jupiter' diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java index fed520e..eade0d2 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java @@ -8,4 +8,6 @@ @Repository public interface BusinessPartnerRepository extends JpaRepository { + + BusinessPartner findByBpn(String bpn); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java index fd24cc6..fbe93f0 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java @@ -1,36 +1,41 @@ package com.smartsense.chat.edc; +import com.smartsense.chat.edc.operation.AgreementFetcherService; +import com.smartsense.chat.edc.operation.ContractNegotiationService; import com.smartsense.chat.edc.operation.PublicUrlHandlerService; +import com.smartsense.chat.edc.operation.QueryCatalogService; import com.smartsense.chat.edc.operation.TransferProcessService; +import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.ChatMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.net.URI; - @Service @RequiredArgsConstructor @Slf4j public class EDCService { - + private final BusinessPartnerService partnerService; + private final QueryCatalogService queryCatalogService; + private final ContractNegotiationService contractNegotiationService; + private final AgreementFetcherService agreementService; private final TransferProcessService transferProcessService; private final PublicUrlHandlerService publicUrlHandlerService; - public void initProcess(URI edcUri, ChatMessage chatMessage) { - // TODO query catalog - //TODO start negotiation - //TODO get agreement - - - String agreementId = null; - + public void initProcess(ChatMessage chatMessage) { + String receiverBpnl = chatMessage.receiverBpn(); + String receiverDspUrl = partnerService.getBusinessPartnerByBpn(receiverBpnl); + // Query the catalog for chat asset + String offerId = queryCatalogService.queryCatalog(receiverDspUrl, receiverBpnl); + // Initiate the contract negotiation + String negotiationId = contractNegotiationService.initNegotiation(receiverDspUrl, receiverBpnl, offerId); + // Get agreement Id based on the negotiationId + String agreementId = agreementService.getAgreement(negotiationId); // Initiate the transfer process - String transferProcessId = transferProcessService.initiateTransfer(edcUri, agreementId); - - // sent the message to public url - publicUrlHandlerService.getAuthCodeAndPublicUrl(edcUri, transferProcessId, chatMessage); + String transferProcessId = transferProcessService.initiateTransfer(agreementId); + // Sent the message to public url + publicUrlHandlerService.getAuthCodeAndPublicUrl(transferProcessId, chatMessage); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java index d1ba8c5..6ccbf05 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java @@ -1,4 +1,46 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.edc.client.EDCConnectorClient; +import com.smartsense.chat.edc.settings.EDCConfigurations; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j public class AgreementFetcherService { + + private final EDCConnectorClient edc; + private final EDCConfigurations edcConfigurations; + + public String getAgreement(String negotiationId) { + try { + int count = 1; + Map agreementResponse = null; + String agreementId = null; + do { + Thread.sleep(5_000); + log.info("Fetching agreement for negotiationId {}", negotiationId); + agreementResponse = edc.getAgreement(edcConfigurations.edcUri(), negotiationId, edcConfigurations.authCode()); + if (!agreementResponse.get("state").toString().equals("FINALIZED")) { + count++; + continue; + } + agreementId = agreementResponse.get("contractAgreementId").toString(); + log.info("Negotiation {} is successfully done and agreementId is {}", negotiationId, agreementId); + log.info("Fetching agreement for negotiationId {} is completed successfully.", negotiationId); + } while ((!CollectionUtils.isEmpty(agreementResponse) && agreementResponse.get("state").equals("FINALIZED")) || + StringUtils.hasText(agreementId) || + count == 3); + return agreementId; + } catch (Exception ex) { + log.error("Error occurred while getting agreement information for negotiationId {}", negotiationId, ex); + return null; + } + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java index 6737332..c50ed5e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java @@ -1,4 +1,64 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.edc.client.EDCConnectorClient; +import com.smartsense.chat.edc.settings.EDCConfigurations; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j public class ContractNegotiationService { + private final EDCConnectorClient edc; + private final EDCConfigurations edcConfigurations; + + private static List prepareNegotiationContext() { + List context = new ArrayList<>(); + context.add("https://w3id.org/tractusx/policy/v1.0.0"); + context.add("http://www.w3.org/ns/odrl.jsonld"); + context.add(Map.of("edc", "https://w3id.org/edc/v0.0.1/ns/")); + return context; + } + + public String initNegotiation(String receiverDspUrl, String receiverBpnL, String offerId) { + try { + log.info("Starting negotiation process with bpnl {}, dspUrl {} and offerId {}", receiverBpnL, receiverDspUrl, offerId); + Map negotiationRequest = prepareNegotiationRequest(receiverDspUrl, receiverBpnL, offerId); + Map negotiationResponse = edc.initNegotiation(edcConfigurations.edcUri(), negotiationRequest, edcConfigurations.authCode()); + String negotiationId = negotiationResponse.get("@id").toString(); + log.info("Contract negotiation process done for offerId {} with negotiationId {}", offerId, negotiationId); + return negotiationId; + } catch (Exception ex) { + log.error("Error occurred while negotiating the contract offer {} with dspUrl {} and bpnl {}.", offerId, receiverDspUrl, receiverBpnL); + return null; + } + + } + + private Map prepareNegotiationRequest(String receiverDspUrl, String receiverBpnL, String offerId) { + Map negotiationRequest = new HashMap<>(); + negotiationRequest.put("@context", prepareNegotiationContext()); + negotiationRequest.put("@type", "ContractRequest"); + negotiationRequest.put("edc:counterPartyAddress", receiverDspUrl); + negotiationRequest.put("edc:protocol", "ContractRequest"); + negotiationRequest.put("edc:counterPartyId", receiverBpnL); + negotiationRequest.put("edc:policy", prepareNegotiationPolicy(receiverBpnL, offerId)); + return negotiationRequest; + } + + private Map prepareNegotiationPolicy(String receiverBpnL, String offerId) { + Map negotiationPolicy = new HashMap<>(); + negotiationPolicy.put("@id", offerId); + negotiationPolicy.put("@type", "Offer"); + negotiationPolicy.put("permission", List.of(Map.of("action", "use"))); + negotiationPolicy.put("target", edcConfigurations.assetId()); + negotiationPolicy.put("assigner", receiverBpnL); + return negotiationPolicy; + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java index c120ebb..2619ae4 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java @@ -2,10 +2,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.edc.client.EDCConnectorClient; +import com.smartsense.chat.edc.settings.EDCConfigurations; import com.smartsense.chat.utils.request.ChatMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.net.URI; @@ -17,13 +17,12 @@ public class PublicUrlHandlerService { private final EDCConnectorClient edc; private final ObjectMapper mapper; - @Value("${edc.auth.code:password}") - private String authCode; + private final EDCConfigurations edcConfigurations; - public void getAuthCodeAndPublicUrl(URI edcUri, String transferProcessId, ChatMessage message) { + public void getAuthCodeAndPublicUrl(String transferProcessId, ChatMessage message) { try { log.info("Initiate to get auth code based on transfer process id " + transferProcessId); - Map response = edc.getAuthCodeAndPublicUrl(edcUri, transferProcessId, authCode); + Map response = edc.getAuthCodeAndPublicUrl(edcConfigurations.edcUri(), transferProcessId, edcConfigurations.authCode()); log.info("Auth code and public url response -> {}", response); // Retrieve public path and authorization code diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java index 9b4c7fe..f47693f 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java @@ -3,12 +3,11 @@ import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.EDCConfigurations; import com.smartsense.chat.service.BusinessPartnerService; -import jakarta.validation.constraints.NotNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.json.JSONObject; import org.springframework.stereotype.Service; -import java.net.URI; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -22,15 +21,20 @@ public class QueryCatalogService { private final BusinessPartnerService partnerService; private final EDCConnectorClient edc; - public void QueryCatalog(@NotNull String bpn) { - log.info("Creating Query Catalog process started..."); - // TODO fetching edcUrl by bpn - String edcUrl = partnerService.getBusinessPartnerByBpn(bpn); - Map request = prepareQueryCatalog(edcUrl, bpn, configurations.assetId()); - Map response = edc.queryCatalog(URI.create(edcUrl), request, configurations.authCode()); - log.info("Response of catalog creation: {}", response); - - // TODO handle and process response + public String queryCatalog(String receiverDspUrl, String receiverBpnl) { + try { + log.info("Creating Query Catalog process started..."); + Map response = edc.queryCatalog(configurations.edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, configurations.assetId()), configurations.authCode()); + JSONObject catalogResponse = new JSONObject(response); + String offerId = catalogResponse.getJSONObject("dcat:dataset") + .getJSONObject("odrl:hasPolicy") + .getString("@id"); + log.info("Received offerId {}.", offerId); + return offerId; + } catch (Exception ex) { + log.error("Error occurred while fetching the catalog for receiverDsp {} and Bpnl {}", receiverDspUrl, receiverBpnl); + return null; + } } private Map prepareQueryCatalog(String counterPartyAddress, String counterPartyId, String assetId) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java index 9821a88..10266ec 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java @@ -1,12 +1,11 @@ package com.smartsense.chat.edc.operation; import com.smartsense.chat.edc.client.EDCConnectorClient; +import com.smartsense.chat.edc.settings.EDCConfigurations; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import java.net.URI; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,17 +16,16 @@ public class TransferProcessService { private final EDCConnectorClient edc; - @Value("${edc.auth.code:password}") - private String authCode; + private final EDCConfigurations edcConfigurations; - public String initiateTransfer(URI edcUri, String agreementId) { + public String initiateTransfer(String agreementId) { try { log.info("Initiate transfer process for agreement Id {}", agreementId); // prepare transfer request Map transferRequest = prepareTransferRequest(agreementId); // initiate the transfer process - List> transferResponse = edc.initTransferProcess(edcUri, transferRequest, authCode); + List> transferResponse = edc.initTransferProcess(edcConfigurations.edcUri(), transferRequest, edcConfigurations.authCode()); log.info("Received transfer response -> {}", transferResponse); // get the transfer process id from response diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java index 6eec751..33c136e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java @@ -2,7 +2,14 @@ import org.springframework.boot.context.properties.ConfigurationProperties; +import java.net.URI; + @ConfigurationProperties("chat.edc") -public record EDCConfigurations(String authCode, +public record EDCConfigurations(String edcUrl, + String authCode, String assetId) { + + public URI edcUri() { + return URI.create(edcUrl); + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 7daaf1d..19b986d 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -3,11 +3,14 @@ import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.dao.repository.BusinessPartnerRepository; import com.smartsense.chat.utils.request.BusinessPartnerRequest; +import com.smartsense.chat.utils.validate.Validate; import com.smartsense.chat.web.BusinessPartnerResource; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.Objects; + @Service @Slf4j @RequiredArgsConstructor @@ -26,4 +29,10 @@ public BusinessPartnerResource createBusinessPartner(BusinessPartnerRequest requ businessPartnerRepository.save(businessPartner); return null; } + + public String getBusinessPartnerByBpn(String bpn) { + BusinessPartner partner = businessPartnerRepository.findByBpn(bpn); + Validate.isTrue(Objects.isNull(partner)).launch("No Business partner found with bpn: " + bpn); + return partner.getEdcUrl(); + } } From b437da2ef0dfff8256c974c7780a26a724f4fd59 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 15:36:30 +0530 Subject: [PATCH 005/100] feat: add endpoints and swagger config --- edc-chat-app-backend/build.gradle | 3 + .../smartsense/chat/EdcChatApplication.java | 9 +- .../chat/dao/entity/BusinessPartner.java | 24 ++- .../repository/BusinessPartnerRepository.java | 6 +- .../chat/service/BusinessPartnerService.java | 35 ++++- .../smartsense/chat/service/ServiceUtil.java | 55 +++++++ .../chat/utils/constant/ContField.java | 16 ++ .../exception/GlobalExceptionHandler.java | 143 ++++++++++++++++++ .../chat/utils/openapi/LandingPageConfig.java | 28 ++++ .../chat/utils/openapi/OpenApiConfig.java | 36 +++++ .../chat/utils/response/BpnResponse.java | 6 + .../chat/web/BusinessPartnerResource.java | 22 ++- 12 files changed, 364 insertions(+), 19 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ServiceUtil.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/constant/ContField.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/OpenApiConfig.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java diff --git a/edc-chat-app-backend/build.gradle b/edc-chat-app-backend/build.gradle index 2222b7c..b51d92f 100644 --- a/edc-chat-app-backend/build.gradle +++ b/edc-chat-app-backend/build.gradle @@ -37,6 +37,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-websocket' implementation 'org.liquibase:liquibase-core' implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + implementation 'com.smartsensesolutions:commons-dao:1.0.2' + implementation 'org.springdoc:springdoc-openapi-starter-common:2.6.0' + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' developmentOnly 'org.springframework.boot:spring-boot-docker-compose' diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/EdcChatApplication.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/EdcChatApplication.java index ac41e3c..74bc4cb 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/EdcChatApplication.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/EdcChatApplication.java @@ -3,16 +3,15 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.openfeign.EnableFeignClients; -@SpringBootApplication +@SpringBootApplication(scanBasePackages = { "com.smartsense", "com.smartsensesolutions" }) @ConfigurationPropertiesScan @EnableFeignClients public class EdcChatApplication { - public static void main(String[] args) { - SpringApplication.run(EdcChatApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(EdcChatApplication.class, args); + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java index a1a5d09..e79d9c8 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java @@ -1,8 +1,22 @@ package com.smartsense.chat.dao.entity; import com.fasterxml.jackson.annotation.JsonIgnore; -import jakarta.persistence.*; -import lombok.*; +import com.smartsensesolutions.commons.dao.base.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import java.util.Date; import java.util.UUID; @@ -14,7 +28,7 @@ @AllArgsConstructor @Entity @Table(name = "raw_data_master") -public class BusinessPartner { +public class BusinessPartner implements BaseEntity { @Id @GeneratedValue(strategy = GenerationType.UUID) @@ -41,11 +55,11 @@ public class BusinessPartner { @PrePersist void createdAt() { - this.createdAt = new Date(); + createdAt = new Date(); } @PreUpdate void updatedAt() { - this.updatedAt = new Date(); + updatedAt = new Date(); } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java index eade0d2..268190b 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java @@ -1,13 +1,15 @@ package com.smartsense.chat.dao.repository; import com.smartsense.chat.dao.entity.BusinessPartner; -import org.springframework.data.jpa.repository.JpaRepository; +import com.smartsensesolutions.commons.dao.base.BaseRepository; import org.springframework.stereotype.Repository; import java.util.UUID; @Repository -public interface BusinessPartnerRepository extends JpaRepository { +public interface BusinessPartnerRepository extends BaseRepository { + + BusinessPartner findByName(String name); BusinessPartner findByBpn(String bpn); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 19b986d..95be27e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -1,33 +1,58 @@ package com.smartsense.chat.service; +import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.dao.repository.BusinessPartnerRepository; import com.smartsense.chat.utils.request.BusinessPartnerRequest; +import com.smartsense.chat.utils.response.BpnResponse; +import com.smartsense.chat.utils.response.BusinessPartnerResponse; import com.smartsense.chat.utils.validate.Validate; -import com.smartsense.chat.web.BusinessPartnerResource; +import com.smartsensesolutions.commons.dao.base.BaseRepository; +import com.smartsensesolutions.commons.dao.base.BaseService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; @Service @Slf4j @RequiredArgsConstructor -public class BusinessPartnerService { +public class BusinessPartnerService extends BaseService { private final BusinessPartnerRepository businessPartnerRepository; + private final ObjectMapper mapper; - public BusinessPartnerResource createBusinessPartner(BusinessPartnerRequest request) { + public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest request) { log.info("Creating BusinessPartner. name: {}", request.name()); BusinessPartner businessPartner = BusinessPartner.builder() .name(request.name()) .edcUrl(request.edcUrl()) .bpn(request.bpn()) .build(); - businessPartnerRepository.save(businessPartner); - return null; + return mapper.convertValue(businessPartnerRepository.save(businessPartner), BusinessPartnerResponse.class); + } + + public BpnResponse getBusinessPartner(String name) { + BusinessPartner businessPartner = businessPartnerRepository.findByName(name); + Validate.isTrue(Objects.isNull(businessPartner)).launch("No Business partner found with name: " + name); + return new BpnResponse(Map.of(businessPartner.getName(), businessPartner.getBpn())); + } + + public BpnResponse getAllBusinessPartners() { + List businessPartnerList = businessPartnerRepository.findAll(); + Map bpnMap = businessPartnerList.stream().collect(Collectors.toMap(BusinessPartner::getName, BusinessPartner::getBpn, (k, v) -> v)); + return new BpnResponse(bpnMap); + } + + @Override + protected BaseRepository getRepository() { + return businessPartnerRepository; } public String getBusinessPartnerByBpn(String bpn) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ServiceUtil.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ServiceUtil.java new file mode 100644 index 0000000..3f7a4ac --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ServiceUtil.java @@ -0,0 +1,55 @@ +package com.smartsense.chat.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.i18n.LocaleContextHolder; + +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.function.Function; + +public interface ServiceUtil { + ObjectMapper getObjectMapper(); + + MessageSource getMessageSource(); + + default O toType(I data, Class c) { + return getObjectMapper().convertValue(data, c); + } + + default List toListOf(Collection data, Class c) { + return getObjectMapper().convertValue(data, TypeFactory.defaultInstance().constructParametricType(List.class, c)); + } + + default List toListOf(Collection data, Function converter) { + return data.stream().map(converter).toList(); + } + + default String convertToString(I data) { + try { + return getObjectMapper().writeValueAsString(data); + } catch (JsonProcessingException e) { + return null; + } + } + + + default String resolveMessage(String key, String... arg) { + try { + return getMessageSource().getMessage(key, arg, LocaleContextHolder.getLocale()); + } catch (Exception e) { + return key; + } + } + + default void delete(File... files) { + for (File file : files) { + if (file.exists()) { + file.delete(); + } + } + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/constant/ContField.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/constant/ContField.java new file mode 100644 index 0000000..6b058fe --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/constant/ContField.java @@ -0,0 +1,16 @@ +package com.smartsense.chat.utils.constant; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class ContField { + public static final String USER_ID = "userId"; + public static final String EMAIL = "email"; + public static final String CLAIMS = "claims"; + public static final String CLAIM_RESOURCE_ACCESS = "resource_access"; + public static final String CLAIM_ROLES = "roles"; + public static final String TIMESTAMP = "timestamp"; + public static final String ERRORS = "errors"; + public static final String PROPERTY = "property"; + public static final String ARGUMENT = "argument"; +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..6ace1d7 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java @@ -0,0 +1,143 @@ +package com.smartsense.chat.utils.exception; + +import com.smartsense.chat.utils.constant.ContField; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.hibernate.exception.ConstraintViolationException; +import org.springframework.data.mapping.PropertyReferenceException; +import org.springframework.http.HttpStatus; +import org.springframework.http.ProblemDetail; +import org.springframework.validation.FieldError; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Global exception handler + * + * @author Sunil Kanzar + * @since 14th feb 2024 + */ +@ControllerAdvice +@Slf4j +@AllArgsConstructor +public class GlobalExceptionHandler { + + /** + * Handle validation problem detail. + * + * @param e the e + * @return the problem detail + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + ProblemDetail handleValidation(MethodArgumentNotValidException e) { + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(e)); + problemDetail.setTitle("Invalid data provided"); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + problemDetail.setProperty(ContField.ERRORS, handleValidationError(e.getFieldErrors())); + return problemDetail; + } + + /** + * Handle validation problem detail. + * + * @param exception the exception + * @return the problem detail + */ + @ExceptionHandler(ConstraintViolationException.class) + ProblemDetail handleValidation(ConstraintViolationException exception) { + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(exception)); + problemDetail.setTitle("Invalid data provided"); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + problemDetail.setProperty(ContField.ERRORS, exception.getConstraintName()); + return problemDetail; + } + + /** + * Handle bad data exception problem detail. + * + * @param e the e + * @return the problem detail + */ + @ExceptionHandler(com.smartsense.chat.utils.exception.BadDataException.class) + ProblemDetail handleBadDataException(com.smartsense.chat.utils.exception.BadDataException e) { + String errorMsg = ExceptionUtils.getMessage(e); + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, errorMsg); + problemDetail.setTitle(errorMsg); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + return problemDetail; + } + + /** + * Handle property reference exception problem detail. + * + * @param exception the exception + * @return the problem detail + */ + @ExceptionHandler(PropertyReferenceException.class) + ProblemDetail handlePropertyReferenceException(PropertyReferenceException exception) { + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(exception)); + problemDetail.setTitle(ExceptionUtils.getMessage(exception)); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + problemDetail.setProperty(ContField.PROPERTY, exception.getPropertyName()); + return problemDetail; + } + + /** + * Handle method argument type mismatch exception problem detail. + * + * @param exception the exception + * @return the problem detail + */ + @ExceptionHandler(MethodArgumentTypeMismatchException.class) + ProblemDetail handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException exception) { + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(exception)); + problemDetail.setTitle(ExceptionUtils.getMessage(exception)); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + problemDetail.setProperty(ContField.ARGUMENT, exception.getName()); + return problemDetail; + } + + /** + * Handle illegal argument exception problem detail. + * + * @param exception the exception + * @return the problem detail + */ + @ExceptionHandler(IllegalArgumentException.class) + ProblemDetail handleIllegalArgumentException(IllegalArgumentException exception) { + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, ExceptionUtils.getMessage(exception)); + problemDetail.setTitle(ExceptionUtils.getMessage(exception)); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + return problemDetail; + } + + /** + * Handle exception problem detail. + * + * @param e the e + * @return the problem detail + */ + @ExceptionHandler(Exception.class) + ProblemDetail handleException(Exception e) { + log.error("Error ", e); + ProblemDetail problemDetail; + problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, ExceptionUtils.getMessage(e)); + problemDetail.setTitle(ExceptionUtils.getMessage(e)); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + return problemDetail; + } + + private Map handleValidationError(List fieldErrors) { + Map messages = new HashMap<>(); + fieldErrors.forEach(fieldError -> messages.put(fieldError.getField(), fieldError.getDefaultMessage())); + return messages; + } +} + diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java new file mode 100644 index 0000000..27b3beb --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2024 Cofinity-X + ******************************************************************************/ + +package com.smartsense.chat.utils.openapi; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springdoc.core.properties.SwaggerUiConfigProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +@AllArgsConstructor +@Slf4j +public class LandingPageConfig implements WebMvcConfigurer { + + private final SwaggerUiConfigProperties properties; + + /** + * Method will use SwaggerUiConfigProperties and redirect user to swagger-ui page. + */ + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addRedirectViewController("/", properties.getPath()); + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/OpenApiConfig.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/OpenApiConfig.java new file mode 100644 index 0000000..c0c9dff --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/OpenApiConfig.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2024 Cofinity-X + ******************************************************************************/ + +package com.smartsense.chat.utils.openapi; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import lombok.RequiredArgsConstructor; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@RequiredArgsConstructor +public class OpenApiConfig { + + @Bean + public OpenAPI openAPI() { + Info info = new Info(); + info.setTitle("EDC based chat application"); + info.setDescription("EDC based chat application"); + OpenAPI openAPI = new OpenAPI(); + return openAPI.info(info); + } + + @Bean + public GroupedOpenApi openApiDefinition() { + return GroupedOpenApi.builder() + .group("docs") + .pathsToMatch("/**") + .displayName("Docs") + .build(); + } + +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java new file mode 100644 index 0000000..d851117 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java @@ -0,0 +1,6 @@ +package com.smartsense.chat.utils.response; + +import java.util.Map; + +public record BpnResponse(Map response) { +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index a8ef074..06b65dc 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -1,12 +1,20 @@ package com.smartsense.chat.web; +import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.BusinessPartnerRequest; +import com.smartsense.chat.utils.response.BpnResponse; +import com.smartsense.chat.utils.response.BusinessPartnerResponse; +import com.smartsensesolutions.commons.dao.filter.FilterRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.domain.Page; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -19,9 +27,19 @@ public class BusinessPartnerResource { private final BusinessPartnerService businessPartnerService; - @PostMapping(value = "/create", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) - public BusinessPartnerResource createBusinessPartner(@RequestBody BusinessPartnerRequest request) { + public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartnerRequest request) { return businessPartnerService.createBusinessPartner(request); } + + @GetMapping(value = "/get", produces = APPLICATION_JSON_VALUE) + public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { + return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); + } + + @PostMapping(value = "/fetch", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) + public Page fetchRawData(@RequestBody FilterRequest request) { + return businessPartnerService.filter(request); + } } + From 22a94f9c80560dae23b2bfbb2416dbce113ac83d Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 15:38:18 +0530 Subject: [PATCH 006/100] feat: update ddl auto to none --- edc-chat-app-backend/src/main/resources/application.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index 998f85e..ad650e7 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -12,7 +12,7 @@ spring: jpa: database-platform: org.hibernate.dialect.PostgreSQLDialect hibernate: - ddl-auto: update + ddl-auto: none properties: hibernate.default_schema: public show-sql: true From 89e20bca14004c8422ed7dbd22d926d4412f5e9e Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 15:39:00 +0530 Subject: [PATCH 007/100] feat: update migration files --- .../src/main/resources/db/changelog/changelog-master.yaml | 2 +- .../changes/{1-initial-table-structure.sql => init.sql} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename edc-chat-app-backend/src/main/resources/db/changelog/changes/{1-initial-table-structure.sql => init.sql} (100%) diff --git a/edc-chat-app-backend/src/main/resources/db/changelog/changelog-master.yaml b/edc-chat-app-backend/src/main/resources/db/changelog/changelog-master.yaml index a5601d6..cfa1f69 100644 --- a/edc-chat-app-backend/src/main/resources/db/changelog/changelog-master.yaml +++ b/edc-chat-app-backend/src/main/resources/db/changelog/changelog-master.yaml @@ -1,3 +1,3 @@ databaseChangeLog: - include: - file: db/changelog/changes/1-initial-table-structure.sql + file: db/changelog/changes/init.sql diff --git a/edc-chat-app-backend/src/main/resources/db/changelog/changes/1-initial-table-structure.sql b/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql similarity index 100% rename from edc-chat-app-backend/src/main/resources/db/changelog/changes/1-initial-table-structure.sql rename to edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql From a6a1999f9f12031e0ed33fd12ac04db0671da42c Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 16:32:45 +0530 Subject: [PATCH 008/100] feat: sent message with EDC --- .../chat/dao/entity/BusinessPartner.java | 2 +- .../com/smartsense/chat/edc/EDCService.java | 38 +++++++++++++++++++ .../operation/AgreementFetcherService.java | 7 +--- .../operation/ContractNegotiationService.java | 4 +- .../edc/operation/QueryCatalogService.java | 11 ++++-- .../chat/edc/web/EDCChatResource.java | 22 +++++++++++ .../src/main/resources/application.yaml | 4 ++ .../resources/db/changelog/changes/init.sql | 12 +++--- 8 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java index e79d9c8..745ee5a 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/BusinessPartner.java @@ -27,7 +27,7 @@ @NoArgsConstructor @AllArgsConstructor @Entity -@Table(name = "raw_data_master") +@Table(name = "business_partner") public class BusinessPartner implements BaseEntity { @Id diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java index fbe93f0..46c2a6e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java @@ -1,5 +1,6 @@ package com.smartsense.chat.edc; +import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.edc.operation.AgreementFetcherService; import com.smartsense.chat.edc.operation.ContractNegotiationService; import com.smartsense.chat.edc.operation.PublicUrlHandlerService; @@ -8,14 +9,24 @@ import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.ChatMessage; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; +import org.json.JSONObject; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.Map; +import java.util.UUID; @Service @RequiredArgsConstructor @Slf4j public class EDCService { + private final ObjectMapper mapper; private final BusinessPartnerService partnerService; private final QueryCatalogService queryCatalogService; private final ContractNegotiationService contractNegotiationService; @@ -23,17 +34,44 @@ public class EDCService { private final TransferProcessService transferProcessService; private final PublicUrlHandlerService publicUrlHandlerService; + @SneakyThrows + @EventListener(ApplicationReadyEvent.class) + public void initProcess() { + ChatMessage message = new ChatMessage("BPNL000000000000", + "BPNL000000000001", + new JSONObject(Map.of("Hello", "My dear dost..")).toString(), + UUID.randomUUID().toString()); + System.out.println(mapper.writeValueAsString(message)); + } + + @Async public void initProcess(ChatMessage chatMessage) { String receiverBpnl = chatMessage.receiverBpn(); String receiverDspUrl = partnerService.getBusinessPartnerByBpn(receiverBpnl); // Query the catalog for chat asset String offerId = queryCatalogService.queryCatalog(receiverDspUrl, receiverBpnl); + if (!StringUtils.hasText(offerId)) { + log.error("Not able to retrieve the offerId from EDC {}, please check manually.", receiverDspUrl); + return; + } // Initiate the contract negotiation String negotiationId = contractNegotiationService.initNegotiation(receiverDspUrl, receiverBpnl, offerId); + if (!StringUtils.hasText(negotiationId)) { + log.error("Not able to initiate the negotiation for EDC {} and offerId {}, please check manually.", receiverDspUrl, offerId); + return; + } // Get agreement Id based on the negotiationId String agreementId = agreementService.getAgreement(negotiationId); + if (!StringUtils.hasText(agreementId)) { + log.error("Not able to get the agreement for offerId {} and negotiationId {}, please check manually.", offerId, negotiationId); + return; + } // Initiate the transfer process String transferProcessId = transferProcessService.initiateTransfer(agreementId); + if (!StringUtils.hasText(transferProcessId)) { + log.error("Not able to get the agreement for transferProcessId {}, please check manually.", transferProcessId); + return; + } // Sent the message to public url publicUrlHandlerService.getAuthCodeAndPublicUrl(transferProcessId, chatMessage); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java index 6ccbf05..d1e1b2e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java @@ -5,8 +5,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import java.util.Map; @@ -27,6 +25,7 @@ public String getAgreement(String negotiationId) { Thread.sleep(5_000); log.info("Fetching agreement for negotiationId {}", negotiationId); agreementResponse = edc.getAgreement(edcConfigurations.edcUri(), negotiationId, edcConfigurations.authCode()); + log.info("AgreementResponse: {}", agreementResponse); if (!agreementResponse.get("state").toString().equals("FINALIZED")) { count++; continue; @@ -34,9 +33,7 @@ public String getAgreement(String negotiationId) { agreementId = agreementResponse.get("contractAgreementId").toString(); log.info("Negotiation {} is successfully done and agreementId is {}", negotiationId, agreementId); log.info("Fetching agreement for negotiationId {} is completed successfully.", negotiationId); - } while ((!CollectionUtils.isEmpty(agreementResponse) && agreementResponse.get("state").equals("FINALIZED")) || - StringUtils.hasText(agreementId) || - count == 3); + } while (!agreementResponse.get("state").equals("FINALIZED") && count <= 3); return agreementId; } catch (Exception ex) { log.error("Error occurred while getting agreement information for negotiationId {}", negotiationId, ex); diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java index c50ed5e..6e4c92c 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java @@ -30,6 +30,7 @@ public String initNegotiation(String receiverDspUrl, String receiverBpnL, String try { log.info("Starting negotiation process with bpnl {}, dspUrl {} and offerId {}", receiverBpnL, receiverDspUrl, offerId); Map negotiationRequest = prepareNegotiationRequest(receiverDspUrl, receiverBpnL, offerId); + log.info("Negotiation initiated for offerId {}", negotiationRequest, offerId); Map negotiationResponse = edc.initNegotiation(edcConfigurations.edcUri(), negotiationRequest, edcConfigurations.authCode()); String negotiationId = negotiationResponse.get("@id").toString(); log.info("Contract negotiation process done for offerId {} with negotiationId {}", offerId, negotiationId); @@ -46,9 +47,10 @@ private Map prepareNegotiationRequest(String receiverDspUrl, Str negotiationRequest.put("@context", prepareNegotiationContext()); negotiationRequest.put("@type", "ContractRequest"); negotiationRequest.put("edc:counterPartyAddress", receiverDspUrl); - negotiationRequest.put("edc:protocol", "ContractRequest"); + negotiationRequest.put("edc:protocol", "dataspace-protocol-http"); negotiationRequest.put("edc:counterPartyId", receiverBpnL); negotiationRequest.put("edc:policy", prepareNegotiationPolicy(receiverBpnL, offerId)); + log.info("Negotiation request looks like: {}", negotiationRequest); return negotiationRequest; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java index f47693f..8d144c8 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java @@ -17,16 +17,21 @@ @Slf4j public class QueryCatalogService { - private final EDCConfigurations configurations; + private final EDCConfigurations edcConfigurations; private final BusinessPartnerService partnerService; private final EDCConnectorClient edc; public String queryCatalog(String receiverDspUrl, String receiverBpnl) { try { log.info("Creating Query Catalog process started..."); - Map response = edc.queryCatalog(configurations.edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, configurations.assetId()), configurations.authCode()); + Map response = edc.queryCatalog(edcConfigurations.edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, edcConfigurations.assetId()), edcConfigurations.authCode()); JSONObject catalogResponse = new JSONObject(response); - String offerId = catalogResponse.getJSONObject("dcat:dataset") + JSONObject dataSet = catalogResponse.getJSONObject("dcat:dataset"); + if (dataSet.isEmpty()) { + log.info("No data set found for the assetId {} from dsp {}", edcConfigurations.assetId(), receiverDspUrl); + return null; + } + String offerId = dataSet .getJSONObject("odrl:hasPolicy") .getString("@id"); log.info("Received offerId {}.", offerId); diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java new file mode 100644 index 0000000..9826ec7 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java @@ -0,0 +1,22 @@ +package com.smartsense.chat.edc.web; + +import com.smartsense.chat.edc.EDCService; +import com.smartsense.chat.utils.request.ChatMessage; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequiredArgsConstructor +public class EDCChatResource { + private final EDCService edcService; + + @PostMapping("/chat") + public Map sentMessage(@RequestBody ChatMessage chatMessage) { + edcService.initProcess(chatMessage); + return Map.of("message", "Send message process has been started, please check the logs for more details."); + } +} diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index ad650e7..4219d7c 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -1,7 +1,11 @@ +server: + port: 8090 + chat: edc: authCode: password assetId: edc-chat-app + edcUrl: http://localhost:9192 spring: application: diff --git a/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql b/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql index 96d887d..4936563 100644 --- a/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql +++ b/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql @@ -4,10 +4,10 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; CREATE TABLE business_partner ( - id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(), - name varchar(100) NOT NULL, - bpn varchar(50) NOT NULL, - edc_url varchar(50) NOT NULL, - created_at timestamp(6) NULL DEFAULT NOW(), - updated_at timestamp(6) NULL DEFAULT NOW() + id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(), + name varchar(100) NOT NULL, + bpn varchar(50) NOT NULL, + edc_url varchar(250) NOT NULL, + created_at timestamp(6) NULL DEFAULT NOW(), + updated_at timestamp(6) NULL DEFAULT NOW() ); From 4faa32717f63329d233acb7af77061e0d81848b9 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 16:39:46 +0530 Subject: [PATCH 009/100] feat: remove unused api --- .../chat/web/BusinessPartnerResource.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index 06b65dc..b42578d 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -1,14 +1,11 @@ package com.smartsense.chat.web; -import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; import com.smartsense.chat.utils.response.BusinessPartnerResponse; -import com.smartsensesolutions.commons.dao.filter.FilterRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.data.domain.Page; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -22,24 +19,19 @@ @RestController @Slf4j @RequiredArgsConstructor -@RequestMapping("/api/partner") +@RequestMapping("/api/partners") public class BusinessPartnerResource { private final BusinessPartnerService businessPartnerService; - @PostMapping(value = "/create", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) + @PostMapping(consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartnerRequest request) { return businessPartnerService.createBusinessPartner(request); } - @GetMapping(value = "/get", produces = APPLICATION_JSON_VALUE) + @GetMapping(produces = APPLICATION_JSON_VALUE) public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); } - - @PostMapping(value = "/fetch", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) - public Page fetchRawData(@RequestBody FilterRequest request) { - return businessPartnerService.filter(request); - } } From 7d46415004bf523a1c5a401fc5d496192b960898 Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 16:58:32 +0530 Subject: [PATCH 010/100] feat: Sending message through EDC and persist all IDS in in memory storage --- .../com/smartsense/chat/edc/EDCService.java | 44 ++++++++++++------- .../chat/edc/manager/EDCProcessDto.java | 22 ++++++++++ .../edc/manager/ProcessManagerService.java | 19 ++++++++ .../edc/operation/TransferProcessService.java | 1 + .../chat/edc/web/EDCChatResource.java | 6 +++ 5 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/ProcessManagerService.java diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java index 46c2a6e..19822de 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java @@ -1,6 +1,7 @@ package com.smartsense.chat.edc; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.smartsense.chat.edc.manager.EDCProcessDto; +import com.smartsense.chat.edc.manager.ProcessManagerService; import com.smartsense.chat.edc.operation.AgreementFetcherService; import com.smartsense.chat.edc.operation.ContractNegotiationService; import com.smartsense.chat.edc.operation.PublicUrlHandlerService; @@ -9,24 +10,18 @@ import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.ChatMessage; import lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.json.JSONObject; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; -import java.util.Map; -import java.util.UUID; +import java.util.Objects; @Service @RequiredArgsConstructor @Slf4j public class EDCService { - private final ObjectMapper mapper; private final BusinessPartnerService partnerService; private final QueryCatalogService queryCatalogService; private final ContractNegotiationService contractNegotiationService; @@ -34,18 +29,20 @@ public class EDCService { private final TransferProcessService transferProcessService; private final PublicUrlHandlerService publicUrlHandlerService; - @SneakyThrows - @EventListener(ApplicationReadyEvent.class) - public void initProcess() { - ChatMessage message = new ChatMessage("BPNL000000000000", - "BPNL000000000001", - new JSONObject(Map.of("Hello", "My dear dost..")).toString(), - UUID.randomUUID().toString()); - System.out.println(mapper.writeValueAsString(message)); - } + private final ProcessManagerService managerService; + private final ProcessManagerService processManagerService; @Async public void initProcess(ChatMessage chatMessage) { + + EDCProcessDto processDto = processManagerService.getProcess(chatMessage.receiverBpn()); + + if (Objects.nonNull(processDto) && StringUtils.hasText(processDto.getTransferProcessId())) { + // Sent the message to public url + publicUrlHandlerService.getAuthCodeAndPublicUrl(processDto.getTransferProcessId(), chatMessage); + return; + } + String receiverBpnl = chatMessage.receiverBpn(); String receiverDspUrl = partnerService.getBusinessPartnerByBpn(receiverBpnl); // Query the catalog for chat asset @@ -74,6 +71,19 @@ public void initProcess(ChatMessage chatMessage) { } // Sent the message to public url publicUrlHandlerService.getAuthCodeAndPublicUrl(transferProcessId, chatMessage); + + prepareProcessDto(receiverBpnl, receiverDspUrl, offerId, agreementId, transferProcessId, negotiationId); + } + + private void prepareProcessDto(String receiverBpnl, String receiverDspUrl, String offerId, String agreementId, String transferProcessId, String negotiationId) { + managerService.put(receiverBpnl, EDCProcessDto.builder() + .bpn(receiverBpnl) + .dspUrl(receiverDspUrl) + .offerId(offerId) + .negotiationId(negotiationId) + .agreementId(agreementId) + .transferProcessId(transferProcessId) + .build()); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java new file mode 100644 index 0000000..0b6be58 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java @@ -0,0 +1,22 @@ +package com.smartsense.chat.edc.manager; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class EDCProcessDto { + + private String bpn; + private String dspUrl; + private String offerId; + private String negotiationId; + private String agreementId; + private String transferProcessId; +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/ProcessManagerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/ProcessManagerService.java new file mode 100644 index 0000000..f8fe17d --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/ProcessManagerService.java @@ -0,0 +1,19 @@ +package com.smartsense.chat.edc.manager; + +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class ProcessManagerService { + private final Map processManager = new HashMap<>(); + + public EDCProcessDto getProcess(String bpn) { + return processManager.get(bpn); + } + + public void put(String bpn, EDCProcessDto dto) { + processManager.put(bpn, dto); + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java index 10266ec..45a29ea 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java @@ -25,6 +25,7 @@ public String initiateTransfer(String agreementId) { // prepare transfer request Map transferRequest = prepareTransferRequest(agreementId); // initiate the transfer process + Thread.sleep(5_000); List> transferResponse = edc.initTransferProcess(edcConfigurations.edcUri(), transferRequest, edcConfigurations.authCode()); log.info("Received transfer response -> {}", transferResponse); diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java index 9826ec7..c20ee56 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java @@ -19,4 +19,10 @@ public Map sentMessage(@RequestBody ChatMessage chatMessage) { edcService.initProcess(chatMessage); return Map.of("message", "Send message process has been started, please check the logs for more details."); } + + @PostMapping("/chat/receive") + public Map receiveMessage(@RequestBody ChatMessage message) { + + return Map.of("message", "Message had been received successfully."); + } } From b992f2c992e8146cee418ea908dbcd72884bc07e Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 17:00:00 +0530 Subject: [PATCH 011/100] feat: fix log sonar --- .../chat/edc/operation/ContractNegotiationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java index 6e4c92c..0b0dbc3 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java @@ -30,7 +30,7 @@ public String initNegotiation(String receiverDspUrl, String receiverBpnL, String try { log.info("Starting negotiation process with bpnl {}, dspUrl {} and offerId {}", receiverBpnL, receiverDspUrl, offerId); Map negotiationRequest = prepareNegotiationRequest(receiverDspUrl, receiverBpnL, offerId); - log.info("Negotiation initiated for offerId {}", negotiationRequest, offerId); + log.info("Negotiation initiated for offerId {}", offerId); Map negotiationResponse = edc.initNegotiation(edcConfigurations.edcUri(), negotiationRequest, edcConfigurations.authCode()); String negotiationId = negotiationResponse.get("@id").toString(); log.info("Contract negotiation process done for offerId {} with negotiationId {}", offerId, negotiationId); From 1e28bb56f2e715bee997198ecbb14b109d5b7f09 Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 17:52:43 +0530 Subject: [PATCH 012/100] feat: Add config endpoint --- .../operation/AgreementFetcherService.java | 8 +++-- .../operation/ContractNegotiationService.java | 8 ++--- .../operation/PublicUrlHandlerService.java | 6 ++-- .../edc/operation/QueryCatalogService.java | 10 +++---- .../edc/operation/TransferProcessService.java | 6 ++-- .../chat/edc/settings/AppConfig.java | 30 +++++++++++++++++++ .../chat/edc/settings/EDCConfigurations.java | 3 -- .../chat/utils/openapi/LandingPageConfig.java | 27 +++++++++++------ .../chat/web/BusinessPartnerResource.java | 13 +++++--- .../src/main/resources/application.yaml | 4 ++- 10 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/AppConfig.java diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java index d1e1b2e..586219c 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java @@ -1,7 +1,7 @@ package com.smartsense.chat.edc.operation; import com.smartsense.chat.edc.client.EDCConnectorClient; -import com.smartsense.chat.edc.settings.EDCConfigurations; +import com.smartsense.chat.edc.settings.AppConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -14,7 +14,7 @@ public class AgreementFetcherService { private final EDCConnectorClient edc; - private final EDCConfigurations edcConfigurations; + private final AppConfig config; public String getAgreement(String negotiationId) { try { @@ -24,7 +24,9 @@ public String getAgreement(String negotiationId) { do { Thread.sleep(5_000); log.info("Fetching agreement for negotiationId {}", negotiationId); - agreementResponse = edc.getAgreement(edcConfigurations.edcUri(), negotiationId, edcConfigurations.authCode()); + agreementResponse = edc.getAgreement(config.edc().edcUri(), + negotiationId, + config.edc().authCode()); log.info("AgreementResponse: {}", agreementResponse); if (!agreementResponse.get("state").toString().equals("FINALIZED")) { count++; diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java index 0b0dbc3..eced62d 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java @@ -1,7 +1,7 @@ package com.smartsense.chat.edc.operation; import com.smartsense.chat.edc.client.EDCConnectorClient; -import com.smartsense.chat.edc.settings.EDCConfigurations; +import com.smartsense.chat.edc.settings.AppConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +16,7 @@ @Slf4j public class ContractNegotiationService { private final EDCConnectorClient edc; - private final EDCConfigurations edcConfigurations; + private final AppConfig config; private static List prepareNegotiationContext() { List context = new ArrayList<>(); @@ -31,7 +31,7 @@ public String initNegotiation(String receiverDspUrl, String receiverBpnL, String log.info("Starting negotiation process with bpnl {}, dspUrl {} and offerId {}", receiverBpnL, receiverDspUrl, offerId); Map negotiationRequest = prepareNegotiationRequest(receiverDspUrl, receiverBpnL, offerId); log.info("Negotiation initiated for offerId {}", offerId); - Map negotiationResponse = edc.initNegotiation(edcConfigurations.edcUri(), negotiationRequest, edcConfigurations.authCode()); + Map negotiationResponse = edc.initNegotiation(config.edc().edcUri(), negotiationRequest, config.edc().authCode()); String negotiationId = negotiationResponse.get("@id").toString(); log.info("Contract negotiation process done for offerId {} with negotiationId {}", offerId, negotiationId); return negotiationId; @@ -59,7 +59,7 @@ private Map prepareNegotiationPolicy(String receiverBpnL, String negotiationPolicy.put("@id", offerId); negotiationPolicy.put("@type", "Offer"); negotiationPolicy.put("permission", List.of(Map.of("action", "use"))); - negotiationPolicy.put("target", edcConfigurations.assetId()); + negotiationPolicy.put("target", config.edc().assetId()); negotiationPolicy.put("assigner", receiverBpnL); return negotiationPolicy; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java index 2619ae4..a8ce1be 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.edc.client.EDCConnectorClient; -import com.smartsense.chat.edc.settings.EDCConfigurations; +import com.smartsense.chat.edc.settings.AppConfig; import com.smartsense.chat.utils.request.ChatMessage; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -17,12 +17,12 @@ public class PublicUrlHandlerService { private final EDCConnectorClient edc; private final ObjectMapper mapper; - private final EDCConfigurations edcConfigurations; + private final AppConfig config; public void getAuthCodeAndPublicUrl(String transferProcessId, ChatMessage message) { try { log.info("Initiate to get auth code based on transfer process id " + transferProcessId); - Map response = edc.getAuthCodeAndPublicUrl(edcConfigurations.edcUri(), transferProcessId, edcConfigurations.authCode()); + Map response = edc.getAuthCodeAndPublicUrl(config.edc().edcUri(), transferProcessId, config.edc().authCode()); log.info("Auth code and public url response -> {}", response); // Retrieve public path and authorization code diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java index 8d144c8..83731ad 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java @@ -1,8 +1,7 @@ package com.smartsense.chat.edc.operation; import com.smartsense.chat.edc.client.EDCConnectorClient; -import com.smartsense.chat.edc.settings.EDCConfigurations; -import com.smartsense.chat.service.BusinessPartnerService; +import com.smartsense.chat.edc.settings.AppConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.json.JSONObject; @@ -17,18 +16,17 @@ @Slf4j public class QueryCatalogService { - private final EDCConfigurations edcConfigurations; - private final BusinessPartnerService partnerService; + private final AppConfig config; private final EDCConnectorClient edc; public String queryCatalog(String receiverDspUrl, String receiverBpnl) { try { log.info("Creating Query Catalog process started..."); - Map response = edc.queryCatalog(edcConfigurations.edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, edcConfigurations.assetId()), edcConfigurations.authCode()); + Map response = edc.queryCatalog(config.edc().edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, config.edc().assetId()), config.edc().authCode()); JSONObject catalogResponse = new JSONObject(response); JSONObject dataSet = catalogResponse.getJSONObject("dcat:dataset"); if (dataSet.isEmpty()) { - log.info("No data set found for the assetId {} from dsp {}", edcConfigurations.assetId(), receiverDspUrl); + log.info("No data set found for the assetId {} from dsp {}", config.edc().assetId(), receiverDspUrl); return null; } String offerId = dataSet diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java index 45a29ea..7c17a89 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java @@ -1,7 +1,7 @@ package com.smartsense.chat.edc.operation; import com.smartsense.chat.edc.client.EDCConnectorClient; -import com.smartsense.chat.edc.settings.EDCConfigurations; +import com.smartsense.chat.edc.settings.AppConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -16,7 +16,7 @@ public class TransferProcessService { private final EDCConnectorClient edc; - private final EDCConfigurations edcConfigurations; + private final AppConfig config; public String initiateTransfer(String agreementId) { try { @@ -26,7 +26,7 @@ public String initiateTransfer(String agreementId) { Map transferRequest = prepareTransferRequest(agreementId); // initiate the transfer process Thread.sleep(5_000); - List> transferResponse = edc.initTransferProcess(edcConfigurations.edcUri(), transferRequest, edcConfigurations.authCode()); + List> transferResponse = edc.initTransferProcess(config.edc().edcUri(), transferRequest, config.edc().authCode()); log.info("Received transfer response -> {}", transferResponse); // get the transfer process id from response diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/AppConfig.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/AppConfig.java new file mode 100644 index 0000000..13d8fad --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/AppConfig.java @@ -0,0 +1,30 @@ +package com.smartsense.chat.edc.settings; + +import jakarta.annotation.PostConstruct; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.StringUtils; + +@ConfigurationProperties("chat") +public record AppConfig(String bpn, + String assetUrl, + EDCConfigurations edc) { + + @PostConstruct + public void checkingConfig() { + if (!StringUtils.hasText(bpn)) { + throw new RuntimeException("Please provide bpn with chat.bpn configurations."); + } + if (!StringUtils.hasText(assetUrl)) { + throw new RuntimeException("Please provide bpn with chat.assetUrl configurations."); + } + if (!StringUtils.hasText(edc().assetId())) { + throw new RuntimeException("Please provide bpn with chat.edc.assetId configurations."); + } + if (!StringUtils.hasText(edc().edcUrl())) { + throw new RuntimeException("Please provide bpn with chat.edc.edcUrl configurations."); + } + if (!StringUtils.hasText(edc().authCode())) { + throw new RuntimeException("Please provide bpn with chat.edc.authCode configurations."); + } + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java index 33c136e..801e7b7 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/settings/EDCConfigurations.java @@ -1,10 +1,7 @@ package com.smartsense.chat.edc.settings; -import org.springframework.boot.context.properties.ConfigurationProperties; - import java.net.URI; -@ConfigurationProperties("chat.edc") public record EDCConfigurations(String edcUrl, String authCode, String assetId) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java index 27b3beb..60f0496 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/openapi/LandingPageConfig.java @@ -4,25 +4,34 @@ package com.smartsense.chat.utils.openapi; -import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springdoc.core.properties.SwaggerUiConfigProperties; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration -@AllArgsConstructor +@RequiredArgsConstructor @Slf4j -public class LandingPageConfig implements WebMvcConfigurer { +public class LandingPageConfig { private final SwaggerUiConfigProperties properties; - /** - * Method will use SwaggerUiConfigProperties and redirect user to swagger-ui page. - */ - @Override - public void addViewControllers(ViewControllerRegistry registry) { - registry.addRedirectViewController("/", properties.getPath()); + @Bean + public WebMvcConfigurer mvcConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**").allowedOrigins("*"); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addRedirectViewController("/", properties.getPath()); + } + }; } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index b42578d..469c8aa 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -1,5 +1,6 @@ package com.smartsense.chat.web; +import com.smartsense.chat.edc.settings.AppConfig; import com.smartsense.chat.service.BusinessPartnerService; import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; @@ -10,7 +11,6 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -19,17 +19,22 @@ @RestController @Slf4j @RequiredArgsConstructor -@RequestMapping("/api/partners") public class BusinessPartnerResource { private final BusinessPartnerService businessPartnerService; + private final AppConfig config; - @PostMapping(consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/config", produces = APPLICATION_JSON_VALUE) + public AppConfig getConfig() { + return config; + } + + @PostMapping(value = "/api/partners", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartnerRequest request) { return businessPartnerService.createBusinessPartner(request); } - @GetMapping(produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/api/partners", produces = APPLICATION_JSON_VALUE) public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); } diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index 4219d7c..d5b7320 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -1,7 +1,9 @@ server: - port: 8090 + port: 8080 chat: + bpn: + assetUrl: edc: authCode: password assetId: edc-chat-app From 28153d3bad7da4d486066bc1545d63e0174c646b Mon Sep 17 00:00:00 2001 From: Nitin Date: Thu, 21 Nov 2024 17:58:35 +0530 Subject: [PATCH 013/100] chore: api prefix removed --- edc-chat-app-backend/compose.yaml | 9 --------- .../com/smartsense/chat/web/BusinessPartnerResource.java | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 edc-chat-app-backend/compose.yaml diff --git a/edc-chat-app-backend/compose.yaml b/edc-chat-app-backend/compose.yaml deleted file mode 100644 index 7c8044f..0000000 --- a/edc-chat-app-backend/compose.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - postgres: - image: 'postgres:latest' - environment: - - 'POSTGRES_DB=mydatabase' - - 'POSTGRES_PASSWORD=secret' - - 'POSTGRES_USER=myuser' - ports: - - '5432' diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index 469c8aa..98293bd 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -29,12 +29,12 @@ public AppConfig getConfig() { return config; } - @PostMapping(value = "/api/partners", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) + @PostMapping(value = "/partners", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartnerRequest request) { return businessPartnerService.createBusinessPartner(request); } - @GetMapping(value = "/api/partners", produces = APPLICATION_JSON_VALUE) + @GetMapping(value = "/partners", produces = APPLICATION_JSON_VALUE) public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); } From 5fd3382b282f76cd0ca29cc1e4774a34784be899 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 18:33:12 +0530 Subject: [PATCH 014/100] feat: add env variable and api docs --- edc-chat-app-backend/build.gradle | 1 - .../repository/BusinessPartnerRepository.java | 4 ++ .../chat/edc/web/EDCChatResource.java | 7 ++- .../chat/service/BusinessPartnerService.java | 22 ++++--- .../chat/web/BusinessPartnerResource.java | 6 ++ .../web/apidocs/BusinessPartnersApiDocs.java | 53 ++++++++++++++++ .../chat/web/apidocs/EDCChatApiDocs.java | 61 +++++++++++++++++++ .../src/main/resources/application.yaml | 29 +++++---- 8 files changed, 163 insertions(+), 20 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/EDCChatApiDocs.java diff --git a/edc-chat-app-backend/build.gradle b/edc-chat-app-backend/build.gradle index b51d92f..70603e0 100644 --- a/edc-chat-app-backend/build.gradle +++ b/edc-chat-app-backend/build.gradle @@ -42,7 +42,6 @@ dependencies { implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' - developmentOnly 'org.springframework.boot:spring-boot-docker-compose' runtimeOnly 'org.postgresql:postgresql' annotationProcessor 'org.projectlombok:lombok' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java index 268190b..1c622a1 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java @@ -2,6 +2,7 @@ import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsensesolutions.commons.dao.base.BaseRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.UUID; @@ -12,4 +13,7 @@ public interface BusinessPartnerRepository extends BaseRepository sentMessage(@RequestBody ChatMessage chatMessage) { edcService.initProcess(chatMessage); return Map.of("message", "Send message process has been started, please check the logs for more details."); } + @EDCChatReceive @PostMapping("/chat/receive") public Map receiveMessage(@RequestBody ChatMessage message) { - return Map.of("message", "Message had been received successfully."); } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 95be27e..8b0ba85 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -29,13 +29,21 @@ public class BusinessPartnerService extends BaseService { public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest request) { - log.info("Creating BusinessPartner. name: {}", request.name()); - BusinessPartner businessPartner = BusinessPartner.builder() - .name(request.name()) - .edcUrl(request.edcUrl()) - .bpn(request.bpn()) - .build(); - return mapper.convertValue(businessPartnerRepository.save(businessPartner), BusinessPartnerResponse.class); + BusinessPartner partner = businessPartnerRepository.findByNameOrBpn(request.name(), request.bpn()); + if (Objects.nonNull(partner)) { + log.info("Updating BusinessPartner for bpn: {}", request.bpn()); + partner.setName(request.name()); + partner.setEdcUrl(request.edcUrl()); + partner.setBpn(request.bpn()); + } else { + log.info("Creating BusinessPartner. name: {}", request.name()); + partner = BusinessPartner.builder() + .name(request.name()) + .edcUrl(request.edcUrl()) + .bpn(request.bpn()) + .build(); + } + return mapper.convertValue(businessPartnerRepository.save(partner), BusinessPartnerResponse.class); } public BpnResponse getBusinessPartner(String name) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index 98293bd..53f3781 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -5,6 +5,9 @@ import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; import com.smartsense.chat.utils.response.BusinessPartnerResponse; +import com.smartsense.chat.web.apidocs.BusinessPartnersApiDocs.CreateBusinessPartner; +import com.smartsense.chat.web.apidocs.BusinessPartnersApiDocs.GetBusinessPartners; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; @@ -19,6 +22,7 @@ @RestController @Slf4j @RequiredArgsConstructor +@Tag(name = "Business Partner management Controller", description = "This controller used for persist Business Partner details.") public class BusinessPartnerResource { private final BusinessPartnerService businessPartnerService; @@ -29,11 +33,13 @@ public AppConfig getConfig() { return config; } + @CreateBusinessPartner @PostMapping(value = "/partners", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE) public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartnerRequest request) { return businessPartnerService.createBusinessPartner(request); } + @GetBusinessPartners @GetMapping(value = "/partners", produces = APPLICATION_JSON_VALUE) public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java new file mode 100644 index 0000000..297defa --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java @@ -0,0 +1,53 @@ +package com.smartsense.chat.web.apidocs; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public class BusinessPartnersApiDocs { + + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + @Operation(description = "Create Business Partner", summary = "Create Business Partner by providing bpn and edcUrl.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Business Partner created", content = { + @Content(examples = { + @ExampleObject(name = "Business Partner created", value = """ + { + "id": "89221248-4c98-4d8e-a909-d31f3ea0fa8f", + "name": "bhautik", + "bpn": "BPNL000000000001", + "edcUrl": "http://localhost:8090" + } + """) + }) + }) }) + public @interface CreateBusinessPartner { + } + + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + @Operation(description = "Get Business Partner", summary = "Get Business Partner details by name.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Get Business Partner details by name.", content = { + @Content(examples = { + @ExampleObject(name = "Get Business Partner details", value = """ + { + "response": { + "bhautik": "BPNL000000000001", + "dilip": "BPNL000000000002" + } + } + """) + }) }) }) + public @interface GetBusinessPartners { + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/EDCChatApiDocs.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/EDCChatApiDocs.java new file mode 100644 index 0000000..89eef0c --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/EDCChatApiDocs.java @@ -0,0 +1,61 @@ +package com.smartsense.chat.web.apidocs; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public class EDCChatApiDocs { + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + @Operation(description = "Receive Chat message", summary = "Receive Chat message.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Receive Chat message", content = { + @Content(examples = { + @ExampleObject(name = "Business Partner created", value = """ + { + "message": "User Created successfully", + "body": { + "id": "248b97f0-6f3a-4f56-af04-c0da600125b1", + "name": "Name Surname", + "age": 19, + "city": "Some City", + "country": "Some Country" + } + } + """) + }) + }) }) + public @interface EDCChatReceive { + } + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + @Operation(description = "Sent Chat message", summary = "Sent Chat message") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Sent Chat message", content = { + @Content(examples = { + @ExampleObject(name = "Business Partner created", value = """ + { + "message": "User Created successfully", + "body": { + "id": "248b97f0-6f3a-4f56-af04-c0da600125b1", + "name": "Name Surname", + "age": 19, + "city": "Some City", + "country": "Some Country" + } + } + """) + }) + }) }) + public @interface EDCChatSent { + } +} diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index d5b7320..17b79db 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -2,16 +2,23 @@ server: port: 8080 chat: - bpn: - assetUrl: + name: ${CHAT_APP_NAME:EDC based chat application} + bpn: ${CHAT_APP_BPN:BPNL000000000001} + assetUrl: ${CHAT_APP_ASSET_URL:http://localhost:9192} + datasource: + host: ${CHAT_DB_HOST:localhost} + port: ${CHAT_DB_PORT:5432} + database: ${CHAT_DB_NAME:chat_app} + schema: ${CHAT_DB_SCHEMA:public} + username: ${CHAT_DB_USER:root} + password: ${CHAT_DB_PASSWORD:root} edc: - authCode: password - assetId: edc-chat-app - edcUrl: http://localhost:9192 - + authCode: ${CHAT_AUTH_CODE:password} + assetId: ${CHAT_ASSET_ID:edc-chat-app} + edcUrl: ${CHAT_EDC_URL:http://localhost:9192} spring: application: - name: EDC based chat application + name: ${chat.name} threads: virtual: enabled: true @@ -20,12 +27,12 @@ spring: hibernate: ddl-auto: none properties: - hibernate.default_schema: public + hibernate.default_schema: ${chat.datasource.schema} show-sql: true datasource: - url: jdbc:postgresql://localhost:5432/chat_app - username: postgres - password: 123456 + url: jdbc:postgresql://${chat.datasource.host}:${chat.datasource.port}/${chat.datasource.database} + username: ${chat.datasource.username:root} + password: ${chat.datasource.password:root} driver-class-name: org.postgresql.Driver liquibase: change-log: classpath:db/changelog/changelog-master.yaml From 87c656ad323e3dd26f688d8d0d8b697d6b8ddc4f Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Thu, 21 Nov 2024 18:37:07 +0530 Subject: [PATCH 015/100] fix: remove unused configs --- .../src/main/resources/application.yaml | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/edc-chat-app-backend/src/main/resources/application.yaml b/edc-chat-app-backend/src/main/resources/application.yaml index 17b79db..3cd5e93 100644 --- a/edc-chat-app-backend/src/main/resources/application.yaml +++ b/edc-chat-app-backend/src/main/resources/application.yaml @@ -2,20 +2,21 @@ server: port: 8080 chat: - name: ${CHAT_APP_NAME:EDC based chat application} - bpn: ${CHAT_APP_BPN:BPNL000000000001} - assetUrl: ${CHAT_APP_ASSET_URL:http://localhost:9192} + name: EDC based chat application + bpn: BPNL000000000001 + assetUrl: http://localhost:9192 datasource: - host: ${CHAT_DB_HOST:localhost} - port: ${CHAT_DB_PORT:5432} - database: ${CHAT_DB_NAME:chat_app} - schema: ${CHAT_DB_SCHEMA:public} - username: ${CHAT_DB_USER:root} - password: ${CHAT_DB_PASSWORD:root} + host: localhost + port: 5432 + database: chat_app + schema: public + username: root + password: root edc: - authCode: ${CHAT_AUTH_CODE:password} - assetId: ${CHAT_ASSET_ID:edc-chat-app} - edcUrl: ${CHAT_EDC_URL:http://localhost:9192} + authCode: password + assetId: edc-chat-app + edcUrl: http://localhost:9192 + spring: application: name: ${chat.name} @@ -31,8 +32,8 @@ spring: show-sql: true datasource: url: jdbc:postgresql://${chat.datasource.host}:${chat.datasource.port}/${chat.datasource.database} - username: ${chat.datasource.username:root} - password: ${chat.datasource.password:root} + username: ${chat.datasource.username} + password: ${chat.datasource.password} driver-class-name: org.postgresql.Driver liquibase: change-log: classpath:db/changelog/changelog-master.yaml @@ -44,8 +45,6 @@ springdoc: show-common-extensions: true csrf: enabled: true -# api-docs: -# path: /docs/api-docs logging: level: From ed70245a057b670f55421dea4299fe19173b65b5 Mon Sep 17 00:00:00 2001 From: Nitin Date: Thu, 21 Nov 2024 18:55:08 +0530 Subject: [PATCH 016/100] feat: config, get BPN and add BPN api integrated --- edc-chat-app-backend/.editorconfig | 533 +++++++++++++++++++++++ edc-chat-app-ui/.env.development | 4 + edc-chat-app-ui/package-lock.json | 32 ++ edc-chat-app-ui/package.json | 1 + edc-chat-app-ui/src/component/add-bpn.js | 11 +- edc-chat-app-ui/src/component/chat.js | 191 ++++---- edc-chat-app-ui/src/component/home.js | 150 ++++--- 7 files changed, 763 insertions(+), 159 deletions(-) create mode 100644 edc-chat-app-backend/.editorconfig create mode 100644 edc-chat-app-ui/.env.development diff --git a/edc-chat-app-backend/.editorconfig b/edc-chat-app-backend/.editorconfig new file mode 100644 index 0000000..983575c --- /dev/null +++ b/edc-chat-app-backend/.editorconfig @@ -0,0 +1,533 @@ +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = false +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false + +[*.java] +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_annotation_parameter_wrap = off +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = off +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_builder_methods = none +ij_java_call_parameters_new_line_after_left_paren = false +ij_java_call_parameters_right_paren_on_new_line = false +ij_java_call_parameters_wrap = off +ij_java_case_statement_on_separate_line = true +ij_java_catch_on_new_line = false +ij_java_class_annotation_wrap = split_into_lines +ij_java_class_brace_style = end_of_line +ij_java_class_count_to_use_import_on_demand = 99 +ij_java_class_names_in_javadoc = 1 +ij_java_do_not_indent_top_level_class_members = false +ij_java_do_not_wrap_after_single_annotation = false +ij_java_do_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_entity_dd_suffix = EJB +ij_java_entity_eb_suffix = Bean +ij_java_entity_hi_suffix = Home +ij_java_entity_lhi_prefix = Local +ij_java_entity_lhi_suffix = Home +ij_java_entity_li_prefix = Local +ij_java_entity_pk_class = java.lang.String +ij_java_entity_vo_suffix = VO +ij_java_enum_constants_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *, |, java.**, javax.**, |, $* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = false +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = true +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = true +ij_java_line_comment_at_first_column = false +ij_java_message_dd_suffix = EJB +ij_java_message_eb_suffix = Bean +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = off +ij_java_method_parameters_new_line_after_left_paren = false +ij_java_method_parameters_right_paren_on_new_line = false +ij_java_method_parameters_wrap = off +ij_java_modifier_list_wrap = false +ij_java_names_count_to_use_import_on_demand = 99 +ij_java_new_line_after_lparen_in_record_header = false +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_java_parameter_annotation_wrap = off +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_record_header = false +ij_java_session_dd_suffix = EJB +ij_java_session_eb_suffix = Bean +ij_java_session_hi_suffix = Home +ij_java_session_lhi_prefix = Local +ij_java_session_lhi_suffix = Home +ij_java_session_li_prefix = Local +ij_java_session_si_suffix = Service +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = false +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = true +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_subclass_name_suffix = Impl +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +ij_java_use_external_annotations = false +ij_java_use_fq_class_names = false +ij_java_use_relative_indents = false +ij_java_use_single_class_imports = true +ij_java_variable_annotation_wrap = off +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false + +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_align_attributes = true +ij_xml_align_text = false +ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false +ij_xml_block_comment_at_first_column = true +ij_xml_keep_blank_lines = 2 +ij_xml_keep_indents_on_empty_lines = false +ij_xml_keep_line_breaks = true +ij_xml_keep_line_breaks_in_text = true +ij_xml_keep_whitespaces = false +ij_xml_keep_whitespaces_around_cdata = preserve +ij_xml_keep_whitespaces_inside_cdata = false +ij_xml_line_comment_at_first_column = true +ij_xml_space_after_tag_name = false +ij_xml_space_around_equals_in_attribute = false +ij_xml_space_inside_empty_tag = false +ij_xml_text_wrap = normal +ij_xml_use_custom_settings = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true + +[{*.gant,*.gradle,*.groovy,*.gson,*.gy}] +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_list_or_map = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_named_args_in_map = true +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_add_space = false +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_class_count_to_use_import_on_demand = 5 +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_if_brace_force = never +ij_groovy_import_annotation_wrap = 2 +ij_groovy_imports_layout = *, |, javax.**, java.**, |, $* +ij_groovy_indent_case_from_switch = true +ij_groovy_indent_label_blocks = true +ij_groovy_insert_inner_class_imports = false +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_indents_on_empty_lines = false +ij_groovy_keep_line_breaks = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_layout_static_imports_separately = true +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_names_count_to_use_import_on_demand = 3 +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_assert_separator = true +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_assert_separator = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_closure_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_record_parentheses = false +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_in_named_argument = true +ij_groovy_space_in_named_argument_before_colon = false +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_regex_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_gstring_injection_braces = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_list_or_map = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_tuple_expression = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_flying_geese_braces = false +ij_groovy_use_fq_class_names = false +ij_groovy_use_fq_class_names_in_javadoc = true +ij_groovy_use_relative_indents = false +ij_groovy_use_single_class_imports = true +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_chain_calls_after_dot = false +ij_groovy_wrap_long_lines = false + +[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = true +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false + +[{*.markdown,*.md}] +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 + +[{*.properties,spring.handlers,spring.schemas}] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true diff --git a/edc-chat-app-ui/.env.development b/edc-chat-app-ui/.env.development new file mode 100644 index 0000000..d234da3 --- /dev/null +++ b/edc-chat-app-ui/.env.development @@ -0,0 +1,4 @@ +REACT_APP_API_BASE_URL=http://localhost:8080 +REACT_APP_WEBSOCKET_URL=wss://websocket.test.com +REACT_APP_APP_NAME=My React App +REACT_APP_BPN=BPNL000000000000 \ No newline at end of file diff --git a/edc-chat-app-ui/package-lock.json b/edc-chat-app-ui/package-lock.json index ad338e1..b7c30ae 100644 --- a/edc-chat-app-ui/package-lock.json +++ b/edc-chat-app-ui/package-lock.json @@ -11,6 +11,7 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "axios": "^1.7.7", "bootstrap": "^5.3.3", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -5195,6 +5196,31 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz", @@ -13876,6 +13902,12 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/psl": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.10.0.tgz", diff --git a/edc-chat-app-ui/package.json b/edc-chat-app-ui/package.json index 11def24..894ea97 100644 --- a/edc-chat-app-ui/package.json +++ b/edc-chat-app-ui/package.json @@ -6,6 +6,7 @@ "@testing-library/jest-dom": "^5.17.0", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", + "axios": "^1.7.7", "bootstrap": "^5.3.3", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/edc-chat-app-ui/src/component/add-bpn.js b/edc-chat-app-ui/src/component/add-bpn.js index 2b48008..f2133b4 100644 --- a/edc-chat-app-ui/src/component/add-bpn.js +++ b/edc-chat-app-ui/src/component/add-bpn.js @@ -1,3 +1,4 @@ +import axios from "axios"; import React, { useState } from "react"; import { useNavigate, useLocation } from "react-router-dom"; @@ -19,12 +20,10 @@ const AddBpn = () => { const requestData = { ...formData, bpn }; // Include BPN in the request body try { - const response = await fetch("https://api.example.com/add-partner", { - method: "POST", + const response = await axios.post(`${process.env.REACT_APP_API_BASE_URL}/partners`,JSON.stringify(requestData), { headers: { "Content-Type": "application/json", - }, - body: JSON.stringify(requestData), + } }); if (response.status === 200) { @@ -68,8 +67,8 @@ const AddBpn = () => { type="text" name="bpn" className="form-control" - value={bpn || ""} - disabled + value={formData.bpn} + onChange={handleInputChange} />
diff --git a/edc-chat-app-ui/src/component/chat.js b/edc-chat-app-ui/src/component/chat.js index c027a5f..09e2458 100644 --- a/edc-chat-app-ui/src/component/chat.js +++ b/edc-chat-app-ui/src/component/chat.js @@ -2,101 +2,108 @@ import React, { useState, useEffect, useRef } from "react"; import { useLocation, useNavigate } from "react-router-dom"; const Chat = () => { - const location = useLocation(); - const navigate = useNavigate(); - const webSocketRef = useRef(null); - - const [messages, setMessages] = useState([]); // Chat messages - const [newMessage, setNewMessage] = useState(""); // Current message to send - const [error, setError] = useState(null); // Error messages - - const { bpn } = location.state || {}; // Get BPN from navigation state - - useEffect(() => { - if (!bpn) { - setError("BPN is missing. Redirecting to home..."); - setTimeout(() => navigate("/"), 3000); - return; - } - - const wsUrl = "wss://example.com/chat"; // Replace with your WebSocket URL - - // WebSocket connection with BPN in headers (via query string) - const socket = new WebSocket(`${wsUrl}?bpn=${bpn}`); - - webSocketRef.current = socket; - - // WebSocket event handlers - socket.onopen = () => console.log("WebSocket connected!"); - - socket.onmessage = (event) => { - const data = JSON.parse(event.data); // Assuming JSON messages - setMessages((prevMessages) => [ - ...prevMessages, - { sender: data.sender, text: data.message }, - ]); + const location = useLocation(); + const navigate = useNavigate(); + const webSocketRef = useRef(null); + + const [messages, setMessages] = useState([]); // Chat messages + const [newMessage, setNewMessage] = useState(""); // Current message to send + const [error, setError] = useState(null); // Error messages + + const { bpn, selectedValue } = location.state || {}; + + useEffect(() => { + if (!bpn || !selectedValue) { + debugger; + setError("BPN is missing. Redirecting to home..."); + setTimeout(() => navigate("/"), 3000); + return; + } else { + console.log("bpn -> " + bpn); + console.log("selected values ->" + selectedValue); + } + + const wsUrl = "wss://example.com/chat"; // Replace with your WebSocket URL + + // WebSocket connection with BPN in headers (via query string) + const socket = new WebSocket(`${wsUrl}?bpn=${bpn}`); + + webSocketRef.current = socket; + + // WebSocket event handlers + socket.onopen = () => console.log("WebSocket connected!"); + + socket.onmessage = (event) => { + const data = JSON.parse(event.data); // Assuming JSON messages + setMessages((prevMessages) => [...prevMessages, { sender: data.sender, text: data.message }]); + }; + + socket.onerror = () => setError("WebSocket connection error"); + + socket.onclose = () => console.log("WebSocket closed"); + + // Cleanup WebSocket on component unmount + return () => { + if (socket.readyState === WebSocket.OPEN) { + socket.close(); + } + }; + }, [bpn]); + + const handleSendMessage = () => { + if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) { + const message = { + sender: "user", // Customize as needed + message: newMessage, + }; + webSocketRef.current.send(JSON.stringify(message)); + setMessages((prevMessages) => [...prevMessages, { sender: "You", text: newMessage }]); + setNewMessage(""); // Clear input field + } else { + setError("WebSocket is not connected"); + } }; - socket.onerror = () => setError("WebSocket connection error"); - - socket.onclose = () => console.log("WebSocket closed"); - - // Cleanup WebSocket on component unmount - return () => { - if (socket.readyState === WebSocket.OPEN) { - socket.close(); - } - }; - }, [bpn]); - - const handleSendMessage = () => { - if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) { - const message = { - sender: "user", // Customize as needed - message: newMessage, - }; - webSocketRef.current.send(JSON.stringify(message)); - setMessages((prevMessages) => [...prevMessages, { sender: "You", text: newMessage }]); - setNewMessage(""); // Clear input field - } else { - setError("WebSocket is not connected"); - } - }; - - return ( -
-

Chat

- - {/* Display BPN */} - {bpn && ( -
- Your BPN: {bpn} + return ( +
+

Chat

+ + {/* Display BPN */} + {bpn && ( +
+ Your BPN: {bpn} +
+ )} + + {bpn && ( +
+ Partner BPN: {selectedValue} +
+ )} + +
+ {messages.map((msg, index) => ( +

+ {msg.sender}: {msg.text} +

+ ))} +
+ + {error &&
{error}
} + +
+ setNewMessage(e.target.value)} + /> + +
- )} - -
- {messages.map((msg, index) => ( -

- {msg.sender}: {msg.text} -

- ))} -
- - {error &&
{error}
} - -
- setNewMessage(e.target.value)} - /> - -
-
- ); + ); }; export default Chat; diff --git a/edc-chat-app-ui/src/component/home.js b/edc-chat-app-ui/src/component/home.js index c2c7f47..aa981d8 100644 --- a/edc-chat-app-ui/src/component/home.js +++ b/edc-chat-app-ui/src/component/home.js @@ -1,80 +1,108 @@ +import axios from "axios"; import React, { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; const Home = () => { - const [bpn, setBpn] = useState(null); // Store the fetched BPN - const [error, setError] = useState(null); // Error messages - const navigate = useNavigate(); + const [bpn, setBpn] = useState(null); // Store the fetched BPN + const [error, setError] = useState(null); // Error messages + const navigate = useNavigate(); + const [dropdownData, setDropdownData] = useState([]); + const [selectedValue, setSelectedValue] = useState(""); - useEffect(() => { - // Fetch BPN when the home page loads - const fetchBpn = async () => { - try { - const response = await fetch("https://api.example.com/get-bpn"); - if (response.status === 200) { - const data = await response.json(); - setBpn(data.bpn); // Save the BPN in state - } else { - setError("Failed to fetch BPN"); + useEffect(() => { + fetchConfig(); + fetchDropdownData(); + }, []); + + //Fetch BPN when the home page loads + const fetchConfig = async () => { + try { + const response = await axios.get(`${process.env.REACT_APP_API_BASE_URL}/config`); + if (response.status === 200) { + const data = await response.data; + setBpn(data.bpn); // Save the BPN in state + } else { + setError("Failed to fetch BPN"); + } + } catch (err) { + setError("Network error: Unable to fetch initial config"); } - } catch (err) { - setError("Network error: Unable to fetch BPN"); - } }; - fetchBpn(); - }, []); + const fetchDropdownData = async () => { + try { + const response = await axios.get(`${process.env.REACT_APP_API_BASE_URL}/partners`); + const apiResponse = response.data.response; + // Transform response into key-value pairs for dropdown + const dropdownItems = Object.entries(apiResponse).map(([key, value]) => ({ + label: `${key} - ${value}`, + value: value, + })); + setDropdownData(dropdownItems); + } catch (error) { + console.error("Error fetching dropdown data:", error); + } + }; + const handleStartChat = () => { + console.log("selected BPN -"+selectedValue) + if (!bpn) { + setError("BPN is not available. Please try again later."); + return; + } + navigate("/chat", { state: { bpn, selectedValue } }); + }; - const handleStartChat = () => { - if (!bpn) { - setError("BPN is not available. Please try again later."); - return; - } - navigate("/chat", { state: { bpn } }); - }; + const handleAddPartner = () => { + if (!bpn) { + setError("BPN is not available. Please try again later."); + return; + } + navigate("/add-business-partner", { state: { bpn } }); + }; - const handleAddPartner = () => { - if (!bpn) { - setError("BPN is not available. Please try again later."); - return; - } - navigate("/add-partner", { state: { bpn } }); - }; + const handleSelectChange = (event) => { + setSelectedValue(event.target.value); + console.log("Selected value:", event.target.value); + }; - return ( -
-

Chat Application using EDC

+ return ( +
+

Chat Application using EDC

- {bpn ? ( -
- Your BPN: {bpn} -
- ) : ( -
Fetching your BPN...
- )} + {bpn ? ( +
+ Your BPN: {bpn} +
+ ) : ( +
Fetching your BPN...
+ )} - {error &&
{error}
} + {error &&
{error}
} -
-
- - -
- +
+
+ + +
+ -
OR
+
OR
- -
-
- ); + +
+
+ ); }; export default Home; From 485fb9481f0b2305ede910b5e96934f85467f803 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Thu, 21 Nov 2024 19:21:58 +0530 Subject: [PATCH 017/100] feat: add conflict exception and handler --- .../chat/service/BusinessPartnerService.java | 23 +++++++++---------- .../utils/exception/ConflictException.java | 13 +++++++++++ .../exception/GlobalExceptionHandler.java | 9 ++++++++ 3 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/ConflictException.java diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 8b0ba85..e372ddb 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.dao.repository.BusinessPartnerRepository; +import com.smartsense.chat.utils.exception.ConflictException; import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; import com.smartsense.chat.utils.response.BusinessPartnerResponse; @@ -31,19 +32,17 @@ public class BusinessPartnerService extends BaseService { public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest request) { BusinessPartner partner = businessPartnerRepository.findByNameOrBpn(request.name(), request.bpn()); if (Objects.nonNull(partner)) { - log.info("Updating BusinessPartner for bpn: {}", request.bpn()); - partner.setName(request.name()); - partner.setEdcUrl(request.edcUrl()); - partner.setBpn(request.bpn()); - } else { - log.info("Creating BusinessPartner. name: {}", request.name()); - partner = BusinessPartner.builder() - .name(request.name()) - .edcUrl(request.edcUrl()) - .bpn(request.bpn()) - .build(); + String errorMessage = String.format("BusinessPartner with name '%s' or BPN '%s' already exists.", request.name(), request.bpn()); + log.error(errorMessage); + throw new ConflictException(errorMessage); } - return mapper.convertValue(businessPartnerRepository.save(partner), BusinessPartnerResponse.class); + log.info("Creating BusinessPartner. name: {}", request.name()); + BusinessPartner businessPartner = BusinessPartner.builder() + .name(request.name()) + .edcUrl(request.edcUrl()) + .bpn(request.bpn()) + .build(); + return mapper.convertValue(businessPartnerRepository.save(businessPartner), BusinessPartnerResponse.class); } public BpnResponse getBusinessPartner(String name) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/ConflictException.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/ConflictException.java new file mode 100644 index 0000000..7b51c1f --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/ConflictException.java @@ -0,0 +1,13 @@ +package com.smartsense.chat.utils.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(HttpStatus.CONFLICT) +public class ConflictException extends RuntimeException { + + public ConflictException(String message) { + super(message); + } +} + diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java index 6ace1d7..ffb5a36 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java @@ -134,6 +134,15 @@ ProblemDetail handleException(Exception e) { return problemDetail; } + @ExceptionHandler(ConflictException.class) + public ProblemDetail handleConflictException(ConflictException ex) { + String errorMsg = ExceptionUtils.getMessage(ex); + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.CONFLICT, errorMsg); + problemDetail.setTitle(errorMsg); + problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); + return problemDetail; + } + private Map handleValidationError(List fieldErrors) { Map messages = new HashMap<>(); fieldErrors.forEach(fieldError -> messages.put(fieldError.getField(), fieldError.getDefaultMessage())); From 494d693dd94f010f8c9a554c33ebc000c7940fe4 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 10:21:49 +0530 Subject: [PATCH 018/100] feat: add bpn API --- edc-chat-app-ui/src/component/add-bpn.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/edc-chat-app-ui/src/component/add-bpn.js b/edc-chat-app-ui/src/component/add-bpn.js index f2133b4..b3b737a 100644 --- a/edc-chat-app-ui/src/component/add-bpn.js +++ b/edc-chat-app-ui/src/component/add-bpn.js @@ -25,7 +25,6 @@ const AddBpn = () => { "Content-Type": "application/json", } }); - if (response.status === 200) { setSuccess("Business partner added successfully!"); setTimeout(() => navigate("/"), 2000); // Redirect to Screen1 after success @@ -33,7 +32,11 @@ const AddBpn = () => { setError("Failed to save business partner. Please try again."); } } catch (err) { - setError("Network error: Unable to save business partner."); + if(err.response.status == 409){ + setError(err.response.data.title) + }else{ + setError("Network error: Unable to save business partner."); + } } }; From 15f3d1aaba4af6ed0d146750a5d07bcd44b0dae9 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Fri, 22 Nov 2024 10:29:18 +0530 Subject: [PATCH 019/100] feat: refactor conflict exception --- .../com/smartsense/chat/service/BusinessPartnerService.java | 5 +++-- .../chat/utils/exception/GlobalExceptionHandler.java | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index e372ddb..68ea994 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -30,9 +30,10 @@ public class BusinessPartnerService extends BaseService { public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest request) { - BusinessPartner partner = businessPartnerRepository.findByNameOrBpn(request.name(), request.bpn()); + log.info("Business partner request: {}", request); + BusinessPartner partner = businessPartnerRepository.findByBpn(request.bpn()); if (Objects.nonNull(partner)) { - String errorMessage = String.format("BusinessPartner with name '%s' or BPN '%s' already exists.", request.name(), request.bpn()); + String errorMessage = String.format("BusinessPartner with BPN '%s' already exists.", request.bpn()); log.error(errorMessage); throw new ConflictException(errorMessage); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java index ffb5a36..0ae43d0 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java @@ -136,9 +136,8 @@ ProblemDetail handleException(Exception e) { @ExceptionHandler(ConflictException.class) public ProblemDetail handleConflictException(ConflictException ex) { - String errorMsg = ExceptionUtils.getMessage(ex); - ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.CONFLICT, errorMsg); - problemDetail.setTitle(errorMsg); + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.CONFLICT, ex.getMessage()); + problemDetail.setTitle(ex.getMessage()); problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); return problemDetail; } From 9b35614632446f7982f0811b35eead7cfa4637b7 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 10:37:56 +0530 Subject: [PATCH 020/100] docs: deployment doc added --- deployment/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 deployment/README.md diff --git a/deployment/README.md b/deployment/README.md new file mode 100644 index 0000000..6556440 --- /dev/null +++ b/deployment/README.md @@ -0,0 +1,28 @@ +# Deploymet document to setup in local + +This document provide step-by-step guide line to deploy Chat aplication using docker compose. + +Once you deploy this stack, it will run below containers + +- Provider side +- - EDC +- - Backend application +- - Chat UI application +- Consumer side +- - EDC +- - Backend application +- - Chat UI application +- Common application +- - SSI dim wallet stub + + +## Data setup + +- Oparator/issuer BPN: BPNL0000TRACTUSX + + +### Pre-requerment +- Docker +- Docker compose + +### Deploy in local \ No newline at end of file From 307ae4c9fcfe7b039dd531fbbb1eb18802d55cc9 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 10:41:46 +0530 Subject: [PATCH 021/100] docs: initial data config added --- deployment/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deployment/README.md b/deployment/README.md index 6556440..17dfecc 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -4,11 +4,11 @@ This document provide step-by-step guide line to deploy Chat aplication using do Once you deploy this stack, it will run below containers -- Provider side +- Company 1 side(provider) - - EDC - - Backend application - - Chat UI application -- Consumer side +- Company 2 side(consumer) - - EDC - - Backend application - - Chat UI application @@ -16,9 +16,11 @@ Once you deploy this stack, it will run below containers - - SSI dim wallet stub -## Data setup +## Data setup and initial config - Oparator/issuer BPN: BPNL0000TRACTUSX +- Company 1 BPN: BPNL00SMARTSENSE +- Company 2 BPN: BPNL000COFINITYX ### Pre-requerment From 83ff33bf72717868f2f260f4f984b5bedf207bf0 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Fri, 22 Nov 2024 10:41:52 +0530 Subject: [PATCH 022/100] feat: update get partners response --- .../repository/BusinessPartnerRepository.java | 3 ++- .../chat/service/BusinessPartnerService.java | 22 ++++++++++++------- .../chat/utils/response/BpnResponse.java | 4 +--- .../chat/web/BusinessPartnerResource.java | 4 +++- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java index 1c622a1..62550d0 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/BusinessPartnerRepository.java @@ -5,12 +5,13 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.UUID; @Repository public interface BusinessPartnerRepository extends BaseRepository { - BusinessPartner findByName(String name); + List findByName(String name); BusinessPartner findByBpn(String bpn); diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 68ea994..7acdce2 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -14,11 +14,10 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.UUID; -import java.util.stream.Collectors; @Service @Slf4j @@ -46,16 +45,23 @@ public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest requ return mapper.convertValue(businessPartnerRepository.save(businessPartner), BusinessPartnerResponse.class); } - public BpnResponse getBusinessPartner(String name) { - BusinessPartner businessPartner = businessPartnerRepository.findByName(name); + public List getBusinessPartner(String name) { + List response = new ArrayList<>(); + List businessPartner = businessPartnerRepository.findByName(name); Validate.isTrue(Objects.isNull(businessPartner)).launch("No Business partner found with name: " + name); - return new BpnResponse(Map.of(businessPartner.getName(), businessPartner.getBpn())); + for (BusinessPartner partner : businessPartner) { + response.add(new BpnResponse(partner.getBpn(), partner.getName())); + } + return response; } - public BpnResponse getAllBusinessPartners() { + public List getAllBusinessPartners() { + List response = new ArrayList<>(); List businessPartnerList = businessPartnerRepository.findAll(); - Map bpnMap = businessPartnerList.stream().collect(Collectors.toMap(BusinessPartner::getName, BusinessPartner::getBpn, (k, v) -> v)); - return new BpnResponse(bpnMap); + for (BusinessPartner partner : businessPartnerList) { + response.add(new BpnResponse(partner.getBpn(), partner.getName())); + } + return response; } @Override diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java index d851117..622b452 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/response/BpnResponse.java @@ -1,6 +1,4 @@ package com.smartsense.chat.utils.response; -import java.util.Map; - -public record BpnResponse(Map response) { +public record BpnResponse(String bpn, String name) { } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index 53f3781..e82dc8f 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @RestController @@ -41,7 +43,7 @@ public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartne @GetBusinessPartners @GetMapping(value = "/partners", produces = APPLICATION_JSON_VALUE) - public BpnResponse getBusinessPartner(@RequestParam(required = false) String name) { + public List getBusinessPartner(@RequestParam(required = false) String name) { return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); } } From f48cecf5c051998d9535b7b3bcb9eb6d0897cbbb Mon Sep 17 00:00:00 2001 From: Dilip Dhankecha Date: Fri, 22 Nov 2024 10:49:54 +0530 Subject: [PATCH 023/100] fix: add docs folders --- deployment/docker-compose.yaml | 0 deployment/env/cofinityx/backend | 0 deployment/env/cofinityx/edc | 0 deployment/env/smartsense/backend | 0 deployment/env/smartsense/edc | 0 deployment/env/wallet/config | 0 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 deployment/docker-compose.yaml create mode 100644 deployment/env/cofinityx/backend create mode 100644 deployment/env/cofinityx/edc create mode 100644 deployment/env/smartsense/backend create mode 100644 deployment/env/smartsense/edc create mode 100644 deployment/env/wallet/config diff --git a/deployment/docker-compose.yaml b/deployment/docker-compose.yaml new file mode 100644 index 0000000..e69de29 diff --git a/deployment/env/cofinityx/backend b/deployment/env/cofinityx/backend new file mode 100644 index 0000000..e69de29 diff --git a/deployment/env/cofinityx/edc b/deployment/env/cofinityx/edc new file mode 100644 index 0000000..e69de29 diff --git a/deployment/env/smartsense/backend b/deployment/env/smartsense/backend new file mode 100644 index 0000000..e69de29 diff --git a/deployment/env/smartsense/edc b/deployment/env/smartsense/edc new file mode 100644 index 0000000..e69de29 diff --git a/deployment/env/wallet/config b/deployment/env/wallet/config new file mode 100644 index 0000000..e69de29 From b3106e6b2f151cb9bb02073eb2d8ac2f8848e89e Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 11:00:08 +0530 Subject: [PATCH 024/100] docs: deployment doc updated --- deployment/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/deployment/README.md b/deployment/README.md index 17dfecc..cd53370 100644 --- a/deployment/README.md +++ b/deployment/README.md @@ -1,29 +1,33 @@ -# Deploymet document to setup in local +# Deployment document to setup in local + +This document provide step-by-step guide line to deploy Chat application using docker compose. + +For better understanding, let's take example like Tractux-X is a operator company and we have two participant smartSense and Cofinity-X. -This document provide step-by-step guide line to deploy Chat aplication using docker compose. Once you deploy this stack, it will run below containers -- Company 1 side(provider) +- smartSense(provider) - - EDC - - Backend application - - Chat UI application -- Company 2 side(consumer) +- Cofinity-X(consumer) - - EDC - - Backend application - - Chat UI application - Common application - - SSI dim wallet stub +- - PostgreSQL database ## Data setup and initial config -- Oparator/issuer BPN: BPNL0000TRACTUSX +- Operator/issuer BPN: BPNL0000TRACTUSX - Company 1 BPN: BPNL00SMARTSENSE - Company 2 BPN: BPNL000COFINITYX -### Pre-requerment +### Pre-requirement - Docker - Docker compose From ba8677c4e8d28196f1e9995cc5e03cb03a52bc55 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Fri, 22 Nov 2024 11:23:22 +0530 Subject: [PATCH 025/100] feat: check config and user provided bpn --- .../com/smartsense/chat/service/BusinessPartnerService.java | 6 +++++- .../chat/utils/exception/GlobalExceptionHandler.java | 4 ++-- .../com/smartsense/chat/web/BusinessPartnerResource.java | 6 ++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 7acdce2..49cb3fb 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smartsense.chat.dao.entity.BusinessPartner; import com.smartsense.chat.dao.repository.BusinessPartnerRepository; +import com.smartsense.chat.edc.settings.AppConfig; import com.smartsense.chat.utils.exception.ConflictException; import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; @@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; @@ -26,10 +28,12 @@ public class BusinessPartnerService extends BaseService { private final BusinessPartnerRepository businessPartnerRepository; private final ObjectMapper mapper; + private final AppConfig config; public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest request) { log.info("Business partner request: {}", request); + Validate.isTrue(Objects.equals(config.bpn(), request.bpn())).launch("This BPN is configured. Not a valid BPN: " + request.bpn()); BusinessPartner partner = businessPartnerRepository.findByBpn(request.bpn()); if (Objects.nonNull(partner)) { String errorMessage = String.format("BusinessPartner with BPN '%s' already exists.", request.bpn()); @@ -48,7 +52,7 @@ public BusinessPartnerResponse createBusinessPartner(BusinessPartnerRequest requ public List getBusinessPartner(String name) { List response = new ArrayList<>(); List businessPartner = businessPartnerRepository.findByName(name); - Validate.isTrue(Objects.isNull(businessPartner)).launch("No Business partner found with name: " + name); + Validate.isTrue(CollectionUtils.isEmpty(businessPartner)).launch("No Business partner found with name: " + name); for (BusinessPartner partner : businessPartner) { response.add(new BpnResponse(partner.getBpn(), partner.getName())); } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java index 0ae43d0..ec639e3 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/exception/GlobalExceptionHandler.java @@ -68,8 +68,8 @@ ProblemDetail handleValidation(ConstraintViolationException exception) { @ExceptionHandler(com.smartsense.chat.utils.exception.BadDataException.class) ProblemDetail handleBadDataException(com.smartsense.chat.utils.exception.BadDataException e) { String errorMsg = ExceptionUtils.getMessage(e); - ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, errorMsg); - problemDetail.setTitle(errorMsg); + ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, e.getMessage()); + problemDetail.setTitle(e.getMessage()); problemDetail.setProperty(ContField.TIMESTAMP, System.currentTimeMillis()); return problemDetail; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index e82dc8f..b40b121 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -10,11 +10,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @@ -43,8 +41,8 @@ public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartne @GetBusinessPartners @GetMapping(value = "/partners", produces = APPLICATION_JSON_VALUE) - public List getBusinessPartner(@RequestParam(required = false) String name) { - return StringUtils.hasText(name) ? businessPartnerService.getBusinessPartner(name) : businessPartnerService.getAllBusinessPartners(); + public List getBusinessPartner() { + return businessPartnerService.getAllBusinessPartners(); } } From 21b059d8141eef97886c373e2728c8888c178271 Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 12:36:04 +0530 Subject: [PATCH 026/100] feat: chat history API --- .../chat/service/BusinessPartnerService.java | 54 +++++++++ .../chat/web/BusinessPartnerResource.java | 8 ++ .../web/apidocs/BusinessPartnersApiDocs.java | 40 +++++-- edc-chat-app-ui/src/component/add-bpn.js | 8 +- edc-chat-app-ui/src/component/chat.js | 109 +++++++++++++++--- edc-chat-app-ui/src/component/home.js | 10 +- 6 files changed, 195 insertions(+), 34 deletions(-) diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java index 49cb3fb..cca779b 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/BusinessPartnerService.java @@ -12,12 +12,14 @@ import com.smartsensesolutions.commons.dao.base.BaseRepository; import com.smartsensesolutions.commons.dao.base.BaseService; import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -78,4 +80,56 @@ public String getBusinessPartnerByBpn(String bpn) { Validate.isTrue(Objects.isNull(partner)).launch("No Business partner found with bpn: " + bpn); return partner.getEdcUrl(); } + + + @SneakyThrows + public List getChatHistory(){ + String history = """ + [ + { + "receiver": "BPNL000000000001", + "sender": "BPNL000000000TATA", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + }, + { + "receiver": "BPNL000000000TATA", + "sender": "BPNL000000000001", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + }, + { + "receiver": "BPNL000000000001", + "sender": "BPNL000000000TATA", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + }, + { + "receiver": "BPNL000000000TATA", + "sender": "BPNL000000000001", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + }, + { + "receiver": "BPNL000000000001", + "sender": "BPNL000000000TATA", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + }, + { + "receiver": "BPNL000000000TATA", + "sender": "BPNL000000000001", + "content": "Hello! How can I help you?", + "timestamp": 1700654400, + "status": "sent" + } + ] + """; + return mapper.readValue(history, List.class); + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java index b40b121..57c9378 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/BusinessPartnerResource.java @@ -5,6 +5,7 @@ import com.smartsense.chat.utils.request.BusinessPartnerRequest; import com.smartsense.chat.utils.response.BpnResponse; import com.smartsense.chat.utils.response.BusinessPartnerResponse; +import com.smartsense.chat.web.apidocs.BusinessPartnersApiDocs; import com.smartsense.chat.web.apidocs.BusinessPartnersApiDocs.CreateBusinessPartner; import com.smartsense.chat.web.apidocs.BusinessPartnersApiDocs.GetBusinessPartners; import io.swagger.v3.oas.annotations.tags.Tag; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @@ -44,5 +46,11 @@ public BusinessPartnerResponse createBusinessPartner(@RequestBody BusinessPartne public List getBusinessPartner() { return businessPartnerService.getAllBusinessPartners(); } + + @BusinessPartnersApiDocs.GetChatHistory + @GetMapping(value = "chat/history", produces = APPLICATION_JSON_VALUE) + public List getChatHistory(){ + return businessPartnerService.getChatHistory(); + } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java index 297defa..110573e 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/web/apidocs/BusinessPartnersApiDocs.java @@ -23,8 +23,8 @@ public class BusinessPartnersApiDocs { @ExampleObject(name = "Business Partner created", value = """ { "id": "89221248-4c98-4d8e-a909-d31f3ea0fa8f", - "name": "bhautik", - "bpn": "BPNL000000000001", + "name": "smartSense", + "bpn": "BPNL00SMARTSENSE", "edcUrl": "http://localhost:8090" } """) @@ -40,14 +40,40 @@ public class BusinessPartnersApiDocs { @ApiResponse(responseCode = "200", description = "Get Business Partner details by name.", content = { @Content(examples = { @ExampleObject(name = "Get Business Partner details", value = """ - { - "response": { - "bhautik": "BPNL000000000001", - "dilip": "BPNL000000000002" + [ + { + "bpn": "BPNL00SMARTSENSE", + "name": "smartSense" } - } + ] """) }) }) }) public @interface GetBusinessPartners { } + + @Target({ ElementType.TYPE, ElementType.METHOD }) + @Retention(RetentionPolicy.RUNTIME) + @Operation(description = "Get Chat history", summary = "Get Chat history") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Get Chat history", content = { + @Content(examples = { + @ExampleObject(name = "Get Chat history", value = """ + [ + { + "receiver": "BPNL000000000001", + "sender": "BPNL000000000TATA", + "content": "Hello!", + "timestamp": 1700654400 + }, + { + "receiver": "BPNL000000000TATA", + "sender": "BPNL000000000001", + "content": "Hello! How can I help you?", + "timestamp": 1700654400 + } + ] + """) + }) }) }) + public @interface GetChatHistory { + } } diff --git a/edc-chat-app-ui/src/component/add-bpn.js b/edc-chat-app-ui/src/component/add-bpn.js index b3b737a..364c97e 100644 --- a/edc-chat-app-ui/src/component/add-bpn.js +++ b/edc-chat-app-ui/src/component/add-bpn.js @@ -7,7 +7,7 @@ const AddBpn = () => { const navigate = useNavigate(); const { bpn } = location.state || {}; // Get BPN from navigation state - const [formData, setFormData] = useState({ name: "", edcUrl: "", bpn: "" }); + const [formData, setFormData] = useState({ name: "", edcUrl: "", partnerBpn: "" }); const [error, setError] = useState(null); const [success, setSuccess] = useState(null); @@ -17,7 +17,7 @@ const AddBpn = () => { }; const handleSave = async () => { - const requestData = { ...formData, bpn }; // Include BPN in the request body + const requestData = { ...formData }; // Include BPN in the request body try { const response = await axios.post(`${process.env.REACT_APP_API_BASE_URL}/partners`,JSON.stringify(requestData), { @@ -32,7 +32,7 @@ const AddBpn = () => { setError("Failed to save business partner. Please try again."); } } catch (err) { - if(err.response.status == 409){ + if(err.response.status == 409 || err.response.status == 400){ setError(err.response.data.title) }else{ setError("Network error: Unable to save business partner."); @@ -70,7 +70,7 @@ const AddBpn = () => { type="text" name="bpn" className="form-control" - value={formData.bpn} + value={formData.partnerBpn} onChange={handleInputChange} />
diff --git a/edc-chat-app-ui/src/component/chat.js b/edc-chat-app-ui/src/component/chat.js index 09e2458..3b85218 100644 --- a/edc-chat-app-ui/src/component/chat.js +++ b/edc-chat-app-ui/src/component/chat.js @@ -1,10 +1,13 @@ import React, { useState, useEffect, useRef } from "react"; import { useLocation, useNavigate } from "react-router-dom"; +import axios from "axios"; const Chat = () => { const location = useLocation(); const navigate = useNavigate(); const webSocketRef = useRef(null); + const chatContainerRef = useRef(null); // Ref to the chat container for scrolling + const [chatHistory, setChatHistory] = useState([]); const [messages, setMessages] = useState([]); // Chat messages const [newMessage, setNewMessage] = useState(""); // Current message to send @@ -12,17 +15,7 @@ const Chat = () => { const { bpn, selectedValue } = location.state || {}; - useEffect(() => { - if (!bpn || !selectedValue) { - debugger; - setError("BPN is missing. Redirecting to home..."); - setTimeout(() => navigate("/"), 3000); - return; - } else { - console.log("bpn -> " + bpn); - console.log("selected values ->" + selectedValue); - } - + const connectWs = () => { const wsUrl = "wss://example.com/chat"; // Replace with your WebSocket URL // WebSocket connection with BPN in headers (via query string) @@ -48,9 +41,59 @@ const Chat = () => { socket.close(); } }; + }; + + const scrollToBottom = () => { + // Scroll chat window to bottom + chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight; + }; + const getChatHistory = async () => { + try { + const response = await axios.get(`${process.env.REACT_APP_API_BASE_URL}/chat/history`); + if (response.status === 200) { + debugger; + const data = await response.data; + setChatHistory(data); + scrollToBottom(); + } else { + setError("Failed to fetch BPN"); + } + } catch (err) { + setError("Network error: Unable to fetch initial config"); + } + }; + + useEffect(() => { + //validate partner BPN is selected + if (!bpn || !selectedValue) { + debugger; + setError("BPN is missing. Redirecting to home..."); + setTimeout(() => navigate("/"), 3000); + return; + } else { + console.log("bpn -> " + bpn); + console.log("selected values ->" + selectedValue); + } + + //get chat history + getChatHistory(); + connectWs(); }, [bpn]); const handleSendMessage = () => { + //push + const message = { + timestamp: Math.floor(Date.now() / 1000), // Current time in seconds + content: newMessage, + sender: bpn, + receiver: selectedValue, + }; + setMessages((prevMessages) => [ + ...prevMessages, + { sender: bpn, text: message.content, timestamp: message.timestamp }, + ]); + + //TODO push message to backend, this should be first if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) { const message = { sender: "user", // Customize as needed @@ -62,11 +105,25 @@ const Chat = () => { } else { setError("WebSocket is not connected"); } + + // Clear the input field + setNewMessage(""); + + // Scroll chat window to bottom + scrollToBottom(); + }; + + const handleKeyDown = (e) => { + if (e.key === "Enter" && !e.shiftKey) { + // Only trigger on Enter without Shift + e.preventDefault(); // Prevents a new line from being added + handleSendMessage(); // Send message when Enter is pressed + } }; return (
-

Chat

+

Welcome to EDC Chat

{/* Display BPN */} {bpn && ( @@ -81,12 +138,26 @@ const Chat = () => {
)} -
- {messages.map((msg, index) => ( -

- {msg.sender}: {msg.text} -

- ))} +
+ {[...chatHistory, ...messages].map((msg, index) => { + // Determine if the message is sent by the current user + const isCurrentUser = msg.sender === bpn; + + // Format the timestamp (assumes `timestamp` is in seconds) + const formattedTimestamp = new Date(msg.timestamp * 1000).toLocaleString(); + + return ( +
+
+ {isCurrentUser ? "You" : msg.sender}: {msg.content || msg.text} +
{formattedTimestamp}
+
+
+ ); + })}
{error &&
{error}
} @@ -96,6 +167,8 @@ const Chat = () => { type="text" className="form-control me-2" value={newMessage} + onKeyDown={handleKeyDown} + rows={3} onChange={(e) => setNewMessage(e.target.value)} /> +
- - - - ); + ); }; export default AddBpn; diff --git a/edc-chat-app-ui/src/component/chat.js b/edc-chat-app-ui/src/component/chat.js index a941d95..9bebf6c 100644 --- a/edc-chat-app-ui/src/component/chat.js +++ b/edc-chat-app-ui/src/component/chat.js @@ -13,13 +13,31 @@ const Chat = () => { const [newMessage, setNewMessage] = useState(""); // Current message to send const [error, setError] = useState(null); // Error messages - const { bpn, selectedValue } = location.state || {}; + const { bpn: selfBpn, selectedValue: partnerBpn } = location.state || {}; + + useEffect(() => { + //validate partner BPN is selected + if (!selfBpn || !partnerBpn) { + setError("BPN is missing. Redirecting to home..."); + setTimeout(() => navigate("/"), 3000); + return; + } else { + console.log("bpn -> " + selfBpn); + console.log("selected values ->" + partnerBpn); + } + + //get chat history + getChatHistory(); + + //connect to WS for message transfer + connectWs(); + }, [selfBpn]); const connectWs = () => { const wsUrl = "wss://example.com/chat"; // Replace with your WebSocket URL // WebSocket connection with BPN in headers (via query string) - const socket = new WebSocket(`${wsUrl}?bpn=${bpn}`); + const socket = new WebSocket(`${wsUrl}?bpn=${selfBpn}&partnerBpn=${partnerBpn}`); webSocketRef.current = socket; @@ -47,14 +65,17 @@ const Chat = () => { // Scroll chat window to bottom const lastMessage = chatContainerRef.current?.lastElementChild; if (lastMessage) { - lastMessage.scrollIntoView({ behavior: 'smooth' }); + setTimeout(() => { + lastMessage.scrollIntoView({ behavior: "smooth" }); + }, 10); } }; const getChatHistory = async () => { try { - const response = await axios.get(`${process.env.REACT_APP_API_BASE_URL}/chat/history`); + const response = await axios.get( + `${process.env.REACT_APP_API_BASE_URL}/chat/history?partnerBpn=${partnerBpn}` + ); if (response.status === 200) { - debugger; const data = await response.data; setChatHistory(data); scrollToBottom(); @@ -66,54 +87,44 @@ const Chat = () => { } }; - useEffect(() => { - //validate partner BPN is selected - if (!bpn || !selectedValue) { - debugger; - setError("BPN is missing. Redirecting to home..."); - setTimeout(() => navigate("/"), 3000); - return; - } else { - console.log("bpn -> " + bpn); - console.log("selected values ->" + selectedValue); - } - - //get chat history - getChatHistory(); - connectWs(); - }, [bpn]); - const handleSendMessage = () => { - //push - const message = { - timestamp: Math.floor(Date.now() / 1000), // Current time in seconds - content: newMessage, - sender: bpn, - receiver: selectedValue, + //send message to backend + const chatRequest = { + message: newMessage, + receiverBpn: partnerBpn, }; - setMessages((prevMessages) => [ - ...prevMessages, - { sender: bpn, text: message.content, timestamp: message.timestamp }, - ]); - - //TODO push message to backend, this should be first - if (webSocketRef.current && webSocketRef.current.readyState === WebSocket.OPEN) { - const message = { - sender: "user", // Customize as needed - message: newMessage, - }; - webSocketRef.current.send(JSON.stringify(message)); - setMessages((prevMessages) => [...prevMessages, { sender: "You", text: newMessage }]); - setNewMessage(""); // Clear input field - } else { - setError("WebSocket is not connected"); - } - - // Clear the input field - setNewMessage(""); - - // Scroll chat window to bottom - scrollToBottom(); + const response = axios + .post(`${process.env.REACT_APP_API_BASE_URL}/chat`, JSON.stringify(chatRequest), { + headers: { + "Content-Type": "application/json", + }, + }) + .then((response) => { + console.log(response.data); + if (response.status === 200) { + const message = { + timestamp: Math.floor(Date.now() / 1000), // Current time in seconds + content: newMessage, + sender: selfBpn, + receiver: partnerBpn, + }; + setMessages((prevMessages) => [ + ...prevMessages, + { sender: selfBpn, text: message.content, timestamp: message.timestamp }, + ]); + + // Clear the input field + setNewMessage(""); + + // Scroll chat window to bottom + scrollToBottom(); + } else { + setError("Failed to send message"); + } // Print the response in the console + }) + .catch((error) => { + setError("Network error: Failed to send message."); + }); }; const handleKeyDown = (e) => { @@ -129,22 +140,23 @@ const Chat = () => {

Welcome to EDC Chat

{/* Display BPN */} - {bpn && ( -
- Your BPN: {bpn} -
- )} - - {bpn && ( -
- Partner BPN: {selectedValue} -
- )} - -
+
+ {selfBpn && ( +
+ Your BPN: {selfBpn} +
+ )} + + {partnerBpn && ( +
+ Partner BPN: {partnerBpn} +
+ )} +
+
{[...chatHistory, ...messages].map((msg, index) => { // Determine if the message is sent by the current user - const isCurrentUser = msg.sender === bpn; + const isCurrentUser = msg.sender === selfBpn; // Format the timestamp (assumes `timestamp` is in seconds) const formattedTimestamp = new Date(msg.timestamp * 1000).toLocaleString(); From 4860adf45d0cd053e9acad00d455d681a3b20037 Mon Sep 17 00:00:00 2001 From: Bhautik Sakhiya Date: Fri, 22 Nov 2024 15:32:48 +0530 Subject: [PATCH 029/100] feat: add db to store edc details and chat details and impl storing logic --- .../chat/dao/entity/ChatMessage.java | 46 ++++++ .../chat/dao/entity/EdcProcessState.java | 74 +++++++++ .../dao/repository/ChatMessageRepository.java | 9 ++ .../repository/EdcProcessStateRepository.java | 12 ++ .../com/smartsense/chat/edc/EDCService.java | 145 ++++++++++-------- .../chat/edc/manager/EDCProcessDto.java | 3 +- .../operation/AgreementFetcherService.java | 7 +- .../operation/ContractNegotiationService.java | 8 +- .../operation/PublicUrlHandlerService.java | 12 +- .../edc/operation/QueryCatalogService.java | 7 +- .../edc/operation/TransferProcessService.java | 9 +- .../chat/edc/web/EDCChatResource.java | 17 +- .../chat/service/ChatMessageService.java | 45 ++++++ .../chat/service/EdcProcessStateService.java | 26 ++++ .../chat/utils/request/ChatMessage.java | 7 - .../utils/request/ChatMessageRequest.java | 6 + .../resources/db/changelog/changes/init.sql | 27 ++++ 17 files changed, 368 insertions(+), 92 deletions(-) create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/ChatMessage.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/EdcProcessState.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/ChatMessageRepository.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/EdcProcessStateRepository.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ChatMessageService.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/service/EdcProcessStateService.java delete mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessage.java create mode 100644 edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessageRequest.java diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/ChatMessage.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/ChatMessage.java new file mode 100644 index 0000000..b86b284 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/ChatMessage.java @@ -0,0 +1,46 @@ +package com.smartsense.chat.dao.entity; + +import com.smartsensesolutions.commons.dao.base.BaseEntity; +import jakarta.persistence.*; +import lombok.*; + +import java.util.Date; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +@Table(name = "chat_messages") +public class ChatMessage implements BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "edc_process_state_id") + private EdcProcessState edcProcessState; + + @Column(name = "partner_bpn") + private String partnerBpn; + + @Column(name = "message") + private String message; + + @Column(name = "self_owner") + private Boolean selfOwner; + + @Column(name = "is_chat_success") + private boolean chatSuccess; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_at", updatable = false, nullable = false) + private Date createdAt; + + @PrePersist + void createdAt() { + createdAt = new Date(); + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/EdcProcessState.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/EdcProcessState.java new file mode 100644 index 0000000..01bbbc9 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/entity/EdcProcessState.java @@ -0,0 +1,74 @@ +package com.smartsense.chat.dao.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.smartsensesolutions.commons.dao.base.BaseEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.PrePersist; +import jakarta.persistence.PreUpdate; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Date; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +@Table(name = "edc_process_states") +public class EdcProcessState implements BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "receiver_bpn") + private String receiverBpn; + + @Column(name = "offer_id") + private String offerId; + + @Column(name = "negotiation_id") + private String negotiationId; + + @Column(name = "agreement_id") + private String agreementId; + + @Column(name = "transfer_id") + private String transferId; + + @Column(name = "error_detail") + private String errorDetail; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_at", updatable = false, nullable = false) + private Date createdAt; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_at") + @JsonIgnore + private Date updatedAt; + + @PrePersist + void createdAt() { + createdAt = new Date(); + } + + @PreUpdate + void updatedAt() { + updatedAt = new Date(); + } + +} + diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/ChatMessageRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/ChatMessageRepository.java new file mode 100644 index 0000000..29a8b67 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/ChatMessageRepository.java @@ -0,0 +1,9 @@ +package com.smartsense.chat.dao.repository; + +import com.smartsense.chat.dao.entity.ChatMessage; +import com.smartsensesolutions.commons.dao.base.BaseRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ChatMessageRepository extends BaseRepository { +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/EdcProcessStateRepository.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/EdcProcessStateRepository.java new file mode 100644 index 0000000..2ad00c9 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/dao/repository/EdcProcessStateRepository.java @@ -0,0 +1,12 @@ +package com.smartsense.chat.dao.repository; + +import com.smartsense.chat.dao.entity.EdcProcessState; +import com.smartsensesolutions.commons.dao.base.BaseRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EdcProcessStateRepository extends BaseRepository { + + EdcProcessState findByReceiverBpn(String receiverBpn); + +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java index b0dc996..557f836 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/EDCService.java @@ -1,20 +1,17 @@ package com.smartsense.chat.edc; import com.fasterxml.jackson.databind.ObjectMapper; -import com.smartsense.chat.edc.manager.EDCProcessDto; -import com.smartsense.chat.edc.manager.ProcessManagerService; +import com.smartsense.chat.dao.entity.ChatMessage; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.operation.AgreementFetcherService; import com.smartsense.chat.edc.operation.ContractNegotiationService; import com.smartsense.chat.edc.operation.PublicUrlHandlerService; import com.smartsense.chat.edc.operation.QueryCatalogService; import com.smartsense.chat.edc.operation.TransferProcessService; import com.smartsense.chat.service.BusinessPartnerService; -import com.smartsense.chat.utils.request.ChatMessage; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import com.smartsense.chat.service.ChatMessageService; +import com.smartsense.chat.service.EdcProcessStateService; +import com.smartsense.chat.utils.request.ChatRequest; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -22,6 +19,10 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.util.List; +import java.util.Map; +import java.util.Objects; + @Service @RequiredArgsConstructor @Slf4j @@ -33,10 +34,78 @@ public class EDCService { private final AgreementFetcherService agreementService; private final TransferProcessService transferProcessService; private final PublicUrlHandlerService publicUrlHandlerService; + private final EdcProcessStateService edcProcessStateService; + private final ChatMessageService chatMessageService; private final ObjectMapper mapper; - private final ProcessManagerService managerService; - private final ProcessManagerService processManagerService; + @Async + public void initProcess(ChatRequest chatMessage) { + String receiverBpnl = chatMessage.receiverBpn(); + EdcProcessState educByReceiverBpn = edcProcessStateService.getEdcByBpn(receiverBpnl); + ChatMessage chatResponse = chatMessageService.createChat(chatMessage, true); + if (Objects.nonNull(educByReceiverBpn) && StringUtils.hasText(educByReceiverBpn.getTransferId())) { + chatMessageService.updateChat(chatResponse, false, educByReceiverBpn); + publicUrlHandlerService.getAuthCodeAndPublicUrl(educByReceiverBpn.getTransferId(), chatMessage, educByReceiverBpn); + chatMessageService.updateChat(chatResponse, true, null); + return; + } + + EdcProcessState edcProcessState = new EdcProcessState(); + edcProcessState.setReceiverBpn(chatMessage.receiverBpn()); + String receiverDspUrl = partnerService.getBusinessPartnerByBpn(receiverBpnl); + + // Query the catalog for chat asset + String offerId = queryCatalogService.queryCatalog(receiverDspUrl, receiverBpnl, edcProcessState); + if (!StringUtils.hasText(offerId)) { + log.error("Not able to retrieve the offerId from EDC {}, please check manually.", receiverDspUrl); + return; + } + edcProcessState = setAndSaveEdcState("OfferId", offerId, edcProcessState); + chatMessageService.updateChat(chatResponse, false, edcProcessState); + // Initiate the contract negotiation + String negotiationId = contractNegotiationService.initNegotiation(receiverDspUrl, receiverBpnl, offerId, edcProcessState); + if (!StringUtils.hasText(negotiationId)) { + log.error("Not able to initiate the negotiation for EDC {} and offerId {}, please check manually.", receiverDspUrl, offerId); + return; + } + edcProcessState = setAndSaveEdcState("NegotiationId", negotiationId, edcProcessState); + + // Get agreement Id based on the negotiationId + String agreementId = agreementService.getAgreement(negotiationId, edcProcessState); + if (!StringUtils.hasText(agreementId)) { + log.error("Not able to get the agreement for offerId {} and negotiationId {}, please check manually.", offerId, negotiationId); + return; + } + edcProcessState = setAndSaveEdcState("AgreementId", agreementId, edcProcessState); + + // Initiate the transfer process + String transferProcessId = transferProcessService.initiateTransfer(agreementId, edcProcessState); + if (!StringUtils.hasText(transferProcessId)) { + log.error("Not able to get the agreement for transferProcessId {}, please check manually.", transferProcessId); + return; + } + edcProcessState = setAndSaveEdcState("TransferId", transferProcessId, edcProcessState); + + // Sent the message to public url + publicUrlHandlerService.getAuthCodeAndPublicUrl(transferProcessId, chatMessage, edcProcessState); + chatMessageService.updateChat(chatResponse, true, null); + } + + private EdcProcessState setAndSaveEdcState(String fieldName, String value, EdcProcessState edcProcessState) { + switch (fieldName) { + case "OfferId" -> edcProcessState.setOfferId(value); + case "NegotiationId" -> edcProcessState.setNegotiationId(value); + case "AgreementId" -> edcProcessState.setAgreementId(value); + case "TransferId" -> edcProcessState.setTransferId(value); + default -> throw new IllegalArgumentException("Unsupported field name: " + fieldName); + } + return edcProcessStateService.create(edcProcessState); + } + + public void receiveMessage(ChatRequest message) { + log.info("Received message: {}", message); + chatMessageService.createChat(message, false); + } @SneakyThrows public List getChatHistory(String partnerBpn) { @@ -88,60 +157,4 @@ public List getChatHistory(String partnerBpn) { """; return mapper.readValue(history, List.class); } - - @Async - public void initProcess(ChatMessage chatMessage) { - - EDCProcessDto processDto = processManagerService.getProcess(chatMessage.receiverBpn()); - - if (Objects.nonNull(processDto) && StringUtils.hasText(processDto.getTransferProcessId())) { - // Sent the message to public url - publicUrlHandlerService.getAuthCodeAndPublicUrl(processDto.getTransferProcessId(), chatMessage); - return; - } - - String receiverBpnl = chatMessage.receiverBpn(); - String receiverDspUrl = partnerService.getBusinessPartnerByBpn(receiverBpnl); - // Query the catalog for chat asset - String offerId = queryCatalogService.queryCatalog(receiverDspUrl, receiverBpnl); - if (!StringUtils.hasText(offerId)) { - log.error("Not able to retrieve the offerId from EDC {}, please check manually.", receiverDspUrl); - return; - } - // Initiate the contract negotiation - String negotiationId = contractNegotiationService.initNegotiation(receiverDspUrl, receiverBpnl, offerId); - if (!StringUtils.hasText(negotiationId)) { - log.error("Not able to initiate the negotiation for EDC {} and offerId {}, please check manually.", receiverDspUrl, offerId); - return; - } - // Get agreement Id based on the negotiationId - String agreementId = agreementService.getAgreement(negotiationId); - if (!StringUtils.hasText(agreementId)) { - log.error("Not able to get the agreement for offerId {} and negotiationId {}, please check manually.", offerId, negotiationId); - return; - } - // Initiate the transfer process - String transferProcessId = transferProcessService.initiateTransfer(agreementId); - if (!StringUtils.hasText(transferProcessId)) { - log.error("Not able to get the agreement for transferProcessId {}, please check manually.", transferProcessId); - return; - } - // Sent the message to public url - publicUrlHandlerService.getAuthCodeAndPublicUrl(transferProcessId, chatMessage); - - prepareProcessDto(receiverBpnl, receiverDspUrl, offerId, agreementId, transferProcessId, negotiationId); - } - - private void prepareProcessDto(String receiverBpnl, String receiverDspUrl, String offerId, String agreementId, String transferProcessId, String negotiationId) { - managerService.put(receiverBpnl, EDCProcessDto.builder() - .bpn(receiverBpnl) - .dspUrl(receiverDspUrl) - .offerId(offerId) - .negotiationId(negotiationId) - .agreementId(agreementId) - .transferProcessId(transferProcessId) - .build()); - } - - } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java index 0b6be58..8b13133 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/manager/EDCProcessDto.java @@ -13,10 +13,11 @@ @Builder public class EDCProcessDto { - private String bpn; + private String receiverBpn; private String dspUrl; private String offerId; private String negotiationId; private String agreementId; private String transferProcessId; + private String errorDetail; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java index 586219c..e8e93ab 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/AgreementFetcherService.java @@ -1,7 +1,9 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.AppConfig; +import com.smartsense.chat.service.EdcProcessStateService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -15,8 +17,9 @@ public class AgreementFetcherService { private final EDCConnectorClient edc; private final AppConfig config; + private final EdcProcessStateService edcProcessStateService; - public String getAgreement(String negotiationId) { + public String getAgreement(String negotiationId, EdcProcessState edcProcessState) { try { int count = 1; Map agreementResponse = null; @@ -38,6 +41,8 @@ public String getAgreement(String negotiationId) { } while (!agreementResponse.get("state").equals("FINALIZED") && count <= 3); return agreementId; } catch (Exception ex) { + edcProcessState.setErrorDetail(String.format("Error occurred while getting agreement information for negotiationId %s and exception is %s", negotiationId, ex.getMessage())); + edcProcessStateService.create(edcProcessState); log.error("Error occurred while getting agreement information for negotiationId {}", negotiationId, ex); return null; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java index eced62d..bdde122 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/ContractNegotiationService.java @@ -1,7 +1,9 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.AppConfig; +import com.smartsense.chat.service.EdcProcessStateService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -17,6 +19,7 @@ public class ContractNegotiationService { private final EDCConnectorClient edc; private final AppConfig config; + private final EdcProcessStateService edcProcessStateService; private static List prepareNegotiationContext() { List context = new ArrayList<>(); @@ -26,7 +29,7 @@ private static List prepareNegotiationContext() { return context; } - public String initNegotiation(String receiverDspUrl, String receiverBpnL, String offerId) { + public String initNegotiation(String receiverDspUrl, String receiverBpnL, String offerId, EdcProcessState edcProcessState) { try { log.info("Starting negotiation process with bpnl {}, dspUrl {} and offerId {}", receiverBpnL, receiverDspUrl, offerId); Map negotiationRequest = prepareNegotiationRequest(receiverDspUrl, receiverBpnL, offerId); @@ -36,10 +39,11 @@ public String initNegotiation(String receiverDspUrl, String receiverBpnL, String log.info("Contract negotiation process done for offerId {} with negotiationId {}", offerId, negotiationId); return negotiationId; } catch (Exception ex) { + edcProcessState.setErrorDetail(String.format("Error occurred while negotiating the contract offer %s with dspUrl %s and bpnl %s and Exception is %s.", offerId, receiverDspUrl, receiverBpnL, ex.getMessage())); + edcProcessStateService.create(edcProcessState); log.error("Error occurred while negotiating the contract offer {} with dspUrl {} and bpnl {}.", offerId, receiverDspUrl, receiverBpnL); return null; } - } private Map prepareNegotiationRequest(String receiverDspUrl, String receiverBpnL, String offerId) { diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java index a8ce1be..c2794d5 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/PublicUrlHandlerService.java @@ -1,9 +1,11 @@ package com.smartsense.chat.edc.operation; import com.fasterxml.jackson.databind.ObjectMapper; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.AppConfig; -import com.smartsense.chat.utils.request.ChatMessage; +import com.smartsense.chat.service.EdcProcessStateService; +import com.smartsense.chat.utils.request.ChatRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -15,13 +17,15 @@ @RequiredArgsConstructor @Slf4j public class PublicUrlHandlerService { + + private final EdcProcessStateService edcProcessStateService; private final EDCConnectorClient edc; private final ObjectMapper mapper; private final AppConfig config; - public void getAuthCodeAndPublicUrl(String transferProcessId, ChatMessage message) { + public void getAuthCodeAndPublicUrl(String transferProcessId, ChatRequest message, EdcProcessState edcProcessState) { try { - log.info("Initiate to get auth code based on transfer process id " + transferProcessId); + log.info("Initiate to get auth code based on transfer process id {}", transferProcessId); Map response = edc.getAuthCodeAndPublicUrl(config.edc().edcUri(), transferProcessId, config.edc().authCode()); log.info("Auth code and public url response -> {}", response); @@ -34,6 +38,8 @@ public void getAuthCodeAndPublicUrl(String transferProcessId, ChatMessage messag log.info("Initiate to get auth code based on transfer process id {} is done.", transferProcessId); } catch (Exception ex) { + edcProcessState.setErrorDetail(String.format("Error occurred in get auth code based on transfer process id %s and exception: %s", transferProcessId, ex.getMessage())); + edcProcessStateService.create(edcProcessState); log.error("Error occurred in get auth code based on transfer process id {} ", transferProcessId, ex); } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java index 83731ad..3e34ad7 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/QueryCatalogService.java @@ -1,7 +1,9 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.AppConfig; +import com.smartsense.chat.service.EdcProcessStateService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.json.JSONObject; @@ -18,8 +20,9 @@ public class QueryCatalogService { private final AppConfig config; private final EDCConnectorClient edc; + private final EdcProcessStateService edcProcessStateService; - public String queryCatalog(String receiverDspUrl, String receiverBpnl) { + public String queryCatalog(String receiverDspUrl, String receiverBpnl, EdcProcessState edcProcessState) { try { log.info("Creating Query Catalog process started..."); Map response = edc.queryCatalog(config.edc().edcUri(), prepareQueryCatalog(receiverDspUrl, receiverBpnl, config.edc().assetId()), config.edc().authCode()); @@ -35,6 +38,8 @@ public String queryCatalog(String receiverDspUrl, String receiverBpnl) { log.info("Received offerId {}.", offerId); return offerId; } catch (Exception ex) { + edcProcessState.setErrorDetail(String.format("Error occurred while fetching the catalog for receiverDsp %s and Bpnl %s and exception is %s", receiverDspUrl, receiverBpnl, ex.getMessage())); + edcProcessStateService.create(edcProcessState); log.error("Error occurred while fetching the catalog for receiverDsp {} and Bpnl {}", receiverDspUrl, receiverBpnl); return null; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java index 7c17a89..5dca883 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/operation/TransferProcessService.java @@ -1,7 +1,9 @@ package com.smartsense.chat.edc.operation; +import com.smartsense.chat.dao.entity.EdcProcessState; import com.smartsense.chat.edc.client.EDCConnectorClient; import com.smartsense.chat.edc.settings.AppConfig; +import com.smartsense.chat.service.EdcProcessStateService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -17,8 +19,9 @@ public class TransferProcessService { private final EDCConnectorClient edc; private final AppConfig config; + private final EdcProcessStateService edcProcessStateService; - public String initiateTransfer(String agreementId) { + public String initiateTransfer(String agreementId, EdcProcessState edcProcessState) { try { log.info("Initiate transfer process for agreement Id {}", agreementId); @@ -30,12 +33,14 @@ public String initiateTransfer(String agreementId) { log.info("Received transfer response -> {}", transferResponse); // get the transfer process id from response - String transferProcessId = transferResponse.get(0).get("transferProcessId").toString(); + String transferProcessId = transferResponse.getFirst().get("transferProcessId").toString(); log.info("Transfer process id: {}", transferProcessId); log.info("Transfer process is complete successfully for agreement Id {}", agreementId); return transferProcessId; } catch (Exception ex) { + edcProcessState.setErrorDetail(String.format("Error occurred in transfer process for agreement Id %s and Exception is %s", agreementId, ex.getMessage())); + edcProcessStateService.create(edcProcessState); log.error("Error occurred in transfer process for agreement Id {}", agreementId, ex); return null; } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java index d25094c..78a242a 100644 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/edc/web/EDCChatResource.java @@ -2,23 +2,22 @@ import com.smartsense.chat.edc.EDCService; import com.smartsense.chat.edc.settings.AppConfig; -import com.smartsense.chat.utils.request.ChatMessage; import com.smartsense.chat.utils.request.ChatRequest; import com.smartsense.chat.web.apidocs.EDCChatApiDocs; import com.smartsense.chat.web.apidocs.EDCChatApiDocs.EDCChatReceive; import io.swagger.v3.oas.annotations.tags.Tag; - -import java.util.List; -import java.util.Map; - import lombok.RequiredArgsConstructor; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.Map; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + @RestController @RequiredArgsConstructor @Tag(name = "EDC Chat management Controller", description = "This controller used to manage chat.") @@ -36,14 +35,14 @@ public List getChatHistory(@RequestParam(name = "partnerBpn") String partne @EDCChatApiDocs.Chat @PostMapping("/chat") public Map sentMessage(@RequestBody ChatRequest chatRequest) { - //TODO start init process - //edcService.initProcess(chatRequest); + edcService.initProcess(chatRequest); return Map.of("message", "Send message process has been started, please check the logs for more details."); } @EDCChatReceive @PostMapping("/chat/receive") - public Map receiveMessage(@RequestBody ChatMessage message) { + public Map receiveMessage(@RequestBody ChatRequest message) { + edcService.receiveMessage(message); return Map.of("message", "Message had been received successfully."); } } diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ChatMessageService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ChatMessageService.java new file mode 100644 index 0000000..7bc5674 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/ChatMessageService.java @@ -0,0 +1,45 @@ +package com.smartsense.chat.service; + +import com.smartsense.chat.dao.entity.ChatMessage; +import com.smartsense.chat.dao.entity.EdcProcessState; +import com.smartsense.chat.dao.repository.ChatMessageRepository; +import com.smartsense.chat.utils.request.ChatRequest; +import com.smartsensesolutions.commons.dao.base.BaseRepository; +import com.smartsensesolutions.commons.dao.base.BaseService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Objects; + +@Service +@Slf4j +@RequiredArgsConstructor +public class ChatMessageService extends BaseService { + + private final ChatMessageRepository chatMessageRepository; + + @Override + protected BaseRepository getRepository() { + return chatMessageRepository; + } + + public ChatMessage createChat(ChatRequest chatMessage, boolean isOwner) { + ChatMessage chat = ChatMessage.builder() + .message(chatMessage.message()) + .partnerBpn(chatMessage.receiverBpn()) + .selfOwner(isOwner) + .chatSuccess(false) + .edcProcessState(null) + .build(); + return create(chat); + } + + public void updateChat(ChatMessage chatMessage, boolean isChatSuccess, EdcProcessState edcState) { + chatMessage.setChatSuccess(isChatSuccess); + if (Objects.nonNull(edcState)) { + chatMessage.setEdcProcessState(edcState); + } + create(chatMessage); + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/EdcProcessStateService.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/EdcProcessStateService.java new file mode 100644 index 0000000..87ba048 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/service/EdcProcessStateService.java @@ -0,0 +1,26 @@ +package com.smartsense.chat.service; + +import com.smartsense.chat.dao.entity.EdcProcessState; +import com.smartsense.chat.dao.repository.EdcProcessStateRepository; +import com.smartsensesolutions.commons.dao.base.BaseRepository; +import com.smartsensesolutions.commons.dao.base.BaseService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +@Service +@Slf4j +@RequiredArgsConstructor +public class EdcProcessStateService extends BaseService { + + private final EdcProcessStateRepository edcProcessStateRepository; + + public EdcProcessState getEdcByBpn(String receiverBpn) { + return edcProcessStateRepository.findByReceiverBpn(receiverBpn); + } + + @Override + protected BaseRepository getRepository() { + return edcProcessStateRepository; + } +} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessage.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessage.java deleted file mode 100644 index 5667066..0000000 --- a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessage.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.smartsense.chat.utils.request; - -public record ChatMessage(String senderBpn, - String receiverBpn, - String message, - String messageId) { -} diff --git a/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessageRequest.java b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessageRequest.java new file mode 100644 index 0000000..003fde3 --- /dev/null +++ b/edc-chat-app-backend/src/main/java/com/smartsense/chat/utils/request/ChatMessageRequest.java @@ -0,0 +1,6 @@ +package com.smartsense.chat.utils.request; + +public record ChatMessageRequest(String senderBpn, + String receiverBpn, + String message) { +} diff --git a/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql b/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql index 4936563..373600a 100644 --- a/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql +++ b/edc-chat-app-backend/src/main/resources/db/changelog/changes/init.sql @@ -11,3 +11,30 @@ CREATE TABLE business_partner created_at timestamp(6) NULL DEFAULT NOW(), updated_at timestamp(6) NULL DEFAULT NOW() ); + +--changeset Bhautik:2 +CREATE TABLE edc_process_states ( + id SERIAL PRIMARY KEY, + receiver_bpn VARCHAR(20) NOT NULL, + offer_id VARCHAR(255), + negotiation_id VARCHAR(255), + agreement_id VARCHAR(255), + transfer_id VARCHAR(255), + error_detail varchar(255), + created_at timestamp(6) NULL DEFAULT NOW(), + updated_at timestamp(6) NULL DEFAULT NOW() +); + +--changeset Bhautik:3 +CREATE TABLE chat_messages ( + id SERIAL PRIMARY KEY, + edc_process_state_id INT, + partner_bpn VARCHAR(255) NOT NULL, + message TEXT NOT NULL, + self_owner BOOLEAN, + created_at timestamp(6) NULL DEFAULT NOW(), + CONSTRAINT fk_edc_process_state FOREIGN KEY (edc_process_state_id) REFERENCES edc_process_states(id) +); + +--changeset Bhautik:4 +ALTER TABLE chat_messages ADD COLUMN IF NOT EXISTS is_chat_success BOOLEAN; From 5a2a37dd1674f3bbc245c33b83cd1f34dcf7e44e Mon Sep 17 00:00:00 2001 From: Nitin Date: Fri, 22 Nov 2024 15:36:29 +0530 Subject: [PATCH 030/100] feat: validation added --- edc-chat-app-ui/src/component/add-bpn.js | 45 ++++++++++++++++++++++-- edc-chat-app-ui/src/component/chat.js | 10 ++++++ edc-chat-app-ui/src/component/home.js | 15 +++++--- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/edc-chat-app-ui/src/component/add-bpn.js b/edc-chat-app-ui/src/component/add-bpn.js index e939455..974d079 100644 --- a/edc-chat-app-ui/src/component/add-bpn.js +++ b/edc-chat-app-ui/src/component/add-bpn.js @@ -10,13 +10,47 @@ const AddBpn = () => { const [formData, setFormData] = useState({ name: "", edcUrl: "", bpn: "" }); const [error, setError] = useState(null); const [success, setSuccess] = useState(null); + const [validationErrors, setValidationErrors] = useState({ + name: false, + bpn: false, + edcUrl: false, + }); const handleInputChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); + setValidationErrors({ ...validationErrors, [name]: false }); // Reset validation error on change }; const handleSave = async () => { + // Check if any field is empty + const { name, bpn, edcUrl } = formData; + let isValid = true; + + // Set validation errors for empty fields + const errors = { name: false, bpn: false, edcUrl: false }; + if (!name.trim()) { + errors.name = true; + isValid = false; + } + if (!bpn.trim()) { + errors.bpn = true; + isValid = false; + } + if (!edcUrl.trim()) { + errors.edcUrl = true; + isValid = false; + } + setValidationErrors(errors); + + // If form is not valid, return early and show error message + if (!isValid) { + setError("All fields are required."); + return; + } + + setError(null); // Clear + const requestData = { ...formData }; // Include BPN in the request body try { @@ -43,7 +77,6 @@ const AddBpn = () => { } } }; - return (

Add New Business Partner

@@ -66,6 +99,9 @@ const AddBpn = () => { className="form-control" value={formData.name} onChange={handleInputChange} + style={{ + borderColor: validationErrors.name ? "red" : "", + }} />
@@ -76,6 +112,9 @@ const AddBpn = () => { value={formData.bpn} className="form-control" onChange={handleInputChange} + style={{ + borderColor: validationErrors.bpn ? "red" : "", + }} />
@@ -86,6 +125,9 @@ const AddBpn = () => { className="form-control" value={formData.edcUrl} onChange={handleInputChange} + style={{ + borderColor: validationErrors.edcUrl ? "red" : "", + }} />