From 0d5c79d009d8392be34e3bfb2efe62d9f76dd29f Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Fri, 10 May 2024 11:35:48 +0530 Subject: [PATCH 01/27] MOSIP-32461 intial changes Signed-off-by: Sowmya Ujjappa Banakar --- .github/workflows/push-trigger.yml | 260 ++-- registration-processor/core-processor/pom.xml | 56 +- .../pom.xml | 174 ++- .../pom.xml | 169 ++- .../middleware/stage/AbisMiddleWareStage.java | 4 +- .../registration-processor-abis/Dockerfile | 12 +- .../registration-processor-abis/pom.xml | 230 ++-- .../messagequeue/AbisMessageQueueImpl.java | 355 ++--- .../abis/service/impl/AbisServiceImpl.java | 738 +++++----- .../pom.xml | 184 ++- .../pom.xml | 195 ++- .../pom.xml | 194 ++- .../pom.xml | 169 ++- .../pom.xml | 196 ++- .../pom.xml | 234 ++-- .../adjudication/response/dto/Candidate.java | 36 +- .../response/dto/CandidateList.java | 46 +- .../stage/ManualAdjudicationStage.java | 4 +- .../ManualVerificationRequestValidator.java | 290 ++-- .../stage/ManualAdjudicationStageTest.java | 29 - .../pom.xml | 171 +-- .../pom.xml | 241 ++-- .../verification/stage/VerificationStage.java | 4 +- .../ManualVerificationRequestValidator.java | 290 ++-- registration-processor/init/pom.xml | 40 +- .../version.xml | 4 +- .../Dockerfile | 4 +- .../pom.xml | 286 ++-- .../stage/PacketReceiverStageTest.java | 29 - .../Dockerfile | 12 +- .../pom.xml | 329 +++-- .../RegistrationStatusSecurityConfig.java | 34 +- ...nalAuthDelegateServicesControllerTest.java | 294 ++-- .../PacketExternalStatusControllerTest.java | 320 ++--- ...istrationExternalStatusControllerTest.java | 460 +++---- ...gistrationStatusAndSyncControllerTest.java | 830 ++++++------ .../mosip-stage-executor/pom.xml | 62 +- registration-processor/pom.xml | 1206 ++++++++--------- registration-processor/post-processor/pom.xml | 44 +- .../pom.xml | 220 ++- .../util/CredentialPartnerUtil.java | 2 +- .../pom.xml | 200 ++- .../Dockerfile | 12 +- .../pom.xml | 342 ++--- .../RegistrationTransactionController.java | 2 +- .../TransactionServiceSecurityConfig.java | 190 ++- registration-processor/pre-processor/pom.xml | 58 +- .../pom.xml | 227 ++-- .../pom.xml | 228 ++-- .../pom.xml | 228 ++-- .../pom.xml | 237 ++-- .../PacketClassificationProcessor.java | 760 +++++------ .../tagging/impl/AgeGroupTagGenerator.java | 206 +-- .../pom.xml | 249 ++-- .../uploader/dto/CryptomanagerRequestDto.java | 106 +- .../pom.xml | 221 ++- .../stages/config/ValidatorConfig.java | 2 +- .../processor/stages/dto/AsyncRequestDTO.java | 76 +- .../stages/helper/RestHelperImpl.java | 262 ++-- .../stages/helper/RestHelperTest.java | 601 ++++---- .../pom.xml | 186 ++- .../stage/QualityClassifierStage.java | 984 +++++++------- .../pom.xml | 194 ++- .../SecurezoneNotificationStageTest.java | 1045 +++++++------- .../pom.xml | 229 ++-- .../qc-users-manger/pom.xml | 158 +-- .../pom.xml | 131 +- .../Dockerfile | 12 +- .../dependency-reduced-pom.xml | 216 +-- .../pom.xml | 308 +++-- .../intercepter/PauseFlowPredicate.java | 2 +- .../registration-processor-core/pom.xml | 11 +- .../StageHealthCheckHandler.java | 10 +- .../factory/ActiveMQMessageListener.java | 4 +- .../core/queue/factory/QueueListener.java | 2 +- .../queue/factory/QueueListenerFactory.java | 4 +- .../core/queue/impl/MosipActiveMqImpl.java | 496 +++---- .../processor/queue/MosipActiveMqTest.java | 46 +- .../pom.xml | 290 ++-- .../config/PacketStorageBeanConfig.java | 260 ++-- .../storage/utils/PacketManagerService.java | 728 +++++----- .../Dockerfile | 186 +-- .../pom.xml | 186 ++- .../pom.xml | 198 ++- .../Dockerfile | 204 +-- .../pom.xml | 264 ++-- .../NotificationControllerTest.java | 173 ++- .../pom.xml | 174 ++- .../manager/dto/CryptomanagerRequestDto.java | 134 +- .../pom.xml | 219 ++- .../status/dto/CryptomanagerRequestDto.java | 134 +- .../processor/status/dto/SearchInfo.java | 60 +- .../validator/LostRidRequestValidator.java | 490 +++---- .../PacketExternalStatusRequestValidator.java | 15 +- ...trationExternalStatusRequestValidator.java | 337 ++--- .../RegistrationStatusRequestValidator.java | 337 ++--- .../RegistrationSyncRequestValidator.java | 15 +- .../pom.xml | 153 ++- .../client/audit/dto/AuditRequestDto.java | 4 +- .../rest/client/utils/RestApiClient.java | 670 ++++----- registration-processor/stage-groups/pom.xml | 52 +- .../Dockerfile | 208 +-- .../pom.xml | 120 +- .../Dockerfile | 234 ++-- .../pom.xml | 138 +- .../Dockerfile | 194 +-- .../pom.xml | 148 +- .../Dockerfile | 236 ++-- .../pom.xml | 128 +- .../Dockerfile | 234 ++-- .../pom.xml | 160 +-- .../Dockerfile | 208 +-- .../pom.xml | 136 +- .../Dockerfile | 194 +-- .../pom.xml | 146 +- .../workflow-engine/pom.xml | 38 +- .../Dockerfile | 208 +-- .../pom.xml | 254 ++-- .../Dockerfile | 12 +- .../pom.xml | 4 +- .../workflowmanager/util/WebSubUtil.java | 2 +- .../verticle/WorkflowActionApiTest.java | 30 - .../verticle/WorkflowSearchApiTest.java | 842 ++++++------ 123 files changed, 12779 insertions(+), 13080 deletions(-) diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml index fd0f12aa220..c880e9a972b 100644 --- a/.github/workflows/push-trigger.yml +++ b/.github/workflows/push-trigger.yml @@ -1,131 +1,131 @@ -name: Maven Package upon a push - -on: - release: - types: [published] - pull_request: - types: [opened, reopened, synchronize] - - workflow_dispatch: - inputs: - message: - description: 'Message for manually triggering' - required: false - default: 'Triggered for Updates' - type: string - push: - branches: - - '!release-branch' - - release-1* - - master - - 1.* - - develop - -jobs: - build-maven-registration: - uses: mosip/kattu/.github/workflows/maven-build.yml@master - with: - SERVICE_LOCATION: ./registration-processor - BUILD_ARTIFACT: registration - secrets: - OSSRH_USER: ${{ secrets.OSSRH_USER }} - OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_SECRET: ${{ secrets.GPG_SECRET }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - publish_to_nexus: - if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}" - needs: build-maven-registration - uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master - with: - SERVICE_LOCATION: ./registration-processor - secrets: - OSSRH_USER: ${{ secrets.OSSRH_USER }} - OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_SECRET: ${{ secrets.GPG_SECRET }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - build-dockers: - needs: build-maven-registration - strategy: - matrix: - include: - - SERVICE_LOCATION: 'registration-processor/post-processor/registration-processor-registration-transaction-service' - SERVICE_NAME: 'registration-processor-registration-transaction-service' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-1' - SERVICE_NAME: 'registration-processor-stage-group-1' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-2' - SERVICE_NAME: 'registration-processor-stage-group-2' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-3' - SERVICE_NAME: 'registration-processor-stage-group-3' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-4' - SERVICE_NAME: 'registration-processor-stage-group-4' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-5' - SERVICE_NAME: 'registration-processor-stage-group-5' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-6' - SERVICE_NAME: 'registration-processor-stage-group-6' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-7' - SERVICE_NAME: 'registration-processor-stage-group-7' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/core-processor/registration-processor-abis' - SERVICE_NAME: 'registration-processor-abis' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/workflow-engine/registration-processor-reprocessor' - SERVICE_NAME: 'registration-processor-reprocessor' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/init/registration-processor-dmz-packet-server' - SERVICE_NAME: 'registration-processor-dmz-packet-server' - - SERVICE_LOCATION: 'registration-processor/init/registration-processor-registration-status-service' - SERVICE_NAME: 'registration-processor-registration-status-service' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/registration-processor-notification-service' - SERVICE_NAME: 'registration-processor-notification-service' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/registration-processor-landing-zone' - SERVICE_NAME: 'registration-processor-landing-zone' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/workflow-engine/registration-processor-workflow-manager-service' - SERVICE_NAME: 'registration-processor-workflow-manager-service' - BUILD_ARTIFACT: 'registration' - - SERVICE_LOCATION: 'registration-processor/registration-processor-common-camel-bridge' - SERVICE_NAME: 'registration-processor-common-camel-bridge' - BUILD_ARTIFACT: 'registration' - - fail-fast: false - name: ${{ matrix.SERVICE_NAME }} - uses: mosip/kattu/.github/workflows/docker-build.yml@master - with: - SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} - SERVICE_NAME: ${{ matrix.SERVICE_NAME }} - BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT || false }} - secrets: - DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} - ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} - RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} - - - sonar_analysis: - needs: build-maven-registration - if: "${{ github.event_name != 'pull_request' }}" - uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master - with: - SERVICE_LOCATION: ./registration-processor - secrets: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - ORG_KEY: ${{ secrets.ORG_KEY }} - OSSRH_USER: ${{ secrets.OSSRH_USER }} - OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_SECRET: ${{ secrets.GPG_SECRET }} +name: Maven Package upon a push + +on: + release: + types: [published] + pull_request: + types: [opened, reopened, synchronize] + + workflow_dispatch: + inputs: + message: + description: 'Message for manually triggering' + required: false + default: 'Triggered for Updates' + type: string + push: + branches: + - '!release-branch' + - release-1* + - master + - 1.* + - develop* + +jobs: + build-maven-registration: + uses: mosip/kattu/.github/workflows/maven-build.yml@master-java21 + with: + SERVICE_LOCATION: ./registration-processor + BUILD_ARTIFACT: registration + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + publish_to_nexus: + if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}" + needs: build-maven-registration + uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master-java21 + with: + SERVICE_LOCATION: ./registration-processor + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + build-dockers: + needs: build-maven-registration + strategy: + matrix: + include: + - SERVICE_LOCATION: 'registration-processor/post-processor/registration-processor-registration-transaction-service' + SERVICE_NAME: 'registration-processor-registration-transaction-service' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-1' + SERVICE_NAME: 'registration-processor-stage-group-1' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-2' + SERVICE_NAME: 'registration-processor-stage-group-2' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-3' + SERVICE_NAME: 'registration-processor-stage-group-3' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-4' + SERVICE_NAME: 'registration-processor-stage-group-4' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-5' + SERVICE_NAME: 'registration-processor-stage-group-5' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-6' + SERVICE_NAME: 'registration-processor-stage-group-6' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/stage-groups/registration-processor-stage-group-7' + SERVICE_NAME: 'registration-processor-stage-group-7' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/core-processor/registration-processor-abis' + SERVICE_NAME: 'registration-processor-abis' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/workflow-engine/registration-processor-reprocessor' + SERVICE_NAME: 'registration-processor-reprocessor' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/init/registration-processor-dmz-packet-server' + SERVICE_NAME: 'registration-processor-dmz-packet-server' + - SERVICE_LOCATION: 'registration-processor/init/registration-processor-registration-status-service' + SERVICE_NAME: 'registration-processor-registration-status-service' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/registration-processor-notification-service' + SERVICE_NAME: 'registration-processor-notification-service' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/registration-processor-landing-zone' + SERVICE_NAME: 'registration-processor-landing-zone' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/workflow-engine/registration-processor-workflow-manager-service' + SERVICE_NAME: 'registration-processor-workflow-manager-service' + BUILD_ARTIFACT: 'registration' + - SERVICE_LOCATION: 'registration-processor/registration-processor-common-camel-bridge' + SERVICE_NAME: 'registration-processor-common-camel-bridge' + BUILD_ARTIFACT: 'registration' + + fail-fast: false + name: ${{ matrix.SERVICE_NAME }} + uses: mosip/kattu/.github/workflows/docker-build.yml@master-java21 + with: + SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} + SERVICE_NAME: ${{ matrix.SERVICE_NAME }} + BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT || false }} + secrets: + DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} + ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} + RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + + sonar_analysis: + needs: build-maven-registration + if: "${{ github.event_name != 'pull_request' }}" + uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master-java21 + with: + SERVICE_LOCATION: ./registration-processor + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + ORG_KEY: ${{ secrets.ORG_KEY }} + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/registration-processor/core-processor/pom.xml b/registration-processor/core-processor/pom.xml index 516903baed7..6a030259a91 100644 --- a/registration-processor/core-processor/pom.xml +++ b/registration-processor/core-processor/pom.xml @@ -1,29 +1,29 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - core-processor - core-processor - - UTF-8 - - - registration-processor-demo-dedupe-stage - registration-processor-bio-dedupe-stage - registration-processor-uin-generator-stage - registration-processor-abis - registration-processor-manual-adjudication-stage - registration-processor-abis-handler-stage - registration-processor-abis-middleware-stage - registration-processor-biometric-authentication-stage - registration-processor-biometric-extraction-stage - registration-processor-finalization-stage - registration-processor-verification-stage - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + core-processor + core-processor + + UTF-8 + + + registration-processor-demo-dedupe-stage + registration-processor-bio-dedupe-stage + registration-processor-uin-generator-stage + registration-processor-abis + registration-processor-manual-adjudication-stage + registration-processor-abis-handler-stage + registration-processor-abis-middleware-stage + registration-processor-biometric-authentication-stage + registration-processor-biometric-extraction-stage + registration-processor-finalization-stage + registration-processor-verification-stage + \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml b/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml index 516af3bcfec..92cbea5c91a 100644 --- a/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml @@ -1,90 +1,86 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - - registration-processor-abis-handler-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - com.google.guava - guava - 30.1.1-jre - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-abis-handler-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + 1.4.195 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + com.google.guava + guava + 30.1.1-jre + + + + \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml b/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml index bc48f7ebe14..43551e7dae0 100644 --- a/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml @@ -1,92 +1,77 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-abis-middleware-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-abis-middleware-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + 1.4.195 + + + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.apache.activemq + activemq-client + 6.1.2 + + + + + + diff --git a/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/java/io/mosip/registartion/processor/abis/middleware/stage/AbisMiddleWareStage.java b/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/java/io/mosip/registartion/processor/abis/middleware/stage/AbisMiddleWareStage.java index 828ab154953..5dcd999c667 100644 --- a/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/java/io/mosip/registartion/processor/abis/middleware/stage/AbisMiddleWareStage.java +++ b/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/java/io/mosip/registartion/processor/abis/middleware/stage/AbisMiddleWareStage.java @@ -8,8 +8,8 @@ import java.util.List; import java.util.stream.Collectors; -import javax.jms.Message; -import javax.jms.TextMessage; +import jakarta.jms.Message; +import jakarta.jms.TextMessage; import org.apache.activemq.command.ActiveMQBytesMessage; import org.assertj.core.util.Arrays; diff --git a/registration-processor/core-processor/registration-processor-abis/Dockerfile b/registration-processor/core-processor/registration-processor-abis/Dockerfile index cd97d92cb64..f00e0810e81 100644 --- a/registration-processor/core-processor/registration-processor-abis/Dockerfile +++ b/registration-processor/core-processor/registration-processor-abis/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine #Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image #FROM openjdk:8-jdk-alpine @@ -49,15 +49,15 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/core-processor/registration-processor-abis/pom.xml b/registration-processor/core-processor/registration-processor-abis/pom.xml index 048eff77629..443a10c4d49 100644 --- a/registration-processor/core-processor/registration-processor-abis/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis/pom.xml @@ -1,114 +1,116 @@ - - - 4.0.0 - jar - - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-abis - 1.2.1-SNAPSHOT - registration-processor-abis - - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - junit - junit - test - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - com.h2database - h2 - - - org.postgresql - postgresql - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + jar + + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-abis + 1.2.1-java21-SNAPSHOT + registration-processor-abis + + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + junit + junit + test + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + com.h2database + h2 + + + org.postgresql + postgresql + + + org.apache.activemq + activemq-client + 6.1.2 + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/messagequeue/AbisMessageQueueImpl.java b/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/messagequeue/AbisMessageQueueImpl.java index d1caf09ddf0..fc2a6440963 100644 --- a/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/messagequeue/AbisMessageQueueImpl.java +++ b/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/messagequeue/AbisMessageQueueImpl.java @@ -1,178 +1,179 @@ -package io.mosip.registration.processor.abis.messagequeue; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; - -import javax.jms.Message; -import javax.jms.TextMessage; - -import org.apache.activemq.command.ActiveMQBytesMessage; -import org.json.simple.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.abis.exception.QueueConnectionNotFound; -import io.mosip.registration.processor.abis.queue.dto.AbisQueueDetails; -import io.mosip.registration.processor.abis.service.AbisService; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyResponseDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertResponseDto; -import io.mosip.registration.processor.core.queue.factory.MosipQueue; -import io.mosip.registration.processor.core.queue.factory.QueueListener; -import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; - -/** - * The AbisMessageQueueImpl class. - * - * @author jyoti-prakash - * @author Kiran Raj - * @author Girish Yarru - */ -@Component -public class AbisMessageQueueImpl { - - private static final String TEXT_MESSAGE = "text"; - - @Value("${activemq.message.format}") - private String messageFormat; - - /** The utilities. */ - @Autowired - Utilities utilities; - - /** The abis service. */ - @Autowired - AbisService abisService; - - /** The mosip queue manager. */ - @Autowired - private MosipQueueManager mosipQueueManager; - - /** The Constant ABIS_INSERT. */ - private static final String ABIS_INSERT = "mosip.abis.insert"; - - /** The Constant ABIS_IDENTIFY. */ - private static final String ABIS_IDENTIFY = "mosip.abis.identify"; - - /** The Constant ID. */ - private static final String ID = "id"; - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(AbisMessageQueueImpl.class); - - /** The is connection. */ - boolean isConnection = false; - - /** - * Run abis queue. - * - * @throws IOException - * Signals that an I/O exception has occurred. - * @throws RegistrationProcessorCheckedException - */ - public void runAbisQueue() throws RegistrationProcessorCheckedException { - List abisQueueDetails = utilities.getAbisQueueDetails(); - if (abisQueueDetails != null && !abisQueueDetails.isEmpty()) { - - for (int i = 0; i < abisQueueDetails.size(); i++) { - String outBoundAddress = abisQueueDetails.get(i).getOutboundQueueName(); - MosipQueue queue = abisQueueDetails.get(i).getMosipQueue(); - QueueListener listener = new QueueListener() { - @Override - public void setListener(Message message) { - consumeLogic(message, outBoundAddress, queue); - } - }; - mosipQueueManager.consume(abisQueueDetails.get(i).getMosipQueue(), - abisQueueDetails.get(i).getInboundQueueName(), listener); - } - - isConnection = true; - } else { - throw new QueueConnectionNotFound(PlatformErrorMessages.RPR_PRT_QUEUE_CONNECTION_NULL.getMessage()); - } - - } - - /** - * Consume logic. - * - * @param message - * the message - * @param abismiddlewareaddress - * the abismiddlewareaddress - * @param queue - * the queue - * @return true, if successful - */ - @SuppressWarnings("unchecked") - public boolean consumeLogic(Message message, String abismiddlewareaddress, MosipQueue queue) { - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisMessageQueueImpl::consumeLogic()::Entry()"); - boolean isrequestAddedtoQueue = false; - String response = null; - String request = null; - try { - if (messageFormat.equalsIgnoreCase(TEXT_MESSAGE)) { - TextMessage textMessage = (TextMessage) message; - request =textMessage.getText(); - } else - request = new String(((ActiveMQBytesMessage) message).getContent().data); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "---request received from abis middle ware ---" + request); - JSONObject object = JsonUtil.objectMapperReadValue(request, JSONObject.class); - ObjectMapper obj = new ObjectMapper(); - String id = (String) object.get(ID); - if (id.matches(ABIS_INSERT)) { - AbisInsertRequestDto abisInsertRequestDto = JsonUtil.objectMapperReadValue(request, AbisInsertRequestDto.class); - AbisInsertResponseDto abisInsertResponseDto = abisService.insert(abisInsertRequestDto); - response = obj.writeValueAsString(abisInsertResponseDto); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), "", - "---Insert response sent to abis middle ware ---" + response); - } - - else if (id.matches(ABIS_IDENTIFY)) { - AbisIdentifyRequestDto identifyRequestDto = JsonUtil.objectMapperReadValue(request, AbisIdentifyRequestDto.class); - AbisIdentifyResponseDto identifyResponseDto = abisService.identify(identifyRequestDto); - response = obj.writeValueAsString(identifyResponseDto); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), "", - "---Identify response sent to abis middle ware ---" + response); - } - - else { - object.put("respoQueueConnectionNotFoundnse", "invalid request"); - response = obj.writeValueAsString(object); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), "", "---invalid request received ---" + response); - } - - if (messageFormat.equalsIgnoreCase(TEXT_MESSAGE)) - isrequestAddedtoQueue = mosipQueueManager.send(queue, response, abismiddlewareaddress); - else - isrequestAddedtoQueue = mosipQueueManager.send(queue, response.getBytes("UTF-8"), abismiddlewareaddress); - - } catch (Exception e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - e.getMessage(), Arrays.toString(e.getStackTrace())); - } - - return isrequestAddedtoQueue; - } - +package io.mosip.registration.processor.abis.messagequeue; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + + + +import org.apache.activemq.command.ActiveMQBytesMessage; +import org.json.simple.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.abis.exception.QueueConnectionNotFound; +import io.mosip.registration.processor.abis.queue.dto.AbisQueueDetails; +import io.mosip.registration.processor.abis.service.AbisService; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyResponseDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertResponseDto; +import io.mosip.registration.processor.core.queue.factory.MosipQueue; +import io.mosip.registration.processor.core.queue.factory.QueueListener; +import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import jakarta.jms.Message; +import jakarta.jms.TextMessage; + +/** + * The AbisMessageQueueImpl class. + * + * @author jyoti-prakash + * @author Kiran Raj + * @author Girish Yarru + */ +@Component +public class AbisMessageQueueImpl { + + private static final String TEXT_MESSAGE = "text"; + + @Value("${activemq.message.format}") + private String messageFormat; + + /** The utilities. */ + @Autowired + Utilities utilities; + + /** The abis service. */ + @Autowired + AbisService abisService; + + /** The mosip queue manager. */ + @Autowired + private MosipQueueManager mosipQueueManager; + + /** The Constant ABIS_INSERT. */ + private static final String ABIS_INSERT = "mosip.abis.insert"; + + /** The Constant ABIS_IDENTIFY. */ + private static final String ABIS_IDENTIFY = "mosip.abis.identify"; + + /** The Constant ID. */ + private static final String ID = "id"; + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(AbisMessageQueueImpl.class); + + /** The is connection. */ + boolean isConnection = false; + + /** + * Run abis queue. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws RegistrationProcessorCheckedException + */ + public void runAbisQueue() throws RegistrationProcessorCheckedException { + List abisQueueDetails = utilities.getAbisQueueDetails(); + if (abisQueueDetails != null && !abisQueueDetails.isEmpty()) { + + for (int i = 0; i < abisQueueDetails.size(); i++) { + String outBoundAddress = abisQueueDetails.get(i).getOutboundQueueName(); + MosipQueue queue = abisQueueDetails.get(i).getMosipQueue(); + QueueListener listener = new QueueListener() { + @Override + public void setListener(Message message) { + consumeLogic(message, outBoundAddress, queue); + } + }; + mosipQueueManager.consume(abisQueueDetails.get(i).getMosipQueue(), + abisQueueDetails.get(i).getInboundQueueName(), listener); + } + + isConnection = true; + } else { + throw new QueueConnectionNotFound(PlatformErrorMessages.RPR_PRT_QUEUE_CONNECTION_NULL.getMessage()); + } + + } + + /** + * Consume logic. + * + * @param message + * the message + * @param abismiddlewareaddress + * the abismiddlewareaddress + * @param queue + * the queue + * @return true, if successful + */ + @SuppressWarnings("unchecked") + public boolean consumeLogic(Message message, String abismiddlewareaddress, MosipQueue queue) { + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisMessageQueueImpl::consumeLogic()::Entry()"); + boolean isrequestAddedtoQueue = false; + String response = null; + String request = null; + try { + if (messageFormat.equalsIgnoreCase(TEXT_MESSAGE)) { + TextMessage textMessage = (TextMessage) message; + request =textMessage.getText(); + } else + request = new String(((ActiveMQBytesMessage) message).getContent().data); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "---request received from abis middle ware ---" + request); + JSONObject object = JsonUtil.objectMapperReadValue(request, JSONObject.class); + ObjectMapper obj = new ObjectMapper(); + String id = (String) object.get(ID); + if (id.matches(ABIS_INSERT)) { + AbisInsertRequestDto abisInsertRequestDto = JsonUtil.objectMapperReadValue(request, AbisInsertRequestDto.class); + AbisInsertResponseDto abisInsertResponseDto = abisService.insert(abisInsertRequestDto); + response = obj.writeValueAsString(abisInsertResponseDto); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), "", + "---Insert response sent to abis middle ware ---" + response); + } + + else if (id.matches(ABIS_IDENTIFY)) { + AbisIdentifyRequestDto identifyRequestDto = JsonUtil.objectMapperReadValue(request, AbisIdentifyRequestDto.class); + AbisIdentifyResponseDto identifyResponseDto = abisService.identify(identifyRequestDto); + response = obj.writeValueAsString(identifyResponseDto); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), "", + "---Identify response sent to abis middle ware ---" + response); + } + + else { + object.put("respoQueueConnectionNotFoundnse", "invalid request"); + response = obj.writeValueAsString(object); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), "", "---invalid request received ---" + response); + } + + if (messageFormat.equalsIgnoreCase(TEXT_MESSAGE)) + isrequestAddedtoQueue = mosipQueueManager.send(queue, response, abismiddlewareaddress); + else + isrequestAddedtoQueue = mosipQueueManager.send(queue, response.getBytes("UTF-8"), abismiddlewareaddress); + + } catch (Exception e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + e.getMessage(), Arrays.toString(e.getStackTrace())); + } + + return isrequestAddedtoQueue; + } + } \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/service/impl/AbisServiceImpl.java b/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/service/impl/AbisServiceImpl.java index d90c9f83d1a..5f58d6279eb 100644 --- a/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/service/impl/AbisServiceImpl.java +++ b/registration-processor/core-processor/registration-processor-abis/src/main/java/io/mosip/registration/processor/abis/service/impl/AbisServiceImpl.java @@ -1,369 +1,369 @@ -package io.mosip.registration.processor.abis.service.impl; - -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.registration.processor.abis.exception.MissingMandatoryFieldsException; -import io.mosip.registration.processor.abis.service.AbisService; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyResponseDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertResponseDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisPingRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisPingResponseDto; -import io.mosip.registration.processor.core.packet.dto.abis.CandidateListDto; -import io.mosip.registration.processor.core.packet.dto.abis.CandidatesDto; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import java.io.IOException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * The Class AbisServiceImpl. - * - * @author M1048860 Kiran Raj - */ -@Service -public class AbisServiceImpl implements AbisService { - - private static final String duplicateSet = "dummy.abis.return.duplicate"; - /** The rest client service. */ - @Autowired - private RegistrationProcessorRestClientService restClientService; - - /** The Constant DUPLICATE. */ - private static final String DUPLICATE = "duplicate"; - - /** The Constant INSERT. */ - private static final String ABIS_INSERT = "mosip.abis.insert"; - - /** The Constant IDENTIFY. */ - private static final String ABIS_IDENTIFY = "mosip.abis.identify"; - - private static Set storedRefId = new HashSet<>(); - - private static Set actualStoredRefId = new HashSet<>(); - - @Autowired - private Environment env; - - /** The Constant TESTFINGERPRINT. */ - /*@Value("${TESTFINGERPRINT}") - private String testFingerPrint;*/ - - /** The Constant TESTIRIS. */ - /*@Value("${TESTIRIS}") - private String testIris;*/ - - /** The Constant TESTFACE. */ - /*@Value("${TESTFACE}") - private String testFace;*/ - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(AbisServiceImpl.class); - - @Override - public AbisInsertResponseDto insert(AbisInsertRequestDto abisInsertRequestDto) { - - AbisInsertResponseDto response = new AbisInsertResponseDto(); - String referenceId = abisInsertRequestDto.getReferenceId(); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, "AbisServiceImpl::insert()::entry"); - if (storedRefId.size() < 1000) - storedRefId.add(referenceId); - - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, " referenceId storeList " + storedRefId); - - response.setId(ABIS_INSERT); - response.setRequestId(abisInsertRequestDto.getRequestId()); - response.setResponsetime(abisInsertRequestDto.getRequesttime()); - response.setReturnValue("1"); - - //Document doc; - /*try { - //doc = getCbeffDocument(referenceId); - if (testFingerPrint == null || testIris == null || testFace == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), - referenceId, "Test Tags are not present"); - } - if (doc != null) { - NodeList fingerNodeList = doc.getElementsByTagName(testFingerPrint); - NodeList irisNodeList = doc.getElementsByTagName(testIris); - NodeList faceNodeList = doc.getElementsByTagName(testFace); - - if (fingerNodeList.getLength() > 0 || irisNodeList.getLength() > 0 || faceNodeList.getLength() > 0) { - response.setReturnValue("1"); - - } else { - response.setReturnValue("2"); - response.setFailureReason("7"); - } - } else { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), - referenceId, "AbisServiceImpl():: unable to fect CBEF file "); - response.setReturnValue("2"); - response.setFailureReason("7"); - } - response.setReturnValue("1"); - - } catch (ApisResourceAccessException | ParserConfigurationException | SAXException | IOException e) { - response.setReturnValue("2"); - response.setFailureReason("7"); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - referenceId, "ApisResourceAccessException : Unable to acces getting cbef url." - + ExceptionUtils.getStackTrace(e)); - - } catch (MissingMandatoryFieldsException e) { - response.setReturnValue("2"); - response.setFailureReason("5"); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - referenceId, "MissingMandatoryFieldsException : Mandatory fields are missing in Request." - + ExceptionUtils.getStackTrace(e)); - - } catch (Exception e) { - response.setReturnValue("2"); - response.setFailureReason("3"); - - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), - referenceId, "Due to some internal error, abis failed" + ExceptionUtils.getStackTrace(e)); - - }*/ - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, "AbisServiceImpl::insert()::exit"); - - return response; - } - - private Document getCbeffDocument(String referenceId) - throws ApisResourceAccessException, ParserConfigurationException, SAXException, IOException { - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, "AbisServiceImpl::getCbeffDocument()::entry"); - if (referenceId != null) { - List pathSegments = new ArrayList<>(); - pathSegments.add(referenceId); - - byte[] bytefile = (byte[]) restClientService.getApi(ApiName.BIODEDUPE, pathSegments, "", "", byte[].class); - if (bytefile == null) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, - "AbisServiceImpl::getCbeffDocument():: get BIODEDUPE service call ended and cbeff file is not present for the referenceID"); - } - - if (bytefile != null) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, - "AbisServiceImpl::getCbeffDocument():: get BIODEDUPE service call ended and Got Byte file from BioDedupe api"); - String byteFileStr = new String(bytefile); - - InputSource is = new InputSource(); - is.setCharacterStream(new StringReader(byteFileStr)); - - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); - dbFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - dbFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - return dBuilder.parse(is); - } - - } else { - throw new MissingMandatoryFieldsException(PlatformErrorMessages.MISSING_MANDATORY_FIELDS.getMessage()); - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), - referenceId, "AbisServiceImpl::getCbeffDocument()::exit"); - - return null; - } - - @Override - public AbisIdentifyResponseDto identify(AbisIdentifyRequestDto identifyRequest) { - boolean duplicate = false; - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::performDedupe()::entry"); - AbisIdentifyResponseDto response = new AbisIdentifyResponseDto(); - String identifyReqId = identifyRequest.getReferenceId(); - if (storedRefId.size() < 1000) - storedRefId.add(identifyReqId); - - //Document doc; - try { - //doc = getCbeffDocument(identifyReqId); - - response.setId(ABIS_IDENTIFY); - response.setRequestId(identifyRequest.getRequestId()); - response.setResponsetime(identifyRequest.getRequesttime()); - - response.setReturnValue("1"); - String duplicateIndicator = env.getProperty(duplicateSet); - if (duplicateIndicator!=null && StringUtils.isNotEmpty(duplicateIndicator) && duplicateIndicator.equalsIgnoreCase("true")) { - addCandidateList(identifyReqId, identifyRequest, response); - } - - /*if (doc != null) { - NodeList fingerNodeList = doc.getElementsByTagName(testFingerPrint); - if (fingerNodeList != null) { - duplicate = checkDuplicate(duplicate, fingerNodeList); - } - - NodeList irisNodeList = doc.getElementsByTagName(testIris); - if (irisNodeList != null) { - duplicate = checkDuplicate(duplicate, irisNodeList); - } - NodeList faceNodeList = doc.getElementsByTagName(testFace); - if (faceNodeList != null) { - duplicate = checkDuplicate(duplicate, faceNodeList); - } - response.setReturnValue("1"); - - if (duplicate) { - addCandidateList(identifyReqId, identifyRequest, response); - } - } else { - response.setReturnValue("2"); - response.setFailureReason("7"); - }*/ - - } /*catch (ApisResourceAccessException | ParserConfigurationException | SAXException | IOException e) { - response.setReturnValue("2"); - response.setFailureReason("7"); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - identifyReqId, "ApisResourceAccessException : Unable to acces getting cbef url." - + ExceptionUtils.getStackTrace(e)); - - } catch (MissingMandatoryFieldsException e) { - response.setReturnValue("2"); - response.setFailureReason("5"); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - identifyReqId, "MissingMandatoryFieldsException : Mandatory fields are missing in Request." - + ExceptionUtils.getStackTrace(e)); - - }*/ catch (Exception e) { - response.setReturnValue("2"); - response.setFailureReason("3"); - - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - identifyReqId, "Due to some internal error, abis failed" + ExceptionUtils.getStackTrace(e)); - - } - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::performDedupe()::exit"); - return response; - } - - private synchronized void addCandidateList(String identifyReqId, AbisIdentifyRequestDto identifyRequest, - AbisIdentifyResponseDto response) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::addCandidateList()::Entry"); - int count = 0; - - CandidateListDto cd = new CandidateListDto(); - if (storedRefId != null && storedRefId.size() >= 1) { - for (String refId : storedRefId) { - if (refId != null && !identifyRequest.getReferenceId().equals(refId)) { - actualStoredRefId.add(refId); - } - } - } - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::addCandidateList()::storedRefId" + storedRefId); - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::addCandidateList()::actualStoredRefId" + actualStoredRefId); - ArrayList storedRefIdList = new ArrayList<>(actualStoredRefId); - Collections.shuffle(storedRefIdList); - List candidatesDtoList = new ArrayList<>(); - if (storedRefIdList.size() > 5) { - for (int i = 0; i < 5; i++) { - if (!(identifyRequest.getReferenceId().equals(storedRefIdList.get(i)))) { - if (StringUtils.isNotEmpty(storedRefIdList.get(i)) && !storedRefIdList.get(i).equalsIgnoreCase("null")) { - CandidatesDto candidatesDto = new CandidatesDto(); - candidatesDto.setReferenceId(storedRefIdList.get(i)); - candidatesDtoList.add(candidatesDto); - count++; - } - } - } - } - - - cd.setCount(count + ""); - if (count != 0) { - cd.setCandidates(candidatesDtoList.isEmpty() ? null : getCandidateArray(candidatesDtoList)); - response.setCandidateList(cd); - } - if (storedRefId.size() < 1000) - storedRefId.add(identifyReqId); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", - "AbisServiceImpl::addCandidateList()::Exit"); - - } - - private CandidatesDto[] getCandidateArray(List candidatesDtoList) { - CandidatesDto[] candidatesDtos = new CandidatesDto[candidatesDtoList.size()]; - candidatesDtos = candidatesDtoList.toArray(candidatesDtos); - return candidatesDtos; - } - - /** - * Check duplicate. - * - * @param duplicate - * the duplicate - * @param nodeList - * the node list - * @return true, if successful - */ - private boolean checkDuplicate(boolean duplicate, NodeList nodeList) { - for (int i = 0; i < nodeList.getLength(); i++) { - String value = nodeList.item(i).getTextContent(); - if (value.equalsIgnoreCase(DUPLICATE)) { - duplicate = true; - break; - } - } - return duplicate; - } - - /* - * (non-Javadoc) - * - * @see io.mosip.registration.processor.abis.service.impl.AbisService#delete() - */ - @Override - public void delete() { - // Delete should be implemented in future - } - - @Override - public AbisPingResponseDto ping(AbisPingRequestDto abisPingRequestDto) { - // Ping should be implemented in future - return null; - } -} +package io.mosip.registration.processor.abis.service.impl; + +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.registration.processor.abis.exception.MissingMandatoryFieldsException; +import io.mosip.registration.processor.abis.service.AbisService; +import io.mosip.registration.processor.core.code.ApiName; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisIdentifyResponseDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisInsertResponseDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisPingRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisPingResponseDto; +import io.mosip.registration.processor.core.packet.dto.abis.CandidateListDto; +import io.mosip.registration.processor.core.packet.dto.abis.CandidatesDto; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import java.io.IOException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * The Class AbisServiceImpl. + * + * @author M1048860 Kiran Raj + */ +@Service +public class AbisServiceImpl implements AbisService { + + private static final String duplicateSet = "dummy.abis.return.duplicate"; + /** The rest client service. */ + @Autowired + private RegistrationProcessorRestClientService restClientService; + + /** The Constant DUPLICATE. */ + private static final String DUPLICATE = "duplicate"; + + /** The Constant INSERT. */ + private static final String ABIS_INSERT = "mosip.abis.insert"; + + /** The Constant IDENTIFY. */ + private static final String ABIS_IDENTIFY = "mosip.abis.identify"; + + private static Set storedRefId = new HashSet<>(); + + private static Set actualStoredRefId = new HashSet<>(); + + @Autowired + private Environment env; + + /** The Constant TESTFINGERPRINT. */ + /*@Value("${TESTFINGERPRINT}") + private String testFingerPrint;*/ + + /** The Constant TESTIRIS. */ + /*@Value("${TESTIRIS}") + private String testIris;*/ + + /** The Constant TESTFACE. */ + /*@Value("${TESTFACE}") + private String testFace;*/ + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(AbisServiceImpl.class); + + @Override + public AbisInsertResponseDto insert(AbisInsertRequestDto abisInsertRequestDto) { + + AbisInsertResponseDto response = new AbisInsertResponseDto(); + String referenceId = abisInsertRequestDto.getReferenceId(); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, "AbisServiceImpl::insert()::entry"); + if (storedRefId.size() < 1000) + storedRefId.add(referenceId); + + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, " referenceId storeList " + storedRefId); + + response.setId(ABIS_INSERT); + response.setRequestId(abisInsertRequestDto.getRequestId()); + response.setResponsetime(abisInsertRequestDto.getRequesttime()); + response.setReturnValue("1"); + + //Document doc; + /*try { + //doc = getCbeffDocument(referenceId); + if (testFingerPrint == null || testIris == null || testFace == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), + referenceId, "Test Tags are not present"); + } + if (doc != null) { + NodeList fingerNodeList = doc.getElementsByTagName(testFingerPrint); + NodeList irisNodeList = doc.getElementsByTagName(testIris); + NodeList faceNodeList = doc.getElementsByTagName(testFace); + + if (fingerNodeList.getLength() > 0 || irisNodeList.getLength() > 0 || faceNodeList.getLength() > 0) { + response.setReturnValue("1"); + + } else { + response.setReturnValue("2"); + response.setFailureReason("7"); + } + } else { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), + referenceId, "AbisServiceImpl():: unable to fect CBEF file "); + response.setReturnValue("2"); + response.setFailureReason("7"); + } + response.setReturnValue("1"); + + } catch (ApisResourceAccessException | ParserConfigurationException | SAXException | IOException e) { + response.setReturnValue("2"); + response.setFailureReason("7"); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + referenceId, "ApisResourceAccessException : Unable to acces getting cbef url." + + ExceptionUtils.getStackTrace(e)); + + } catch (MissingMandatoryFieldsException e) { + response.setReturnValue("2"); + response.setFailureReason("5"); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + referenceId, "MissingMandatoryFieldsException : Mandatory fields are missing in Request." + + ExceptionUtils.getStackTrace(e)); + + } catch (Exception e) { + response.setReturnValue("2"); + response.setFailureReason("3"); + + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFFERENCEID.toString(), + referenceId, "Due to some internal error, abis failed" + ExceptionUtils.getStackTrace(e)); + + }*/ + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, "AbisServiceImpl::insert()::exit"); + + return response; + } + + private Document getCbeffDocument(String referenceId) + throws ApisResourceAccessException, ParserConfigurationException, SAXException, IOException { + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, "AbisServiceImpl::getCbeffDocument()::entry"); + if (referenceId != null) { + List pathSegments = new ArrayList<>(); + pathSegments.add(referenceId); + + byte[] bytefile = (byte[]) restClientService.getApi(ApiName.BIODEDUPE, pathSegments, "", "", byte[].class); + if (bytefile == null) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, + "AbisServiceImpl::getCbeffDocument():: get BIODEDUPE service call ended and cbeff file is not present for the referenceID"); + } + + if (bytefile != null) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, + "AbisServiceImpl::getCbeffDocument():: get BIODEDUPE service call ended and Got Byte file from BioDedupe api"); + String byteFileStr = new String(bytefile); + + InputSource is = new InputSource(); + is.setCharacterStream(new StringReader(byteFileStr)); + + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + dbFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); + dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); + dbFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); + dbFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); + DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); + return dBuilder.parse(is); + } + + } else { + throw new MissingMandatoryFieldsException(PlatformErrorMessages.MISSING_MANDATORY_FIELDS.getMessage()); + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REFERENCEID.toString(), + referenceId, "AbisServiceImpl::getCbeffDocument()::exit"); + + return null; + } + + @Override + public AbisIdentifyResponseDto identify(AbisIdentifyRequestDto identifyRequest) { + boolean duplicate = false; + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::performDedupe()::entry"); + AbisIdentifyResponseDto response = new AbisIdentifyResponseDto(); + String identifyReqId = identifyRequest.getReferenceId(); + if (storedRefId.size() < 1000) + storedRefId.add(identifyReqId); + + //Document doc; + try { + //doc = getCbeffDocument(identifyReqId); + + response.setId(ABIS_IDENTIFY); + response.setRequestId(identifyRequest.getRequestId()); + response.setResponsetime(identifyRequest.getRequesttime()); + + response.setReturnValue("1"); + String duplicateIndicator = env.getProperty(duplicateSet); + if (duplicateIndicator!=null && StringUtils.isNotEmpty(duplicateIndicator) && duplicateIndicator.equalsIgnoreCase("true")) { + addCandidateList(identifyReqId, identifyRequest, response); + } + + /*if (doc != null) { + NodeList fingerNodeList = doc.getElementsByTagName(testFingerPrint); + if (fingerNodeList != null) { + duplicate = checkDuplicate(duplicate, fingerNodeList); + } + + NodeList irisNodeList = doc.getElementsByTagName(testIris); + if (irisNodeList != null) { + duplicate = checkDuplicate(duplicate, irisNodeList); + } + NodeList faceNodeList = doc.getElementsByTagName(testFace); + if (faceNodeList != null) { + duplicate = checkDuplicate(duplicate, faceNodeList); + } + response.setReturnValue("1"); + + if (duplicate) { + addCandidateList(identifyReqId, identifyRequest, response); + } + } else { + response.setReturnValue("2"); + response.setFailureReason("7"); + }*/ + + } /*catch (ApisResourceAccessException | ParserConfigurationException | SAXException | IOException e) { + response.setReturnValue("2"); + response.setFailureReason("7"); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + identifyReqId, "ApisResourceAccessException : Unable to acces getting cbef url." + + ExceptionUtils.getStackTrace(e)); + + } catch (MissingMandatoryFieldsException e) { + response.setReturnValue("2"); + response.setFailureReason("5"); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + identifyReqId, "MissingMandatoryFieldsException : Mandatory fields are missing in Request." + + ExceptionUtils.getStackTrace(e)); + + }*/ catch (Exception e) { + response.setReturnValue("2"); + response.setFailureReason("3"); + + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + identifyReqId, "Due to some internal error, abis failed" + ExceptionUtils.getStackTrace(e)); + + } + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::performDedupe()::exit"); + return response; + } + + private synchronized void addCandidateList(String identifyReqId, AbisIdentifyRequestDto identifyRequest, + AbisIdentifyResponseDto response) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::addCandidateList()::Entry"); + int count = 0; + + CandidateListDto cd = new CandidateListDto(); + if (storedRefId != null && storedRefId.size() >= 1) { + for (String refId : storedRefId) { + if (refId != null && !identifyRequest.getReferenceId().equals(refId)) { + actualStoredRefId.add(refId); + } + } + } + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::addCandidateList()::storedRefId" + storedRefId); + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::addCandidateList()::actualStoredRefId" + actualStoredRefId); + ArrayList storedRefIdList = new ArrayList<>(actualStoredRefId); + Collections.shuffle(storedRefIdList); + List candidatesDtoList = new ArrayList<>(); + if (storedRefIdList.size() > 5) { + for (int i = 0; i < 5; i++) { + if (!(identifyRequest.getReferenceId().equals(storedRefIdList.get(i)))) { + if (StringUtils.isNotEmpty(storedRefIdList.get(i)) && !storedRefIdList.get(i).equalsIgnoreCase("null")) { + CandidatesDto candidatesDto = new CandidatesDto(); + candidatesDto.setReferenceId(storedRefIdList.get(i)); + candidatesDtoList.add(candidatesDto); + count++; + } + } + } + } + + + cd.setCount(count + ""); + if (count != 0) { + cd.setCandidates(candidatesDtoList.isEmpty() ? null : getCandidateArray(candidatesDtoList)); + response.setCandidateList(cd); + } + if (storedRefId.size() < 1000) + storedRefId.add(identifyReqId); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), "", + "AbisServiceImpl::addCandidateList()::Exit"); + + } + + private CandidatesDto[] getCandidateArray(List candidatesDtoList) { + CandidatesDto[] candidatesDtos = new CandidatesDto[candidatesDtoList.size()]; + candidatesDtos = candidatesDtoList.toArray(candidatesDtos); + return candidatesDtos; + } + + /** + * Check duplicate. + * + * @param duplicate + * the duplicate + * @param nodeList + * the node list + * @return true, if successful + */ + private boolean checkDuplicate(boolean duplicate, NodeList nodeList) { + for (int i = 0; i < nodeList.getLength(); i++) { + String value = nodeList.item(i).getTextContent(); + if (value.equalsIgnoreCase(DUPLICATE)) { + duplicate = true; + break; + } + } + return duplicate; + } + + /* + * (non-Javadoc) + * + * @see io.mosip.registration.processor.abis.service.impl.AbisService#delete() + */ + @Override + public void delete() { + // Delete should be implemented in future + } + + @Override + public AbisPingResponseDto ping(AbisPingRequestDto abisPingRequestDto) { + // Ping should be implemented in future + return null; + } +} diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/pom.xml b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/pom.xml index c61dee6d983..7fd87d81df7 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/pom.xml @@ -1,95 +1,89 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - - registration-processor-bio-dedupe-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-bio-dedupe-service-impl - ${packet.bio.dedupe.service.impl.version} - - - junit - junit - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-bio-dedupe-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-bio-dedupe-service-impl + ${packet.bio.dedupe.service.impl.version} + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + + + + diff --git a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/pom.xml b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/pom.xml index 9e94623d1c1..10d1e68f819 100644 --- a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/pom.xml @@ -1,100 +1,95 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-biometric-authentication-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-biometric-authentication-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + diff --git a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml index 8315f465b9a..e1e26c4ee41 100644 --- a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml @@ -1,100 +1,96 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-biometric-extraction-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-biometric-extraction-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/pom.xml b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/pom.xml index b50b1103ba7..565a812da95 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/pom.xml @@ -1,87 +1,82 @@ - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-demo-dedupe-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-demo-dedupe-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + + + + diff --git a/registration-processor/core-processor/registration-processor-finalization-stage/pom.xml b/registration-processor/core-processor/registration-processor-finalization-stage/pom.xml index 7c17b49d64c..86c364f8e48 100644 --- a/registration-processor/core-processor/registration-processor-finalization-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-finalization-stage/pom.xml @@ -1,101 +1,95 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-finalization-stage - registration-processor-finalization-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-finalization-stage + registration-processor-finalization-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml index 37b73b60700..c145fe1cedc 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml @@ -1,122 +1,112 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - - registration-processor-manual-adjudication-stage - 1.2.1-SNAPSHOT - - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - com.h2database - h2 - 1.4.195 - - - - - - - org.apache.httpcomponents - httpmime - 4.3.1 - - - org.springframework - spring-context - 5.0.6.RELEASE - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - junit - junit - test - ${junit.version} - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - org.postgresql - postgresql - - - com.h2database - h2 - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.scala-lang - scala-library - 2.11.0 - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-manual-adjudication-stage + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + com.h2database + h2 + + + + + + + org.apache.httpcomponents + httpmime + 4.3.1 + + + org.springframework + spring-context + + + junit + junit + test + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + org.postgresql + postgresql + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.scala-lang + scala-library + 2.11.0 + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.apache.activemq + activemq-client + 6.1.2 + + + + + + diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/Candidate.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/Candidate.java index 6b332302151..352fffd6640 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/Candidate.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/Candidate.java @@ -1,18 +1,18 @@ -package io.mosip.registration.processor.adjudication.response.dto; - -import lombok.Data; -import org.json.simple.JSONObject; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Data -public class Candidate { - - @NotNull - @NotBlank - private String referenceId; - - private JSONObject analytics; - -} +package io.mosip.registration.processor.adjudication.response.dto; + +import lombok.Data; +import org.json.simple.JSONObject; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +@Data +public class Candidate { + + @NotNull + @NotBlank + private String referenceId; + + private JSONObject analytics; + +} diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/CandidateList.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/CandidateList.java index 3f83048b2dd..d1430877098 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/CandidateList.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/response/dto/CandidateList.java @@ -1,23 +1,23 @@ -package io.mosip.registration.processor.adjudication.response.dto; - -import java.util.List; -import java.util.Map; - -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Data -public class CandidateList { - - @NotNull - private Integer count; - /** - * Analytics will be dumped in the manual verification table hence its expected as - * key value pair of String and Object. - */ - private Map analytics; - private List candidates; - - -} +package io.mosip.registration.processor.adjudication.response.dto; + +import java.util.List; +import java.util.Map; + +import lombok.Data; + +import jakarta.validation.constraints.NotNull; + +@Data +public class CandidateList { + + @NotNull + private Integer count; + /** + * Analytics will be dumped in the manual verification table hence its expected as + * key value pair of String and Object. + */ + private Map analytics; + private List candidates; + + +} diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/stage/ManualAdjudicationStage.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/stage/ManualAdjudicationStage.java index 18291d13f5c..47fb2ced5b9 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/stage/ManualAdjudicationStage.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/stage/ManualAdjudicationStage.java @@ -2,8 +2,8 @@ import java.util.List; -import javax.jms.Message; -import javax.jms.TextMessage; +import jakarta.jms.Message; +import jakarta.jms.TextMessage; import org.apache.activemq.command.ActiveMQBytesMessage; import org.apache.activemq.command.ActiveMQTextMessage; diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/util/ManualVerificationRequestValidator.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/util/ManualVerificationRequestValidator.java index 6f00856e260..76189c5e06b 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/util/ManualVerificationRequestValidator.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/util/ManualVerificationRequestValidator.java @@ -1,142 +1,148 @@ -package io.mosip.registration.processor.adjudication.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.TimeZone; - -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; -import org.springframework.stereotype.Component; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.adjudication.constants.ManualAdjudicationConstants; -import io.mosip.registration.processor.adjudication.exception.ManualVerificationAppException; -import io.mosip.registration.processor.adjudication.exception.ManualVerificationValidationException; -import io.vertx.core.json.JsonObject; - -/** - * The Class ManualVerificationRequestValidator. - * @author Rishabh Keshari - */ -@Component -public class ManualVerificationRequestValidator{ - - - /** The mosip logger. */ - Logger regProcLogger = RegProcessorLogger.getLogger(ManualVerificationRequestValidator.class); - - - /** The env. */ - @Autowired - private Environment env; - - /** The id. */ - // @Resource - private Map id=new HashMap<>(); - - /** The grace period. */ - @Value("${mosip.registration.processor.grace.period}") - private int gracePeriod; - - /** - * Validate. - * - * @param obj the obj - * @param serviceId the service id - * @throws ManualVerificationAppException the manual verification app exception - */ - public void validate(JsonObject obj,String serviceId){ - id.put("manual", serviceId); - validateId(obj.getString("id")); - validateVersion(obj.getString("version")); - validateReqTime(obj.getString("requesttime")); - } - - - - - - /** - * Validate id. - * - * @param id the id - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateId(String id) { - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(id)) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_ID,exception); - } else if (!this.id.containsValue(id)) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_ID,exception); - - } - } - - /** - * Validate ver. - * - * @param ver the ver - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateVersion(String ver){ - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(ver)) { - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_VERSION,exception); - - } else if ((!ManualAdjudicationConstants.verPattern.matcher(ver).matches())) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_VERSION,exception); - } - } - - - /** - * Validate req time. - * - * @param timestamp the timestamp - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateReqTime(String timestamp){ - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(timestamp)) { - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_TIMESTAMP,exception); - - } else { - try { - if (Objects.nonNull(env.getProperty(ManualAdjudicationConstants.DATETIME_PATTERN))) { - DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( - env.getProperty(ManualAdjudicationConstants.DATETIME_PATTERN)); - timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(ManualAdjudicationConstants.DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { - - regProcLogger.error(ManualAdjudicationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", - "\n" + PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); - } - - } - } catch (IllegalArgumentException e) { - regProcLogger.error(ManualAdjudicationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", - "\n" + ExceptionUtils.getStackTrace(e)); - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); - } - } - } - - -} +package io.mosip.registration.processor.adjudication.util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.TimeZone; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; +import org.springframework.stereotype.Component; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.adjudication.constants.ManualAdjudicationConstants; +import io.mosip.registration.processor.adjudication.exception.ManualVerificationAppException; +import io.mosip.registration.processor.adjudication.exception.ManualVerificationValidationException; +import io.vertx.core.json.JsonObject; + +/** + * The Class ManualVerificationRequestValidator. + * @author Rishabh Keshari + */ +@Component +public class ManualVerificationRequestValidator{ + + + /** The mosip logger. */ + Logger regProcLogger = RegProcessorLogger.getLogger(ManualVerificationRequestValidator.class); + + + /** The env. */ + @Autowired + private Environment env; + + /** The id. */ + // @Resource + private Map id=new HashMap<>(); + + /** The grace period. */ + @Value("${mosip.registration.processor.grace.period}") + private int gracePeriod; + + /** + * Validate. + * + * @param obj the obj + * @param serviceId the service id + * @throws ManualVerificationAppException the manual verification app exception + */ + public void validate(JsonObject obj,String serviceId){ + id.put("manual", serviceId); + validateId(obj.getString("id")); + validateVersion(obj.getString("version")); + validateReqTime(obj.getString("requesttime")); + } + + + + + + /** + * Validate id. + * + * @param id the id + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateId(String id) { + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(id)) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_ID,exception); + } else if (!this.id.containsValue(id)) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_ID,exception); + + } + } + + /** + * Validate ver. + * + * @param ver the ver + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateVersion(String ver){ + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(ver)) { + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_VERSION,exception); + + } else if ((!ManualAdjudicationConstants.verPattern.matcher(ver).matches())) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_VERSION,exception); + } + } + + + /** + * Validate req time. + * + * @param timestamp the timestamp + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateReqTime(String timestamp){ + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(timestamp)) { + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_TIMESTAMP,exception); + + } else { + try { + if (Objects.nonNull(env.getProperty(ManualAdjudicationConstants.DATETIME_PATTERN))) { + DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( + env.getProperty(ManualAdjudicationConstants.DATETIME_PATTERN)); + timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(ManualAdjudicationConstants.DATETIME_TIMEZONE))); + DateTimeFormatter formatter = DateTimeFormatter + .ofPattern(env.getProperty(ManualAdjudicationConstants.DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { + + regProcLogger.error(ManualAdjudicationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", + "\n" + PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); + } + + } + } catch (IllegalArgumentException e) { + regProcLogger.error(ManualAdjudicationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", + "\n" + ExceptionUtils.getStackTrace(e)); + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); + } + } + } + + +} diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java index f7d06c6fca0..f62b9e491ae 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java @@ -481,35 +481,6 @@ public int addBodyEndHandler(Handler handler) { public List acceptableLocales() { return null; } - - @Override - public void fail(int statusCode, Throwable throwable) { - } - - @Override - public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { - return null; - } - - @Override - public Map cookieMap() { - return null; - } - - @Override - public boolean isSessionAccessed() { - return false; - } - - @Override - public int addEndHandler(Handler> handler) { - return 0; - } - - @Override - public boolean removeEndHandler(int handlerID) { - return false; - } }; } diff --git a/registration-processor/core-processor/registration-processor-uin-generator-stage/pom.xml b/registration-processor/core-processor/registration-processor-uin-generator-stage/pom.xml index bf344cfaabe..862e13856cf 100644 --- a/registration-processor/core-processor/registration-processor-uin-generator-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-uin-generator-stage/pom.xml @@ -1,96 +1,75 @@ - - 4.0.0 - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - registration-processor-uin-generator-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + 4.0.0 + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-uin-generator-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + + + + diff --git a/registration-processor/core-processor/registration-processor-verification-stage/pom.xml b/registration-processor/core-processor/registration-processor-verification-stage/pom.xml index 53aa7f44800..4f2f719067c 100644 --- a/registration-processor/core-processor/registration-processor-verification-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-verification-stage/pom.xml @@ -1,122 +1,119 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - core-processor - 1.2.1-SNAPSHOT - - - registration-processor-verification-stage - 1.2.1-SNAPSHOT - - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - com.h2database - h2 - 1.4.195 - - - - - - - org.apache.httpcomponents - httpmime - 4.3.1 - - - org.springframework - spring-context - 5.0.6.RELEASE - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - junit - junit - test - ${junit.version} - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - org.postgresql - postgresql - - - com.h2database - h2 - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.scala-lang - scala-library - 2.11.0 - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + core-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-verification-stage + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + com.h2database + h2 + + + io.mosip.kernel + kernel-bom + 1.2.1-java21-SNAPSHOT + pom + import + + + + + + + org.apache.httpcomponents + httpmime + 4.3.1 + + + org.springframework + spring-context + + + junit + junit + test + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + org.postgresql + postgresql + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.scala-lang + scala-library + 2.11.0 + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.apache.activemq + activemq-client + 6.1.2 + + + + + + diff --git a/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/stage/VerificationStage.java b/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/stage/VerificationStage.java index 5a6ed1b15ff..bde7b62a48f 100644 --- a/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/stage/VerificationStage.java +++ b/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/stage/VerificationStage.java @@ -2,8 +2,8 @@ import java.util.List; -import javax.jms.Message; -import javax.jms.TextMessage; +import jakarta.jms.Message; +import jakarta.jms.TextMessage; import org.apache.activemq.command.ActiveMQBytesMessage; import org.apache.activemq.command.ActiveMQTextMessage; diff --git a/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/util/ManualVerificationRequestValidator.java b/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/util/ManualVerificationRequestValidator.java index 0a7b2d4b65d..6ea208596c3 100644 --- a/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/util/ManualVerificationRequestValidator.java +++ b/registration-processor/core-processor/registration-processor-verification-stage/src/main/java/io/mosip/registration/processor/verification/util/ManualVerificationRequestValidator.java @@ -1,142 +1,148 @@ -package io.mosip.registration.processor.verification.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.TimeZone; - -import io.mosip.registration.processor.verification.exception.ManualVerificationAppException; -import io.mosip.registration.processor.verification.exception.ManualVerificationValidationException; -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; -import org.springframework.stereotype.Component; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.verification.constants.VerificationConstants; -import io.vertx.core.json.JsonObject; - -/** - * The Class ManualVerificationRequestValidator. - * @author Rishabh Keshari - */ -@Component -public class ManualVerificationRequestValidator{ - - - /** The mosip logger. */ - Logger regProcLogger = RegProcessorLogger.getLogger(ManualVerificationRequestValidator.class); - - - /** The env. */ - @Autowired - private Environment env; - - /** The id. */ - // @Resource - private Map id=new HashMap<>(); - - /** The grace period. */ - @Value("${mosip.registration.processor.grace.period}") - private int gracePeriod; - - /** - * Validate. - * - * @param obj the obj - * @param serviceId the service id - * @throws ManualVerificationAppException the manual verification app exception - */ - public void validate(JsonObject obj,String serviceId){ - id.put("manual", serviceId); - validateId(obj.getString("id")); - validateVersion(obj.getString("version")); - validateReqTime(obj.getString("requesttime")); - } - - - - - - /** - * Validate id. - * - * @param id the id - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateId(String id) { - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(id)) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_ID,exception); - } else if (!this.id.containsValue(id)) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_ID,exception); - - } - } - - /** - * Validate ver. - * - * @param ver the ver - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateVersion(String ver){ - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(ver)) { - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_VERSION,exception); - - } else if ((!VerificationConstants.verPattern.matcher(ver).matches())) { - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_VERSION,exception); - } - } - - - /** - * Validate req time. - * - * @param timestamp the timestamp - * @throws ManualVerificationAppException the manual verification app exception - */ - private void validateReqTime(String timestamp){ - ManualVerificationValidationException exception = new ManualVerificationValidationException(); - - if (Objects.isNull(timestamp)) { - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_TIMESTAMP,exception); - - } else { - try { - if (Objects.nonNull(env.getProperty(VerificationConstants.DATETIME_PATTERN))) { - DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( - env.getProperty(VerificationConstants.DATETIME_PATTERN)); - timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(VerificationConstants.DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { - - regProcLogger.error(VerificationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", - "\n" + PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); - - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); - } - - } - } catch (IllegalArgumentException e) { - regProcLogger.error(VerificationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", - "\n" + ExceptionUtils.getStackTrace(e)); - throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); - } - } - } - - -} +package io.mosip.registration.processor.verification.util; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.TimeZone; + +import io.mosip.registration.processor.verification.exception.ManualVerificationAppException; +import io.mosip.registration.processor.verification.exception.ManualVerificationValidationException; +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; +import org.springframework.stereotype.Component; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.verification.constants.VerificationConstants; +import io.vertx.core.json.JsonObject; + +/** + * The Class ManualVerificationRequestValidator. + * @author Rishabh Keshari + */ +@Component +public class ManualVerificationRequestValidator{ + + + /** The mosip logger. */ + Logger regProcLogger = RegProcessorLogger.getLogger(ManualVerificationRequestValidator.class); + + + /** The env. */ + @Autowired + private Environment env; + + /** The id. */ + // @Resource + private Map id=new HashMap<>(); + + /** The grace period. */ + @Value("${mosip.registration.processor.grace.period}") + private int gracePeriod; + + /** + * Validate. + * + * @param obj the obj + * @param serviceId the service id + * @throws ManualVerificationAppException the manual verification app exception + */ + public void validate(JsonObject obj,String serviceId){ + id.put("manual", serviceId); + validateId(obj.getString("id")); + validateVersion(obj.getString("version")); + validateReqTime(obj.getString("requesttime")); + } + + + + + + /** + * Validate id. + * + * @param id the id + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateId(String id) { + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(id)) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_ID,exception); + } else if (!this.id.containsValue(id)) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_ID,exception); + + } + } + + /** + * Validate ver. + * + * @param ver the ver + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateVersion(String ver){ + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(ver)) { + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_VERSION,exception); + + } else if ((!VerificationConstants.verPattern.matcher(ver).matches())) { + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_VERSION,exception); + } + } + + + /** + * Validate req time. + * + * @param timestamp the timestamp + * @throws ManualVerificationAppException the manual verification app exception + */ + private void validateReqTime(String timestamp){ + ManualVerificationValidationException exception = new ManualVerificationValidationException(); + + if (Objects.isNull(timestamp)) { + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_MISSING_INPUT_PARAMETER_TIMESTAMP,exception); + + } else { + try { + if (Objects.nonNull(env.getProperty(VerificationConstants.DATETIME_PATTERN))) { + DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( + env.getProperty(VerificationConstants.DATETIME_PATTERN)); + timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(VerificationConstants.DATETIME_TIMEZONE))); + DateTimeFormatter formatter = DateTimeFormatter + .ofPattern(env.getProperty(VerificationConstants.DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { + + regProcLogger.error(VerificationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", + "\n" + PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); + + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); + } + + } + } catch (IllegalArgumentException e) { + regProcLogger.error(VerificationConstants.MAN_VERI_SERVICE, "ManReqRequestValidator", "validateReqTime", + "\n" + ExceptionUtils.getStackTrace(e)); + throw new ManualVerificationAppException(PlatformErrorMessages.RPR_MVS_INVALID_INPUT_PARAMETER_TIMESTAMP,exception); + } + } + } + + +} diff --git a/registration-processor/init/pom.xml b/registration-processor/init/pom.xml index ab854dde10c..28a02239538 100644 --- a/registration-processor/init/pom.xml +++ b/registration-processor/init/pom.xml @@ -1,20 +1,20 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - init - 1.2.1-SNAPSHOT - - UTF-8 - - - registration-processor-packet-receiver-stage - registration-processor-registration-status-service - - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + init + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + registration-processor-packet-receiver-stage + registration-processor-registration-status-service + + diff --git a/registration-processor/init/registration-processor-dmz-packet-server/version.xml b/registration-processor/init/registration-processor-dmz-packet-server/version.xml index f39c04fd636..244bdc89265 100644 --- a/registration-processor/init/registration-processor-dmz-packet-server/version.xml +++ b/registration-processor/init/registration-processor-dmz-packet-server/version.xml @@ -1,2 +1,2 @@ - -1.2.1-SNAPSHOT + +1.2.1-java21-SNAPSHOT diff --git a/registration-processor/init/registration-processor-packet-receiver-stage/Dockerfile b/registration-processor/init/registration-processor-packet-receiver-stage/Dockerfile index 2147d260e8b..14b1cdb81d6 100644 --- a/registration-processor/init/registration-processor-packet-receiver-stage/Dockerfile +++ b/registration-processor/init/registration-processor-packet-receiver-stage/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine #Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image #FROM openjdk:8-jdk-alpine @@ -35,7 +35,7 @@ EXPOSE 4001 CMD if [ "$active_profile_env" = "preprod" ]; then \ wget 'http://13.71.87.138:8040/artifactory/libs-release-local/io/mosip/testing/glowroot.zip' ; \ - apt-get update && apt-get install -y unzip ; \ + apt-get update && apk add -q unzip wget ; \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ diff --git a/registration-processor/init/registration-processor-packet-receiver-stage/pom.xml b/registration-processor/init/registration-processor-packet-receiver-stage/pom.xml index 4521fd04973..06d3cc79ae1 100644 --- a/registration-processor/init/registration-processor-packet-receiver-stage/pom.xml +++ b/registration-processor/init/registration-processor-packet-receiver-stage/pom.xml @@ -1,145 +1,141 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - init - 1.2.1-SNAPSHOT - - - registration-processor-packet-receiver-stage - 1.2.1-SNAPSHOT - jar - registration-processor-packet-receiver-stage - - - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - junit - junit - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - io.mosip.commons - khazana - ${object.store.khazana.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.vertx - vertx-unit - ${vertx.version} - test - - - io.vertx - vertx-web-client - 3.6.2 - - - - io.vertx - vertx-core - - - - - org.apache.httpcomponents - httpmime - 4.3.1 - - - - org.springframework - spring-context - 5.0.6.RELEASE - - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - org.postgresql - postgresql - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - javax.inject - javax.inject - 1 - - - - - - com.h2database - h2 - ${h2.version} - - - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + init + 1.2.1-java21-SNAPSHOT + + + registration-processor-packet-receiver-stage + 1.2.1-java21-SNAPSHOT + jar + registration-processor-packet-receiver-stage + + + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + junit + junit + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + io.mosip.commons + khazana + ${object.store.khazana.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.vertx + vertx-unit + ${vertx.version} + test + + + io.vertx + vertx-web-client + 3.6.2 + + + + io.vertx + vertx-core + + + + + org.apache.httpcomponents + httpmime + 4.3.1 + + + + org.springframework + spring-context + + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + org.postgresql + postgresql + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + javax.inject + javax.inject + 1 + + + + + + com.h2database + h2 + ${h2.version} + + + + + + + + + + diff --git a/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java b/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java index 07dc799f447..7f9a58f9ec5 100644 --- a/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java +++ b/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java @@ -442,35 +442,6 @@ public List acceptableLocales() { return null; } - @Override - public void fail(int statusCode, Throwable throwable) { - - } - - @Override - public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { - return null; - } - - @Override - public Map cookieMap() { - return null; - } - - @Override - public boolean isSessionAccessed() { - return false; - } - - @Override - public int addEndHandler(Handler> handler) { - return 0; - } - - @Override - public boolean removeEndHandler(int handlerID) { - return false; - } }; } diff --git a/registration-processor/init/registration-processor-registration-status-service/Dockerfile b/registration-processor/init/registration-processor-registration-status-service/Dockerfile index 26015819b82..610e3e69eca 100644 --- a/registration-processor/init/registration-processor-registration-status-service/Dockerfile +++ b/registration-processor/init/registration-processor-registration-status-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine #Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image #FROM openjdk:8-jdk-alpine @@ -44,15 +44,15 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/init/registration-processor-registration-status-service/pom.xml b/registration-processor/init/registration-processor-registration-status-service/pom.xml index ae0840caea5..85a1e31e2e9 100644 --- a/registration-processor/init/registration-processor-registration-status-service/pom.xml +++ b/registration-processor/init/registration-processor-registration-status-service/pom.xml @@ -1,165 +1,164 @@ - - - - 4.0.0 - - - io.mosip.registrationprocessor - init - 1.2.1-SNAPSHOT - - registration-processor-registration-status-service - 1.2.1-SNAPSHOT - - registration-processor-registration-status-service - - - UTF-8 - - - - - junit - junit - test - - - org.springframework.boot - spring-boot-starter-web - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.springfox - springfox-swagger-ui - - - io.springfox - springfox-swagger2 - - - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.security - spring-security-test - - - org.springdoc - springdoc-openapi-ui - 1.5.10 - - - org.springframework.boot - spring-boot-configuration-processor - ${spring.boot.version} - true - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - - build-info - repackage - - - - - - - - - openapi-doc-generate-profile - - - io.mosip.kernel - kernel-auth-adapter - ${project.version} - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - pre-integration-test - - start - - - - src/test/resources - - - openapi-profile - - - --server.port=8090 - --server.servlet.path=/app/generic - - - - - - post-integration-test - - stop - - - - - build-info - repackage - - - - - - org.springdoc - springdoc-openapi-maven-plugin - 0.2 - - - integration-test - - generate - - - - - http://localhost:8090/app/generic/v3/api-docs - ${name}-openapi.json - ${project.build.directory} - false - - - - - - - + + + + 4.0.0 + + + io.mosip.registrationprocessor + init + 1.2.1-java21-SNAPSHOT + + registration-processor-registration-status-service + 1.2.1-java21-SNAPSHOT + + registration-processor-registration-status-service + + + UTF-8 + + + + + junit + junit + test + + + org.springframework.boot + spring-boot-starter-web + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.springfox + springfox-swagger-ui + + + io.springfox + springfox-swagger2 + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-test + + + org.springdoc + springdoc-openapi-ui + 1.5.10 + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + + build-info + repackage + + + + + + + + + openapi-doc-generate-profile + + + io.mosip.kernel + kernel-auth-adapter + ${project.version} + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + pre-integration-test + + start + + + + src/test/resources + + + openapi-profile + + + --server.port=8090 + --server.servlet.path=/app/generic + + + + + + post-integration-test + + stop + + + + + build-info + repackage + + + + + + org.springdoc + springdoc-openapi-maven-plugin + 0.2 + + + integration-test + + generate + + + + + http://localhost:8090/app/generic/v3/api-docs + ${name}-openapi.json + ${project.build.directory} + false + + + + + + + diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusSecurityConfig.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusSecurityConfig.java index 8676cf0df34..2bdb3808a4f 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusSecurityConfig.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusSecurityConfig.java @@ -4,15 +4,15 @@ import java.util.Arrays; import java.util.List; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.User; @@ -22,22 +22,21 @@ import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.firewall.DefaultHttpFirewall; import org.springframework.security.web.firewall.HttpFirewall; +import org.springframework.security.web.SecurityFilterChain; @Configuration @EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class RegistrationStatusSecurityConfig extends WebSecurityConfigurerAdapter { +@EnableMethodSecurity +public class RegistrationStatusSecurityConfig { @Bean public HttpFirewall defaultHttpFirewall() { return new DefaultHttpFirewall(); } - @Override - public void configure(WebSecurity webSecurity) throws Exception { - webSecurity.ignoring().antMatchers(allowedEndPoints()); - super.configure(webSecurity); - webSecurity.httpFirewall(defaultHttpFirewall()); + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring().requestMatchers(allowedEndPoints()).and().httpFirewall(defaultHttpFirewall()); } private String[] allowedEndPoints() { @@ -46,12 +45,15 @@ private String[] allowedEndPoints() { "/*/configuration/security", "/*/swagger-resources/**", "/*/swagger-ui.html" }; } - @Override - protected void configure(final HttpSecurity httpSecurity) throws Exception { - httpSecurity.csrf().disable(); - httpSecurity.httpBasic().and().authorizeRequests().anyRequest().authenticated().and().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling() - .authenticationEntryPoint(unauthorizedEntryPoint()); + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.csrf(csrf -> csrf.disable()) + .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedEntryPoint())) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((authz) -> authz.anyRequest().authenticated()) + .userDetailsService(userDetailsService()); + + return http.build(); } @Bean diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/InternalAuthDelegateServicesControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/InternalAuthDelegateServicesControllerTest.java index 272117de921..663c32d4c86 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/InternalAuthDelegateServicesControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/InternalAuthDelegateServicesControllerTest.java @@ -1,147 +1,147 @@ -package io.mosip.registration.processor.status.api.controller; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import javax.servlet.http.Cookie; - -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.http.MediaType; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.WebApplicationContext; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.registration.processor.core.auth.dto.AuthRequestDTO; -import io.mosip.registration.processor.core.auth.dto.AuthResponseDTO; -import io.mosip.registration.processor.core.auth.dto.ResponseDTO; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; -import io.mosip.registration.processor.status.service.InternalAuthDelegateService; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationUtility; - -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -@ContextConfiguration(classes = RegistrationStatusConfigTest.class) -@TestPropertySource(locations = "classpath:application.properties") -@ImportAutoConfiguration(RefreshAutoConfiguration.class) -public class InternalAuthDelegateServicesControllerTest { - - @MockBean - @Qualifier("selfTokenRestTemplate") - private RestTemplate restTemplate; - - @InjectMocks - InternalAuthDelegateServicesController internalAuthDelegateServicesController = new InternalAuthDelegateServicesController(); - - @Autowired - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - @MockBean - private InternalAuthDelegateService internalAuthDelegateService; - - @MockBean - private RegistrationStatusServiceImpl registrationStatusService; - - @MockBean - SyncRegistrationServiceImpl syncRegistrationService; - - @MockBean - RegistrationUtility registrationUtility; - - - ObjectMapper obj=new ObjectMapper(); - - - AuthRequestDTO authRequestDTO = new AuthRequestDTO(); - AuthResponseDTO authResponse = new AuthResponseDTO(); - ResponseDTO responseDto = new ResponseDTO(); - - @Before - public void setUp() throws JsonProcessingException, ApisResourceAccessException { - - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - authRequestDTO.setEnv("Staging"); - authRequestDTO.setIndividualId("45128164920495"); - authRequestDTO.setIndividualIdType("UIN"); - authRequestDTO.setRequest("BFijjscahGoaaol"); - - responseDto.setAuthStatus(true); - authResponse.setId(""); - authResponse.setResponse(responseDto); - obj.setSerializationInclusion(JsonInclude.Include.NON_NULL); - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void testAuthDelegateController() throws Exception { - - String authRequestDTOJson = obj.writeValueAsString(authRequestDTO); - Mockito.when(internalAuthDelegateService.authenticate(any(), any())).thenReturn(authResponse); - MvcResult result = this.mockMvc - .perform(post("/auth").accept(MediaType.APPLICATION_JSON_VALUE) - .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) - .content(authRequestDTOJson.getBytes()).cookie(new Cookie("Authorization", authRequestDTOJson))) - .andExpect(status().isOk()).andReturn(); - String resultContent = result.getResponse().getContentAsString(); - JSONObject object = (JSONObject) new JSONParser().parse(resultContent); - JSONObject responseDto = (JSONObject) object.get("response"); - assertEquals(responseDto.get("authStatus").toString(), "true"); - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void testAuthDelegateFailureController() throws Exception { - - String authRequestDTOJson = obj.writeValueAsString(authRequestDTO); - Mockito.when(internalAuthDelegateService.authenticate(any(), any())).thenReturn(authResponse); - this.mockMvc.perform(post("/auth").accept(MediaType.APPLICATION_JSON_VALUE) - .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", authRequestDTOJson))).andExpect(status().isBadRequest()); - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void getCertificateTestController() throws Exception { - - Mockito.when(internalAuthDelegateService.getCertificate(anyString(), any(), any())).thenReturn(""); - this.mockMvc - .perform(get("/getCertificate").accept(MediaType.APPLICATION_JSON_VALUE) - .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) - .param("applicationId", "REG_CLIENT").param("referenceId", "KERNEL")) - .andExpect(status().isOk()); - } - -} +package io.mosip.registration.processor.status.api.controller; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import jakarta.servlet.http.Cookie; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.WebApplicationContext; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.registration.processor.core.auth.dto.AuthRequestDTO; +import io.mosip.registration.processor.core.auth.dto.AuthResponseDTO; +import io.mosip.registration.processor.core.auth.dto.ResponseDTO; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; +import io.mosip.registration.processor.status.service.InternalAuthDelegateService; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationUtility; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +@ContextConfiguration(classes = RegistrationStatusConfigTest.class) +@TestPropertySource(locations = "classpath:application.properties") +@ImportAutoConfiguration(RefreshAutoConfiguration.class) +public class InternalAuthDelegateServicesControllerTest { + + @MockBean + @Qualifier("selfTokenRestTemplate") + private RestTemplate restTemplate; + + @InjectMocks + InternalAuthDelegateServicesController internalAuthDelegateServicesController = new InternalAuthDelegateServicesController(); + + @Autowired + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext webApplicationContext; + + @MockBean + private InternalAuthDelegateService internalAuthDelegateService; + + @MockBean + private RegistrationStatusServiceImpl registrationStatusService; + + @MockBean + SyncRegistrationServiceImpl syncRegistrationService; + + @MockBean + RegistrationUtility registrationUtility; + + + ObjectMapper obj=new ObjectMapper(); + + + AuthRequestDTO authRequestDTO = new AuthRequestDTO(); + AuthResponseDTO authResponse = new AuthResponseDTO(); + ResponseDTO responseDto = new ResponseDTO(); + + @Before + public void setUp() throws JsonProcessingException, ApisResourceAccessException { + + mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); + authRequestDTO.setEnv("Staging"); + authRequestDTO.setIndividualId("45128164920495"); + authRequestDTO.setIndividualIdType("UIN"); + authRequestDTO.setRequest("BFijjscahGoaaol"); + + responseDto.setAuthStatus(true); + authResponse.setId(""); + authResponse.setResponse(responseDto); + obj.setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void testAuthDelegateController() throws Exception { + + String authRequestDTOJson = obj.writeValueAsString(authRequestDTO); + Mockito.when(internalAuthDelegateService.authenticate(any(), any())).thenReturn(authResponse); + MvcResult result = this.mockMvc + .perform(post("/auth").accept(MediaType.APPLICATION_JSON_VALUE) + .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(authRequestDTOJson.getBytes()).cookie(new Cookie("Authorization", authRequestDTOJson))) + .andExpect(status().isOk()).andReturn(); + String resultContent = result.getResponse().getContentAsString(); + JSONObject object = (JSONObject) new JSONParser().parse(resultContent); + JSONObject responseDto = (JSONObject) object.get("response"); + assertEquals(responseDto.get("authStatus").toString(), "true"); + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void testAuthDelegateFailureController() throws Exception { + + String authRequestDTOJson = obj.writeValueAsString(authRequestDTO); + Mockito.when(internalAuthDelegateService.authenticate(any(), any())).thenReturn(authResponse); + this.mockMvc.perform(post("/auth").accept(MediaType.APPLICATION_JSON_VALUE) + .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", authRequestDTOJson))).andExpect(status().isBadRequest()); + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void getCertificateTestController() throws Exception { + + Mockito.when(internalAuthDelegateService.getCertificate(anyString(), any(), any())).thenReturn(""); + this.mockMvc + .perform(get("/getCertificate").accept(MediaType.APPLICATION_JSON_VALUE) + .header("timestamp", "2019-05-07T05:13:55.704Z").contentType(MediaType.APPLICATION_JSON_VALUE) + .param("applicationId", "REG_CLIENT").param("referenceId", "KERNEL")) + .andExpect(status().isOk()); + } + +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusControllerTest.java index db09e04f331..792d3803823 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusControllerTest.java @@ -1,160 +1,160 @@ -package io.mosip.registration.processor.status.api.controller; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.Cookie; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.WebApplicationContext; - -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; -import io.mosip.registration.processor.status.dto.PacketExternalStatusDTO; -import io.mosip.registration.processor.status.dto.PacketExternalStatusRequestDTO; -import io.mosip.registration.processor.status.dto.PacketExternalStatusSubRequestDTO; -import io.mosip.registration.processor.status.service.PacketExternalStatusService; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationUtility; -import io.mosip.registration.processor.status.validator.PacketExternalStatusRequestValidator; - -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -@ContextConfiguration(classes = RegistrationStatusConfigTest.class) -@TestPropertySource(locations = "classpath:application.properties") -@ImportAutoConfiguration(RefreshAutoConfiguration.class) -public class PacketExternalStatusControllerTest { - - @MockBean - @Qualifier("selfTokenRestTemplate") - private RestTemplate restTemplate; - - @InjectMocks - PacketExternalStatusController packetExternalStatusController = new PacketExternalStatusController(); - - @MockBean - PacketExternalStatusService packetExternalStatusService; - - @MockBean - RegistrationStatusServiceImpl registrationStatusService; - - @Autowired - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - @MockBean - PacketExternalStatusRequestValidator packetStatusRequestValidator; - - @MockBean - SyncRegistrationServiceImpl syncRegistrationService; - - @MockBean - DigitalSignatureUtility digitalSignatureUtility; - - @MockBean - RegistrationUtility registrationUtility; - - @Spy - ObjectMapper objectMapper; - - @Mock - private Environment env; - - private String packetExternalStatusRequestToJson; - - PacketExternalStatusRequestDTO packetExternalStatusRequestDTO; - - @Before - public void setUp() throws JsonProcessingException, ApisResourceAccessException { - objectMapper.setSerializationInclusion(Include.USE_DEFAULTS); - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - when(env.getProperty("mosip.registration.processor.packet.external.status.id")) - .thenReturn("mosip.registration.packet.external.status"); - when(env.getProperty("mosip.registration.processor.datetime.pattern")) - .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - when(env.getProperty("mosip.registration.processor.packet.external.status.version")).thenReturn("1.0"); - - PacketExternalStatusSubRequestDTO packetExternalStatusSubRequestDTO = new PacketExternalStatusSubRequestDTO(); - packetExternalStatusSubRequestDTO.setPacketId("test1"); - PacketExternalStatusSubRequestDTO packetExternalStatusSubRequestDTO1 = new PacketExternalStatusSubRequestDTO(); - packetExternalStatusSubRequestDTO1.setPacketId("test2"); - List requestList = new ArrayList<>(); - requestList.add(packetExternalStatusSubRequestDTO); - requestList.add(packetExternalStatusSubRequestDTO1); - packetExternalStatusRequestDTO = new PacketExternalStatusRequestDTO(); - packetExternalStatusRequestDTO.setId("mosip.registration.packet.external.status"); - packetExternalStatusRequestDTO.setVersion("1.0"); - packetExternalStatusRequestDTO - .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); - packetExternalStatusRequestDTO.setRequest(requestList); - packetExternalStatusRequestToJson = objectMapper.writeValueAsString(packetExternalStatusRequestDTO); - PacketExternalStatusDTO packetExternalStatusDTO = new PacketExternalStatusDTO(); - packetExternalStatusDTO.setPacketId("test1"); - packetExternalStatusDTO.setStatusCode("PROCESSED"); - List packetExternalStatusDTOList = new ArrayList(); - packetExternalStatusDTOList.add(packetExternalStatusDTO); - Mockito.doReturn(packetExternalStatusDTOList).when(packetExternalStatusService) - .getByPacketIds(ArgumentMatchers.any()); - } - - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void packetExternalStatusSuccessTest() throws Exception { - doNothing().when(packetStatusRequestValidator).validate((packetExternalStatusRequestDTO), - "mosip.registration.packet.external.status"); - Mockito.doReturn("test").when(digitalSignatureUtility).getDigitalSignature(ArgumentMatchers.any()); - MvcResult result = this.mockMvc.perform(post("/packetexternalstatus").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", packetExternalStatusRequestToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(packetExternalStatusRequestToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()).andReturn(); - String resultContent = result.getResponse().getContentAsString(); - JSONObject object = (JSONObject) new JSONParser().parse(resultContent); - JSONArray responseObject = (JSONArray) object.get("response"); - JSONObject packetExternalStatusDTO = (JSONObject) responseObject.get(0); - assertEquals(packetExternalStatusDTO.get("packetId").toString(), "test1"); - assertEquals(packetExternalStatusDTO.get("statusCode").toString(), "PROCESSED"); - } -} +package io.mosip.registration.processor.status.api.controller; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.servlet.http.Cookie; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.WebApplicationContext; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; +import io.mosip.registration.processor.status.dto.PacketExternalStatusDTO; +import io.mosip.registration.processor.status.dto.PacketExternalStatusRequestDTO; +import io.mosip.registration.processor.status.dto.PacketExternalStatusSubRequestDTO; +import io.mosip.registration.processor.status.service.PacketExternalStatusService; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationUtility; +import io.mosip.registration.processor.status.validator.PacketExternalStatusRequestValidator; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +@ContextConfiguration(classes = RegistrationStatusConfigTest.class) +@TestPropertySource(locations = "classpath:application.properties") +@ImportAutoConfiguration(RefreshAutoConfiguration.class) +public class PacketExternalStatusControllerTest { + + @MockBean + @Qualifier("selfTokenRestTemplate") + private RestTemplate restTemplate; + + @InjectMocks + PacketExternalStatusController packetExternalStatusController = new PacketExternalStatusController(); + + @MockBean + PacketExternalStatusService packetExternalStatusService; + + @MockBean + RegistrationStatusServiceImpl registrationStatusService; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext webApplicationContext; + + @MockBean + PacketExternalStatusRequestValidator packetStatusRequestValidator; + + @MockBean + SyncRegistrationServiceImpl syncRegistrationService; + + @MockBean + DigitalSignatureUtility digitalSignatureUtility; + + @MockBean + RegistrationUtility registrationUtility; + + @Spy + ObjectMapper objectMapper; + + @Mock + private Environment env; + + private String packetExternalStatusRequestToJson; + + PacketExternalStatusRequestDTO packetExternalStatusRequestDTO; + + @Before + public void setUp() throws JsonProcessingException, ApisResourceAccessException { + objectMapper.setSerializationInclusion(Include.USE_DEFAULTS); + mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); + when(env.getProperty("mosip.registration.processor.packet.external.status.id")) + .thenReturn("mosip.registration.packet.external.status"); + when(env.getProperty("mosip.registration.processor.datetime.pattern")) + .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + when(env.getProperty("mosip.registration.processor.packet.external.status.version")).thenReturn("1.0"); + + PacketExternalStatusSubRequestDTO packetExternalStatusSubRequestDTO = new PacketExternalStatusSubRequestDTO(); + packetExternalStatusSubRequestDTO.setPacketId("test1"); + PacketExternalStatusSubRequestDTO packetExternalStatusSubRequestDTO1 = new PacketExternalStatusSubRequestDTO(); + packetExternalStatusSubRequestDTO1.setPacketId("test2"); + List requestList = new ArrayList<>(); + requestList.add(packetExternalStatusSubRequestDTO); + requestList.add(packetExternalStatusSubRequestDTO1); + packetExternalStatusRequestDTO = new PacketExternalStatusRequestDTO(); + packetExternalStatusRequestDTO.setId("mosip.registration.packet.external.status"); + packetExternalStatusRequestDTO.setVersion("1.0"); + packetExternalStatusRequestDTO + .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); + packetExternalStatusRequestDTO.setRequest(requestList); + packetExternalStatusRequestToJson = objectMapper.writeValueAsString(packetExternalStatusRequestDTO); + PacketExternalStatusDTO packetExternalStatusDTO = new PacketExternalStatusDTO(); + packetExternalStatusDTO.setPacketId("test1"); + packetExternalStatusDTO.setStatusCode("PROCESSED"); + List packetExternalStatusDTOList = new ArrayList(); + packetExternalStatusDTOList.add(packetExternalStatusDTO); + Mockito.doReturn(packetExternalStatusDTOList).when(packetExternalStatusService) + .getByPacketIds(ArgumentMatchers.any()); + } + + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void packetExternalStatusSuccessTest() throws Exception { + doNothing().when(packetStatusRequestValidator).validate((packetExternalStatusRequestDTO), + "mosip.registration.packet.external.status"); + Mockito.doReturn("test").when(digitalSignatureUtility).getDigitalSignature(ArgumentMatchers.any()); + MvcResult result = this.mockMvc.perform(post("/packetexternalstatus").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", packetExternalStatusRequestToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(packetExternalStatusRequestToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()).andReturn(); + String resultContent = result.getResponse().getContentAsString(); + JSONObject object = (JSONObject) new JSONParser().parse(resultContent); + JSONArray responseObject = (JSONArray) object.get("response"); + JSONObject packetExternalStatusDTO = (JSONObject) responseObject.get(0); + assertEquals(packetExternalStatusDTO.get("packetId").toString(), "test1"); + assertEquals(packetExternalStatusDTO.get("statusCode").toString(), "PROCESSED"); + } +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java index 765ab1b3eee..6e5fa429930 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java @@ -1,230 +1,230 @@ -package io.mosip.registration.processor.status.api.controller; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.Cookie; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.util.NestedServletException; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.mosip.registration.processor.core.workflow.dto.SortInfo; -import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; -import io.mosip.registration.processor.status.dto.FilterInfo; -import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; -import io.mosip.registration.processor.status.dto.RegistrationExternalStatusSubRequestDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.SearchInfo; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationUtility; -import io.mosip.registration.processor.status.validator.LostRidRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationExternalStatusRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationSyncRequestValidator; - -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -@ContextConfiguration(classes = RegistrationStatusConfigTest.class) -@TestPropertySource(locations = "classpath:application.properties") -@ImportAutoConfiguration(RefreshAutoConfiguration.class) -public class RegistrationExternalStatusControllerTest { - - @MockBean - @Qualifier("selfTokenRestTemplate") - private RestTemplate restTemplate; - - @Autowired - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - @InjectMocks - RegistrationExternalStatusController registrationExternalStatusController = new RegistrationExternalStatusController(); - - @MockBean - RegistrationExternalStatusRequestValidator registrationExternalStatusRequestValidator; - - @MockBean - RegistrationStatusRequestValidator registrationStatusRequestValidator; - - /** The registration status service. */ - @MockBean - RegistrationStatusServiceImpl registrationStatusService; - - @MockBean - SyncRegistrationServiceImpl syncRegistrationService; - - @MockBean - DigitalSignatureUtility digitalSignatureUtility; - - @MockBean - LostRidRequestValidator lostRidRequestValidator; - - @MockBean - RegistrationUtility registrationUtility; - - @MockBean - private RegistrationSyncRequestValidator syncrequestvalidator; - - @Mock - private Environment env; - - @Autowired - public ObjectMapper objectMapper; - - /** The registration dto list. */ - private List registrationDtoList; - private List registrationDtoList1; - - RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO; - - /** The array to json. */ - private String regStatusToJson; - - @Before - public void setUp() throws JsonProcessingException, ApisResourceAccessException { - - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - when(env.getProperty("mosip.registration.processor.registration.external.status.id")) - .thenReturn("mosip.registration.external.status"); - when(env.getProperty("mosip.registration.processor.datetime.pattern")) - .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - when(env.getProperty("mosip.registration.processor.registration.external.status.version")).thenReturn("1.0"); - List request = new ArrayList<>(); - RegistrationExternalStatusSubRequestDto regitrationid1 = new RegistrationExternalStatusSubRequestDto(); - RegistrationExternalStatusSubRequestDto regitrationid2 = new RegistrationExternalStatusSubRequestDto(); - RegistrationExternalStatusSubRequestDto regitrationid3 = new RegistrationExternalStatusSubRequestDto(); - regitrationid1.setRegistrationId("1001"); - regitrationid2.setRegistrationId("1002"); - regitrationid3.setRegistrationId("1003"); - request.add(regitrationid1); - request.add(regitrationid2); - request.add(regitrationid3); - registrationExternalStatusRequestDTO = new RegistrationExternalStatusRequestDTO(); - registrationExternalStatusRequestDTO.setRequest(request); - registrationExternalStatusRequestDTO.setId("mosip.registration.external.status"); - registrationExternalStatusRequestDTO.setVersion("1.0"); - registrationExternalStatusRequestDTO - .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); - regStatusToJson =objectMapper.writeValueAsString(registrationExternalStatusRequestDTO); - registrationDtoList = new ArrayList<>(); - registrationDtoList1 = new ArrayList<>(); - RegistrationStatusDto registrationStatusDto1 = new RegistrationStatusDto(); - registrationStatusDto1.setRegistrationId("1001"); - registrationStatusDto1.setStatusCode("PROCESSED"); - - RegistrationStatusDto registrationStatusDto2 = new RegistrationStatusDto(); - registrationStatusDto2.setRegistrationId("1002"); - registrationStatusDto2.setStatusCode("PROCESSED"); - - registrationDtoList.add(registrationStatusDto1); - registrationDtoList1.add(registrationStatusDto2); - - Mockito.doReturn(registrationDtoList).when(registrationStatusService).getExternalStatusByIds(ArgumentMatchers.any()); - Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getExternalStatusByIds(ArgumentMatchers.any()); - SearchInfo searchInfo = new SearchInfo(); - List filterinfos = new ArrayList(); - List sortInfos = new ArrayList(); - FilterInfo filterInfo = new FilterInfo(); - filterInfo.setColumnName("name"); - filterInfo.setValue("mosip"); - filterinfos.add(filterInfo); - SortInfo sortInfo = new SortInfo(); - sortInfo.setSortField("createDateTime"); - sortInfo.setSortType("desc"); - sortInfos.add(sortInfo); - searchInfo.setFilters(filterinfos); - searchInfo.setSort(sortInfos); - - Mockito.doReturn(registrationDtoList).when(registrationStatusService).getByIds(ArgumentMatchers.any()); - Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getByIds(ArgumentMatchers.any()); - - } - - /** - * Search success test. - * - */ - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void searchSuccessTest() throws Exception { - doNothing().when(registrationExternalStatusRequestValidator).validate((registrationExternalStatusRequestDTO), - "mosip.registration.external.status"); - Mockito.doReturn("test").when(digitalSignatureUtility).getDigitalSignature(ArgumentMatchers.any()); - - MvcResult result = this.mockMvc.perform(post("/externalstatus/search").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()).andReturn(); - String resultContent = result.getResponse().getContentAsString(); - JSONObject object = (JSONObject) new JSONParser().parse(resultContent); - JSONArray responseObject = (JSONArray) object.get("response"); - JSONArray errorObject = (JSONArray) object.get("errors"); - JSONObject registrationStatusDto = (JSONObject) responseObject.get(0); - JSONObject registrationStatusDto1 = (JSONObject) responseObject.get(1); - JSONObject registrationStatusErrorDto = (JSONObject) errorObject.get(0); - - assertEquals(registrationStatusDto.get("registrationId").toString(), "1001"); - assertEquals(registrationStatusDto.get("statusCode").toString(), "PROCESSED"); - assertEquals(registrationStatusDto1.get("registrationId").toString(), "1002"); - assertEquals(registrationStatusDto1.get("statusCode").toString(), "PROCESSED"); - assertEquals(registrationStatusErrorDto.get("registrationId").toString(), "1003"); - assertEquals(registrationStatusErrorDto.get("errorMessage").toString(), "RID Not Found"); - } - - @Test(expected = NestedServletException.class) - @WithMockUser(value = "resident", roles = "RESIDENT") - public void searchRegstatusException() throws Exception { - - Mockito.doThrow(new RegStatusAppException()).when(registrationExternalStatusRequestValidator) - .validate(ArgumentMatchers.any(), ArgumentMatchers.any()); - this.mockMvc.perform(post("/externalstatus/search").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isInternalServerError()); - } - -} +package io.mosip.registration.processor.status.api.controller; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.servlet.http.Cookie; + +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.util.NestedServletException; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.mosip.registration.processor.core.workflow.dto.SortInfo; +import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; +import io.mosip.registration.processor.status.dto.FilterInfo; +import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; +import io.mosip.registration.processor.status.dto.RegistrationExternalStatusSubRequestDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.SearchInfo; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationUtility; +import io.mosip.registration.processor.status.validator.LostRidRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationExternalStatusRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationSyncRequestValidator; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +@ContextConfiguration(classes = RegistrationStatusConfigTest.class) +@TestPropertySource(locations = "classpath:application.properties") +@ImportAutoConfiguration(RefreshAutoConfiguration.class) +public class RegistrationExternalStatusControllerTest { + + @MockBean + @Qualifier("selfTokenRestTemplate") + private RestTemplate restTemplate; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext webApplicationContext; + + @InjectMocks + RegistrationExternalStatusController registrationExternalStatusController = new RegistrationExternalStatusController(); + + @MockBean + RegistrationExternalStatusRequestValidator registrationExternalStatusRequestValidator; + + @MockBean + RegistrationStatusRequestValidator registrationStatusRequestValidator; + + /** The registration status service. */ + @MockBean + RegistrationStatusServiceImpl registrationStatusService; + + @MockBean + SyncRegistrationServiceImpl syncRegistrationService; + + @MockBean + DigitalSignatureUtility digitalSignatureUtility; + + @MockBean + LostRidRequestValidator lostRidRequestValidator; + + @MockBean + RegistrationUtility registrationUtility; + + @MockBean + private RegistrationSyncRequestValidator syncrequestvalidator; + + @Mock + private Environment env; + + @Autowired + public ObjectMapper objectMapper; + + /** The registration dto list. */ + private List registrationDtoList; + private List registrationDtoList1; + + RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO; + + /** The array to json. */ + private String regStatusToJson; + + @Before + public void setUp() throws JsonProcessingException, ApisResourceAccessException { + + mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); + when(env.getProperty("mosip.registration.processor.registration.external.status.id")) + .thenReturn("mosip.registration.external.status"); + when(env.getProperty("mosip.registration.processor.datetime.pattern")) + .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + when(env.getProperty("mosip.registration.processor.registration.external.status.version")).thenReturn("1.0"); + List request = new ArrayList<>(); + RegistrationExternalStatusSubRequestDto regitrationid1 = new RegistrationExternalStatusSubRequestDto(); + RegistrationExternalStatusSubRequestDto regitrationid2 = new RegistrationExternalStatusSubRequestDto(); + RegistrationExternalStatusSubRequestDto regitrationid3 = new RegistrationExternalStatusSubRequestDto(); + regitrationid1.setRegistrationId("1001"); + regitrationid2.setRegistrationId("1002"); + regitrationid3.setRegistrationId("1003"); + request.add(regitrationid1); + request.add(regitrationid2); + request.add(regitrationid3); + registrationExternalStatusRequestDTO = new RegistrationExternalStatusRequestDTO(); + registrationExternalStatusRequestDTO.setRequest(request); + registrationExternalStatusRequestDTO.setId("mosip.registration.external.status"); + registrationExternalStatusRequestDTO.setVersion("1.0"); + registrationExternalStatusRequestDTO + .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); + regStatusToJson =objectMapper.writeValueAsString(registrationExternalStatusRequestDTO); + registrationDtoList = new ArrayList<>(); + registrationDtoList1 = new ArrayList<>(); + RegistrationStatusDto registrationStatusDto1 = new RegistrationStatusDto(); + registrationStatusDto1.setRegistrationId("1001"); + registrationStatusDto1.setStatusCode("PROCESSED"); + + RegistrationStatusDto registrationStatusDto2 = new RegistrationStatusDto(); + registrationStatusDto2.setRegistrationId("1002"); + registrationStatusDto2.setStatusCode("PROCESSED"); + + registrationDtoList.add(registrationStatusDto1); + registrationDtoList1.add(registrationStatusDto2); + + Mockito.doReturn(registrationDtoList).when(registrationStatusService).getExternalStatusByIds(ArgumentMatchers.any()); + Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getExternalStatusByIds(ArgumentMatchers.any()); + SearchInfo searchInfo = new SearchInfo(); + List filterinfos = new ArrayList(); + List sortInfos = new ArrayList(); + FilterInfo filterInfo = new FilterInfo(); + filterInfo.setColumnName("name"); + filterInfo.setValue("mosip"); + filterinfos.add(filterInfo); + SortInfo sortInfo = new SortInfo(); + sortInfo.setSortField("createDateTime"); + sortInfo.setSortType("desc"); + sortInfos.add(sortInfo); + searchInfo.setFilters(filterinfos); + searchInfo.setSort(sortInfos); + + Mockito.doReturn(registrationDtoList).when(registrationStatusService).getByIds(ArgumentMatchers.any()); + Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getByIds(ArgumentMatchers.any()); + + } + + /** + * Search success test. + * + */ + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void searchSuccessTest() throws Exception { + doNothing().when(registrationExternalStatusRequestValidator).validate((registrationExternalStatusRequestDTO), + "mosip.registration.external.status"); + Mockito.doReturn("test").when(digitalSignatureUtility).getDigitalSignature(ArgumentMatchers.any()); + + MvcResult result = this.mockMvc.perform(post("/externalstatus/search").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()).andReturn(); + String resultContent = result.getResponse().getContentAsString(); + JSONObject object = (JSONObject) new JSONParser().parse(resultContent); + JSONArray responseObject = (JSONArray) object.get("response"); + JSONArray errorObject = (JSONArray) object.get("errors"); + JSONObject registrationStatusDto = (JSONObject) responseObject.get(0); + JSONObject registrationStatusDto1 = (JSONObject) responseObject.get(1); + JSONObject registrationStatusErrorDto = (JSONObject) errorObject.get(0); + + assertEquals(registrationStatusDto.get("registrationId").toString(), "1001"); + assertEquals(registrationStatusDto.get("statusCode").toString(), "PROCESSED"); + assertEquals(registrationStatusDto1.get("registrationId").toString(), "1002"); + assertEquals(registrationStatusDto1.get("statusCode").toString(), "PROCESSED"); + assertEquals(registrationStatusErrorDto.get("registrationId").toString(), "1003"); + assertEquals(registrationStatusErrorDto.get("errorMessage").toString(), "RID Not Found"); + } + + @Test(expected = NestedServletException.class) + @WithMockUser(value = "resident", roles = "RESIDENT") + public void searchRegstatusException() throws Exception { + + Mockito.doThrow(new RegStatusAppException()).when(registrationExternalStatusRequestValidator) + .validate(ArgumentMatchers.any(), ArgumentMatchers.any()); + this.mockMvc.perform(post("/externalstatus/search").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isInternalServerError()); + } + +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java index 42798f22eb2..f6772c23102 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java @@ -1,416 +1,416 @@ -package io.mosip.registration.processor.status.api.controller; - -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.Cookie; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentMatchers; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.ImportAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.WebApplicationContext; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.digital.signature.dto.SignResponseDto; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.WorkFlowSearchException; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.workflow.dto.SortInfo; -import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; -import io.mosip.registration.processor.status.dto.FilterInfo; -import io.mosip.registration.processor.status.dto.LostRidRequestDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; -import io.mosip.registration.processor.status.dto.RegistrationStatusSubRequestDto; -import io.mosip.registration.processor.status.dto.RegistrationSyncRequestDTO; -import io.mosip.registration.processor.status.dto.SearchInfo; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.dto.SyncResponseFailDto; -import io.mosip.registration.processor.status.dto.SyncResponseFailureDto; -import io.mosip.registration.processor.status.dto.SyncResponseSuccessDto; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationUtility; -import io.mosip.registration.processor.status.validator.LostRidRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationSyncRequestValidator; - -/** - * The Class RegistrationStatusControllerTest. - * - * @author M1047487 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -@AutoConfigureMockMvc -@ContextConfiguration(classes = RegistrationStatusConfigTest.class) -@TestPropertySource(locations = "classpath:application.properties") -@ImportAutoConfiguration(RefreshAutoConfiguration.class) -public class RegistrationStatusAndSyncControllerTest { - - @MockBean - @Qualifier("selfTokenRestTemplate") - private RestTemplate restTemplate; - - /** The registration status controller. */ - @InjectMocks - RegistrationStatusController registrationStatusController = new RegistrationStatusController(); - - @InjectMocks - RegistrationSyncController registrationSyncController = new RegistrationSyncController(); - - /** The registration status service. */ - @MockBean - RegistrationStatusServiceImpl registrationStatusService; - - /** The sync registration service. */ - @MockBean - SyncRegistrationServiceImpl syncRegistrationService; - - /** The sync registration dto. */ - @MockBean - SyncRegistrationDto syncRegistrationDto; - - RegistrationStatusRequestDTO registrationStatusRequestDTO; - /** The mock mvc. */ - @Autowired - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - /** The registration dto list. */ - private List registrationDtoList; - - /** The registration dto list. */ - private List registrationDtoList1; - - /** The array to json. */ - private String regStatusToJson; - - private String lostRidReqToJson; - - @MockBean - private RegistrationProcessorRestClientService reprcrestclient; - - @MockBean - RegistrationUtility registrationUtility; - - private ResponseWrapper dto = new ResponseWrapper(); - - private SignResponseDto signresponse = new SignResponseDto(); - RegistrationSyncRequestDTO registrationSyncRequestDTO; - - @Mock - private Environment env; - - LostRidRequestDto lostRidRequestDto; - - - @MockBean - RegistrationStatusRequestValidator registrationStatusRequestValidator; - - @MockBean - LostRidRequestValidator lostRidRequestValidator; - - @MockBean - private RegistrationSyncRequestValidator syncrequestvalidator; - - @Autowired - ObjectMapper objMp=new ObjectMapper(); - private List syncResponseDtoList; - private List list; - SyncResponseFailureDto syncResponseFailureDto = new SyncResponseFailureDto(); - - // @Autowired -// private WebApplicationContext context; - - // @Autowired - //// private Filter springSecurityFilterChain; - - /** - * Sets the up. - * - * @throws JsonProcessingException - * @throws ApisResourceAccessException - */ - @Before - public void setUp() throws JsonProcessingException, ApisResourceAccessException { - ObjectMapper objMp=new ObjectMapper(); - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - when(env.getProperty("mosip.registration.processor.registration.status.id")) - .thenReturn("mosip.registration.status"); - when(env.getProperty("mosip.registration.processor.lostrid.id")).thenReturn("mosip.registration.lostrid"); - when(env.getProperty("mosip.registration.processor.lostrid.version")).thenReturn("1.0"); - when(env.getProperty("mosip.registration.processor.datetime.pattern")) - .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - when(env.getProperty("mosip.registration.processor.application.version")).thenReturn("1.0"); - List request = new ArrayList<>(); - RegistrationStatusSubRequestDto regitrationid1 = new RegistrationStatusSubRequestDto(); - RegistrationStatusSubRequestDto regitrationid2 = new RegistrationStatusSubRequestDto(); - RegistrationStatusSubRequestDto regitrationid3 = new RegistrationStatusSubRequestDto(); - regitrationid1.setRegistrationId("1001"); - regitrationid2.setRegistrationId("1002"); - regitrationid3.setRegistrationId("1003"); - request.add(regitrationid1); - request.add(regitrationid2); - request.add(regitrationid3); - registrationStatusRequestDTO = new RegistrationStatusRequestDTO(); - registrationStatusRequestDTO.setRequest(request); - registrationStatusRequestDTO.setId("mosip.registration.status"); - registrationStatusRequestDTO.setVersion("1.0"); - registrationStatusRequestDTO - .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); - regStatusToJson = objMp.writeValueAsString(registrationStatusRequestDTO); - registrationDtoList = new ArrayList<>(); - registrationDtoList1 = new ArrayList<>(); - RegistrationStatusDto registrationStatusDto1 = new RegistrationStatusDto(); - registrationStatusDto1.setRegistrationId("1001"); - - RegistrationStatusDto registrationStatusDto2 = new RegistrationStatusDto(); - registrationStatusDto2.setRegistrationId("1002"); - - registrationDtoList.add(registrationStatusDto1); - registrationDtoList1.add(registrationStatusDto2); - SyncResponseSuccessDto syncResponseDto = new SyncResponseSuccessDto(); - SyncResponseFailureDto syncResponseFailureDto = new SyncResponseFailureDto(); - syncResponseDto.setRegistrationId("1001"); - - syncResponseDto.setStatus("SUCCESS"); - syncResponseFailureDto.setRegistrationId("1001"); - - syncResponseFailureDto.setMessage("Registartion Id's are successfully synched in Sync table"); - syncResponseFailureDto.setStatus("FAILURE"); - syncResponseFailureDto.setErrorCode("Test"); - syncResponseDtoList = new ArrayList<>(); - syncResponseDtoList.add(syncResponseDto); - syncResponseDtoList.add(syncResponseFailureDto); - list = new ArrayList<>(); - SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto(); - syncRegistrationDto = new SyncRegistrationDto(); - syncRegistrationDto.setRegistrationId("1002"); - syncRegistrationDto.setLangCode("eng"); - syncRegistrationDto.setIsActive(true); - list.add(syncRegistrationDto); - registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); - registrationSyncRequestDTO.setRequest(list); - registrationSyncRequestDTO.setId("mosip.registration.sync"); - registrationSyncRequestDTO.setVersion("1.0"); - registrationSyncRequestDTO - .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); - lostRidRequestDto = new LostRidRequestDto(); - lostRidRequestDto.setId("mosip.registration.lostrid"); - lostRidRequestDto.setVersion("1.0"); - lostRidRequestDto.setRequesttime(LocalDateTime.now().toString()); - SearchInfo searchInfo = new SearchInfo(); - List filterinfos = new ArrayList(); - List sortInfos = new ArrayList(); - FilterInfo filterInfo = new FilterInfo(); - filterInfo.setColumnName("name"); - filterInfo.setValue("mosip"); - filterinfos.add(filterInfo); - SortInfo sortInfo = new SortInfo(); - sortInfo.setSortField("createDateTime"); - sortInfo.setSortType("desc"); - sortInfos.add(sortInfo); - searchInfo.setFilters(filterinfos); - searchInfo.setSort(sortInfos); - lostRidReqToJson =objMp.writeValueAsString(lostRidRequestDto); - - Mockito.doReturn(registrationDtoList).when(registrationStatusService).getByIds(ArgumentMatchers.any()); - Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getByIds(ArgumentMatchers.any()); - - signresponse.setSignature("abcd"); - dto.setResponse(signresponse); - Mockito.when(reprcrestclient.postApi(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(dto); - Mockito.when(syncRegistrationService.sync(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(syncResponseDtoList); - Mockito.when( - syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) - .thenReturn(Boolean.TRUE); - - } - - /** - * Search success test. - * - * @throws Exception - * the exception - */ - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void searchSuccessTest() throws Exception { - doNothing().when(registrationStatusRequestValidator).validate((registrationStatusRequestDTO), - "mosip.registration.status"); - - this.mockMvc.perform(post("/search").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void searchRegstatusException() throws Exception { - - Mockito.doThrow(new RegStatusAppException()).when(registrationStatusRequestValidator) - .validate(ArgumentMatchers.any(), ArgumentMatchers.any()); - this.mockMvc.perform(post("/search").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void testSyncController() throws Exception { - - RegistrationSyncRequestDTO registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); - List request = new ArrayList(); - SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto("45128164920495", "NEW", null, null, "eng"); - request.add(syncRegistrationDto); - String requestJson = objMp.writeValueAsString(request); - - List syncResponseList = new ArrayList<>(); - SyncResponseDto syncResponseDto = new SyncResponseDto(); - syncResponseDto.setStatus("true"); - syncResponseDto.setRegistrationId("45128164920495"); - syncResponseList.add(syncResponseDto); - - Mockito.when(syncRegistrationService.decryptAndGetSyncRequest(ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(registrationSyncRequestDTO); - Mockito.when( - syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) - .thenReturn(true); - Mockito.when( - syncRegistrationService.sync(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) - .thenReturn(syncResponseList); - this.mockMvc.perform( - post("/sync").accept(MediaType.APPLICATION_JSON_VALUE).header("timestamp", "2019-05-07T05:13:55.704Z") - .header("Center-Machine-RefId", "abcd").contentType(MediaType.APPLICATION_JSON_VALUE) - .content(requestJson.getBytes()).cookie(new Cookie("Authorization", requestJson))) - .andExpect(status().isOk()); - } - - @Test - @WithMockUser(value = "resident", roles = "RESIDENT") - public void testSyncV2Controller() throws Exception { - - RegistrationSyncRequestDTO registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); - List request = new ArrayList(); - SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto("45128164920495", "NEW", null, null, "eng"); - request.add(syncRegistrationDto); - String requestJson = objMp.writeValueAsString(request); - - List syncResponseList = new ArrayList<>(); - SyncResponseDto syncResponseDto = new SyncResponseDto(); - syncResponseDto.setStatus("true"); - syncResponseDto.setRegistrationId("45128164920495"); - syncResponseList.add(syncResponseDto); - - Mockito.when(syncRegistrationService.decryptAndGetSyncRequest(ArgumentMatchers.any(), ArgumentMatchers.any(), - ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(registrationSyncRequestDTO); - Mockito.when( - syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) - .thenReturn(true); - Mockito.when( - syncRegistrationService.syncV2(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) - .thenReturn(syncResponseList); - this.mockMvc.perform( - post("/syncV2").accept(MediaType.APPLICATION_JSON_VALUE).header("timestamp", "2019-05-07T05:13:55.704Z") - .header("Center-Machine-RefId", "abcd").contentType(MediaType.APPLICATION_JSON_VALUE) - .content(requestJson.getBytes()).cookie(new Cookie("Authorization", requestJson))) - .andExpect(status().isOk()); - } - - @Test - public void testBuildRegistrationSyncResponse() throws JsonProcessingException { - List syncResponseDtoList = new ArrayList<>(); - syncResponseFailureDto.setStatus("SUCCESS"); - syncResponseDtoList.add(syncResponseFailureDto); - registrationSyncController.buildRegistrationSyncResponse(syncResponseDtoList); - - } - - @Test - public void testBuildRegistrationSyncResponse1() throws JsonProcessingException { - List syncResponseDtoList = new ArrayList<>(); - SyncResponseFailDto syncResponseFailDto = new SyncResponseFailDto(); - SyncResponseFailureDto syncResponseDto = new SyncResponseFailureDto(); - - syncResponseDto.setStatus("Fail"); - syncResponseDtoList.add(syncResponseDto); - - syncResponseFailDto.setStatus("Fail"); - syncResponseDtoList.add(syncResponseFailDto); - registrationSyncController.buildRegistrationSyncResponse(syncResponseDtoList); - - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void lostRidSuccessTest() throws Exception { - doNothing().when(lostRidRequestValidator).validate((lostRidRequestDto)); - - this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void lostRidRegstatusException() throws Exception { - - Mockito.doThrow(new RegStatusAppException()).when(lostRidRequestValidator).validate(ArgumentMatchers.any()); - this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - - @Test - @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") - public void lostRidWorkFlowSearchException() throws Exception { - - Mockito.doThrow(new WorkFlowSearchException("ERR-001", "exception occured")).when(lostRidRequestValidator) - .validate(ArgumentMatchers.any()); - this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } +package io.mosip.registration.processor.status.api.controller; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import jakarta.servlet.http.Cookie; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.context.WebApplicationContext; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.digital.signature.dto.SignResponseDto; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.WorkFlowSearchException; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.workflow.dto.SortInfo; +import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; +import io.mosip.registration.processor.status.dto.FilterInfo; +import io.mosip.registration.processor.status.dto.LostRidRequestDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; +import io.mosip.registration.processor.status.dto.RegistrationStatusSubRequestDto; +import io.mosip.registration.processor.status.dto.RegistrationSyncRequestDTO; +import io.mosip.registration.processor.status.dto.SearchInfo; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.dto.SyncResponseFailDto; +import io.mosip.registration.processor.status.dto.SyncResponseFailureDto; +import io.mosip.registration.processor.status.dto.SyncResponseSuccessDto; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationUtility; +import io.mosip.registration.processor.status.validator.LostRidRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationSyncRequestValidator; + +/** + * The Class RegistrationStatusControllerTest. + * + * @author M1047487 + */ +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +@ContextConfiguration(classes = RegistrationStatusConfigTest.class) +@TestPropertySource(locations = "classpath:application.properties") +@ImportAutoConfiguration(RefreshAutoConfiguration.class) +public class RegistrationStatusAndSyncControllerTest { + + @MockBean + @Qualifier("selfTokenRestTemplate") + private RestTemplate restTemplate; + + /** The registration status controller. */ + @InjectMocks + RegistrationStatusController registrationStatusController = new RegistrationStatusController(); + + @InjectMocks + RegistrationSyncController registrationSyncController = new RegistrationSyncController(); + + /** The registration status service. */ + @MockBean + RegistrationStatusServiceImpl registrationStatusService; + + /** The sync registration service. */ + @MockBean + SyncRegistrationServiceImpl syncRegistrationService; + + /** The sync registration dto. */ + @MockBean + SyncRegistrationDto syncRegistrationDto; + + RegistrationStatusRequestDTO registrationStatusRequestDTO; + /** The mock mvc. */ + @Autowired + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext webApplicationContext; + + /** The registration dto list. */ + private List registrationDtoList; + + /** The registration dto list. */ + private List registrationDtoList1; + + /** The array to json. */ + private String regStatusToJson; + + private String lostRidReqToJson; + + @MockBean + private RegistrationProcessorRestClientService reprcrestclient; + + @MockBean + RegistrationUtility registrationUtility; + + private ResponseWrapper dto = new ResponseWrapper(); + + private SignResponseDto signresponse = new SignResponseDto(); + RegistrationSyncRequestDTO registrationSyncRequestDTO; + + @Mock + private Environment env; + + LostRidRequestDto lostRidRequestDto; + + + @MockBean + RegistrationStatusRequestValidator registrationStatusRequestValidator; + + @MockBean + LostRidRequestValidator lostRidRequestValidator; + + @MockBean + private RegistrationSyncRequestValidator syncrequestvalidator; + + @Autowired + ObjectMapper objMp=new ObjectMapper(); + private List syncResponseDtoList; + private List list; + SyncResponseFailureDto syncResponseFailureDto = new SyncResponseFailureDto(); + + // @Autowired +// private WebApplicationContext context; + + // @Autowired + //// private Filter springSecurityFilterChain; + + /** + * Sets the up. + * + * @throws JsonProcessingException + * @throws ApisResourceAccessException + */ + @Before + public void setUp() throws JsonProcessingException, ApisResourceAccessException { + ObjectMapper objMp=new ObjectMapper(); + mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); + when(env.getProperty("mosip.registration.processor.registration.status.id")) + .thenReturn("mosip.registration.status"); + when(env.getProperty("mosip.registration.processor.lostrid.id")).thenReturn("mosip.registration.lostrid"); + when(env.getProperty("mosip.registration.processor.lostrid.version")).thenReturn("1.0"); + when(env.getProperty("mosip.registration.processor.datetime.pattern")) + .thenReturn("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + when(env.getProperty("mosip.registration.processor.application.version")).thenReturn("1.0"); + List request = new ArrayList<>(); + RegistrationStatusSubRequestDto regitrationid1 = new RegistrationStatusSubRequestDto(); + RegistrationStatusSubRequestDto regitrationid2 = new RegistrationStatusSubRequestDto(); + RegistrationStatusSubRequestDto regitrationid3 = new RegistrationStatusSubRequestDto(); + regitrationid1.setRegistrationId("1001"); + regitrationid2.setRegistrationId("1002"); + regitrationid3.setRegistrationId("1003"); + request.add(regitrationid1); + request.add(regitrationid2); + request.add(regitrationid3); + registrationStatusRequestDTO = new RegistrationStatusRequestDTO(); + registrationStatusRequestDTO.setRequest(request); + registrationStatusRequestDTO.setId("mosip.registration.status"); + registrationStatusRequestDTO.setVersion("1.0"); + registrationStatusRequestDTO + .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); + regStatusToJson = objMp.writeValueAsString(registrationStatusRequestDTO); + registrationDtoList = new ArrayList<>(); + registrationDtoList1 = new ArrayList<>(); + RegistrationStatusDto registrationStatusDto1 = new RegistrationStatusDto(); + registrationStatusDto1.setRegistrationId("1001"); + + RegistrationStatusDto registrationStatusDto2 = new RegistrationStatusDto(); + registrationStatusDto2.setRegistrationId("1002"); + + registrationDtoList.add(registrationStatusDto1); + registrationDtoList1.add(registrationStatusDto2); + SyncResponseSuccessDto syncResponseDto = new SyncResponseSuccessDto(); + SyncResponseFailureDto syncResponseFailureDto = new SyncResponseFailureDto(); + syncResponseDto.setRegistrationId("1001"); + + syncResponseDto.setStatus("SUCCESS"); + syncResponseFailureDto.setRegistrationId("1001"); + + syncResponseFailureDto.setMessage("Registartion Id's are successfully synched in Sync table"); + syncResponseFailureDto.setStatus("FAILURE"); + syncResponseFailureDto.setErrorCode("Test"); + syncResponseDtoList = new ArrayList<>(); + syncResponseDtoList.add(syncResponseDto); + syncResponseDtoList.add(syncResponseFailureDto); + list = new ArrayList<>(); + SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto(); + syncRegistrationDto = new SyncRegistrationDto(); + syncRegistrationDto.setRegistrationId("1002"); + syncRegistrationDto.setLangCode("eng"); + syncRegistrationDto.setIsActive(true); + list.add(syncRegistrationDto); + registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); + registrationSyncRequestDTO.setRequest(list); + registrationSyncRequestDTO.setId("mosip.registration.sync"); + registrationSyncRequestDTO.setVersion("1.0"); + registrationSyncRequestDTO + .setRequesttime(DateUtils.getUTCCurrentDateTimeString("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); + lostRidRequestDto = new LostRidRequestDto(); + lostRidRequestDto.setId("mosip.registration.lostrid"); + lostRidRequestDto.setVersion("1.0"); + lostRidRequestDto.setRequesttime(LocalDateTime.now().toString()); + SearchInfo searchInfo = new SearchInfo(); + List filterinfos = new ArrayList(); + List sortInfos = new ArrayList(); + FilterInfo filterInfo = new FilterInfo(); + filterInfo.setColumnName("name"); + filterInfo.setValue("mosip"); + filterinfos.add(filterInfo); + SortInfo sortInfo = new SortInfo(); + sortInfo.setSortField("createDateTime"); + sortInfo.setSortType("desc"); + sortInfos.add(sortInfo); + searchInfo.setFilters(filterinfos); + searchInfo.setSort(sortInfos); + lostRidReqToJson =objMp.writeValueAsString(lostRidRequestDto); + + Mockito.doReturn(registrationDtoList).when(registrationStatusService).getByIds(ArgumentMatchers.any()); + Mockito.doReturn(registrationDtoList1).when(syncRegistrationService).getByIds(ArgumentMatchers.any()); + + signresponse.setSignature("abcd"); + dto.setResponse(signresponse); + Mockito.when(reprcrestclient.postApi(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(dto); + Mockito.when(syncRegistrationService.sync(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(syncResponseDtoList); + Mockito.when( + syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) + .thenReturn(Boolean.TRUE); + + } + + /** + * Search success test. + * + * @throws Exception + * the exception + */ + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void searchSuccessTest() throws Exception { + doNothing().when(registrationStatusRequestValidator).validate((registrationStatusRequestDTO), + "mosip.registration.status"); + + this.mockMvc.perform(post("/search").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void searchRegstatusException() throws Exception { + + Mockito.doThrow(new RegStatusAppException()).when(registrationStatusRequestValidator) + .validate(ArgumentMatchers.any(), ArgumentMatchers.any()); + this.mockMvc.perform(post("/search").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void testSyncController() throws Exception { + + RegistrationSyncRequestDTO registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); + List request = new ArrayList(); + SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto("45128164920495", "NEW", null, null, "eng"); + request.add(syncRegistrationDto); + String requestJson = objMp.writeValueAsString(request); + + List syncResponseList = new ArrayList<>(); + SyncResponseDto syncResponseDto = new SyncResponseDto(); + syncResponseDto.setStatus("true"); + syncResponseDto.setRegistrationId("45128164920495"); + syncResponseList.add(syncResponseDto); + + Mockito.when(syncRegistrationService.decryptAndGetSyncRequest(ArgumentMatchers.any(), ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(registrationSyncRequestDTO); + Mockito.when( + syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) + .thenReturn(true); + Mockito.when( + syncRegistrationService.sync(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) + .thenReturn(syncResponseList); + this.mockMvc.perform( + post("/sync").accept(MediaType.APPLICATION_JSON_VALUE).header("timestamp", "2019-05-07T05:13:55.704Z") + .header("Center-Machine-RefId", "abcd").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(requestJson.getBytes()).cookie(new Cookie("Authorization", requestJson))) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(value = "resident", roles = "RESIDENT") + public void testSyncV2Controller() throws Exception { + + RegistrationSyncRequestDTO registrationSyncRequestDTO = new RegistrationSyncRequestDTO(); + List request = new ArrayList(); + SyncRegistrationDto syncRegistrationDto = new SyncRegistrationDto("45128164920495", "NEW", null, null, "eng"); + request.add(syncRegistrationDto); + String requestJson = objMp.writeValueAsString(request); + + List syncResponseList = new ArrayList<>(); + SyncResponseDto syncResponseDto = new SyncResponseDto(); + syncResponseDto.setStatus("true"); + syncResponseDto.setRegistrationId("45128164920495"); + syncResponseList.add(syncResponseDto); + + Mockito.when(syncRegistrationService.decryptAndGetSyncRequest(ArgumentMatchers.any(), ArgumentMatchers.any(), + ArgumentMatchers.any(), ArgumentMatchers.any())).thenReturn(registrationSyncRequestDTO); + Mockito.when( + syncrequestvalidator.validate(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) + .thenReturn(true); + Mockito.when( + syncRegistrationService.syncV2(ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any())) + .thenReturn(syncResponseList); + this.mockMvc.perform( + post("/syncV2").accept(MediaType.APPLICATION_JSON_VALUE).header("timestamp", "2019-05-07T05:13:55.704Z") + .header("Center-Machine-RefId", "abcd").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(requestJson.getBytes()).cookie(new Cookie("Authorization", requestJson))) + .andExpect(status().isOk()); + } + + @Test + public void testBuildRegistrationSyncResponse() throws JsonProcessingException { + List syncResponseDtoList = new ArrayList<>(); + syncResponseFailureDto.setStatus("SUCCESS"); + syncResponseDtoList.add(syncResponseFailureDto); + registrationSyncController.buildRegistrationSyncResponse(syncResponseDtoList); + + } + + @Test + public void testBuildRegistrationSyncResponse1() throws JsonProcessingException { + List syncResponseDtoList = new ArrayList<>(); + SyncResponseFailDto syncResponseFailDto = new SyncResponseFailDto(); + SyncResponseFailureDto syncResponseDto = new SyncResponseFailureDto(); + + syncResponseDto.setStatus("Fail"); + syncResponseDtoList.add(syncResponseDto); + + syncResponseFailDto.setStatus("Fail"); + syncResponseDtoList.add(syncResponseFailDto); + registrationSyncController.buildRegistrationSyncResponse(syncResponseDtoList); + + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void lostRidSuccessTest() throws Exception { + doNothing().when(lostRidRequestValidator).validate((lostRidRequestDto)); + + this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void lostRidRegstatusException() throws Exception { + + Mockito.doThrow(new RegStatusAppException()).when(lostRidRequestValidator).validate(ArgumentMatchers.any()); + this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()); + } + + @Test + @WithMockUser(value = "admin", roles = "REGISTRATION_ADMIN") + public void lostRidWorkFlowSearchException() throws Exception { + + Mockito.doThrow(new WorkFlowSearchException("ERR-001", "exception occured")).when(lostRidRequestValidator) + .validate(ArgumentMatchers.any()); + this.mockMvc.perform(post("/lostridsearch").accept(MediaType.APPLICATION_JSON_VALUE) + .cookie(new Cookie("Authorization", lostRidReqToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + .content(lostRidReqToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) + .andExpect(status().isOk()); + } } \ No newline at end of file diff --git a/registration-processor/mosip-stage-executor/pom.xml b/registration-processor/mosip-stage-executor/pom.xml index 4d489c00882..26cf1564e5b 100644 --- a/registration-processor/mosip-stage-executor/pom.xml +++ b/registration-processor/mosip-stage-executor/pom.xml @@ -1,31 +1,31 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.springframework - spring-context - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.springframework + spring-context + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + + diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index 28a19731638..fbfb4db0efb 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -1,609 +1,597 @@ - - - 4.0.0 - - - MPL 2.0 - https://www.mozilla.org/en-US/MPL/2.0/ - - - - scm:git:git://github.com/mosip/registration.git - scm:git:ssh://github.com:mosip/registration.git - https://github.com/mosip/registration - HEAD - - - - Mosip - mosip.emailnotifier@gmail.com - io.mosip - https://github.com/mosip/registration - - - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - pom - - registration-processor - Parent project of MOSIP Registration processor - https://github.com/mosip/registration - - - none - UTF-8 - 11 - 11 - 3.8.0 - 3.0.2 - 3.1.0 - 2.22.0 - 0.8.5 - 3.7.0.1746 - 3.2.0 - 3.3.0 - - - 5.0.6.RELEASE - 5.0.4.RELEASE - 2.0.2.RELEASE - 2.0.9.RELEASE - 2.0.0.RELEASE - - 4.0.1.RELEASE - 2.0.0.RELEASE - - - 3.0.0 - 2.0.1.Final - 2.12.0 - 2.12.0 - 6.0.12.Final - 2.1.1 - 1.7.25 - 4.5.6 - - - 2.9.2 - - - 2.5.0 - 5.1.46 - 1.4.195 - 42.2.2 - - - 1.18.8 - - - 2.3.0 - - - 1.60 - 1.6 - - - 3.6.1 - 3.7 - 2.6 - 1.10 - 1.9.2 - 2.2 - 2.6 - 1.7 - 2.0 - - - 4.12 - 1.2.3 - 1.7.19 - 3.4.4 - 2.0.7 - 2.0.7 - 3.1.0 - 1.1.1 - 1.9 - - 1.11.368 - 0.2.4 - - - 3.9.1 - 2.23.0 - 1.0.0 - - 1.1.1 - - - 2.8.1 - - - 0.1.55 - - - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - - - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - 1.2.1-SNAPSHOT - **/dto/**, - **/exception/*Exception.java, - **/config/*Config.java, - **/handler/*ExceptionHandler.java, - **/**/*Application.java, - **/utilities/*.java, - **/validator/*Validator.java, - **/utils/*.java, - **/util/*.java, - **/code/*.java, - **/entity/*.java, - **/config/*.java, - - **/core/code/*.java, - **/packet/storage/entity/*.java, - **/manager/exception/systemexception/*.java, - **/registration/processor/rest/client/*.java, - **/registration/processor/rest/client/audit/builder/*.java, - - **/registration/processor/packet/receiver/*.java, - **/registration/processor/packet/receiver/exception/systemexception/*.java, - **/registration/processor/failoverstage/*.java, - **/registration/processor/stages/*.java, - **/registration/processor/retry/verticle/*.java, - **/registration/processor/retry/verticle/stages/*.java, - **/registration/processor/retry/verticle/constants/*.java, - **/registration/processor/packet/decrypter/job/stage/*.java, - **/registration/processor/packet/decryptor/job/exception/constant/*.java, - - **/registration/processor/virus/scanner/job/exceptions/*.java, - - - **/registration/processor/stages/app/*.java, - **/registration/processor/stages/executor/*.java, - **/registration/processor/camel/bridge/processor/*.java, - **/registration/processor/core/constant/*.java, - **/registration/processor/core/packet/dto/demographicinfo/*.java, - **/registration/processor/core/packet/dto/demographicinfo/identify/*.java, - **/registration/processor/core/packet/dto/regcentermachine/*.java, - - **/registration/processor/quality/check/client/*.java, - **/registration/processor/quality/check/code/*.java, - **/registration/processor/quality/check/entity/*.java, - **/registration/processor/quality/check/exception/*.java, - **/registration/processor/quality/check/*.java, - **/registration/processor/message/sender/*.java, - **/registration/processor/message/sender/utility/*.java, - **/registration/processor/core/logger/*.java, - **/registration/processor/core/notification/template/mapping/*.java, - **/registration/processor/bio/dedupe/service/*.java, - **/registration/processor/bio/dedupe/exception/*.java, - - **/registration/processor/packet/storage/storage/*.java, - **/registration/processor/packet/storage/exception/*.java, - **/registration/processor/status/repositary/*.java, - **/registration/processor/status/entity/*.java, - **/registration/processor/virus/scanner/job/*.java, - - - **/registration/processor/packet/uploader/*.java, - **/registration/processor/biodedupe/*.java, - - - **/registration/processor/abis/config/*.java, - **/registration/processor/abis/controller/*.java, - **/registration/processor/abis/exception/*.java, - **/registration/processor/abis/messagequeue/*.java, - **/registration/processor/abis/service/*.java, - **/registration/processor/abis/service/impl/*.java, - - - **/registration/processor/abis/handler/*.java, - **/registration/processor/abis/handler/config/*.java, - - **/registration/processor/packet/service/**/*.java, - **/registration/processor/packet/upload/**/*.java, - - **/registration/processor/status/code/*.java, - **/registration/processor/rest/client/config/RestConfigBean.java, - **/registration/processor/bio/dedupe/api/BioDedupeApiApp.java, - **/registration/processor/manual/verification/response/builder/*.java, - **/registration/processor/manual/verification/config/*.java, - **/registration/processor/stages/config/OSIConfigBean.java, - **/registration/processor/stages/demo/dedupe/StatusMessage.java, - **/registration/processor/stages/demo/dedupe/DemodedupeStage.java, - **/registration/processor/stages/demo/dedupe/BiometricValidation.java, - **/registration/processor/core/exception/ExceptionJSONInfo.java, - **/registration/processor/core/config/CoreConfigBean.java, - **/registration/processor/core/kernel/beans/KernelConfig.java, - **/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java, - **/registration/processor/core/abstractverticle/WorkflowInternalActionDTO.java, - **/registration/processor/core/http/*.java, - **/registration/processor/core/queue/factory/*.java, - **/registration/processor/core/queue/impl/*.java, - **/registration/processor/core/tracing/*.java, - **/registration/processor/message/sender/config/MsgNotificationBeanCofig.java, - **/registration/processor/abis/exception/QueueConnectionNotFound.java, - **/registration/processor/stages/demodedupe/StatusMessage.java, - **/registration/processor/stages/demodedupe/BiometricValidation.java, - **/registration/processor/camel/bridge/MosipBridgeFactory.java, - **/registration/processor/manual/verification/stage/ManualVerificationStage.java, - **/registration/processor/packet/receiver/builder/PacketReceiverResponseBuilder.java, - **/registration/processor/packet/receiver/stage/PacketReceiverStage.java, - **/registration/processor/camel/bridge/**/*.java, - **/registration/processor/stages/connector/stage/**/*.java, - **/registration/processor/stages/demodedupe/DemoDedupeStage.java, - - **/registration/processor/packet/storage/mapper/PacketInfoMapper.java, - **/registration/processor/packet/storage/dao/PacketInfoDao.java, - **/registration/processor/packet/uploader/constants/*.java, - **/registration/processor/packet/manager/constant/*.java, - **/registration/processor/packet/receiver/constants/*.java, - **/registration/processor/credentialrequestor/stage/exception/*.java, - **/registration/processor/packet/uploader/constants/*.java, - **/registration/processor/packet/uploader/decryptor/*.java, - **/registration/processor/core/abstractverticle/MosipRouter.java, - **/registration/processor/packet/uploader/decryptor/*.java, - - **/registration/processor/message/sender/constants/*.java, - **/registration/processor/core/abstractverticle/BaseHealthCheckModel.java, - **/registration/processor/core/**/TokenValidator.java, - **/registration/processor/core/abstractverticle/StageHealthCheckHandler.java, - **/registration/processor/core/abstractverticle/MessageDTO.java, - **/registration/processor/request/handler/**/*.java - - **/dto/**,**/entity/**,**/config/**,**/handler/**,**/utilities/**, - **/validator/**, **/utils/**,**/util/**,**/code/** - none - - - - - ossrh - CentralRepository - https://oss.sonatype.org/content/repositories/snapshots - default - - true - - - - central - MavenCentral - default - https://repo1.maven.org/maven2 - - false - - - - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - - - - org.mockito - mockito-core - 3.4.4 - test - - - - net.bytebuddy - byte-buddy - 1.10.13 - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - org.projectlombok - lombok - 1.18.8 - provided - - - org.powermock - powermock-core - 2.0.7 - test - - - javax.xml.bind - jaxb-api - 2.3.1 - - - org.javassist - javassist - 3.27.0-GA - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - - - - registration-processor-core - registration-processor-rest-client - registration-processor-packet-manager - registration-processor-common-camel-bridge - registration-processor-bio-dedupe-service-impl - registration-processor-info-storage-service - registration-processor-registration-status-service-impl - registration-processor-message-sender-impl - registration-processor-notification-service - init - pre-processor - core-processor - post-processor - mosip-stage-executor - stage-groups - workflow-engine - registration-processor-landing-zone - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - ${skipTests} - false - - ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --illegal-access=permit - - - - - org.jacoco - jacoco-maven-plugin - ${maven.jacoco.version} - - - - prepare-agent - - - - report - prepare-package - - report - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.version} - - ${maven.compiler.source} - ${maven.compiler.target} - - - - org.apache.maven.plugins - maven-jar-plugin - ${maven.jar.plugin.version} - - - - true - true - - - ${project.name} - ${project.version} - ${user.name} - ${os.name} - ${maven.build.timestamp} - ${env.BUILD_NUMBER} - ${env.BUILD_ID} - ${env.BUILD_URL} - - - - - - pl.project13.maven - git-commit-id-plugin - 3.0.1 - - - get-the-git-infos - - revision - - validate - - - - true - ${project.build.outputDirectory}/git.properties - - ^git.build.(time|version)$ - ^git.commit.id.(abbrev|full)$ - - full - ${project.basedir}/.git - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - --pinentry-mode - loopback - - - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven.war.plugin.version} - - - - true - true - - - ${project.name} - ${project.version} - ${user.name} - ${os.name} - ${maven.build.timestamp} - ${env.BUILD_NUMBER} - ${env.BUILD_ID} - ${env.BUILD_URL} - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven.javadoc.version} - - true - none - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - false - - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - - attach-javadocs - - jar - - - - - none - - - - - - - sonar - - . - src/main/java/**,src/main/resources/** - **/registration/processor/core/queue/factory/*.java, - ${sonar.coverage.exclusions} - https://sonarcloud.io - - - false - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - ${maven.sonar.plugin.version} - - - verify - - sonar - - - - - - - - - + + + 4.0.0 + + + MPL 2.0 + https://www.mozilla.org/en-US/MPL/2.0/ + + + + scm:git:git://github.com/mosip/registration.git + scm:git:ssh://github.com:mosip/registration.git + https://github.com/mosip/registration + HEAD + + + + Mosip + mosip.emailnotifier@gmail.com + io.mosip + https://github.com/mosip/registration + + + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + pom + + registration-processor + Parent project of MOSIP Registration processor + https://github.com/mosip/registration + + + none + UTF-8 + 21 + 21 + 3.8.0 + 3.0.2 + 3.1.0 + 2.22.0 + 0.8.11 + 3.7.0.1746 + 3.2.0 + 3.3.0 + + + 5.0.6.RELEASE + 5.0.4.RELEASE + 2.0.2.RELEASE + 2.0.9.RELEASE + 2.0.0.RELEASE + + 4.0.1.RELEASE + 2.0.0.RELEASE + + + 3.0.0 + 2.0.1.Final + 2.12.0 + 2.12.0 + 6.0.12.Final + 2.1.1 + 1.7.25 + 4.5.6 + + + 2.9.2 + + + 2.5.0 + 5.1.46 + 1.4.195 + 42.2.2 + + + 1.18.8 + + + 2.3.0 + + + 1.60 + 1.6 + + + 3.6.1 + 3.7 + 2.6 + 1.10 + 1.9.2 + 2.2 + 2.6 + 1.7 + 2.0 + + + 4.12 + 1.2.3 + 1.7.19 + 3.11.2 + 1.1.1 + 1.9 + + 1.11.368 + 0.2.4 + + + 3.9.1 + 2.23.0 + 1.0.0 + + 1.1.1 + + + 2.12.7 + + + 0.1.55 + + + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + + + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT + **/dto/**, + **/exception/*Exception.java, + **/config/*Config.java, + **/handler/*ExceptionHandler.java, + **/**/*Application.java, + **/utilities/*.java, + **/validator/*Validator.java, + **/utils/*.java, + **/util/*.java, + **/code/*.java, + **/entity/*.java, + **/config/*.java, + + **/core/code/*.java, + **/packet/storage/entity/*.java, + **/manager/exception/systemexception/*.java, + **/registration/processor/rest/client/*.java, + **/registration/processor/rest/client/audit/builder/*.java, + + **/registration/processor/packet/receiver/*.java, + **/registration/processor/packet/receiver/exception/systemexception/*.java, + **/registration/processor/failoverstage/*.java, + **/registration/processor/stages/*.java, + **/registration/processor/retry/verticle/*.java, + **/registration/processor/retry/verticle/stages/*.java, + **/registration/processor/retry/verticle/constants/*.java, + **/registration/processor/packet/decrypter/job/stage/*.java, + **/registration/processor/packet/decryptor/job/exception/constant/*.java, + + **/registration/processor/virus/scanner/job/exceptions/*.java, + + + **/registration/processor/stages/app/*.java, + **/registration/processor/stages/executor/*.java, + **/registration/processor/camel/bridge/processor/*.java, + **/registration/processor/core/constant/*.java, + **/registration/processor/core/packet/dto/demographicinfo/*.java, + **/registration/processor/core/packet/dto/demographicinfo/identify/*.java, + **/registration/processor/core/packet/dto/regcentermachine/*.java, + + **/registration/processor/quality/check/client/*.java, + **/registration/processor/quality/check/code/*.java, + **/registration/processor/quality/check/entity/*.java, + **/registration/processor/quality/check/exception/*.java, + **/registration/processor/quality/check/*.java, + **/registration/processor/message/sender/*.java, + **/registration/processor/message/sender/utility/*.java, + **/registration/processor/core/logger/*.java, + **/registration/processor/core/notification/template/mapping/*.java, + **/registration/processor/bio/dedupe/service/*.java, + **/registration/processor/bio/dedupe/exception/*.java, + + **/registration/processor/packet/storage/storage/*.java, + **/registration/processor/packet/storage/exception/*.java, + **/registration/processor/status/repositary/*.java, + **/registration/processor/status/entity/*.java, + **/registration/processor/virus/scanner/job/*.java, + + + **/registration/processor/packet/uploader/*.java, + **/registration/processor/biodedupe/*.java, + + + **/registration/processor/abis/config/*.java, + **/registration/processor/abis/controller/*.java, + **/registration/processor/abis/exception/*.java, + **/registration/processor/abis/messagequeue/*.java, + **/registration/processor/abis/service/*.java, + **/registration/processor/abis/service/impl/*.java, + + + **/registration/processor/abis/handler/*.java, + **/registration/processor/abis/handler/config/*.java, + + **/registration/processor/packet/service/**/*.java, + **/registration/processor/packet/upload/**/*.java, + + **/registration/processor/status/code/*.java, + **/registration/processor/rest/client/config/RestConfigBean.java, + **/registration/processor/bio/dedupe/api/BioDedupeApiApp.java, + **/registration/processor/manual/verification/response/builder/*.java, + **/registration/processor/manual/verification/config/*.java, + **/registration/processor/stages/config/OSIConfigBean.java, + **/registration/processor/stages/demo/dedupe/StatusMessage.java, + **/registration/processor/stages/demo/dedupe/DemodedupeStage.java, + **/registration/processor/stages/demo/dedupe/BiometricValidation.java, + **/registration/processor/core/exception/ExceptionJSONInfo.java, + **/registration/processor/core/config/CoreConfigBean.java, + **/registration/processor/core/kernel/beans/KernelConfig.java, + **/registration/processor/core/abstractverticle/MosipVerticleAPIManager.java, + **/registration/processor/core/abstractverticle/WorkflowInternalActionDTO.java, + **/registration/processor/core/http/*.java, + **/registration/processor/core/queue/factory/*.java, + **/registration/processor/core/queue/impl/*.java, + **/registration/processor/core/tracing/*.java, + **/registration/processor/message/sender/config/MsgNotificationBeanCofig.java, + **/registration/processor/abis/exception/QueueConnectionNotFound.java, + **/registration/processor/stages/demodedupe/StatusMessage.java, + **/registration/processor/stages/demodedupe/BiometricValidation.java, + **/registration/processor/camel/bridge/MosipBridgeFactory.java, + **/registration/processor/manual/verification/stage/ManualVerificationStage.java, + **/registration/processor/packet/receiver/builder/PacketReceiverResponseBuilder.java, + **/registration/processor/packet/receiver/stage/PacketReceiverStage.java, + **/registration/processor/camel/bridge/**/*.java, + **/registration/processor/stages/connector/stage/**/*.java, + **/registration/processor/stages/demodedupe/DemoDedupeStage.java, + + **/registration/processor/packet/storage/mapper/PacketInfoMapper.java, + **/registration/processor/packet/storage/dao/PacketInfoDao.java, + **/registration/processor/packet/uploader/constants/*.java, + **/registration/processor/packet/manager/constant/*.java, + **/registration/processor/packet/receiver/constants/*.java, + **/registration/processor/credentialrequestor/stage/exception/*.java, + **/registration/processor/packet/uploader/constants/*.java, + **/registration/processor/packet/uploader/decryptor/*.java, + **/registration/processor/core/abstractverticle/MosipRouter.java, + **/registration/processor/packet/uploader/decryptor/*.java, + + **/registration/processor/message/sender/constants/*.java, + **/registration/processor/core/abstractverticle/BaseHealthCheckModel.java, + **/registration/processor/core/**/TokenValidator.java, + **/registration/processor/core/abstractverticle/StageHealthCheckHandler.java, + **/registration/processor/core/abstractverticle/MessageDTO.java, + **/registration/processor/request/handler/**/*.java + + **/dto/**,**/entity/**,**/config/**,**/handler/**,**/utilities/**, + **/validator/**, **/utils/**,**/util/**,**/code/** + none + + + + + ossrh + CentralRepository + https://oss.sonatype.org/content/repositories/snapshots + default + + true + + + + central + MavenCentral + default + https://repo1.maven.org/maven2 + + false + + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + net.bytebuddy + byte-buddy + 1.10.13 + + + org.powermock + powermock-core + 2.0.7 + test + + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.javassist + javassist + 3.27.0-GA + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + io.mosip.kernel + kernel-bom + 1.2.1-java21-SNAPSHOT + pom + import + + + + + + registration-processor-core + registration-processor-rest-client + registration-processor-packet-manager + registration-processor-common-camel-bridge + registration-processor-bio-dedupe-service-impl + registration-processor-info-storage-service + registration-processor-registration-status-service-impl + registration-processor-message-sender-impl + registration-processor-notification-service + init + pre-processor + core-processor + post-processor + mosip-stage-executor + stage-groups + workflow-engine + registration-processor-landing-zone + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.plugin.version} + + ${skipTests} + false + + ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --illegal-access=permit + + + + + org.jacoco + jacoco-maven-plugin + ${maven.jacoco.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + + + + + org.apache.maven.plugins + maven-jar-plugin + ${maven.jar.plugin.version} + + + + true + true + + + ${project.name} + ${project.version} + ${user.name} + ${os.name} + ${maven.build.timestamp} + ${env.BUILD_NUMBER} + ${env.BUILD_ID} + ${env.BUILD_URL} + + + + + + pl.project13.maven + git-commit-id-plugin + 3.0.1 + + + get-the-git-infos + + revision + + validate + + + + true + ${project.build.outputDirectory}/service-git.properties + + ^git.build.(time|version)$ + ^git.commit.id.(abbrev|full)$ + + full + ${project.basedir}/.git + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven.war.plugin.version} + + + + true + true + + + ${project.name} + ${project.version} + ${user.name} + ${os.name} + ${maven.build.timestamp} + ${env.BUILD_NUMBER} + ${env.BUILD_ID} + ${env.BUILD_URL} + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven.javadoc.version} + + true + none + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://oss.sonatype.org/ + false + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + attach-javadocs + + jar + + + + + none + + + + + + + sonar + + . + src/main/java/**,src/main/resources/** + **/registration/processor/core/queue/factory/*.java, + ${sonar.coverage.exclusions} + https://sonarcloud.io + + + false + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${maven.sonar.plugin.version} + + + verify + + sonar + + + + + + + + + diff --git a/registration-processor/post-processor/pom.xml b/registration-processor/post-processor/pom.xml index 3aba489bf87..05eb249f89c 100644 --- a/registration-processor/post-processor/pom.xml +++ b/registration-processor/post-processor/pom.xml @@ -1,22 +1,22 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - post-processor - post-processor - - UTF-8 - - - registration-processor-message-sender-stage - registration-processor-credential-requestor-stage - registration-processor-registration-transaction-service - - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + post-processor + post-processor + + UTF-8 + + + registration-processor-message-sender-stage + registration-processor-credential-requestor-stage + registration-processor-registration-transaction-service + + diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml index 8df5b0653f1..af95750d0d1 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml @@ -1,111 +1,109 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - post-processor - 1.2.1-SNAPSHOT - - registration-processor-credential-requestor-stage - 1.2.1-SNAPSHOT - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.vertx - vertx-unit - ${vertx.version} - test - - - io.vertx - vertx-web-client - ${vertx.version} - - - org.apache.httpcomponents - httpmime - 4.3.1 - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.mvel - mvel2 - 2.4.12.Final - - - junit - junit - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + post-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-credential-requestor-stage + 1.2.1-java21-SNAPSHOT + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + ${spring-framework.version} + + + org.springframework + spring-tx + ${spring-framework.version} + + + io.vertx + vertx-unit + ${vertx.version} + test + + + io.vertx + vertx-web-client + ${vertx.version} + + + org.apache.httpcomponents + httpmime + 4.3.1 + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.mvel + mvel2 + 2.4.12.Final + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + + + + + diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java index 5cd509ff627..e331031ee33 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/util/CredentialPartnerUtil.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.Optional; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.apache.commons.collections.MapUtils; import org.assertj.core.util.Lists; diff --git a/registration-processor/post-processor/registration-processor-message-sender-stage/pom.xml b/registration-processor/post-processor/registration-processor-message-sender-stage/pom.xml index dd5d1227441..fdb91bcb40a 100644 --- a/registration-processor/post-processor/registration-processor-message-sender-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-message-sender-stage/pom.xml @@ -1,103 +1,97 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - post-processor - 1.2.1-SNAPSHOT - - - registration-processor-message-sender-stage - 1.2.1-SNAPSHOT - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-message-sender-impl - ${registration.processor.message.sender.version} - - - junit - junit - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - - - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + post-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-message-sender-stage + 1.2.1-java21-SNAPSHOT + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-message-sender-impl + ${registration.processor.message.sender.version} + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + + + + + diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile index 18d9125c225..506be6d6e06 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine #Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image #FROM openjdk:8-jdk-alpine @@ -60,15 +60,15 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml index f06783c4ebf..b02319b49d6 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml @@ -1,171 +1,171 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - post-processor - 1.2.1-SNAPSHOT - - registration-processor-registration-transaction-service - 1.2.1-SNAPSHOT - registration-processor-registration-transaction-service - - UTF-8 - - - - - javax.servlet - javax.servlet-api - 4.0.1 - - - junit - junit - test - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.security - spring-security-test - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.springfox - springfox-swagger-ui - - - io.springfox - springfox-swagger2 - - - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.springdoc - springdoc-openapi-ui - 1.5.10 - - - org.springframework.boot - spring-boot-configuration-processor - ${spring.boot.version} - true - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - - build-info - repackage - - - - - - - - - openapi-doc-generate-profile - - - io.mosip.kernel - kernel-auth-adapter - ${project.version} - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - pre-integration-test - - start - - - - src/test/resources - - - openapi-profile - - - --server.port=8090 - --server.servlet.path=/app/generic - - - - - post-integration-test - - stop - - - - - build-info - repackage - - - - - - org.springdoc - springdoc-openapi-maven-plugin - 0.2 - - - integration-test - - generate - - - - - http://localhost:8090/app/generic/v3/api-docs - ${name}-openapi.json - - ${project.build.directory} - false - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + post-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-registration-transaction-service + 1.2.1-java21-SNAPSHOT + registration-processor-registration-transaction-service + + UTF-8 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + + + junit + junit + test + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-test + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.springfox + springfox-swagger-ui + + + io.springfox + springfox-swagger2 + + + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.springdoc + springdoc-openapi-ui + 1.5.10 + + + org.springframework.boot + spring-boot-configuration-processor + ${spring.boot.version} + true + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + + build-info + repackage + + + + + + + + + openapi-doc-generate-profile + + + io.mosip.kernel + kernel-auth-adapter + ${project.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + pre-integration-test + + start + + + + src/test/resources + + + openapi-profile + + + --server.port=8090 + --server.servlet.path=/app/generic + + + + + post-integration-test + + stop + + + + + build-info + repackage + + + + + + org.springdoc + springdoc-openapi-maven-plugin + 0.2 + + + integration-test + + generate + + + + + http://localhost:8090/app/generic/v3/api-docs + ${name}-openapi.json + + ${project.build.directory} + false + + + + + + + diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/controller/RegistrationTransactionController.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/controller/RegistrationTransactionController.java index 8a4289913ba..0b28186dcaf 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/controller/RegistrationTransactionController.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/controller/RegistrationTransactionController.java @@ -3,7 +3,7 @@ import java.util.List; import java.util.Objects; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/test/java/io/mosip/registration/processor/transaction/api/transaction/api/config/TransactionServiceSecurityConfig.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/test/java/io/mosip/registration/processor/transaction/api/transaction/api/config/TransactionServiceSecurityConfig.java index c555bebf824..866c4a9c271 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/test/java/io/mosip/registration/processor/transaction/api/transaction/api/config/TransactionServiceSecurityConfig.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/test/java/io/mosip/registration/processor/transaction/api/transaction/api/config/TransactionServiceSecurityConfig.java @@ -1,99 +1,93 @@ -package io.mosip.registration.processor.transaction.api.transaction.api.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.provisioning.InMemoryUserDetailsManager; -import org.springframework.security.web.AuthenticationEntryPoint; -import org.springframework.security.web.firewall.DefaultHttpFirewall; -import org.springframework.security.web.firewall.HttpFirewall; - -import javax.servlet.http.HttpServletResponse; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * The Class PrintServiceSecurityConfig. - * - * @author M1045447 Mono - */ -@Configuration -@EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class TransactionServiceSecurityConfig extends WebSecurityConfigurerAdapter { - - /** - * Default http firewall. - * - * @return the http firewall - */ - @Bean - public HttpFirewall defaultHttpFirewall() { - return new DefaultHttpFirewall(); - } - - /* (non-Javadoc) - * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.web.builders.WebSecurity) - */ - @Override - public void configure(WebSecurity webSecurity) throws Exception { - webSecurity.ignoring().antMatchers(allowedEndPoints()); - super.configure(webSecurity); - webSecurity.httpFirewall(defaultHttpFirewall()); - } - - /** - * Allowed end points. - * - * @return the string[] - */ - private String[] allowedEndPoints() { - return new String[] { "/assets/**", "/icons/**", "/screenshots/**", "/favicon**", "/**/favicon**", "/css/**", - "/js/**", "/*/error**", "/*/webjars/**", "/*/v2/api-docs", "/*/configuration/ui", - "/*/configuration/security", "/*/swagger-resources/**", "/*/swagger-ui.html" }; - } - - /* (non-Javadoc) - * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.web.builders.HttpSecurity) - */ - @Override - protected void configure(final HttpSecurity httpSecurity) throws Exception { - httpSecurity.csrf().disable(); - httpSecurity.httpBasic().and().authorizeRequests().anyRequest().authenticated().and().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().exceptionHandling() - .authenticationEntryPoint(unauthorizedEntryPoint()); - } - - /** - * Unauthorized entry point. - * - * @return the authentication entry point - */ - @Bean - public AuthenticationEntryPoint unauthorizedEntryPoint() { - return (request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - } - - /* (non-Javadoc) - * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#userDetailsService() - */ - @Bean - public UserDetailsService userDetailsService() { - List users = new ArrayList<>(); - users.add(new User("reg-processor", "mosip", - Arrays.asList(new SimpleGrantedAuthority("ROLE_REGISTRATION_PROCESSOR")))); - users.add(new User("reg-admin", "mosip", - Arrays.asList(new SimpleGrantedAuthority("ROLE_REGISTRATION_ADMIN")))); - return new InMemoryUserDetailsManager(users); - } +package io.mosip.registration.processor.transaction.api.transaction.api.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.firewall.DefaultHttpFirewall; +import org.springframework.security.web.firewall.HttpFirewall; + +import jakarta.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * The Class PrintServiceSecurityConfig. + * + * @author M1045447 Mono + */ +@Configuration +@EnableWebSecurity +public class TransactionServiceSecurityConfig { + + /** + * Default http firewall. + * + * @return the http firewall + */ + @Bean + public HttpFirewall defaultHttpFirewall() { + return new DefaultHttpFirewall(); + } + + @Bean + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring().requestMatchers(allowedEndPoints()).and().httpFirewall(defaultHttpFirewall()); + } + + /** + * Allowed end points. + * + * @return the string[] + */ + private String[] allowedEndPoints() { + return new String[] { "/assets/**", "/icons/**", "/screenshots/**", "/favicon**", "/**/favicon**", "/css/**", + "/js/**", "/*/error**", "/*/webjars/**", "/*/v2/api-docs", "/*/configuration/ui", + "/*/configuration/security", "/*/swagger-resources/**", "/*/swagger-ui.html" }; + } + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.csrf(csrf -> csrf.disable()) + .exceptionHandling(exception -> exception.authenticationEntryPoint(unauthorizedEntryPoint())) + .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) + .authorizeHttpRequests((authz) -> authz.anyRequest().authenticated()) + .userDetailsService(userDetailsService()); + + return http.build(); + } + + /** + * Unauthorized entry point. + * + * @return the authentication entry point + */ + @Bean + public AuthenticationEntryPoint unauthorizedEntryPoint() { + return (request, response, authException) -> response.sendError(HttpServletResponse.SC_UNAUTHORIZED); + } + + /* (non-Javadoc) + * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#userDetailsService() + */ + @Bean + public UserDetailsService userDetailsService() { + List users = new ArrayList<>(); + users.add(new User("reg-processor", "mosip", + Arrays.asList(new SimpleGrantedAuthority("ROLE_REGISTRATION_PROCESSOR")))); + users.add(new User("reg-admin", "mosip", + Arrays.asList(new SimpleGrantedAuthority("ROLE_REGISTRATION_ADMIN")))); + return new InMemoryUserDetailsManager(users); + } } \ No newline at end of file diff --git a/registration-processor/pre-processor/pom.xml b/registration-processor/pre-processor/pom.xml index ffbd011138d..696de9f7230 100644 --- a/registration-processor/pre-processor/pom.xml +++ b/registration-processor/pre-processor/pom.xml @@ -1,29 +1,29 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - pre-processor - pre-processor - - UTF-8 - - - registration-processor-packet-validator-stage - registration-processor-cmd-validator-stage - registration-processor-operator-validator-stage - registration-processor-supervisor-validator-stage - registration-processor-introducer-validator-stage - registration-processor-packet-uploader-stage - registration-processor-quality-classifier-stage - registration-processor-securezone-notification-stage - registration-processor-packet-classifier-stage - - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + pre-processor + pre-processor + + UTF-8 + + + registration-processor-packet-validator-stage + registration-processor-cmd-validator-stage + registration-processor-operator-validator-stage + registration-processor-supervisor-validator-stage + registration-processor-introducer-validator-stage + registration-processor-packet-uploader-stage + registration-processor-quality-classifier-stage + registration-processor-securezone-notification-stage + registration-processor-packet-classifier-stage + + diff --git a/registration-processor/pre-processor/registration-processor-cmd-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-cmd-validator-stage/pom.xml index 78669832088..84079ac823b 100644 --- a/registration-processor/pre-processor/registration-processor-cmd-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-cmd-validator-stage/pom.xml @@ -1,119 +1,108 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-cmd-validator-stage - 1.2.1-SNAPSHOT - registration-processor-cmd-validator-stage - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-bioapi-provider - ${kernel.bioapi.provider.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-cmd-validator-stage + 1.2.1-java21-SNAPSHOT + registration-processor-cmd-validator-stage + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/pom.xml index 792f9b93d8f..d563f78c48d 100644 --- a/registration-processor/pre-processor/registration-processor-introducer-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-introducer-validator-stage/pom.xml @@ -1,119 +1,109 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-introducer-validator-stage - 1.2.1-SNAPSHOT - registration-processor-introducer-validator-stage - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-bioapi-provider - ${kernel.bioapi.provider.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-introducer-validator-stage + 1.2.1-java21-SNAPSHOT + registration-processor-introducer-validator-stage + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-operator-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-operator-validator-stage/pom.xml index 7b98d5354a0..67acc02d3bd 100644 --- a/registration-processor/pre-processor/registration-processor-operator-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-operator-validator-stage/pom.xml @@ -1,119 +1,109 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-operator-validator-stage - 1.2.1-SNAPSHOT - registration-processor-operator-validator-stage - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-bioapi-provider - ${kernel.bioapi.provider.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-operator-validator-stage + 1.2.1-java21-SNAPSHOT + registration-processor-operator-validator-stage + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml index 706352df0d8..e90ebc709c4 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml @@ -1,122 +1,115 @@ - - - 4.0.0 - - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-packet-classifier-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - - io.mosip.registrationprocessor - registration-processor-message-sender-impl - ${registration.processor.message.sender.version} - - - commons-io - commons-io - ${commons.io.version} - - - junit - junit - 4.12 - test - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.springframework.boot - spring-boot-starter-webflux - ${spring.boot.version} - - - org.mvel - mvel2 - 2.4.12.Final - - - - - - - + + + 4.0.0 + + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-packet-classifier-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + + io.mosip.registrationprocessor + registration-processor-message-sender-impl + ${registration.processor.message.sender.version} + + + commons-io + commons-io + + + junit + junit + test + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.springframework.boot + spring-boot-starter-webflux + + + org.mvel + mvel2 + 2.4.12.Final + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/PacketClassificationProcessor.java b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/PacketClassificationProcessor.java index 4923312f25d..42d1ea14582 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/PacketClassificationProcessor.java +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/PacketClassificationProcessor.java @@ -1,380 +1,380 @@ -package io.mosip.registration.processor.stages.packetclassifier; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.dao.DataAccessException; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.kernel.core.exception.BaseUncheckedException; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.code.EventId; -import io.mosip.registration.processor.core.code.EventName; -import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.ModuleName; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.storage.exception.ParsingException; -import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO; -import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.exception.TablenotAccessibleException; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class PacketClassificationProcessor contain the logic of how to invoke various - * configured tag generators, combine all generated tags and trigger adding them to the packet - * - * @author Vishwanath V - */ -@Service -@Transactional -public class PacketClassificationProcessor { - - /** - * The reg proc logger. - */ - private static Logger regProcLogger = - RegProcessorLogger.getLogger(PacketClassificationProcessor.class); - - /** - * The Constant USER. - */ - private static final String USER = "MOSIP_SYSTEM"; - - private static final String VALUE = "value"; - - /* - * java class to trim exception message - */ - private TrimExceptionMessage trimExpMessage = new TrimExceptionMessage(); - - /** The tag value that will be used by default when the packet does not have value for the tag field */ - @Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}") - private String notAvailableTagValue; - - /** - * The packet manager service that will invoked for all the packet related activities - */ - @Autowired - private PriorityBasedPacketManagerService priorityBasedPacketManagerService; - - @Autowired - private PacketManagerService packetManagerService; - - /** - * The registration status service. - */ - @Autowired - RegistrationStatusService registrationStatusService; - - /** - * The core audit request builder. - */ - @Autowired - AuditLogRequestBuilder auditLogRequestBuilder; - - /** - * The mapper util that holds the mapping to decide whether to fail or reprocess the packet - */ - @Autowired - RegistrationExceptionMapperUtil registrationStatusMapperUtil; - - /** - * Frequently used util methods are available in this bean - */ - @Autowired - private Utilities utility; - - /** - * Holds all the util methods to deal with Id schema - */ - @Autowired - private IdSchemaUtil idSchemaUtil; - - /** - * This List will contain all the tag generators that is applicable as per the configuration - */ - @Autowired - private List tagGenerators; - - /** - * Id object fields required by all the configured tag generators will be maintained here - */ - private List requiredIdObjectFieldNames; - - private String idSchemaVersionLabel; - - /** - * Once this bean is initialized and all properties are set, each configured tag - * generator is invoked to collect all the required Id object field names - * - * @throws IOException - */ - @PostConstruct - private void collectRequiredIdObjectFieldNames() throws BaseCheckedException, IOException { - regProcLogger.info("collectRequiredIdObjectFieldNames called in PostConstruct"); - try { - requiredIdObjectFieldNames = new ArrayList(); - org.json.simple.JSONObject identityMappingJson = utility.getRegistrationProcessorMappingJson( - MappingJsonConstants.IDENTITY); - idSchemaVersionLabel = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(identityMappingJson, MappingJsonConstants.IDSCHEMA_VERSION), VALUE); - requiredIdObjectFieldNames.add(idSchemaVersionLabel); - for(TagGenerator tagGenerator : tagGenerators) { - regProcLogger.info("TagGenerator enabled : {}", tagGenerator.getClass().toString()); - List idFieldNames; - idFieldNames = tagGenerator.getRequiredIdObjectFieldNames(); - if(idFieldNames != null && !idFieldNames.isEmpty()) - requiredIdObjectFieldNames.addAll(idFieldNames); - } - } catch (BaseCheckedException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), - PlatformErrorMessages.RPR_PCM_COLLECT_IDOBJECT_FIELD_FAILED.getCode(), - PlatformErrorMessages.RPR_PCM_COLLECT_IDOBJECT_FIELD_FAILED.getMessage() - + e.getMessage() + ExceptionUtils.getStackTrace(e)); - throw e; - } catch (IOException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), - PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getCode(), - PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getMessage() - + e.getMessage() + ExceptionUtils.getStackTrace(e)); - throw e; - } - } - - /** - * Process methods will be called will the stage to perform packet classification for each packet - * @param object This is the actual event object will contains all the meta information about the packet - * @param stageName The stageName that needs to be used in audit and status updates - * @return The same event object with proper internal error and valid status set - */ - public MessageDTO process(MessageDTO object, String stageName) { - - LogDescription description = new LogDescription(); - boolean isTransactionSuccessful = false; - String registrationId = ""; - - InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - registrationStatusDto.setLatestTransactionTypeCode( - RegistrationTransactionTypeCode.PACKET_CLASSIFICATION.toString()); - registrationStatusDto.setRegistrationStageName(stageName); - - try { - object.setMessageBusAddress(MessageBusAddress.PACKET_CLASSIFIER_BUS_IN); - object.setIsValid(Boolean.FALSE); - object.setInternalError(Boolean.TRUE); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), "", - "PacketClassificationProcessor::process()::entry"); - registrationId = object.getRid(); - - registrationStatusDto = registrationStatusService.getRegistrationStatus( - registrationId, object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); - registrationStatusDto.setLatestTransactionTypeCode( - RegistrationTransactionTypeCode.PACKET_CLASSIFICATION.toString()); - registrationStatusDto.setRegistrationStageName(stageName); - - generateAndAddTags(registrationStatusDto.getWorkflowInstanceId(), registrationId, - registrationStatusDto.getRegistrationType(), object.getIteration()); - object.setTags(null); - - registrationStatusDto.setLatestTransactionStatusCode( - RegistrationTransactionStatusCode.SUCCESS.toString()); - registrationStatusDto.setStatusComment( - StatusUtil.PACKET_CLASSIFICATION_SUCCESS.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_CLASSIFICATION_SUCCESS.getCode()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); - - description.setMessage( - PlatformSuccessMessages.RPR_PKR_PACKET_CLASSIFIER.getMessage() + " -- " + registrationId); - description.setCode(PlatformSuccessMessages.RPR_PKR_PACKET_CLASSIFIER.getCode()); - - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), registrationId, - description.getCode() + description.getMessage()); - - object.setIsValid(Boolean.TRUE); - object.setInternalError(Boolean.FALSE); - isTransactionSuccessful = true; - } catch (PacketManagerException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, - StatusUtil.PACKET_MANAGER_EXCEPTION, RegistrationExceptionTypeCode.PACKET_MANAGER_EXCEPTION, - description, PlatformErrorMessages.PACKET_MANAGER_EXCEPTION, e); - } catch (DataAccessException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, - StatusUtil.DB_NOT_ACCESSIBLE, RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION, - description, PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); - } catch (IOException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, - StatusUtil.IO_EXCEPTION, RegistrationExceptionTypeCode.IOEXCEPTION, - description, PlatformErrorMessages.RPR_SYS_IO_EXCEPTION, e); - } catch (ParsingException | JsonProcessingException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, - StatusUtil.JSON_PARSING_EXCEPTION, RegistrationExceptionTypeCode.PARSE_EXCEPTION, - description, PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION, e); - } catch (TablenotAccessibleException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, - StatusUtil.DB_NOT_ACCESSIBLE, RegistrationExceptionTypeCode.TABLE_NOT_ACCESSIBLE_EXCEPTION, - description, PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); - } catch (BaseUncheckedException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, - StatusUtil.BASE_UNCHECKED_EXCEPTION, RegistrationExceptionTypeCode.BASE_UNCHECKED_EXCEPTION, - description, PlatformErrorMessages.RPR_PCM_BASE_UNCHECKED_EXCEPTION, e); - } catch (BaseCheckedException e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, - StatusUtil.BASE_CHECKED_EXCEPTION, RegistrationExceptionTypeCode.BASE_CHECKED_EXCEPTION, - description, PlatformErrorMessages.RPR_PCM_BASE_CHECKED_EXCEPTION, e); - } catch (Exception e) { - updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, - StatusUtil.UNKNOWN_EXCEPTION_OCCURED, RegistrationExceptionTypeCode.EXCEPTION, - description, PlatformErrorMessages.PACKET_CLASSIFICATION_FAILED, e); - } finally { - if (object.getInternalError()) { - int retryCount = registrationStatusDto.getRetryCount() != null - ? registrationStatusDto.getRetryCount() + 1 - : 1; - registrationStatusDto.setRetryCount(retryCount); - updateErrorFlags(registrationStatusDto, object); - } - registrationStatusDto.setUpdatedBy(USER); - /** Module-Id can be Both Success/Error code */ - String moduleId = description.getCode(); - String moduleName = ModuleName.PACKET_CLASSIFIER.toString(); - registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); - updateAudit(description, isTransactionSuccessful, moduleId, moduleName, registrationId); - } - - return object; - } - - private void updateDTOsAndLogError(InternalRegistrationStatusDto registrationStatusDto, - RegistrationStatusCode registrationStatusCode, StatusUtil statusUtil, - RegistrationExceptionTypeCode registrationExceptionTypeCode, LogDescription description, - PlatformErrorMessages platformErrorMessages, Exception e) { - registrationStatusDto.setStatusCode(registrationStatusCode.toString()); - registrationStatusDto.setStatusComment(trimExpMessage - .trimExceptionMessage(statusUtil.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(statusUtil.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(registrationExceptionTypeCode)); - description.setMessage(platformErrorMessages.getMessage()); - description.setCode(platformErrorMessages.getCode()); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), - description.getCode() + " -- " + registrationStatusDto.getRegistrationId(), - platformErrorMessages.getMessage() + e.getMessage() + ExceptionUtils.getStackTrace(e)); - } - - private void updateAudit(LogDescription description, boolean isTransactionSuccessful, String moduleId, - String moduleName, String registrationId) { - String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() - : EventId.RPR_405.toString(); - String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() - : EventName.EXCEPTION.toString(); - String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() - : EventType.SYSTEM.toString(); - - auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, - eventType, moduleId, moduleName, registrationId); - } - - private void generateAndAddTags(String workflowInstanceId, String registrationId, String process, int iteration) - throws IOException, BaseCheckedException, NumberFormatException, JSONException { - regProcLogger.debug("generateAndAddTags called for registration id {} {}", registrationId, - requiredIdObjectFieldNames); - Map identityFieldValueMap = priorityBasedPacketManagerService.getFields(registrationId, - requiredIdObjectFieldNames, process, ProviderStageName.CLASSIFICATION); - Map fieldTypeMap = getFieldTypeMap(identityFieldValueMap.get(idSchemaVersionLabel)); - Map idObjectFieldDTOMap = - getIdObjectFieldDTOMap(identityFieldValueMap, fieldTypeMap); - Map metaInfoMap = priorityBasedPacketManagerService.getMetaInfo(registrationId, process, ProviderStageName.CLASSIFICATION); - Map allTags = new HashMap(); - for(TagGenerator tagGenerator : tagGenerators) { - Map tags = tagGenerator.generateTags(workflowInstanceId, registrationId, process, - idObjectFieldDTOMap, metaInfoMap, iteration); - if(tags != null && !tags.isEmpty()) - allTags.putAll(tags); - } - handleNullValueTags(allTags); - regProcLogger.debug("generated tags {}", new JSONObject(allTags).toString()); - if(!allTags.isEmpty()) - packetManagerService.addOrUpdateTags(registrationId, allTags); - } - - private Map getIdObjectFieldDTOMap(Map identityFieldValueMap, - Map fieldTypeMap ) { - Map idObjectFieldMap = new HashMap<>(); - identityFieldValueMap.forEach((key,value) -> { - idObjectFieldMap.put(key, new FieldDTO(fieldTypeMap.get(key), value)); - }); - return idObjectFieldMap; - } - - private Map getFieldTypeMap(String idSchemaVersion) - throws NumberFormatException, ApisResourceAccessException, JSONException, IOException { - - Map fieldTypeMap = idSchemaUtil.getIdSchemaFieldTypes( - Double.parseDouble(idSchemaVersion)); - regProcLogger.debug("getDefaultFields item {}", new JSONObject(fieldTypeMap).toString()); - return fieldTypeMap; - } - - private void handleNullValueTags(Map tags) { - for (Map.Entry entry : tags.entrySet()) { - if(entry.getValue() == null) - entry.setValue(notAvailableTagValue); - } - } - - private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { - object.setInternalError(true); - if (registrationStatusDto.getLatestTransactionStatusCode() - .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { - object.setIsValid(true); - } else { - object.setIsValid(false); - } - } - -} +package io.mosip.registration.processor.stages.packetclassifier; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jakarta.annotation.PostConstruct; + +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.dao.DataAccessException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.kernel.core.exception.BaseUncheckedException; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.code.EventId; +import io.mosip.registration.processor.core.code.EventName; +import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.ModuleName; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.storage.exception.ParsingException; +import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO; +import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.exception.TablenotAccessibleException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +/** + * The Class PacketClassificationProcessor contain the logic of how to invoke various + * configured tag generators, combine all generated tags and trigger adding them to the packet + * + * @author Vishwanath V + */ +@Service +@Transactional +public class PacketClassificationProcessor { + + /** + * The reg proc logger. + */ + private static Logger regProcLogger = + RegProcessorLogger.getLogger(PacketClassificationProcessor.class); + + /** + * The Constant USER. + */ + private static final String USER = "MOSIP_SYSTEM"; + + private static final String VALUE = "value"; + + /* + * java class to trim exception message + */ + private TrimExceptionMessage trimExpMessage = new TrimExceptionMessage(); + + /** The tag value that will be used by default when the packet does not have value for the tag field */ + @Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}") + private String notAvailableTagValue; + + /** + * The packet manager service that will invoked for all the packet related activities + */ + @Autowired + private PriorityBasedPacketManagerService priorityBasedPacketManagerService; + + @Autowired + private PacketManagerService packetManagerService; + + /** + * The registration status service. + */ + @Autowired + RegistrationStatusService registrationStatusService; + + /** + * The core audit request builder. + */ + @Autowired + AuditLogRequestBuilder auditLogRequestBuilder; + + /** + * The mapper util that holds the mapping to decide whether to fail or reprocess the packet + */ + @Autowired + RegistrationExceptionMapperUtil registrationStatusMapperUtil; + + /** + * Frequently used util methods are available in this bean + */ + @Autowired + private Utilities utility; + + /** + * Holds all the util methods to deal with Id schema + */ + @Autowired + private IdSchemaUtil idSchemaUtil; + + /** + * This List will contain all the tag generators that is applicable as per the configuration + */ + @Autowired + private List tagGenerators; + + /** + * Id object fields required by all the configured tag generators will be maintained here + */ + private List requiredIdObjectFieldNames; + + private String idSchemaVersionLabel; + + /** + * Once this bean is initialized and all properties are set, each configured tag + * generator is invoked to collect all the required Id object field names + * + * @throws IOException + */ + @PostConstruct + private void collectRequiredIdObjectFieldNames() throws BaseCheckedException, IOException { + regProcLogger.info("collectRequiredIdObjectFieldNames called in PostConstruct"); + try { + requiredIdObjectFieldNames = new ArrayList(); + org.json.simple.JSONObject identityMappingJson = utility.getRegistrationProcessorMappingJson( + MappingJsonConstants.IDENTITY); + idSchemaVersionLabel = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(identityMappingJson, MappingJsonConstants.IDSCHEMA_VERSION), VALUE); + requiredIdObjectFieldNames.add(idSchemaVersionLabel); + for(TagGenerator tagGenerator : tagGenerators) { + regProcLogger.info("TagGenerator enabled : {}", tagGenerator.getClass().toString()); + List idFieldNames; + idFieldNames = tagGenerator.getRequiredIdObjectFieldNames(); + if(idFieldNames != null && !idFieldNames.isEmpty()) + requiredIdObjectFieldNames.addAll(idFieldNames); + } + } catch (BaseCheckedException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), + PlatformErrorMessages.RPR_PCM_COLLECT_IDOBJECT_FIELD_FAILED.getCode(), + PlatformErrorMessages.RPR_PCM_COLLECT_IDOBJECT_FIELD_FAILED.getMessage() + + e.getMessage() + ExceptionUtils.getStackTrace(e)); + throw e; + } catch (IOException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getCode(), + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getMessage() + + e.getMessage() + ExceptionUtils.getStackTrace(e)); + throw e; + } + } + + /** + * Process methods will be called will the stage to perform packet classification for each packet + * @param object This is the actual event object will contains all the meta information about the packet + * @param stageName The stageName that needs to be used in audit and status updates + * @return The same event object with proper internal error and valid status set + */ + public MessageDTO process(MessageDTO object, String stageName) { + + LogDescription description = new LogDescription(); + boolean isTransactionSuccessful = false; + String registrationId = ""; + + InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + registrationStatusDto.setLatestTransactionTypeCode( + RegistrationTransactionTypeCode.PACKET_CLASSIFICATION.toString()); + registrationStatusDto.setRegistrationStageName(stageName); + + try { + object.setMessageBusAddress(MessageBusAddress.PACKET_CLASSIFIER_BUS_IN); + object.setIsValid(Boolean.FALSE); + object.setInternalError(Boolean.TRUE); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), "", + "PacketClassificationProcessor::process()::entry"); + registrationId = object.getRid(); + + registrationStatusDto = registrationStatusService.getRegistrationStatus( + registrationId, object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); + registrationStatusDto.setLatestTransactionTypeCode( + RegistrationTransactionTypeCode.PACKET_CLASSIFICATION.toString()); + registrationStatusDto.setRegistrationStageName(stageName); + + generateAndAddTags(registrationStatusDto.getWorkflowInstanceId(), registrationId, + registrationStatusDto.getRegistrationType(), object.getIteration()); + object.setTags(null); + + registrationStatusDto.setLatestTransactionStatusCode( + RegistrationTransactionStatusCode.SUCCESS.toString()); + registrationStatusDto.setStatusComment( + StatusUtil.PACKET_CLASSIFICATION_SUCCESS.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_CLASSIFICATION_SUCCESS.getCode()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); + + description.setMessage( + PlatformSuccessMessages.RPR_PKR_PACKET_CLASSIFIER.getMessage() + " -- " + registrationId); + description.setCode(PlatformSuccessMessages.RPR_PKR_PACKET_CLASSIFIER.getCode()); + + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), registrationId, + description.getCode() + description.getMessage()); + + object.setIsValid(Boolean.TRUE); + object.setInternalError(Boolean.FALSE); + isTransactionSuccessful = true; + } catch (PacketManagerException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, + StatusUtil.PACKET_MANAGER_EXCEPTION, RegistrationExceptionTypeCode.PACKET_MANAGER_EXCEPTION, + description, PlatformErrorMessages.PACKET_MANAGER_EXCEPTION, e); + } catch (DataAccessException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, + StatusUtil.DB_NOT_ACCESSIBLE, RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION, + description, PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); + } catch (IOException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, + StatusUtil.IO_EXCEPTION, RegistrationExceptionTypeCode.IOEXCEPTION, + description, PlatformErrorMessages.RPR_SYS_IO_EXCEPTION, e); + } catch (ParsingException | JsonProcessingException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, + StatusUtil.JSON_PARSING_EXCEPTION, RegistrationExceptionTypeCode.PARSE_EXCEPTION, + description, PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION, e); + } catch (TablenotAccessibleException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.PROCESSING, + StatusUtil.DB_NOT_ACCESSIBLE, RegistrationExceptionTypeCode.TABLE_NOT_ACCESSIBLE_EXCEPTION, + description, PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); + } catch (BaseUncheckedException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, + StatusUtil.BASE_UNCHECKED_EXCEPTION, RegistrationExceptionTypeCode.BASE_UNCHECKED_EXCEPTION, + description, PlatformErrorMessages.RPR_PCM_BASE_UNCHECKED_EXCEPTION, e); + } catch (BaseCheckedException e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, + StatusUtil.BASE_CHECKED_EXCEPTION, RegistrationExceptionTypeCode.BASE_CHECKED_EXCEPTION, + description, PlatformErrorMessages.RPR_PCM_BASE_CHECKED_EXCEPTION, e); + } catch (Exception e) { + updateDTOsAndLogError(registrationStatusDto, RegistrationStatusCode.FAILED, + StatusUtil.UNKNOWN_EXCEPTION_OCCURED, RegistrationExceptionTypeCode.EXCEPTION, + description, PlatformErrorMessages.PACKET_CLASSIFICATION_FAILED, e); + } finally { + if (object.getInternalError()) { + int retryCount = registrationStatusDto.getRetryCount() != null + ? registrationStatusDto.getRetryCount() + 1 + : 1; + registrationStatusDto.setRetryCount(retryCount); + updateErrorFlags(registrationStatusDto, object); + } + registrationStatusDto.setUpdatedBy(USER); + /** Module-Id can be Both Success/Error code */ + String moduleId = description.getCode(); + String moduleName = ModuleName.PACKET_CLASSIFIER.toString(); + registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); + updateAudit(description, isTransactionSuccessful, moduleId, moduleName, registrationId); + } + + return object; + } + + private void updateDTOsAndLogError(InternalRegistrationStatusDto registrationStatusDto, + RegistrationStatusCode registrationStatusCode, StatusUtil statusUtil, + RegistrationExceptionTypeCode registrationExceptionTypeCode, LogDescription description, + PlatformErrorMessages platformErrorMessages, Exception e) { + registrationStatusDto.setStatusCode(registrationStatusCode.toString()); + registrationStatusDto.setStatusComment(trimExpMessage + .trimExceptionMessage(statusUtil.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(statusUtil.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(registrationExceptionTypeCode)); + description.setMessage(platformErrorMessages.getMessage()); + description.setCode(platformErrorMessages.getCode()); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), + description.getCode() + " -- " + registrationStatusDto.getRegistrationId(), + platformErrorMessages.getMessage() + e.getMessage() + ExceptionUtils.getStackTrace(e)); + } + + private void updateAudit(LogDescription description, boolean isTransactionSuccessful, String moduleId, + String moduleName, String registrationId) { + String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() + : EventId.RPR_405.toString(); + String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() + : EventName.EXCEPTION.toString(); + String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() + : EventType.SYSTEM.toString(); + + auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, + eventType, moduleId, moduleName, registrationId); + } + + private void generateAndAddTags(String workflowInstanceId, String registrationId, String process, int iteration) + throws IOException, BaseCheckedException, NumberFormatException, JSONException { + regProcLogger.debug("generateAndAddTags called for registration id {} {}", registrationId, + requiredIdObjectFieldNames); + Map identityFieldValueMap = priorityBasedPacketManagerService.getFields(registrationId, + requiredIdObjectFieldNames, process, ProviderStageName.CLASSIFICATION); + Map fieldTypeMap = getFieldTypeMap(identityFieldValueMap.get(idSchemaVersionLabel)); + Map idObjectFieldDTOMap = + getIdObjectFieldDTOMap(identityFieldValueMap, fieldTypeMap); + Map metaInfoMap = priorityBasedPacketManagerService.getMetaInfo(registrationId, process, ProviderStageName.CLASSIFICATION); + Map allTags = new HashMap(); + for(TagGenerator tagGenerator : tagGenerators) { + Map tags = tagGenerator.generateTags(workflowInstanceId, registrationId, process, + idObjectFieldDTOMap, metaInfoMap, iteration); + if(tags != null && !tags.isEmpty()) + allTags.putAll(tags); + } + handleNullValueTags(allTags); + regProcLogger.debug("generated tags {}", new JSONObject(allTags).toString()); + if(!allTags.isEmpty()) + packetManagerService.addOrUpdateTags(registrationId, allTags); + } + + private Map getIdObjectFieldDTOMap(Map identityFieldValueMap, + Map fieldTypeMap ) { + Map idObjectFieldMap = new HashMap<>(); + identityFieldValueMap.forEach((key,value) -> { + idObjectFieldMap.put(key, new FieldDTO(fieldTypeMap.get(key), value)); + }); + return idObjectFieldMap; + } + + private Map getFieldTypeMap(String idSchemaVersion) + throws NumberFormatException, ApisResourceAccessException, JSONException, IOException { + + Map fieldTypeMap = idSchemaUtil.getIdSchemaFieldTypes( + Double.parseDouble(idSchemaVersion)); + regProcLogger.debug("getDefaultFields item {}", new JSONObject(fieldTypeMap).toString()); + return fieldTypeMap; + } + + private void handleNullValueTags(Map tags) { + for (Map.Entry entry : tags.entrySet()) { + if(entry.getValue() == null) + entry.setValue(notAvailableTagValue); + } + } + + private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { + object.setInternalError(true); + if (registrationStatusDto.getLatestTransactionStatusCode() + .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { + object.setIsValid(true); + } else { + object.setIsValid(false); + } + } + +} diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java index aabe425c587..df8303af2fe 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java @@ -1,103 +1,103 @@ -package io.mosip.registration.processor.stages.packetclassifier.tagging.impl; - -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO; -import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; -import org.springframework.stereotype.Component; - -@Component -@ConditionalOnExpression(value = "'${mosip.regproc.packet.classifier.tag-generators}'.contains('MosipAgeGroup')") -public class AgeGroupTagGenerator implements TagGenerator { - - /** Tag name that will be used while tagging age group */ - @Value("${mosip.regproc.packet.classifier.tagging.agegroup.tag-name:AGE_GROUP}") - private String tagName; - - /** Below age ranges map should contain proper age group name and age range, any overlap of the age - * range will result in a random behaviour of tagging. In range, upper and lower values are inclusive. */ - @Value("#{${mosip.regproc.packet.classifier.tagging.agegroup.ranges:{'CHILD':'0-17','ADULT':'18-59','SENIOR_CITIZEN':'60-200'}}}") - private Map ageGroupRangeMap; - - /** The tag value that will be used by default when the packet does not have value for the tag field */ - @Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}") - private String notAvailableTagValue; - - /** Frequently used util methods are available in this bean */ - @Autowired - private Utilities utility; - - private static String RANGE_DELIMITER = "-"; - - private Map parsedAgeGroupRangemap; - - @PostConstruct - private void generateParsedAgeGroupRangeMap() { - parsedAgeGroupRangemap = new HashMap<>(); - for (Map.Entry entry : ageGroupRangeMap.entrySet()) { - String[] range = entry.getValue().split(RANGE_DELIMITER); - int[] rangeArray = new int[2]; - rangeArray[0] = Integer.parseInt(range[0]); - rangeArray[1] = Integer.parseInt(range[1]); - parsedAgeGroupRangemap.put(entry.getKey(), rangeArray); - } - } - - /** - * {@inheritDoc} - */ - @Override - public List getRequiredIdObjectFieldNames() throws BaseCheckedException { - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public Map generateTags(String workflowInstanceId, String registrationId, String process, - Map idObjectFieldDTOMap, Map metaInfoMap, int iteration) - throws BaseCheckedException { - try { - String ageGroup = ""; - int age = utility.getApplicantAge(registrationId, process, ProviderStageName.CLASSIFICATION); - - if (age == -1) { - ageGroup = notAvailableTagValue; - } else { - for (Map.Entry entry : parsedAgeGroupRangemap.entrySet()) { - if (age >= entry.getValue()[0] && age <= entry.getValue()[1]) { - ageGroup = entry.getKey(); - break; - } - } - } - - if(ageGroup == null || ageGroup.trim().isEmpty()) - throw new BaseCheckedException( - PlatformErrorMessages.RPR_PCM_AGE_GROUP_NOT_FOUND.getCode(), - PlatformErrorMessages.RPR_PCM_AGE_GROUP_NOT_FOUND.getMessage() + " Age: " + age); - - Map tags = new HashMap(); - tags.put(tagName, ageGroup); - return tags; - } catch (IOException e) { - throw new BaseCheckedException( - PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getCode(), - PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getMessage(), e); - } - } -} +package io.mosip.registration.processor.stages.packetclassifier.tagging.impl; + +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO; +import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jakarta.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.stereotype.Component; + +@Component +@ConditionalOnExpression(value = "'${mosip.regproc.packet.classifier.tag-generators}'.contains('MosipAgeGroup')") +public class AgeGroupTagGenerator implements TagGenerator { + + /** Tag name that will be used while tagging age group */ + @Value("${mosip.regproc.packet.classifier.tagging.agegroup.tag-name:AGE_GROUP}") + private String tagName; + + /** Below age ranges map should contain proper age group name and age range, any overlap of the age + * range will result in a random behaviour of tagging. In range, upper and lower values are inclusive. */ + @Value("#{${mosip.regproc.packet.classifier.tagging.agegroup.ranges:{'CHILD':'0-17','ADULT':'18-59','SENIOR_CITIZEN':'60-200'}}}") + private Map ageGroupRangeMap; + + /** The tag value that will be used by default when the packet does not have value for the tag field */ + @Value("${mosip.regproc.packet.classifier.tagging.not-available-tag-value}") + private String notAvailableTagValue; + + /** Frequently used util methods are available in this bean */ + @Autowired + private Utilities utility; + + private static String RANGE_DELIMITER = "-"; + + private Map parsedAgeGroupRangemap; + + @PostConstruct + private void generateParsedAgeGroupRangeMap() { + parsedAgeGroupRangemap = new HashMap<>(); + for (Map.Entry entry : ageGroupRangeMap.entrySet()) { + String[] range = entry.getValue().split(RANGE_DELIMITER); + int[] rangeArray = new int[2]; + rangeArray[0] = Integer.parseInt(range[0]); + rangeArray[1] = Integer.parseInt(range[1]); + parsedAgeGroupRangemap.put(entry.getKey(), rangeArray); + } + } + + /** + * {@inheritDoc} + */ + @Override + public List getRequiredIdObjectFieldNames() throws BaseCheckedException { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public Map generateTags(String workflowInstanceId, String registrationId, String process, + Map idObjectFieldDTOMap, Map metaInfoMap, int iteration) + throws BaseCheckedException { + try { + String ageGroup = ""; + int age = utility.getApplicantAge(registrationId, process, ProviderStageName.CLASSIFICATION); + + if (age == -1) { + ageGroup = notAvailableTagValue; + } else { + for (Map.Entry entry : parsedAgeGroupRangemap.entrySet()) { + if (age >= entry.getValue()[0] && age <= entry.getValue()[1]) { + ageGroup = entry.getKey(); + break; + } + } + } + + if(ageGroup == null || ageGroup.trim().isEmpty()) + throw new BaseCheckedException( + PlatformErrorMessages.RPR_PCM_AGE_GROUP_NOT_FOUND.getCode(), + PlatformErrorMessages.RPR_PCM_AGE_GROUP_NOT_FOUND.getMessage() + " Age: " + age); + + Map tags = new HashMap(); + tags.put(tagName, ageGroup); + return tags; + } catch (IOException e) { + throw new BaseCheckedException( + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getCode(), + PlatformErrorMessages.RPR_PCM_ACCESSING_IDOBJECT_MAPPING_FILE_FAILED.getMessage(), e); + } + } +} diff --git a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/pom.xml index 01743ebb3a6..e07dc83e351 100644 --- a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/pom.xml @@ -1,127 +1,122 @@ - - - 4.0.0 - - - registration-processor-packet-uploader-stage - - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - - UTF-8 - - - - - - junit - junit - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - com.h2database - h2 - ${h2.version} - - - - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - org.springframework - spring-context - ${spring-framework.version} - - - org.postgresql - postgresql - runtime - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.batch - spring-batch-test - test - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - com.h2database - h2 - - - org.mockito - mockito-core - test - - - org.awaitility - awaitility - ${awaitility.version} - test - - - org.json - json - 20180813 - - - io.mosip.commons - khazana - ${object.store.khazana.version} - - - - - - - - - - + + + 4.0.0 + + + registration-processor-packet-uploader-stage + + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + + + + junit + junit + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + com.h2database + h2 + ${h2.version} + + + + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.springframework + spring-context + + + org.postgresql + postgresql + runtime + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.batch + spring-batch-test + test + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + com.h2database + h2 + + + org.mockito + mockito-core + test + + + org.awaitility + awaitility + test + + + org.json + json + + + io.mosip.commons + khazana + ${object.store.khazana.version} + + + + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/java/io/mosip/registration/processor/packet/uploader/dto/CryptomanagerRequestDto.java b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/java/io/mosip/registration/processor/packet/uploader/dto/CryptomanagerRequestDto.java index b33e7d9e775..d46a528e730 100644 --- a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/java/io/mosip/registration/processor/packet/uploader/dto/CryptomanagerRequestDto.java +++ b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/java/io/mosip/registration/processor/packet/uploader/dto/CryptomanagerRequestDto.java @@ -1,53 +1,53 @@ -package io.mosip.registration.processor.packet.uploader.dto; - -import java.time.LocalDateTime; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import io.mosip.registration.processor.packet.uploader.constants.CryptomanagerConstant; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * - * @author Girish Yarru - * - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@ApiModel(description = "Model representing a Crypto-Manager-Service Request") -public class CryptomanagerRequestDto { - /** - * Application id of decrypting module - */ - @ApiModelProperty(notes = "Application id of decrypting module", example = "REGISTRATION", required = true) - @NotBlank(message = CryptomanagerConstant.INVALID_REQUEST) - private String applicationId; - /** - * Refrence Id - */ - @ApiModelProperty(notes = "Refrence Id", example = "REF01") - private String referenceId; - /** - * Timestamp - */ - @ApiModelProperty(notes = "Timestamp as metadata", example = "2018-12-10T06:12:52.994Z", required = true) - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - @NotNull - private LocalDateTime timeStamp; - /** - * Data in BASE64 encoding to encrypt/decrypt - */ - @ApiModelProperty(notes = "Data in BASE64 encoding to encrypt/decrypt", required = true) - @NotBlank(message = CryptomanagerConstant.INVALID_REQUEST) - private String data; - - private Boolean prependThumbprint; -} +package io.mosip.registration.processor.packet.uploader.dto; + +import java.time.LocalDateTime; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import io.mosip.registration.processor.packet.uploader.constants.CryptomanagerConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * + * @author Girish Yarru + * + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(description = "Model representing a Crypto-Manager-Service Request") +public class CryptomanagerRequestDto { + /** + * Application id of decrypting module + */ + @ApiModelProperty(notes = "Application id of decrypting module", example = "REGISTRATION", required = true) + @NotBlank(message = CryptomanagerConstant.INVALID_REQUEST) + private String applicationId; + /** + * Refrence Id + */ + @ApiModelProperty(notes = "Refrence Id", example = "REF01") + private String referenceId; + /** + * Timestamp + */ + @ApiModelProperty(notes = "Timestamp as metadata", example = "2018-12-10T06:12:52.994Z", required = true) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @NotNull + private LocalDateTime timeStamp; + /** + * Data in BASE64 encoding to encrypt/decrypt + */ + @ApiModelProperty(notes = "Data in BASE64 encoding to encrypt/decrypt", required = true) + @NotBlank(message = CryptomanagerConstant.INVALID_REQUEST) + private String data; + + private Boolean prependThumbprint; +} diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml index 657414481ef..c889adc4238 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/pom.xml @@ -1,114 +1,107 @@ - - - 4.0.0 - - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-packet-validator-stage - 1.2.1-SNAPSHOT - jar - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-message-sender-impl - ${registration.processor.message.sender.version} - - - commons-io - commons-io - ${commons.io.version} - - - junit - junit - 4.12 - test - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.springframework.boot - spring-boot-starter-webflux - ${spring.boot.version} - - - - - - - + + + 4.0.0 + + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-packet-validator-stage + 1.2.1-java21-SNAPSHOT + jar + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-message-sender-impl + ${registration.processor.message.sender.version} + + + commons-io + commons-io + + + junit + junit + test + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.springframework.boot + spring-boot-starter-webflux + + + + + + + diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/config/ValidatorConfig.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/config/ValidatorConfig.java index 863906763fd..168fb2480a7 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/config/ValidatorConfig.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/config/ValidatorConfig.java @@ -6,7 +6,7 @@ import java.security.NoSuchAlgorithmException; import java.util.Collections; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import io.mosip.registration.processor.stages.packet.validator.PacketValidatorStage; import org.apache.commons.lang3.StringUtils; diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/dto/AsyncRequestDTO.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/dto/AsyncRequestDTO.java index 5d6ceb2c2b6..b93020e91e8 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/dto/AsyncRequestDTO.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/dto/AsyncRequestDTO.java @@ -1,38 +1,38 @@ -package io.mosip.registration.processor.stages.dto; - -import lombok.Data; - -import java.util.Map; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.util.MultiValueMap; - -@Data -public class AsyncRequestDTO { - - @Pattern(regexp = "<\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]>", message = "{mosip.rest.request.uri.message}") - @NotNull - private String uri; - - MultiValueMap params; - - Map pathVariables; - - @NotNull - private HttpMethod httpMethod; - - private Object requestBody; - - @NotNull - private Class responseType; - - @NotNull - private HttpHeaders headers; - - @Pattern(regexp = "^[0-9]*$", message = "{mosip.rest.request.timeout.message}") - private Integer timeout; -} +package io.mosip.registration.processor.stages.dto; + +import lombok.Data; + +import java.util.Map; + +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.util.MultiValueMap; + +@Data +public class AsyncRequestDTO { + + @Pattern(regexp = "<\\b(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]>", message = "{mosip.rest.request.uri.message}") + @NotNull + private String uri; + + MultiValueMap params; + + Map pathVariables; + + @NotNull + private HttpMethod httpMethod; + + private Object requestBody; + + @NotNull + private Class responseType; + + @NotNull + private HttpHeaders headers; + + @Pattern(regexp = "^[0-9]*$", message = "{mosip.rest.request.timeout.message}") + private Integer timeout; +} diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/helper/RestHelperImpl.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/helper/RestHelperImpl.java index 55df42f2061..7dd367573dd 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/helper/RestHelperImpl.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/helper/RestHelperImpl.java @@ -1,129 +1,133 @@ -package io.mosip.registration.processor.stages.helper; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; -import java.util.function.Supplier; - -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLException; -import javax.validation.Valid; - -import io.mosip.registration.processor.rest.client.utils.RestApiClient; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseCookie; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; -import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; -import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import brave.http.HttpRuleSampler.Builder; -import io.mosip.kernel.core.http.RequestWrapper; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.EmptyCheckUtils; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.token.validation.dto.TokenResponseDTO; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.stages.dto.AsyncRequestDTO; -import io.mosip.registration.processor.stages.exception.RestServiceException; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.util.InsecureTrustManagerFactory; -import lombok.NoArgsConstructor; -import reactor.core.publisher.Mono; - -@Component -@NoArgsConstructor -public class RestHelperImpl implements RestHelper { - - private static Logger mosipLogger = RegProcessorLogger.getLogger(RestHelperImpl.class); - - @Autowired - private RestApiClient restApiClient; - - @Autowired - private ObjectMapper mapper; - - @Override - public Supplier requestAsync(@Valid AsyncRequestDTO request) { - try { - Mono sendRequest = request(request, getSslContext()); - return () -> sendRequest.block(); - } catch (RestServiceException | IOException e) { - mosipLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RestHelperImpl::SslContext()::error"); - return () -> new RestServiceException("UNABLE_TO_PROCESS", e); - } - } - - private SslContext getSslContext() throws RestServiceException { - try { - return SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); - } catch (SSLException e) { - mosipLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RestHelperImpl::SslContext()::error"); - throw new RestServiceException("UNKNOWN_ERROR", e); - } - } - - private Mono request(AsyncRequestDTO request, SslContext sslContext) throws IOException { - WebClient webClient; - Mono monoResponse; - RequestBodySpec uri; - ResponseSpec exchange; - RequestBodyUriSpec method; - - if (request.getHeaders() != null) { - org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(builder -> builder.sslContext(sslContext))) - .baseUrl(request.getUri()); - if (request.getHeaders().getContentType() != null) { - webClientBuilder = webClientBuilder.defaultHeader(HttpHeaders.CONTENT_TYPE, - request.getHeaders().getContentType().toString()); - } - webClient = webClientBuilder.build(); - } else { - webClient = WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(builder -> builder.sslContext(sslContext))) - .baseUrl(request.getUri()).build(); - } - - method = webClient.method(request.getHttpMethod()); - if (request.getParams() != null && request.getPathVariables() == null) { - uri = method.uri(builder -> builder.queryParams(request.getParams()).build()); - } else if (request.getParams() == null && request.getPathVariables() != null) { - uri = method.uri(builder -> builder.build(request.getPathVariables())); - } else { - uri = method.uri(builder -> builder.build()); - } - - uri.header("cookie", restApiClient.getToken()); - - if (request.getRequestBody() != null) { - exchange = uri.syncBody(request.getRequestBody()).retrieve(); - } else { - exchange = uri.retrieve(); - } - - monoResponse = exchange.bodyToMono(request.getResponseType()); - - return monoResponse; - } - -} +package io.mosip.registration.processor.stages.helper; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.function.Supplier; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLException; +import jakarta.validation.Valid; + +import io.mosip.registration.processor.rest.client.utils.RestApiClient; + +import org.apache.hc.core5.http.ParseException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseCookie; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.client.ClientResponse; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; +import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; +import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import brave.http.HttpRuleSampler.Builder; +import io.mosip.kernel.core.http.RequestWrapper; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.EmptyCheckUtils; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.token.validation.dto.TokenResponseDTO; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.stages.dto.AsyncRequestDTO; +import io.mosip.registration.processor.stages.exception.RestServiceException; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; +import io.netty.handler.ssl.util.InsecureTrustManagerFactory; +import lombok.NoArgsConstructor; +import reactor.core.publisher.Mono; +import reactor.netty.http.client.HttpClient; + +@Component +@NoArgsConstructor +public class RestHelperImpl implements RestHelper { + + private static Logger mosipLogger = RegProcessorLogger.getLogger(RestHelperImpl.class); + + @Autowired + private RestApiClient restApiClient; + + @Autowired + private ObjectMapper mapper; + + @Override + public Supplier requestAsync(@Valid AsyncRequestDTO request) { + try { + Mono sendRequest = request(request, getSslContext()); + return () -> sendRequest.block(); + } catch (RestServiceException | IOException | ParseException e) { + mosipLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RestHelperImpl::SslContext()::error"); + return () -> new RestServiceException("UNABLE_TO_PROCESS", e); + } + } + + private SslContext getSslContext() throws RestServiceException { + try { + return SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE).build(); + } catch (SSLException e) { + mosipLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RestHelperImpl::SslContext()::error"); + throw new RestServiceException("UNKNOWN_ERROR", e); + } + } + + private Mono request(AsyncRequestDTO request, SslContext sslContext) throws IOException, ParseException { + WebClient webClient; + Mono monoResponse; + RequestBodySpec uri; + ResponseSpec exchange; + RequestBodyUriSpec method; + HttpClient httpClient = HttpClient.create().secure(sslContextSpec -> sslContextSpec.sslContext(sslContext)); + if (request.getHeaders() != null) { + + org.springframework.web.reactive.function.client.WebClient.Builder webClientBuilder = WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .baseUrl(request.getUri()); + if (request.getHeaders().getContentType() != null) { + webClientBuilder = webClientBuilder.defaultHeader(HttpHeaders.CONTENT_TYPE, + request.getHeaders().getContentType().toString()); + } + webClient = webClientBuilder.build(); + } else { + webClient = WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .baseUrl(request.getUri()).build(); + } + + method = webClient.method(request.getHttpMethod()); + if (request.getParams() != null && request.getPathVariables() == null) { + uri = method.uri(builder -> builder.queryParams(request.getParams()).build()); + } else if (request.getParams() == null && request.getPathVariables() != null) { + uri = method.uri(builder -> builder.build(request.getPathVariables())); + } else { + uri = method.uri(builder -> builder.build()); + } + + uri.header("cookie", restApiClient.getToken()); + + if (request.getRequestBody() != null) { + exchange = uri.syncBody(request.getRequestBody()).retrieve(); + } else { + exchange = uri.retrieve(); + } + + monoResponse = exchange.bodyToMono(request.getResponseType()); + + return monoResponse; + } + +} diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java index e30e8a88d64..8ae1256bdc0 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java @@ -1,300 +1,301 @@ -package io.mosip.registration.processor.stages.helper; - -import java.io.IOException; -import java.net.URI; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; - -import javax.net.ssl.SSLException; -import javax.net.ssl.TrustManagerFactory; - -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseCookie; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestContext; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.util.ReflectionTestUtils; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClient.Builder; -import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; -import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; -import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; -import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; -import org.springframework.web.util.UriBuilder; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import io.mosip.registration.processor.rest.client.utils.RestApiClient; -import io.mosip.registration.processor.stages.dto.AsyncRequestDTO; -import io.mosip.registration.processor.stages.exception.RestServiceException; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import reactor.core.publisher.Mono; - - -@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({"com.sun.org.apache.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) -@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class) -@WebMvcTest -@AutoConfigureMockMvc -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -@PrepareForTest({ WebClient.class, SslContextBuilder.class, Mock.class }) -public class RestHelperTest { - - /** The rest helper. */ - @InjectMocks - RestHelperImpl restHelper; - - /** The mapper. */ - @Autowired - ObjectMapper mapper; - - /** The environment. */ - @Autowired - Environment environment; - - @MockBean - private RestApiClient restApiClient; - - @Before - public void before() throws IOException { - PowerMockito.mockStatic(SslContextBuilder.class); - SslContextBuilder sslContextBuilder = PowerMockito.mock(SslContextBuilder.class); - PowerMockito.when(SslContextBuilder.forClient()).thenReturn(sslContextBuilder); - PowerMockito.when(sslContextBuilder.trustManager(Mockito.any(TrustManagerFactory.class))) - .thenReturn(sslContextBuilder); - PowerMockito.when(sslContextBuilder.build()).thenReturn(Mockito.mock(SslContext.class)); - Mockito.when(restApiClient.getToken()).thenReturn("Gjnaiuhs=="); - } - - /** - * Test get auth token. - * - * @throws JsonParseException the json parse exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - @Ignore - public void testGetAuthToken() throws IOException { - //ReflectionTestUtils.setField(restHelper, "authToken", null); - PowerMockito.mockStatic(WebClient.class); - WebClient webClient = PowerMockito.mock(WebClient.class); - PowerMockito.when(WebClient.create(Mockito.any())).thenReturn(webClient); - RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); - PowerMockito.when(webClient.post()).thenReturn(requestBodyUriSpec); - RequestHeadersSpec requestHeadersSpec = PowerMockito.mock(RequestHeadersSpec.class); - PowerMockito.when(requestBodyUriSpec.syncBody(Mockito.any())).thenReturn(requestHeadersSpec); - ClientResponse clientResponse = PowerMockito.mock(ClientResponse.class); - PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("Authorization", ResponseCookie.from("Authorization", "1234").build()); - PowerMockito.when(clientResponse.cookies()).thenReturn(map); - PowerMockito.when(clientResponse.statusCode()).thenReturn(HttpStatus.OK); - String response = "{\"response\":{\"status\":\"success\"}}"; - PowerMockito.when(clientResponse.bodyToMono(Mockito.any(Class.class))) - .thenReturn(Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); - ReflectionTestUtils.invokeMethod(restHelper, "getAuthToken"); - } - - /** - * Test get auth token invalid. - * - * @throws JsonParseException the json parse exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Test - @Ignore - public void testGetAuthTokenInvalid() throws JsonParseException, JsonMappingException, IOException { - //ReflectionTestUtils.setField(restHelper, "authToken", null); - PowerMockito.mockStatic(WebClient.class); - WebClient webClient = PowerMockito.mock(WebClient.class); - PowerMockito.when(WebClient.create(Mockito.any())).thenReturn(webClient); - RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); - PowerMockito.when(webClient.post()).thenReturn(requestBodyUriSpec); - RequestHeadersSpec requestHeadersSpec = PowerMockito.mock(RequestHeadersSpec.class); - PowerMockito.when(requestBodyUriSpec.syncBody(Mockito.any())).thenReturn(requestHeadersSpec); - ClientResponse clientResponse = PowerMockito.mock(ClientResponse.class); - PowerMockito.when(clientResponse.toEntity(Mockito.any(Class.class))).thenReturn(Mono.just(new ResponseEntity<>(HttpStatus.OK))); - //PowerMockito.when(clientResponse.b(Mockito.any(Class.class))).thenReturn(clientResponse); - PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); - MultiValueMap map = new LinkedMultiValueMap<>(); - map.add("Authorization", ResponseCookie.from("Authorization", "1234").build()); - PowerMockito.when(clientResponse.cookies()).thenReturn(map); - PowerMockito.when(clientResponse.statusCode()).thenReturn(HttpStatus.CREATED); - String response = "{\"response\":{\"status\":\"success\"}}"; - PowerMockito.when(clientResponse.bodyToMono(Mockito.any(Class.class))) - .thenReturn(Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); - ReflectionTestUtils.invokeMethod(restHelper, "getAuthToken"); - } - - /** - * Test request async. - * - * @throws IDDataValidationException the ID data validation exception - * @throws RestServiceException the rest service exception - * @throws JsonParseException the json parse exception - * @throws JsonMappingException the json mapping exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test - public void testRequestAsync() throws JsonParseException, JsonMappingException, IOException { - PowerMockito.mockStatic(WebClient.class); - ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); - PowerMockito.mock(ClientResponse.class); - //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); - String response = "{\"response\":{\"status\":\"success\"}}"; - //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); - AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); - Map pathVariables=new HashMap<>();; - restReqDTO.setPathVariables(pathVariables); - //restReqDTO.setResponseType(Mockito.any(Class.class)); - WebClient webClient = PowerMockito.mock(WebClient.class); - RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); - RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); - Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); - PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.build()).thenReturn(webClient); - PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); - Function uriFunction=Mockito.any(); - PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); - PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); - PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); - restHelper.requestAsync(restReqDTO); - } - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test - public void testRequestAsyncWithHeaders() throws JsonParseException, JsonMappingException, IOException { - PowerMockito.mockStatic(WebClient.class); - ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); - PowerMockito.mock(ClientResponse.class); - //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); - String response = "{\"response\":{\"status\":\"success\"}}"; - //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); - AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); - Map pathVariables=new HashMap<>();; - restReqDTO.setPathVariables(pathVariables); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - restReqDTO.setHeaders(headers); - //restReqDTO.setResponseType(Mockito.any(Class.class)); - WebClient webClient = PowerMockito.mock(WebClient.class); - RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); - RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); - Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); - PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.build()).thenReturn(webClient); - PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); - Function uriFunction=Mockito.any(); - PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); - PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); - PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); - restHelper.requestAsync(restReqDTO); - } - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test - public void testRequestAsyncWithParam() throws IOException { - PowerMockito.mockStatic(WebClient.class); - ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); - PowerMockito.mock(ClientResponse.class); - //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); - String response = "{\"response\":{\"status\":\"success\"}}"; - //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); - AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.APPLICATION_JSON); - restReqDTO.setHeaders(headers); - MultiValueMap paramMap = new LinkedMultiValueMap<>(); - String name="Tapaswini"; - paramMap.add("name", name); - restReqDTO.setParams(paramMap); - WebClient webClient = PowerMockito.mock(WebClient.class); - RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); - RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); - Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); - PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); - PowerMockito.when(mockBuilder.build()).thenReturn(webClient); - PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); - Function uriFunction=Mockito.any(); - PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); - PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); - PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); - restHelper.requestAsync(restReqDTO); - } - - - /** - * Test request async and return. - * - * @throws IDDataValidationException the ID data validation exception - * @throws RestServiceException the rest service exception - * @throws SSLException the SSL exception - */ - @Test(expected=RestServiceException.class) - public void testRequestAsyncAndReturn() throws RestServiceException, SSLException { - PowerMockito.mockStatic(SslContextBuilder.class); - SslContextBuilder sslContextBuilder = PowerMockito.mock(SslContextBuilder.class); - PowerMockito.when(SslContextBuilder.forClient()).thenReturn(sslContextBuilder); - PowerMockito.when(sslContextBuilder.trustManager(Mockito.any(TrustManagerFactory.class))) - .thenReturn(sslContextBuilder); - PowerMockito.when(sslContextBuilder.build()).thenThrow(new SSLException("")); - Object object = restHelper.requestAsync(new AsyncRequestDTO()).get(); - if(object instanceof RestServiceException) { - RestServiceException restServiceException = (RestServiceException) object; - throw restServiceException; - - } - } - - -} - - +package io.mosip.registration.processor.stages.helper; + +import java.io.IOException; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + +import javax.net.ssl.SSLException; +import javax.net.ssl.TrustManagerFactory; + +import org.apache.hc.core5.http.ParseException; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseCookie; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestContext; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.reactive.function.client.ClientResponse; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClient.Builder; +import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; +import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; +import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; +import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; +import org.springframework.web.util.UriBuilder; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import io.mosip.registration.processor.rest.client.utils.RestApiClient; +import io.mosip.registration.processor.stages.dto.AsyncRequestDTO; +import io.mosip.registration.processor.stages.exception.RestServiceException; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; +import reactor.core.publisher.Mono; + + +@ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) +@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class) +@WebMvcTest +@AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@PrepareForTest({ WebClient.class, SslContextBuilder.class, Mock.class }) +public class RestHelperTest { + + /** The rest helper. */ + @InjectMocks + RestHelperImpl restHelper; + + /** The mapper. */ + @Autowired + ObjectMapper mapper; + + /** The environment. */ + @Autowired + Environment environment; + + @MockBean + private RestApiClient restApiClient; + + @Before + public void before() throws IOException, ParseException { + PowerMockito.mockStatic(SslContextBuilder.class); + SslContextBuilder sslContextBuilder = PowerMockito.mock(SslContextBuilder.class); + PowerMockito.when(SslContextBuilder.forClient()).thenReturn(sslContextBuilder); + PowerMockito.when(sslContextBuilder.trustManager(Mockito.any(TrustManagerFactory.class))) + .thenReturn(sslContextBuilder); + PowerMockito.when(sslContextBuilder.build()).thenReturn(Mockito.mock(SslContext.class)); + Mockito.when(restApiClient.getToken()).thenReturn("Gjnaiuhs=="); + } + + /** + * Test get auth token. + * + * @throws JsonParseException the json parse exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test + @Ignore + public void testGetAuthToken() throws IOException { + //ReflectionTestUtils.setField(restHelper, "authToken", null); + PowerMockito.mockStatic(WebClient.class); + WebClient webClient = PowerMockito.mock(WebClient.class); + PowerMockito.when(WebClient.create(Mockito.any())).thenReturn(webClient); + RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); + PowerMockito.when(webClient.post()).thenReturn(requestBodyUriSpec); + RequestHeadersSpec requestHeadersSpec = PowerMockito.mock(RequestHeadersSpec.class); + PowerMockito.when(requestBodyUriSpec.syncBody(Mockito.any())).thenReturn(requestHeadersSpec); + ClientResponse clientResponse = PowerMockito.mock(ClientResponse.class); + PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); + MultiValueMap map = new LinkedMultiValueMap<>(); + map.add("Authorization", ResponseCookie.from("Authorization", "1234").build()); + PowerMockito.when(clientResponse.cookies()).thenReturn(map); + PowerMockito.when(clientResponse.statusCode()).thenReturn(HttpStatus.OK); + String response = "{\"response\":{\"status\":\"success\"}}"; + PowerMockito.when(clientResponse.bodyToMono(Mockito.any(Class.class))) + .thenReturn(Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); + ReflectionTestUtils.invokeMethod(restHelper, "getAuthToken"); + } + + /** + * Test get auth token invalid. + * + * @throws JsonParseException the json parse exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Test + @Ignore + public void testGetAuthTokenInvalid() throws JsonParseException, JsonMappingException, IOException { + //ReflectionTestUtils.setField(restHelper, "authToken", null); + PowerMockito.mockStatic(WebClient.class); + WebClient webClient = PowerMockito.mock(WebClient.class); + PowerMockito.when(WebClient.create(Mockito.any())).thenReturn(webClient); + RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); + PowerMockito.when(webClient.post()).thenReturn(requestBodyUriSpec); + RequestHeadersSpec requestHeadersSpec = PowerMockito.mock(RequestHeadersSpec.class); + PowerMockito.when(requestBodyUriSpec.syncBody(Mockito.any())).thenReturn(requestHeadersSpec); + ClientResponse clientResponse = PowerMockito.mock(ClientResponse.class); + PowerMockito.when(clientResponse.toEntity(Mockito.any(Class.class))).thenReturn(Mono.just(new ResponseEntity<>(HttpStatus.OK))); + //PowerMockito.when(clientResponse.b(Mockito.any(Class.class))).thenReturn(clientResponse); + PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); + MultiValueMap map = new LinkedMultiValueMap<>(); + map.add("Authorization", ResponseCookie.from("Authorization", "1234").build()); + PowerMockito.when(clientResponse.cookies()).thenReturn(map); + PowerMockito.when(clientResponse.statusCode()).thenReturn(HttpStatus.CREATED); + String response = "{\"response\":{\"status\":\"success\"}}"; + PowerMockito.when(clientResponse.bodyToMono(Mockito.any(Class.class))) + .thenReturn(Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); + ReflectionTestUtils.invokeMethod(restHelper, "getAuthToken"); + } + + /** + * Test request async. + * + * @throws IDDataValidationException the ID data validation exception + * @throws RestServiceException the rest service exception + * @throws JsonParseException the json parse exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testRequestAsync() throws JsonParseException, JsonMappingException, IOException { + PowerMockito.mockStatic(WebClient.class); + ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); + PowerMockito.mock(ClientResponse.class); + //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); + String response = "{\"response\":{\"status\":\"success\"}}"; + //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); + AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); + Map pathVariables=new HashMap<>();; + restReqDTO.setPathVariables(pathVariables); + //restReqDTO.setResponseType(Mockito.any(Class.class)); + WebClient webClient = PowerMockito.mock(WebClient.class); + RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); + RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); + Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); + PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.build()).thenReturn(webClient); + PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); + Function uriFunction=Mockito.any(); + PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); + PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); + PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); + restHelper.requestAsync(restReqDTO); + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testRequestAsyncWithHeaders() throws JsonParseException, JsonMappingException, IOException { + PowerMockito.mockStatic(WebClient.class); + ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); + PowerMockito.mock(ClientResponse.class); + //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); + String response = "{\"response\":{\"status\":\"success\"}}"; + //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); + AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); + Map pathVariables=new HashMap<>();; + restReqDTO.setPathVariables(pathVariables); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + restReqDTO.setHeaders(headers); + //restReqDTO.setResponseType(Mockito.any(Class.class)); + WebClient webClient = PowerMockito.mock(WebClient.class); + RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); + RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); + Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); + PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.build()).thenReturn(webClient); + PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); + Function uriFunction=Mockito.any(); + PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); + PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); + PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); + restHelper.requestAsync(restReqDTO); + } + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Test + public void testRequestAsyncWithParam() throws IOException { + PowerMockito.mockStatic(WebClient.class); + ResponseSpec responseSpec=PowerMockito.mock(ResponseSpec.class); + PowerMockito.mock(ClientResponse.class); + //PowerMockito.when(requestHeadersSpec.exchange()).thenReturn(Mono.just(clientResponse)); + String response = "{\"response\":{\"status\":\"success\"}}"; + //Mono monoResponse= Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class)); + AsyncRequestDTO restReqDTO=new AsyncRequestDTO(); + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + restReqDTO.setHeaders(headers); + MultiValueMap paramMap = new LinkedMultiValueMap<>(); + String name="Tapaswini"; + paramMap.add("name", name); + restReqDTO.setParams(paramMap); + WebClient webClient = PowerMockito.mock(WebClient.class); + RequestBodyUriSpec requestBodyUriSpec = PowerMockito.mock(RequestBodyUriSpec.class); + RequestBodySpec requestBodySpec = PowerMockito.mock(RequestBodySpec.class); + Builder mockBuilder = PowerMockito.mock(WebClient.Builder.class); + PowerMockito.when(WebClient.builder()).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.clientConnector(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.baseUrl(Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.defaultHeader(Mockito.any(), Mockito.any())).thenReturn(mockBuilder); + PowerMockito.when(mockBuilder.build()).thenReturn(webClient); + PowerMockito.when(webClient.method(Mockito.any())).thenReturn(requestBodyUriSpec); + Function uriFunction=Mockito.any(); + PowerMockito.when(requestBodyUriSpec.uri(uriFunction)).thenReturn(requestBodySpec); + PowerMockito.when(requestBodySpec.retrieve()).thenReturn(responseSpec); + PowerMockito.when(responseSpec.bodyToMono((Class)null)).thenReturn( Mono.just(mapper.readValue(response.getBytes(), ObjectNode.class))); + restHelper.requestAsync(restReqDTO); + } + + + /** + * Test request async and return. + * + * @throws IDDataValidationException the ID data validation exception + * @throws RestServiceException the rest service exception + * @throws SSLException the SSL exception + */ + @Test(expected=RestServiceException.class) + public void testRequestAsyncAndReturn() throws RestServiceException, SSLException { + PowerMockito.mockStatic(SslContextBuilder.class); + SslContextBuilder sslContextBuilder = PowerMockito.mock(SslContextBuilder.class); + PowerMockito.when(SslContextBuilder.forClient()).thenReturn(sslContextBuilder); + PowerMockito.when(sslContextBuilder.trustManager(Mockito.any(TrustManagerFactory.class))) + .thenReturn(sslContextBuilder); + PowerMockito.when(sslContextBuilder.build()).thenThrow(new SSLException("")); + Object object = restHelper.requestAsync(new AsyncRequestDTO()).get(); + if(object instanceof RestServiceException) { + RestServiceException restServiceException = (RestServiceException) object; + throw restServiceException; + + } + } + + +} + + diff --git a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/pom.xml b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/pom.xml index b91e0971f9d..1b2968d0124 100644 --- a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/pom.xml @@ -1,97 +1,91 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - - registration-processor-quality-classifier-stage - 1.2.1-SNAPSHOT - - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - io.mosip.kernel - kernel-cbeffutil-api - ${kernel.cbeffutil.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-quality-classifier-stage + 1.2.1-java21-SNAPSHOT + + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + io.mosip.kernel + kernel-cbeffutil-api + ${kernel.cbeffutil.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + + + + \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java index 88ada0f55da..4d044b91b73 100644 --- a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java +++ b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java @@ -1,492 +1,492 @@ -package io.mosip.registration.processor.quality.classifier.stage; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import javax.annotation.PostConstruct; - -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import io.mosip.kernel.biometrics.constant.BiometricFunction; -import io.mosip.kernel.biometrics.constant.BiometricType; -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.biosdk.provider.factory.BioAPIFactory; -import io.mosip.kernel.biosdk.provider.spi.iBioProviderApi; -import io.mosip.kernel.core.bioapi.exception.BiometricException; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; -import io.mosip.registration.processor.core.code.EventId; -import io.mosip.registration.processor.core.code.EventName; -import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.ModuleName; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import io.mosip.registration.processor.quality.classifier.exception.FileMissingException; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class QualityCheckerStage. - * - * @author M1048358 Alok Ranjan - */ -@Component -@Configuration -@ComponentScan(basePackages = { "${mosip.auth.adapter.impl.basepackage}", - "io.mosip.registration.processor.core.config", - "io.mosip.registration.processor.quality.classifier.config", "io.mosip.registration.processor.stages.config", - "io.mosip.registrationprocessor.stages.config", "io.mosip.registration.processor.status.config", - "io.mosip.registration.processor.rest.client.config", "io.mosip.registration.processor.packet.storage.config", - "io.mosip.registration.processor.packet.manager.config", "io.mosip.kernel.idobjectvalidator.config", - "io.mosip.registration.processor.core.kernel.beans", "io.mosip.kernel.biosdk.provider.impl" }) -public class QualityClassifierStage extends MosipVerticleAPIManager { - - private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.quality.classifier."; - - - /** The Constant UTF_8. */ - public static final String UTF_8 = "UTF-8"; - - /** The Constant VALUE. */ - public static final String VALUE = "value"; - - /** The Constant TRUE. */ - public static final String TRUE = "true"; - - /** The Constant EXCEPTION. */ - public static final String EXCEPTION = "EXCEPTION"; - - private TrimExceptionMessage trimExceptionMsg = new TrimExceptionMessage(); - - /** The cluster manager url. */ - @Value("${vertx.cluster.configuration}") - private String clusterManagerUrl; - - /** worker pool size. */ - @Value("${worker.pool.size}") - private Integer workerPoolSize; - - /** - * After this time intervel, message should be considered as expired (In - * seconds). - */ - @Value("${mosip.regproc.quality.classifier.message.expiry-time-limit}") - private Long messageExpiryTimeLimit; - - /** The core audit request builder. */ - @Autowired - private AuditLogRequestBuilder auditLogRequestBuilder; - - /** The registration status service. */ - @Autowired - private RegistrationStatusService registrationStatusService; - - /** Mosip router for APIs */ - @Autowired - private MosipRouter router; - - @Autowired - private PriorityBasedPacketManagerService basedPacketManagerService; - - @Autowired - private PacketManagerService packetManagerService; - - /** The registration status mapper util. */ - @Autowired - private RegistrationExceptionMapperUtil registrationStatusMapperUtil; - - /** - * Below quality classifications map should contain proper quality - * classification name and quality range, any overlap of the quality range will - * result in a random behaviour of tagging. In range, upper and lower values are - * inclusive. - */ - - @Value("#{${mosip.regproc.quality.classifier.tagging.quality.ranges:{'level-1':'0-10','level-2':'10-20','level-3':'20-30','level-4':'30-40','level-5':'40-50','level-6':'50-60','level-7':'60-70','level-8':'70-80','level-9':'80-90','level-10':'90-101',}}}") - private Map qualityClassificationRangeMap; - - /** Quality Tag Prefix */ - @Value("${mosip.regproc.quality.classifier.tagging.quality.prefix:Biometric_Quality-}") - private String qualityTagPrefix; - - /** The tag value that will be used by default when the packet does not have value for the biometric tag field */ - @Value("${mosip.regproc.quality.classifier.tagging.quality.biometric-not-available-tag-value}") - private String biometricNotAvailableTagValue; - - /** modality arrays that needs to be tagged */ - @Value("#{'${mosip.regproc.quality.classifier.tagging.quality.modalities}'.split(',')}") - private List modalities; - - private static String RANGE_DELIMITER = "-"; - - /** - * Filter qualityClassficaticationsRangeMap using delimiter and store into - * parsedQualityRangemap using @PostConstruct - */ - private Map parsedQualityRangeMap; - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(QualityClassifierStage.class); - - /** The Constant FILE_SEPARATOR. */ - public static final String FILE_SEPARATOR = File.separator; - - private MosipEventBus mosipEventBus = null; - - private TrimExceptionMessage trimExpMessage = new TrimExceptionMessage(); - - @Autowired - private BioAPIFactory bioApiFactory; - - @PostConstruct - private void generateParsedQualityRangeMap() { - parsedQualityRangeMap = new HashMap<>(); - for (Map.Entry entry : qualityClassificationRangeMap.entrySet()) { - String[] range = entry.getValue().split(RANGE_DELIMITER); - int[] rangeArray = new int[2]; - rangeArray[0] = Integer.parseInt(range[0]); - rangeArray[1] = Integer.parseInt(range[1]); - parsedQualityRangeMap.put(entry.getKey(), rangeArray); - } - } - - /** - * Deploy verticle. - */ - public void deployVerticle() { - mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); - this.consumeAndSend(mosipEventBus, MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN, - MessageBusAddress.QUALITY_CLASSIFIER_BUS_OUT, messageExpiryTimeLimit); - } - - @Override - protected String getPropertyPrefix() { - return STAGE_PROPERTY_PREFIX; - } - - @Override - public void start() { - router.setRoute(this.postUrl(getVertx(), MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN, - MessageBusAddress.QUALITY_CLASSIFIER_BUS_OUT)); - this.createServer(router.getRouter(), getPort()); - } - - /* - * (non-Javadoc) - * - * @see - * io.mosip.registration.processor.core.spi.eventbus.EventBusManager#process( - * java.lang.Object) - */ - @Override - public MessageDTO process(MessageDTO object) { - object.setMessageBusAddress(MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN); - String regId = object.getRid(); - LogDescription description = new LogDescription(); - object.setInternalError(Boolean.FALSE); - object.setIsValid(Boolean.FALSE); - Boolean isTransactionSuccessful = Boolean.FALSE; - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, - "QualityCheckerStage::process()::entry"); - - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus(regId, - object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); - - try { - String individualBiometricsObject = basedPacketManagerService.getFieldByMappingJsonKey(regId, - MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationStatusDto.getRegistrationType(), - ProviderStageName.QUALITY_CHECKER); - if (StringUtils.isEmpty(individualBiometricsObject)) { - packetManagerService.addOrUpdateTags(regId, getQualityTags(null)); - description.setCode(PlatformErrorMessages.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getCode()); - description.setMessage(PlatformErrorMessages.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getMessage()); - object.setIsValid(Boolean.TRUE); - isTransactionSuccessful = Boolean.TRUE; - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.SUCCESS.toString()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); - registrationStatusDto.setStatusComment(StatusUtil.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getCode()); - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, - "Individual Biometric parameter is not present in ID Json"); - } else { - BiometricRecord biometricRecord = basedPacketManagerService.getBiometricsByMappingJsonKey(regId, - MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationStatusDto.getRegistrationType(), - ProviderStageName.QUALITY_CHECKER); - - if (biometricRecord == null || CollectionUtils.isEmpty(biometricRecord.getSegments())) { - biometricRecord = basedPacketManagerService.getBiometricsByMappingJsonKey(regId, - MappingJsonConstants.AUTHENTICATION_BIOMETRICS, registrationStatusDto.getRegistrationType(), - ProviderStageName.QUALITY_CHECKER); - } - - if (biometricRecord == null || biometricRecord.getSegments() == null - || biometricRecord.getSegments().size() == 0) { - description.setCode(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getCode()); - description.setMessage(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), regId, - PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); - throw new FileMissingException(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getCode(), - PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); - } - - - packetManagerService.addOrUpdateTags(regId, getQualityTags(biometricRecord.getSegments())); - - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, - "UpdatingTags::success "); - - object.setIsValid(Boolean.TRUE); - description.setCode(PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getCode()); - description.setMessage(PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getMessage()); - isTransactionSuccessful = Boolean.TRUE; - registrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.SUCCESS.toString()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); - registrationStatusDto.setStatusComment(StatusUtil.BIOMETRIC_QUALITY_CHECK_SUCCESS.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.BIOMETRIC_QUALITY_CHECK_SUCCESS.getCode()); - regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), regId, "QualityCheckerImpl::success"); - } - - } catch (ApisResourceAccessException e) { - registrationStatusDto.setLatestTransactionStatusCode(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.APIS_RESOURCE_ACCESS_EXCEPTION)); - registrationStatusDto.setStatusComment(trimExpMessage - .trimExceptionMessage(StatusUtil.API_RESOUCE_ACCESS_FAILED.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.API_RESOUCE_ACCESS_FAILED.getCode()); - object.setInternalError(Boolean.TRUE); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.name() + ExceptionUtils.getStackTrace(e)); - - description.setMessage(PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.getMessage()); - description.setCode(PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.getCode()); - } catch (FileMissingException e) { - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); - registrationStatusDto.setStatusComment(StatusUtil.BIO_METRIC_FILE_MISSING.getMessage()); - registrationStatusDto.setSubStatusCode(StatusUtil.BIO_METRIC_FILE_MISSING.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.BIOMETRIC_EXCEPTION)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, - PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage() + ExceptionUtils.getStackTrace(e)); - object.setInternalError(Boolean.TRUE); - description.setCode(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getCode()); - description.setMessage(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage()); - - } catch (BiometricException e) { - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); - registrationStatusDto.setStatusComment(trimExceptionMsg - .trimExceptionMessage(StatusUtil.BIO_METRIC_EXCEPTION.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.BIO_METRIC_EXCEPTION.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.BIOMETRIC_EXCEPTION)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, - PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage() + ExceptionUtils.getStackTrace(e)); - object.setInternalError(Boolean.TRUE); - description.setCode(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getCode()); - description.setMessage(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage()); - } catch (JsonProcessingException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() - + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - registrationStatusDto.setStatusComment(trimExceptionMsg - .trimExceptionMessage(StatusUtil.JSON_PARSING_EXCEPTION.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.JSON_PARSING_EXCEPTION.getCode()); - registrationStatusDto.setLatestTransactionStatusCode(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.JSON_PROCESSING_EXCEPTION)); - description.setMessage(PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION.getMessage()); - description.setCode(PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (IOException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() - + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - registrationStatusDto.setStatusComment( - trimExceptionMsg.trimExceptionMessage(StatusUtil.IO_EXCEPTION.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.IO_EXCEPTION.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.IOEXCEPTION)); - description.setMessage(PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getMessage()); - description.setCode(PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (PacketManagerException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() - + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); - registrationStatusDto.setStatusComment(trimExceptionMsg - .trimExceptionMessage(StatusUtil.PACKET_MANAGER_EXCEPTION.getMessage() + e.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_MANAGER_EXCEPTION.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.PACKET_MANAGER_EXCEPTION)); - description.setMessage(PlatformErrorMessages.PACKET_MANAGER_EXCEPTION.getMessage()); - description.setCode(PlatformErrorMessages.PACKET_MANAGER_EXCEPTION.getCode()); - object.setInternalError(Boolean.TRUE); - } catch (Exception ex) { - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.name()); - registrationStatusDto.setStatusComment(trimExceptionMsg - .trimExceptionMessage(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getMessage() + ex.getMessage())); - registrationStatusDto.setSubStatusCode(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getCode()); - registrationStatusDto.setLatestTransactionStatusCode( - registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.EXCEPTION)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - regId, - RegistrationStatusCode.FAILED.toString() + ex.getMessage() + ExceptionUtils.getStackTrace(ex)); - object.setInternalError(Boolean.TRUE); - description.setCode(PlatformErrorMessages.RPR_BDD_UNKNOWN_EXCEPTION.getCode()); - description.setMessage(PlatformErrorMessages.RPR_BDD_UNKNOWN_EXCEPTION.getMessage()); - } finally { - if(object.getInternalError()) { - updateErrorFlags(registrationStatusDto, object); - } - object.setRid(registrationStatusDto.getRegistrationId()); - registrationStatusDto.setRegistrationStageName(getStageName()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.QUALITY_CLASSIFIER.toString()); - String moduleId = isTransactionSuccessful ? PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getCode() - : description.getCode(); - String moduleName = ModuleName.QUALITY_CLASSIFIER.toString(); - registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); - String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() : EventId.RPR_405.toString(); - String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() : EventName.EXCEPTION.toString(); - String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() : EventType.SYSTEM.toString(); - - auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, - moduleId, moduleName, regId); - - } - - return object; - } - - - private iBioProviderApi getBioSdkInstance(BiometricType biometricType) throws BiometricException { - iBioProviderApi bioProvider = bioApiFactory.getBioProvider(biometricType, BiometricFunction.QUALITY_CHECK); - return bioProvider; - } - - private Map getQualityTags(List birs) throws BiometricException{ - - Map tags = new HashMap(); - - // setting biometricNotAvailableTagValue for each modality in case biometrics are not available - if (birs == null) { - modalities.forEach(modality -> { - tags.put(qualityTagPrefix.concat(modality), biometricNotAvailableTagValue); - }); - return tags; - } - - HashMap bioTypeMinScoreMap = new HashMap(); - - // get individual biometrics file name from id.json - for (BIR bir : birs) { - - if (bir.getOthers() != null) { - HashMap othersInfo = bir.getOthers(); - boolean exceptionValue = false; - for (Map.Entry other : othersInfo.entrySet()) { - if (other.getKey().equals(EXCEPTION)) { - if (other.getValue().equals(TRUE)) { - exceptionValue = true; - } - break; - } - } - - if (exceptionValue) { - continue; - } - } - - BiometricType biometricType = bir.getBdbInfo().getType().get(0); - BIR[] birArray = new BIR[1]; - birArray[0] = bir; - if(!biometricType.name().equalsIgnoreCase(BiometricType.EXCEPTION_PHOTO.name())) { - float[] qualityScoreresponse = getBioSdkInstance(biometricType).getSegmentQuality(birArray, null); - - float score = qualityScoreresponse[0]; - String bioType = bir.getBdbInfo().getType().get(0).value(); - - // Check for entry - Float storedMinScore = bioTypeMinScoreMap.get(bioType); - - bioTypeMinScoreMap.put(bioType, - storedMinScore == null ? score : storedMinScore > score ? score : storedMinScore); - } - } - - for (Entry bioTypeMinEntry : bioTypeMinScoreMap.entrySet()) { - - for (Entry qualityRangeEntry : parsedQualityRangeMap.entrySet()) { - - if (bioTypeMinEntry.getValue() >= qualityRangeEntry.getValue()[0] - && bioTypeMinEntry.getValue() < qualityRangeEntry.getValue()[1]) { - - tags.put( qualityTagPrefix.concat(bioTypeMinEntry.getKey()), qualityRangeEntry.getKey()); - break; - } - - } - } - - // setting biometricNotAvailableTagValue for modalities those are not available in BIRs - modalities.forEach(modality -> { - if (!tags.containsKey(qualityTagPrefix.concat(modality))) { - tags.put(qualityTagPrefix.concat(modality), biometricNotAvailableTagValue); - } - }); - - return tags; - } - - private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { - object.setInternalError(true); - if (registrationStatusDto.getLatestTransactionStatusCode() - .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { - object.setIsValid(true); - } else { - object.setIsValid(false); - } - } -} +package io.mosip.registration.processor.quality.classifier.stage; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import jakarta.annotation.PostConstruct; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import io.mosip.kernel.biometrics.constant.BiometricFunction; +import io.mosip.kernel.biometrics.constant.BiometricType; +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.biosdk.provider.factory.BioAPIFactory; +import io.mosip.kernel.biosdk.provider.spi.iBioProviderApi; +import io.mosip.kernel.core.bioapi.exception.BiometricException; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; +import io.mosip.registration.processor.core.abstractverticle.MosipRouter; +import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; +import io.mosip.registration.processor.core.code.EventId; +import io.mosip.registration.processor.core.code.EventName; +import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.ModuleName; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.core.status.util.TrimExceptionMessage; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.quality.classifier.exception.FileMissingException; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +/** + * The Class QualityCheckerStage. + * + * @author M1048358 Alok Ranjan + */ +@Component +@Configuration +@ComponentScan(basePackages = { "${mosip.auth.adapter.impl.basepackage}", + "io.mosip.registration.processor.core.config", + "io.mosip.registration.processor.quality.classifier.config", "io.mosip.registration.processor.stages.config", + "io.mosip.registrationprocessor.stages.config", "io.mosip.registration.processor.status.config", + "io.mosip.registration.processor.rest.client.config", "io.mosip.registration.processor.packet.storage.config", + "io.mosip.registration.processor.packet.manager.config", "io.mosip.kernel.idobjectvalidator.config", + "io.mosip.registration.processor.core.kernel.beans", "io.mosip.kernel.biosdk.provider.impl" }) +public class QualityClassifierStage extends MosipVerticleAPIManager { + + private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.quality.classifier."; + + + /** The Constant UTF_8. */ + public static final String UTF_8 = "UTF-8"; + + /** The Constant VALUE. */ + public static final String VALUE = "value"; + + /** The Constant TRUE. */ + public static final String TRUE = "true"; + + /** The Constant EXCEPTION. */ + public static final String EXCEPTION = "EXCEPTION"; + + private TrimExceptionMessage trimExceptionMsg = new TrimExceptionMessage(); + + /** The cluster manager url. */ + @Value("${vertx.cluster.configuration}") + private String clusterManagerUrl; + + /** worker pool size. */ + @Value("${worker.pool.size}") + private Integer workerPoolSize; + + /** + * After this time intervel, message should be considered as expired (In + * seconds). + */ + @Value("${mosip.regproc.quality.classifier.message.expiry-time-limit}") + private Long messageExpiryTimeLimit; + + /** The core audit request builder. */ + @Autowired + private AuditLogRequestBuilder auditLogRequestBuilder; + + /** The registration status service. */ + @Autowired + private RegistrationStatusService registrationStatusService; + + /** Mosip router for APIs */ + @Autowired + private MosipRouter router; + + @Autowired + private PriorityBasedPacketManagerService basedPacketManagerService; + + @Autowired + private PacketManagerService packetManagerService; + + /** The registration status mapper util. */ + @Autowired + private RegistrationExceptionMapperUtil registrationStatusMapperUtil; + + /** + * Below quality classifications map should contain proper quality + * classification name and quality range, any overlap of the quality range will + * result in a random behaviour of tagging. In range, upper and lower values are + * inclusive. + */ + + @Value("#{${mosip.regproc.quality.classifier.tagging.quality.ranges:{'level-1':'0-10','level-2':'10-20','level-3':'20-30','level-4':'30-40','level-5':'40-50','level-6':'50-60','level-7':'60-70','level-8':'70-80','level-9':'80-90','level-10':'90-101',}}}") + private Map qualityClassificationRangeMap; + + /** Quality Tag Prefix */ + @Value("${mosip.regproc.quality.classifier.tagging.quality.prefix:Biometric_Quality-}") + private String qualityTagPrefix; + + /** The tag value that will be used by default when the packet does not have value for the biometric tag field */ + @Value("${mosip.regproc.quality.classifier.tagging.quality.biometric-not-available-tag-value}") + private String biometricNotAvailableTagValue; + + /** modality arrays that needs to be tagged */ + @Value("#{'${mosip.regproc.quality.classifier.tagging.quality.modalities}'.split(',')}") + private List modalities; + + private static String RANGE_DELIMITER = "-"; + + /** + * Filter qualityClassficaticationsRangeMap using delimiter and store into + * parsedQualityRangemap using @PostConstruct + */ + private Map parsedQualityRangeMap; + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(QualityClassifierStage.class); + + /** The Constant FILE_SEPARATOR. */ + public static final String FILE_SEPARATOR = File.separator; + + private MosipEventBus mosipEventBus = null; + + private TrimExceptionMessage trimExpMessage = new TrimExceptionMessage(); + + @Autowired + private BioAPIFactory bioApiFactory; + + @PostConstruct + private void generateParsedQualityRangeMap() { + parsedQualityRangeMap = new HashMap<>(); + for (Map.Entry entry : qualityClassificationRangeMap.entrySet()) { + String[] range = entry.getValue().split(RANGE_DELIMITER); + int[] rangeArray = new int[2]; + rangeArray[0] = Integer.parseInt(range[0]); + rangeArray[1] = Integer.parseInt(range[1]); + parsedQualityRangeMap.put(entry.getKey(), rangeArray); + } + } + + /** + * Deploy verticle. + */ + public void deployVerticle() { + mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); + this.consumeAndSend(mosipEventBus, MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN, + MessageBusAddress.QUALITY_CLASSIFIER_BUS_OUT, messageExpiryTimeLimit); + } + + @Override + protected String getPropertyPrefix() { + return STAGE_PROPERTY_PREFIX; + } + + @Override + public void start() { + router.setRoute(this.postUrl(getVertx(), MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN, + MessageBusAddress.QUALITY_CLASSIFIER_BUS_OUT)); + this.createServer(router.getRouter(), getPort()); + } + + /* + * (non-Javadoc) + * + * @see + * io.mosip.registration.processor.core.spi.eventbus.EventBusManager#process( + * java.lang.Object) + */ + @Override + public MessageDTO process(MessageDTO object) { + object.setMessageBusAddress(MessageBusAddress.QUALITY_CLASSIFIER_BUS_IN); + String regId = object.getRid(); + LogDescription description = new LogDescription(); + object.setInternalError(Boolean.FALSE); + object.setIsValid(Boolean.FALSE); + Boolean isTransactionSuccessful = Boolean.FALSE; + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, + "QualityCheckerStage::process()::entry"); + + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus(regId, + object.getReg_type(), object.getIteration(), object.getWorkflowInstanceId()); + + try { + String individualBiometricsObject = basedPacketManagerService.getFieldByMappingJsonKey(regId, + MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationStatusDto.getRegistrationType(), + ProviderStageName.QUALITY_CHECKER); + if (StringUtils.isEmpty(individualBiometricsObject)) { + packetManagerService.addOrUpdateTags(regId, getQualityTags(null)); + description.setCode(PlatformErrorMessages.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getCode()); + description.setMessage(PlatformErrorMessages.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getMessage()); + object.setIsValid(Boolean.TRUE); + isTransactionSuccessful = Boolean.TRUE; + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.SUCCESS.toString()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); + registrationStatusDto.setStatusComment(StatusUtil.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.INDIVIDUAL_BIOMETRIC_NOT_FOUND.getCode()); + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, + "Individual Biometric parameter is not present in ID Json"); + } else { + BiometricRecord biometricRecord = basedPacketManagerService.getBiometricsByMappingJsonKey(regId, + MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationStatusDto.getRegistrationType(), + ProviderStageName.QUALITY_CHECKER); + + if (biometricRecord == null || CollectionUtils.isEmpty(biometricRecord.getSegments())) { + biometricRecord = basedPacketManagerService.getBiometricsByMappingJsonKey(regId, + MappingJsonConstants.AUTHENTICATION_BIOMETRICS, registrationStatusDto.getRegistrationType(), + ProviderStageName.QUALITY_CHECKER); + } + + if (biometricRecord == null || biometricRecord.getSegments() == null + || biometricRecord.getSegments().size() == 0) { + description.setCode(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getCode()); + description.setMessage(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), regId, + PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); + throw new FileMissingException(PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getCode(), + PlatformErrorMessages.RPR_QCR_BIO_FILE_MISSING.getMessage()); + } + + + packetManagerService.addOrUpdateTags(regId, getQualityTags(biometricRecord.getSegments())); + + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, + "UpdatingTags::success "); + + object.setIsValid(Boolean.TRUE); + description.setCode(PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getCode()); + description.setMessage(PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getMessage()); + isTransactionSuccessful = Boolean.TRUE; + registrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.SUCCESS.toString()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.toString()); + registrationStatusDto.setStatusComment(StatusUtil.BIOMETRIC_QUALITY_CHECK_SUCCESS.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.BIOMETRIC_QUALITY_CHECK_SUCCESS.getCode()); + regProcLogger.info(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), regId, "QualityCheckerImpl::success"); + } + + } catch (ApisResourceAccessException e) { + registrationStatusDto.setLatestTransactionStatusCode(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.APIS_RESOURCE_ACCESS_EXCEPTION)); + registrationStatusDto.setStatusComment(trimExpMessage + .trimExceptionMessage(StatusUtil.API_RESOUCE_ACCESS_FAILED.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.API_RESOUCE_ACCESS_FAILED.getCode()); + object.setInternalError(Boolean.TRUE); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.name() + ExceptionUtils.getStackTrace(e)); + + description.setMessage(PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.getMessage()); + description.setCode(PlatformErrorMessages.RPR_PUM_NGINX_ACCESS_FAILED.getCode()); + } catch (FileMissingException e) { + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); + registrationStatusDto.setStatusComment(StatusUtil.BIO_METRIC_FILE_MISSING.getMessage()); + registrationStatusDto.setSubStatusCode(StatusUtil.BIO_METRIC_FILE_MISSING.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.BIOMETRIC_EXCEPTION)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, + PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage() + ExceptionUtils.getStackTrace(e)); + object.setInternalError(Boolean.TRUE); + description.setCode(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getCode()); + description.setMessage(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage()); + + } catch (BiometricException e) { + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); + registrationStatusDto.setStatusComment(trimExceptionMsg + .trimExceptionMessage(StatusUtil.BIO_METRIC_EXCEPTION.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.BIO_METRIC_EXCEPTION.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.BIOMETRIC_EXCEPTION)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, + PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage() + ExceptionUtils.getStackTrace(e)); + object.setInternalError(Boolean.TRUE); + description.setCode(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getCode()); + description.setMessage(PlatformErrorMessages.RPR_QCR_BIOMETRIC_EXCEPTION.getMessage()); + } catch (JsonProcessingException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() + + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + registrationStatusDto.setStatusComment(trimExceptionMsg + .trimExceptionMessage(StatusUtil.JSON_PARSING_EXCEPTION.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.JSON_PARSING_EXCEPTION.getCode()); + registrationStatusDto.setLatestTransactionStatusCode(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.JSON_PROCESSING_EXCEPTION)); + description.setMessage(PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION.getMessage()); + description.setCode(PlatformErrorMessages.RPR_SYS_JSON_PARSING_EXCEPTION.getCode()); + object.setInternalError(Boolean.TRUE); + } catch (IOException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() + + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + registrationStatusDto.setStatusComment( + trimExceptionMsg.trimExceptionMessage(StatusUtil.IO_EXCEPTION.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.IO_EXCEPTION.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.IOEXCEPTION)); + description.setMessage(PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getMessage()); + description.setCode(PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getCode()); + object.setInternalError(Boolean.TRUE); + } catch (PacketManagerException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, RegistrationStatusCode.FAILED.toString() + e.getMessage() + + org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(e)); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSING.name()); + registrationStatusDto.setStatusComment(trimExceptionMsg + .trimExceptionMessage(StatusUtil.PACKET_MANAGER_EXCEPTION.getMessage() + e.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.PACKET_MANAGER_EXCEPTION.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.PACKET_MANAGER_EXCEPTION)); + description.setMessage(PlatformErrorMessages.PACKET_MANAGER_EXCEPTION.getMessage()); + description.setCode(PlatformErrorMessages.PACKET_MANAGER_EXCEPTION.getCode()); + object.setInternalError(Boolean.TRUE); + } catch (Exception ex) { + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.name()); + registrationStatusDto.setStatusComment(trimExceptionMsg + .trimExceptionMessage(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getMessage() + ex.getMessage())); + registrationStatusDto.setSubStatusCode(StatusUtil.UNKNOWN_EXCEPTION_OCCURED.getCode()); + registrationStatusDto.setLatestTransactionStatusCode( + registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.EXCEPTION)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + regId, + RegistrationStatusCode.FAILED.toString() + ex.getMessage() + ExceptionUtils.getStackTrace(ex)); + object.setInternalError(Boolean.TRUE); + description.setCode(PlatformErrorMessages.RPR_BDD_UNKNOWN_EXCEPTION.getCode()); + description.setMessage(PlatformErrorMessages.RPR_BDD_UNKNOWN_EXCEPTION.getMessage()); + } finally { + if(object.getInternalError()) { + updateErrorFlags(registrationStatusDto, object); + } + object.setRid(registrationStatusDto.getRegistrationId()); + registrationStatusDto.setRegistrationStageName(getStageName()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.QUALITY_CLASSIFIER.toString()); + String moduleId = isTransactionSuccessful ? PlatformSuccessMessages.RPR_QUALITY_CHECK_SUCCESS.getCode() + : description.getCode(); + String moduleName = ModuleName.QUALITY_CLASSIFIER.toString(); + registrationStatusService.updateRegistrationStatus(registrationStatusDto, moduleId, moduleName); + String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() : EventId.RPR_405.toString(); + String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() : EventName.EXCEPTION.toString(); + String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() : EventType.SYSTEM.toString(); + + auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, + moduleId, moduleName, regId); + + } + + return object; + } + + + private iBioProviderApi getBioSdkInstance(BiometricType biometricType) throws BiometricException { + iBioProviderApi bioProvider = bioApiFactory.getBioProvider(biometricType, BiometricFunction.QUALITY_CHECK); + return bioProvider; + } + + private Map getQualityTags(List birs) throws BiometricException{ + + Map tags = new HashMap(); + + // setting biometricNotAvailableTagValue for each modality in case biometrics are not available + if (birs == null) { + modalities.forEach(modality -> { + tags.put(qualityTagPrefix.concat(modality), biometricNotAvailableTagValue); + }); + return tags; + } + + HashMap bioTypeMinScoreMap = new HashMap(); + + // get individual biometrics file name from id.json + for (BIR bir : birs) { + + if (bir.getOthers() != null) { + HashMap othersInfo = bir.getOthers(); + boolean exceptionValue = false; + for (Map.Entry other : othersInfo.entrySet()) { + if (other.getKey().equals(EXCEPTION)) { + if (other.getValue().equals(TRUE)) { + exceptionValue = true; + } + break; + } + } + + if (exceptionValue) { + continue; + } + } + + BiometricType biometricType = bir.getBdbInfo().getType().get(0); + BIR[] birArray = new BIR[1]; + birArray[0] = bir; + if(!biometricType.name().equalsIgnoreCase(BiometricType.EXCEPTION_PHOTO.name())) { + float[] qualityScoreresponse = getBioSdkInstance(biometricType).getSegmentQuality(birArray, null); + + float score = qualityScoreresponse[0]; + String bioType = bir.getBdbInfo().getType().get(0).value(); + + // Check for entry + Float storedMinScore = bioTypeMinScoreMap.get(bioType); + + bioTypeMinScoreMap.put(bioType, + storedMinScore == null ? score : storedMinScore > score ? score : storedMinScore); + } + } + + for (Entry bioTypeMinEntry : bioTypeMinScoreMap.entrySet()) { + + for (Entry qualityRangeEntry : parsedQualityRangeMap.entrySet()) { + + if (bioTypeMinEntry.getValue() >= qualityRangeEntry.getValue()[0] + && bioTypeMinEntry.getValue() < qualityRangeEntry.getValue()[1]) { + + tags.put( qualityTagPrefix.concat(bioTypeMinEntry.getKey()), qualityRangeEntry.getKey()); + break; + } + + } + } + + // setting biometricNotAvailableTagValue for modalities those are not available in BIRs + modalities.forEach(modality -> { + if (!tags.containsKey(qualityTagPrefix.concat(modality))) { + tags.put(qualityTagPrefix.concat(modality), biometricNotAvailableTagValue); + } + }); + + return tags; + } + + private void updateErrorFlags(InternalRegistrationStatusDto registrationStatusDto, MessageDTO object) { + object.setInternalError(true); + if (registrationStatusDto.getLatestTransactionStatusCode() + .equalsIgnoreCase(RegistrationTransactionStatusCode.REPROCESS.toString())) { + object.setIsValid(true); + } else { + object.setIsValid(false); + } + } +} diff --git a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/pom.xml b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/pom.xml index 8be0786203b..56a812ce292 100644 --- a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/pom.xml @@ -1,100 +1,96 @@ - - - - pre-processor - io.mosip.registrationprocessor - 1.2.1-SNAPSHOT - - 4.0.0 - 1.2.1-SNAPSHOT - - registration-processor-securezone-notification-stage - - - - - - junit - junit - test - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - com.h2database - h2 - ${h2.version} - - - - - - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - org.springframework - spring-context - ${spring-framework.version} - - - org.postgresql - postgresql - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.batch - spring-batch-test - test - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - com.h2database - h2 - - - org.mockito - mockito-core - test - - - org.awaitility - awaitility - ${awaitility.version} - test - - - + + + + pre-processor + io.mosip.registrationprocessor + 1.2.1-java21-SNAPSHOT + + 4.0.0 + 1.2.1-java21-SNAPSHOT + + registration-processor-securezone-notification-stage + + + + + + junit + junit + test + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + com.h2database + h2 + ${h2.version} + + + + + + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.springframework + spring-context + + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.batch + spring-batch-test + test + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + com.h2database + h2 + + + org.mockito + mockito-core + test + + + org.awaitility + awaitility + test + + + \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java index 86171c89847..6e366b277da 100644 --- a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java +++ b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java @@ -1,538 +1,507 @@ -package io.mosip.registration.processor.securezone.notification.stage; - -import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; - -import java.io.InputStream; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.util.ReflectionTestUtils; - -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; -import io.mosip.registration.processor.status.exception.TablenotAccessibleException; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.SyncRegistrationService; -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.HttpMethod; -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.auth.User; -import io.vertx.ext.web.Cookie; -import io.vertx.ext.web.FileUpload; -import io.vertx.ext.web.Locale; -import io.vertx.ext.web.ParsedHeaderValues; -import io.vertx.ext.web.Route; -import io.vertx.ext.web.Router; -import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.Session; - -@RunWith(SpringRunner.class) -public class SecurezoneNotificationStageTest { - - private static final int maxRetryCount = 5; - - private static final InputStream stream = Mockito.mock(InputStream.class); - - MessageDTO messageDTO= new MessageDTO(); - - /** The registration status service. */ - @Mock - RegistrationStatusService registrationStatusService; - - @Mock - private SyncRegistrationService syncRegistrationService; - - @Mock - private RegistrationExceptionMapperUtil registrationStatusMapperUtil; - - @Mock - private AuditLogRequestBuilder auditLogRequestBuilder; - - private RoutingContext ctx; - private Boolean responseObject; - - @Mock - private MosipRouter router; - - @InjectMocks - SecurezoneNotificationStage notificationStage = new SecurezoneNotificationStage() { - - @Override - public void setResponse(RoutingContext ctx, Object object) { - responseObject = Boolean.TRUE; - } - - @Override - public void send(MosipEventBus mosipEventBus, MessageBusAddress toAddress, MessageDTO message) { - } - - @Override - public MosipEventBus getEventBus(Object verticleName, String url, int instanceNumber) { - return null; - } - - @Override - public void createServer(Router route, int port) - { - - } - @Override - public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { - return null; - } - }; - - private RoutingContext setContext() { - return new RoutingContext() { - - @Override - public Set fileUploads() { - return null; - } - - @Override - public Vertx vertx() { - return null; - } - - @Override - public User user() { - return null; - } - - @Override - public int statusCode() { - return 0; - } - - @Override - public void setUser(User user) { - } - - @Override - public void setSession(Session session) { - } - - @Override - public void setBody(Buffer body) { - } - - @Override - public void setAcceptableContentType(String contentType) { - } - - @Override - public Session session() { - return null; - } - - @Override - public HttpServerResponse response() { - return null; - } - - @Override - public void reroute(HttpMethod method, String path) { - } - - @Override - public HttpServerRequest request() { - return null; - } - - @Override - public boolean removeHeadersEndHandler(int handlerID) { - return false; - } - - @Override - public Cookie removeCookie(String name, boolean invalidate) { - return null; - } - - @Override - public boolean removeBodyEndHandler(int handlerID) { - return false; - } - - @Override - public T remove(String key) { - return null; - } - - @Override - public MultiMap queryParams() { - return null; - } - - @Override - public List queryParam(String query) { - return null; - } - - @Override - public RoutingContext put(String key, Object obj) { - return null; - } - - @Override - public Map pathParams() { - return null; - } - - @Override - public String pathParam(String name) { - return null; - } - - @Override - public ParsedHeaderValues parsedHeaders() { - return null; - } - - @Override - public String normalisedPath() { - return null; - } - - @Override - public void next() { - } - - @Override - public String mountPoint() { - return null; - } - - @Override - public Cookie getCookie(String name) { - return null; - } - - @Override - public String getBodyAsString(String encoding) { - return null; - } - - @Override - public String getBodyAsString() { - return null; - } - - @Override - public JsonArray getBodyAsJsonArray() { - return null; - } - - @Override - public JsonObject getBodyAsJson() { - JsonObject obj = new JsonObject(); - obj.put("rid", "2018701130000410092018110735"); - obj.put("isValid", true); - obj.put("internalError", false); - obj.put("reg_type", "NEW"); - obj.put("source", "REGISTRATIONCLIENT"); - obj.put("iteration", 1); - obj.put("workflowInstanceId", "78fc3d34-03f5-11ec-9a03-0242ac130003"); - return obj; - } - - @Override - public Buffer getBody() { - return null; - } - - @Override - public String getAcceptableContentType() { - return null; - } - - @Override - public T get(String key) { - return null; - } - - @Override - public Throwable failure() { - return null; - } - - @Override - public boolean failed() { - return false; - } - - @Override - public void fail(Throwable throwable) { - } - - @Override - public void fail(int statusCode) { - } - - @Override - public Map data() { - return null; - } - - @Override - public Route currentRoute() { - return null; - } - - @Override - public Set cookies() { - return null; - } - - @Override - public int cookieCount() { - return 0; - } - - @Override - public void clearUser() { - } - - @Override - public int addHeadersEndHandler(Handler handler) { - return 0; - } - - @Override - public RoutingContext addCookie(Cookie cookie) { - return null; - } - - @Override - public int addBodyEndHandler(Handler handler) { - return 0; - } - - @Override - public List acceptableLocales() { - return null; - } - - @Override - public RoutingContext addCookie(io.vertx.core.http.Cookie arg0) { - return null; - } - - @Override - public int addEndHandler(Handler> arg0) { - return 0; - } - - @Override - public Map cookieMap() { - return null; - } - - @Override - public void fail(int arg0, Throwable arg1) { - - } - - @Override - public boolean isSessionAccessed() { - return false; - } - - @Override - public boolean removeEndHandler(int arg0) { - return false; - } - - - }; - } - - InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - InternalRegistrationStatusDto registrationStatusDto1 = new InternalRegistrationStatusDto(); - List entities = new ArrayList(); - SyncRegistrationEntity entity = new SyncRegistrationEntity(); - SyncRegistrationEntity entity1 = new SyncRegistrationEntity(); - - @Before - public void setup() { - - registrationStatusDto = new InternalRegistrationStatusDto(); - registrationStatusDto.setRegistrationId("2018701130000410092018110735"); - registrationStatusDto.setStatusCode("SECUREZONE_NOTIFICATION_SUCCESS"); - registrationStatusDto.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); - registrationStatusDto.setCreateDateTime(LocalDateTime.now().minusDays(1)); - - registrationStatusDto1 = new InternalRegistrationStatusDto(); - registrationStatusDto1.setRegistrationId("2018701130000410092018110735"); - registrationStatusDto1.setStatusCode("SECUREZONE_NOTIFICATION_SUCCESS"); - registrationStatusDto1.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); - registrationStatusDto1.setCreateDateTime(LocalDateTime.now()); - - ResponseWrapper responseWrapper = new ResponseWrapper(); - AuditResponseDto auditResponseDto = new AuditResponseDto(); - responseWrapper.setResponse(auditResponseDto); - - entity.setAdditionalInfoReqId("abc"); - entity.setPacketId("2018701130000410092018110735"); - entity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); - - entity1.setAdditionalInfoReqId(null); - entity1.setPacketId("2018701130000410092018110735"); - entity1.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); - - ctx = setContext(); - ReflectionTestUtils.setField(notificationStage, "workerPoolSize", 10); - ReflectionTestUtils.setField(notificationStage, "clusterManagerUrl", "/dummyPath"); - ReflectionTestUtils.setField(notificationStage, "messageExpiryTimeLimit", Long.valueOf(0)); - ReflectionTestUtils.setField(notificationStage, "mainProcesses", Arrays.asList("NEW","UPDATE","LOST")); - //ReflectionTestUtils.setField(notificationStage, "port", "7999"); - Mockito.when(router.post(Mockito.any())).thenReturn(null); - Mockito.doNothing().when(router).setRoute(Mockito.any()); - Mockito.doNothing().when(router).nonSecureHandler(Mockito.any(),Mockito.any()); - messageDTO.setRid("2018701130000410092018110735"); - messageDTO.setIsValid(true); - messageDTO.setInternalError(false); - messageDTO.setReg_type("NEW"); - messageDTO.setSource("REGISTRATIONCLIENT"); - messageDTO.setIteration(1); - messageDTO.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); - - Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(),any(),any()); - Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder(anyString(), anyString(), anyString(), - anyString(), anyString(), anyString(), anyString()); - entities.add(entity); - Mockito.when(registrationStatusMapperUtil.getStatusCode(any())).thenReturn("Something"); - Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); - Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) - .thenReturn(registrationStatusDto); - } - - @Test - public void processURLTest() { - - notificationStage.processURL(ctx); - - assertTrue(responseObject); - } - - @Test - public void ridNotFoundTest() { - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(null); - - notificationStage.processURL(ctx); - assertTrue(responseObject); - } - - @Test - public void duplicateRidFoundTest() { - - SyncRegistrationEntity syncEntity = new SyncRegistrationEntity(); - syncEntity.setAdditionalInfoReqId(null); - syncEntity.setRegistrationType("NEW"); - syncEntity.setPacketId("2018701130000410092018110735"); - syncEntity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); - entities.add(syncEntity); - entities.add(entity1); - - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) - .thenReturn(registrationStatusDto).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1); - Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(syncEntity); - Mockito.when(syncRegistrationService.findByRegistrationId(any())).thenReturn(entities); - notificationStage.processURL(ctx); - assertTrue(responseObject); - } - - @Test - public void duplicateAdditionalReqIdFoundTest() { - - SyncRegistrationEntity syncEntity = new SyncRegistrationEntity(); - syncEntity.setAdditionalInfoReqId("abc"); - syncEntity.setPacketId("2018701130000410092018110735"); - syncEntity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); - entities.add(syncEntity); - entities.add(entity); - - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) - .thenReturn(registrationStatusDto).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1); - Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); - Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); - notificationStage.processURL(ctx); - assertTrue(responseObject); - } - - @Test - public void processFailureURLTest() { - RoutingContext routingContext = Mockito.mock(RoutingContext.class); - routingContext.setBody(null); - notificationStage.processURL(routingContext); - assertEquals(responseObject, null); - } - - @Test - public void processTest() { - MessageDTO inputDto= new MessageDTO(); - inputDto.setInternalError(Boolean.FALSE); - inputDto.setIsValid(Boolean.TRUE); - inputDto.setRid("2018701130000410092018110735"); - inputDto.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); - - Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); - Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); - MessageDTO messageDTO = notificationStage.process(inputDto); - assertTrue(messageDTO.getIsValid()); - } - - @Test - public void dbExceptionTest() { - Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenThrow(new TablenotAccessibleException("exception")); - Mockito.when(registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)) - .thenReturn("REPROCESS"); - MessageDTO result = notificationStage.process(messageDTO); - assertTrue(result.getInternalError()); - } - - - @Test - public void genericExceptionTest() { - Mockito.when(syncRegistrationService - .findByWorkflowInstanceId(anyString())).thenThrow(new NullPointerException("exception")); - Mockito.when(registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)) - .thenReturn("REPROCESS"); - MessageDTO result = notificationStage.process(messageDTO); - assertFalse(result.getIsValid()); - } -} +package io.mosip.registration.processor.securezone.notification.stage; + +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; + +import java.io.InputStream; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; +import io.mosip.registration.processor.core.abstractverticle.MosipRouter; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; +import io.mosip.registration.processor.status.exception.TablenotAccessibleException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.MultiMap; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.auth.User; +import io.vertx.ext.web.Cookie; +import io.vertx.ext.web.FileUpload; +import io.vertx.ext.web.Locale; +import io.vertx.ext.web.ParsedHeaderValues; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.Session; + +@RunWith(SpringRunner.class) +public class SecurezoneNotificationStageTest { + + private static final int maxRetryCount = 5; + + private static final InputStream stream = Mockito.mock(InputStream.class); + + MessageDTO messageDTO= new MessageDTO(); + + /** The registration status service. */ + @Mock + RegistrationStatusService registrationStatusService; + + @Mock + private SyncRegistrationService syncRegistrationService; + + @Mock + private RegistrationExceptionMapperUtil registrationStatusMapperUtil; + + @Mock + private AuditLogRequestBuilder auditLogRequestBuilder; + + private RoutingContext ctx; + private Boolean responseObject; + + @Mock + private MosipRouter router; + + @InjectMocks + SecurezoneNotificationStage notificationStage = new SecurezoneNotificationStage() { + + @Override + public void setResponse(RoutingContext ctx, Object object) { + responseObject = Boolean.TRUE; + } + + @Override + public void send(MosipEventBus mosipEventBus, MessageBusAddress toAddress, MessageDTO message) { + } + + @Override + public MosipEventBus getEventBus(Object verticleName, String url, int instanceNumber) { + return null; + } + + @Override + public void createServer(Router route, int port) + { + + } + @Override + public Router postUrl(Vertx vertx, MessageBusAddress consumeAddress, MessageBusAddress sendAddress) { + return null; + } + }; + + private RoutingContext setContext() { + return new RoutingContext() { + + @Override + public Set fileUploads() { + return null; + } + + @Override + public Vertx vertx() { + return null; + } + + @Override + public User user() { + return null; + } + + @Override + public int statusCode() { + return 0; + } + + @Override + public void setUser(User user) { + } + + @Override + public void setSession(Session session) { + } + + @Override + public void setBody(Buffer body) { + } + + @Override + public void setAcceptableContentType(String contentType) { + } + + @Override + public Session session() { + return null; + } + + @Override + public HttpServerResponse response() { + return null; + } + + @Override + public void reroute(HttpMethod method, String path) { + } + + @Override + public HttpServerRequest request() { + return null; + } + + @Override + public boolean removeHeadersEndHandler(int handlerID) { + return false; + } + + @Override + public Cookie removeCookie(String name, boolean invalidate) { + return null; + } + + @Override + public boolean removeBodyEndHandler(int handlerID) { + return false; + } + + @Override + public T remove(String key) { + return null; + } + + @Override + public MultiMap queryParams() { + return null; + } + + @Override + public List queryParam(String query) { + return null; + } + + @Override + public RoutingContext put(String key, Object obj) { + return null; + } + + @Override + public Map pathParams() { + return null; + } + + @Override + public String pathParam(String name) { + return null; + } + + @Override + public ParsedHeaderValues parsedHeaders() { + return null; + } + + @Override + public String normalisedPath() { + return null; + } + + @Override + public void next() { + } + + @Override + public String mountPoint() { + return null; + } + + @Override + public Cookie getCookie(String name) { + return null; + } + + @Override + public String getBodyAsString(String encoding) { + return null; + } + + @Override + public String getBodyAsString() { + return null; + } + + @Override + public JsonArray getBodyAsJsonArray() { + return null; + } + + @Override + public JsonObject getBodyAsJson() { + JsonObject obj = new JsonObject(); + obj.put("rid", "2018701130000410092018110735"); + obj.put("isValid", true); + obj.put("internalError", false); + obj.put("reg_type", "NEW"); + obj.put("source", "REGISTRATIONCLIENT"); + obj.put("iteration", 1); + obj.put("workflowInstanceId", "78fc3d34-03f5-11ec-9a03-0242ac130003"); + return obj; + } + + @Override + public Buffer getBody() { + return null; + } + + @Override + public String getAcceptableContentType() { + return null; + } + + @Override + public T get(String key) { + return null; + } + + @Override + public Throwable failure() { + return null; + } + + @Override + public boolean failed() { + return false; + } + + @Override + public void fail(Throwable throwable) { + } + + @Override + public void fail(int statusCode) { + } + + @Override + public Map data() { + return null; + } + + @Override + public Route currentRoute() { + return null; + } + + @Override + public Set cookies() { + return null; + } + + @Override + public int cookieCount() { + return 0; + } + + @Override + public void clearUser() { + } + + @Override + public int addHeadersEndHandler(Handler handler) { + return 0; + } + + @Override + public RoutingContext addCookie(Cookie cookie) { + return null; + } + + @Override + public int addBodyEndHandler(Handler handler) { + return 0; + } + + @Override + public List acceptableLocales() { + return null; + } + + }; + } + + InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + InternalRegistrationStatusDto registrationStatusDto1 = new InternalRegistrationStatusDto(); + List entities = new ArrayList(); + SyncRegistrationEntity entity = new SyncRegistrationEntity(); + SyncRegistrationEntity entity1 = new SyncRegistrationEntity(); + + @Before + public void setup() { + + registrationStatusDto = new InternalRegistrationStatusDto(); + registrationStatusDto.setRegistrationId("2018701130000410092018110735"); + registrationStatusDto.setStatusCode("SECUREZONE_NOTIFICATION_SUCCESS"); + registrationStatusDto.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); + registrationStatusDto.setCreateDateTime(LocalDateTime.now().minusDays(1)); + + registrationStatusDto1 = new InternalRegistrationStatusDto(); + registrationStatusDto1.setRegistrationId("2018701130000410092018110735"); + registrationStatusDto1.setStatusCode("SECUREZONE_NOTIFICATION_SUCCESS"); + registrationStatusDto1.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); + registrationStatusDto1.setCreateDateTime(LocalDateTime.now()); + + ResponseWrapper responseWrapper = new ResponseWrapper(); + AuditResponseDto auditResponseDto = new AuditResponseDto(); + responseWrapper.setResponse(auditResponseDto); + + entity.setAdditionalInfoReqId("abc"); + entity.setPacketId("2018701130000410092018110735"); + entity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); + + entity1.setAdditionalInfoReqId(null); + entity1.setPacketId("2018701130000410092018110735"); + entity1.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); + + ctx = setContext(); + ReflectionTestUtils.setField(notificationStage, "workerPoolSize", 10); + ReflectionTestUtils.setField(notificationStage, "clusterManagerUrl", "/dummyPath"); + ReflectionTestUtils.setField(notificationStage, "messageExpiryTimeLimit", Long.valueOf(0)); + ReflectionTestUtils.setField(notificationStage, "mainProcesses", Arrays.asList("NEW","UPDATE","LOST")); + //ReflectionTestUtils.setField(notificationStage, "port", "7999"); + Mockito.when(router.post(Mockito.any())).thenReturn(null); + Mockito.doNothing().when(router).setRoute(Mockito.any()); + Mockito.doNothing().when(router).nonSecureHandler(Mockito.any(),Mockito.any()); + messageDTO.setRid("2018701130000410092018110735"); + messageDTO.setIsValid(true); + messageDTO.setInternalError(false); + messageDTO.setReg_type("NEW"); + messageDTO.setSource("REGISTRATIONCLIENT"); + messageDTO.setIteration(1); + messageDTO.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); + + Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(),any(),any()); + Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder(anyString(), anyString(), anyString(), + anyString(), anyString(), anyString(), anyString()); + entities.add(entity); + Mockito.when(registrationStatusMapperUtil.getStatusCode(any())).thenReturn("Something"); + Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); + Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) + .thenReturn(registrationStatusDto); + } + + @Test + public void processURLTest() { + + notificationStage.processURL(ctx); + + assertTrue(responseObject); + } + + @Test + public void ridNotFoundTest() { + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenReturn(null); + + notificationStage.processURL(ctx); + assertTrue(responseObject); + } + + @Test + public void duplicateRidFoundTest() { + + SyncRegistrationEntity syncEntity = new SyncRegistrationEntity(); + syncEntity.setAdditionalInfoReqId(null); + syncEntity.setRegistrationType("NEW"); + syncEntity.setPacketId("2018701130000410092018110735"); + syncEntity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); + entities.add(syncEntity); + entities.add(entity1); + + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) + .thenReturn(registrationStatusDto).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1); + Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(syncEntity); + Mockito.when(syncRegistrationService.findByRegistrationId(any())).thenReturn(entities); + notificationStage.processURL(ctx); + assertTrue(responseObject); + } + + @Test + public void duplicateAdditionalReqIdFoundTest() { + + SyncRegistrationEntity syncEntity = new SyncRegistrationEntity(); + syncEntity.setAdditionalInfoReqId("abc"); + syncEntity.setPacketId("2018701130000410092018110735"); + syncEntity.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130004"); + entities.add(syncEntity); + entities.add(entity); + + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())) + .thenReturn(registrationStatusDto).thenReturn(registrationStatusDto).thenReturn(registrationStatusDto1); + Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); + Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); + notificationStage.processURL(ctx); + assertTrue(responseObject); + } + + @Test + public void processFailureURLTest() { + RoutingContext routingContext = Mockito.mock(RoutingContext.class); + routingContext.setBody(null); + notificationStage.processURL(routingContext); + assertEquals(responseObject, null); + } + + @Test + public void processTest() { + MessageDTO inputDto= new MessageDTO(); + inputDto.setInternalError(Boolean.FALSE); + inputDto.setIsValid(Boolean.TRUE); + inputDto.setRid("2018701130000410092018110735"); + inputDto.setWorkflowInstanceId("78fc3d34-03f5-11ec-9a03-0242ac130003"); + + Mockito.when(syncRegistrationService.findByWorkflowInstanceId(anyString())).thenReturn(entity); + Mockito.when(syncRegistrationService.findByAdditionalInfoReqId(anyString())).thenReturn(entities); + MessageDTO messageDTO = notificationStage.process(inputDto); + assertTrue(messageDTO.getIsValid()); + } + + @Test + public void dbExceptionTest() { + Mockito.when(registrationStatusService.getRegistrationStatus(anyString(), any(), any(), any())).thenThrow(new TablenotAccessibleException("exception")); + Mockito.when(registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)) + .thenReturn("REPROCESS"); + MessageDTO result = notificationStage.process(messageDTO); + assertTrue(result.getInternalError()); + } + + + @Test + public void genericExceptionTest() { + Mockito.when(syncRegistrationService + .findByWorkflowInstanceId(anyString())).thenThrow(new NullPointerException("exception")); + Mockito.when(registrationStatusMapperUtil.getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)) + .thenReturn("REPROCESS"); + MessageDTO result = notificationStage.process(messageDTO); + assertFalse(result.getIsValid()); + } +} diff --git a/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml index fcc42cbce37..a7d6ac3a871 100644 --- a/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml @@ -1,119 +1,110 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - pre-processor - 1.2.1-SNAPSHOT - - registration-processor-supervisor-validator-stage - 1.2.1-SNAPSHOT - registration-processor-supervisor-validator-stage - - UTF-8 - UTF-8 - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-bioapi-provider - ${kernel.bioapi.provider.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - javax.servlet - servlet-api - - - dom4j - dom4j - - - - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + pre-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-supervisor-validator-stage + 1.2.1-java21-SNAPSHOT + registration-processor-supervisor-validator-stage + + UTF-8 + UTF-8 + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + javax.servlet + servlet-api + + + dom4j + dom4j + + + + + + + + + + + diff --git a/registration-processor/qc-users-manger/pom.xml b/registration-processor/qc-users-manger/pom.xml index 189d76e6bac..bffd7c5ba8d 100644 --- a/registration-processor/qc-users-manger/pom.xml +++ b/registration-processor/qc-users-manger/pom.xml @@ -1,79 +1,79 @@ - - - 4.0.0 - - - qc-users-manger - 1.2.1-SNAPSHOT - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - - UTF-8 - UTF-8 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-jpa - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - org.postgresql - postgresql - - - io.mosip.kernel - kernel-dataaccess-hibernate - ${kernel.core.version} - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - exec - - - - - - - - + + + 4.0.0 + + + qc-users-manger + 1.2.1-java21-SNAPSHOT + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + + UTF-8 + UTF-8 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + org.postgresql + postgresql + + + io.mosip.kernel + kernel-dataaccess-hibernate + ${kernel.core.version} + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + exec + + + + + + + + diff --git a/registration-processor/registration-processor-bio-dedupe-service-impl/pom.xml b/registration-processor/registration-processor-bio-dedupe-service-impl/pom.xml index cb4bfa09937..bad802b9fae 100644 --- a/registration-processor/registration-processor-bio-dedupe-service-impl/pom.xml +++ b/registration-processor/registration-processor-bio-dedupe-service-impl/pom.xml @@ -1,67 +1,64 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - registration-processor-bio-dedupe-service-impl - 1.2.1-SNAPSHOT - registration-processor-bio-dedupe-service-impl - - - UTF-8 - - - - org.mockito - mockito-core - ${mockito.version} - test - - - junit - junit - test - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - commons-io - commons-io - 2.6 - - - com.h2database - h2 - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - + + + 4.0.0 + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-bio-dedupe-service-impl + 1.2.1-java21-SNAPSHOT + registration-processor-bio-dedupe-service-impl + + + UTF-8 + + + + org.mockito + mockito-core + ${mockito.version} + test + + + junit + junit + test + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + commons-io + commons-io + + + com.h2database + h2 + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + diff --git a/registration-processor/registration-processor-common-camel-bridge/Dockerfile b/registration-processor/registration-processor-common-camel-bridge/Dockerfile index e66fa0142be..00a750a5c83 100644 --- a/registration-processor/registration-processor-common-camel-bridge/Dockerfile +++ b/registration-processor/registration-processor-common-camel-bridge/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine ARG SOURCE ARG COMMIT_HASH @@ -63,15 +63,15 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/registration-processor-common-camel-bridge/dependency-reduced-pom.xml b/registration-processor/registration-processor-common-camel-bridge/dependency-reduced-pom.xml index b1f3b703f28..15d1496c0fe 100644 --- a/registration-processor/registration-processor-common-camel-bridge/dependency-reduced-pom.xml +++ b/registration-processor/registration-processor-common-camel-bridge/dependency-reduced-pom.xml @@ -1,108 +1,108 @@ - - - - registration-processor - io.mosip.registrationprocessor - 1.2.1-SNAPSHOT - - 4.0.0 - registration-processor-common-camel-bridge - 1.2.1-SNAPSHOT - - - - maven-shade-plugin - 2.3 - - - package - - shade - - - - - io.mosip.registration.processor.camel.bridge.MosipCamelBridgeApplication - - - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - - - - - - - io.vertx - vertx-unit - 3.9.1 - test - - - org.mockito - mockito-core - 3.4.4 - test - - - byte-buddy-agent - net.bytebuddy - - - objenesis - org.objenesis - - - - - org.powermock - powermock-module-junit4 - 2.0.7 - test - - - powermock-module-junit4-common - org.powermock - - - - - org.powermock - powermock-api-mockito2 - 2.0.7 - test - - - powermock-api-support - org.powermock - - - - - - - - com.h2database - h2 - ${h2.version} - - - - - io.mosip.registration.processor.camel.bridge.MosipCamelBridge - 1.0.5 - 1.2.1-SNAPSHOT - - - + + + + registration-processor + io.mosip.registrationprocessor + 1.2.1-java21-SNAPSHOT + + 4.0.0 + registration-processor-common-camel-bridge + 1.2.1-java21-SNAPSHOT + + + + maven-shade-plugin + 2.3 + + + package + + shade + + + + + io.mosip.registration.processor.camel.bridge.MosipCamelBridgeApplication + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + io.vertx + vertx-unit + 3.9.1 + test + + + org.mockito + mockito-core + 3.4.4 + test + + + byte-buddy-agent + net.bytebuddy + + + objenesis + org.objenesis + + + + + org.powermock + powermock-module-junit4 + 2.0.7 + test + + + powermock-module-junit4-common + org.powermock + + + + + org.powermock + powermock-api-mockito2 + 2.0.7 + test + + + powermock-api-support + org.powermock + + + + + + + + com.h2database + h2 + ${h2.version} + + + + + io.mosip.registration.processor.camel.bridge.MosipCamelBridge + 1.0.5 + 1.2.1-java21-SNAPSHOT + + + diff --git a/registration-processor/registration-processor-common-camel-bridge/pom.xml b/registration-processor/registration-processor-common-camel-bridge/pom.xml index 4892646c6a5..5fc105adc24 100644 --- a/registration-processor/registration-processor-common-camel-bridge/pom.xml +++ b/registration-processor/registration-processor-common-camel-bridge/pom.xml @@ -1,155 +1,153 @@ - - 4.0.0 - - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - registration-processor-common-camel-bridge - 1.2.1-SNAPSHOT - jar - - - io.mosip.registration.processor.camel.bridge.MosipCamelBridge - 1.0.5 - 1.2.1-SNAPSHOT - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.slf4j - jul-to-slf4j - - - org.slf4j - jcl-over-slf4j - - - com.hazelcast - hazelcast-kubernetes - - - - - io.vertx - vertx-unit - ${vertx.version} - test - - - io.vertx - vertx-config-spring-config-server - ${vertx.version} - - - io.vertx - vertx-config - ${vertx.version} - - - - org.apache.camel - camel-vertx - ${camel.vertx.version} - - - org.slf4j - slf4j-api - - - - - com.hazelcast - hazelcast-kubernetes - 1.0.0 - - - org.apache.camel - camel-http - ${camel.vertx.version} - - - org.slf4j - slf4j-api - - - - - org.apache.camel - camel-kafka - ${camel.vertx.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.apache.camel - camel-jsonpath - ${camel.vertx.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.processor.registration.status.service.impl.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - - - - com.h2database - h2 - ${h2.version} - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.camel.bridge.MosipCamelBridgeApplication - ZIP - - - - - build-info - repackage - - - - - - - + + 4.0.0 + + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-common-camel-bridge + 1.2.1-java21-SNAPSHOT + jar + + + io.mosip.registration.processor.camel.bridge.MosipCamelBridge + 1.0.5 + 1.2.1-java21-SNAPSHOT + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.slf4j + jul-to-slf4j + + + org.slf4j + jcl-over-slf4j + + + com.hazelcast + hazelcast-kubernetes + + + + + io.vertx + vertx-unit + ${vertx.version} + test + + + io.vertx + vertx-config-spring-config-server + ${vertx.version} + + + io.vertx + vertx-config + ${vertx.version} + + + + org.apache.camel + camel-vertx + ${camel.vertx.version} + + + org.slf4j + slf4j-api + + + + + com.hazelcast + hazelcast-kubernetes + 1.0.0 + + + org.apache.camel + camel-http + ${camel.vertx.version} + + + org.slf4j + slf4j-api + + + + + org.apache.camel + camel-kafka + ${camel.vertx.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.apache.camel + camel-jsonpath + ${camel.vertx.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.processor.registration.status.service.impl.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + + + + com.h2database + h2 + ${h2.version} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.camel.bridge.MosipCamelBridgeApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/registration-processor-common-camel-bridge/src/main/java/io/mosip/registration/processor/camel/bridge/intercepter/PauseFlowPredicate.java b/registration-processor/registration-processor-common-camel-bridge/src/main/java/io/mosip/registration/processor/camel/bridge/intercepter/PauseFlowPredicate.java index 8811beff3c7..1dfa344c76f 100644 --- a/registration-processor/registration-processor-common-camel-bridge/src/main/java/io/mosip/registration/processor/camel/bridge/intercepter/PauseFlowPredicate.java +++ b/registration-processor/registration-processor-common-camel-bridge/src/main/java/io/mosip/registration/processor/camel/bridge/intercepter/PauseFlowPredicate.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.regex.Pattern; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.apache.camel.Exchange; import org.apache.camel.Predicate; diff --git a/registration-processor/registration-processor-core/pom.xml b/registration-processor/registration-processor-core/pom.xml index 299aa9591c4..0c71d48ae35 100644 --- a/registration-processor/registration-processor-core/pom.xml +++ b/registration-processor/registration-processor-core/pom.xml @@ -7,27 +7,24 @@ io.mosip.registrationprocessor registration-processor - 1.2.1-SNAPSHOT + 1.2.1-java21-SNAPSHOT registration-processor-core - 1.2.1-SNAPSHOT + 1.2.1-java21-SNAPSHOT org.mockito mockito-core - ${mockito.version} test org.powermock powermock-module-junit4 - ${powermock.module.junit4.version} test org.powermock powermock-api-mockito2 - ${powermock.api.mockito.version} test @@ -54,7 +51,6 @@ org.springframework.boot spring-boot-starter-actuator - ${spring.boot.version} io.vertx @@ -64,7 +60,7 @@ org.apache.activemq activemq-client - 5.17.4 + 6.1.2 org.springframework.boot @@ -184,7 +180,6 @@ com.fasterxml.jackson.module jackson-module-afterburner - ${jackson.afterburner.version} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/StageHealthCheckHandler.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/StageHealthCheckHandler.java index f35ac51bbb3..95a276c79a6 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/StageHealthCheckHandler.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/abstractverticle/StageHealthCheckHandler.java @@ -17,10 +17,10 @@ import java.util.Arrays; import java.util.List; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; import org.apache.activemq.command.ActiveMQBytesMessage; import org.apache.commons.io.FileUtils; @@ -96,7 +96,7 @@ public class StageHealthCheckHandler implements HealthCheckHandler { private static final String WIN_UTIL = "winutils.exe"; private static final String CLASSPATH_PREFIX = "classpath:"; private static final int THRESHOLD = 10485760; - javax.jms.Connection connection = null; + jakarta.jms.Connection connection = null; private Session session = null; MessageConsumer messageConsumer; MessageProducer messageProducer; diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/ActiveMQMessageListener.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/ActiveMQMessageListener.java index 8bc6d344401..926d296d4b0 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/ActiveMQMessageListener.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/ActiveMQMessageListener.java @@ -1,7 +1,7 @@ package io.mosip.registration.processor.core.queue.factory; -import javax.jms.Message; -import javax.jms.MessageListener; +import jakarta.jms.Message; +import jakarta.jms.MessageListener; public abstract class ActiveMQMessageListener implements MessageListener { diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListener.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListener.java index 3a448ac5132..73783fdec75 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListener.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListener.java @@ -1,6 +1,6 @@ package io.mosip.registration.processor.core.queue.factory; -import javax.jms.Message; +import jakarta.jms.Message; public abstract class QueueListener { diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListenerFactory.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListenerFactory.java index 5534f4c2bd4..57c16fcdc35 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListenerFactory.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/factory/QueueListenerFactory.java @@ -1,7 +1,7 @@ package io.mosip.registration.processor.core.queue.factory; -import javax.jms.Message; -import javax.jms.MessageListener; +import jakarta.jms.Message; +import jakarta.jms.MessageListener; public class QueueListenerFactory { diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/impl/MosipActiveMqImpl.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/impl/MosipActiveMqImpl.java index 4a54c65f1ae..6106d1fa9eb 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/impl/MosipActiveMqImpl.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/queue/impl/MosipActiveMqImpl.java @@ -1,248 +1,248 @@ -package io.mosip.registration.processor.core.queue.impl; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.queue.factory.MosipActiveMq; -import io.mosip.registration.processor.core.queue.factory.MosipQueue; -import io.mosip.registration.processor.core.queue.factory.QueueListener; -import io.mosip.registration.processor.core.queue.factory.QueueListenerFactory; -import io.mosip.registration.processor.core.queue.impl.exception.ConnectionUnavailableException; -import io.mosip.registration.processor.core.queue.impl.exception.InvalidConnectionException; -import io.mosip.registration.processor.core.queue.impl.exception.QueueConnectionException; -import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; -import org.apache.activemq.ActiveMQConnection; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.springframework.beans.factory.annotation.Value; - -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; - - -/** - * This class is ActiveMQ implementation for Mosip Queue - * - * @author Mukul Puspam - * @since 0.8.0 - */ -public class MosipActiveMqImpl implements MosipQueueManager { - - /** - * The reg proc logger. - */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(MosipActiveMqImpl.class); - - private Connection connection; - private Session session; - private Destination destination; - private static final String LINE_SEPERATOR = "----------------"; - @Value("${registration.processor.queue.connection.retry.count:10}") - private int retryCount; - - /** - * The method to set up session and destination - * - * @param mosipActiveMq The Mosip ActiveMq instance - */ - private void setup(MosipActiveMq mosipActiveMq) { - regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "In ActiveMq setUp ", LINE_SEPERATOR); - try { - ActiveMQConnection activemQConn = (ActiveMQConnection) connection; - if (activemQConn == null || activemQConn.isClosed()) { - regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----INITIAL CONNECTION-----", - LINE_SEPERATOR + this.connection); - regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----INITIAL SESSION-----", - LINE_SEPERATOR + this.session); - connection = mosipActiveMq.getActiveMQConnectionFactory().createConnection(); - activemQConn = (ActiveMQConnection) connection; - activemQConn.addTransportListener(new TransportExceptionListener()); - if (session == null) { - connection.start(); - this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----NEW CONNECTION-----", - LINE_SEPERATOR + this.connection); - regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----NEW SESSION-----", - LINE_SEPERATOR + this.session); - if (!((ActiveMQConnection) connection).isStarted() || session == null) { - regProcLogger.error("Activemq connection is not created. Retrying....."); - throw new QueueConnectionException("session is "+session); - - } - } - } - - } catch (JMSException e) { - regProcLogger.error(LINE_SEPERATOR, LINE_SEPERATOR, "-----EXCEPTION While starting connection -----", - LINE_SEPERATOR + ExceptionUtils.getFullStackTrace(e)); - throw new ConnectionUnavailableException(PlatformErrorMessages.RPR_MQI_CONNECTION_UNAVAILABLE.getMessage(), - e); - } - - } - - /* - * (non-Javadoc) - * - * @see - * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#send(java. - * lang.Object, java.lang.Object, java.lang.String) - */ - @Override - public Boolean send(MosipQueue mosipQueue, byte[] message, String address) { - return send(mosipQueue, message, address, 0); - } - - /* - * (non-Javadoc) - * - * @see - * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#send(java. - * lang.Object, java.lang.Object, java.lang.String, long) - */ - @Override - public Boolean send(MosipQueue mosipQueue, byte[] message, String address, int messageTTL) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::send()::entry"); - - boolean flag = false; - initialSetup(mosipQueue); - try { - destination = session.createQueue(address); - MessageProducer messageProducer = session.createProducer(destination); - BytesMessage byteMessage = session.createBytesMessage(); - byteMessage.writeObject(message); - if(messageTTL > 0) - messageProducer.setTimeToLive(messageTTL * (long)1000); - messageProducer.send(byteMessage); - flag = true; - } catch (JMSException e) { - regProcLogger.error("*******SEND EXCEPTION *****", "*******SEND EXCEPTION *****", - "*******SEND EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "MosipActiveMqImpl::send():: error with error message " - + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); - throw new ConnectionUnavailableException( - PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::send()::exit"); - - return flag; - } - - @Override - public Boolean send(MosipQueue mosipQueue, String message, String address) { - return send(mosipQueue, message, address, 0); - } - - @Override - public Boolean send(MosipQueue mosipQueue, String message, String address, int messageTTL) { - boolean flag = false; - initialSetup(mosipQueue); - try { - // fix for activemq connection issue - if (session == null) - initialSetup(mosipQueue); - destination = session.createQueue(address); - MessageProducer messageProducer = session.createProducer(destination); - TextMessage textMessage = session.createTextMessage(); - textMessage.setText(message); - if(messageTTL > 0) - messageProducer.setTimeToLive(messageTTL * (long)1000); - messageProducer.send(textMessage); - flag = true; - } catch (JMSException e) { - regProcLogger.error("*******SEND EXCEPTION *****", "*******SEND EXCEPTION *****", - "*******SEND EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "MosipActiveMqImpl::send():: error with error message " - + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); - throw new ConnectionUnavailableException( - PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::send()::exit"); - - return flag; - } - - /* - * (non-Javadoc) - * - * @see - * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#consume(java - * .lang.Object, java.lang.String) - */ - @Override - public byte[] consume(MosipQueue mosipQueue, String address, QueueListener object) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::consume()::entry"); - - MosipActiveMq mosipActiveMq = (MosipActiveMq) mosipQueue; - ActiveMQConnectionFactory activeMQConnectionFactory = mosipActiveMq.getActiveMQConnectionFactory(); - if (activeMQConnectionFactory == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "MosipActiveMqImpl::consume():: error with error message " - + PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); - - throw new InvalidConnectionException(PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); - } - if (destination == null) { - setup(mosipActiveMq); - } - MessageConsumer consumer; - try { - if (session == null) { - regProcLogger.error("Session is null. System will retry to create session"); - setup(mosipActiveMq); - } - destination = session.createQueue(address); - consumer = session.createConsumer(destination); - consumer.setMessageListener(QueueListenerFactory.getListener(mosipQueue.getQueueName(), object)); - } catch (JMSException | NullPointerException e) { - regProcLogger.error("*******CONSUME EXCEPTION *****", "*******CONSUME EXCEPTION *****", - "*******CONSUME EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "MosipActiveMqImpl::consume():: error with error message " - + PlatformErrorMessages.RPR_MQI_UNABLE_TO_CONSUME_FROM_QUEUE.getMessage()); - - if (e instanceof NullPointerException && retryCount > 0) { - regProcLogger.warn(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "Could not obtain queue connection. System will retry for "+ retryCount +" more times."); - retryCount = retryCount - 1; - consume(mosipQueue, address, object); - } else { - throw new ConnectionUnavailableException( - PlatformErrorMessages.RPR_MQI_UNABLE_TO_CONSUME_FROM_QUEUE.getMessage()); - } - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::consume()::exit"); - - return null; - } - - private void initialSetup(MosipQueue mosipQueue) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - "", "MosipActiveMqImpl::send()::entry"); - - MosipActiveMq mosipActiveMq = (MosipActiveMq) mosipQueue; - ActiveMQConnectionFactory activeMQConnectionFactory = mosipActiveMq.getActiveMQConnectionFactory(); - if (activeMQConnectionFactory == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "MosipActiveMqImpl::send():: error with error message " - + PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); - throw new InvalidConnectionException(PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); - } - setup(mosipActiveMq); - } - -} +package io.mosip.registration.processor.core.queue.impl; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.queue.factory.MosipActiveMq; +import io.mosip.registration.processor.core.queue.factory.MosipQueue; +import io.mosip.registration.processor.core.queue.factory.QueueListener; +import io.mosip.registration.processor.core.queue.factory.QueueListenerFactory; +import io.mosip.registration.processor.core.queue.impl.exception.ConnectionUnavailableException; +import io.mosip.registration.processor.core.queue.impl.exception.InvalidConnectionException; +import io.mosip.registration.processor.core.queue.impl.exception.QueueConnectionException; +import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.commons.lang.exception.ExceptionUtils; +import org.springframework.beans.factory.annotation.Value; + +import jakarta.jms.BytesMessage; +import jakarta.jms.Connection; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import jakarta.jms.TextMessage; + + +/** + * This class is ActiveMQ implementation for Mosip Queue + * + * @author Mukul Puspam + * @since 0.8.0 + */ +public class MosipActiveMqImpl implements MosipQueueManager { + + /** + * The reg proc logger. + */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(MosipActiveMqImpl.class); + + private Connection connection; + private Session session; + private Destination destination; + private static final String LINE_SEPERATOR = "----------------"; + @Value("${registration.processor.queue.connection.retry.count:10}") + private int retryCount; + + /** + * The method to set up session and destination + * + * @param mosipActiveMq The Mosip ActiveMq instance + */ + private void setup(MosipActiveMq mosipActiveMq) { + regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "In ActiveMq setUp ", LINE_SEPERATOR); + try { + ActiveMQConnection activemQConn = (ActiveMQConnection) connection; + if (activemQConn == null || activemQConn.isClosed()) { + regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----INITIAL CONNECTION-----", + LINE_SEPERATOR + this.connection); + regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----INITIAL SESSION-----", + LINE_SEPERATOR + this.session); + connection = mosipActiveMq.getActiveMQConnectionFactory().createConnection(); + activemQConn = (ActiveMQConnection) connection; + activemQConn.addTransportListener(new TransportExceptionListener()); + if (session == null) { + connection.start(); + this.session = this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----NEW CONNECTION-----", + LINE_SEPERATOR + this.connection); + regProcLogger.debug(LINE_SEPERATOR, LINE_SEPERATOR, "-----NEW SESSION-----", + LINE_SEPERATOR + this.session); + if (!((ActiveMQConnection) connection).isStarted() || session == null) { + regProcLogger.error("Activemq connection is not created. Retrying....."); + throw new QueueConnectionException("session is "+session); + + } + } + } + + } catch (JMSException e) { + regProcLogger.error(LINE_SEPERATOR, LINE_SEPERATOR, "-----EXCEPTION While starting connection -----", + LINE_SEPERATOR + ExceptionUtils.getFullStackTrace(e)); + throw new ConnectionUnavailableException(PlatformErrorMessages.RPR_MQI_CONNECTION_UNAVAILABLE.getMessage(), + e); + } + + } + + /* + * (non-Javadoc) + * + * @see + * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#send(java. + * lang.Object, java.lang.Object, java.lang.String) + */ + @Override + public Boolean send(MosipQueue mosipQueue, byte[] message, String address) { + return send(mosipQueue, message, address, 0); + } + + /* + * (non-Javadoc) + * + * @see + * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#send(java. + * lang.Object, java.lang.Object, java.lang.String, long) + */ + @Override + public Boolean send(MosipQueue mosipQueue, byte[] message, String address, int messageTTL) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::send()::entry"); + + boolean flag = false; + initialSetup(mosipQueue); + try { + destination = session.createQueue(address); + MessageProducer messageProducer = session.createProducer(destination); + BytesMessage byteMessage = session.createBytesMessage(); + byteMessage.writeObject(message); + if(messageTTL > 0) + messageProducer.setTimeToLive(messageTTL * (long)1000); + messageProducer.send(byteMessage); + flag = true; + } catch (JMSException e) { + regProcLogger.error("*******SEND EXCEPTION *****", "*******SEND EXCEPTION *****", + "*******SEND EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "MosipActiveMqImpl::send():: error with error message " + + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); + throw new ConnectionUnavailableException( + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::send()::exit"); + + return flag; + } + + @Override + public Boolean send(MosipQueue mosipQueue, String message, String address) { + return send(mosipQueue, message, address, 0); + } + + @Override + public Boolean send(MosipQueue mosipQueue, String message, String address, int messageTTL) { + boolean flag = false; + initialSetup(mosipQueue); + try { + // fix for activemq connection issue + if (session == null) + initialSetup(mosipQueue); + destination = session.createQueue(address); + MessageProducer messageProducer = session.createProducer(destination); + TextMessage textMessage = session.createTextMessage(); + textMessage.setText(message); + if(messageTTL > 0) + messageProducer.setTimeToLive(messageTTL * (long)1000); + messageProducer.send(textMessage); + flag = true; + } catch (JMSException e) { + regProcLogger.error("*******SEND EXCEPTION *****", "*******SEND EXCEPTION *****", + "*******SEND EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "MosipActiveMqImpl::send():: error with error message " + + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); + throw new ConnectionUnavailableException( + PlatformErrorMessages.RPR_MQI_UNABLE_TO_SEND_TO_QUEUE.getMessage()); + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::send()::exit"); + + return flag; + } + + /* + * (non-Javadoc) + * + * @see + * io.mosip.registration.processor.core.spi.queue.MosipQueueManager#consume(java + * .lang.Object, java.lang.String) + */ + @Override + public byte[] consume(MosipQueue mosipQueue, String address, QueueListener object) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::consume()::entry"); + + MosipActiveMq mosipActiveMq = (MosipActiveMq) mosipQueue; + ActiveMQConnectionFactory activeMQConnectionFactory = mosipActiveMq.getActiveMQConnectionFactory(); + if (activeMQConnectionFactory == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "MosipActiveMqImpl::consume():: error with error message " + + PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); + + throw new InvalidConnectionException(PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); + } + if (destination == null) { + setup(mosipActiveMq); + } + MessageConsumer consumer; + try { + if (session == null) { + regProcLogger.error("Session is null. System will retry to create session"); + setup(mosipActiveMq); + } + destination = session.createQueue(address); + consumer = session.createConsumer(destination); + consumer.setMessageListener(QueueListenerFactory.getListener(mosipQueue.getQueueName(), object)); + } catch (JMSException | NullPointerException e) { + regProcLogger.error("*******CONSUME EXCEPTION *****", "*******CONSUME EXCEPTION *****", + "*******CONSUME EXCEPTION *****", ExceptionUtils.getFullStackTrace(e)); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "MosipActiveMqImpl::consume():: error with error message " + + PlatformErrorMessages.RPR_MQI_UNABLE_TO_CONSUME_FROM_QUEUE.getMessage()); + + if (e instanceof NullPointerException && retryCount > 0) { + regProcLogger.warn(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "Could not obtain queue connection. System will retry for "+ retryCount +" more times."); + retryCount = retryCount - 1; + consume(mosipQueue, address, object); + } else { + throw new ConnectionUnavailableException( + PlatformErrorMessages.RPR_MQI_UNABLE_TO_CONSUME_FROM_QUEUE.getMessage()); + } + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::consume()::exit"); + + return null; + } + + private void initialSetup(MosipQueue mosipQueue) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + "", "MosipActiveMqImpl::send()::entry"); + + MosipActiveMq mosipActiveMq = (MosipActiveMq) mosipQueue; + ActiveMQConnectionFactory activeMQConnectionFactory = mosipActiveMq.getActiveMQConnectionFactory(); + if (activeMQConnectionFactory == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "MosipActiveMqImpl::send():: error with error message " + + PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); + throw new InvalidConnectionException(PlatformErrorMessages.RPR_MQI_INVALID_CONNECTION.getMessage()); + } + setup(mosipActiveMq); + } + +} diff --git a/registration-processor/registration-processor-core/src/test/java/io/mosip/registration/processor/queue/MosipActiveMqTest.java b/registration-processor/registration-processor-core/src/test/java/io/mosip/registration/processor/queue/MosipActiveMqTest.java index d7f3f7a6b5a..da18c204f40 100644 --- a/registration-processor/registration-processor-core/src/test/java/io/mosip/registration/processor/queue/MosipActiveMqTest.java +++ b/registration-processor/registration-processor-core/src/test/java/io/mosip/registration/processor/queue/MosipActiveMqTest.java @@ -5,29 +5,29 @@ import java.io.Serializable; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionConsumer; -import javax.jms.ConnectionMetaData; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.MapMessage; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.ObjectMessage; -import javax.jms.Queue; -import javax.jms.QueueBrowser; -import javax.jms.ServerSessionPool; -import javax.jms.Session; -import javax.jms.StreamMessage; -import javax.jms.TemporaryQueue; -import javax.jms.TemporaryTopic; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.jms.TopicSubscriber; +import jakarta.jms.BytesMessage; +import jakarta.jms.Connection; +import jakarta.jms.ConnectionConsumer; +import jakarta.jms.ConnectionMetaData; +import jakarta.jms.Destination; +import jakarta.jms.ExceptionListener; +import jakarta.jms.JMSException; +import jakarta.jms.MapMessage; +import jakarta.jms.Message; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageListener; +import jakarta.jms.MessageProducer; +import jakarta.jms.ObjectMessage; +import jakarta.jms.Queue; +import jakarta.jms.QueueBrowser; +import jakarta.jms.ServerSessionPool; +import jakarta.jms.Session; +import jakarta.jms.StreamMessage; +import jakarta.jms.TemporaryQueue; +import jakarta.jms.TemporaryTopic; +import jakarta.jms.TextMessage; +import jakarta.jms.Topic; +import jakarta.jms.TopicSubscriber; import org.apache.activemq.ActiveMQConnectionFactory; import org.junit.Test; diff --git a/registration-processor/registration-processor-info-storage-service/pom.xml b/registration-processor/registration-processor-info-storage-service/pom.xml index d685569d4e3..70128f2b301 100644 --- a/registration-processor/registration-processor-info-storage-service/pom.xml +++ b/registration-processor/registration-processor-info-storage-service/pom.xml @@ -1,143 +1,147 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - registration-processor-info-storage-service - 1.2.1-SNAPSHOT - registration-processor-info-storage-service - - UTF-8 - - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.postgresql - postgresql - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - junit - junit - test - - - com.h2database - h2 - - - io.mosip.kernel - kernel-dataaccess-hibernate - ${kernel.dataaccess.hibernate.version} - - - io.mosip.kernel - kernel-keymanager-service - ${kernel-keymanager-service.version} - - - org.springframework.security - spring-security-config - - - lib - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - commons-codec - commons-codec - - - - com.googlecode.json-simple - json-simple - - - org.projectlombok - lombok - compile - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-biosdk-provider - ${kernel-biosdk-provider.version} - - - + + + 4.0.0 + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-info-storage-service + 1.2.1-java21-SNAPSHOT + registration-processor-info-storage-service + + UTF-8 + + + + + org.mockito + mockito-core + ${mockito.version} + test + + + io.mosip.kernel + kernel-bom + 1.2.1-java21-SNAPSHOT + pom + import + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.postgresql + postgresql + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + junit + junit + test + + + com.h2database + h2 + + + io.mosip.kernel + kernel-dataaccess-hibernate + ${kernel.dataaccess.hibernate.version} + + + io.mosip.kernel + kernel-keymanager-service + ${kernel-keymanager-service.version} + + + org.springframework.security + spring-security-config + + + lib + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + commons-codec + commons-codec + + + + com.googlecode.json-simple + json-simple + + + org.projectlombok + lombok + compile + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-biosdk-provider + ${kernel-biosdk-provider.version} + + + diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java index 7e8cf408d72..6d645986262 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java @@ -1,130 +1,130 @@ -package io.mosip.registration.processor.packet.storage.config; - -import java.security.PrivateKey; -import java.security.PublicKey; -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.crypto.SecretKey; - -import io.mosip.registration.processor.packet.storage.helper.PacketManagerHelper; -import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.PropertySource; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -import io.mosip.kernel.core.crypto.spi.CryptoCoreSpec; -import io.mosip.kernel.crypto.jce.core.CryptoCore; -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; -import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; -import io.mosip.kernel.keygenerator.bouncycastle.KeyGenerator; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.manager.idreposervice.impl.IdRepoServiceImpl; -import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; -import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; -import io.mosip.registration.processor.packet.storage.service.impl.PacketInfoManagerImpl; -import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; -import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; -import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; - -@Configuration -@PropertySource("classpath:bootstrap.properties") -@EnableConfigurationProperties -@Import({ HibernateDaoConfig.class }) -@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) -public class PacketStorageBeanConfig { - - @Bean - @ConfigurationProperties(prefix = "provider.packetreader") - public Map readerConfiguration() { - return new HashMap<>(); - } - - @Bean - @ConfigurationProperties(prefix = "packetmanager.provider") - public Map providerConfiguration() { - return new HashMap<>(); - } - - @Bean - @ConfigurationProperties(prefix = "provider.packetwriter") - public Map writerConfiguration() { - return new HashMap<>(); - } - - @PostConstruct - public void initialize() { - Utilities.initialize(readerConfiguration(), writerConfiguration()); - PriorityBasedPacketManagerService.initialize(providerConfiguration()); - } - - @Bean - public PacketInfoManager getPacketInfoManager() { - return new PacketInfoManagerImpl(); - } - - @Bean - public PacketInfoDao getPacketInfoDao() { - return new PacketInfoDao(); - } - - @Bean - public Utilities getUtilities() { - return new Utilities(); - } - - @Bean - public PacketManagerService packetManagerService() { - return new PacketManagerService(); - } - - @Bean - public ABISHandlerUtil getABISHandlerUtil() { - return new ABISHandlerUtil(); - } - - - @Bean - public BioSdkUtil getBioSdkUtil() { - return new BioSdkUtil(); - } - - - @Bean - public KeyGenerator getKeyGenerator() { - return new KeyGenerator(); - } - - @Bean - @Primary - public CryptoCoreSpec getEncryptor() { - return new CryptoCore(); - } - - @Bean - public IdRepoService getIdRepoService() { - return new IdRepoServiceImpl(); - } - - @Bean - public PacketManagerHelper packetManagerHelper() { - return new PacketManagerHelper(); - } - - @Bean - public IdSchemaUtil getIdSchemaUtil() { - return new IdSchemaUtil(); - } -} +package io.mosip.registration.processor.packet.storage.config; + +import java.security.PrivateKey; +import java.security.PublicKey; +import java.util.HashMap; +import java.util.Map; + +import jakarta.annotation.PostConstruct; +import javax.crypto.SecretKey; + +import io.mosip.registration.processor.packet.storage.helper.PacketManagerHelper; +import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.PropertySource; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +import io.mosip.kernel.core.crypto.spi.CryptoCoreSpec; +import io.mosip.kernel.crypto.jce.core.CryptoCore; +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; +import io.mosip.kernel.keygenerator.bouncycastle.KeyGenerator; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.manager.idreposervice.impl.IdRepoServiceImpl; +import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; +import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; +import io.mosip.registration.processor.packet.storage.service.impl.PacketInfoManagerImpl; +import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; +import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; +import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; + +@Configuration +@PropertySource("classpath:bootstrap.properties") +@EnableConfigurationProperties +@Import({ HibernateDaoConfig.class }) +@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) +public class PacketStorageBeanConfig { + + @Bean + @ConfigurationProperties(prefix = "provider.packetreader") + public Map readerConfiguration() { + return new HashMap<>(); + } + + @Bean + @ConfigurationProperties(prefix = "packetmanager.provider") + public Map providerConfiguration() { + return new HashMap<>(); + } + + @Bean + @ConfigurationProperties(prefix = "provider.packetwriter") + public Map writerConfiguration() { + return new HashMap<>(); + } + + @PostConstruct + public void initialize() { + Utilities.initialize(readerConfiguration(), writerConfiguration()); + PriorityBasedPacketManagerService.initialize(providerConfiguration()); + } + + @Bean + public PacketInfoManager getPacketInfoManager() { + return new PacketInfoManagerImpl(); + } + + @Bean + public PacketInfoDao getPacketInfoDao() { + return new PacketInfoDao(); + } + + @Bean + public Utilities getUtilities() { + return new Utilities(); + } + + @Bean + public PacketManagerService packetManagerService() { + return new PacketManagerService(); + } + + @Bean + public ABISHandlerUtil getABISHandlerUtil() { + return new ABISHandlerUtil(); + } + + + @Bean + public BioSdkUtil getBioSdkUtil() { + return new BioSdkUtil(); + } + + + @Bean + public KeyGenerator getKeyGenerator() { + return new KeyGenerator(); + } + + @Bean + @Primary + public CryptoCoreSpec getEncryptor() { + return new CryptoCore(); + } + + @Bean + public IdRepoService getIdRepoService() { + return new IdRepoServiceImpl(); + } + + @Bean + public PacketManagerHelper packetManagerHelper() { + return new PacketManagerHelper(); + } + + @Bean + public IdSchemaUtil getIdSchemaUtil() { + return new IdSchemaUtil(); + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java index 35f5c4d7e70..3fbce8cc8e6 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java @@ -1,364 +1,364 @@ -package io.mosip.registration.processor.packet.storage.utils; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.annotation.PostConstruct; - -import com.fasterxml.jackson.databind.SerializationFeature; -import io.mosip.registration.processor.core.packet.dto.packetmanager.TagRequestDto; -import io.mosip.registration.processor.core.packet.dto.packetmanager.TagResponseDto; -import io.mosip.registration.processor.packet.storage.exception.ObjectDoesnotExistsException; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.JsonUtils; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.http.RequestWrapper; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.packet.storage.dto.BiometricRequestDto; -import io.mosip.registration.processor.packet.storage.dto.DeleteTagRequestDTO; -import io.mosip.registration.processor.packet.storage.dto.DeleteTagResponseDTO; -import io.mosip.registration.processor.packet.storage.dto.Document; -import io.mosip.registration.processor.packet.storage.dto.DocumentDto; -import io.mosip.registration.processor.packet.storage.dto.FieldDto; -import io.mosip.registration.processor.packet.storage.dto.FieldDtos; -import io.mosip.registration.processor.packet.storage.dto.FieldResponseDto; -import io.mosip.registration.processor.packet.storage.dto.InfoDto; -import io.mosip.registration.processor.packet.storage.dto.InfoRequestDto; -import io.mosip.registration.processor.packet.storage.dto.InfoResponseDto; -import io.mosip.registration.processor.packet.storage.dto.UpdateTagRequestDto; -import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; - -@Component -public class PacketManagerService extends PriorityBasedPacketManagerService { - - private static Logger regProcLogger = RegProcessorLogger.getLogger(PacketManagerService.class); - private static final String ID = "mosip.commmons.packetmanager"; - private static final String VERSION = "v1"; - private static final String OBJECT_DOESNOT_EXISTS_ERROR_CODE = "KER-PUT-027"; - - @Autowired - private RegistrationProcessorRestClientService restApi; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private Utilities utilities; - - @PostConstruct - private void setObjectMapper() { - objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - } - - protected String getField(String id, String field, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - FieldDto fieldDto = new FieldDto(id, field, source, process, false); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_FIELD, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); - - String responseField = fieldResponseDto.getFields().get(field); - if (StringUtils.isNotEmpty(responseField) && responseField.equalsIgnoreCase("null")) - responseField = null; - return responseField; - } - - protected Map getFields(String id, List fields, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - FieldDtos fieldDto = new FieldDtos(id, fields, source, process, false); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_FIELDS, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); - - return fieldResponseDto.getFields(); - } - - protected Document getDocument(String id, String documentName, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - return getDocument(id, documentName, null, process); - } - - protected Document getDocument(String id, String documentName, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - DocumentDto fieldDto = new DocumentDto(id, documentName, source, process); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_DOCUMENT, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - Document document = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), Document.class); - - return document; - } - - protected ValidatePacketResponse validate(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - InfoDto fieldDto = new InfoDto(id, source, process, false); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_VALIDATE, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - ValidatePacketResponse validatePacketResponse = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), ValidatePacketResponse.class); - - return validatePacketResponse; - } - - protected List getAudits(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - - InfoDto fieldDto = new InfoDto(id, source, process, false); - List response = new ArrayList<>(); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper> responseObj = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_AUDITS, "", "", request, ResponseWrapper.class); - - if (responseObj.getErrors() != null && responseObj.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(responseObj)); - ErrorDTO errorDTO = responseObj.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - for (Object o : responseObj.getResponse()) { - FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(o), FieldResponseDto.class); - response.add(fieldResponseDto); - } - - return response; - } - - protected BiometricRecord getBiometrics(String id, String person, List modalities, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - - BiometricRequestDto fieldDto = new BiometricRequestDto(id, person, modalities, source, process, false); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_BIOMETRICS, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - if (response.getResponse() != null) { - BiometricRecord biometricRecord = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), BiometricRecord.class); - return biometricRecord; - } - return null; - - } - - protected Map getMetaInfo(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - InfoDto fieldDto = new InfoDto(id, source, process, false); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(fieldDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_METAINFO, "", "", request, ResponseWrapper.class); - - if (CollectionUtils.isNotEmpty(response.getErrors())) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); - - return fieldResponseDto.getFields(); - } - - protected InfoResponseDto info(String id) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - InfoRequestDto infoRequestDto = new InfoRequestDto(id); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(infoRequestDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_INFO, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - InfoResponseDto infoResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), InfoResponseDto.class); - - return infoResponseDto; - } - - public void addOrUpdateTags(String id, Map tags) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - UpdateTagRequestDto updateTagRequestDto = new UpdateTagRequestDto(id, tags); - - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(updateTagRequestDto); - ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_UPDATE_TAGS, "", "", request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - } - - @SuppressWarnings("unchecked") - public void deleteTags(String id, List tags) - throws ApisResourceAccessException, PacketManagerException, JsonProcessingException { - DeleteTagRequestDTO deleteTagREquestDto = new DeleteTagRequestDTO(id, tags); - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(deleteTagREquestDto); - ResponseWrapper response = (ResponseWrapper) restApi - .postApi(ApiName.PACKETMANAGER_DELETE_TAGS, "", "", - request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - id, JsonUtils.javaObjectToJsonString(response)); - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - - - } - - public Map getAllTags(String id) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - return getTags(id, null); - } - - public Map getTags(String id, List tagNames) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - TagRequestDto tagRequestDto = new TagRequestDto(id, tagNames); - RequestWrapper request = new RequestWrapper<>(); - request.setId(ID); - request.setVersion(VERSION); - request.setRequesttime(DateUtils.getUTCCurrentDateTime()); - request.setRequest(tagRequestDto); - ResponseWrapper response = (ResponseWrapper) restApi - .postApi(ApiName.PACKETMANAGER_GET_TAGS, "", "", - request, ResponseWrapper.class); - - if (response.getErrors() != null && response.getErrors().size() > 0) { - ErrorDTO error=response.getErrors().get(0); - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - id, JsonUtils.javaObjectToJsonString(response)); - //This error code will return if requested tag is not present ,so returning null for that - if(error.getErrorCode().equalsIgnoreCase("KER-PUT-024")) - return null; - else { - ErrorDTO errorDTO = response.getErrors().iterator().next(); - if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) - throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); - else - throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); - } - } - - TagResponseDto tagResponseDto = null; - if (response.getResponse() != null) { - tagResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), TagResponseDto.class); - - } - - return tagResponseDto != null ? tagResponseDto.getTags() : null; - } -} +package io.mosip.registration.processor.packet.storage.utils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import jakarta.annotation.PostConstruct; + +import com.fasterxml.jackson.databind.SerializationFeature; +import io.mosip.registration.processor.core.packet.dto.packetmanager.TagRequestDto; +import io.mosip.registration.processor.core.packet.dto.packetmanager.TagResponseDto; +import io.mosip.registration.processor.packet.storage.exception.ObjectDoesnotExistsException; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.JsonUtils; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.code.ApiName; +import io.mosip.registration.processor.core.common.rest.dto.ErrorDTO; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.http.RequestWrapper; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.packet.storage.dto.BiometricRequestDto; +import io.mosip.registration.processor.packet.storage.dto.DeleteTagRequestDTO; +import io.mosip.registration.processor.packet.storage.dto.DeleteTagResponseDTO; +import io.mosip.registration.processor.packet.storage.dto.Document; +import io.mosip.registration.processor.packet.storage.dto.DocumentDto; +import io.mosip.registration.processor.packet.storage.dto.FieldDto; +import io.mosip.registration.processor.packet.storage.dto.FieldDtos; +import io.mosip.registration.processor.packet.storage.dto.FieldResponseDto; +import io.mosip.registration.processor.packet.storage.dto.InfoDto; +import io.mosip.registration.processor.packet.storage.dto.InfoRequestDto; +import io.mosip.registration.processor.packet.storage.dto.InfoResponseDto; +import io.mosip.registration.processor.packet.storage.dto.UpdateTagRequestDto; +import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; + +@Component +public class PacketManagerService extends PriorityBasedPacketManagerService { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(PacketManagerService.class); + private static final String ID = "mosip.commmons.packetmanager"; + private static final String VERSION = "v1"; + private static final String OBJECT_DOESNOT_EXISTS_ERROR_CODE = "KER-PUT-027"; + + @Autowired + private RegistrationProcessorRestClientService restApi; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private Utilities utilities; + + @PostConstruct + private void setObjectMapper() { + objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + } + + protected String getField(String id, String field, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + FieldDto fieldDto = new FieldDto(id, field, source, process, false); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_FIELD, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); + + String responseField = fieldResponseDto.getFields().get(field); + if (StringUtils.isNotEmpty(responseField) && responseField.equalsIgnoreCase("null")) + responseField = null; + return responseField; + } + + protected Map getFields(String id, List fields, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + FieldDtos fieldDto = new FieldDtos(id, fields, source, process, false); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_FIELDS, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); + + return fieldResponseDto.getFields(); + } + + protected Document getDocument(String id, String documentName, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + return getDocument(id, documentName, null, process); + } + + protected Document getDocument(String id, String documentName, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + DocumentDto fieldDto = new DocumentDto(id, documentName, source, process); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_DOCUMENT, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + Document document = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), Document.class); + + return document; + } + + protected ValidatePacketResponse validate(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + InfoDto fieldDto = new InfoDto(id, source, process, false); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_VALIDATE, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + ValidatePacketResponse validatePacketResponse = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), ValidatePacketResponse.class); + + return validatePacketResponse; + } + + protected List getAudits(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + + InfoDto fieldDto = new InfoDto(id, source, process, false); + List response = new ArrayList<>(); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper> responseObj = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_AUDITS, "", "", request, ResponseWrapper.class); + + if (responseObj.getErrors() != null && responseObj.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(responseObj)); + ErrorDTO errorDTO = responseObj.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + for (Object o : responseObj.getResponse()) { + FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(o), FieldResponseDto.class); + response.add(fieldResponseDto); + } + + return response; + } + + protected BiometricRecord getBiometrics(String id, String person, List modalities, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + + BiometricRequestDto fieldDto = new BiometricRequestDto(id, person, modalities, source, process, false); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_BIOMETRICS, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + if (response.getResponse() != null) { + BiometricRecord biometricRecord = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), BiometricRecord.class); + return biometricRecord; + } + return null; + + } + + protected Map getMetaInfo(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + InfoDto fieldDto = new InfoDto(id, source, process, false); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(fieldDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_SEARCH_METAINFO, "", "", request, ResponseWrapper.class); + + if (CollectionUtils.isNotEmpty(response.getErrors())) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + FieldResponseDto fieldResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), FieldResponseDto.class); + + return fieldResponseDto.getFields(); + } + + protected InfoResponseDto info(String id) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + InfoRequestDto infoRequestDto = new InfoRequestDto(id); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(infoRequestDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_INFO, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + InfoResponseDto infoResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), InfoResponseDto.class); + + return infoResponseDto; + } + + public void addOrUpdateTags(String id, Map tags) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + UpdateTagRequestDto updateTagRequestDto = new UpdateTagRequestDto(id, tags); + + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(updateTagRequestDto); + ResponseWrapper response = (ResponseWrapper) restApi.postApi(ApiName.PACKETMANAGER_UPDATE_TAGS, "", "", request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + } + + @SuppressWarnings("unchecked") + public void deleteTags(String id, List tags) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException { + DeleteTagRequestDTO deleteTagREquestDto = new DeleteTagRequestDTO(id, tags); + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(deleteTagREquestDto); + ResponseWrapper response = (ResponseWrapper) restApi + .postApi(ApiName.PACKETMANAGER_DELETE_TAGS, "", "", + request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + id, JsonUtils.javaObjectToJsonString(response)); + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + + + } + + public Map getAllTags(String id) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + return getTags(id, null); + } + + public Map getTags(String id, List tagNames) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + TagRequestDto tagRequestDto = new TagRequestDto(id, tagNames); + RequestWrapper request = new RequestWrapper<>(); + request.setId(ID); + request.setVersion(VERSION); + request.setRequesttime(DateUtils.getUTCCurrentDateTime()); + request.setRequest(tagRequestDto); + ResponseWrapper response = (ResponseWrapper) restApi + .postApi(ApiName.PACKETMANAGER_GET_TAGS, "", "", + request, ResponseWrapper.class); + + if (response.getErrors() != null && response.getErrors().size() > 0) { + ErrorDTO error=response.getErrors().get(0); + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + id, JsonUtils.javaObjectToJsonString(response)); + //This error code will return if requested tag is not present ,so returning null for that + if(error.getErrorCode().equalsIgnoreCase("KER-PUT-024")) + return null; + else { + ErrorDTO errorDTO = response.getErrors().iterator().next(); + if (OBJECT_DOESNOT_EXISTS_ERROR_CODE.equalsIgnoreCase(errorDTO.getErrorCode())) + throw new ObjectDoesnotExistsException(errorDTO.getErrorCode(), errorDTO.getMessage()); + else + throw new PacketManagerException(errorDTO.getErrorCode(), errorDTO.getMessage()); + } + } + + TagResponseDto tagResponseDto = null; + if (response.getResponse() != null) { + tagResponseDto = objectMapper.readValue(JsonUtils.javaObjectToJsonString(response.getResponse()), TagResponseDto.class); + + } + + return tagResponseDto != null ? tagResponseDto.getTags() : null; + } +} diff --git a/registration-processor/registration-processor-landing-zone/Dockerfile b/registration-processor/registration-processor-landing-zone/Dockerfile index c772e7311ae..8347d87645d 100644 --- a/registration-processor/registration-processor-landing-zone/Dockerfile +++ b/registration-processor/registration-processor-landing-zone/Dockerfile @@ -1,93 +1,93 @@ -FROM openjdk:11 - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment management rmi server hostname -ARG management_rmi_server_hostname - -# can be passed during Docker build as build time environment management rmi server port -ARG management_jmxremote_rmi_port - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass iam_adapter url, at docker runtime -ENV iam_adapter_url_env=${iam_adapter_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -VOLUME /home/ftp1/ARCHIVE_PACKET_LOCATION /home/ftp1/LANDING_ZONE ${work_dir}/logs ${work_dir}/Glowroot - -ADD ./target/registration-processor-landing-zone-*.jar registration-processor-landing-zone.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$active_profile_env" = "preprod" ]; then \ - wget 'http://13.71.87.138:8040/artifactory/libs-release-local/io/mosip/testing/glowroot.zip' ; \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - #java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-registration-status-service/g' glowroot/glowroot.properties ; \ - java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+UseStringDeduplication -jar -javaagent:glowroot/glowroot.jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar; \ - fi - -#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","-javaagent:/home/Glowroot/glowroot.jar","registration-processor-landing-zone.jar"] +FROM eclipse-temurin:21-jre-alpine + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment management rmi server hostname +ARG management_rmi_server_hostname + +# can be passed during Docker build as build time environment management rmi server port +ARG management_jmxremote_rmi_port + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass iam_adapter url, at docker runtime +ENV iam_adapter_url_env=${iam_adapter_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +VOLUME /home/ftp1/ARCHIVE_PACKET_LOCATION /home/ftp1/LANDING_ZONE ${work_dir}/logs ${work_dir}/Glowroot + +ADD ./target/registration-processor-landing-zone-*.jar registration-processor-landing-zone.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$active_profile_env" = "preprod" ]; then \ + wget 'http://13.71.87.138:8040/artifactory/libs-release-local/io/mosip/testing/glowroot.zip' ; \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + #java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-registration-status-service/g' glowroot/glowroot.properties ; \ + java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+UseStringDeduplication -jar -javaagent:glowroot/glowroot.jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-landing-zone.jar; \ + fi + +#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","-javaagent:/home/Glowroot/glowroot.jar","registration-processor-landing-zone.jar"] diff --git a/registration-processor/registration-processor-landing-zone/pom.xml b/registration-processor/registration-processor-landing-zone/pom.xml index 3c047eae2fa..96db5a61a80 100644 --- a/registration-processor/registration-processor-landing-zone/pom.xml +++ b/registration-processor/registration-processor-landing-zone/pom.xml @@ -1,94 +1,92 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - registration-processor-landing-zone - registration-processor-landing-zone - 1.2.1-SNAPSHOT - - UTF-8 - - - - - org.springframework.boot - spring-boot-starter - - - io.mosip.commons - khazana - ${object.store.khazana.version} - - - org.springframework.boot - spring-boot-starter-test - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.postgresql - postgresql - runtime - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - org.mockito - mockito-core - ${mockito.version} - test - - - junit - junit - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - - build-info - repackage - - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-landing-zone + registration-processor-landing-zone + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + + + org.springframework.boot + spring-boot-starter + + + io.mosip.commons + khazana + ${object.store.khazana.version} + + + org.springframework.boot + spring-boot-starter-test + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.postgresql + postgresql + runtime + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + org.mockito + mockito-core + ${mockito.version} + test + + + junit + junit + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + + build-info + repackage + + + + + + + + diff --git a/registration-processor/registration-processor-message-sender-impl/pom.xml b/registration-processor/registration-processor-message-sender-impl/pom.xml index 60c684321f5..0cd8a7cc5e4 100644 --- a/registration-processor/registration-processor-message-sender-impl/pom.xml +++ b/registration-processor/registration-processor-message-sender-impl/pom.xml @@ -1,100 +1,98 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - registration-processor-message-sender-impl - 1.2.1-SNAPSHOT - - - UTF-8 - UTF-8 - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - junit - junit - test - - - org.springframework.boot - spring-boot-starter-web - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-templatemanager-velocity - ${kernel.templatemanager.velocity.version} - - - org.apache.velocity - velocity - ${velocity.version} - - - org.apache.velocity - velocity-tools - ${velocity.tools.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-message-sender-impl + 1.2.1-java21-SNAPSHOT + + + UTF-8 + UTF-8 + + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + 1.4.195 + + + + + + junit + junit + test + + + org.springframework.boot + spring-boot-starter-web + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-templatemanager-velocity + ${kernel.templatemanager.velocity.version} + + + org.apache.velocity + velocity + ${velocity.version} + + + org.apache.velocity + velocity-tools + ${velocity.tools.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + diff --git a/registration-processor/registration-processor-notification-service/Dockerfile b/registration-processor/registration-processor-notification-service/Dockerfile index 9694f894d19..319bb75507a 100644 --- a/registration-processor/registration-processor-notification-service/Dockerfile +++ b/registration-processor/registration-processor-notification-service/Dockerfile @@ -1,102 +1,102 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# environment variable to pass iam_adapter url, at docker runtime -ENV iam_adapter_url_env=${iam_adapter_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -VOLUME ${work_dir}/logs ${work_dir}/Glowroot - -ADD ./target/registration-processor-notification-service-*.jar registration-processor-notification-service.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - #java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-notification-service/g' glowroot/glowroot.properties ; \ - java -jar -javaagent:glowroot/glowroot.jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar; \ - fi - -#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-notification-service.jar"] - +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# environment variable to pass iam_adapter url, at docker runtime +ENV iam_adapter_url_env=${iam_adapter_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +VOLUME ${work_dir}/logs ${work_dir}/Glowroot + +ADD ./target/registration-processor-notification-service-*.jar registration-processor-notification-service.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + #java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-notification-service/g' glowroot/glowroot.properties ; \ + java -jar -javaagent:glowroot/glowroot.jar -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" registration-processor-notification-service.jar; \ + fi + +#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-notification-service.jar"] + diff --git a/registration-processor/registration-processor-notification-service/pom.xml b/registration-processor/registration-processor-notification-service/pom.xml index 41b181f89da..18510c96c9e 100644 --- a/registration-processor/registration-processor-notification-service/pom.xml +++ b/registration-processor/registration-processor-notification-service/pom.xml @@ -1,134 +1,130 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - registration-processor-notification-service - 1.2.1-SNAPSHOT - - UTF-8 - UTF-8 - 1.2.1-SNAPSHOT - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - ${h2.version} - - - - - - org.springframework - spring-context - ${spring-framework.version} - - - org.springframework - spring-tx - ${spring-framework.version} - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.springframework.boot - - spring-boot-starter-security - - - - - - - io.mosip.registrationprocessor - registration-processor-message-sender-impl - ${registration.processor.message.sender.version} - - - org.springframework.boot - - spring-boot-starter-security - - - - org.springframework.security - spring-security-test - - - - - junit - junit - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - io.mosip.registrationprocessor - registration-processor-packet-manager - ${packet.manager.version} - - - io.mosip.kernel - kernel-websubclient-api - ${kernel.websubclient.api.version} - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-notification-service + 1.2.1-java21-SNAPSHOT + + UTF-8 + UTF-8 + 1.2.1-java21-SNAPSHOT + + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + ${h2.version} + + + + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.springframework.boot + + spring-boot-starter-security + + + + + + + io.mosip.registrationprocessor + registration-processor-message-sender-impl + ${registration.processor.message.sender.version} + + + org.springframework.boot + + spring-boot-starter-security + + + + org.springframework.security + spring-security-test + + + + + junit + junit + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + io.mosip.registrationprocessor + registration-processor-packet-manager + ${packet.manager.version} + + + io.mosip.kernel + kernel-websubclient-api + ${kernel.websubclient.api.version} + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/registration-processor-notification-service/src/test/java/io/mosip/registration/processor/notification/controller/NotificationControllerTest.java b/registration-processor/registration-processor-notification-service/src/test/java/io/mosip/registration/processor/notification/controller/NotificationControllerTest.java index 664f51f22fd..b61b5b98de6 100644 --- a/registration-processor/registration-processor-notification-service/src/test/java/io/mosip/registration/processor/notification/controller/NotificationControllerTest.java +++ b/registration-processor/registration-processor-notification-service/src/test/java/io/mosip/registration/processor/notification/controller/NotificationControllerTest.java @@ -1,88 +1,85 @@ -/* -package io.mosip.registration.processor.notification.controller; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import javax.servlet.http.Cookie; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.workflow.dto.WorkflowCompletedEventDTO; -import io.mosip.registration.processor.core.workflow.dto.WorkflowPausedForAdditionalInfoEventDTO; -import io.mosip.registration.processor.notification.service.NotificationService; - -@RunWith(SpringRunner.class) -@WebMvcTest(value = NotificationController.class) -public class NotificationControllerTest { - - @Autowired - private MockMvc mockMvc; - - @Autowired - private WebApplicationContext webApplicationContext; - - @InjectMocks - NotificationController notificationController = new NotificationController(); - - @MockBean - private NotificationService notificationService; - - Gson gson = new GsonBuilder().serializeNulls().create(); - WorkflowCompletedEventDTO notifyDto = new WorkflowCompletedEventDTO(); - WorkflowPausedForAdditionalInfoEventDTO pausedDto = new WorkflowPausedForAdditionalInfoEventDTO(); - - private String notifyDtoJson; - private String pausedDtoJson; - - @Before - public void setUp() throws JsonProcessingException, ApisResourceAccessException { - mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - notifyDtoJson = gson.toJson(notifyDto); - pausedDtoJson = gson.toJson(pausedDto); - } - - @Test - public void processNotify() throws Exception { - - ResponseEntity response = new ResponseEntity(HttpStatus.OK); - - Mockito.doReturn(response).when(notificationService).process(notifyDto); - this.mockMvc.perform(post("/callback/notify").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", notifyDtoJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(notifyDtoJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - - @Test - public void processNotifyPausedForAdditionalInfo() throws Exception { - - ResponseEntity response = new ResponseEntity(HttpStatus.OK); - - Mockito.doReturn(response).when(notificationService).process(pausedDto); - this.mockMvc.perform(post("/callback/notifyPausedForAdditionalInfo").accept(MediaType.APPLICATION_JSON_VALUE) - .cookie(new Cookie("Authorization", pausedDtoJson)).contentType(MediaType.APPLICATION_JSON_VALUE) - .content(pausedDtoJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isOk()); - } - -} -*/ +/* + * package io.mosip.registration.processor.notification.controller; + * + * import static + * org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; + * import static + * org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + * + * import jakarta.servlet.http.Cookie; + * + * import org.junit.Before; import org.junit.Test; import + * org.junit.runner.RunWith; import org.mockito.InjectMocks; import + * org.mockito.Mockito; import + * org.springframework.beans.factory.annotation.Autowired; import + * org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import + * org.springframework.boot.test.mock.mockito.MockBean; import + * org.springframework.http.HttpStatus; import + * org.springframework.http.MediaType; import + * org.springframework.http.ResponseEntity; import + * org.springframework.test.context.junit4.SpringRunner; import + * org.springframework.test.web.servlet.MockMvc; import + * org.springframework.test.web.servlet.setup.MockMvcBuilders; import + * org.springframework.web.context.WebApplicationContext; import + * com.fasterxml.jackson.core.JsonProcessingException; import + * com.google.gson.Gson; import com.google.gson.GsonBuilder; + * + * import + * io.mosip.registration.processor.core.exception.ApisResourceAccessException; + * import + * io.mosip.registration.processor.core.workflow.dto.WorkflowCompletedEventDTO; + * import io.mosip.registration.processor.core.workflow.dto. + * WorkflowPausedForAdditionalInfoEventDTO; import + * io.mosip.registration.processor.notification.service.NotificationService; + * + * @RunWith(SpringRunner.class) + * + * @WebMvcTest(value = NotificationController.class) public class + * NotificationControllerTest { + * + * @Autowired private MockMvc mockMvc; + * + * @Autowired private WebApplicationContext webApplicationContext; + * + * @InjectMocks NotificationController notificationController = new + * NotificationController(); + * + * @MockBean private NotificationService notificationService; + * + * Gson gson = new GsonBuilder().serializeNulls().create(); + * WorkflowCompletedEventDTO notifyDto = new WorkflowCompletedEventDTO(); + * WorkflowPausedForAdditionalInfoEventDTO pausedDto = new + * WorkflowPausedForAdditionalInfoEventDTO(); + * + * private String notifyDtoJson; private String pausedDtoJson; + * + * @Before public void setUp() throws JsonProcessingException, + * ApisResourceAccessException { mockMvc = + * MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); + * notifyDtoJson = gson.toJson(notifyDto); pausedDtoJson = + * gson.toJson(pausedDto); } + * + * @Test public void processNotify() throws Exception { + * + * ResponseEntity response = new ResponseEntity(HttpStatus.OK); + * + * Mockito.doReturn(response).when(notificationService).process(notifyDto); + * this.mockMvc.perform(post("/callback/notify").accept(MediaType. + * APPLICATION_JSON_VALUE) .cookie(new Cookie("Authorization", + * notifyDtoJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + * .content(notifyDtoJson.getBytes()).header("timestamp", + * "2019-05-07T05:13:55.704Z")) .andExpect(status().isOk()); } + * + * @Test public void processNotifyPausedForAdditionalInfo() throws Exception { + * + * ResponseEntity response = new ResponseEntity(HttpStatus.OK); + * + * Mockito.doReturn(response).when(notificationService).process(pausedDto); + * this.mockMvc.perform(post("/callback/notifyPausedForAdditionalInfo").accept( + * MediaType.APPLICATION_JSON_VALUE) .cookie(new Cookie("Authorization", + * pausedDtoJson)).contentType(MediaType.APPLICATION_JSON_VALUE) + * .content(pausedDtoJson.getBytes()).header("timestamp", + * "2019-05-07T05:13:55.704Z")) .andExpect(status().isOk()); } + * + * } + */ diff --git a/registration-processor/registration-processor-packet-manager/pom.xml b/registration-processor/registration-processor-packet-manager/pom.xml index f1eb4eaa5bb..a2a14f950ff 100644 --- a/registration-processor/registration-processor-packet-manager/pom.xml +++ b/registration-processor/registration-processor-packet-manager/pom.xml @@ -1,88 +1,86 @@ - - - 4.0.0 - jar - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - registration-processor-packet-manager - registration-processor-packet-manager - 1.2.1-SNAPSHOT - - UTF-8 - - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - commons-pool - commons-pool - ${commons.pool} - - - junit - junit - test - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - commons-io - commons-io - ${commons-io} - - - com.h2database - h2 - - - com.jcraft - jsch - ${jsch.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - + + + 4.0.0 + jar + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-packet-manager + registration-processor-packet-manager + 1.2.1-java21-SNAPSHOT + + UTF-8 + + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + commons-pool + commons-pool + ${commons.pool} + + + junit + junit + test + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + commons-io + commons-io + ${commons-io} + + + com.h2database + h2 + + + com.jcraft + jsch + ${jsch.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + diff --git a/registration-processor/registration-processor-packet-manager/src/main/java/io/mosip/registration/processor/packet/manager/dto/CryptomanagerRequestDto.java b/registration-processor/registration-processor-packet-manager/src/main/java/io/mosip/registration/processor/packet/manager/dto/CryptomanagerRequestDto.java index 3a5493179cf..0edcb1874a8 100644 --- a/registration-processor/registration-processor-packet-manager/src/main/java/io/mosip/registration/processor/packet/manager/dto/CryptomanagerRequestDto.java +++ b/registration-processor/registration-processor-packet-manager/src/main/java/io/mosip/registration/processor/packet/manager/dto/CryptomanagerRequestDto.java @@ -1,67 +1,67 @@ -package io.mosip.registration.processor.packet.manager.dto; - -import java.time.LocalDateTime; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import io.mosip.registration.processor.packet.manager.constant.CryptomanagerConstant; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * - * @author Girish Yarru - * - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@ApiModel(description = "Model representing a Crypto-Manager-Service Request") -public class CryptomanagerRequestDto { - /** - * Application id of decrypting module - */ - - @NotBlank(message = "should not be null or empty") - private String applicationId; - /** - * Refrence Id - */ - - private String referenceId; - /** - * Timestamp - */ - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - @NotNull - private LocalDateTime timeStamp; - /** - * Data in BASE64 encoding to encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String data; - - /** - * salt in BASE64 encoding for encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String salt; - - /** - * aad in BASE64 encoding for encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String aad; - - private Boolean prependThumbprint; -} +package io.mosip.registration.processor.packet.manager.dto; + +import java.time.LocalDateTime; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import io.mosip.registration.processor.packet.manager.constant.CryptomanagerConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * + * @author Girish Yarru + * + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(description = "Model representing a Crypto-Manager-Service Request") +public class CryptomanagerRequestDto { + /** + * Application id of decrypting module + */ + + @NotBlank(message = "should not be null or empty") + private String applicationId; + /** + * Refrence Id + */ + + private String referenceId; + /** + * Timestamp + */ + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @NotNull + private LocalDateTime timeStamp; + /** + * Data in BASE64 encoding to encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String data; + + /** + * salt in BASE64 encoding for encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String salt; + + /** + * aad in BASE64 encoding for encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String aad; + + private Boolean prependThumbprint; +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/pom.xml b/registration-processor/registration-processor-registration-status-service-impl/pom.xml index 8f210c1ef9c..117f3ada416 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/pom.xml +++ b/registration-processor/registration-processor-registration-status-service-impl/pom.xml @@ -1,111 +1,108 @@ - - - 4.0.0 - jar - - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - registration-processor-registration-status-service-impl - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - org.mockito - mockito-core - ${mockito.version} - test - - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.springframework.boot - spring-boot-starter-test - - - org.springframework.boot - spring-boot-starter-data-jpa - - - joda-time - joda-time - ${jodatime.version} - - - org.postgresql - postgresql - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - - junit - junit - test - - - io.mosip.kernel - kernel-core - ${kernel.core.version} - - - io.mosip.kernel - kernel-idvalidator-rid - ${kernel.idvalidator.rid.version} - - - com.h2database - h2 - - - io.mosip.kernel - kernel-dataaccess-hibernate - ${kernel.dataaccess.hibernate.version} - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - io.mosip.registrationprocessor - registration-processor-rest-client - ${registration.processor.rest.client.version} - - - org.powermock - powermock-module-junit4 - ${powermock.module.junit4.version} - test - - - org.powermock - powermock-api-mockito2 - ${powermock.api.mockito.version} - test - - - + + + 4.0.0 + jar + + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + registration-processor-registration-status-service-impl + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-data-jpa + + + joda-time + joda-time + ${jodatime.version} + + + org.postgresql + postgresql + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + + junit + junit + test + + + io.mosip.kernel + kernel-core + ${kernel.core.version} + + + io.mosip.kernel + kernel-idvalidator-rid + ${kernel.idvalidator.rid.version} + + + com.h2database + h2 + + + io.mosip.kernel + kernel-dataaccess-hibernate + ${kernel.dataaccess.hibernate.version} + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + io.mosip.registrationprocessor + registration-processor-rest-client + ${registration.processor.rest.client.version} + + + org.powermock + powermock-module-junit4 + test + + + org.powermock + powermock-api-mockito2 + test + + + diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/CryptomanagerRequestDto.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/CryptomanagerRequestDto.java index e394d551a3c..fd7848c4275 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/CryptomanagerRequestDto.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/CryptomanagerRequestDto.java @@ -1,67 +1,67 @@ -package io.mosip.registration.processor.status.dto; - -import java.time.LocalDateTime; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import io.mosip.registration.processor.status.constants.CryptomanagerConstant; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * - * @author Girish Yarru - * - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@ApiModel(description = "Model representing a Crypto-Manager-Service Request") -public class CryptomanagerRequestDto { - /** - * Application id of decrypting module - */ - - @NotBlank(message = "should not be null or empty") - private String applicationId; - /** - * Refrence Id - */ - - private String referenceId; - /** - * Timestamp - */ - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - @NotNull - private LocalDateTime timeStamp; - /** - * Data in BASE64 encoding to encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String data; - - /** - * salt in BASE64 encoding for encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String salt; - - /** - * aad in BASE64 encoding for encrypt/decrypt - */ - - @NotBlank(message = "should not be null or empty") - private String aad; - - private Boolean prependThumbprint; -} +package io.mosip.registration.processor.status.dto; + +import java.time.LocalDateTime; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import io.mosip.registration.processor.status.constants.CryptomanagerConstant; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * + * @author Girish Yarru + * + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(description = "Model representing a Crypto-Manager-Service Request") +public class CryptomanagerRequestDto { + /** + * Application id of decrypting module + */ + + @NotBlank(message = "should not be null or empty") + private String applicationId; + /** + * Refrence Id + */ + + private String referenceId; + /** + * Timestamp + */ + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + @NotNull + private LocalDateTime timeStamp; + /** + * Data in BASE64 encoding to encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String data; + + /** + * salt in BASE64 encoding for encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String salt; + + /** + * aad in BASE64 encoding for encrypt/decrypt + */ + + @NotBlank(message = "should not be null or empty") + private String aad; + + private Boolean prependThumbprint; +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/SearchInfo.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/SearchInfo.java index 6e5e65de914..d60e7ab0f01 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/SearchInfo.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/dto/SearchInfo.java @@ -1,30 +1,30 @@ -package io.mosip.registration.processor.status.dto; - -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import io.mosip.registration.processor.core.workflow.dto.SortInfo; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * - * @author Dhanendra - * - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SearchInfo { - - @NotNull - @Valid - private List filters; - - @NotNull - private List sort; - -} +package io.mosip.registration.processor.status.dto; + +import java.util.List; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import io.mosip.registration.processor.core.workflow.dto.SortInfo; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * + * @author Dhanendra + * + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SearchInfo { + + @NotNull + @Valid + private List filters; + + @NotNull + private List sort; + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/LostRidRequestValidator.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/LostRidRequestValidator.java index e06c459d3a4..c738392ff8d 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/LostRidRequestValidator.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/LostRidRequestValidator.java @@ -1,245 +1,247 @@ -package io.mosip.registration.processor.status.validator; - -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; -import java.util.List; -import java.util.Objects; -import java.util.TimeZone; - -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; -import org.springframework.stereotype.Component; - -import com.hazelcast.util.StringUtil; - -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.WorkFlowSearchException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.workflow.dto.SortInfo; -import io.mosip.registration.processor.status.dto.FilterInfo; -import io.mosip.registration.processor.status.dto.LostRidRequestDto; -import io.mosip.registration.processor.status.exception.LostRidValidationException; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.exception.RegStatusValidationException; - -@Component -public class LostRidRequestValidator { - - /** The Constant DATETIME_TIMEZONE. */ - private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; - - /** The Constant DATETIME_PATTERN. */ - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - - /** The mosip logger. */ - Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationStatusRequestValidator.class); - - /** The Constant REG_STATUS_SERVICE. */ - private static final String REG_STATUS_SERVICE = "RegStatusService"; - - @Value("${mosip.registration.processor.lostrid.max-registration-date-filter-interval:30}") - private int maxRegistrationDateFilterInterval; - - /** The Constant REG_STATUS_APPLICATION_VERSION. */ - private static final String REG_LOSTRID_APPLICATION_VERSION = "mosip.registration.processor.lostrid.version"; - - private static final String REG_LOSTRID_SERVICE_ID = "mosip.registration.processor.lostrid.id"; - - /** The env. */ - @Autowired - private Environment env; - - /** The grace period. */ - @Value("${mosip.registration.processor.grace.period}") - private int gracePeriod; - - /** The registrationDate pattern. */ - @Value("${mosip.registration.processor.lostrid.registrationdate.pattern}") - private String regDatePattern; - - - /** - * Validate. - * - * @param registrationStatusRequestDTO the registration status request DTO - * @param serviceId the service id - * @throws RegStatusAppException the reg status app exception - */ - public void validate(LostRidRequestDto lostRidRequestDto) - throws RegStatusAppException, WorkFlowSearchException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "LostRidRequestValidator::validate()::entry"); - - validateId(lostRidRequestDto.getId()); - validateVersion(lostRidRequestDto.getVersion()); - validateReqTime(lostRidRequestDto.getRequesttime()); - validateFilter(lostRidRequestDto.getRequest().getFilters()); - validateSortField(lostRidRequestDto.getRequest().getSort()); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "LostRidRequestValidator::validate()::exit"); - - } - - /** - * Validate id. - * - * @param id the id - * @throws RegStatusAppException the reg status app exception - */ - private void validateId(String id) throws RegStatusAppException { - LostRidValidationException exception = new LostRidValidationException(); - String lostRidService=env.getProperty(REG_LOSTRID_SERVICE_ID); - if (Objects.isNull(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); - - } else if (lostRidService!=null && !lostRidService.equals(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); - - } - } - - - /** - * Validate filter. - * - * @param version the version - * @param errors the errors - * @return true, if successful - * @throws RegStatusAppException - * - */ - private void validateFilter(List filterInfos) throws WorkFlowSearchException, RegStatusAppException { - LostRidValidationException exception = new LostRidValidationException(); - if (Objects.isNull(filterInfos)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); - } - for (FilterInfo filter : filterInfos) { - if (filter.getColumnName().equals("name") || filter.getColumnName().equals("email") - || filter.getColumnName().equals("phone") || filter.getColumnName().equals("centerId") - || filter.getColumnName().equals("locationCode")||filter.getColumnName().equals("registrationDate")) { - validateFilterType(filter); - } else { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); - } - } - - } - - /** - * Validate filter type. - * - * @param version the version - * @param errors the errors - * @return true, if successful - * @throws RegStatusAppException - * - */ - private void validateFilterType(FilterInfo filter) - throws WorkFlowSearchException, RegStatusAppException { - LostRidValidationException exception = new LostRidValidationException(); - if (filter.getColumnName().equals("registrationDate") && filter.getType().equalsIgnoreCase("between")) { - DateTimeFormatter dtf = DateTimeFormatter.ofPattern(regDatePattern); - LocalDate dateForm = LocalDate.parse(filter.getFromValue(), dtf); - LocalDate dateTo = LocalDate.parse(filter.getToValue(), dtf); - long noOfDaysBetween = ChronoUnit.DAYS.between(dateForm, dateTo); - if (noOfDaysBetween > maxRegistrationDateFilterInterval) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATE_VALIDATION_FAILED, exception); - } - } else if (!filter.getType().equalsIgnoreCase("equals")) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); - } - - } - - /** - * Validate ver. - * - * @param ver the ver - * @throws RegStatusAppException the reg status app exception - */ - private void validateVersion(String ver) throws RegStatusAppException { - String version = env.getProperty(REG_LOSTRID_APPLICATION_VERSION); - LostRidValidationException exception = new LostRidValidationException(); - if (Objects.isNull(ver)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); - - } else if (version!=null && !version.equals(ver)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); - } - } - - /** - * Validate sortInfo. - * - * @param version the version - * @param errors the errors - * @return true, if successful - * @throws RegStatusAppException - */ - private void validateSortField(List sortInfos) throws WorkFlowSearchException, RegStatusAppException { - LostRidValidationException exception = new LostRidValidationException(); - if (sortInfos.size() > 1) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_SORTING_VALIDATION_FAILED, exception); - } else if (sortInfos.get(0).getSortField().equals("name") || sortInfos.get(0).getSortField().equals("email") - || sortInfos.get(0).getSortField().equals("phone") || sortInfos.get(0).getSortField().equals("centerId") - || sortInfos.get(0).getSortField().equals("registrationDate") - || sortInfos.get(0).getSortField().equals("locationCode")) { - - } else { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); - - } - - } - - - /** - * Validate req time. - * - * @param timestamp the timestamp - * @throws RegStatusAppException the reg status app exception - */ - private void validateReqTime(String timestamp) throws RegStatusAppException { - RegStatusValidationException exception = new RegStatusValidationException(); - - if (Objects.isNull(timestamp)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); - - } else { - try { - if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { - DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( - env.getProperty(DATETIME_PATTERN)); - timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { - regProcLogger.error(REG_STATUS_SERVICE, "LostRidRequestValidator", "validateReqTime", - "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - - } - } catch (IllegalArgumentException e) { - regProcLogger.error(REG_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", - "\n" + ExceptionUtils.getStackTrace(e)); - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - } - } +package io.mosip.registration.processor.status.validator; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.List; +import java.util.Objects; +import java.util.TimeZone; + +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.WorkFlowSearchException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.workflow.dto.SortInfo; +import io.mosip.registration.processor.status.dto.FilterInfo; +import io.mosip.registration.processor.status.dto.LostRidRequestDto; +import io.mosip.registration.processor.status.exception.LostRidValidationException; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.exception.RegStatusValidationException; + +@Component +public class LostRidRequestValidator { + + /** The Constant DATETIME_TIMEZONE. */ + private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; + + /** The Constant DATETIME_PATTERN. */ + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + + /** The mosip logger. */ + Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationStatusRequestValidator.class); + + /** The Constant REG_STATUS_SERVICE. */ + private static final String REG_STATUS_SERVICE = "RegStatusService"; + + @Value("${mosip.registration.processor.lostrid.max-registration-date-filter-interval:30}") + private int maxRegistrationDateFilterInterval; + + /** The Constant REG_STATUS_APPLICATION_VERSION. */ + private static final String REG_LOSTRID_APPLICATION_VERSION = "mosip.registration.processor.lostrid.version"; + + private static final String REG_LOSTRID_SERVICE_ID = "mosip.registration.processor.lostrid.id"; + + /** The env. */ + @Autowired + private Environment env; + + /** The grace period. */ + @Value("${mosip.registration.processor.grace.period}") + private int gracePeriod; + + /** The registrationDate pattern. */ + @Value("${mosip.registration.processor.lostrid.registrationdate.pattern}") + private String regDatePattern; + + + /** + * Validate. + * + * @param registrationStatusRequestDTO the registration status request DTO + * @param serviceId the service id + * @throws RegStatusAppException the reg status app exception + */ + public void validate(LostRidRequestDto lostRidRequestDto) + throws RegStatusAppException, WorkFlowSearchException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "LostRidRequestValidator::validate()::entry"); + + validateId(lostRidRequestDto.getId()); + validateVersion(lostRidRequestDto.getVersion()); + validateReqTime(lostRidRequestDto.getRequesttime()); + validateFilter(lostRidRequestDto.getRequest().getFilters()); + validateSortField(lostRidRequestDto.getRequest().getSort()); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "LostRidRequestValidator::validate()::exit"); + + } + + /** + * Validate id. + * + * @param id the id + * @throws RegStatusAppException the reg status app exception + */ + private void validateId(String id) throws RegStatusAppException { + LostRidValidationException exception = new LostRidValidationException(); + String lostRidService=env.getProperty(REG_LOSTRID_SERVICE_ID); + if (Objects.isNull(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); + + } else if (lostRidService!=null && !lostRidService.equals(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); + + } + } + + + /** + * Validate filter. + * + * @param version the version + * @param errors the errors + * @return true, if successful + * @throws RegStatusAppException + * + */ + private void validateFilter(List filterInfos) throws WorkFlowSearchException, RegStatusAppException { + LostRidValidationException exception = new LostRidValidationException(); + if (Objects.isNull(filterInfos)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); + } + for (FilterInfo filter : filterInfos) { + if (filter.getColumnName().equals("name") || filter.getColumnName().equals("email") + || filter.getColumnName().equals("phone") || filter.getColumnName().equals("centerId") + || filter.getColumnName().equals("locationCode")||filter.getColumnName().equals("registrationDate")) { + validateFilterType(filter); + } else { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); + } + } + + } + + /** + * Validate filter type. + * + * @param version the version + * @param errors the errors + * @return true, if successful + * @throws RegStatusAppException + * + */ + private void validateFilterType(FilterInfo filter) + throws WorkFlowSearchException, RegStatusAppException { + LostRidValidationException exception = new LostRidValidationException(); + if (filter.getColumnName().equals("registrationDate") && filter.getType().equalsIgnoreCase("between")) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern(regDatePattern); + LocalDate dateForm = LocalDate.parse(filter.getFromValue(), dtf); + LocalDate dateTo = LocalDate.parse(filter.getToValue(), dtf); + long noOfDaysBetween = ChronoUnit.DAYS.between(dateForm, dateTo); + if (noOfDaysBetween > maxRegistrationDateFilterInterval) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATE_VALIDATION_FAILED, exception); + } + } else if (!filter.getType().equalsIgnoreCase("equals")) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); + } + + } + + /** + * Validate ver. + * + * @param ver the ver + * @throws RegStatusAppException the reg status app exception + */ + private void validateVersion(String ver) throws RegStatusAppException { + String version = env.getProperty(REG_LOSTRID_APPLICATION_VERSION); + LostRidValidationException exception = new LostRidValidationException(); + if (Objects.isNull(ver)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); + + } else if (version!=null && !version.equals(ver)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); + } + } + + /** + * Validate sortInfo. + * + * @param version the version + * @param errors the errors + * @return true, if successful + * @throws RegStatusAppException + */ + private void validateSortField(List sortInfos) throws WorkFlowSearchException, RegStatusAppException { + LostRidValidationException exception = new LostRidValidationException(); + if (sortInfos.size() > 1) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_SORTING_VALIDATION_FAILED, exception); + } else if (sortInfos.get(0).getSortField().equals("name") || sortInfos.get(0).getSortField().equals("email") + || sortInfos.get(0).getSortField().equals("phone") || sortInfos.get(0).getSortField().equals("centerId") + || sortInfos.get(0).getSortField().equals("registrationDate") + || sortInfos.get(0).getSortField().equals("locationCode")) { + + } else { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER, exception); + + } + + } + + + /** + * Validate req time. + * + * @param timestamp the timestamp + * @throws RegStatusAppException the reg status app exception + */ + private void validateReqTime(String timestamp) throws RegStatusAppException { + RegStatusValidationException exception = new RegStatusValidationException(); + + if (Objects.isNull(timestamp)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); + + } else { + try { + if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { + DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( + env.getProperty(DATETIME_PATTERN)); + timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { + regProcLogger.error(REG_STATUS_SERVICE, "LostRidRequestValidator", "validateReqTime", + "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + + } + } catch (IllegalArgumentException e) { + regProcLogger.error(REG_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", + "\n" + ExceptionUtils.getStackTrace(e)); + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + } + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/PacketExternalStatusRequestValidator.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/PacketExternalStatusRequestValidator.java index f627f814ca2..a7a7a2f6970 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/PacketExternalStatusRequestValidator.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/PacketExternalStatusRequestValidator.java @@ -1,5 +1,7 @@ package io.mosip.registration.processor.status.validator; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -9,11 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; import org.springframework.stereotype.Component; import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; import io.mosip.registration.processor.core.constant.LoggerFileConstant; import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; import io.mosip.registration.processor.core.logger.RegProcessorLogger; @@ -127,10 +130,12 @@ private void validateReqTime(String timestamp) throws RegStatusAppException { DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( env.getProperty(DATETIME_PATTERN)); timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { regProcLogger.error(REG_STATUS_SERVICE, "PacketExternalStatusRequestValidator", "validateReqTime", "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationExternalStatusRequestValidator.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationExternalStatusRequestValidator.java index ec561684047..d897a90cd63 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationExternalStatusRequestValidator.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationExternalStatusRequestValidator.java @@ -1,166 +1,171 @@ -package io.mosip.registration.processor.status.validator; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.TimeZone; - -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; -import org.springframework.stereotype.Component; - -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.exception.RegStatusValidationException; - -/** - * The Class RegistrationExternalStatusRequestValidator. - * - * @author Satish Gohil - */ -@Component -public class RegistrationExternalStatusRequestValidator { - - /** The Constant DATETIME_TIMEZONE. */ - private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; - - /** The Constant DATETIME_PATTERN. */ - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - - /** The mosip logger. */ - Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationExternalStatusRequestValidator.class); - - /** The Constant REG_EXTERNAL_STATUS_SERVICE. */ - private static final String REG_EXTERNAL_STATUS_SERVICE = "RegExternalStatusService"; - - /** The Constant REG_EXTERNAL_STATUS_APPLICATION_VERSION. */ - private static final String REG_EXTERNAL_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.external.status.version"; - - /** The env. */ - @Autowired - private Environment env; - - - /** The grace period. */ - @Value("${mosip.registration.processor.grace.period}") - private int gracePeriod; - - /** The id. */ - private Map id = new HashMap<>(); - - /** - * Validate. - * - * @param registrationExternalStatusRequestDTO - * the registration external status request DTO - * @param serviceId - * the service id - * @throws RegStatusAppException - * the reg status app exception - */ - public void validate(RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO, String serviceId) - throws RegStatusAppException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RegistrationExternalStatusRequestValidator::validate()::entry"); - - id.put("status", serviceId); - validateId(registrationExternalStatusRequestDTO.getId()); - validateVersion(registrationExternalStatusRequestDTO.getVersion()); - validateReqTime(registrationExternalStatusRequestDTO.getRequesttime()); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RegistrationExternalStatusRequestValidator::validate()::exit"); - - } - - /** - * Validate id. - * - * @param id - * the id - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateId(String id) throws RegStatusAppException { - RegStatusValidationException exception = new RegStatusValidationException(); - - if (Objects.isNull(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); - } else if (!this.id.containsValue(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); - - } - } - - /** - * Validate ver. - * - * @param ver - * the ver - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateVersion(String ver) throws RegStatusAppException { - String version = env.getProperty(REG_EXTERNAL_STATUS_APPLICATION_VERSION); - RegStatusValidationException exception = new RegStatusValidationException(); - if (Objects.isNull(ver)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); - - } else if (version!=null && !version.equals(ver)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); - } - } - - /** - * Validate req time. - * - * @param timestamp - * the timestamp - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateReqTime(String timestamp) throws RegStatusAppException { - RegStatusValidationException exception = new RegStatusValidationException(); - - if (Objects.isNull(timestamp)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); - - } else { - try { - if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { - DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( - env.getProperty(DATETIME_PATTERN)); - timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { - regProcLogger.error(REG_EXTERNAL_STATUS_SERVICE, "RegistrationExternalStatusRequestValidator", "validateReqTime", - "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - - } - } catch (IllegalArgumentException e) { - regProcLogger.error(REG_EXTERNAL_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", - "\n" + ExceptionUtils.getStackTrace(e)); - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - } - } - -} +package io.mosip.registration.processor.status.validator; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.TimeZone; + +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.exception.RegStatusValidationException; + +/** + * The Class RegistrationExternalStatusRequestValidator. + * + * @author Satish Gohil + */ +@Component +public class RegistrationExternalStatusRequestValidator { + + /** The Constant DATETIME_TIMEZONE. */ + private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; + + /** The Constant DATETIME_PATTERN. */ + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + + /** The mosip logger. */ + Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationExternalStatusRequestValidator.class); + + /** The Constant REG_EXTERNAL_STATUS_SERVICE. */ + private static final String REG_EXTERNAL_STATUS_SERVICE = "RegExternalStatusService"; + + /** The Constant REG_EXTERNAL_STATUS_APPLICATION_VERSION. */ + private static final String REG_EXTERNAL_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.external.status.version"; + + /** The env. */ + @Autowired + private Environment env; + + + /** The grace period. */ + @Value("${mosip.registration.processor.grace.period}") + private int gracePeriod; + + /** The id. */ + private Map id = new HashMap<>(); + + /** + * Validate. + * + * @param registrationExternalStatusRequestDTO + * the registration external status request DTO + * @param serviceId + * the service id + * @throws RegStatusAppException + * the reg status app exception + */ + public void validate(RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO, String serviceId) + throws RegStatusAppException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RegistrationExternalStatusRequestValidator::validate()::entry"); + + id.put("status", serviceId); + validateId(registrationExternalStatusRequestDTO.getId()); + validateVersion(registrationExternalStatusRequestDTO.getVersion()); + validateReqTime(registrationExternalStatusRequestDTO.getRequesttime()); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RegistrationExternalStatusRequestValidator::validate()::exit"); + + } + + /** + * Validate id. + * + * @param id + * the id + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateId(String id) throws RegStatusAppException { + RegStatusValidationException exception = new RegStatusValidationException(); + + if (Objects.isNull(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); + } else if (!this.id.containsValue(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); + + } + } + + /** + * Validate ver. + * + * @param ver + * the ver + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateVersion(String ver) throws RegStatusAppException { + String version = env.getProperty(REG_EXTERNAL_STATUS_APPLICATION_VERSION); + RegStatusValidationException exception = new RegStatusValidationException(); + if (Objects.isNull(ver)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); + + } else if (version!=null && !version.equals(ver)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); + } + } + + /** + * Validate req time. + * + * @param timestamp + * the timestamp + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateReqTime(String timestamp) throws RegStatusAppException { + RegStatusValidationException exception = new RegStatusValidationException(); + + if (Objects.isNull(timestamp)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); + + } else { + try { + if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { + DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( + env.getProperty(DATETIME_PATTERN)); + timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { + regProcLogger.error(REG_EXTERNAL_STATUS_SERVICE, "RegistrationExternalStatusRequestValidator", "validateReqTime", + "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + + } + } catch (IllegalArgumentException e) { + regProcLogger.error(REG_EXTERNAL_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", + "\n" + ExceptionUtils.getStackTrace(e)); + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + } + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationStatusRequestValidator.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationStatusRequestValidator.java index b46323692cc..4c2c42522ee 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationStatusRequestValidator.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationStatusRequestValidator.java @@ -1,166 +1,171 @@ -package io.mosip.registration.processor.status.validator; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.TimeZone; - -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; -import org.springframework.stereotype.Component; - -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.exception.RegStatusValidationException; - -/** - * The Class RegistrationStatusRequestValidator. - * - * @author Rishabh Keshari - */ -@Component -public class RegistrationStatusRequestValidator { - - /** The Constant DATETIME_TIMEZONE. */ - private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; - - /** The Constant DATETIME_PATTERN. */ - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - - /** The mosip logger. */ - Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationStatusRequestValidator.class); - - /** The Constant REG_STATUS_SERVICE. */ - private static final String REG_STATUS_SERVICE = "RegStatusService"; - - /** The Constant REG_STATUS_APPLICATION_VERSION. */ - private static final String REG_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.status.version"; - - /** The env. */ - @Autowired - private Environment env; - - - /** The grace period. */ - @Value("${mosip.registration.processor.grace.period}") - private int gracePeriod; - - /** The id. */ - private Map id = new HashMap<>(); - - /** - * Validate. - * - * @param registrationStatusRequestDTO - * the registration status request DTO - * @param serviceId - * the service id - * @throws RegStatusAppException - * the reg status app exception - */ - public void validate(RegistrationStatusRequestDTO registrationStatusRequestDTO, String serviceId) - throws RegStatusAppException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RegistrationStatusRequestValidator::validate()::entry"); - - id.put("status", serviceId); - validateId(registrationStatusRequestDTO.getId()); - validateVersion(registrationStatusRequestDTO.getVersion()); - validateReqTime(registrationStatusRequestDTO.getRequesttime()); - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "RegistrationStatusRequestValidator::validate()::exit"); - - } - - /** - * Validate id. - * - * @param id - * the id - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateId(String id) throws RegStatusAppException { - RegStatusValidationException exception = new RegStatusValidationException(); - - if (Objects.isNull(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); - } else if (!this.id.containsValue(id)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); - - } - } - - /** - * Validate ver. - * - * @param ver - * the ver - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateVersion(String ver) throws RegStatusAppException { - String version = env.getProperty(REG_STATUS_APPLICATION_VERSION); - RegStatusValidationException exception = new RegStatusValidationException(); - if (Objects.isNull(ver)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); - - } else if (null!=version && !version.equals(ver)) { - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); - } - } - - /** - * Validate req time. - * - * @param timestamp - * the timestamp - * @throws RegStatusAppException - * the reg status app exception - */ - private void validateReqTime(String timestamp) throws RegStatusAppException { - RegStatusValidationException exception = new RegStatusValidationException(); - - if (Objects.isNull(timestamp)) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); - - } else { - try { - if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { - DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( - env.getProperty(DATETIME_PATTERN)); - timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { - regProcLogger.error(REG_STATUS_SERVICE, "RegistrationStatusRequestValidator", "validateReqTime", - "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); - - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - - } - } catch (IllegalArgumentException e) { - regProcLogger.error(REG_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", - "\n" + ExceptionUtils.getStackTrace(e)); - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, - exception); - } - } - } - -} +package io.mosip.registration.processor.status.validator; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.TimeZone; + +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.exception.RegStatusValidationException; + +/** + * The Class RegistrationStatusRequestValidator. + * + * @author Rishabh Keshari + */ +@Component +public class RegistrationStatusRequestValidator { + + /** The Constant DATETIME_TIMEZONE. */ + private static final String DATETIME_TIMEZONE = "mosip.registration.processor.timezone"; + + /** The Constant DATETIME_PATTERN. */ + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + + /** The mosip logger. */ + Logger regProcLogger = RegProcessorLogger.getLogger(RegistrationStatusRequestValidator.class); + + /** The Constant REG_STATUS_SERVICE. */ + private static final String REG_STATUS_SERVICE = "RegStatusService"; + + /** The Constant REG_STATUS_APPLICATION_VERSION. */ + private static final String REG_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.status.version"; + + /** The env. */ + @Autowired + private Environment env; + + + /** The grace period. */ + @Value("${mosip.registration.processor.grace.period}") + private int gracePeriod; + + /** The id. */ + private Map id = new HashMap<>(); + + /** + * Validate. + * + * @param registrationStatusRequestDTO + * the registration status request DTO + * @param serviceId + * the service id + * @throws RegStatusAppException + * the reg status app exception + */ + public void validate(RegistrationStatusRequestDTO registrationStatusRequestDTO, String serviceId) + throws RegStatusAppException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RegistrationStatusRequestValidator::validate()::entry"); + + id.put("status", serviceId); + validateId(registrationStatusRequestDTO.getId()); + validateVersion(registrationStatusRequestDTO.getVersion()); + validateReqTime(registrationStatusRequestDTO.getRequesttime()); + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "RegistrationStatusRequestValidator::validate()::exit"); + + } + + /** + * Validate id. + * + * @param id + * the id + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateId(String id) throws RegStatusAppException { + RegStatusValidationException exception = new RegStatusValidationException(); + + if (Objects.isNull(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_ID, exception); + } else if (!this.id.containsValue(id)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_ID, exception); + + } + } + + /** + * Validate ver. + * + * @param ver + * the ver + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateVersion(String ver) throws RegStatusAppException { + String version = env.getProperty(REG_STATUS_APPLICATION_VERSION); + RegStatusValidationException exception = new RegStatusValidationException(); + if (Objects.isNull(ver)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_VERSION, exception); + + } else if (null!=version && !version.equals(ver)) { + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_VERSION, exception); + } + } + + /** + * Validate req time. + * + * @param timestamp + * the timestamp + * @throws RegStatusAppException + * the reg status app exception + */ + private void validateReqTime(String timestamp) throws RegStatusAppException { + RegStatusValidationException exception = new RegStatusValidationException(); + + if (Objects.isNull(timestamp)) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_MISSING_INPUT_PARAMETER_TIMESTAMP, exception); + + } else { + try { + if (Objects.nonNull(env.getProperty(DATETIME_PATTERN))) { + DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( + env.getProperty(DATETIME_PATTERN)); + timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { + regProcLogger.error(REG_STATUS_SERVICE, "RegistrationStatusRequestValidator", "validateReqTime", + "\n" + PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP.getMessage()); + + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + + } + } catch (IllegalArgumentException e) { + regProcLogger.error(REG_STATUS_SERVICE, "IdRequestValidator", "validateReqTime", + "\n" + ExceptionUtils.getStackTrace(e)); + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_INPUT_PARAMETER_TIMESTAMP, + exception); + } + } + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationSyncRequestValidator.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationSyncRequestValidator.java index ec66f0179fd..42de8997dda 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationSyncRequestValidator.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/validator/RegistrationSyncRequestValidator.java @@ -1,5 +1,7 @@ package io.mosip.registration.processor.status.validator; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,11 +12,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; -import org.springframework.format.datetime.joda.DateTimeFormatterFactory; +import org.springframework.format.datetime.standard.DateTimeFormatterFactory; import org.springframework.stereotype.Component; import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; import io.mosip.registration.processor.core.constant.LoggerFileConstant; import io.mosip.registration.processor.core.constant.ResponseStatusCode; import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; @@ -196,10 +199,12 @@ private boolean validateReqTime(String timestamp, List syncResp DateTimeFormatterFactory timestampFormat = new DateTimeFormatterFactory( env.getProperty(DATETIME_PATTERN)); timestampFormat.setTimeZone(TimeZone.getTimeZone(env.getProperty(DATETIME_TIMEZONE))); - if (!(DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isAfter(new DateTime().minusSeconds(gracePeriod)) - && DateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) - .isBefore(new DateTime().plusSeconds(gracePeriod)))) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localDateTime = LocalDateTime.parse(timestamp, formatter); + if (!(localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isAfter(DateUtils.getUTCCurrentDateTime().minusSeconds(gracePeriod)) + && localDateTime.parse(timestamp, timestampFormat.createDateTimeFormatter()) + .isBefore(DateUtils.getUTCCurrentDateTime().plusSeconds(gracePeriod)))) { SyncResponseFailDto syncResponseFailureDto = new SyncResponseFailDto(); diff --git a/registration-processor/registration-processor-rest-client/pom.xml b/registration-processor/registration-processor-rest-client/pom.xml index fab11f50f6e..6228c7da0c8 100644 --- a/registration-processor/registration-processor-rest-client/pom.xml +++ b/registration-processor/registration-processor-rest-client/pom.xml @@ -1,77 +1,76 @@ - - - 4.0.0 - jar - - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - - registration-processor-rest-client - registration-processor-rest-client - 1.2.1-SNAPSHOT - - - UTF-8 - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.postgresql - postgresql - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - - junit - junit - test - - - - com.h2database - h2 - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - com.auth0 - java-jwt - 3.9.0 - - - + + + 4.0.0 + jar + + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + + registration-processor-rest-client + registration-processor-rest-client + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.postgresql + postgresql + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + + junit + junit + test + + + + com.h2database + h2 + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + com.auth0 + java-jwt + 3.9.0 + + + diff --git a/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/audit/dto/AuditRequestDto.java b/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/audit/dto/AuditRequestDto.java index bdf1a6110f4..217890ae508 100644 --- a/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/audit/dto/AuditRequestDto.java +++ b/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/audit/dto/AuditRequestDto.java @@ -1,7 +1,7 @@ package io.mosip.registration.processor.rest.client.audit.dto; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/utils/RestApiClient.java b/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/utils/RestApiClient.java index 177d44c140b..828321ba834 100644 --- a/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/utils/RestApiClient.java +++ b/registration-processor/registration-processor-rest-client/src/main/java/io/mosip/registration/processor/rest/client/utils/RestApiClient.java @@ -1,332 +1,338 @@ -package io.mosip.registration.processor.rest.client.utils; - -import java.io.IOException; -import java.net.URI; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.http.Header; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.client.RestTemplate; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.kernel.core.util.TokenHandlerUtil; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.tracing.ContextualData; -import io.mosip.registration.processor.core.tracing.TracingConstant; -import io.mosip.registration.processor.rest.client.audit.dto.Metadata; -import io.mosip.registration.processor.rest.client.audit.dto.SecretKeyRequest; -import io.mosip.registration.processor.rest.client.audit.dto.TokenRequestDTO; -import io.mosip.registration.processor.rest.client.exception.TokenGenerationFailedException; - -/** - * The Class RestApiClient. - * - * @author Rishabh Keshari - */ -@Component -public class RestApiClient { - - /** The logger. */ - private final Logger logger = RegProcessorLogger.getLogger(RestApiClient.class); - - /** The builder. */ - @Autowired - RestTemplateBuilder builder; - - @Autowired - Environment environment; - - private static final String AUTHORIZATION = "Authorization="; - - @Autowired - @Qualifier("selfTokenRestTemplate") - RestTemplate localRestTemplate; - - @Autowired - ObjectMapper objMp; - - /** - * Gets the api. * - * - * @param the generic type - * @param uri the get URI - * @param responseType the response type - * @return the api - * @throws Exception - */ - @SuppressWarnings("unchecked") - public T getApi(URI uri, Class responseType) throws Exception { - T result = null; - - try { - result = (T) localRestTemplate.exchange(uri, HttpMethod.GET, setRequestHeader(null, null), responseType) - .getBody(); - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - return result; - } - - /** - * Post api. - * - * @param the generic type - * @param uri the uri - * @param requestType the request type - * @param responseClass the response class - * @return the t - */ - @SuppressWarnings("unchecked") - public T postApi(String uri, MediaType mediaType, Object requestType, Class responseClass) throws Exception { - - T result = null; - try { - logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), uri); - result = (T) localRestTemplate.postForObject(uri, setRequestHeader(requestType, mediaType), responseClass); - - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - return result; - } - - /** - * Patch api. - * - * @param the generic type - * @param uri the uri - * @param requestType the request type - * @param responseClass the response class - * @return the t - */ - @SuppressWarnings("unchecked") - public T patchApi(String uri, MediaType mediaType, Object requestType, Class responseClass) - throws Exception { - - T result = null; - try { - logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), uri); - result = (T) localRestTemplate.patchForObject(uri, setRequestHeader(requestType, mediaType), responseClass); - - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - return result; - } - - public T patchApi(String uri, Object requestType, Class responseClass) throws Exception { - return patchApi(uri, null, requestType, responseClass); - } - - /** - * Put api. - * - * @param the generic type - * @param uri the uri - * @param requestType the request type - * @param responseClass the response class - * @param mediaType - * @return the t - * @throws Exception the exception - */ - @SuppressWarnings("unchecked") - public T putApi(String uri, Object requestType, Class responseClass, MediaType mediaType) throws Exception { - - T result = null; - ResponseEntity response = null; - try { - logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), uri); - - response = (ResponseEntity) localRestTemplate.exchange(uri, HttpMethod.PUT, - setRequestHeader(requestType, mediaType), responseClass); - result = response.getBody(); - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - return result; - } - - public int headApi(URI uri) throws Exception { - try { - HttpStatus httpStatus = localRestTemplate - .exchange(uri, HttpMethod.HEAD, setRequestHeader(null, null), Object.class).getStatusCode(); - return httpStatus.value(); - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - } - - public RestTemplate getRestTemplate() { - return localRestTemplate; - } - - /** - * this method sets token to header of the request - * - * @param requestType - * @param mediaType - * @return - * @throws IOException - */ - @SuppressWarnings("unchecked") - private HttpEntity setRequestHeader(Object requestType, MediaType mediaType) throws IOException { - MultiValueMap headers = new LinkedMultiValueMap(); - // headers.add("Cookie", getToken()); - headers.add(TracingConstant.TRACE_HEADER, (String) ContextualData.getOrDefault(TracingConstant.TRACE_ID_KEY)); - if (mediaType != null) { - headers.add("Content-Type", mediaType.toString()); - } - if (requestType != null) { - try { - HttpEntity httpEntity = (HttpEntity) requestType; - HttpHeaders httpHeader = httpEntity.getHeaders(); - Iterator iterator = httpHeader.keySet().iterator(); - while (iterator.hasNext()) { - String key = iterator.next(); - List collection = httpHeader.get(key); - if ((collection != null && !collection.isEmpty()) - && !(headers.containsKey("Content-Type") && key.equalsIgnoreCase("Content-Type"))) - headers.add(key, collection.get(0)); - - } - return new HttpEntity(httpEntity.getBody(), headers); - } catch (ClassCastException e) { - return new HttpEntity(requestType, headers); - } - } else - return new HttpEntity(headers); - } - - /** - * This method gets the token for the user details present in config server. - * - * @return - * @throws IOException - */ - public String getToken() throws IOException { - String token = System.getProperty("token"); - boolean isValid = false; - - if (StringUtils.isNotEmpty(token)) { - - isValid = TokenHandlerUtil.isValidBearerToken(token, environment.getProperty("token.request.issuerUrl"), - environment.getProperty("token.request.clientId")); - - } - if (!isValid) { - TokenRequestDTO tokenRequestDTO = new TokenRequestDTO(); - tokenRequestDTO.setId(environment.getProperty("token.request.id")); - tokenRequestDTO.setMetadata(new Metadata()); - - tokenRequestDTO.setRequesttime(DateUtils.getUTCCurrentDateTimeString()); - // tokenRequestDTO.setRequest(setPasswordRequestDTO()); - tokenRequestDTO.setRequest(setSecretKeyRequestDTO()); - tokenRequestDTO.setVersion(environment.getProperty("token.request.version")); - - HttpClient httpClient = HttpClientBuilder.create().build(); - HttpPost post = new HttpPost(environment.getProperty("KEYBASEDTOKENAPI")); - try { - StringEntity postingString = new StringEntity(objMp.writeValueAsString(tokenRequestDTO)); - post.setEntity(postingString); - post.setHeader("Content-type", "application/json"); - post.setHeader(TracingConstant.TRACE_HEADER, - (String) ContextualData.getOrDefault(TracingConstant.TRACE_ID_KEY)); - HttpResponse response = httpClient.execute(post); - org.apache.http.HttpEntity entity = response.getEntity(); - String responseBody = EntityUtils.toString(entity, "UTF-8"); - Header[] cookie = response.getHeaders("Set-Cookie"); - if (cookie.length == 0) - throw new TokenGenerationFailedException(); - token = response.getHeaders("Set-Cookie")[0].getValue(); - System.setProperty("token", token.substring(14, token.indexOf(';'))); - return token.substring(0, token.indexOf(';')); - } catch (IOException e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - throw e; - } - } - return AUTHORIZATION + token; - } - - private SecretKeyRequest setSecretKeyRequestDTO() { - SecretKeyRequest request = new SecretKeyRequest(); - request.setAppId(environment.getProperty("token.request.appid")); - request.setClientId(environment.getProperty("token.request.clientId")); - request.setSecretKey(environment.getProperty("token.request.secretKey")); - return request; - } - - public void tokenExceptionHandler(Exception e) { - if (e instanceof HttpStatusCodeException) { - HttpStatusCodeException ex = (HttpStatusCodeException) e; - if (ex.getRawStatusCode() == 401) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), "Authentication failed. Resetting auth token."); - System.setProperty("token", ""); - } - } - } - - - public T deleteApi(URI uri, Class responseType) throws Exception { - T result = null; - - try { - result = (T) localRestTemplate.exchange(uri, HttpMethod.DELETE, setRequestHeader(null, null), responseType) - .getBody(); - } catch (Exception e) { - logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), - LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); - tokenExceptionHandler(e); - throw e; - } - return result; - } - - -} +package io.mosip.registration.processor.rest.client.utils; + +import java.io.IOException; +import java.net.URI; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.ParseException; +import org.apache.http.HttpResponse; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.impl.classic.*; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.HttpStatusCodeException; +import org.springframework.web.client.RestTemplate; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.kernel.core.util.TokenHandlerUtil; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.tracing.ContextualData; +import io.mosip.registration.processor.core.tracing.TracingConstant; +import io.mosip.registration.processor.rest.client.audit.dto.Metadata; +import io.mosip.registration.processor.rest.client.audit.dto.SecretKeyRequest; +import io.mosip.registration.processor.rest.client.audit.dto.TokenRequestDTO; +import io.mosip.registration.processor.rest.client.exception.TokenGenerationFailedException; + +/** + * The Class RestApiClient. + * + * @author Rishabh Keshari + */ +@Component +public class RestApiClient { + + /** The logger. */ + private final Logger logger = RegProcessorLogger.getLogger(RestApiClient.class); + + /** The builder. */ + @Autowired + RestTemplateBuilder builder; + + @Autowired + Environment environment; + + private static final String AUTHORIZATION = "Authorization="; + + @Autowired + @Qualifier("selfTokenRestTemplate") + RestTemplate localRestTemplate; + + @Autowired + ObjectMapper objMp; + + /** + * Gets the api. * + * + * @param the generic type + * @param uri the get URI + * @param responseType the response type + * @return the api + * @throws Exception + */ + @SuppressWarnings("unchecked") + public T getApi(URI uri, Class responseType) throws Exception { + T result = null; + + try { + result = (T) localRestTemplate.exchange(uri, HttpMethod.GET, setRequestHeader(null, null), responseType) + .getBody(); + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + return result; + } + + /** + * Post api. + * + * @param the generic type + * @param uri the uri + * @param requestType the request type + * @param responseClass the response class + * @return the t + */ + @SuppressWarnings("unchecked") + public T postApi(String uri, MediaType mediaType, Object requestType, Class responseClass) throws Exception { + + T result = null; + try { + logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), uri); + result = (T) localRestTemplate.postForObject(uri, setRequestHeader(requestType, mediaType), responseClass); + + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + return result; + } + + /** + * Patch api. + * + * @param the generic type + * @param uri the uri + * @param requestType the request type + * @param responseClass the response class + * @return the t + */ + @SuppressWarnings("unchecked") + public T patchApi(String uri, MediaType mediaType, Object requestType, Class responseClass) + throws Exception { + + T result = null; + try { + logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), uri); + result = (T) localRestTemplate.patchForObject(uri, setRequestHeader(requestType, mediaType), responseClass); + + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + return result; + } + + public T patchApi(String uri, Object requestType, Class responseClass) throws Exception { + return patchApi(uri, null, requestType, responseClass); + } + + /** + * Put api. + * + * @param the generic type + * @param uri the uri + * @param requestType the request type + * @param responseClass the response class + * @param mediaType + * @return the t + * @throws Exception the exception + */ + @SuppressWarnings("unchecked") + public T putApi(String uri, Object requestType, Class responseClass, MediaType mediaType) throws Exception { + + T result = null; + ResponseEntity response = null; + try { + logger.info(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), uri); + + response = (ResponseEntity) localRestTemplate.exchange(uri, HttpMethod.PUT, + setRequestHeader(requestType, mediaType), responseClass); + result = response.getBody(); + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + return result; + } + + public int headApi(URI uri) throws Exception { + try { + HttpStatusCode httpStatus = localRestTemplate + .exchange(uri, HttpMethod.HEAD, setRequestHeader(null, null), Object.class).getStatusCode(); + return httpStatus.value(); + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + } + + public RestTemplate getRestTemplate() { + return localRestTemplate; + } + + /** + * this method sets token to header of the request + * + * @param requestType + * @param mediaType + * @return + * @throws IOException + */ + @SuppressWarnings("unchecked") + private HttpEntity setRequestHeader(Object requestType, MediaType mediaType) throws IOException { + MultiValueMap headers = new LinkedMultiValueMap(); + // headers.add("Cookie", getToken()); + headers.add(TracingConstant.TRACE_HEADER, (String) ContextualData.getOrDefault(TracingConstant.TRACE_ID_KEY)); + if (mediaType != null) { + headers.add("Content-Type", mediaType.toString()); + } + if (requestType != null) { + try { + HttpEntity httpEntity = (HttpEntity) requestType; + HttpHeaders httpHeader = httpEntity.getHeaders(); + Iterator iterator = httpHeader.keySet().iterator(); + while (iterator.hasNext()) { + String key = iterator.next(); + List collection = httpHeader.get(key); + if ((collection != null && !collection.isEmpty()) + && !(headers.containsKey("Content-Type") && key.equalsIgnoreCase("Content-Type"))) + headers.add(key, collection.get(0)); + + } + return new HttpEntity(httpEntity.getBody(), headers); + } catch (ClassCastException e) { + return new HttpEntity(requestType, headers); + } + } else + return new HttpEntity(headers); + } + + /** + * This method gets the token for the user details present in config server. + * + * @return + * @throws IOException + * @throws ParseException + */ + public String getToken() throws IOException, ParseException { + String token = System.getProperty("token"); + boolean isValid = false; + + if (StringUtils.isNotEmpty(token)) { + + isValid = TokenHandlerUtil.isValidBearerToken(token, environment.getProperty("token.request.issuerUrl"), + environment.getProperty("token.request.clientId")); + + } + if (!isValid) { + TokenRequestDTO tokenRequestDTO = new TokenRequestDTO(); + tokenRequestDTO.setId(environment.getProperty("token.request.id")); + tokenRequestDTO.setMetadata(new Metadata()); + + tokenRequestDTO.setRequesttime(DateUtils.getUTCCurrentDateTimeString()); + // tokenRequestDTO.setRequest(setPasswordRequestDTO()); + tokenRequestDTO.setRequest(setSecretKeyRequestDTO()); + tokenRequestDTO.setVersion(environment.getProperty("token.request.version")); + + CloseableHttpClient httpClient = HttpClientBuilder.create().build(); + HttpPost post = new HttpPost(environment.getProperty("KEYBASEDTOKENAPI")); + try { + StringEntity postingString = new StringEntity(objMp.writeValueAsString(tokenRequestDTO)); + post.setEntity(postingString); + post.setHeader("Content-type", "application/json"); + post.setHeader(TracingConstant.TRACE_HEADER, + (String) ContextualData.getOrDefault(TracingConstant.TRACE_ID_KEY)); + CloseableHttpResponse response = httpClient.execute(post); + org.apache.hc.core5.http.HttpEntity entity = response.getEntity(); + String responseBody = EntityUtils.toString(entity, "UTF-8"); + Header[] cookie = response.getHeaders("Set-Cookie"); + if (cookie.length == 0) + throw new TokenGenerationFailedException(); + token = response.getHeaders("Set-Cookie")[0].getValue(); + System.setProperty("token", token.substring(14, token.indexOf(';'))); + return token.substring(0, token.indexOf(';')); + } catch (IOException e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + throw e; + } catch (ParseException e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + throw e; + } + } + return AUTHORIZATION + token; + } + + private SecretKeyRequest setSecretKeyRequestDTO() { + SecretKeyRequest request = new SecretKeyRequest(); + request.setAppId(environment.getProperty("token.request.appid")); + request.setClientId(environment.getProperty("token.request.clientId")); + request.setSecretKey(environment.getProperty("token.request.secretKey")); + return request; + } + + public void tokenExceptionHandler(Exception e) { + if (e instanceof HttpStatusCodeException) { + HttpStatusCodeException ex = (HttpStatusCodeException) e; + if (ex.getRawStatusCode() == 401) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), "Authentication failed. Resetting auth token."); + System.setProperty("token", ""); + } + } + } + + + public T deleteApi(URI uri, Class responseType) throws Exception { + T result = null; + + try { + result = (T) localRestTemplate.exchange(uri, HttpMethod.DELETE, setRequestHeader(null, null), responseType) + .getBody(); + } catch (Exception e) { + logger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.APPLICATIONID.toString(), + LoggerFileConstant.APPLICATIONID.toString(), e.getMessage() + ExceptionUtils.getStackTrace(e)); + tokenExceptionHandler(e); + throw e; + } + return result; + } + + +} diff --git a/registration-processor/stage-groups/pom.xml b/registration-processor/stage-groups/pom.xml index 861de95aacf..9a17963d2ca 100644 --- a/registration-processor/stage-groups/pom.xml +++ b/registration-processor/stage-groups/pom.xml @@ -1,27 +1,27 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - stage-groups - stage-groups - - UTF-8 - - - registration-processor-stage-group-1 - registration-processor-stage-group-2 - registration-processor-stage-group-3 - registration-processor-stage-group-4 - registration-processor-stage-group-5 - registration-processor-stage-group-6 - registration-processor-stage-group-7 - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + stage-groups + stage-groups + + UTF-8 + + + registration-processor-stage-group-1 + registration-processor-stage-group-2 + registration-processor-stage-group-3 + registration-processor-stage-group-4 + registration-processor-stage-group-5 + registration-processor-stage-group-6 + registration-processor-stage-group-7 + \ No newline at end of file diff --git a/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile index 2392ed16e5e..364743a5d24 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile @@ -1,104 +1,104 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -ARG regproc_jars - -ENV regproc_jars_env=${regproc_jars} - -# change volume to whichever storage directory you want to use for this container. -VOLUME /home/logs /home/ftp1/ARCHIVE_PACKET_LOCATION /home/ftp1/LANDING_ZONE - -ENV group_name=registration-processor-stage-group-1 - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - apt-get update && apt-get install -y unzip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +ARG regproc_jars + +ENV regproc_jars_env=${regproc_jars} + +# change volume to whichever storage directory you want to use for this container. +VOLUME /home/logs /home/ftp1/ARCHIVE_PACKET_LOCATION /home/ftp1/LANDING_ZONE + +ENV group_name=registration-processor-stage-group-1 + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + apt-get update && apk add -q unzip wget ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-1/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-1/pom.xml index 7a045af3a7d..a2db22541b5 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-1/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-1/pom.xml @@ -1,60 +1,60 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-1 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-packet-receiver-stage - 1.2.1-SNAPSHOT - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-1 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-packet-receiver-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index 0091f8f59c6..43ac5b6bf09 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -1,117 +1,117 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -#ARG bio_sdk_folder=mock/0.9 -ARG biosdk_zip_path - -ARG biosdk_local_dir=biosdk-client - -ENV biosdk_local_dir_name=${biosdk_local_dir} - -#ENV bio_sdk_folder_env=${bio_sdk_folder} -ENV biosdk_zip_file_path=${biosdk_zip_path} - -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -#VOLUME /home/logs - -ARG stage_group_name=registration-processor-stage-group-2 - -ENV group_name=${stage_group_name} - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -ADD configure_start.sh configure_start.sh - -RUN chmod +x configure_start.sh - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -ENTRYPOINT [ "./configure_start.sh" ] - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +#ARG bio_sdk_folder=mock/0.9 +ARG biosdk_zip_path + +ARG biosdk_local_dir=biosdk-client + +ENV biosdk_local_dir_name=${biosdk_local_dir} + +#ENV bio_sdk_folder_env=${bio_sdk_folder} +ENV biosdk_zip_file_path=${biosdk_zip_path} + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +#VOLUME /home/logs + +ARG stage_group_name=registration-processor-stage-group-2 + +ENV group_name=${stage_group_name} + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +ADD configure_start.sh configure_start.sh + +RUN chmod +x configure_start.sh + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +ENTRYPOINT [ "./configure_start.sh" ] + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-2/pom.xml index 0d9cbbd89cf..ca049eae818 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/pom.xml @@ -1,69 +1,69 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-2 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-quality-classifier-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-securezone-notification-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-message-sender-stage - 1.2.1-SNAPSHOT - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-2 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-quality-classifier-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-securezone-notification-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-message-sender-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile index 63ce6ebcb02..2a89cd90c80 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile @@ -1,97 +1,97 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -ENV group_name=registration-processor-stage-group-3 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -VOLUME ${work_dir}/logs - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +ENV group_name=registration-processor-stage-group-3 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +VOLUME ${work_dir}/logs + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-3/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-3/pom.xml index dd6a4eb0a7e..ab9aaa3ccb1 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-3/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-3/pom.xml @@ -1,75 +1,75 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-3 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-abis-handler-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-abis-middleware-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-bio-dedupe-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-manual-adjudication-stage - 1.2.1-SNAPSHOT - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-3 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-abis-handler-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-abis-middleware-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-bio-dedupe-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-manual-adjudication-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + \ No newline at end of file diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index c5c4874af79..7066c9d9f31 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -1,118 +1,118 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -#ARG bio_sdk_folder=mock/0.9 -ARG biosdk_zip_path - -ARG biosdk_local_dir=biosdk-client - -ENV biosdk_local_dir_name=${biosdk_local_dir} - -#ENV bio_sdk_folder_env=${bio_sdk_folder} -ENV biosdk_zip_file_path=${biosdk_zip_path} - -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -#VOLUME /home/logs - -ARG stage_group_name=registration-processor-stage-group-4 - -ENV group_name=${stage_group_name} - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -ADD configure_start.sh configure_start.sh - -RUN chmod +x configure_start.sh - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -ENTRYPOINT [ "./configure_start.sh" ] - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ -#apt-get update && apt-get install -y unzip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +#ARG bio_sdk_folder=mock/0.9 +ARG biosdk_zip_path + +ARG biosdk_local_dir=biosdk-client + +ENV biosdk_local_dir_name=${biosdk_local_dir} + +#ENV bio_sdk_folder_env=${bio_sdk_folder} +ENV biosdk_zip_file_path=${biosdk_zip_path} + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +#VOLUME /home/logs + +ARG stage_group_name=registration-processor-stage-group-4 + +ENV group_name=${stage_group_name} + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +ADD configure_start.sh configure_start.sh + +RUN chmod +x configure_start.sh + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +ENTRYPOINT [ "./configure_start.sh" ] + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ +#apt-get update && apk add -q unzip wget ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-4/pom.xml index f71e55388b1..243d8d7ee5b 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/pom.xml @@ -1,65 +1,65 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-4 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-biometric-authentication-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-demo-dedupe-stage - 1.2.1-SNAPSHOT - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-4 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-biometric-authentication-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-demo-dedupe-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + \ No newline at end of file diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile index eb3f172c3b5..4763acae982 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile @@ -1,117 +1,117 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -#ARG bio_sdk_folder=mock/0.9 -ARG biosdk_zip_path - -ARG biosdk_local_dir=biosdk-client - -ENV biosdk_local_dir_name=${biosdk_local_dir} - -#ENV bio_sdk_folder_env=${bio_sdk_folder} -ENV biosdk_zip_file_path=${biosdk_zip_path} - -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -# /home/logs - -ARG stage_group_name=registration-processor-stage-group-5 - -ENV group_name=${stage_group_name} - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -ADD configure_start.sh configure_start.sh - -RUN chmod +x configure_start.sh - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -ENTRYPOINT [ "./configure_start.sh" ] - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +#ARG bio_sdk_folder=mock/0.9 +ARG biosdk_zip_path + +ARG biosdk_local_dir=biosdk-client + +ENV biosdk_local_dir_name=${biosdk_local_dir} + +#ENV bio_sdk_folder_env=${bio_sdk_folder} +ENV biosdk_zip_file_path=${biosdk_zip_path} + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +# /home/logs + +ARG stage_group_name=registration-processor-stage-group-5 + +ENV group_name=${stage_group_name} + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +ADD configure_start.sh configure_start.sh + +RUN chmod +x configure_start.sh + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +ENTRYPOINT [ "./configure_start.sh" ] + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-5/pom.xml index a72645163dd..49b0eef4b19 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/pom.xml @@ -1,80 +1,80 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-5 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-cmd-validator-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-operator-validator-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-supervisor-validator-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-introducer-validator-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-packet-validator-stage - 1.2.1-SNAPSHOT - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-5 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-cmd-validator-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-operator-validator-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-supervisor-validator-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-introducer-validator-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-packet-validator-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile index 0e01e51babf..5783ca49093 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile @@ -1,104 +1,104 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# install packages and create user -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -ARG regproc_jars - -ENV regproc_jars_env=${regproc_jars} - -# change volume to whichever storage directory you want to use for this container. -VOLUME /home/logs - -ENV group_name=registration-processor-stage-group-6 - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# install packages and create user +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +ARG regproc_jars + +ENV regproc_jars_env=${regproc_jars} + +# change volume to whichever storage directory you want to use for this container. +VOLUME /home/logs + +ENV group_name=registration-processor-stage-group-6 + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget --no-parent "${artifactory_url_env}"/"${regproc_jars_env}" --directory-prefix "${loader_path_env}"/ ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-6/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-6/pom.xml index 1d3df4a5ee2..4d0f2b647a6 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-6/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-6/pom.xml @@ -1,68 +1,68 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-6 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-packet-uploader-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-packet-classifier-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-verification-stage - 1.2.1-SNAPSHOT - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-6 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-packet-uploader-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-packet-classifier-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-verification-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile index 643b37764f5..1e582469a52 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile @@ -1,97 +1,97 @@ -FROM openjdk:11 - -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to configuration server url to pickup configuration from, at docker runtime -ENV spring_config_url_env=${spring_config_url} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# change volume to whichever storage directory you want to use for this container. -#VOLUME /home/logs - -ENV group_name=registration-processor-stage-group-7 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -ADD ./target/${group_name}-*.jar ${group_name}.jar - -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ - fi +FROM eclipse-temurin:21-jre-alpine + +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to configuration server url to pickup configuration from, at docker runtime +ENV spring_config_url_env=${spring_config_url} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# change volume to whichever storage directory you want to use for this container. +#VOLUME /home/logs + +ENV group_name=registration-processor-stage-group-7 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +ADD ./target/${group_name}-*.jar ${group_name}.jar + +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml b/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml index 536a9781889..965fdd3e8ec 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/pom.xml @@ -1,74 +1,74 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - stage-groups - 1.2.1-SNAPSHOT - - - registration-processor-stage-group-7 - 1.2.1-SNAPSHOT - - - UTF-8 - - - - - - - io.mosip.registrationprocessor - mosip-stage-executor - 1.2.1-SNAPSHOT - - - - - io.mosip.registrationprocessor - registration-processor-uin-generator-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-biometric-extraction-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-finalization-stage - 1.2.1-SNAPSHOT - - - io.mosip.registrationprocessor - registration-processor-credential-requestor-stage - 1.2.1-SNAPSHOT - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication - ZIP - - - - - build-info - repackage - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + stage-groups + 1.2.1-java21-SNAPSHOT + + + registration-processor-stage-group-7 + 1.2.1-java21-SNAPSHOT + + + UTF-8 + + + + + + + io.mosip.registrationprocessor + mosip-stage-executor + 1.2.1-java21-SNAPSHOT + + + + + io.mosip.registrationprocessor + registration-processor-uin-generator-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-biometric-extraction-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-finalization-stage + 1.2.1-java21-SNAPSHOT + + + io.mosip.registrationprocessor + registration-processor-credential-requestor-stage + 1.2.1-java21-SNAPSHOT + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.stages.executor.MosipStageExecutorApplication + ZIP + + + + + build-info + repackage + + + + + + \ No newline at end of file diff --git a/registration-processor/workflow-engine/pom.xml b/registration-processor/workflow-engine/pom.xml index a82b533fd98..2ae7a78e990 100644 --- a/registration-processor/workflow-engine/pom.xml +++ b/registration-processor/workflow-engine/pom.xml @@ -1,20 +1,20 @@ - - - 4.0.0 - pom - - io.mosip.registrationprocessor - registration-processor - 1.2.1-SNAPSHOT - - 1.2.1-SNAPSHOT - workflow-engine - workflow-engine - - UTF-8 - - - registration-processor-workflow-manager-service - registration-processor-reprocessor - + + + 4.0.0 + pom + + io.mosip.registrationprocessor + registration-processor + 1.2.1-java21-SNAPSHOT + + 1.2.1-java21-SNAPSHOT + workflow-engine + workflow-engine + + UTF-8 + + + registration-processor-workflow-manager-service + registration-processor-reprocessor + \ No newline at end of file diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile index 7e09a054a1c..782771946a7 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile @@ -1,104 +1,104 @@ -FROM openjdk:11 - -#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image -#FROM openjdk:8-jdk-alpine -ARG SOURCE -ARG COMMIT_HASH -ARG COMMIT_ID -ARG BUILD_TIME -LABEL source=${SOURCE} -LABEL commit_hash=${COMMIT_HASH} -LABEL commit_id=${COMMIT_ID} -LABEL build_time=${BUILD_TIME} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG spring_config_label - -# can be passed during Docker build as build time environment for spring profiles active -ARG active_profile - -# can be passed during Docker build as build time environment for config server URL -ARG spring_config_url - -# can be passed during Docker build as build time environment for glowroot -ARG is_glowroot - -# can be passed during Docker build as build time environment for artifactory URL -ARG artifactory_url - -# environment variable to pass active profile such as DEV, QA etc at docker runtime -ENV active_profile_env=${active_profile} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass github branch to pickup configuration from, at docker runtime -ENV spring_config_label_env=${spring_config_label} - -# environment variable to pass glowroot, at docker runtime -ENV is_glowroot_env=${is_glowroot} - -# environment variable to pass artifactory url, at docker runtime -ENV artifactory_url_env=${artifactory_url} - -# environment variable to pass iam_adapter url, at docker runtime -ENV iam_adapter_url_env=${iam_adapter_url} - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_group=mosip - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 - -# can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_gid=1001 - -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ -&& adduser ${container_user} sudo - -# set working directory for the user -WORKDIR /home/${container_user} - -ENV work_dir=/home/${container_user} - -ARG loader_path=${work_dir}/additional_jars/ - -RUN mkdir -p ${loader_path} - -ENV loader_path_env=${loader_path} - -# change volume to whichever storage directory you want to use for this container. -VOLUME ${work_dir}/logs ${work_dir}/Glowroot - -ADD ./target/registration-processor-reprocessor-*.jar registration-processor-reprocessor.jar - -#Below 4 lines is added only as a temporary fix to downloaded the ceylon dependencies for chime scheduler -#later this chime to be replaced with something else -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} - -# select container user for all tasks -USER ${container_user_uid}:${container_user_gid} - -CMD wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/regproc-reprocessor-ceylon-cache-repo.zip ; \ - unzip regproc-reprocessor-ceylon-cache-repo.zip ; \ - rm -rf regproc-reprocessor-ceylon-cache-repo.zip ; \ - if [ "$is_glowroot_env" = "present" ]; then \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ - unzip glowroot.zip ; \ - rm -rf glowroot.zip ; \ - sed -i 's//registration-processor-reprocessor/g' glowroot/glowroot.properties ; \ - java -jar -Dloader.path="${loader_path_env}" -javaagent:glowroot/glowroot.jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dceylon.cache.repo=./regproc-reprocessor-ceylon-cache-repo registration-processor-reprocessor.jar ; \ - else \ - wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dceylon.cache.repo=./regproc-reprocessor-ceylon-cache-repo registration-processor-reprocessor.jar ; \ - fi - -#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-reprocessor.jar"] +FROM eclipse-temurin:21-jre-alpine + +#Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image +#FROM openjdk:8-jdk-alpine +ARG SOURCE +ARG COMMIT_HASH +ARG COMMIT_ID +ARG BUILD_TIME +LABEL source=${SOURCE} +LABEL commit_hash=${COMMIT_HASH} +LABEL commit_id=${COMMIT_ID} +LABEL build_time=${BUILD_TIME} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG spring_config_label + +# can be passed during Docker build as build time environment for spring profiles active +ARG active_profile + +# can be passed during Docker build as build time environment for config server URL +ARG spring_config_url + +# can be passed during Docker build as build time environment for glowroot +ARG is_glowroot + +# can be passed during Docker build as build time environment for artifactory URL +ARG artifactory_url + +# environment variable to pass active profile such as DEV, QA etc at docker runtime +ENV active_profile_env=${active_profile} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass github branch to pickup configuration from, at docker runtime +ENV spring_config_label_env=${spring_config_label} + +# environment variable to pass glowroot, at docker runtime +ENV is_glowroot_env=${is_glowroot} + +# environment variable to pass artifactory url, at docker runtime +ENV artifactory_url_env=${artifactory_url} + +# environment variable to pass iam_adapter url, at docker runtime +ENV iam_adapter_url_env=${iam_adapter_url} + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_group=mosip + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_uid=1002 + +# can be passed during Docker build as build time environment for github branch to pickup configuration from. +ARG container_user_gid=1001 + +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& adduser ${container_user} sudo + +# set working directory for the user +WORKDIR /home/${container_user} + +ENV work_dir=/home/${container_user} + +ARG loader_path=${work_dir}/additional_jars/ + +RUN mkdir -p ${loader_path} + +ENV loader_path_env=${loader_path} + +# change volume to whichever storage directory you want to use for this container. +VOLUME ${work_dir}/logs ${work_dir}/Glowroot + +ADD ./target/registration-processor-reprocessor-*.jar registration-processor-reprocessor.jar + +#Below 4 lines is added only as a temporary fix to downloaded the ceylon dependencies for chime scheduler +#later this chime to be replaced with something else +# change permissions of file inside working dir +RUN chown -R ${container_user}:${container_user} /home/${container_user} + +# select container user for all tasks +USER ${container_user_uid}:${container_user_gid} + +CMD wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/regproc-reprocessor-ceylon-cache-repo.zip ; \ + unzip regproc-reprocessor-ceylon-cache-repo.zip ; \ + rm -rf regproc-reprocessor-ceylon-cache-repo.zip ; \ + if [ "$is_glowroot_env" = "present" ]; then \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + wget "${artifactory_url_env}"/artifactory/libs-release-local/io/mosip/testing/glowroot.zip ; \ + unzip glowroot.zip ; \ + rm -rf glowroot.zip ; \ + sed -i 's//registration-processor-reprocessor/g' glowroot/glowroot.properties ; \ + java -jar -Dloader.path="${loader_path_env}" -javaagent:glowroot/glowroot.jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dceylon.cache.repo=./regproc-reprocessor-ceylon-cache-repo registration-processor-reprocessor.jar ; \ + else \ + wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ + java -Dloader.path="${loader_path_env}" -jar -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dceylon.cache.repo=./regproc-reprocessor-ceylon-cache-repo registration-processor-reprocessor.jar ; \ + fi + +#CMD ["java","-Dspring.cloud.config.label=${spring_config_label_env}","-Dspring.profiles.active=${active_profile_env}","-Dspring.cloud.config.uri=${spring_config_url_env}","-jar","registration-processor-reprocessor.jar"] diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml index 9f9dd3676ed..217551fc058 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml @@ -1,127 +1,127 @@ - - - 4.0.0 - - io.mosip.registrationprocessor - workflow-engine - 1.2.1-SNAPSHOT - - registration-processor-reprocessor - 1.2.1-SNAPSHOT - registration-processor-reprocessor - - UTF-8 - UTF-8 - - - - io.mosip.registrationprocessor - registration-processor-core - ${registration.processor.core.version} - - - org.springframework - spring-context - - - org.springframework - spring-tx - - - - io.vertx - vertx-core - ${vertx.version} - - - - io.vertx - vertx-lang-ceylon - 3.4.1 - - - org.ceylon-lang - ceylon-complete - - - - - - org.ceylon-lang - ceylon-complete - 1.3.2 - - - io.mosip.registrationprocessor - registration-processor-registration-status-service-impl - ${registration.status.service.version} - - - io.vertx - vertx-unit - ${vertx.version} - test - - - org.mockito - mockito-core - test - - - io.mosip.registrationprocessor - registration-processor-info-storage-service - ${packet.info.storage.service.version} - - - io.mosip.kernel - kernel-websubclient-api - ${kernel.websubclient.version} - - - - - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - - - org.mockito - mockito-core - ${mockito.version} - test - - - com.h2database - h2 - 1.4.195 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - true - io.mosip.registration.processor.reprocessor.ReprocessorApplication - ZIP - - - - - build-info - repackage - - - - - - - + + + 4.0.0 + + io.mosip.registrationprocessor + workflow-engine + 1.2.1-java21-SNAPSHOT + + registration-processor-reprocessor + 1.2.1-java21-SNAPSHOT + registration-processor-reprocessor + + UTF-8 + UTF-8 + + + + io.mosip.registrationprocessor + registration-processor-core + ${registration.processor.core.version} + + + org.springframework + spring-context + + + org.springframework + spring-tx + + + + io.vertx + vertx-core + ${vertx.version} + + + + io.vertx + vertx-lang-ceylon + 3.4.1 + + + org.ceylon-lang + ceylon-complete + + + + + + org.ceylon-lang + ceylon-complete + 1.3.2 + + + io.mosip.registrationprocessor + registration-processor-registration-status-service-impl + ${registration.status.service.version} + + + io.vertx + vertx-unit + ${vertx.version} + test + + + org.mockito + mockito-core + test + + + io.mosip.registrationprocessor + registration-processor-info-storage-service + ${packet.info.storage.service.version} + + + io.mosip.kernel + kernel-websubclient-api + ${kernel.websubclient.version} + + + + + + org.springframework.cloud + spring-cloud-starter-config + ${spring-cloud-config.version} + + + org.mockito + mockito-core + ${mockito.version} + test + + + com.h2database + h2 + 1.4.195 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + true + io.mosip.registration.processor.reprocessor.ReprocessorApplication + ZIP + + + + + build-info + repackage + + + + + + + diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile index aed8e7f6bdb..069b9f57e84 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:11 +FROM eclipse-temurin:21-jre-alpine #Uncomment below and Comment above line(i.e. FROM openjdk:8) for OS specific (e.g. Alpine OS ) docker base image #FROM openjdk:8-jdk-alpine @@ -51,15 +51,15 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1001 +ARG container_user_uid=1002 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 -RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ -&& groupadd -g ${container_user_gid} ${container_user_group} \ -&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/sh -m ${container_user} \ +RUN apk -q update \ +&& apk add -q unzip wget sudo \ +&& addgroup -g ${container_user_gid} ${container_user_group} \ +&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml index 0378336e704..ea2bc81108d 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml @@ -5,10 +5,10 @@ io.mosip.registrationprocessor workflow-engine - 1.2.1-SNAPSHOT + 1.2.1-java21-SNAPSHOT registration-processor-workflow-manager-service - 1.2.1-SNAPSHOT + 1.2.1-java21-SNAPSHOT registration-processor-workflow-manager-service UTF-8 diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/util/WebSubUtil.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/util/WebSubUtil.java index a1f511338fd..81e41d88487 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/util/WebSubUtil.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/util/WebSubUtil.java @@ -1,6 +1,6 @@ package io.mosip.registration.processor.workflowmanager.util; -import javax.annotation.PostConstruct; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java index 7f64c4ff413..fbfaf87ea5e 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java @@ -386,36 +386,6 @@ public List acceptableLocales() { return null; } - @Override - public RoutingContext addCookie(io.vertx.core.http.Cookie arg0) { - return null; - } - - @Override - public int addEndHandler(Handler> arg0) { - return 0; - } - - @Override - public Map cookieMap() { - return null; - } - - @Override - public void fail(int arg0, Throwable arg1) { - - } - - @Override - public boolean isSessionAccessed() { - return false; - } - - @Override - public boolean removeEndHandler(int arg0) { - return false; - } - }; } diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java index 2b4e1c193ca..522d4afd51f 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java @@ -1,437 +1,407 @@ -package io.mosip.registration.processor.workflowmanager.verticle; - -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.util.ReflectionTestUtils; - -import io.mosip.registration.processor.core.exception.WorkFlowSearchException; -import io.mosip.registration.processor.core.exception.WorkflowActionRequestValidationException; -import io.mosip.registration.processor.core.workflow.dto.WorkflowDetail; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.workflowmanager.service.WorkflowSearchService; -import io.mosip.registration.processor.workflowmanager.validator.WorkflowSearchRequestValidator; -import io.vertx.codegen.annotations.Nullable; -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.MultiMap; -import io.vertx.core.Vertx; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.http.HttpMethod; -import io.vertx.core.http.HttpServerRequest; -import io.vertx.core.http.HttpServerResponse; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.ext.auth.AuthProvider; -import io.vertx.ext.auth.User; -import io.vertx.ext.web.Cookie; -import io.vertx.ext.web.FileUpload; -import io.vertx.ext.web.Locale; -import io.vertx.ext.web.ParsedHeaderValues; -import io.vertx.ext.web.Route; -import io.vertx.ext.web.RoutingContext; -import io.vertx.ext.web.Session; - -@RunWith(SpringRunner.class) -public class WorkflowSearchApiTest { - - private Boolean responseObject; - - private RoutingContext ctx; - - @Mock - AuditLogRequestBuilder auditLogRequestBuilder; - - @Mock - WorkflowSearchRequestValidator workflowSearchRequestValidator; - - @Mock - WorkflowSearchService workflowSearchService; - - @InjectMocks - WorkflowSearchApi workflowSearchApi = new WorkflowSearchApi() { - @Override - public void setResponse(RoutingContext ctx, Object object) { - responseObject = Boolean.TRUE; - } - }; - - private RoutingContext setContext() { - return new RoutingContext() { - - @Override - public Vertx vertx() { - return null; - } - - @Override - public User user() { - return new User() { - - @Override - public void setAuthProvider(AuthProvider authProvider) { - // TODO Auto-generated method stub - - } - - @Override - public JsonObject principal() { - // TODO Auto-generated method stub - JsonObject obj = new JsonObject(); - obj.put("username", "admin"); - return obj; - } - - @Override - public User isAuthorized(String authority, Handler> resultHandler) { - // TODO Auto-generated method stub - return null; - } - - @Override - public User clearCache() { - // TODO Auto-generated method stub - return null; - } - }; - } - - @Override - public Map pathParams() { - return null; - } - - @Override - public String pathParam(String name) { - return null; - } - - @Override - public ParsedHeaderValues parsedHeaders() { - return null; - } - - @Override - public String normalisedPath() { - return null; - } - - @Override - public void next() { - } - - @Override - public String mountPoint() { - return null; - } - - @Override - public Cookie getCookie(String name) { - return null; - } - - @Override - public String getBodyAsString(String encoding) { - return null; - } - - @Override - public String getBodyAsString() { - return null; - } - - @Override - public JsonArray getBodyAsJsonArray() { - return null; - } - - @Override - public JsonObject getBodyAsJson() { - JsonObject obj = new JsonObject(); - obj.put("id", "mosip.registration.processor.workflow.action"); - obj.put("version", "1.0"); - obj.put("requesttime", "2021-03-15T10:02:45.474Z"); - JsonObject searchInfo = new JsonObject(); - JsonObject filterInfo = new JsonObject(); - JsonObject pagination = new JsonObject(); - JsonObject sort = new JsonObject(); - sort.put("sortField", ""); - sort.put("sortType", ""); - pagination.put("pageStart", 1); - pagination.put("pageFetch", 5); - filterInfo.put("columnName", "id"); - filterInfo.put("value", "45128164920495"); - searchInfo.put("filters", Arrays.asList(filterInfo)); - searchInfo.put("pagination", pagination); - searchInfo.put("sort", sort); - obj.put("request", searchInfo); - return obj; - } - - @Override - public Buffer getBody() { - return null; - } - - @Override - public String getAcceptableContentType() { - return null; - } - - @Override - public T get(String key) { - return null; - } - - @Override - public Throwable failure() { - return null; - } - - @Override - public boolean failed() { - return false; - } - - @Override - public void fail(Throwable throwable) { - } - - @Override - public void fail(int statusCode) { - } - - @Override - public Map data() { - return null; - } - - @Override - public Route currentRoute() { - return null; - } - - @Override - public Set cookies() { - return null; - } - - @Override - public int cookieCount() { - return 0; - } - - @Override - public void clearUser() { - } - - @Override - public int addHeadersEndHandler(Handler handler) { - return 0; - } - - @Override - public RoutingContext addCookie(Cookie cookie) { - return null; - } - - @Override - public int addBodyEndHandler(Handler handler) { - return 0; - } - - @Override - public List acceptableLocales() { - return null; - } - - @Override - public RoutingContext addCookie(io.vertx.core.http.Cookie arg0) { - return null; - } - - @Override - public int addEndHandler(Handler> arg0) { - return 0; - } - - @Override - public Map cookieMap() { - return null; - } - - @Override - public void fail(int arg0, Throwable arg1) { - - } - - @Override - public boolean isSessionAccessed() { - return false; - } - - @Override - public boolean removeEndHandler(int arg0) { - return false; - } - - @Override - public HttpServerRequest request() { - // TODO Auto-generated method stub - return null; - } - - @Override - public HttpServerResponse response() { - // TODO Auto-generated method stub - return null; - } - - @Override - public RoutingContext put(String key, Object obj) { - // TODO Auto-generated method stub - return null; - } - - @Override - public T remove(String key) { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Cookie removeCookie(String name, boolean invalidate) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Set fileUploads() { - // TODO Auto-generated method stub - return null; - } - - @Override - public @Nullable Session session() { - // TODO Auto-generated method stub - return null; - } - - @Override - public int statusCode() { - // TODO Auto-generated method stub - return 0; - } - - @Override - public boolean removeHeadersEndHandler(int handlerID) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean removeBodyEndHandler(int handlerID) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void setBody(Buffer body) { - // TODO Auto-generated method stub - - } - - @Override - public void setSession(Session session) { - // TODO Auto-generated method stub - - } - - @Override - public void setUser(User user) { - // TODO Auto-generated method stub - - } - - @Override - public void setAcceptableContentType(@Nullable String contentType) { - // TODO Auto-generated method stub - - } - - @Override - public void reroute(HttpMethod method, String path) { - // TODO Auto-generated method stub - - } - - @Override - public MultiMap queryParams() { - // TODO Auto-generated method stub - return null; - } - - @Override - public List queryParam(String name) { - // TODO Auto-generated method stub - return null; - } - - }; - } - - @Before - public void setup() throws WorkflowActionRequestValidationException { - ReflectionTestUtils.setField(workflowSearchApi, "id", "workflow.id"); - ReflectionTestUtils.setField(workflowSearchApi, "version", "1.0"); - ReflectionTestUtils.setField(workflowSearchApi, "contextPath", "/dummyPath"); - ReflectionTestUtils.setField(workflowSearchApi, "dateTimePattern", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - ctx = setContext(); - } - - @Test - public void testProcessURL() throws WorkFlowSearchException { - WorkflowDetail workflowDetail = new WorkflowDetail(); - workflowDetail.setWorkflowId("45128164920495"); - workflowDetail.setWorkflowType("NEW"); - - Page pageDtos = new PageImpl(Arrays.asList(workflowDetail)); - - Mockito.doNothing().when(workflowSearchRequestValidator).validate(Mockito.any()); - Mockito.when(workflowSearchService.searchRegistrationDetails(any())).thenReturn(pageDtos); - workflowSearchApi.processURL(ctx); - assertTrue(responseObject); - } - - @Test - public void testProcessFailureURL() throws WorkFlowSearchException { - - WorkFlowSearchException exception = new WorkFlowSearchException("ERR-001", "exception occured"); - Mockito.doNothing().when(workflowSearchRequestValidator).validate(Mockito.any()); - Mockito.when(workflowSearchService.searchRegistrationDetails(any())).thenThrow(exception); - workflowSearchApi.processURL(ctx); - assertTrue(responseObject); - } - - @Test - public void testProcessUnkonwnFailureURL() throws WorkFlowSearchException { - - Mockito.doThrow(NullPointerException.class).when(workflowSearchRequestValidator).validate(Mockito.any()); - workflowSearchApi.processURL(ctx); - assertTrue(responseObject); - } +package io.mosip.registration.processor.workflowmanager.verticle; + +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import io.mosip.registration.processor.core.exception.WorkFlowSearchException; +import io.mosip.registration.processor.core.exception.WorkflowActionRequestValidationException; +import io.mosip.registration.processor.core.workflow.dto.WorkflowDetail; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.workflowmanager.service.WorkflowSearchService; +import io.mosip.registration.processor.workflowmanager.validator.WorkflowSearchRequestValidator; +import io.vertx.codegen.annotations.Nullable; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.MultiMap; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpServerResponse; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.ext.auth.AuthProvider; +import io.vertx.ext.auth.User; +import io.vertx.ext.web.Cookie; +import io.vertx.ext.web.FileUpload; +import io.vertx.ext.web.Locale; +import io.vertx.ext.web.ParsedHeaderValues; +import io.vertx.ext.web.Route; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.Session; + +@RunWith(SpringRunner.class) +public class WorkflowSearchApiTest { + + private Boolean responseObject; + + private RoutingContext ctx; + + @Mock + AuditLogRequestBuilder auditLogRequestBuilder; + + @Mock + WorkflowSearchRequestValidator workflowSearchRequestValidator; + + @Mock + WorkflowSearchService workflowSearchService; + + @InjectMocks + WorkflowSearchApi workflowSearchApi = new WorkflowSearchApi() { + @Override + public void setResponse(RoutingContext ctx, Object object) { + responseObject = Boolean.TRUE; + } + }; + + private RoutingContext setContext() { + return new RoutingContext() { + + @Override + public Vertx vertx() { + return null; + } + + @Override + public User user() { + return new User() { + + @Override + public void setAuthProvider(AuthProvider authProvider) { + // TODO Auto-generated method stub + + } + + @Override + public JsonObject principal() { + // TODO Auto-generated method stub + JsonObject obj = new JsonObject(); + obj.put("username", "admin"); + return obj; + } + + @Override + public User isAuthorized(String authority, Handler> resultHandler) { + // TODO Auto-generated method stub + return null; + } + + @Override + public User clearCache() { + // TODO Auto-generated method stub + return null; + } + }; + } + + @Override + public Map pathParams() { + return null; + } + + @Override + public String pathParam(String name) { + return null; + } + + @Override + public ParsedHeaderValues parsedHeaders() { + return null; + } + + @Override + public String normalisedPath() { + return null; + } + + @Override + public void next() { + } + + @Override + public String mountPoint() { + return null; + } + + @Override + public Cookie getCookie(String name) { + return null; + } + + @Override + public String getBodyAsString(String encoding) { + return null; + } + + @Override + public String getBodyAsString() { + return null; + } + + @Override + public JsonArray getBodyAsJsonArray() { + return null; + } + + @Override + public JsonObject getBodyAsJson() { + JsonObject obj = new JsonObject(); + obj.put("id", "mosip.registration.processor.workflow.action"); + obj.put("version", "1.0"); + obj.put("requesttime", "2021-03-15T10:02:45.474Z"); + JsonObject searchInfo = new JsonObject(); + JsonObject filterInfo = new JsonObject(); + JsonObject pagination = new JsonObject(); + JsonObject sort = new JsonObject(); + sort.put("sortField", ""); + sort.put("sortType", ""); + pagination.put("pageStart", 1); + pagination.put("pageFetch", 5); + filterInfo.put("columnName", "id"); + filterInfo.put("value", "45128164920495"); + searchInfo.put("filters", Arrays.asList(filterInfo)); + searchInfo.put("pagination", pagination); + searchInfo.put("sort", sort); + obj.put("request", searchInfo); + return obj; + } + + @Override + public Buffer getBody() { + return null; + } + + @Override + public String getAcceptableContentType() { + return null; + } + + @Override + public T get(String key) { + return null; + } + + @Override + public Throwable failure() { + return null; + } + + @Override + public boolean failed() { + return false; + } + + @Override + public void fail(Throwable throwable) { + } + + @Override + public void fail(int statusCode) { + } + + @Override + public Map data() { + return null; + } + + @Override + public Route currentRoute() { + return null; + } + + @Override + public Set cookies() { + return null; + } + + @Override + public int cookieCount() { + return 0; + } + + @Override + public void clearUser() { + } + + @Override + public int addHeadersEndHandler(Handler handler) { + return 0; + } + + @Override + public RoutingContext addCookie(Cookie cookie) { + return null; + } + + @Override + public int addBodyEndHandler(Handler handler) { + return 0; + } + + @Override + public List acceptableLocales() { + return null; + } + + @Override + public HttpServerRequest request() { + // TODO Auto-generated method stub + return null; + } + + @Override + public HttpServerResponse response() { + // TODO Auto-generated method stub + return null; + } + + @Override + public RoutingContext put(String key, Object obj) { + // TODO Auto-generated method stub + return null; + } + + @Override + public T remove(String key) { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Cookie removeCookie(String name, boolean invalidate) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Set fileUploads() { + // TODO Auto-generated method stub + return null; + } + + @Override + public @Nullable Session session() { + // TODO Auto-generated method stub + return null; + } + + @Override + public int statusCode() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean removeHeadersEndHandler(int handlerID) { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean removeBodyEndHandler(int handlerID) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setBody(Buffer body) { + // TODO Auto-generated method stub + + } + + @Override + public void setSession(Session session) { + // TODO Auto-generated method stub + + } + + @Override + public void setUser(User user) { + // TODO Auto-generated method stub + + } + + @Override + public void setAcceptableContentType(@Nullable String contentType) { + // TODO Auto-generated method stub + + } + + @Override + public void reroute(HttpMethod method, String path) { + // TODO Auto-generated method stub + + } + + @Override + public MultiMap queryParams() { + // TODO Auto-generated method stub + return null; + } + + @Override + public List queryParam(String name) { + // TODO Auto-generated method stub + return null; + } + + }; + } + + @Before + public void setup() throws WorkflowActionRequestValidationException { + ReflectionTestUtils.setField(workflowSearchApi, "id", "workflow.id"); + ReflectionTestUtils.setField(workflowSearchApi, "version", "1.0"); + ReflectionTestUtils.setField(workflowSearchApi, "contextPath", "/dummyPath"); + ReflectionTestUtils.setField(workflowSearchApi, "dateTimePattern", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + ctx = setContext(); + } + + @Test + public void testProcessURL() throws WorkFlowSearchException { + WorkflowDetail workflowDetail = new WorkflowDetail(); + workflowDetail.setWorkflowId("45128164920495"); + workflowDetail.setWorkflowType("NEW"); + + Page pageDtos = new PageImpl(Arrays.asList(workflowDetail)); + + Mockito.doNothing().when(workflowSearchRequestValidator).validate(Mockito.any()); + Mockito.when(workflowSearchService.searchRegistrationDetails(any())).thenReturn(pageDtos); + workflowSearchApi.processURL(ctx); + assertTrue(responseObject); + } + + @Test + public void testProcessFailureURL() throws WorkFlowSearchException { + + WorkFlowSearchException exception = new WorkFlowSearchException("ERR-001", "exception occured"); + Mockito.doNothing().when(workflowSearchRequestValidator).validate(Mockito.any()); + Mockito.when(workflowSearchService.searchRegistrationDetails(any())).thenThrow(exception); + workflowSearchApi.processURL(ctx); + assertTrue(responseObject); + } + + @Test + public void testProcessUnkonwnFailureURL() throws WorkFlowSearchException { + + Mockito.doThrow(NullPointerException.class).when(workflowSearchRequestValidator).validate(Mockito.any()); + workflowSearchApi.processURL(ctx); + assertTrue(responseObject); + } } \ No newline at end of file From 4a23a41f5b837fe7688d83ca685b4fa83228c3b0 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 14 May 2024 17:16:48 +0530 Subject: [PATCH 02/27] MOSIP-32461 few test cases fixed Signed-off-by: Sowmya Ujjappa Banakar --- .../pom.xml | 5 - .../pom.xml | 5 - .../stage/ManualAdjudicationStageTest.java | 28 + .../stage/PacketReceiverStageTest.java | 30 + .../pom.xml | 4 +- .../RegistrationStatusServiceBeanConfig.java | 243 ++--- .../config/RegistrationStatusConfigTest.java | 14 +- registration-processor/pom.xml | 29 +- .../pom.xml | 7 - .../pom.xml | 4 +- .../pom.xml | 2 +- .../SecurezoneNotificationStageTest.java | 30 + .../pom.xml | 5 - .../qc/users/entity/BaseQcuserEntity.java | 8 +- .../qc/users/entity/RoleListEntity.java | 6 +- .../qc/users/entity/RoleListPKEntity.java | 2 +- .../qc/users/entity/UserDetailEntity.java | 6 +- .../qc/users/entity/UserDetailPKEntity.java | 2 +- .../qc/users/entity/UserRoleEntity.java | 6 +- .../qc/users/entity/UserRolePKEntity.java | 2 +- .../registration-processor-core/pom.xml | 13 +- .../PropertyLoaderConfig.java | 190 ++-- .../digital/signature/dto/SignRequestDto.java | 2 +- .../processor/core/http/RequestWrapper.java | 4 +- .../processor/core/http/ResponseWrapper.java | 4 +- .../kernel/master/dto/UserResponseDTO.java | 64 +- .../core/workflow/dto/PageResponseDTO.java | 40 +- .../core/workflow/dto/SearchInfo.java | 68 +- .../storage/entity/AbisApplicationEntity.java | 274 ++--- .../entity/AbisApplicationPKEntity.java | 114 +-- .../storage/entity/AbisRequestEntity.java | 406 ++++---- .../storage/entity/AbisRequestPKEntity.java | 98 +- .../storage/entity/AbisResponseDetEntity.java | 8 +- .../entity/AbisResponseDetPKEntity.java | 112 +- .../storage/entity/AbisResponseEntity.java | 308 +++--- .../storage/entity/AbisResponsePKEntity.java | 102 +- .../storage/entity/BasePacketEntity.java | 8 +- .../IndividualDemographicDedupeEntity.java | 482 ++++----- .../IndividualDemographicDedupePKEntity.java | 146 +-- .../entity/ManualVerificationEntity.java | 836 +++++++-------- .../entity/ManualVerificationPKEntity.java | 164 +-- .../entity/QcuserRegistrationIdEntity.java | 6 +- .../entity/QcuserRegistrationIdPKEntity.java | 4 +- .../storage/entity/RegBioRefEntity.java | 252 ++--- .../storage/entity/RegBioRefPKEntity.java | 84 +- .../entity/RegDemoDedupeListEntity.java | 212 ++-- .../entity/RegDemoDedupeListPKEntity.java | 112 +- .../storage/entity/RegLostUinDetEntity.java | 222 ++-- .../storage/entity/RegLostUinDetPKEntity.java | 78 +- .../storage/entity/VerificationEntity.java | 400 ++++---- .../storage/entity/VerificationPKEntity.java | 58 +- .../repository/BasePacketRepository.java | 968 +++++++++--------- .../pom.xml | 5 - .../pom.xml | 5 - .../pom.xml | 10 + .../config/RegistrationStatusBeanConfig.java | 291 +++--- .../entity/AdditionalInfoRequestEntity.java | 164 +-- .../entity/AdditionalInfoRequestPKEntity.java | 100 +- .../status/entity/AnonymousProfileEntity.java | 6 +- .../entity/AnonymousProfilePKEntity.java | 6 +- .../status/entity/BasePacketEntity.java | 80 +- .../status/entity/BaseRegistrationEntity.java | 88 +- .../entity/BaseRegistrationPKEntity.java | 90 +- .../entity/BaseSyncRegistrationEntity.java | 104 +- .../status/entity/BaseTransactionEntity.java | 56 +- .../entity/RegistrationStatusEntity.java | 8 +- .../processor/status/entity/SaltEntity.java | 8 +- .../status/entity/SyncRegistrationEntity.java | 6 +- .../status/entity/TransactionEntity.java | 824 +++++++-------- .../pom.xml | 5 - .../pom.xml | 5 - .../WorkflowManagerApplication.java | 7 +- .../verticle/WorkflowActionApiTest.java | 30 + .../verticle/WorkflowSearchApiTest.java | 30 + 74 files changed, 4177 insertions(+), 4028 deletions(-) diff --git a/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml b/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml index 92cbea5c91a..94756c6a88c 100644 --- a/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis-handler-stage/pom.xml @@ -18,11 +18,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml index e1e26c4ee41..cc264ec04a3 100644 --- a/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-biometric-extraction-stage/pom.xml @@ -16,11 +16,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java index f62b9e491ae..2476e721cad 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/test/java/io/mosip/registration/processor/verification/stage/ManualAdjudicationStageTest.java @@ -481,6 +481,34 @@ public int addBodyEndHandler(Handler handler) { public List acceptableLocales() { return null; } + @Override + public void fail(int statusCode, Throwable throwable) { + } + + @Override + public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { + return null; + } + + @Override + public Map cookieMap() { + return null; + } + + @Override + public boolean isSessionAccessed() { + return false; + } + + @Override + public int addEndHandler(Handler> handler) { + return 0; + } + + @Override + public boolean removeEndHandler(int handlerID) { + return false; + } }; } diff --git a/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java b/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java index 7f9a58f9ec5..0755e176811 100644 --- a/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java +++ b/registration-processor/init/registration-processor-packet-receiver-stage/src/test/java/io/mosip/registration/processor/packet/receiver/stage/PacketReceiverStageTest.java @@ -442,6 +442,36 @@ public List acceptableLocales() { return null; } + @Override + public void fail(int statusCode, Throwable throwable) { + + } + + @Override + public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { + return null; + } + + @Override + public Map cookieMap() { + return null; + } + + @Override + public boolean isSessionAccessed() { + return false; + } + + @Override + public int addEndHandler(Handler> handler) { + return 0; + } + + @Override + public boolean removeEndHandler(int handlerID) { + return false; + } + }; } diff --git a/registration-processor/init/registration-processor-registration-status-service/pom.xml b/registration-processor/init/registration-processor-registration-status-service/pom.xml index 85a1e31e2e9..b076a810128 100644 --- a/registration-processor/init/registration-processor-registration-status-service/pom.xml +++ b/registration-processor/init/registration-processor-registration-status-service/pom.xml @@ -54,8 +54,8 @@ org.springdoc - springdoc-openapi-ui - 1.5.10 + springdoc-openapi-starter-webmvc-ui + 2.5.0 org.springframework.boot diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusServiceBeanConfig.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusServiceBeanConfig.java index e8d42029806..cbed592ad56 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusServiceBeanConfig.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusServiceBeanConfig.java @@ -1,121 +1,122 @@ -package io.mosip.registration.processor.status.config; - -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.PropertySource; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; -import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.rest.client.utils.RestApiClient; -import io.mosip.registration.processor.status.dao.RegistrationStatusDao; -import io.mosip.registration.processor.status.dao.SyncRegistrationDao; -import io.mosip.registration.processor.status.decryptor.Decryptor; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.dto.TransactionDto; -import io.mosip.registration.processor.status.encryptor.Encryptor; -import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; -import io.mosip.registration.processor.status.entity.BaseRegistrationPKEntity; -import io.mosip.registration.processor.status.entity.BaseSyncRegistrationEntity; -import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; -import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.SyncRegistrationService; -import io.mosip.registration.processor.status.service.TransactionService; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.service.impl.TransactionServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationExternalStatusUtility; -@Configuration -@PropertySource("classpath:bootstrap.properties") -@Import({ HibernateDaoConfig.class }) -@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) -public class RegistrationStatusServiceBeanConfig { - - @Bean - public RegistrationStatusService getRegistrationStatusService() { - return new RegistrationStatusServiceImpl(); - } - - @Bean - public AuditLogRequestBuilder getAuditLogRequestBuilder() { - return new AuditLogRequestBuilder(); - } - -// @Bean -// public RegistrationProcessorRestClientService getRegistrationProcessorRestClientService() { -// return new RegistrationProcessorRestClientServiceImpl(); -// } - - @Bean - public SyncRegistrationDao getSyncRegistrationDao() { - return new SyncRegistrationDao(); - } - - @Bean - public RestTemplateBuilder getRestTemplateBuilder() { - return new RestTemplateBuilder(); - } - - @Bean - public RegistrationStatusDao getRegistrationStatusDao() { - return new RegistrationStatusDao(); - } - - @Bean - public TransactionService getTransactionService() { - return new TransactionServiceImpl(); - } - - @Bean - public RestApiClient getRestApiClient() { - return new RestApiClient(); - } - - @Bean - public SyncRegistrationService getSyncRegistrationService(){ - return new SyncRegistrationServiceImpl(); - } - - @Bean - public InternalRegistrationStatusDto internalRegistrationStatusDto() { - return new InternalRegistrationStatusDto(); - } - - @Bean - public RegistrationStatusEntity registrationStatusEntity() { - return new RegistrationStatusEntity(); - } - - @Bean - public BaseRegistrationEntity baseRegistrationStatusEntity() { - return new RegistrationStatusEntity(); - } - - @Bean - public BaseSyncRegistrationEntity baseSyncRegistrationEntity() { - return new SyncRegistrationEntity(); - } - - @Bean - public RegistrationExternalStatusUtility getRegistrationExternalStatusUtility() - { - return new RegistrationExternalStatusUtility(); - } - - @Bean - public Decryptor decryptor() { - return new Decryptor(); - } - - @Bean - public Encryptor encryptor() { - return new Encryptor(); - } -} +package io.mosip.registration.processor.status.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.context.annotation.PropertySource; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.rest.client.utils.RestApiClient; +import io.mosip.registration.processor.status.dao.RegistrationStatusDao; +import io.mosip.registration.processor.status.dao.SyncRegistrationDao; +import io.mosip.registration.processor.status.decryptor.Decryptor; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.dto.TransactionDto; +import io.mosip.registration.processor.status.encryptor.Encryptor; +import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; +import io.mosip.registration.processor.status.entity.BaseRegistrationPKEntity; +import io.mosip.registration.processor.status.entity.BaseSyncRegistrationEntity; +import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; +import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; +import io.mosip.registration.processor.status.repositary.RegistrationRepositary; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; +import io.mosip.registration.processor.status.service.TransactionService; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.service.impl.TransactionServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationExternalStatusUtility; +@Configuration +@PropertySource("classpath:bootstrap.properties") +@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) +public class RegistrationStatusServiceBeanConfig { + + @Bean + public RegistrationStatusService getRegistrationStatusService() { + return new RegistrationStatusServiceImpl(); + } + + @Bean + public AuditLogRequestBuilder getAuditLogRequestBuilder() { + return new AuditLogRequestBuilder(); + } + +// @Bean +// public RegistrationProcessorRestClientService getRegistrationProcessorRestClientService() { +// return new RegistrationProcessorRestClientServiceImpl(); +// } + + @Bean + public SyncRegistrationDao getSyncRegistrationDao() { + return new SyncRegistrationDao(); + } + + @Bean + public RestTemplateBuilder getRestTemplateBuilder() { + return new RestTemplateBuilder(); + } + + @Bean + public RegistrationStatusDao getRegistrationStatusDao() { + return new RegistrationStatusDao(); + } + + @Bean + public TransactionService getTransactionService() { + return new TransactionServiceImpl(); + } + + @Bean + public RestApiClient getRestApiClient() { + return new RestApiClient(); + } + + @Bean + public SyncRegistrationService getSyncRegistrationService(){ + return new SyncRegistrationServiceImpl(); + } + + @Bean + public InternalRegistrationStatusDto internalRegistrationStatusDto() { + return new InternalRegistrationStatusDto(); + } + + @Bean + public RegistrationStatusEntity registrationStatusEntity() { + return new RegistrationStatusEntity(); + } + + @Bean + public BaseRegistrationEntity baseRegistrationStatusEntity() { + return new RegistrationStatusEntity(); + } + + @Bean + public BaseSyncRegistrationEntity baseSyncRegistrationEntity() { + return new SyncRegistrationEntity(); + } + + @Bean + public RegistrationExternalStatusUtility getRegistrationExternalStatusUtility() + { + return new RegistrationExternalStatusUtility(); + } + + @Bean + public Decryptor decryptor() { + return new Decryptor(); + } + + @Bean + public Encryptor encryptor() { + return new Encryptor(); + } + +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java index 952a880fe86..fde757006c1 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java @@ -7,11 +7,20 @@ import org.springframework.context.annotation.FilterType; import io.mosip.kernel.core.authmanager.authadapter.spi.VertxAuthenticationProvider; +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; import io.mosip.registration.processor.core.config.CoreConfigBean; +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.rest.client.config.RestConfigBean; import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; import io.mosip.registration.processor.status.config.RegistrationStatusServiceBeanConfig; +import io.mosip.registration.processor.status.dao.RegistrationStatusDao; +import io.mosip.registration.processor.status.dao.SyncRegistrationDao; import io.mosip.registration.processor.status.dto.AuthorizedRolesDto; +import io.mosip.registration.processor.status.repositary.RegistrationRepositary; +import io.mosip.registration.processor.status.service.impl.AnonymousProfileServiceImpl; +import io.mosip.registration.processor.status.service.impl.PacketExternalStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.TransactionServiceImpl; import io.vertx.core.Vertx; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.HttpServer; @@ -21,8 +30,9 @@ @Configuration @ComponentScan(basePackages = { "io.mosip.registration.processor.status.*" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { - RegistrationStatusServiceBeanConfig.class, RegistrationStatusBeanConfig.class, RestConfigBean.class, - CoreConfigBean.class, AuthorizedRolesDto.class})) + RegistrationStatusBeanConfig.class, RestConfigBean.class, + CoreConfigBean.class, AuthorizedRolesDto.class, + PacketExternalStatusServiceImpl.class })) public class RegistrationStatusConfigTest { @Bean diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index fbfb4db0efb..e4cabb82e1b 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -46,19 +46,13 @@ 3.3.0 - 5.0.6.RELEASE - 5.0.4.RELEASE - 2.0.2.RELEASE - 2.0.9.RELEASE - 2.0.0.RELEASE + 3.2.3 - 4.0.1.RELEASE - 2.0.0.RELEASE 3.0.0 2.0.1.Final - 2.12.0 + 2.15.4 2.12.0 6.0.12.Final 2.1.1 @@ -352,6 +346,11 @@ pom import + + com.hazelcast + hazelcast + 3.9.4 + @@ -384,7 +383,19 @@ ${skipTests} false - ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --illegal-access=permit + ${argLine} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.net=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + --add-opens java.base/java.io=ALL-UNNAMED + --add-opens java.base/java.time=ALL-UNNAMED + --add-opens java.base/java.nio.charset=ALL-UNNAMED + --add-opens java.base/java.time.format=ALL-UNNAMED + --add-opens java.base/java.lang.reflect=ALL-UNNAMED + --add-opens java.base/sun.security.jca=ALL-UNNAMED + --add-opens java.base/sun.security.util=ALL-UNNAMED + --add-opens java.base/jdk.internal.util=ALL-UNNAMED + --illegal-access=permit diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml index af95750d0d1..79eb26018fc 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml @@ -16,11 +16,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core @@ -38,12 +33,10 @@ org.springframework spring-context - ${spring-framework.version} org.springframework spring-tx - ${spring-framework.version} io.vertx diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml index b02319b49d6..152f4b9e181 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml @@ -59,8 +59,8 @@ org.springdoc - springdoc-openapi-ui - 1.5.10 + springdoc-openapi-starter-webmvc-ui + 2.5.0 org.springframework.boot diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml index e90ebc709c4..5b3b5292180 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/pom.xml @@ -105,7 +105,7 @@ org.mvel mvel2 - 2.4.12.Final + 2.5.2.Final diff --git a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java index 6e366b277da..ae472336cea 100644 --- a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java +++ b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/test/java/io/mosip/registration/processor/securezone/notification/stage/SecurezoneNotificationStageTest.java @@ -346,6 +346,36 @@ public List acceptableLocales() { return null; } + @Override + public void fail(int statusCode, Throwable throwable) { + + } + + @Override + public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { + return null; + } + + @Override + public Map cookieMap() { + return null; + } + + @Override + public boolean isSessionAccessed() { + return false; + } + + @Override + public int addEndHandler(Handler> handler) { + return 0; + } + + @Override + public boolean removeEndHandler(int handlerID) { + return false; + } + }; } diff --git a/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml b/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml index a7d6ac3a871..e1fdee69460 100644 --- a/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml +++ b/registration-processor/pre-processor/registration-processor-supervisor-validator-stage/pom.xml @@ -17,11 +17,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/BaseQcuserEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/BaseQcuserEntity.java index fd41415f0ae..24aa03389e7 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/BaseQcuserEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/BaseQcuserEntity.java @@ -1,9 +1,9 @@ package io.mosip.registration.processor.qc.users.entity; -import javax.persistence.EmbeddedId; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.MappedSuperclass; @MappedSuperclass diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListEntity.java index 526caa48b73..ceb0446092d 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListEntity.java @@ -3,9 +3,9 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import org.hibernate.annotations.CreationTimestamp; diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListPKEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListPKEntity.java index 26126df6ee7..0679a23fde8 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListPKEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/RoleListPKEntity.java @@ -1,7 +1,7 @@ package io.mosip.registration.processor.qc.users.entity; import java.io.Serializable; -import javax.persistence.*; +import jakarta.persistence.*; /** * @author M1048399 diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailEntity.java index fb14ffced4d..5dcdb5c5595 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailEntity.java @@ -3,9 +3,9 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import org.hibernate.annotations.CreationTimestamp; diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailPKEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailPKEntity.java index a2874a85abb..1011700baf0 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailPKEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserDetailPKEntity.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import javax.persistence.Embeddable; +import jakarta.persistence.Embeddable; @Embeddable public class UserDetailPKEntity implements Serializable { diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRoleEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRoleEntity.java index a681b8b737e..a23d0316829 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRoleEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRoleEntity.java @@ -3,9 +3,9 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import org.hibernate.annotations.CreationTimestamp; diff --git a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRolePKEntity.java b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRolePKEntity.java index 2cbaf957749..31030996287 100644 --- a/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRolePKEntity.java +++ b/registration-processor/qc-users-manger/src/main/java/io/mosip/registration/processor/qc/users/entity/UserRolePKEntity.java @@ -1,7 +1,7 @@ package io.mosip.registration.processor.qc.users.entity; import java.io.Serializable; -import javax.persistence.*; +import jakarta.persistence.*; /** * @author M1048399 diff --git a/registration-processor/registration-processor-core/pom.xml b/registration-processor/registration-processor-core/pom.xml index 0c71d48ae35..84a04a80c1e 100644 --- a/registration-processor/registration-processor-core/pom.xml +++ b/registration-processor/registration-processor-core/pom.xml @@ -135,12 +135,10 @@ io.vertx vertx-config-spring-config-server - ${vertx.version} io.vertx vertx-unit - ${vertx.version} test @@ -165,7 +163,6 @@ io.micrometer micrometer-core - ${io.micrometer.prometheus.version} io.vertx @@ -175,12 +172,20 @@ io.micrometer micrometer-registry-prometheus - ${io.micrometer.prometheus.version} com.fasterxml.jackson.module jackson-module-afterburner + + io.vertx + vertx-core + ${vertx.version} + + + io.vertx + vertx-config + diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java index 6791a2d7a0a..c9ad2de5e5d 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java @@ -1,95 +1,95 @@ -package io.mosip.registration.processor.core.config.configserverloader; - -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.config.ConfigurationUtil; -import io.mosip.registration.processor.core.config.CoreConfigBean; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.vertx.config.ConfigRetriever; -import io.vertx.config.ConfigRetrieverOptions; -import io.vertx.config.ConfigStoreOptions; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.core.env.Environment; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -@PropertySource("classpath:bootstrap.properties") -@Configuration -public class PropertyLoaderConfig { - - private static Logger regProcLogger = RegProcessorLogger.getLogger(PropertyLoaderConfig.class); - - private enum HttpConstants { - HTTP("http://"), HTTPS("https://"); - - private String url; - - HttpConstants(String url) { - this.url = url; - } - - String getUrl() { - return url; - } - - } - - @Bean - public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Environment environment) throws InterruptedException { - try { - Vertx vertx = Vertx.vertx(); - List configStores = new ArrayList<>(); - List configUrls = CoreConfigBean.getUrls(environment); - configUrls.forEach(url -> { - if (url.startsWith(PropertyLoaderConfig.HttpConstants.HTTP.getUrl())) - configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) - .setConfig(new JsonObject().put("url", url).put("timeout", - Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)))); - else - configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) - .setConfig(new JsonObject().put("url", url) - .put("timeout", Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)) - .put("httpClientConfiguration", - new JsonObject().put("trustAll", true).put("ssl", true)))); - }); - ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions(); - configStores.forEach(configRetrieverOptions::addStore); - ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0)); - regProcLogger.info(this.getClass().getName(), "", "", "Getting values from config Server"); - CompletableFuture configLoader = new CompletableFuture(); - retriever.getConfig(json -> { - if (json.succeeded()) { - JsonObject jsonObject = json.result(); - if (jsonObject != null) { - jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(), - sourceValue.getValue().toString())); - } - configLoader.complete(json.result()); - json.mapEmpty(); - retriever.close(); - vertx.close(); - } else { - regProcLogger.info(this.getClass().getName(), "", json.cause().getLocalizedMessage(), - json.cause().getMessage()); - json.otherwiseEmpty(); - retriever.close(); - vertx.close(); - } - }); - configLoader.get(); - } catch (InterruptedException interruptedException) { - regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(interruptedException)); - throw interruptedException; - } catch (Exception exception) { - regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(exception)); - } - return new PropertySourcesPlaceholderConfigurer(); - } -} +package io.mosip.registration.processor.core.config.configserverloader; + +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.core.config.ConfigurationUtil; +import io.mosip.registration.processor.core.config.CoreConfigBean; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.vertx.config.ConfigRetriever; +import io.vertx.config.ConfigRetrieverOptions; +import io.vertx.config.ConfigStoreOptions; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.env.Environment; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; + +@PropertySource("classpath:bootstrap.properties") +@Configuration +public class PropertyLoaderConfig { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(PropertyLoaderConfig.class); + + private enum HttpConstants { + HTTP("http://"), HTTPS("https://"); + + private String url; + + HttpConstants(String url) { + this.url = url; + } + + String getUrl() { + return url; + } + + } + + /* @Bean + public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Environment environment) throws InterruptedException { + try { + Vertx vertx = Vertx.vertx(); + List configStores = new ArrayList<>(); + List configUrls = CoreConfigBean.getUrls(environment); + configUrls.forEach(url -> { + if (url.startsWith(PropertyLoaderConfig.HttpConstants.HTTP.getUrl())) + configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) + .setConfig(new JsonObject().put("url", url).put("timeout", + Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)))); + else + configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) + .setConfig(new JsonObject().put("url", url) + .put("timeout", Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)) + .put("httpClientConfiguration", + new JsonObject().put("trustAll", true).put("ssl", true)))); + }); + ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions(); + configStores.forEach(configRetrieverOptions::addStore); + ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0)); + regProcLogger.info(this.getClass().getName(), "", "", "Getting values from config Server"); + CompletableFuture configLoader = new CompletableFuture(); + retriever.getConfig(json -> { + if (json.succeeded()) { + JsonObject jsonObject = json.result(); + if (jsonObject != null) { + jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(), + sourceValue.getValue().toString())); + } + configLoader.complete(json.result()); + json.mapEmpty(); + retriever.close(); + vertx.close(); + } else { + regProcLogger.info(this.getClass().getName(), "", json.cause().getLocalizedMessage(), + json.cause().getMessage()); + json.otherwiseEmpty(); + retriever.close(); + vertx.close(); + } + }); + configLoader.get(); + } catch (InterruptedException interruptedException) { + regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(interruptedException)); + throw interruptedException; + } catch (Exception exception) { + regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(exception)); + } + return new PropertySourcesPlaceholderConfigurer(); + }*/ +} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/digital/signature/dto/SignRequestDto.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/digital/signature/dto/SignRequestDto.java index 9aa0ca8fbda..bb2c42ae315 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/digital/signature/dto/SignRequestDto.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/digital/signature/dto/SignRequestDto.java @@ -1,6 +1,6 @@ package io.mosip.registration.processor.core.digital.signature.dto; -import javax.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotBlank; import lombok.Data; diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/RequestWrapper.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/RequestWrapper.java index 12ff784f498..b9325bb72d2 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/RequestWrapper.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/RequestWrapper.java @@ -2,8 +2,8 @@ import java.time.LocalDateTime; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/ResponseWrapper.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/ResponseWrapper.java index 54517c42138..757a00a4e89 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/ResponseWrapper.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/http/ResponseWrapper.java @@ -5,8 +5,8 @@ import java.util.ArrayList; import java.util.List; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import com.fasterxml.jackson.annotation.JsonFormat; diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/kernel/master/dto/UserResponseDTO.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/kernel/master/dto/UserResponseDTO.java index 336df337323..63c796ebe3b 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/kernel/master/dto/UserResponseDTO.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/kernel/master/dto/UserResponseDTO.java @@ -1,33 +1,33 @@ -package io.mosip.registration.processor.core.kernel.master.dto; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; - -import lombok.Data; - -@Data -public class UserResponseDTO { - /** The id. */ - private String id; - - /** The lang code. */ - private String langCode; - - /** The uin. */ - private String uin; - - /** The name. */ - private String name; - - /** The email. */ - private String email; - - /** The mobile. */ - private String mobile; - - /** The status code. */ - private String statusCode; - - /** The is active. */ - private Boolean isActive; +package io.mosip.registration.processor.core.kernel.master.dto; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; + +import lombok.Data; + +@Data +public class UserResponseDTO { + /** The id. */ + private String id; + + /** The lang code. */ + private String langCode; + + /** The uin. */ + private String uin; + + /** The name. */ + private String name; + + /** The email. */ + private String email; + + /** The mobile. */ + private String mobile; + + /** The status code. */ + private String statusCode; + + /** The is active. */ + private Boolean isActive; } \ No newline at end of file diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/PageResponseDTO.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/PageResponseDTO.java index 1b4c2770157..b3d8167eb19 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/PageResponseDTO.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/PageResponseDTO.java @@ -1,20 +1,20 @@ -package io.mosip.registration.processor.core.workflow.dto; - -import java.util.List; - -import javax.validation.Valid; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@AllArgsConstructor -@NoArgsConstructor -public class PageResponseDTO { - private long fromRecord; - private long toRecord; - private long totalRecord; - @Valid - private List data; -} +package io.mosip.registration.processor.core.workflow.dto; + +import java.util.List; + +import jakarta.validation.Valid; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PageResponseDTO { + private long fromRecord; + private long toRecord; + private long totalRecord; + @Valid + private List data; +} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/SearchInfo.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/SearchInfo.java index 7cad7fb0e46..1265de2afb4 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/SearchInfo.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/workflow/dto/SearchInfo.java @@ -1,34 +1,34 @@ -package io.mosip.registration.processor.core.workflow.dto; - -import java.util.List; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Dto to hold the search criteria. - * - * @author Abhishek Kumar - * @since 1.0.0 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SearchInfo { - - @NotNull - @Valid - private List filters; - - @NotNull - private SortInfo sort; - - // @NotNull - private PaginationInfo pagination; - - // private String languageCode; -} +package io.mosip.registration.processor.core.workflow.dto; + +import java.util.List; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Dto to hold the search criteria. + * + * @author Abhishek Kumar + * @since 1.0.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SearchInfo { + + @NotNull + @Valid + private List filters; + + @NotNull + private SortInfo sort; + + // @NotNull + private PaginationInfo pagination; + + // private String languageCode; +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationEntity.java index 148c42c20f2..30b9b22f030 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationEntity.java @@ -1,138 +1,138 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * The persistent class for the abis_application database table. - * - */ -@Entity -@Table(name = "abis_application", schema = "regprc") -public class AbisApplicationEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "cr_by", nullable = false) - private String crBy = "SYSTEM"; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - private String descr; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - private String name; - - @Column(name = "status_code") - private String statusCode; - - @Column(name = "status_update_dtimes") - private LocalDateTime statusUpdateDtimes; - - @Column(name = "upd_by") - private String updBy = "MOSIP_SYSTEM"; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - public AbisApplicationEntity() { - } - - public AbisApplicationPKEntity getId() { - return this.id; - } - - public void setId(AbisApplicationPKEntity id) { - this.id = id; - } - - public String getCrBy() { - return this.crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return this.crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public LocalDateTime getDelDtimes() { - return this.delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public String getDescr() { - return this.descr; - } - - public void setDescr(String descr) { - this.descr = descr; - } - - public Boolean getIsDeleted() { - return this.isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public String getStatusCode() { - return this.statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public LocalDateTime getStatusUpdateDtimes() { - return this.statusUpdateDtimes; - } - - public void setStatusUpdateDtimes(LocalDateTime statusUpdateDtimes) { - this.statusUpdateDtimes = statusUpdateDtimes; - } - - public String getUpdBy() { - return this.updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return this.updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * The persistent class for the abis_application database table. + * + */ +@Entity +@Table(name = "abis_application", schema = "regprc") +public class AbisApplicationEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "cr_by", nullable = false) + private String crBy = "SYSTEM"; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + private String descr; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + private String name; + + @Column(name = "status_code") + private String statusCode; + + @Column(name = "status_update_dtimes") + private LocalDateTime statusUpdateDtimes; + + @Column(name = "upd_by") + private String updBy = "MOSIP_SYSTEM"; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + public AbisApplicationEntity() { + } + + public AbisApplicationPKEntity getId() { + return this.id; + } + + public void setId(AbisApplicationPKEntity id) { + this.id = id; + } + + public String getCrBy() { + return this.crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return this.crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public LocalDateTime getDelDtimes() { + return this.delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public String getDescr() { + return this.descr; + } + + public void setDescr(String descr) { + this.descr = descr; + } + + public Boolean getIsDeleted() { + return this.isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStatusCode() { + return this.statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public LocalDateTime getStatusUpdateDtimes() { + return this.statusUpdateDtimes; + } + + public void setStatusUpdateDtimes(LocalDateTime statusUpdateDtimes) { + this.statusUpdateDtimes = statusUpdateDtimes; + } + + public String getUpdBy() { + return this.updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return this.updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationPKEntity.java index f7ef48824bd..ea31b5708ff 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisApplicationPKEntity.java @@ -1,58 +1,58 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * The primary key class for the abis_application database table. - * - */ -@Embeddable -public class AbisApplicationPKEntity implements Serializable { - //default serial version id, required for serializable classes. - private static final long serialVersionUID = 1L; - - private String code; - - @Column(name="lang_code") - private String langCode; - - public AbisApplicationPKEntity() { - } - public String getCode() { - return this.code; - } - public void setCode(String code) { - this.code = code; - } - public String getLangCode() { - return this.langCode; - } - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (!(other instanceof AbisApplicationPKEntity)) { - return false; - } - AbisApplicationPKEntity castOther = (AbisApplicationPKEntity)other; - return - this.code.equals(castOther.code) - && this.langCode.equals(castOther.langCode); - } - - public int hashCode() { - final int prime = 31; - int hash = 17; - hash = hash * prime + this.code.hashCode(); - hash = hash * prime + this.langCode.hashCode(); - - return hash; - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +/** + * The primary key class for the abis_application database table. + * + */ +@Embeddable +public class AbisApplicationPKEntity implements Serializable { + //default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + + private String code; + + @Column(name="lang_code") + private String langCode; + + public AbisApplicationPKEntity() { + } + public String getCode() { + return this.code; + } + public void setCode(String code) { + this.code = code; + } + public String getLangCode() { + return this.langCode; + } + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof AbisApplicationPKEntity)) { + return false; + } + AbisApplicationPKEntity castOther = (AbisApplicationPKEntity)other; + return + this.code.equals(castOther.code) + && this.langCode.equals(castOther.langCode); + } + + public int hashCode() { + final int prime = 31; + int hash = 17; + hash = hash * prime + this.code.hashCode(); + hash = hash * prime + this.langCode.hashCode(); + + return hash; + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestEntity.java index b1f8e0e60bb..8374bf366ab 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestEntity.java @@ -1,204 +1,204 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.Arrays; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * The persistent class for the abis_request database table. - * - */ -@Entity -@Table(name = "abis_request", schema = "regprc") -public class AbisRequestEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "abis_app_code") - private String abisAppCode; - - @Column(name = "bio_ref_id") - private String bioRefId; - - @Column(name = "cr_by") - private String crBy; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "lang_code") - private String langCode; - - @Column(name = "ref_regtrn_id") - private String refRegtrnId; - - @Column(name = "req_batch_id") - private String reqBatchId; - - @Column(name = "req_text") - private byte[] reqText; - - @Column(name = "request_dtimes") - private LocalDateTime requestDtimes; - - @Column(name = "request_type") - private String requestType; - - @Column(name = "status_code") - private String statusCode; - - @Column(name = "status_comment") - private String statusComment; - - @Column(name = "upd_by") - private String updBy; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - public AbisRequestEntity() { - - } - - public String getAbisAppCode() { - return this.abisAppCode; - } - - public void setAbisAppCode(String abisAppCode) { - this.abisAppCode = abisAppCode; - } - - public String getBioRefId() { - return this.bioRefId; - } - - public void setBioRefId(String bioRefId) { - this.bioRefId = bioRefId; - } - - public String getCrBy() { - return this.crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return this.crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public LocalDateTime getDelDtimes() { - return this.delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public Boolean getIsDeleted() { - return this.isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public String getLangCode() { - return this.langCode; - } - - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - public String getRefRegtrnId() { - return this.refRegtrnId; - } - - public void setRefRegtrnId(String refRegtrnId) { - this.refRegtrnId = refRegtrnId; - } - - public String getReqBatchId() { - return this.reqBatchId; - } - - public void setReqBatchId(String reqBatchId) { - this.reqBatchId = reqBatchId; - } - - public byte[] getReqText() { - if (reqText != null) { - return Arrays.copyOf(reqText, reqText.length); - } else { - return null; - } - } - - public void setReqText(byte[] reqText) { - this.reqText = reqText != null ? reqText : null; - } - - public LocalDateTime getRequestDtimes() { - return this.requestDtimes; - } - - public void setRequestDtimes(LocalDateTime requestDtimes) { - this.requestDtimes = requestDtimes; - } - - public String getRequestType() { - return this.requestType; - } - - public void setRequestType(String requestType) { - this.requestType = requestType; - } - - public String getStatusCode() { - return this.statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public String getStatusComment() { - return this.statusComment; - } - - public void setStatusComment(String statusComment) { - this.statusComment = statusComment; - } - - public String getUpdBy() { - return this.updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return this.updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Arrays; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * The persistent class for the abis_request database table. + * + */ +@Entity +@Table(name = "abis_request", schema = "regprc") +public class AbisRequestEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "abis_app_code") + private String abisAppCode; + + @Column(name = "bio_ref_id") + private String bioRefId; + + @Column(name = "cr_by") + private String crBy; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "lang_code") + private String langCode; + + @Column(name = "ref_regtrn_id") + private String refRegtrnId; + + @Column(name = "req_batch_id") + private String reqBatchId; + + @Column(name = "req_text") + private byte[] reqText; + + @Column(name = "request_dtimes") + private LocalDateTime requestDtimes; + + @Column(name = "request_type") + private String requestType; + + @Column(name = "status_code") + private String statusCode; + + @Column(name = "status_comment") + private String statusComment; + + @Column(name = "upd_by") + private String updBy; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + public AbisRequestEntity() { + + } + + public String getAbisAppCode() { + return this.abisAppCode; + } + + public void setAbisAppCode(String abisAppCode) { + this.abisAppCode = abisAppCode; + } + + public String getBioRefId() { + return this.bioRefId; + } + + public void setBioRefId(String bioRefId) { + this.bioRefId = bioRefId; + } + + public String getCrBy() { + return this.crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return this.crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public LocalDateTime getDelDtimes() { + return this.delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public Boolean getIsDeleted() { + return this.isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getLangCode() { + return this.langCode; + } + + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + public String getRefRegtrnId() { + return this.refRegtrnId; + } + + public void setRefRegtrnId(String refRegtrnId) { + this.refRegtrnId = refRegtrnId; + } + + public String getReqBatchId() { + return this.reqBatchId; + } + + public void setReqBatchId(String reqBatchId) { + this.reqBatchId = reqBatchId; + } + + public byte[] getReqText() { + if (reqText != null) { + return Arrays.copyOf(reqText, reqText.length); + } else { + return null; + } + } + + public void setReqText(byte[] reqText) { + this.reqText = reqText != null ? reqText : null; + } + + public LocalDateTime getRequestDtimes() { + return this.requestDtimes; + } + + public void setRequestDtimes(LocalDateTime requestDtimes) { + this.requestDtimes = requestDtimes; + } + + public String getRequestType() { + return this.requestType; + } + + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + public String getStatusCode() { + return this.statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public String getStatusComment() { + return this.statusComment; + } + + public void setStatusComment(String statusComment) { + this.statusComment = statusComment; + } + + public String getUpdBy() { + return this.updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return this.updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestPKEntity.java index a2b4e354af4..5f439293623 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisRequestPKEntity.java @@ -1,50 +1,50 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class AbisRequestPKEntity implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - @Column(name = "id") - private String id; - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AbisRequestPKEntity other = (AbisRequestPKEntity) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class AbisRequestPKEntity implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + @Column(name = "id") + private String id; + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AbisRequestPKEntity other = (AbisRequestPKEntity) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetEntity.java index e0f9a0a9e7f..d24d153976c 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetEntity.java @@ -3,10 +3,10 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; @Entity @Table(name = "abis_response_det", schema = "regprc") diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetPKEntity.java index 18e7456dd22..f1a6c90f715 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseDetPKEntity.java @@ -1,57 +1,57 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class AbisResponseDetPKEntity implements Serializable { - // default serial version id, required for serializable classes. - private static final long serialVersionUID = 1L; - - @Column(name = "matched_bio_ref_id") - private String matchedBioRefId; - - @Column(name = "abis_resp_id", insertable = false, updatable = false) - private String abisRespId; - - public AbisResponseDetPKEntity() { - } - - public String getMatchedBioRefId() { - return this.matchedBioRefId; - } - - public void setMatchedBioRefId(String matchedBioRefId) { - this.matchedBioRefId = matchedBioRefId; - } - - public String getAbisRespId() { - return this.abisRespId; - } - - public void setAbisRespId(String abisRespId) { - this.abisRespId = abisRespId; - } - - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (!(other instanceof AbisResponseDetPKEntity)) { - return false; - } - AbisResponseDetPKEntity castOther = (AbisResponseDetPKEntity) other; - return this.matchedBioRefId.equals(castOther.matchedBioRefId) && this.abisRespId.equals(castOther.abisRespId); - } - - public int hashCode() { - final int prime = 31; - int hash = 17; - hash = hash * prime + this.matchedBioRefId.hashCode(); - hash = hash * prime + this.abisRespId.hashCode(); - - return hash; - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class AbisResponseDetPKEntity implements Serializable { + // default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + + @Column(name = "matched_bio_ref_id") + private String matchedBioRefId; + + @Column(name = "abis_resp_id", insertable = false, updatable = false) + private String abisRespId; + + public AbisResponseDetPKEntity() { + } + + public String getMatchedBioRefId() { + return this.matchedBioRefId; + } + + public void setMatchedBioRefId(String matchedBioRefId) { + this.matchedBioRefId = matchedBioRefId; + } + + public String getAbisRespId() { + return this.abisRespId; + } + + public void setAbisRespId(String abisRespId) { + this.abisRespId = abisRespId; + } + + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof AbisResponseDetPKEntity)) { + return false; + } + AbisResponseDetPKEntity castOther = (AbisResponseDetPKEntity) other; + return this.matchedBioRefId.equals(castOther.matchedBioRefId) && this.abisRespId.equals(castOther.abisRespId); + } + + public int hashCode() { + final int prime = 31; + int hash = 17; + hash = hash * prime + this.matchedBioRefId.hashCode(); + hash = hash * prime + this.abisRespId.hashCode(); + + return hash; + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseEntity.java index be4797c80a8..46eece12994 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponseEntity.java @@ -1,155 +1,155 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * The persistent class for the abis_response database table. - * - */ -@Entity -@Table(name = "abis_response", schema = "regprc") -public class AbisResponseEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "cr_by") - private String crBy; - - @Column(name = "cr_dtimes", updatable = false) - - private LocalDateTime crDtimes; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "lang_code") - private String langCode; - - @Column(name = "resp_dtimes") - private LocalDateTime respDtimes; - - @Column(name = "resp_text") - private byte[] respText; - - @Column(name = "status_code") - private String statusCode; - - @Column(name = "status_comment") - private String statusComment; - - @Column(name = "upd_by") - private String updBy; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - @Column(name = "abis_req_id") - private String abisRequest; - - public AbisResponseEntity() { - } - - public String getCrBy() { - return this.crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return this.crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public LocalDateTime getDelDtimes() { - return this.delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public Boolean getIsDeleted() { - return this.isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public String getLangCode() { - return this.langCode; - } - - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - public LocalDateTime getRespDtimes() { - return this.respDtimes; - } - - public void setRespDtimes(LocalDateTime respDtimes) { - this.respDtimes = respDtimes; - } - - public byte[] getRespText() { - return respText.clone(); - } - - public void setRespText(byte[] respText) { - this.respText = respText != null ? respText : null; - } - - public String getStatusCode() { - return this.statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public String getStatusComment() { - return this.statusComment; - } - - public void setStatusComment(String statusComment) { - this.statusComment = statusComment; - } - - public String getUpdBy() { - return this.updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return this.updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - - public String getAbisRequest() { - return this.abisRequest; - } - - public void setAbisRequest(String abisRequest) { - this.abisRequest = abisRequest; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * The persistent class for the abis_response database table. + * + */ +@Entity +@Table(name = "abis_response", schema = "regprc") +public class AbisResponseEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "cr_by") + private String crBy; + + @Column(name = "cr_dtimes", updatable = false) + + private LocalDateTime crDtimes; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "lang_code") + private String langCode; + + @Column(name = "resp_dtimes") + private LocalDateTime respDtimes; + + @Column(name = "resp_text") + private byte[] respText; + + @Column(name = "status_code") + private String statusCode; + + @Column(name = "status_comment") + private String statusComment; + + @Column(name = "upd_by") + private String updBy; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + @Column(name = "abis_req_id") + private String abisRequest; + + public AbisResponseEntity() { + } + + public String getCrBy() { + return this.crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return this.crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public LocalDateTime getDelDtimes() { + return this.delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public Boolean getIsDeleted() { + return this.isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getLangCode() { + return this.langCode; + } + + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + public LocalDateTime getRespDtimes() { + return this.respDtimes; + } + + public void setRespDtimes(LocalDateTime respDtimes) { + this.respDtimes = respDtimes; + } + + public byte[] getRespText() { + return respText.clone(); + } + + public void setRespText(byte[] respText) { + this.respText = respText != null ? respText : null; + } + + public String getStatusCode() { + return this.statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public String getStatusComment() { + return this.statusComment; + } + + public void setStatusComment(String statusComment) { + this.statusComment = statusComment; + } + + public String getUpdBy() { + return this.updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return this.updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + + public String getAbisRequest() { + return this.abisRequest; + } + + public void setAbisRequest(String abisRequest) { + this.abisRequest = abisRequest; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponsePKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponsePKEntity.java index f7dacf23161..6c63bb07de2 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponsePKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/AbisResponsePKEntity.java @@ -1,51 +1,51 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class AbisResponsePKEntity implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - @Column(name = "id") - private String id; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - AbisResponsePKEntity other = (AbisResponsePKEntity) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - return true; - } - -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class AbisResponsePKEntity implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + @Column(name = "id") + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AbisResponsePKEntity other = (AbisResponsePKEntity) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/BasePacketEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/BasePacketEntity.java index 84923b5d57c..bf91f9552b9 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/BasePacketEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/BasePacketEntity.java @@ -1,9 +1,9 @@ package io.mosip.registration.processor.packet.storage.entity; -import javax.persistence.EmbeddedId; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.MappedSuperclass; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.MappedSuperclass; /** * The Class BasePacketEntity. diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupeEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupeEntity.java index df1ab49e9aa..0d7e9da44c0 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupeEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupeEntity.java @@ -1,241 +1,241 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * - * @author Girish Yarru - * - */ -@Entity -@Table(name = "individual_demographic_dedup", schema = "regprc") -public class IndividualDemographicDedupeEntity extends BasePacketEntity - implements Serializable { - private static final long serialVersionUID = 1L; - - /** The reg id. */ - @Column(name = "reg_id", nullable = false) - private String regId; - - - @Column(name = "process") - private String process; - - @Column(name = "iteration") - private Integer iteration; - - @Column(name = "name") - private String name; - - @Column(name = "dob") - private String dob; - - @Column(name = "gender") - private String gender; - - @Column(name = "mobile_number") - private String phone; - - @Column(name = "email") - private String email; - - @Column(name = "pincode") - private String postalCode; - - @Column(name = "is_active") - private Boolean isActive; - - @Column(name = "cr_by", nullable = false) - private String crBy = "SYSTEM"; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "upd_by") - private String updBy = "MOSIP_SYSTEM"; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - public IndividualDemographicDedupeEntity() { - super(); - } - - /** - * Gets the reg id. - * - * @return the reg id - */ - public String getRegId() { - return this.regId; - } - - /** - * Sets the reg id. - * - * @param regId the new reg id - */ - public void setRegId(String regId) { - this.regId = regId; - } - - public String getName() { - return name; - } - - public void setName(String fullName) { - this.name = fullName; - } - - public String getDob() { - return dob; // new Date(dob.getTime()); - } - - public void setDob(String dob) { - this.dob = dob; // new Date(dob.getTime()); - } - - public String getGender() { - return gender; - } - - public void setGender(String genderCode) { - this.gender = genderCode; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPostalCode() { - return postalCode; - } - - public void setPostalCode(String postalCode) { - this.postalCode = postalCode; - } - - public Boolean getIsActive() { - return isActive; - } - - public void setIsActive(Boolean isActive) { - this.isActive = isActive; - } - - public String getCrBy() { - return crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public String getUpdBy() { - return updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - - public Boolean getIsDeleted() { - return isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public LocalDateTime getDelDtimes() { - return delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public String getProcess() { - return process; - } - - public void setProcess(String process) { - this.process = process; - } - - public Integer getIteration() { - return iteration; - } - - public void setIteration(Integer iteration) { - this.iteration = iteration; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IndividualDemographicDedupeEntity that = (IndividualDemographicDedupeEntity) o; - return Objects.equals(regId, that.regId) && - Objects.equals(process, that.process) && - Objects.equals(iteration, that.iteration) && - Objects.equals(name, that.name) && - Objects.equals(dob, that.dob) && - Objects.equals(gender, that.gender) && - Objects.equals(phone, that.phone) && - Objects.equals(email, that.email) && - Objects.equals(postalCode, that.postalCode) && - Objects.equals(isActive, that.isActive) && - Objects.equals(crBy, that.crBy) && - Objects.equals(crDtimes, that.crDtimes) && - Objects.equals(updBy, that.updBy) && - Objects.equals(updDtimes, that.updDtimes) && - Objects.equals(isDeleted, that.isDeleted) && - Objects.equals(delDtimes, that.delDtimes); - } - - @Override - public int hashCode() { - return Objects.hash(regId, process, iteration, name, dob, gender, phone, email, postalCode, isActive, crBy, crDtimes, updBy, updDtimes, isDeleted, delDtimes); - } -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * + * @author Girish Yarru + * + */ +@Entity +@Table(name = "individual_demographic_dedup", schema = "regprc") +public class IndividualDemographicDedupeEntity extends BasePacketEntity + implements Serializable { + private static final long serialVersionUID = 1L; + + /** The reg id. */ + @Column(name = "reg_id", nullable = false) + private String regId; + + + @Column(name = "process") + private String process; + + @Column(name = "iteration") + private Integer iteration; + + @Column(name = "name") + private String name; + + @Column(name = "dob") + private String dob; + + @Column(name = "gender") + private String gender; + + @Column(name = "mobile_number") + private String phone; + + @Column(name = "email") + private String email; + + @Column(name = "pincode") + private String postalCode; + + @Column(name = "is_active") + private Boolean isActive; + + @Column(name = "cr_by", nullable = false) + private String crBy = "SYSTEM"; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "upd_by") + private String updBy = "MOSIP_SYSTEM"; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + public IndividualDemographicDedupeEntity() { + super(); + } + + /** + * Gets the reg id. + * + * @return the reg id + */ + public String getRegId() { + return this.regId; + } + + /** + * Sets the reg id. + * + * @param regId the new reg id + */ + public void setRegId(String regId) { + this.regId = regId; + } + + public String getName() { + return name; + } + + public void setName(String fullName) { + this.name = fullName; + } + + public String getDob() { + return dob; // new Date(dob.getTime()); + } + + public void setDob(String dob) { + this.dob = dob; // new Date(dob.getTime()); + } + + public String getGender() { + return gender; + } + + public void setGender(String genderCode) { + this.gender = genderCode; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public String getCrBy() { + return crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public String getUpdBy() { + return updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + + public Boolean getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public LocalDateTime getDelDtimes() { + return delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public String getProcess() { + return process; + } + + public void setProcess(String process) { + this.process = process; + } + + public Integer getIteration() { + return iteration; + } + + public void setIteration(Integer iteration) { + this.iteration = iteration; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IndividualDemographicDedupeEntity that = (IndividualDemographicDedupeEntity) o; + return Objects.equals(regId, that.regId) && + Objects.equals(process, that.process) && + Objects.equals(iteration, that.iteration) && + Objects.equals(name, that.name) && + Objects.equals(dob, that.dob) && + Objects.equals(gender, that.gender) && + Objects.equals(phone, that.phone) && + Objects.equals(email, that.email) && + Objects.equals(postalCode, that.postalCode) && + Objects.equals(isActive, that.isActive) && + Objects.equals(crBy, that.crBy) && + Objects.equals(crDtimes, that.crDtimes) && + Objects.equals(updBy, that.updBy) && + Objects.equals(updDtimes, that.updDtimes) && + Objects.equals(isDeleted, that.isDeleted) && + Objects.equals(delDtimes, that.delDtimes); + } + + @Override + public int hashCode() { + return Objects.hash(regId, process, iteration, name, dob, gender, phone, email, postalCode, isActive, crBy, crDtimes, updBy, updDtimes, isDeleted, delDtimes); + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupePKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupePKEntity.java index 0c17783bd64..28e9795f90f 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupePKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/IndividualDemographicDedupePKEntity.java @@ -1,74 +1,74 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * The Class IndividualDemographicDedupePKEntity. - * - * @author Girish Yarru - */ -@Embeddable -public class IndividualDemographicDedupePKEntity implements Serializable { - - /** The Constant serialVersionUID. */ - // default serial version id, required for serializable classes. - private static final long serialVersionUID = 1L; - - /** The lang code. */ - @Column(name = "lang_code", nullable = false) - private String langCode; - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - /** - * Instantiates a new individual demographic dedupe PK entity. - */ - public IndividualDemographicDedupePKEntity() { - super(); - } - - /** - * Gets the lang code. - * - * @return the lang code - */ - public String getLangCode() { - return this.langCode; - } - - /** - * Sets the lang code. - * - * @param langCode the new lang code - */ - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IndividualDemographicDedupePKEntity that = (IndividualDemographicDedupePKEntity) o; - return Objects.equals(langCode, that.langCode) && - Objects.equals(workflowInstanceId, that.workflowInstanceId); - } - - @Override - public int hashCode() { - return Objects.hash(langCode, workflowInstanceId); - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +/** + * The Class IndividualDemographicDedupePKEntity. + * + * @author Girish Yarru + */ +@Embeddable +public class IndividualDemographicDedupePKEntity implements Serializable { + + /** The Constant serialVersionUID. */ + // default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + + /** The lang code. */ + @Column(name = "lang_code", nullable = false) + private String langCode; + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + /** + * Instantiates a new individual demographic dedupe PK entity. + */ + public IndividualDemographicDedupePKEntity() { + super(); + } + + /** + * Gets the lang code. + * + * @return the lang code + */ + public String getLangCode() { + return this.langCode; + } + + /** + * Sets the lang code. + * + * @param langCode the new lang code + */ + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + IndividualDemographicDedupePKEntity that = (IndividualDemographicDedupePKEntity) o; + return Objects.equals(langCode, that.langCode) && + Objects.equals(workflowInstanceId, that.workflowInstanceId); + } + + @Override + public int hashCode() { + return Objects.hash(langCode, workflowInstanceId); + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationEntity.java index 9f1bb5a82f5..c06357b061d 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationEntity.java @@ -1,418 +1,418 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.sql.Timestamp; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.persistence.Transient; - -/** - * The persistent class for the reg_manual_verification database table. - * - * @author Shuchita - * @since 0.0.1 - * - */ -@Entity -@Table(name = "reg_manual_verification", schema = "regprc") -public class ManualVerificationEntity extends BasePacketEntity implements Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The reg id. */ - @Column(name = "reg_id") - private String regId; - - /** The cr by. */ - @Column(name = "cr_by") - private String crBy; - - /** The cr dtimes. */ - @Column(name = "cr_dtimes", updatable = false) - private Timestamp crDtimes; - - /** The del dtimes. */ - @Column(name = "del_dtimes") - private Timestamp delDtimes; - - /** The is active. */ - @Column(name = "is_active") - private Boolean isActive; - - /** The is deleted. */ - @Column(name = "is_deleted") - private Boolean isDeleted; - - /** The lang code. */ - @Column(name = "lang_code") - private String langCode; - - /** The matched score. */ - //@Column(name = "matched_score") - //private BigDecimal matchedScore; - - /** The mv usr id. */ - @Column(name = "mv_usr_id") - private String mvUsrId; - - /** The reason code. */ - @Column(name = "reason_code") - private String reasonCode; - - /** The status code. */ - @Column(name = "status_code") - private String statusCode; - - /** The status comment. */ - @Column(name = "status_comment") - private String statusComment; - - /** The upd by. */ - @Column(name = "upd_by") - private String updBy; - - /** The upd dtimes. */ - @Column(name = "upd_dtimes") - private Timestamp updDtimes; - - /** The dedupe source name. */ - @Column(name = "trntyp_code") - private String trnTypCode; - - - @Column(name="ref_regtrn_id",nullable = true) - private String transactionId; - - - @Column(name="request_id",nullable = true) - private String requestId; - - - @Column(name="res_text",nullable = true) - private byte[] reponseText; - - /** - * Gets the reg id. - * - * @return the regId - */ - public String getRegId() { - return regId; - } - - /** - * Sets the reg id. - * - * @param regId the regId to set - */ - public void setRegId(String regId) { - this.regId = regId; - } - - /** - * Gets the source name. - * - * @return the source name. - */ - - public String getTrnTypCode() { - return trnTypCode; - } - - public void setTrnTypCode(String trnTypCode) { - this.trnTypCode = trnTypCode; - } - - /** - * Instantiates a new manual verification entity. - */ - public ManualVerificationEntity() { - super(); - } - - /** - * Gets the cr by. - * - * @return the crBy - */ - public String getCrBy() { - return crBy; - } - - /** - * Sets the cr by. - * - * @param crBy - * the crBy to set - */ - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - /** - * Gets the cr dtimes. - * - * @return the crDtimes - */ - public Timestamp getCrDtimes() { - return new Timestamp(crDtimes.getTime()); - } - - /** - * Sets the cr dtimes. - * - * @param crDtimes - * the crDtimes to set - */ - public void setCrDtimes(Timestamp crDtimes) { - this.crDtimes = new Timestamp(crDtimes.getTime()); - } - - /** - * Gets the del dtimes. - * - * @return the delDtimes - */ - public Timestamp getDelDtimes() { - return new Timestamp(delDtimes.getTime()); - } - - /** - * Sets the del dtimes. - * - * @param delDtimes - * the delDtimes to set - */ - public void setDelDtimes(Timestamp delDtimes) { - this.delDtimes = new Timestamp(delDtimes.getTime()); - } - - /** - * Gets the checks if is active. - * - * @return the isActive - */ - public Boolean getIsActive() { - return isActive; - } - - /** - * Sets the checks if is active. - * - * @param isActive - * the isActive to set - */ - public void setIsActive(Boolean isActive) { - this.isActive = isActive; - } - - /** - * Gets the checks if is deleted. - * - * @return the isDeleted - */ - public Boolean getIsDeleted() { - return isDeleted; - } - - /** - * Sets the checks if is deleted. - * - * @param isDeleted - * the isDeleted to set - */ - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - /** - * Gets the lang code. - * - * @return the langCode - */ - public String getLangCode() { - return langCode; - } - - /** - * Sets the lang code. - * - * @param langCode - * the langCode to set - */ - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - /** - * Gets the matched score. - * - * @return the matchedScore - */ - /*public BigDecimal getMatchedScore() { - return matchedScore; - }*/ - - /** - * Sets the matched score. - * - * @param matchedScore - * the matchedScore to set - */ - /*public void setMatchedScore(BigDecimal matchedScore) { - this.matchedScore = matchedScore; - }*/ - - /** - * Gets the mv usr id. - * - * @return the mvUsrId - */ - public String getMvUsrId() { - return mvUsrId; - } - - /** - * Sets the mv usr id. - * - * @param mvUsrId - * the mvUsrId to set - */ - public void setMvUsrId(String mvUsrId) { - this.mvUsrId = mvUsrId; - } - - /** - * Gets the reason code. - * - * @return the reasonCode - */ - public String getReasonCode() { - return reasonCode; - } - - /** - * Sets the reason code. - * - * @param reasonCode - * the reasonCode to set - */ - public void setReasonCode(String reasonCode) { - this.reasonCode = reasonCode; - } - - /** - * Gets the status code. - * - * @return the statusCode - */ - public String getStatusCode() { - return statusCode; - } - - /** - * Sets the status code. - * - * @param statusCode - * the statusCode to set - */ - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - /** - * Gets the status comment. - * - * @return the statusComment - */ - public String getStatusComment() { - return statusComment; - } - - /** - * Sets the status comment. - * - * @param statusComment - * the statusComment to set - */ - public void setStatusComment(String statusComment) { - this.statusComment = statusComment; - } - - /** - * Gets the upd by. - * - * @return the updBy - */ - public String getUpdBy() { - return updBy; - } - - /** - * Sets the upd by. - * - * @param updBy - * the updBy to set - */ - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - /** - * Gets the upd dtimes. - * - * @return the updDtimes - */ - public Timestamp getUpdDtimes() { - return new Timestamp(updDtimes.getTime()); - } - - /** - * Sets the upd dtimes. - * - * @param updDtimes - * the updDtimes to set - */ - public void setUpdDtimes(Timestamp updDtimes) { - this.updDtimes = new Timestamp(updDtimes.getTime()); - } - - /** - * Gets the serialversionuid. - * - * @return the serialversionuid - */ - public static long getSerialversionuid() { - return serialVersionUID; - } - - public String getTransactionId() { - return transactionId; - } - - public void setTransactionId(String transactionId) { - this.transactionId = transactionId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public byte[] getReponseText() { - return reponseText; - } - - public void setReponseText(byte[] reponseText) { - this.reponseText = reponseText; - } - - -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; + +/** + * The persistent class for the reg_manual_verification database table. + * + * @author Shuchita + * @since 0.0.1 + * + */ +@Entity +@Table(name = "reg_manual_verification", schema = "regprc") +public class ManualVerificationEntity extends BasePacketEntity implements Serializable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** The reg id. */ + @Column(name = "reg_id") + private String regId; + + /** The cr by. */ + @Column(name = "cr_by") + private String crBy; + + /** The cr dtimes. */ + @Column(name = "cr_dtimes", updatable = false) + private Timestamp crDtimes; + + /** The del dtimes. */ + @Column(name = "del_dtimes") + private Timestamp delDtimes; + + /** The is active. */ + @Column(name = "is_active") + private Boolean isActive; + + /** The is deleted. */ + @Column(name = "is_deleted") + private Boolean isDeleted; + + /** The lang code. */ + @Column(name = "lang_code") + private String langCode; + + /** The matched score. */ + //@Column(name = "matched_score") + //private BigDecimal matchedScore; + + /** The mv usr id. */ + @Column(name = "mv_usr_id") + private String mvUsrId; + + /** The reason code. */ + @Column(name = "reason_code") + private String reasonCode; + + /** The status code. */ + @Column(name = "status_code") + private String statusCode; + + /** The status comment. */ + @Column(name = "status_comment") + private String statusComment; + + /** The upd by. */ + @Column(name = "upd_by") + private String updBy; + + /** The upd dtimes. */ + @Column(name = "upd_dtimes") + private Timestamp updDtimes; + + /** The dedupe source name. */ + @Column(name = "trntyp_code") + private String trnTypCode; + + + @Column(name="ref_regtrn_id",nullable = true) + private String transactionId; + + + @Column(name="request_id",nullable = true) + private String requestId; + + + @Column(name="res_text",nullable = true) + private byte[] reponseText; + + /** + * Gets the reg id. + * + * @return the regId + */ + public String getRegId() { + return regId; + } + + /** + * Sets the reg id. + * + * @param regId the regId to set + */ + public void setRegId(String regId) { + this.regId = regId; + } + + /** + * Gets the source name. + * + * @return the source name. + */ + + public String getTrnTypCode() { + return trnTypCode; + } + + public void setTrnTypCode(String trnTypCode) { + this.trnTypCode = trnTypCode; + } + + /** + * Instantiates a new manual verification entity. + */ + public ManualVerificationEntity() { + super(); + } + + /** + * Gets the cr by. + * + * @return the crBy + */ + public String getCrBy() { + return crBy; + } + + /** + * Sets the cr by. + * + * @param crBy + * the crBy to set + */ + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + /** + * Gets the cr dtimes. + * + * @return the crDtimes + */ + public Timestamp getCrDtimes() { + return new Timestamp(crDtimes.getTime()); + } + + /** + * Sets the cr dtimes. + * + * @param crDtimes + * the crDtimes to set + */ + public void setCrDtimes(Timestamp crDtimes) { + this.crDtimes = new Timestamp(crDtimes.getTime()); + } + + /** + * Gets the del dtimes. + * + * @return the delDtimes + */ + public Timestamp getDelDtimes() { + return new Timestamp(delDtimes.getTime()); + } + + /** + * Sets the del dtimes. + * + * @param delDtimes + * the delDtimes to set + */ + public void setDelDtimes(Timestamp delDtimes) { + this.delDtimes = new Timestamp(delDtimes.getTime()); + } + + /** + * Gets the checks if is active. + * + * @return the isActive + */ + public Boolean getIsActive() { + return isActive; + } + + /** + * Sets the checks if is active. + * + * @param isActive + * the isActive to set + */ + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + /** + * Gets the checks if is deleted. + * + * @return the isDeleted + */ + public Boolean getIsDeleted() { + return isDeleted; + } + + /** + * Sets the checks if is deleted. + * + * @param isDeleted + * the isDeleted to set + */ + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + /** + * Gets the lang code. + * + * @return the langCode + */ + public String getLangCode() { + return langCode; + } + + /** + * Sets the lang code. + * + * @param langCode + * the langCode to set + */ + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + /** + * Gets the matched score. + * + * @return the matchedScore + */ + /*public BigDecimal getMatchedScore() { + return matchedScore; + }*/ + + /** + * Sets the matched score. + * + * @param matchedScore + * the matchedScore to set + */ + /*public void setMatchedScore(BigDecimal matchedScore) { + this.matchedScore = matchedScore; + }*/ + + /** + * Gets the mv usr id. + * + * @return the mvUsrId + */ + public String getMvUsrId() { + return mvUsrId; + } + + /** + * Sets the mv usr id. + * + * @param mvUsrId + * the mvUsrId to set + */ + public void setMvUsrId(String mvUsrId) { + this.mvUsrId = mvUsrId; + } + + /** + * Gets the reason code. + * + * @return the reasonCode + */ + public String getReasonCode() { + return reasonCode; + } + + /** + * Sets the reason code. + * + * @param reasonCode + * the reasonCode to set + */ + public void setReasonCode(String reasonCode) { + this.reasonCode = reasonCode; + } + + /** + * Gets the status code. + * + * @return the statusCode + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Sets the status code. + * + * @param statusCode + * the statusCode to set + */ + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + /** + * Gets the status comment. + * + * @return the statusComment + */ + public String getStatusComment() { + return statusComment; + } + + /** + * Sets the status comment. + * + * @param statusComment + * the statusComment to set + */ + public void setStatusComment(String statusComment) { + this.statusComment = statusComment; + } + + /** + * Gets the upd by. + * + * @return the updBy + */ + public String getUpdBy() { + return updBy; + } + + /** + * Sets the upd by. + * + * @param updBy + * the updBy to set + */ + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + /** + * Gets the upd dtimes. + * + * @return the updDtimes + */ + public Timestamp getUpdDtimes() { + return new Timestamp(updDtimes.getTime()); + } + + /** + * Sets the upd dtimes. + * + * @param updDtimes + * the updDtimes to set + */ + public void setUpdDtimes(Timestamp updDtimes) { + this.updDtimes = new Timestamp(updDtimes.getTime()); + } + + /** + * Gets the serialversionuid. + * + * @return the serialversionuid + */ + public static long getSerialversionuid() { + return serialVersionUID; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public byte[] getReponseText() { + return reponseText; + } + + public void setReponseText(byte[] reponseText) { + this.reponseText = reponseText; + } + + +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationPKEntity.java index ab4928d2736..1101ed3b4b0 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/ManualVerificationPKEntity.java @@ -1,83 +1,83 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -/** - * The primary key class for the reg_manual_verification database table. - * - * @author Shuchita - * @since 0.0.1 - */ -@Embeddable -public class ManualVerificationPKEntity implements Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The matched ref id. */ - @Column(name = "matched_ref_id") - private String matchedRefId; - - /** The matched ref type. */ - @Column(name = "matched_ref_type") - private String matchedRefType; - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - /** - * Gets the matched ref id. - * - * @return the matchedRefId - */ - public String getMatchedRefId() { - return matchedRefId; - } - - /** - * Sets the matched ref id. - * - * @param matchedRefId the matchedRefId to set - */ - public void setMatchedRefId(String matchedRefId) { - this.matchedRefId = matchedRefId; - } - - /** - * Gets the matched ref type. - * - * @return the matchedRefType - */ - public String getMatchedRefType() { - return matchedRefType; - } - - /** - * Sets the matched ref type. - * - * @param matchedRefType the matchedRefType to set - */ - public void setMatchedRefType(String matchedRefType) { - this.matchedRefType = matchedRefType; - } - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - /** - * Gets the serialversionuid. - * - * @return the serialversionuid - */ - public static long getSerialversionuid() { - return serialVersionUID; - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +/** + * The primary key class for the reg_manual_verification database table. + * + * @author Shuchita + * @since 0.0.1 + */ +@Embeddable +public class ManualVerificationPKEntity implements Serializable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** The matched ref id. */ + @Column(name = "matched_ref_id") + private String matchedRefId; + + /** The matched ref type. */ + @Column(name = "matched_ref_type") + private String matchedRefType; + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + /** + * Gets the matched ref id. + * + * @return the matchedRefId + */ + public String getMatchedRefId() { + return matchedRefId; + } + + /** + * Sets the matched ref id. + * + * @param matchedRefId the matchedRefId to set + */ + public void setMatchedRefId(String matchedRefId) { + this.matchedRefId = matchedRefId; + } + + /** + * Gets the matched ref type. + * + * @return the matchedRefType + */ + public String getMatchedRefType() { + return matchedRefType; + } + + /** + * Sets the matched ref type. + * + * @param matchedRefType the matchedRefType to set + */ + public void setMatchedRefType(String matchedRefType) { + this.matchedRefType = matchedRefType; + } + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + /** + * Gets the serialversionuid. + * + * @return the serialversionuid + */ + public static long getSerialversionuid() { + return serialVersionUID; + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdEntity.java index 9b32bd41102..d8e571614b2 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdEntity.java @@ -3,9 +3,9 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.UpdateTimestamp; diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdPKEntity.java index 51d55dc6538..b18de792976 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/QcuserRegistrationIdPKEntity.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; /** * The primary key class for the qcuser_registration_id database table. diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefEntity.java index 014e4716a5b..a0c806f2d44 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefEntity.java @@ -1,127 +1,127 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -@Entity -@Table(name = "reg_bio_ref", schema = "regprc") -public class RegBioRefEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "cr_by", nullable = false) - private String crBy = "SYSTEM"; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - @Column(name = "is_active") - private Boolean isActive; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "upd_by") - private String updBy = "MOSIP_SYSTEM"; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - @Column(name = "reg_id") - private String regId; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "process") - private String process; - - @Column(name = "iteration") - private int iteration; - - public String getRegId() { - return regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } - - public LocalDateTime getCrDtimes() { - return this.crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public String getProcess() { - return process; - } - - public void setProcess(String process) { - this.process = process; - } - - public int getIteration() { - return iteration; - } - - public void setIteration(int iteration) { - this.iteration = iteration; - } - - public RegBioRefEntity() { - } - - public String getCrBy() { - return this.crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getDelDtimes() { - return this.delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public Boolean getIsActive() { - return this.isActive; - } - - public void setIsActive(Boolean isActive) { - this.isActive = isActive; - } - - public Boolean getIsDeleted() { - return this.isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public String getUpdBy() { - return this.updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return this.updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "reg_bio_ref", schema = "regprc") +public class RegBioRefEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "cr_by", nullable = false) + private String crBy = "SYSTEM"; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + @Column(name = "is_active") + private Boolean isActive; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "upd_by") + private String updBy = "MOSIP_SYSTEM"; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + @Column(name = "reg_id") + private String regId; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "process") + private String process; + + @Column(name = "iteration") + private int iteration; + + public String getRegId() { + return regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public LocalDateTime getCrDtimes() { + return this.crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public String getProcess() { + return process; + } + + public void setProcess(String process) { + this.process = process; + } + + public int getIteration() { + return iteration; + } + + public void setIteration(int iteration) { + this.iteration = iteration; + } + + public RegBioRefEntity() { + } + + public String getCrBy() { + return this.crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getDelDtimes() { + return this.delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public Boolean getIsActive() { + return this.isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public Boolean getIsDeleted() { + return this.isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getUpdBy() { + return this.updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return this.updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefPKEntity.java index 8998a4eb5ba..821d72fc341 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegBioRefPKEntity.java @@ -1,42 +1,42 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class RegBioRefPKEntity implements Serializable { - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - @Column(name = "bio_ref_id") - private String bioRefId; - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - public String getBioRefId() { - return this.bioRefId; - } - - public void setBioRefId(String bioRefId) { - this.bioRefId = bioRefId; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class RegBioRefPKEntity implements Serializable { + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + @Column(name = "bio_ref_id") + private String bioRefId; + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + public String getBioRefId() { + return this.bioRefId; + } + + public void setBioRefId(String bioRefId) { + this.bioRefId = bioRefId; + } + + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return super.equals(obj); + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListEntity.java index 164bcfcaf3b..2c2ef6c9a45 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListEntity.java @@ -1,107 +1,107 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.Table; - -@Entity -@Table(name = "reg_demo_dedupe_list", schema = "regprc") -public class RegDemoDedupeListEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @EmbeddedId - private RegDemoDedupeListPKEntity id; - - @Column(name = "cr_by", nullable = false) - private String crBy = "SYSTEM"; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "reg_id") - private String regId; - - @Column(name = "upd_by") - private String updBy = "MOSIP_SYSTEM"; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - public RegDemoDedupeListEntity() { - } - - public RegDemoDedupeListPKEntity getId() { - return this.id; - } - - public void setId(RegDemoDedupeListPKEntity id) { - this.id = id; - } - - public String getCrBy() { - return this.crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return this.crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public LocalDateTime getDelDtimes() { - return this.delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public Boolean getIsDeleted() { - return this.isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public String getRegId() { - return this.regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } - - public String getUpdBy() { - return this.updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return this.updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "reg_demo_dedupe_list", schema = "regprc") +public class RegDemoDedupeListEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @EmbeddedId + private RegDemoDedupeListPKEntity id; + + @Column(name = "cr_by", nullable = false) + private String crBy = "SYSTEM"; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "reg_id") + private String regId; + + @Column(name = "upd_by") + private String updBy = "MOSIP_SYSTEM"; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + public RegDemoDedupeListEntity() { + } + + public RegDemoDedupeListPKEntity getId() { + return this.id; + } + + public void setId(RegDemoDedupeListPKEntity id) { + this.id = id; + } + + public String getCrBy() { + return this.crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return this.crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public LocalDateTime getDelDtimes() { + return this.delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public Boolean getIsDeleted() { + return this.isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public String getRegId() { + return this.regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public String getUpdBy() { + return this.updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return this.updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListPKEntity.java index 6977411dd09..d562044d9b4 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegDemoDedupeListPKEntity.java @@ -1,57 +1,57 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class RegDemoDedupeListPKEntity implements Serializable { - // default serial version id, required for serializable classes. - private static final long serialVersionUID = 1L; - - @Column(name = "matched_reg_id") - private String matchedRegId; - - @Column(name = "regtrn_id", insertable = false, updatable = false) - private String regtrnId; - - public RegDemoDedupeListPKEntity() { - } - - public String getMatchedRegId() { - return this.matchedRegId; - } - - public void setMatchedRegId(String matchedRegId) { - this.matchedRegId = matchedRegId; - } - - public String getRegtrnId() { - return this.regtrnId; - } - - public void setRegtrnId(String regtrnId) { - this.regtrnId = regtrnId; - } - - public boolean equals(Object other) { - if (this == other) { - return true; - } - if (!(other instanceof RegDemoDedupeListPKEntity)) { - return false; - } - RegDemoDedupeListPKEntity castOther = (RegDemoDedupeListPKEntity) other; - return this.matchedRegId.equals(castOther.matchedRegId) && this.regtrnId.equals(castOther.regtrnId); - } - - public int hashCode() { - final int prime = 31; - int hash = 17; - hash = hash * prime + this.matchedRegId.hashCode(); - hash = hash * prime + this.regtrnId.hashCode(); - - return hash; - } +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class RegDemoDedupeListPKEntity implements Serializable { + // default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + + @Column(name = "matched_reg_id") + private String matchedRegId; + + @Column(name = "regtrn_id", insertable = false, updatable = false) + private String regtrnId; + + public RegDemoDedupeListPKEntity() { + } + + public String getMatchedRegId() { + return this.matchedRegId; + } + + public void setMatchedRegId(String matchedRegId) { + this.matchedRegId = matchedRegId; + } + + public String getRegtrnId() { + return this.regtrnId; + } + + public void setRegtrnId(String regtrnId) { + this.regtrnId = regtrnId; + } + + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof RegDemoDedupeListPKEntity)) { + return false; + } + RegDemoDedupeListPKEntity castOther = (RegDemoDedupeListPKEntity) other; + return this.matchedRegId.equals(castOther.matchedRegId) && this.regtrnId.equals(castOther.regtrnId); + } + + public int hashCode() { + final int prime = 31; + int hash = 17; + hash = hash * prime + this.matchedRegId.hashCode(); + hash = hash * prime + this.regtrnId.hashCode(); + + return hash; + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetEntity.java index dede7a6ac97..d3e1f892606 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetEntity.java @@ -1,111 +1,111 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -@Entity -@Table(name = "reg_lost_uin_det", schema = "regprc") -public class RegLostUinDetEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "reg_id") - private String regId; - - @Column(name = "latest_reg_id") - private String latestRegId; - - @Column(name = "cr_by") - private String crBy; - - @Column(name = "cr_dtimes", updatable = false) - private LocalDateTime crDtimes; - - @Column(name = "upd_by") - private String updBy; - - @Column(name = "upd_dtimes") - private LocalDateTime updDtimes; - - @Column(name = "is_deleted") - private Boolean isDeleted; - - @Column(name = "del_dtimes") - private LocalDateTime delDtimes; - - public RegLostUinDetEntity() { - - } - - public String getRegId() { - return regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } - - public String getLatestRegId() { - return latestRegId; - } - - public void setLatestRegId(String latestRegId) { - this.latestRegId = latestRegId; - } - - public String getCrBy() { - return crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public LocalDateTime getCrDtimes() { - return crDtimes; - } - - public void setCrDtimes(LocalDateTime crDtimes) { - this.crDtimes = crDtimes; - } - - public String getUpdBy() { - return updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public LocalDateTime getUpdDtimes() { - return updDtimes; - } - - public void setUpdDtimes(LocalDateTime updDtimes) { - this.updDtimes = updDtimes; - } - - public Boolean getIsDeleted() { - return isDeleted; - } - - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - public LocalDateTime getDelDtimes() { - return delDtimes; - } - - public void setDelDtimes(LocalDateTime delDtimes) { - this.delDtimes = delDtimes; - } - - public static long getSerialversionuid() { - return serialVersionUID; - } - -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "reg_lost_uin_det", schema = "regprc") +public class RegLostUinDetEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "reg_id") + private String regId; + + @Column(name = "latest_reg_id") + private String latestRegId; + + @Column(name = "cr_by") + private String crBy; + + @Column(name = "cr_dtimes", updatable = false) + private LocalDateTime crDtimes; + + @Column(name = "upd_by") + private String updBy; + + @Column(name = "upd_dtimes") + private LocalDateTime updDtimes; + + @Column(name = "is_deleted") + private Boolean isDeleted; + + @Column(name = "del_dtimes") + private LocalDateTime delDtimes; + + public RegLostUinDetEntity() { + + } + + public String getRegId() { + return regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public String getLatestRegId() { + return latestRegId; + } + + public void setLatestRegId(String latestRegId) { + this.latestRegId = latestRegId; + } + + public String getCrBy() { + return crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public LocalDateTime getCrDtimes() { + return crDtimes; + } + + public void setCrDtimes(LocalDateTime crDtimes) { + this.crDtimes = crDtimes; + } + + public String getUpdBy() { + return updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public LocalDateTime getUpdDtimes() { + return updDtimes; + } + + public void setUpdDtimes(LocalDateTime updDtimes) { + this.updDtimes = updDtimes; + } + + public Boolean getIsDeleted() { + return isDeleted; + } + + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + public LocalDateTime getDelDtimes() { + return delDtimes; + } + + public void setDelDtimes(LocalDateTime delDtimes) { + this.delDtimes = delDtimes; + } + + public static long getSerialversionuid() { + return serialVersionUID; + } + +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetPKEntity.java index a31c19834cd..e00577320b0 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/RegLostUinDetPKEntity.java @@ -1,39 +1,39 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import java.io.Serializable; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class RegLostUinDetPKEntity implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RegLostUinDetPKEntity that = (RegLostUinDetPKEntity) o; - return Objects.equals(workflowInstanceId, that.workflowInstanceId); - } - - @Override - public int hashCode() { - return Objects.hash(workflowInstanceId); - } -} +package io.mosip.registration.processor.packet.storage.entity; + +import java.io.Serializable; +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + +@Embeddable +public class RegLostUinDetPKEntity implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RegLostUinDetPKEntity that = (RegLostUinDetPKEntity) o; + return Objects.equals(workflowInstanceId, that.workflowInstanceId); + } + + @Override + public int hashCode() { + return Objects.hash(workflowInstanceId); + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationEntity.java index 93e8b514d95..108a0036bae 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationEntity.java @@ -1,200 +1,200 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * The persistent class for the reg_verification database table. - * - * @author Monobikash - * @since 1.2.0 - * - */ -@Entity -@Table(name = "reg_verification", schema = "regprc") -public class VerificationEntity extends BasePacketEntity implements Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The reg id. */ - @Column(name = "reg_id") - private String regId; - - /** The reg id. */ - @Column(name = "verification_req_id") - private String requestId; - - @Column(name = "matched_type") - private String matchType; - - /** The mv usr id. */ - @Column(name = "verification_usr_id") - private String verificationUsrId; - - @Column(name="response_text",nullable = true) - private String reponseText; - - /** The reason code. */ - @Column(name = "reason_code") - private String reasonCode; - - /** The status code. */ - @Column(name = "status_code") - private String statusCode; - - /** The status comment. */ - @Column(name = "status_comment") - private String statusComment; - - /** The cr by. */ - @Column(name = "cr_by") - private String crBy; - - /** The cr dtimes. */ - @Column(name = "cr_dtimes", updatable = false) - private Timestamp crDtimes; - - /** The del dtimes. */ - @Column(name = "del_dtimes") - private Timestamp delDtimes; - - /** The is active. */ - @Column(name = "is_active") - private Boolean isActive; - - /** The is deleted. */ - @Column(name = "is_deleted") - private Boolean isDeleted; - - /** The upd by. */ - @Column(name = "upd_by") - private String updBy; - - /** The upd dtimes. */ - @Column(name = "upd_dtimes") - private Timestamp updDtimes; - - public String getRegId() { - return regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getMatchType() { - return matchType; - } - - public void setMatchType(String matchType) { - this.matchType = matchType; - } - - public String getVerificationUsrId() { - return verificationUsrId; - } - - public void setVerificationUsrId(String verificationUsrId) { - this.verificationUsrId = verificationUsrId; - } - - public String getReponseText() { - return reponseText; - } - - public void setReponseText(String reponseText) { - this.reponseText = reponseText; - } - - public String getReasonCode() { - return reasonCode; - } - - public void setReasonCode(String reasonCode) { - this.reasonCode = reasonCode; - } - - public String getStatusCode() { - return statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public String getStatusComment() { - return statusComment; - } - - public void setStatusComment(String statusComment) { - this.statusComment = statusComment; - } - - public String getCrBy() { - return crBy; - } - - public void setCrBy(String crBy) { - this.crBy = crBy; - } - - public Timestamp getCrDtimes() { - return crDtimes; - } - - public void setCrDtimes(Timestamp crDtimes) { - this.crDtimes = crDtimes; - } - - public Timestamp getDelDtimes() { - return delDtimes; - } - - public void setDelDtimes(Timestamp delDtimes) { - this.delDtimes = delDtimes; - } - - public Boolean getActive() { - return isActive; - } - - public void setActive(Boolean active) { - isActive = active; - } - - public Boolean getDeleted() { - return isDeleted; - } - - public void setDeleted(Boolean deleted) { - isDeleted = deleted; - } - - public String getUpdBy() { - return updBy; - } - - public void setUpdBy(String updBy) { - this.updBy = updBy; - } - - public Timestamp getUpdDtimes() { - return updDtimes; - } - - public void setUpdDtimes(Timestamp updDtimes) { - this.updDtimes = updDtimes; - } -} +package io.mosip.registration.processor.packet.storage.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * The persistent class for the reg_verification database table. + * + * @author Monobikash + * @since 1.2.0 + * + */ +@Entity +@Table(name = "reg_verification", schema = "regprc") +public class VerificationEntity extends BasePacketEntity implements Serializable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** The reg id. */ + @Column(name = "reg_id") + private String regId; + + /** The reg id. */ + @Column(name = "verification_req_id") + private String requestId; + + @Column(name = "matched_type") + private String matchType; + + /** The mv usr id. */ + @Column(name = "verification_usr_id") + private String verificationUsrId; + + @Column(name="response_text",nullable = true) + private String reponseText; + + /** The reason code. */ + @Column(name = "reason_code") + private String reasonCode; + + /** The status code. */ + @Column(name = "status_code") + private String statusCode; + + /** The status comment. */ + @Column(name = "status_comment") + private String statusComment; + + /** The cr by. */ + @Column(name = "cr_by") + private String crBy; + + /** The cr dtimes. */ + @Column(name = "cr_dtimes", updatable = false) + private Timestamp crDtimes; + + /** The del dtimes. */ + @Column(name = "del_dtimes") + private Timestamp delDtimes; + + /** The is active. */ + @Column(name = "is_active") + private Boolean isActive; + + /** The is deleted. */ + @Column(name = "is_deleted") + private Boolean isDeleted; + + /** The upd by. */ + @Column(name = "upd_by") + private String updBy; + + /** The upd dtimes. */ + @Column(name = "upd_dtimes") + private Timestamp updDtimes; + + public String getRegId() { + return regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public String getRequestId() { + return requestId; + } + + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + public String getMatchType() { + return matchType; + } + + public void setMatchType(String matchType) { + this.matchType = matchType; + } + + public String getVerificationUsrId() { + return verificationUsrId; + } + + public void setVerificationUsrId(String verificationUsrId) { + this.verificationUsrId = verificationUsrId; + } + + public String getReponseText() { + return reponseText; + } + + public void setReponseText(String reponseText) { + this.reponseText = reponseText; + } + + public String getReasonCode() { + return reasonCode; + } + + public void setReasonCode(String reasonCode) { + this.reasonCode = reasonCode; + } + + public String getStatusCode() { + return statusCode; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public String getStatusComment() { + return statusComment; + } + + public void setStatusComment(String statusComment) { + this.statusComment = statusComment; + } + + public String getCrBy() { + return crBy; + } + + public void setCrBy(String crBy) { + this.crBy = crBy; + } + + public Timestamp getCrDtimes() { + return crDtimes; + } + + public void setCrDtimes(Timestamp crDtimes) { + this.crDtimes = crDtimes; + } + + public Timestamp getDelDtimes() { + return delDtimes; + } + + public void setDelDtimes(Timestamp delDtimes) { + this.delDtimes = delDtimes; + } + + public Boolean getActive() { + return isActive; + } + + public void setActive(Boolean active) { + isActive = active; + } + + public Boolean getDeleted() { + return isDeleted; + } + + public void setDeleted(Boolean deleted) { + isDeleted = deleted; + } + + public String getUpdBy() { + return updBy; + } + + public void setUpdBy(String updBy) { + this.updBy = updBy; + } + + public Timestamp getUpdDtimes() { + return updDtimes; + } + + public void setUpdDtimes(Timestamp updDtimes) { + this.updDtimes = updDtimes; + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationPKEntity.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationPKEntity.java index 33b9ecde659..5c997e9faa2 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationPKEntity.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/entity/VerificationPKEntity.java @@ -1,30 +1,30 @@ -package io.mosip.registration.processor.packet.storage.entity; - -import javax.persistence.Column; -import javax.persistence.Embeddable; -import java.io.Serializable; - -/** - * The primary key class for the reg_verification database table. - * - * @author Monobikash - * @since 1.2.0 - */ -@Embeddable -public class VerificationPKEntity implements Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - +package io.mosip.registration.processor.packet.storage.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import java.io.Serializable; + +/** + * The primary key class for the reg_verification database table. + * + * @author Monobikash + * @since 1.2.0 + */ +@Embeddable +public class VerificationPKEntity implements Serializable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 1L; + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/repository/BasePacketRepository.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/repository/BasePacketRepository.java index f792b93c3f9..7c9e8916c9d 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/repository/BasePacketRepository.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/repository/BasePacketRepository.java @@ -1,484 +1,484 @@ -package io.mosip.registration.processor.packet.storage.repository; - -import java.util.List; - -import io.mosip.registration.processor.packet.storage.entity.VerificationEntity; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; -import org.springframework.transaction.annotation.Transactional; - -import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository; -import io.mosip.registration.processor.packet.storage.entity.AbisRequestEntity; -import io.mosip.registration.processor.packet.storage.entity.AbisResponseDetEntity; -import io.mosip.registration.processor.packet.storage.entity.AbisResponseEntity; -import io.mosip.registration.processor.packet.storage.entity.BasePacketEntity; -import io.mosip.registration.processor.packet.storage.entity.ManualVerificationEntity; -import io.mosip.registration.processor.packet.storage.entity.RegBioRefEntity; -import io.mosip.registration.processor.packet.storage.entity.RegDemoDedupeListEntity; - -/** - * The Interface BasePacketRepository. - * - * @author Girish Yarru - * @param - * the element type - * @param - * the generic type - */ -@Repository -public interface BasePacketRepository, T> extends BaseRepository { - - /** - * Find by user id. - * - * @param qcuserId - * the qcuser id - * @return the list - */ - @Query("SELECT qcUser FROM QcuserRegistrationIdEntity qcUser WHERE qcUser.id.usrId=:qcuserId") - public List findByUserId(@Param("qcuserId") String qcuserId); - - /** - * Find demo by id. - * - * @param regId - * the reg id - * @return the list - */ - @Query("SELECT demo FROM IndividualDemographicDedupeEntity demo WHERE demo.regId=:regId") - public List findDemoById(@Param("regId") String regId); - - /** - * This method gets the first created registration record - * {@link ManualVerificationEntity} with the specified status. - * - * @param statusCode - * The statusCode - * @param matchType - * the match type - * @return {@link ManualVerificationEntity} - */ - @Query(value = "SELECT mve FROM ManualVerificationEntity mve WHERE mve.crDtimes in " - + "(SELECT min(mve2.crDtimes) FROM ManualVerificationEntity mve2 where mve2.statusCode=:statusCode AND mve2.trnTypCode=:trntyp_code) and mve.statusCode=:statusCode") - public List getFirstApplicantDetails(@Param("statusCode") String statusCode, - @Param("trntyp_code") String matchType); - - /** - * This method gets the first created registration record for source name as ALL - * {@link ManualVerificationEntity} with the specified status. - * - * @param statusCode - * The statusCode - * @return {@link ManualVerificationEntity} - */ - @Query(value = "SELECT mve FROM ManualVerificationEntity mve WHERE mve.crDtimes in " - + "(SELECT min(mve2.crDtimes) FROM ManualVerificationEntity mve2 where mve2.statusCode=:statusCode) and mve.statusCode=:statusCode") - public List getFirstApplicantDetailsForAll(@Param("statusCode") String statusCode); - - /** - * This method returns {@link ManualVerificationEntity} corresponding to - * specified registration Id and manual verifier user Id. - * - * @param regId - * The registration Id - * @param refId - * the ref id - * @param mvUserId - * The manual verifier user Id - * @param statusCode - * the status code - * @return {@link ManualVerificationEntity} - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId=:regId and mve.mvUsrId=:mvUserId and mve.id.matchedRefId=:refId and mve.statusCode=:statusCode") - public List getSingleAssignedRecord(@Param("regId") String regId, @Param("refId") String refId, - @Param("mvUserId") String mvUserId, @Param("statusCode") String statusCode); - - /** - * This method returns {@link ManualVerificationEntity} corresponding to - * specified registration Id and manual verifier user Id. - * - * @param regId - * The registration Id - * @param mvUserId - * The manual verifier user Id - * @param statusCode - * the status code - * @return {@link ManualVerificationEntity} - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId=:regId and mve.statusCode=:statusCode") - public List getAllAssignedRecord(@Param("regId") String regId, @Param("statusCode") String statusCode); - - - @Query("SELECT mve FROM VerificationEntity mve where mve.regId=:regId and mve.statusCode=:statusCode") - public List getAssignedVerificationRecord(@Param("regId") String regId, @Param("statusCode") String statusCode); - - /** - * Gets the assigned applicant details. - * - * @param mvUserId - * the mv user id - * @param statusCode - * the status code - * @return the assigned applicant details - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.mvUsrId=:mvUserId and mve.statusCode=:statusCode") - public List getAssignedApplicantDetails(@Param("mvUserId") String mvUserId, - @Param("statusCode") String statusCode); - - /** - * Gets the matched ids for ref id. - * - * @param refId - * the reference id - * @return the List of ManualVerificationEntity records - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId =:regId and status_code =:status_code") - public List getMatchedIds(@Param("regId") String regId, @Param("status_code") String status_code); - - - - /** - * Gets the Manual verification entity based on request id and matchedreference id - * - * @param requestId - * the requestId - * @param matchedRefId - * the Matched reference Id - * @return the ManualVerificationEntity record - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.requestId=:requestId and mve.id.matchedRefId=:matchedRefId") - public E getManualVerificationEntitty(@Param("requestId") String requestId,@Param("matchedRefId") String matchedRefId); - - /** - * Gets the Manual verification entity based on request id and matchedreference id - * - * @param requestId - * the requestId - - * @return the ManualVerificationEntity record - */ - @Query("SELECT mve FROM ManualVerificationEntity mve where mve.requestId=:requestId") - public E getManualVerificationEntityForRID(@Param("requestId") String requestId); - - - - - /** - * Update is active if duplicate found. - * - * @param regId - * the reg id - */ - @Modifying - @Transactional - @Query("UPDATE IndividualDemographicDedupeEntity demo SET demo.isActive = FALSE WHERE demo.regId =:regId") - public void updateIsActiveIfDuplicateFound(@Param("regId") String regId); - - /** - * Gets the reference id by rid. - * - * @param rid - * the rid - * @return the reference id by rid - */ - @Query("SELECT abis.id.bioRefId FROM RegBioRefEntity abis WHERE abis.regId =:rid order by crDtimes desc") - public List getReferenceIdByRid(@Param("rid") String rid); - - @Query("SELECT abis.id.bioRefId FROM RegBioRefEntity abis WHERE abis.id.workflowInstanceId =:workflowInstanceId order by crDtimes desc") - public List getRefIdByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); - - /** - * Gets the rid by reference id. - * - * @param refId - * the ref id - * @return the rid by reference id - */ - @Query("SELECT abis.regId FROM RegBioRefEntity abis WHERE abis.id.bioRefId =:refId") - public List getRidByReferenceId(@Param("refId") String refId); - - /** - * Gets the insert or identify request. - * - * @param bioRefId - * the bio ref id - * @param refRegtrnId - * the ref regtrn id - * @return the insert or identify request - */ - - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.bioRefId =:bioRefId and abisreq.refRegtrnId =:refRegtrnId") - public List getInsertOrIdentifyRequest(@Param("bioRefId") String bioRefId, - @Param("refRegtrnId") String refRegtrnId); - - @Query("SELECT abisreq.bioRefId FROM AbisRequestEntity abisreq WHERE abisreq.reqBatchId =:reqBatchId") - public List getReferenceIdByBatchId(@Param("reqBatchId") String reqBatchId); - - /** - * Get transaction id from Abis request table - * - * @param id - * @return - */ - @Query("SELECT abisreq.refRegtrnId FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") - public List getAbisTransactionIdByRequestId(@Param("id") String id); - - /** - * Gets the identify req list by transaction id. - * - * @param refRegtrnId - * the ref regtrn id - * @param requestType - * the request type - * @return the identify req list by transaction id - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType =:requestType") - public List getIdentifyReqListByTransactionId(@Param("refRegtrnId") String refRegtrnId, - @Param("requestType") String requestType); - - /** - * Gets the abis request by request id. - * - * @param id - * the id - * @return the abis request by request id - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") - public List getAbisRequestByRequestId(@Param("id") String id); - - /** - * Gets the insert or identify request. - * - * @param bioRefId - * the bio ref id - * @param refRegtrnId - * the ref regtrn id - * @param requestType - * the request type - * @return the insert or identify request - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.bioRefId =:bioRefId and abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType =:requestType") - public List getInsertOrIdentifyRequest(@Param("bioRefId") String bioRefId, - @Param("refRegtrnId") String refRegtrnId, @Param("requestType") String requestType); - - /** - * Gets the batch id by request id. - * - * @param id - * the id - * @return the batch id by request id - */ - @Query("SELECT abisreq.reqBatchId FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") - public List getBatchIdByRequestId(@Param("id") String id); - - /** - * Gets the batch statusby batch id. - * - * @param reqBatchId - * the req batch id - * @return the batch statusby batch id - */ - @Query("SELECT abisreq.statusCode FROM AbisRequestEntity abisreq WHERE abisreq.reqBatchId =:reqBatchId") - public List getBatchStatusbyBatchId(@Param("reqBatchId") String reqBatchId); - - /** - * Update abis request status code. - * - * @param id - * the id - */ - @Query("UPDATE AbisRequestEntity abisReq SET abisReq.statusCode = 'PROCESSED' WHERE abisReq.id.id =:id") - @Modifying - public void updateAbisRequestStatusCode(@Param("id") String id); - - /** - * Gets the abis request I ds. - * - * @param transactionId - * the transaction id - * @return the abis request I ds - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId") - public List getAbisRequestIDs(@Param("refRegtrnId") String transactionId); - - /** - * Gets the abis request I dsbased on identity. - * - * @param transactionId - * the transaction id - * @param requestType - * the request type - * @return the abis request I dsbased on identity - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType=:requestType") - public List getAbisRequestIDsbasedOnIdentity(@Param("refRegtrnId") String transactionId, - @Param("requestType") String requestType); - - /** - * Gets the abis response I ds. - * - * @param abisRequest - * the abis request - * @return the abis response I ds - */ - @Query("SELECT abisresp FROM AbisResponseEntity abisresp WHERE abisresp.abisRequest =:abisRequest") - public List getAbisResponseIDs(@Param("abisRequest") String abisRequest); - - /** - * Gets the abis response details. - * - * @param responseId - * the response id - * @return the abis response details - */ - @Query("SELECT abisRespDet FROM AbisResponseDetEntity abisRespDet WHERE abisRespDet.id.abisRespId =:abisRespId") - public List getAbisResponseDetails(@Param("abisRespId") String responseId); - - /** - * Gets the abis response details list. - * - * @param responseId - * the response id - * @return the abis response details list - */ - @Query("SELECT abisRespDet FROM AbisResponseDetEntity abisRespDet WHERE abisRespDet.id.abisRespId in :abisRespIds") - public List getAbisResponseDetailsList(@Param("abisRespIds") List responseId); - - /** - * Gets the bio ref ids. - * - * @param bioRefId - * the bio ref id - * @return the bio ref ids - */ - @Query("SELECT regBioRef.regId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId in :bioRefIds") - public List getAbisRefRegIdsByMatchedRefIds(@Param("bioRefIds") List bioRefId); - - /** - * Gets the RegId by bioRefId,process & iteration. - * @param bioRefId - * @param workflowInstanceId - * @return regId - */ - @Query("SELECT regBioRef.regId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId=:bioRefId and regBioRef.id.workflowInstanceId=:workflowInstanceId") - public String getRegIdByRefIdAndWorkflowInstanceId(@Param("bioRefId") String bioRefId, @Param("workflowInstanceId") String workflowInstanceId); - - /** - * Gets the bio Ref entity list by bioRefId. - * @param bioRefIds - * @return RegBioRef Entities - */ - @Query("SELECT regBioRef FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId in :bioRefIds") - public List getBioRefIdsByRefIds(@Param("bioRefIds") List bioRefId); - - /** - * Gets the identify by transaction id. - * - * @param transactionId - * the transaction id - * @param identify - * the identify - * @return the identify by transaction id - */ - @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:transactionId and abisreq.requestType =:identify") - public List getIdentifyByTransactionId(@Param("transactionId") String transactionId, - @Param("identify") String identify); - - /** - * Gets the bio ref id by reg id. - * - * @param regId - * the reg id - * @return the bio ref id by reg id - */ - @Query("SELECT bioRef.id.bioRefId FROM RegBioRefEntity bioRef WHERE bioRef.regId =:regId") - public List getBioRefIdByRegIds(@Param("regId") String regId); - - /** - * Gets the reg id by bio ref id. - * - * @param bioRefId - * the bio ref id - * @return the reg id by bio ref id - */ - @Query("SELECT bioRef.regId FROM RegBioRefEntity bioRef WHERE LOWER(bioRef.id.bioRefId) =:bioRefId") - public String getRegIdByBioRefId(@Param("bioRefId") String bioRefId); - - /** - * Gets the bio ref id by reg id. - * - * @param regId - * the reg id - * @return the bio ref id by reg id - */ - @Query("SELECT bioRef FROM RegBioRefEntity bioRef WHERE bioRef.regId =:regId") - public List getBioRefIdByRegId(@Param("regId") String regId); - - /** - * Gets the demo list by transaction id. - * - * @param regtrnId - * the regtrn id - * @return the demo list by transaction id - */ - @Query("SELECT regDemo FROM RegDemoDedupeListEntity regDemo WHERE regDemo.id.regtrnId =:regtrnId") - public List getDemoListByTransactionId(@Param("regtrnId") String regtrnId); - - /** - * Gets the abis ref matched ref id by rid. - * - * @param regId - * the reg id - * @return the abis ref matched ref id by rid - */ - @Query("SELECT regBioRef.id.bioRefId FROM RegBioRefEntity regBioRef WHERE regBioRef.regId =:regId order by regBioRef.crDtimes desc") - public List getAbisRefMatchedRefIdByRid(@Param("regId") String regId); - - @Query("SELECT regBioRef.id.bioRefId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.workflowInstanceId =:workflowInstanceId order by regBioRef.crDtimes desc") - public List getAbisRefIdByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); - - /** - * Gets the abis requests by bio ref id. - * - * @param bioRefId - * the bio ref id - * @param insert - * the insert - * @return the abis requests by bio ref id - */ - @Query("SELECT abisReq FROM AbisRequestEntity abisReq WHERE abisReq.bioRefId =:bioRefId and abisReq.requestType =:insert") - public List getAbisRequestsByBioRefId(@Param("bioRefId") String bioRefId, - @Param("insert") String insert); - - /** - * Gets the abis processed requests app code by bio ref id. - * - * @param bioRefId - * the bio ref id - * @param requestType - * the request type - * @param statusCode - * the status code - * @return the abis processed requests app code by bio ref id - */ - @Query("SELECT abisReq.abisAppCode FROM AbisRequestEntity abisReq WHERE abisReq.bioRefId =:bioRefId and abisReq.requestType =:requestType and abisReq.statusCode =:statusCode") - public List getAbisProcessedRequestsAppCodeByBioRefId(@Param("bioRefId") String bioRefId, - @Param("requestType") String requestType, @Param("statusCode") String statusCode); - - @Query("SELECT latestRegId FROM RegLostUinDetEntity lostUin WHERE lostUin.regId =:regId") - public String getLostUinMatchedRegId(@Param("regId") String regId); - - @Query("SELECT latestRegId FROM RegLostUinDetEntity lostUin WHERE lostUin.id.workflowInstanceId =:workflowInstanceId") - public String getLostUinMatchedRegIdByWorkflowId(@Param("workflowInstanceId") String workflowInstanceId); - - @Query(value ="SELECT m FROM ManualVerificationEntity m WHERE m.requestId =:requestId") - public List getRegistrationIdbyRequestId(@Param("requestId") String requestId); - - @Query(value ="SELECT m FROM VerificationEntity m WHERE m.requestId =:requestId") - public List getVerificationRecordByRequestId(@Param("requestId") String requestId); - - @Query(value ="SELECT m FROM VerificationEntity m WHERE m.id.workflowInstanceId =:workflowInstanceId") - public List getVerificationRecordByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); -} +package io.mosip.registration.processor.packet.storage.repository; + +import java.util.List; + +import io.mosip.registration.processor.packet.storage.entity.VerificationEntity; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import io.mosip.kernel.core.dataaccess.spi.repository.BaseRepository; +import io.mosip.registration.processor.packet.storage.entity.AbisRequestEntity; +import io.mosip.registration.processor.packet.storage.entity.AbisResponseDetEntity; +import io.mosip.registration.processor.packet.storage.entity.AbisResponseEntity; +import io.mosip.registration.processor.packet.storage.entity.BasePacketEntity; +import io.mosip.registration.processor.packet.storage.entity.ManualVerificationEntity; +import io.mosip.registration.processor.packet.storage.entity.RegBioRefEntity; +import io.mosip.registration.processor.packet.storage.entity.RegDemoDedupeListEntity; + +/** + * The Interface BasePacketRepository. + * + * @author Girish Yarru + * @param + * the element type + * @param + * the generic type + */ +@Repository +public interface BasePacketRepository, T> extends BaseRepository { + + /** + * Find by user id. + * + * @param qcuserId + * the qcuser id + * @return the list + */ + @Query("SELECT qcUser FROM QcuserRegistrationIdEntity qcUser WHERE qcUser.id.usrId=:qcuserId") + public List findByUserId(@Param("qcuserId") String qcuserId); + + /** + * Find demo by id. + * + * @param regId + * the reg id + * @return the list + */ + @Query("SELECT demo FROM IndividualDemographicDedupeEntity demo WHERE demo.regId=:regId") + public List findDemoById(@Param("regId") String regId); + + /** + * This method gets the first created registration record + * {@link ManualVerificationEntity} with the specified status. + * + * @param statusCode + * The statusCode + * @param matchType + * the match type + * @return {@link ManualVerificationEntity} + */ + @Query(value = "SELECT mve FROM ManualVerificationEntity mve WHERE mve.crDtimes in " + + "(SELECT min(mve2.crDtimes) FROM ManualVerificationEntity mve2 where mve2.statusCode=:statusCode AND mve2.trnTypCode=:trntyp_code) and mve.statusCode=:statusCode") + public List getFirstApplicantDetails(@Param("statusCode") String statusCode, + @Param("trntyp_code") String matchType); + + /** + * This method gets the first created registration record for source name as ALL + * {@link ManualVerificationEntity} with the specified status. + * + * @param statusCode + * The statusCode + * @return {@link ManualVerificationEntity} + */ + @Query(value = "SELECT mve FROM ManualVerificationEntity mve WHERE mve.crDtimes in " + + "(SELECT min(mve2.crDtimes) FROM ManualVerificationEntity mve2 where mve2.statusCode=:statusCode) and mve.statusCode=:statusCode") + public List getFirstApplicantDetailsForAll(@Param("statusCode") String statusCode); + + /** + * This method returns {@link ManualVerificationEntity} corresponding to + * specified registration Id and manual verifier user Id. + * + * @param regId + * The registration Id + * @param refId + * the ref id + * @param mvUserId + * The manual verifier user Id + * @param statusCode + * the status code + * @return {@link ManualVerificationEntity} + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId=:regId and mve.mvUsrId=:mvUserId and mve.id.matchedRefId=:refId and mve.statusCode=:statusCode") + public List getSingleAssignedRecord(@Param("regId") String regId, @Param("refId") String refId, + @Param("mvUserId") String mvUserId, @Param("statusCode") String statusCode); + + /** + * This method returns {@link ManualVerificationEntity} corresponding to + * specified registration Id and manual verifier user Id. + * + * @param regId + * The registration Id + * @param mvUserId + * The manual verifier user Id + * @param statusCode + * the status code + * @return {@link ManualVerificationEntity} + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId=:regId and mve.statusCode=:statusCode") + public List getAllAssignedRecord(@Param("regId") String regId, @Param("statusCode") String statusCode); + + + @Query("SELECT mve FROM VerificationEntity mve where mve.regId=:regId and mve.statusCode=:statusCode") + public List getAssignedVerificationRecord(@Param("regId") String regId, @Param("statusCode") String statusCode); + + /** + * Gets the assigned applicant details. + * + * @param mvUserId + * the mv user id + * @param statusCode + * the status code + * @return the assigned applicant details + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.mvUsrId=:mvUserId and mve.statusCode=:statusCode") + public List getAssignedApplicantDetails(@Param("mvUserId") String mvUserId, + @Param("statusCode") String statusCode); + + /** + * Gets the matched ids for ref id. + * + * @param refId + * the reference id + * @return the List of ManualVerificationEntity records + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.regId =:regId and mve.statusCode =:status_code") + public List getMatchedIds(@Param("regId") String regId, @Param("status_code") String status_code); + + + + /** + * Gets the Manual verification entity based on request id and matchedreference id + * + * @param requestId + * the requestId + * @param matchedRefId + * the Matched reference Id + * @return the ManualVerificationEntity record + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.requestId=:requestId and mve.id.matchedRefId=:matchedRefId") + public E getManualVerificationEntitty(@Param("requestId") String requestId,@Param("matchedRefId") String matchedRefId); + + /** + * Gets the Manual verification entity based on request id and matchedreference id + * + * @param requestId + * the requestId + + * @return the ManualVerificationEntity record + */ + @Query("SELECT mve FROM ManualVerificationEntity mve where mve.requestId=:requestId") + public E getManualVerificationEntityForRID(@Param("requestId") String requestId); + + + + + /** + * Update is active if duplicate found. + * + * @param regId + * the reg id + */ + @Modifying + @Transactional + @Query("UPDATE IndividualDemographicDedupeEntity demo SET demo.isActive = FALSE WHERE demo.regId =:regId") + public void updateIsActiveIfDuplicateFound(@Param("regId") String regId); + + /** + * Gets the reference id by rid. + * + * @param rid + * the rid + * @return the reference id by rid + */ + @Query("SELECT abis.id.bioRefId FROM RegBioRefEntity abis WHERE abis.regId =:rid order by crDtimes desc") + public List getReferenceIdByRid(@Param("rid") String rid); + + @Query("SELECT abis.id.bioRefId FROM RegBioRefEntity abis WHERE abis.id.workflowInstanceId =:workflowInstanceId order by crDtimes desc") + public List getRefIdByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); + + /** + * Gets the rid by reference id. + * + * @param refId + * the ref id + * @return the rid by reference id + */ + @Query("SELECT abis.regId FROM RegBioRefEntity abis WHERE abis.id.bioRefId =:refId") + public List getRidByReferenceId(@Param("refId") String refId); + + /** + * Gets the insert or identify request. + * + * @param bioRefId + * the bio ref id + * @param refRegtrnId + * the ref regtrn id + * @return the insert or identify request + */ + + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.bioRefId =:bioRefId and abisreq.refRegtrnId =:refRegtrnId") + public List getInsertOrIdentifyRequest(@Param("bioRefId") String bioRefId, + @Param("refRegtrnId") String refRegtrnId); + + @Query("SELECT abisreq.bioRefId FROM AbisRequestEntity abisreq WHERE abisreq.reqBatchId =:reqBatchId") + public List getReferenceIdByBatchId(@Param("reqBatchId") String reqBatchId); + + /** + * Get transaction id from Abis request table + * + * @param id + * @return + */ + @Query("SELECT abisreq.refRegtrnId FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") + public List getAbisTransactionIdByRequestId(@Param("id") String id); + + /** + * Gets the identify req list by transaction id. + * + * @param refRegtrnId + * the ref regtrn id + * @param requestType + * the request type + * @return the identify req list by transaction id + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType =:requestType") + public List getIdentifyReqListByTransactionId(@Param("refRegtrnId") String refRegtrnId, + @Param("requestType") String requestType); + + /** + * Gets the abis request by request id. + * + * @param id + * the id + * @return the abis request by request id + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") + public List getAbisRequestByRequestId(@Param("id") String id); + + /** + * Gets the insert or identify request. + * + * @param bioRefId + * the bio ref id + * @param refRegtrnId + * the ref regtrn id + * @param requestType + * the request type + * @return the insert or identify request + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.bioRefId =:bioRefId and abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType =:requestType") + public List getInsertOrIdentifyRequest(@Param("bioRefId") String bioRefId, + @Param("refRegtrnId") String refRegtrnId, @Param("requestType") String requestType); + + /** + * Gets the batch id by request id. + * + * @param id + * the id + * @return the batch id by request id + */ + @Query("SELECT abisreq.reqBatchId FROM AbisRequestEntity abisreq WHERE abisreq.id.id =:id") + public List getBatchIdByRequestId(@Param("id") String id); + + /** + * Gets the batch statusby batch id. + * + * @param reqBatchId + * the req batch id + * @return the batch statusby batch id + */ + @Query("SELECT abisreq.statusCode FROM AbisRequestEntity abisreq WHERE abisreq.reqBatchId =:reqBatchId") + public List getBatchStatusbyBatchId(@Param("reqBatchId") String reqBatchId); + + /** + * Update abis request status code. + * + * @param id + * the id + */ + @Query("UPDATE AbisRequestEntity abisReq SET abisReq.statusCode = 'PROCESSED' WHERE abisReq.id.id =:id") + @Modifying + public void updateAbisRequestStatusCode(@Param("id") String id); + + /** + * Gets the abis request I ds. + * + * @param transactionId + * the transaction id + * @return the abis request I ds + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId") + public List getAbisRequestIDs(@Param("refRegtrnId") String transactionId); + + /** + * Gets the abis request I dsbased on identity. + * + * @param transactionId + * the transaction id + * @param requestType + * the request type + * @return the abis request I dsbased on identity + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:refRegtrnId and abisreq.requestType=:requestType") + public List getAbisRequestIDsbasedOnIdentity(@Param("refRegtrnId") String transactionId, + @Param("requestType") String requestType); + + /** + * Gets the abis response I ds. + * + * @param abisRequest + * the abis request + * @return the abis response I ds + */ + @Query("SELECT abisresp FROM AbisResponseEntity abisresp WHERE abisresp.abisRequest =:abisRequest") + public List getAbisResponseIDs(@Param("abisRequest") String abisRequest); + + /** + * Gets the abis response details. + * + * @param responseId + * the response id + * @return the abis response details + */ + @Query("SELECT abisRespDet FROM AbisResponseDetEntity abisRespDet WHERE abisRespDet.id.abisRespId =:abisRespId") + public List getAbisResponseDetails(@Param("abisRespId") String responseId); + + /** + * Gets the abis response details list. + * + * @param responseId + * the response id + * @return the abis response details list + */ + @Query("SELECT abisRespDet FROM AbisResponseDetEntity abisRespDet WHERE abisRespDet.id.abisRespId in :abisRespIds") + public List getAbisResponseDetailsList(@Param("abisRespIds") List responseId); + + /** + * Gets the bio ref ids. + * + * @param bioRefId + * the bio ref id + * @return the bio ref ids + */ + @Query("SELECT regBioRef.regId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId in :bioRefIds") + public List getAbisRefRegIdsByMatchedRefIds(@Param("bioRefIds") List bioRefId); + + /** + * Gets the RegId by bioRefId,process & iteration. + * @param bioRefId + * @param workflowInstanceId + * @return regId + */ + @Query("SELECT regBioRef.regId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId=:bioRefId and regBioRef.id.workflowInstanceId=:workflowInstanceId") + public String getRegIdByRefIdAndWorkflowInstanceId(@Param("bioRefId") String bioRefId, @Param("workflowInstanceId") String workflowInstanceId); + + /** + * Gets the bio Ref entity list by bioRefId. + * @param bioRefIds + * @return RegBioRef Entities + */ + @Query("SELECT regBioRef FROM RegBioRefEntity regBioRef WHERE regBioRef.id.bioRefId in :bioRefIds") + public List getBioRefIdsByRefIds(@Param("bioRefIds") List bioRefId); + + /** + * Gets the identify by transaction id. + * + * @param transactionId + * the transaction id + * @param identify + * the identify + * @return the identify by transaction id + */ + @Query("SELECT abisreq FROM AbisRequestEntity abisreq WHERE abisreq.refRegtrnId =:transactionId and abisreq.requestType =:identify") + public List getIdentifyByTransactionId(@Param("transactionId") String transactionId, + @Param("identify") String identify); + + /** + * Gets the bio ref id by reg id. + * + * @param regId + * the reg id + * @return the bio ref id by reg id + */ + @Query("SELECT bioRef.id.bioRefId FROM RegBioRefEntity bioRef WHERE bioRef.regId =:regId") + public List getBioRefIdByRegIds(@Param("regId") String regId); + + /** + * Gets the reg id by bio ref id. + * + * @param bioRefId + * the bio ref id + * @return the reg id by bio ref id + */ + @Query("SELECT bioRef.regId FROM RegBioRefEntity bioRef WHERE LOWER(bioRef.id.bioRefId) =:bioRefId") + public String getRegIdByBioRefId(@Param("bioRefId") String bioRefId); + + /** + * Gets the bio ref id by reg id. + * + * @param regId + * the reg id + * @return the bio ref id by reg id + */ + @Query("SELECT bioRef FROM RegBioRefEntity bioRef WHERE bioRef.regId =:regId") + public List getBioRefIdByRegId(@Param("regId") String regId); + + /** + * Gets the demo list by transaction id. + * + * @param regtrnId + * the regtrn id + * @return the demo list by transaction id + */ + @Query("SELECT regDemo FROM RegDemoDedupeListEntity regDemo WHERE regDemo.id.regtrnId =:regtrnId") + public List getDemoListByTransactionId(@Param("regtrnId") String regtrnId); + + /** + * Gets the abis ref matched ref id by rid. + * + * @param regId + * the reg id + * @return the abis ref matched ref id by rid + */ + @Query("SELECT regBioRef.id.bioRefId FROM RegBioRefEntity regBioRef WHERE regBioRef.regId =:regId order by regBioRef.crDtimes desc") + public List getAbisRefMatchedRefIdByRid(@Param("regId") String regId); + + @Query("SELECT regBioRef.id.bioRefId FROM RegBioRefEntity regBioRef WHERE regBioRef.id.workflowInstanceId =:workflowInstanceId order by regBioRef.crDtimes desc") + public List getAbisRefIdByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); + + /** + * Gets the abis requests by bio ref id. + * + * @param bioRefId + * the bio ref id + * @param insert + * the insert + * @return the abis requests by bio ref id + */ + @Query("SELECT abisReq FROM AbisRequestEntity abisReq WHERE abisReq.bioRefId =:bioRefId and abisReq.requestType =:insert") + public List getAbisRequestsByBioRefId(@Param("bioRefId") String bioRefId, + @Param("insert") String insert); + + /** + * Gets the abis processed requests app code by bio ref id. + * + * @param bioRefId + * the bio ref id + * @param requestType + * the request type + * @param statusCode + * the status code + * @return the abis processed requests app code by bio ref id + */ + @Query("SELECT abisReq.abisAppCode FROM AbisRequestEntity abisReq WHERE abisReq.bioRefId =:bioRefId and abisReq.requestType =:requestType and abisReq.statusCode =:statusCode") + public List getAbisProcessedRequestsAppCodeByBioRefId(@Param("bioRefId") String bioRefId, + @Param("requestType") String requestType, @Param("statusCode") String statusCode); + + @Query("SELECT latestRegId FROM RegLostUinDetEntity lostUin WHERE lostUin.regId =:regId") + public String getLostUinMatchedRegId(@Param("regId") String regId); + + @Query("SELECT latestRegId FROM RegLostUinDetEntity lostUin WHERE lostUin.id.workflowInstanceId =:workflowInstanceId") + public String getLostUinMatchedRegIdByWorkflowId(@Param("workflowInstanceId") String workflowInstanceId); + + @Query(value ="SELECT m FROM ManualVerificationEntity m WHERE m.requestId =:requestId") + public List getRegistrationIdbyRequestId(@Param("requestId") String requestId); + + @Query(value ="SELECT m FROM VerificationEntity m WHERE m.requestId =:requestId") + public List getVerificationRecordByRequestId(@Param("requestId") String requestId); + + @Query(value ="SELECT m FROM VerificationEntity m WHERE m.id.workflowInstanceId =:workflowInstanceId") + public List getVerificationRecordByWorkflowInstanceId(@Param("workflowInstanceId") String workflowInstanceId); +} diff --git a/registration-processor/registration-processor-message-sender-impl/pom.xml b/registration-processor/registration-processor-message-sender-impl/pom.xml index 0cd8a7cc5e4..19374114397 100644 --- a/registration-processor/registration-processor-message-sender-impl/pom.xml +++ b/registration-processor/registration-processor-message-sender-impl/pom.xml @@ -21,11 +21,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/registration-processor-notification-service/pom.xml b/registration-processor/registration-processor-notification-service/pom.xml index 18510c96c9e..33bbeb5dc77 100644 --- a/registration-processor/registration-processor-notification-service/pom.xml +++ b/registration-processor/registration-processor-notification-service/pom.xml @@ -21,11 +21,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/registration-processor-packet-manager/pom.xml b/registration-processor/registration-processor-packet-manager/pom.xml index a2a14f950ff..48e650ab007 100644 --- a/registration-processor/registration-processor-packet-manager/pom.xml +++ b/registration-processor/registration-processor-packet-manager/pom.xml @@ -82,5 +82,15 @@ powermock-api-mockito2 test + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java index 9ce97b2885b..5e0734f1fb4 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java @@ -1,146 +1,145 @@ -package io.mosip.registration.processor.status.config; - -import io.mosip.registration.processor.status.service.AdditionalInfoRequestService; -import io.mosip.registration.processor.status.service.AnonymousProfileService; -import io.mosip.registration.processor.status.service.impl.AdditionalInfoRequestServiceImpl; -import io.mosip.registration.processor.status.service.impl.AnonymousProfileServiceImpl; - -import io.mosip.registration.processor.status.utilities.RegistrationUtility; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.PropertySource; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; -import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.rest.client.utils.RestApiClient; -import io.mosip.registration.processor.status.dao.RegistrationStatusDao; -import io.mosip.registration.processor.status.dao.SyncRegistrationDao; -import io.mosip.registration.processor.status.decryptor.Decryptor; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.dto.TransactionDto; -import io.mosip.registration.processor.status.encryptor.Encryptor; -import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; -import io.mosip.registration.processor.status.entity.BaseRegistrationPKEntity; -import io.mosip.registration.processor.status.entity.BaseSyncRegistrationEntity; -import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; -import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.SyncRegistrationService; -import io.mosip.registration.processor.status.service.TransactionService; -import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; -import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; -import io.mosip.registration.processor.status.service.impl.TransactionServiceImpl; -import io.mosip.registration.processor.status.utilities.RegistrationExternalStatusUtility; - -@Configuration -@PropertySource("classpath:bootstrap.properties") -@Import({ HibernateDaoConfig.class }) -@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) -public class RegistrationStatusBeanConfig { - - @Bean - @Primary - public RegistrationStatusService getRegistrationStatusService() { - return new RegistrationStatusServiceImpl(); - } - - @Bean - public AuditLogRequestBuilder getAuditLogRequestBuilder() { - return new AuditLogRequestBuilder(); - } - -// @Bean -// public RegistrationProcessorRestClientService getRegistrationProcessorRestClientService() { -// return new RegistrationProcessorRestClientServiceImpl(); -// } - - @Bean - public SyncRegistrationDao getSyncRegistrationDao() { - return new SyncRegistrationDao(); - } - - @Bean - public RestTemplateBuilder getRestTemplateBuilder() { - return new RestTemplateBuilder(); - } - - @Bean - public RegistrationStatusDao getRegistrationStatusDao() { - return new RegistrationStatusDao(); - } - - @Bean - @Primary - public TransactionService getTransactionService() { - return new TransactionServiceImpl(); - } - - @Bean - public RestApiClient getRestApiClient() { - return new RestApiClient(); - } - - @Bean - public SyncRegistrationService getSyncRegistrationService() { - return new SyncRegistrationServiceImpl(); - } - - @Bean - public InternalRegistrationStatusDto internalRegistrationStatusDto() { - return new InternalRegistrationStatusDto(); - } - - @Bean - public RegistrationStatusEntity registrationStatusEntity() { - return new RegistrationStatusEntity(); - } - - @Bean - public BaseRegistrationEntity baseRegistrationStatusEntity() { - return new RegistrationStatusEntity(); - } - - @Bean - public BaseSyncRegistrationEntity baseSyncRegistrationEntity() { - return new SyncRegistrationEntity(); - } - - @Bean - @Primary - public RegistrationExternalStatusUtility getRegistrationExternalStatusUtility() { - return new RegistrationExternalStatusUtility(); - } - - @Bean - public Decryptor decryptor() { - return new Decryptor(); - } - - @Bean - public Encryptor encryptor() { - return new Encryptor(); - } - - @Bean - public AdditionalInfoRequestService additionalInfoRequestService() { - return new AdditionalInfoRequestServiceImpl(); - } - - @Bean - public AnonymousProfileService anonymousProfileService() { - return new AnonymousProfileServiceImpl(); - } - - @Bean - public RegistrationUtility registrationUtility() { - return new RegistrationUtility(); - } -} +package io.mosip.registration.processor.status.config; + +import io.mosip.registration.processor.status.service.AdditionalInfoRequestService; +import io.mosip.registration.processor.status.service.AnonymousProfileService; +import io.mosip.registration.processor.status.service.impl.AdditionalInfoRequestServiceImpl; +import io.mosip.registration.processor.status.service.impl.AnonymousProfileServiceImpl; + +import io.mosip.registration.processor.status.utilities.RegistrationUtility; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.PropertySource; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + + +import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.rest.client.utils.RestApiClient; +import io.mosip.registration.processor.status.dao.RegistrationStatusDao; +import io.mosip.registration.processor.status.dao.SyncRegistrationDao; +import io.mosip.registration.processor.status.decryptor.Decryptor; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.dto.TransactionDto; +import io.mosip.registration.processor.status.encryptor.Encryptor; +import io.mosip.registration.processor.status.entity.BaseRegistrationEntity; +import io.mosip.registration.processor.status.entity.BaseRegistrationPKEntity; +import io.mosip.registration.processor.status.entity.BaseSyncRegistrationEntity; +import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; +import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; +import io.mosip.registration.processor.status.service.TransactionService; +import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; +import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; +import io.mosip.registration.processor.status.service.impl.TransactionServiceImpl; +import io.mosip.registration.processor.status.utilities.RegistrationExternalStatusUtility; + +@Configuration +@PropertySource("classpath:bootstrap.properties") +@EnableJpaRepositories(basePackages = "io.mosip.registration.processor.status.repositary", repositoryBaseClass = HibernateRepositoryImpl.class) +public class RegistrationStatusBeanConfig { + + @Bean + @Primary + public RegistrationStatusService getRegistrationStatusService() { + return new RegistrationStatusServiceImpl(); + } + + @Bean + public AuditLogRequestBuilder getAuditLogRequestBuilder() { + return new AuditLogRequestBuilder(); + } + +// @Bean +// public RegistrationProcessorRestClientService getRegistrationProcessorRestClientService() { +// return new RegistrationProcessorRestClientServiceImpl(); +// } + + @Bean + public SyncRegistrationDao getSyncRegistrationDao() { + return new SyncRegistrationDao(); + } + + @Bean + public RestTemplateBuilder getRestTemplateBuilder() { + return new RestTemplateBuilder(); + } + + @Bean + public RegistrationStatusDao getRegistrationStatusDao() { + return new RegistrationStatusDao(); + } + + @Bean + @Primary + public TransactionService getTransactionService() { + return new TransactionServiceImpl(); + } + + @Bean + public RestApiClient getRestApiClient() { + return new RestApiClient(); + } + + @Bean + public SyncRegistrationService getSyncRegistrationService() { + return new SyncRegistrationServiceImpl(); + } + + @Bean + public InternalRegistrationStatusDto internalRegistrationStatusDto() { + return new InternalRegistrationStatusDto(); + } + + @Bean + public RegistrationStatusEntity registrationStatusEntity() { + return new RegistrationStatusEntity(); + } + + @Bean + public BaseRegistrationEntity baseRegistrationStatusEntity() { + return new RegistrationStatusEntity(); + } + + @Bean + public BaseSyncRegistrationEntity baseSyncRegistrationEntity() { + return new SyncRegistrationEntity(); + } + + @Bean + @Primary + public RegistrationExternalStatusUtility getRegistrationExternalStatusUtility() { + return new RegistrationExternalStatusUtility(); + } + + @Bean + public Decryptor decryptor() { + return new Decryptor(); + } + + @Bean + public Encryptor encryptor() { + return new Encryptor(); + } + + @Bean + public AdditionalInfoRequestService additionalInfoRequestService() { + return new AdditionalInfoRequestServiceImpl(); + } + + @Bean + public AnonymousProfileService anonymousProfileService() { + return new AnonymousProfileServiceImpl(); + } + + @Bean + public RegistrationUtility registrationUtility() { + return new RegistrationUtility(); + } +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestEntity.java index 6a44d079bc7..2332fca0171 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestEntity.java @@ -1,83 +1,83 @@ -package io.mosip.registration.processor.status.entity; - -import java.io.Serializable; -import java.time.LocalDateTime; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * The persistent class for the additional_info_request table. - * - */ -@Entity -@Table(name = "additional_info_request", schema = "regprc") -public class AdditionalInfoRequestEntity extends BasePacketEntity implements Serializable { - private static final long serialVersionUID = 1L; - - @Column(name = "reg_id") - private String regId; - - @Column(name = "additional_info_process") - private String additionalInfoProcess; - - @Column(name = "additional_info_iteration") - private int additionalInfoIteration; - - @Column(name = "timestamp", updatable = false) - private LocalDateTime timestamp; - - public AdditionalInfoRequestEntity() { - - } - - public String getRegId() { - return regId; - } - - public void setRegId(String regId) { - this.regId = regId; - } - - public String getAdditionalInfoProcess() { - return additionalInfoProcess; - } - - public void setAdditionalInfoProcess(String additionalInfoProcess) { - this.additionalInfoProcess = additionalInfoProcess; - } - - public int getAdditionalInfoIteration() { - return additionalInfoIteration; - } - - public void setAdditionalInfoIteration(int additionalInfoIteration) { - this.additionalInfoIteration = additionalInfoIteration; - } - - public LocalDateTime getTimestamp() { - return timestamp; - } - - public void setTimestamp(LocalDateTime timestamp) { - this.timestamp = timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AdditionalInfoRequestEntity that = (AdditionalInfoRequestEntity) o; - return additionalInfoIteration == that.additionalInfoIteration && - additionalInfoProcess.equals(that.additionalInfoProcess) && - regId.equals(that.regId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash(regId, additionalInfoProcess, additionalInfoIteration, timestamp); - } +package io.mosip.registration.processor.status.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * The persistent class for the additional_info_request table. + * + */ +@Entity +@Table(name = "additional_info_request", schema = "regprc") +public class AdditionalInfoRequestEntity extends BasePacketEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name = "reg_id") + private String regId; + + @Column(name = "additional_info_process") + private String additionalInfoProcess; + + @Column(name = "additional_info_iteration") + private int additionalInfoIteration; + + @Column(name = "timestamp", updatable = false) + private LocalDateTime timestamp; + + public AdditionalInfoRequestEntity() { + + } + + public String getRegId() { + return regId; + } + + public void setRegId(String regId) { + this.regId = regId; + } + + public String getAdditionalInfoProcess() { + return additionalInfoProcess; + } + + public void setAdditionalInfoProcess(String additionalInfoProcess) { + this.additionalInfoProcess = additionalInfoProcess; + } + + public int getAdditionalInfoIteration() { + return additionalInfoIteration; + } + + public void setAdditionalInfoIteration(int additionalInfoIteration) { + this.additionalInfoIteration = additionalInfoIteration; + } + + public LocalDateTime getTimestamp() { + return timestamp; + } + + public void setTimestamp(LocalDateTime timestamp) { + this.timestamp = timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AdditionalInfoRequestEntity that = (AdditionalInfoRequestEntity) o; + return additionalInfoIteration == that.additionalInfoIteration && + additionalInfoProcess.equals(that.additionalInfoProcess) && + regId.equals(that.regId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(regId, additionalInfoProcess, additionalInfoIteration, timestamp); + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestPKEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestPKEntity.java index 1a4c2785dea..bc469462c2a 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestPKEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AdditionalInfoRequestPKEntity.java @@ -1,51 +1,51 @@ -package io.mosip.registration.processor.status.entity; - -import javax.persistence.Column; -import javax.persistence.Embeddable; -import java.io.Serializable; -import java.util.Objects; - -@Embeddable -public class AdditionalInfoRequestPKEntity implements Serializable { - // default serial version id, required for serializable classes. - private static final long serialVersionUID = 1L; - - @Column(name = "workflow_instance_id") - private String workflowInstanceId; - - @Column(name = "additional_info_req_id") - private String additionalInfoReqId; - - public AdditionalInfoRequestPKEntity() { - } - - public String getAdditionalInfoReqId() { - return additionalInfoReqId; - } - - public void setAdditionalInfoReqId(String additionalInfoReqId) { - this.additionalInfoReqId = additionalInfoReqId; - } - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - AdditionalInfoRequestPKEntity that = (AdditionalInfoRequestPKEntity) o; - return workflowInstanceId.equals(that.workflowInstanceId) && - additionalInfoReqId.equals(that.additionalInfoReqId); - } - - @Override - public int hashCode() { - return Objects.hash(workflowInstanceId, additionalInfoReqId); - } +package io.mosip.registration.processor.status.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import java.io.Serializable; +import java.util.Objects; + +@Embeddable +public class AdditionalInfoRequestPKEntity implements Serializable { + // default serial version id, required for serializable classes. + private static final long serialVersionUID = 1L; + + @Column(name = "workflow_instance_id") + private String workflowInstanceId; + + @Column(name = "additional_info_req_id") + private String additionalInfoReqId; + + public AdditionalInfoRequestPKEntity() { + } + + public String getAdditionalInfoReqId() { + return additionalInfoReqId; + } + + public void setAdditionalInfoReqId(String additionalInfoReqId) { + this.additionalInfoReqId = additionalInfoReqId; + } + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AdditionalInfoRequestPKEntity that = (AdditionalInfoRequestPKEntity) o; + return workflowInstanceId.equals(that.workflowInstanceId) && + additionalInfoReqId.equals(that.additionalInfoReqId); + } + + @Override + public int hashCode() { + return Objects.hash(workflowInstanceId, additionalInfoReqId); + } } \ No newline at end of file diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfileEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfileEntity.java index 084ecce290c..63092306a05 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfileEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfileEntity.java @@ -3,9 +3,9 @@ import java.io.Serializable; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; @Entity @Table(name = "anonymous_profile", schema = "regprc") public class AnonymousProfileEntity extends BasePacketEntity implements Serializable{ diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfilePKEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfilePKEntity.java index 5d876a8961e..8bfe94f73f4 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfilePKEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/AnonymousProfilePKEntity.java @@ -2,9 +2,9 @@ import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Embeddable; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Id; @Embeddable public class AnonymousProfilePKEntity implements Serializable{ //default serial version id, required for serializable classes. diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BasePacketEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BasePacketEntity.java index 506fb642409..4de693790e9 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BasePacketEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BasePacketEntity.java @@ -1,40 +1,40 @@ -package io.mosip.registration.processor.status.entity; - -import javax.persistence.EmbeddedId; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.MappedSuperclass; - -/** - * The Class BasePacketEntity. - * - * @author Girish Yarru - * @param the generic type - */ -@MappedSuperclass -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -public class BasePacketEntity { - - /** The id. */ - @EmbeddedId - protected C id; - - /** - * Gets the id. - * - * @return the id - */ - public C getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(C id) { - this.id = id; - } - -} +package io.mosip.registration.processor.status.entity; + +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.MappedSuperclass; + +/** + * The Class BasePacketEntity. + * + * @author Girish Yarru + * @param the generic type + */ +@MappedSuperclass +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class BasePacketEntity { + + /** The id. */ + @EmbeddedId + protected C id; + + /** + * Gets the id. + * + * @return the id + */ + public C getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(C id) { + this.id = id; + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java index 56e1bb30a96..1a49bd6d4cf 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java @@ -1,43 +1,45 @@ -package io.mosip.registration.processor.status.entity; - - -import javax.persistence.EmbeddedId; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.MappedSuperclass; - -/** - * The Class BaseRegistrationEntity. - * - * @author Girish Yarru - */ -// Common Entity where RegistrationStatusEntity,Transaction Enity and -// SyncRegistrationEntity extends this. This is created to implement common -// repository(RegistrationRepository) - -@MappedSuperclass -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -public class BaseRegistrationEntity { - - @EmbeddedId - protected C id; - - /** - * Gets the id. - * - * @return the id - */ - public C getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(C id) { - this.id = id; - } - -} +package io.mosip.registration.processor.status.entity; + + +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.MappedSuperclass; + +/** + * The Class BaseRegistrationEntity. + * + * @author Girish Yarru + */ +// Common Entity where RegistrationStatusEntity,Transaction Enity and +// SyncRegistrationEntity extends this. This is created to implement common +// repository(RegistrationRepository) + + +@MappedSuperclass +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class BaseRegistrationEntity { + + @EmbeddedId + protected C id; + + /** + * Gets the id. + * + * @return the id + */ + public C getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(C id) { + this.id = id; + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationPKEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationPKEntity.java index e62bc9da605..a51a892e0a2 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationPKEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationPKEntity.java @@ -1,45 +1,45 @@ -package io.mosip.registration.processor.status.entity; - -import java.io.Serializable; -import java.util.Objects; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - - -@Embeddable -public class BaseRegistrationPKEntity implements Serializable{ - - /** - * - */ - private static final long serialVersionUID = 1L; - - @Column(name = "workflow_instance_id") - protected String workflowInstanceId; - - public BaseRegistrationPKEntity() { - super(); - } - - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - public void setWorkflowInstanceId(String workflowInstanceId) { - this.workflowInstanceId = workflowInstanceId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - BaseRegistrationPKEntity that = (BaseRegistrationPKEntity) o; - return Objects.equals(workflowInstanceId, that.workflowInstanceId); - } - - @Override - public int hashCode() { - return Objects.hash(workflowInstanceId); - } -} +package io.mosip.registration.processor.status.entity; + +import java.io.Serializable; +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; + + +@Embeddable +public class BaseRegistrationPKEntity implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + + @Column(name = "workflow_instance_id") + protected String workflowInstanceId; + + public BaseRegistrationPKEntity() { + super(); + } + + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + public void setWorkflowInstanceId(String workflowInstanceId) { + this.workflowInstanceId = workflowInstanceId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + BaseRegistrationPKEntity that = (BaseRegistrationPKEntity) o; + return Objects.equals(workflowInstanceId, that.workflowInstanceId); + } + + @Override + public int hashCode() { + return Objects.hash(workflowInstanceId); + } +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseSyncRegistrationEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseSyncRegistrationEntity.java index fe578771a0f..cf0340c6da5 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseSyncRegistrationEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseSyncRegistrationEntity.java @@ -1,52 +1,52 @@ -package io.mosip.registration.processor.status.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; - -/** - * The Class BaseSyncRegistrationEntity. - * - * @author Mamta Andhe - */ -// Common Entity where Transaction Enity and -// SyncRegistrationEntity extends this. This is created to implement common -// repository(RegistrationRepository) - -@Entity -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -public abstract class BaseSyncRegistrationEntity { - - /** - * Instantiates a new base registration entity. - */ - public BaseSyncRegistrationEntity() { - super(); - } - - /** The id. */ - @Column(name = "workflow_instance_id", nullable = false) - @Id - protected String workflowInstanceId; - - /** - * Gets the id. - * - * @return the id - */ - public String getWorkflowInstanceId() { - return workflowInstanceId; - } - - /** - * Sets the id. - * - * @param baseId the new id - */ - public void setWorkflowInstanceId(String baseId) { - this.workflowInstanceId = baseId; - } - -} +package io.mosip.registration.processor.status.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; + +/** + * The Class BaseSyncRegistrationEntity. + * + * @author Mamta Andhe + */ +// Common Entity where Transaction Enity and +// SyncRegistrationEntity extends this. This is created to implement common +// repository(RegistrationRepository) + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public abstract class BaseSyncRegistrationEntity { + + /** + * Instantiates a new base registration entity. + */ + public BaseSyncRegistrationEntity() { + super(); + } + + /** The id. */ + @Column(name = "workflow_instance_id", nullable = false) + @Id + protected String workflowInstanceId; + + /** + * Gets the id. + * + * @return the id + */ + public String getWorkflowInstanceId() { + return workflowInstanceId; + } + + /** + * Sets the id. + * + * @param baseId the new id + */ + public void setWorkflowInstanceId(String baseId) { + this.workflowInstanceId = baseId; + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseTransactionEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseTransactionEntity.java index 1de5d328d7a..0aa84411d80 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseTransactionEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseTransactionEntity.java @@ -1,28 +1,28 @@ -package io.mosip.registration.processor.status.entity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; - -@Entity -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) -public class BaseTransactionEntity { - - @Column(name = "id", nullable = false) - @Id - protected String id; - - public BaseTransactionEntity() { - super(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} +package io.mosip.registration.processor.status.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class BaseTransactionEntity { + + @Column(name = "id", nullable = false) + @Id + protected String id; + + public BaseTransactionEntity() { + super(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/RegistrationStatusEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/RegistrationStatusEntity.java index 0f40de4eaa2..28d8bf3d6e9 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/RegistrationStatusEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/RegistrationStatusEntity.java @@ -4,10 +4,10 @@ import java.time.LocalDateTime; import java.util.Objects; -import javax.persistence.Column; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; /** * The Class RegistrationStatusEntity. diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SaltEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SaltEntity.java index fa427c5b258..ea39601f0bc 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SaltEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SaltEntity.java @@ -2,10 +2,10 @@ import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; import lombok.Data; diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SyncRegistrationEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SyncRegistrationEntity.java index 4f075a4184b..19500dbf6cb 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SyncRegistrationEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/SyncRegistrationEntity.java @@ -7,9 +7,9 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; /** * The Class SyncRegistrationEntity. diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/TransactionEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/TransactionEntity.java index 16984b224fe..e36723cd912 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/TransactionEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/TransactionEntity.java @@ -1,412 +1,412 @@ -package io.mosip.registration.processor.status.entity; - -import java.time.LocalDateTime; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; - -/** - * The Class TransactionEntity. - */ -@Entity -@Table(name = "registration_transaction", schema = "regprc") -public class TransactionEntity extends BaseTransactionEntity { - - /** The registration id. */ - @Column(name = "reg_id") - private String registrationId; - - /** The trntypecode. */ - @Column(name = "trn_type_code") - private String trntypecode; - - /** The remarks. */ - @Column(name = "remarks") - private String remarks; - - /** The parentid. */ - @Column(name = "parent_regtrn_id") - private String parentid; - - /** The status code. */ - @Column(name = "status_code") - private String statusCode; - - /** The sub status code. */ - @Column(name = "sub_status_code") - private String subStatusCode; - - /** The lang code. */ - @Column(name = "lang_code") - private String langCode = "eng"; - - /** The status comment. */ - @Column(name = "status_comment") - private String statusComment; - - /** The reference id. */ - @Column(name = "ref_id") - private String referenceId; - - /** The reference id type. */ - @Column(name = "ref_id_type") - private String referenceIdType; - - /** is deleted?. */ - @Column(name = "is_deleted", length = 32) - private Boolean isDeleted ; - - /** The update date time. */ - @Column(name = "del_dtimes") - private LocalDateTime deleteDateTime; - - /** The created by. */ - @Column(name = "cr_by") - private String createdBy = "MOSIP_SYSTEM"; - - /** The create date time. */ - @Column(name = "cr_dtimes") - private LocalDateTime createDateTime; - - /** The updated by. */ - @Column(name = "upd_by", length = 32) - private String updatedBy = "MOSIP_SYSTEM"; - - /** The update date time. */ - @Column(name = "upd_dtimes") - private LocalDateTime updateDateTime; - - /** - * Instantiates a new transaction entity. - */ - public TransactionEntity() { - super(); - } - - /** - * Instantiates a new transaction entity. - * - * @param transactionId the transaction id - * @param registrationId the registration id - * @param parentid the parentid - * @param trntypecode the trntypecode - * @param statusCode the status code - * @param statusComment the status comment - */ - public TransactionEntity(String transactionId, String registrationId, String parentid, String trntypecode, - String subStatusCode,String statusCode, String statusComment) { - id = transactionId; - this.registrationId = registrationId; - this.parentid = parentid; - this.trntypecode = trntypecode; - this.statusCode = statusCode; - this.statusComment = statusComment; - this.subStatusCode=subStatusCode; - } - - /** - * Get Enrolment_Id from transaction table. - * - * @return the enrolmentId - */ - public String getRegistrationId() { - return registrationId; - } - - /** - * Set RegistrationId to transaction table. - * - * @param registrationId - * the new registration id - */ - public void setRegistrationId(String registrationId) { - this.registrationId = registrationId; - } - - /** - * Get parent id from transaction table. - * - * @return the parentid - */ - public String getParentid() { - return parentid; - } - - /** - * Set parent id to transaction table. - * - * @param parentid - * the parentid to set - */ - public void setParentid(String parentid) { - this.parentid = parentid; - } - - /** - * Get trn_type_code from transaction table. - * - * @return the trntypecode - */ - public String getTrntypecode() { - return trntypecode; - } - - /** - * Set trn_type_code to transaction table. - * - * @param trntypecode - * the trntypecode to set - */ - public void setTrntypecode(String trntypecode) { - this.trntypecode = trntypecode; - } - - /** - * Get remarks from transaction table. - * - * @return the remarks - */ - public String getRemarks() { - return remarks; - } - - /** - * Set remarks to transaction table. - * - * @param remarks - * the remarks to set - */ - public void setRemarks(String remarks) { - this.remarks = remarks; - } - - /** - * Get Status Code from transaction table. - * - * @return the statusCode - */ - public String getStatusCode() { - return statusCode; - } - - /** - * Set status Code to transaction table. - * - * @param statusCode - * the statusCode to set - */ - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - /** - * Get sub Status Code from transaction table. - * @return - * the subStatusCode - */ - public String getSubStatusCode() { - return subStatusCode; - } - - /** - * Set sub status Code to transaction table. - * @param subStatusCode - * the subStatusCode to set - */ - public void setSubStatusCode(String subStatusCode) { - this.subStatusCode = subStatusCode; - } - - /** - * Get lang_Code from transaction table. - * - * @return the langCode - */ - public String getLangCode() { - return langCode; - } - - /** - * Set lang Code to transaction table. - * - * @param langCode - * the langCode to set - */ - public void setLangCode(String langCode) { - this.langCode = langCode; - } - - /** - * Get referenceId from transaction table. - * - * @return the referenceId - */ - public String getReferenceId() { - return referenceId; - } - - /** - * Set referenceId to transaction table. - * - * @param referenceId - * the referenceId to set - */ - public void setReferenceId(String referenceId) { - this.referenceId = referenceId; - } - - /** - * Get referenceIdType from transaction table. - * - * @return the referenceIdType - */ - public String getReferenceIdType() { - return referenceIdType; - } - - /** - * Set referenceIdType to transaction table. - * - * @param referenceIdType - * the referenceIdType to set - */ - public void setReferenceIdType(String referenceIdType) { - this.referenceIdType = referenceIdType; - } - - /** - * Get status Comment from transaction table. - * - * @return the statusComment - */ - public String getStatusComment() { - return statusComment; - } - - /** - * Set status comment to transaction table. - * - * @param statusComment - * the statusComment to set - */ - public void setStatusComment(String statusComment) { - this.statusComment = statusComment; - } - - - - /** - * Gets the checks if is deleted. - * - * @return the checks if is deleted - */ - public Boolean getIsDeleted() { - return isDeleted; - } - - /** - * Sets the checks if is deleted. - * - * @param isDeleted the new checks if is deleted - */ - public void setIsDeleted(Boolean isDeleted) { - this.isDeleted = isDeleted; - } - - /** - * Gets the delete date time. - * - * @return the delete date time - */ - public LocalDateTime getDeleteDateTime() { - return deleteDateTime; - } - - /** - * Sets the delete date time. - * - * @param deleteDateTime the new delete date time - */ - public void setDeleteDateTime(LocalDateTime deleteDateTime) { - this.deleteDateTime = deleteDateTime; - } - - /** - * Get created By from transaction table. - * - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * Set created By to transaction table. - * - * @param createdBy - * the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - /** - * Get create Date Time from transaction table. - * - * @return the createDateTime - */ - - public LocalDateTime getCreateDateTime() { - return createDateTime; - } - - /** - * Set create Date Time to transaction table. - * - * @param createDateTime - * the createDateTime to set - */ - public void setCreateDateTime(LocalDateTime createDateTime) { - this.createDateTime = createDateTime; - } - - /** - * Get updated By from transaction table. - * - * @return the updatedBy - */ - public String getUpdatedBy() { - return updatedBy; - } - - /** - * Set updated By to transaction table. - * - * @param updatedBy - * the updatedBy to set - */ - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - /** - * Get update Date Time By from transaction table. - * - * @return the updateDateTime - */ - public LocalDateTime getUpdateDateTime() { - return updateDateTime; - } - - /** - * Set update Date Time to transaction table. - * - * @param updateDateTime - * the updateDateTime to set - */ - public void setUpdateDateTime(LocalDateTime updateDateTime) { - this.updateDateTime = updateDateTime; - } - -} +package io.mosip.registration.processor.status.entity; + +import java.time.LocalDateTime; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +/** + * The Class TransactionEntity. + */ +@Entity +@Table(name = "registration_transaction", schema = "regprc") +public class TransactionEntity extends BaseTransactionEntity { + + /** The registration id. */ + @Column(name = "reg_id") + private String registrationId; + + /** The trntypecode. */ + @Column(name = "trn_type_code") + private String trntypecode; + + /** The remarks. */ + @Column(name = "remarks") + private String remarks; + + /** The parentid. */ + @Column(name = "parent_regtrn_id") + private String parentid; + + /** The status code. */ + @Column(name = "status_code") + private String statusCode; + + /** The sub status code. */ + @Column(name = "sub_status_code") + private String subStatusCode; + + /** The lang code. */ + @Column(name = "lang_code") + private String langCode = "eng"; + + /** The status comment. */ + @Column(name = "status_comment") + private String statusComment; + + /** The reference id. */ + @Column(name = "ref_id") + private String referenceId; + + /** The reference id type. */ + @Column(name = "ref_id_type") + private String referenceIdType; + + /** is deleted?. */ + @Column(name = "is_deleted", length = 32) + private Boolean isDeleted ; + + /** The update date time. */ + @Column(name = "del_dtimes") + private LocalDateTime deleteDateTime; + + /** The created by. */ + @Column(name = "cr_by") + private String createdBy = "MOSIP_SYSTEM"; + + /** The create date time. */ + @Column(name = "cr_dtimes") + private LocalDateTime createDateTime; + + /** The updated by. */ + @Column(name = "upd_by", length = 32) + private String updatedBy = "MOSIP_SYSTEM"; + + /** The update date time. */ + @Column(name = "upd_dtimes") + private LocalDateTime updateDateTime; + + /** + * Instantiates a new transaction entity. + */ + public TransactionEntity() { + super(); + } + + /** + * Instantiates a new transaction entity. + * + * @param transactionId the transaction id + * @param registrationId the registration id + * @param parentid the parentid + * @param trntypecode the trntypecode + * @param statusCode the status code + * @param statusComment the status comment + */ + public TransactionEntity(String transactionId, String registrationId, String parentid, String trntypecode, + String subStatusCode,String statusCode, String statusComment) { + id = transactionId; + this.registrationId = registrationId; + this.parentid = parentid; + this.trntypecode = trntypecode; + this.statusCode = statusCode; + this.statusComment = statusComment; + this.subStatusCode=subStatusCode; + } + + /** + * Get Enrolment_Id from transaction table. + * + * @return the enrolmentId + */ + public String getRegistrationId() { + return registrationId; + } + + /** + * Set RegistrationId to transaction table. + * + * @param registrationId + * the new registration id + */ + public void setRegistrationId(String registrationId) { + this.registrationId = registrationId; + } + + /** + * Get parent id from transaction table. + * + * @return the parentid + */ + public String getParentid() { + return parentid; + } + + /** + * Set parent id to transaction table. + * + * @param parentid + * the parentid to set + */ + public void setParentid(String parentid) { + this.parentid = parentid; + } + + /** + * Get trn_type_code from transaction table. + * + * @return the trntypecode + */ + public String getTrntypecode() { + return trntypecode; + } + + /** + * Set trn_type_code to transaction table. + * + * @param trntypecode + * the trntypecode to set + */ + public void setTrntypecode(String trntypecode) { + this.trntypecode = trntypecode; + } + + /** + * Get remarks from transaction table. + * + * @return the remarks + */ + public String getRemarks() { + return remarks; + } + + /** + * Set remarks to transaction table. + * + * @param remarks + * the remarks to set + */ + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + /** + * Get Status Code from transaction table. + * + * @return the statusCode + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Set status Code to transaction table. + * + * @param statusCode + * the statusCode to set + */ + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + /** + * Get sub Status Code from transaction table. + * @return + * the subStatusCode + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Set sub status Code to transaction table. + * @param subStatusCode + * the subStatusCode to set + */ + public void setSubStatusCode(String subStatusCode) { + this.subStatusCode = subStatusCode; + } + + /** + * Get lang_Code from transaction table. + * + * @return the langCode + */ + public String getLangCode() { + return langCode; + } + + /** + * Set lang Code to transaction table. + * + * @param langCode + * the langCode to set + */ + public void setLangCode(String langCode) { + this.langCode = langCode; + } + + /** + * Get referenceId from transaction table. + * + * @return the referenceId + */ + public String getReferenceId() { + return referenceId; + } + + /** + * Set referenceId to transaction table. + * + * @param referenceId + * the referenceId to set + */ + public void setReferenceId(String referenceId) { + this.referenceId = referenceId; + } + + /** + * Get referenceIdType from transaction table. + * + * @return the referenceIdType + */ + public String getReferenceIdType() { + return referenceIdType; + } + + /** + * Set referenceIdType to transaction table. + * + * @param referenceIdType + * the referenceIdType to set + */ + public void setReferenceIdType(String referenceIdType) { + this.referenceIdType = referenceIdType; + } + + /** + * Get status Comment from transaction table. + * + * @return the statusComment + */ + public String getStatusComment() { + return statusComment; + } + + /** + * Set status comment to transaction table. + * + * @param statusComment + * the statusComment to set + */ + public void setStatusComment(String statusComment) { + this.statusComment = statusComment; + } + + + + /** + * Gets the checks if is deleted. + * + * @return the checks if is deleted + */ + public Boolean getIsDeleted() { + return isDeleted; + } + + /** + * Sets the checks if is deleted. + * + * @param isDeleted the new checks if is deleted + */ + public void setIsDeleted(Boolean isDeleted) { + this.isDeleted = isDeleted; + } + + /** + * Gets the delete date time. + * + * @return the delete date time + */ + public LocalDateTime getDeleteDateTime() { + return deleteDateTime; + } + + /** + * Sets the delete date time. + * + * @param deleteDateTime the new delete date time + */ + public void setDeleteDateTime(LocalDateTime deleteDateTime) { + this.deleteDateTime = deleteDateTime; + } + + /** + * Get created By from transaction table. + * + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * Set created By to transaction table. + * + * @param createdBy + * the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * Get create Date Time from transaction table. + * + * @return the createDateTime + */ + + public LocalDateTime getCreateDateTime() { + return createDateTime; + } + + /** + * Set create Date Time to transaction table. + * + * @param createDateTime + * the createDateTime to set + */ + public void setCreateDateTime(LocalDateTime createDateTime) { + this.createDateTime = createDateTime; + } + + /** + * Get updated By from transaction table. + * + * @return the updatedBy + */ + public String getUpdatedBy() { + return updatedBy; + } + + /** + * Set updated By to transaction table. + * + * @param updatedBy + * the updatedBy to set + */ + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + /** + * Get update Date Time By from transaction table. + * + * @return the updateDateTime + */ + public LocalDateTime getUpdateDateTime() { + return updateDateTime; + } + + /** + * Set update Date Time to transaction table. + * + * @param updateDateTime + * the updateDateTime to set + */ + public void setUpdateDateTime(LocalDateTime updateDateTime) { + this.updateDateTime = updateDateTime; + } + +} diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml index 217551fc058..23d60979903 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml @@ -84,11 +84,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml index ea2bc81108d..290264a1890 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml @@ -81,11 +81,6 @@ - - org.springframework.cloud - spring-cloud-starter-config - ${spring-cloud-config.version} - org.mockito mockito-core diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java index c35addaca22..d67997b773e 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java @@ -7,7 +7,11 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.ComponentScan.Filter; +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.registration.processor.core.kernel.beans.KernelConfig; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionApi; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionJob; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowInternalActionVerticle; @@ -21,7 +25,8 @@ "io.mosip.registration.processor.status.config", "io.mosip.registration.processor.core.kernel.beans", "io.mosip.registration.processor.packet.storage.config", - "io.mosip.kernel.websub.api.config.publisher" }) + "io.mosip.kernel.websub.api.config.publisher" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { + KernelConfig.class, HibernateDaoConfig.class })) public class WorkflowManagerApplication { public static void main(String[] args) { diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java index fbfaf87ea5e..40e1eb5baac 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowActionApiTest.java @@ -386,6 +386,36 @@ public List acceptableLocales() { return null; } + @Override + public void fail(int statusCode, Throwable throwable) { + + } + + @Override + public RoutingContext addCookie(io.vertx.core.http.Cookie cookie) { + return null; + } + + @Override + public Map cookieMap() { + return null; + } + + @Override + public boolean isSessionAccessed() { + return false; + } + + @Override + public int addEndHandler(Handler> handler) { + return 0; + } + + @Override + public boolean removeEndHandler(int handlerID) { + return false; + } + }; } diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java index 522d4afd51f..24e830d20a3 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowSearchApiTest.java @@ -259,6 +259,36 @@ public List acceptableLocales() { return null; } + @Override + public RoutingContext addCookie(io.vertx.core.http.Cookie arg0) { + return null; + } + + @Override + public int addEndHandler(Handler> arg0) { + return 0; + } + + @Override + public Map cookieMap() { + return null; + } + + @Override + public void fail(int arg0, Throwable arg1) { + + } + + @Override + public boolean isSessionAccessed() { + return false; + } + + @Override + public boolean removeEndHandler(int arg0) { + return false; + } + @Override public HttpServerRequest request() { // TODO Auto-generated method stub From a9c3bbdb29f027599602876265f7c9183dba18de Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Wed, 15 May 2024 15:42:54 +0530 Subject: [PATCH 03/27] MOSIP-32461 code fix Signed-off-by: Sowmya Ujjappa Banakar --- registration-processor/pom.xml | 1 + .../registration-processor-core/pom.xml | 5 +++ .../config/PacketReaderWriterConfig.java | 30 ++++++++++++++++++ .../config/PacketStorageBeanConfig.java | 31 ++++++++----------- .../config/RegistrationStatusBeanConfig.java | 7 +++-- .../WorkflowManagerApplication.java | 2 ++ 6 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketReaderWriterConfig.java diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index e4cabb82e1b..3b87c0e7e57 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -395,6 +395,7 @@ --add-opens java.base/sun.security.jca=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED --add-opens java.base/jdk.internal.util=ALL-UNNAMED + --add-opens java.base/java.text=ALL-UNNAMED --illegal-access=permit diff --git a/registration-processor/registration-processor-core/pom.xml b/registration-processor/registration-processor-core/pom.xml index 84a04a80c1e..8c8e4de0724 100644 --- a/registration-processor/registration-processor-core/pom.xml +++ b/registration-processor/registration-processor-core/pom.xml @@ -186,6 +186,11 @@ io.vertx vertx-config + + io.zipkin.zipkin2 + zipkin + 3.3.0 + diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketReaderWriterConfig.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketReaderWriterConfig.java new file mode 100644 index 00000000000..008a77e653f --- /dev/null +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketReaderWriterConfig.java @@ -0,0 +1,30 @@ +package io.mosip.registration.processor.packet.storage.config; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class PacketReaderWriterConfig { + + @Bean(name = "readerConfiguration") + @ConfigurationProperties(prefix = "provider.packetreader") + public Map readerConfiguration() { + return new HashMap<>(); + } + + @Bean(name = "providerConfiguration") + @ConfigurationProperties(prefix = "packetmanager.provider") + public Map providerConfiguration() { + return new HashMap<>(); + } + + @Bean(name = "writerConfiguration") + @ConfigurationProperties(prefix = "provider.packetwriter") + public Map writerConfiguration() { + return new HashMap<>(); + } +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java index 6d645986262..81e3590b5b4 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java @@ -13,6 +13,7 @@ import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -43,31 +44,25 @@ @PropertySource("classpath:bootstrap.properties") @EnableConfigurationProperties @Import({ HibernateDaoConfig.class }) -@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) +//@EnableJpaRepositories(basePackages = "io.mosip.registration.processor", repositoryBaseClass = HibernateRepositoryImpl.class) public class PacketStorageBeanConfig { - @Bean - @ConfigurationProperties(prefix = "provider.packetreader") - public Map readerConfiguration() { - return new HashMap<>(); - } + @Autowired + @Qualifier("readerConfiguration") + private Map packetReaderConfig; - @Bean - @ConfigurationProperties(prefix = "packetmanager.provider") - public Map providerConfiguration() { - return new HashMap<>(); - } + @Autowired + @Qualifier("writerConfiguration") + private Map packetWriterConfig; - @Bean - @ConfigurationProperties(prefix = "provider.packetwriter") - public Map writerConfiguration() { - return new HashMap<>(); - } + @Autowired + @Qualifier("providerConfiguration") + private Map packetProviderConfig; @PostConstruct public void initialize() { - Utilities.initialize(readerConfiguration(), writerConfiguration()); - PriorityBasedPacketManagerService.initialize(providerConfiguration()); + Utilities.initialize(packetReaderConfig, packetWriterConfig); + PriorityBasedPacketManagerService.initialize(packetProviderConfig); } @Bean diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java index 5e0734f1fb4..be257b8bba9 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java @@ -9,12 +9,12 @@ import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; - +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.PropertySource; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; import io.mosip.kernel.dataaccess.hibernate.repository.impl.HibernateRepositoryImpl; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.rest.client.utils.RestApiClient; @@ -42,7 +42,8 @@ @Configuration @PropertySource("classpath:bootstrap.properties") -@EnableJpaRepositories(basePackages = "io.mosip.registration.processor.status.repositary", repositoryBaseClass = HibernateRepositoryImpl.class) +@Import({ HibernateDaoConfig.class }) +//@EnableJpaRepositories(basePackages = "io.mosip.registration.processor.status.repositary", repositoryBaseClass = HibernateRepositoryImpl.class) public class RegistrationStatusBeanConfig { @Bean diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java index d67997b773e..ca7d398e1f1 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java @@ -12,6 +12,8 @@ import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; import io.mosip.registration.processor.core.kernel.beans.KernelConfig; +import io.mosip.registration.processor.packet.storage.config.PacketStorageBeanConfig; +import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionApi; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionJob; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowInternalActionVerticle; From 228d547378ae0cdd9fc25134d2e2b0e37b7f6ea2 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 16 May 2024 19:13:42 +0530 Subject: [PATCH 04/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../pom.xml | 5 - .../biodedupe/stage/BioDedupeProcessor.java | 6 +- .../stage/BioDedupeProcessorTest.java | 1378 +++++++++-------- .../stage/BiometricAuthenticationStage.java | 3 +- .../BiometricAuthenticationStageTest.java | 14 +- .../demodedupe/DemodedupeProcessor.java | 16 +- .../demodedupe/DemodedupeProcessorTest.java | 44 +- .../pom.xml | 5 - .../impl/ManualAdjudicationServiceImpl.java | 15 +- .../pom.xml | 5 - registration-processor/pom.xml | 4 + .../stage/CredentialRequestorStage.java | 7 +- .../util/CredentialPartnerUtil.java | 11 +- ...strationTransactionServiceApplication.java | 2 +- .../tagging/impl/AgeGroupTagGenerator.java | 3 +- .../impl/AgeGroupTagGeneratorTest.java | 213 +-- .../validator/impl/PacketValidatorImpl.java | 600 +++---- .../validator/PacketValidatorImplTest.java | 774 ++++----- .../processor/core/config/CoreConfigBean.java | 421 +++-- .../PropertyLoaderConfig.java | 4 +- .../config/PacketStorageBeanConfig.java | 11 + .../packet/storage/utils/ABISHandlerUtil.java | 487 +++--- .../storage/utils/PacketManagerService.java | 33 +- .../packet/storage/utils/Utilities.java | 119 -- .../packet/storage/utils/Utility.java | 157 ++ ...rationProcessorLandingZoneApplication.java | 42 +- .../processor/util/LandingZoneConfig.java | 102 +- .../status/entity/BaseRegistrationEntity.java | 1 + .../WorkflowManagerApplication.java | 7 +- .../config/WorkflowManagerConfigBeans.java | 1 + .../WorkflowInternalActionVerticle.java | 1249 +++++++-------- .../WorkflowInternalActionVerticleTest.java | 13 +- 32 files changed, 2925 insertions(+), 2827 deletions(-) create mode 100644 registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java diff --git a/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml b/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml index 43551e7dae0..12f04dd1a43 100644 --- a/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis-middleware-stage/pom.xml @@ -65,11 +65,6 @@ powermock-api-mockito2 test - - org.apache.activemq - activemq-client - 6.1.2 - diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java index be0738c4a74..6a6f57c9839 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessor.java @@ -59,6 +59,7 @@ import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.status.code.RegistrationStatusCode; import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; @@ -117,6 +118,9 @@ public class BioDedupeProcessor { @Autowired private BioDedupeService biodedupeServiceImpl; + @Autowired + Utility utility; + /** The config server file storage URL. */ @Value("${config.server.file.storage.uri}") private String configServerFileStorageURL; @@ -496,7 +500,7 @@ private Boolean isValidCbeff(MessageDTO messageDTO) throws ApisResourceAccessExc private boolean infantCheck(String registrationId, String registrationType) throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException { boolean isInfant = false; if (RegistrationType.NEW.name().equalsIgnoreCase(registrationType)) { - int age = utilities.getApplicantAge(registrationId, registrationType, ProviderStageName.BIO_DEDUPE); + int age = utility.getApplicantAge(registrationId, registrationType, ProviderStageName.BIO_DEDUPE); int ageThreshold = Integer.parseInt(ageLimit); isInfant = age < ageThreshold; } else { diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java index a4d723d240f..8d381cfb818 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/test/java/io/mosip/registration/processor/biodedupe/stage/BioDedupeProcessorTest.java @@ -1,688 +1,692 @@ -package io.mosip.registration.processor.biodedupe.stage; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.biodedupe.service.CbeffValidateAndVerificatonService; -import io.mosip.registration.processor.biodedupe.stage.exception.CbeffNotFoundException; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import org.apache.commons.io.IOUtils; -import org.json.simple.JSONObject; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.core.env.Environment; -import org.springframework.dao.DataAccessException; -import org.springframework.test.util.ReflectionTestUtils; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.code.EventId; -import io.mosip.registration.processor.core.code.EventName; -import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.constant.AbisConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException; -import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; -import io.mosip.registration.processor.core.http.ResponseWrapper; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.spi.biodedupe.BioDedupeService; -import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; -import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; -import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; -import io.mosip.registration.processor.status.dao.RegistrationStatusDao; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; -import io.mosip.registration.processor.status.service.RegistrationStatusService; - -/** - * The Class BioDedupeStageTest. - */ -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({ "javax.management.*", "javax.net.ssl.*","com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" }) -@PrepareForTest({ Utilities.class }) -public class BioDedupeProcessorTest { - - /** The Constant ERROR. */ - private static final String ERROR = "ERROR"; - - /** The Constant IDENTITY. */ - private static final String IDENTITY = "identity"; - - /** The Constant ABIS_HANDLER_BUS_IN. */ - private static final String ABIS_HANDLER_BUS_IN = "abis-handler-bus-in"; - - /** The registration status service. */ - @Mock - private RegistrationStatusService registrationStatusService; - - @Mock - private CbeffValidateAndVerificatonService cbeffValidateAndVerificatonService; - - /** The packet info manager. */ - @Mock - private PacketInfoManager packetInfoManager; - - /** The bio dedupe service. */ - @Mock - private BioDedupeService bioDedupeService; - - /** The registration status dao. */ - @Mock - private RegistrationStatusDao registrationStatusDao; - - /** The packet info dao. */ - @Mock - private PacketInfoDao packetInfoDao; - - @Mock - private IdRepoService idRepoService; - - /** The dto. */ - MessageDTO dto = new MessageDTO(); - - /** The registration status dto. */ - InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); - - /** The audit log request builder. */ - @Mock - private AuditLogRequestBuilder auditLogRequestBuilder; - - /** The matched reg ids. */ - List matchedRegIds = new ArrayList(); - - /** The registration status mapper util. */ - @Mock - RegistrationExceptionMapperUtil registrationStatusMapperUtil; - - /** The bio dedupe processor. */ - @InjectMocks - private BioDedupeProcessor bioDedupeProcessor; - - - /** The stage name. */ - private String stageName = "BioDedupeStage"; - - /** The utilities. */ - @Mock - Utilities utility; - - /** The rest client service. */ - @Mock - private RegistrationProcessorRestClientService restClientService; - - /** The entity. */ - @Mock - RegistrationStatusEntity entity = new RegistrationStatusEntity(); - - /** The abis handler util. */ - @Mock - private ABISHandlerUtil abisHandlerUtil; - - /** The map identity json string to object. */ - @Mock - ObjectMapper mapIdentityJsonStringToObject; - - @Mock - LogDescription description; - - @Mock - private Environment env; - - @Mock - private PriorityBasedPacketManagerService priorityBasedPacketManagerService; - - /** - * Sets the up. - * - * @throws Exception - * the exception - */ - @Before - public void setUp() throws Exception { - Mockito.doNothing().when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); - Mockito.when(priorityBasedPacketManagerService.getFieldByMappingJsonKey(any(),any(),any(),any())).thenReturn("field"); - Mockito.when(priorityBasedPacketManagerService.getField(any(),any(),any(),any())).thenReturn("field"); - when(utility.getDefaultSource(any(), any())).thenReturn("reg-client"); - ReflectionTestUtils.setField(bioDedupeProcessor, "infantDedupe", "Y"); - ReflectionTestUtils.setField(bioDedupeProcessor, "ageLimit", "4"); - - AuditResponseDto auditResponseDto = new AuditResponseDto(); - ResponseWrapper responseWrapper = new ResponseWrapper<>(); - responseWrapper.setResponse(auditResponseDto); - Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder( - "test case description", EventId.RPR_405.toString(), EventName.UPDATE.toString(), - EventType.BUSINESS.toString(), "1234testcase", ApiName.AUDIT); - - dto.setRid("reg1234"); - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("new"); - - Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(), any(), any()); - Mockito.doNothing().when(description).setMessage(any()); - - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())) - .thenReturn("1233445566".getBytes("UTF-16")); - Mockito.when(registrationStatusMapperUtil.getStatusCode(any())).thenReturn(ERROR); - Mockito.doNothing().when(packetInfoManager).saveManualAdjudicationData(any(), any(), any(), any(), any(),any(),any()); - Mockito.doNothing().when(packetInfoManager).saveRegLostUinDet(any(), any(), any(), any(), any()); - - - ClassLoader classLoader = getClass().getClassLoader(); - - File mappingJsonFile = new File(classLoader.getResource("RegistrationProcessorIdentity.json").getFile()); - InputStream is = new FileInputStream(mappingJsonFile); - String value = IOUtils.toString(is); - Mockito.when(utility.getRegistrationProcessorMappingJson(anyString())).thenReturn(JsonUtil - .getJSONObject(JsonUtil.objectMapperReadValue(value, JSONObject.class), MappingJsonConstants.IDENTITY)); - Mockito.when(bioDedupeService.getFileByRegId(any(),any())).thenReturn("test".getBytes()); - - } - - /** - * Test bio dedupe success. - * - * @throws Exception - * the exception - */ - @Test - public void testNewInsertionPostProcessing() throws Exception { - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getMessageBusAddress().toString() - .equalsIgnoreCase(MessageBusAddress.ABIS_HANDLER_BUS_IN.toString())); - - } - - /** - * Test new insertion to uin success. - * - * @throws Exception - * the exception - */ - @Test - public void testNewInsertionToUinSuccess() throws Exception { - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - ReflectionTestUtils.setField(bioDedupeProcessor, "infantDedupe", "N"); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); - Mockito.when(utility.getApplicantAge(any(),any(),any())).thenReturn(2); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - - } - - /** - * Test new insertion adult CBEFF not found exception. - * - * @throws Exception - * the exception - */ - @Test - public void testNewInsertionAdultCBEFFNotFoundException() throws Exception { - Mockito.doThrow(new CbeffNotFoundException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); - Mockito.when(utility.getApplicantAge(any(),any(),any())).thenReturn(12); - Mockito.when(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.CBEFF_NOT_PRESENT_EXCEPTION)).thenReturn("FAILED"); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getIsValid()); - } - - /** - * Test new exception. - * - * @throws Exception - * the exception - */ - @Test - @Ignore - public void testNewException() throws Exception { - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - - ReflectionTestUtils.setField(bioDedupeProcessor, "ageLimit", "age"); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); - Mockito.when(utility.getApplicantAge(any(),any(),any())).thenReturn(12); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getInternalError()); - assertFalse(messageDto.getIsValid()); - } - - /** - * Test new insertion IO exception. - * - * @throws Exception - * the exception - */ - @Test - public void testNewInsertionIOException() throws Exception { - Mockito.doThrow(new IOException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); - Mockito.when(utility.getApplicantAge(any(),any(),any())).thenThrow(new IOException("IOException")); - Mockito.when(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.IOEXCEPTION)).thenReturn("ERROR"); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getInternalError()); - assertFalse(messageDto.getIsValid()); - } - - /** - * Test data access exception. - */ - @Test - public void testDataAccessException() { - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())) - .thenThrow(new DataAccessException("DataAccessException") { - private static final long serialVersionUID = 1L; - }); - Mockito.when(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)).thenReturn("REPROCESS"); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getInternalError()); - assertTrue(messageDto.getIsValid()); - } - - /** - * Test new identify to UIN stage. - * - * @throws Exception - * the exception - */ - @Test - public void testNewIdentifyToUINStage() throws Exception { - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test new identify to manual stage. - * - * @throws Exception - * the exception - */ - @Test - public void testNewIdentifyToManualStage() throws Exception { - - Set set = new HashSet<>(); - set.add("1"); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(set); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - - } - - /** - * Test update insertion to handler. - * - * @throws Exception - * the exception - */ - @Test - public void testUpdateInsertionToHandler() throws Exception { - - PowerMockito.mockStatic(Utilities.class); - Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); - - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("Update"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertEquals(messageDto.getMessageBusAddress().getAddress(), ABIS_HANDLER_BUS_IN); - } - - /** - * Test update insertion to UIN. - * - * @throws Exception - * the exception - */ - @Test - public void testUpdateInsertionToUIN() throws Exception { - - PowerMockito.mockStatic(Utilities.class); - Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); - Mockito.when(priorityBasedPacketManagerService.getField(any(),any(),any(),any())).thenReturn(null); - Mockito.when(priorityBasedPacketManagerService.getFieldByMappingJsonKey(any(),any(),any(),any())).thenReturn(null); - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("Update"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test bio de dup update packet handler processing success. - * - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - * @throws PacketDecryptionFailureException - * @throws RegistrationProcessorCheckedException - */ - @Test - public void testBioDeDupUpdatePacketHandlerProcessingSuccess() throws ApisResourceAccessException, IOException, - io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("UPDATE"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - - Set matchedRidList = new HashSet<>(); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test bio de dup update packet handler processing failure. - * - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - * @throws PacketDecryptionFailureException - * @throws RegistrationProcessorCheckedException - */ - @Test - public void testBioDeDupUpdatePacketHandlerProcessingFailure() throws ApisResourceAccessException, IOException, - PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("UPDATE"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test lost packet validation matched id empty. - * - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - * @throws PacketDecryptionFailureException - * @throws RegistrationProcessorCheckedException - */ - @Test - public void testLostPacketValidationMatchedIdEmpty() throws ApisResourceAccessException, IOException, - PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertFalse(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test lost packet validation single matched reg id. - * - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - * @throws PacketDecryptionFailureException - * @throws RegistrationProcessorCheckedException - */ - @Test - public void testLostPacketValidationSingleMatchedRegId() throws ApisResourceAccessException, IOException, - PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test lost packet validation multiple matched reg id. - * - * @throws Exception - * the exception - */ - @Test - public void testLostPacketValidationMultipleMatchedRegId() throws Exception { - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - matchedRidList.add("27847657360002520190320095011"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - Mockito.when(priorityBasedPacketManagerService.getField("reg1234","gender","LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("MALE"); - Mockito.when(priorityBasedPacketManagerService.getField("reg1234","dob", "LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("2016/01/01"); - - Map map = new LinkedHashMap<>(); - map.put("gender", "MALE"); - map.put("dateOfBirth", "2016/01/01"); - JSONObject j1 = new JSONObject(map); - - Mockito.when(idRepoService.getIdJsonFromIDRepo(any(), any())).thenReturn(j1); - Mockito.when(utility.getApplicantAge(any(),any(),any())).thenReturn(12); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertFalse(messageDto.getIsValid()); - assertFalse(messageDto.getInternalError()); - } - - /** - * Test lost packet validation multiple matched reg id demo match. - * - * @throws Exception - * the exception - */ - @SuppressWarnings("unchecked") - @Test - public void testLostPacketValidationSingleDemoMatch() throws Exception { - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - matchedRidList.add("27847657360002520190320095011"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - JSONObject obj1 = new JSONObject(); - obj1.put("dateOfBirth", "2016/01/01"); - - JSONObject obj2 = new JSONObject(); - obj2.put("dateOfBirth", "2016/01/02"); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertFalse(messageDto.getInternalError()); - assertFalse(messageDto.getIsValid()); - } - - @SuppressWarnings("unchecked") - @Test - public void testPacketValidationSingleDemoMatch() throws Exception { - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - matchedRidList.add("27847657360002520190320095011"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - JSONObject obj1 = new JSONObject(); - obj1.put("dateOfBirth", "2016/01/01"); - - JSONObject obj2 = new JSONObject(); - obj2.put("dateOfBirth", "2016/01/02"); - LinkedHashMap map = new LinkedHashMap(); - map.put("language", "eng"); - map.put("value", "Male"); - obj2.put("gender", map); - - Mockito.when(utility.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); - Mockito.when(priorityBasedPacketManagerService.getField("reg1234","dob","LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("2016/01/01"); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertFalse(messageDto.getInternalError()); - assertTrue(messageDto.getIsValid()); - } - - @SuppressWarnings("unchecked") - @Test - public void testLostPacketValidationMultipleDemoMatch() throws Exception { - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Set matchedRidList = new HashSet<>(); - matchedRidList.add("27847657360002520190320095010"); - matchedRidList.add("27847657360002520190320095011"); - matchedRidList.add("27847657360002520190320095012"); - Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); - - JSONObject obj1 = new JSONObject(); - obj1.put("dateOfBirth", "2016/01/01"); - - JSONObject obj2 = new JSONObject(); - obj2.put("dateOfBirth", "2016/01/02"); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); - Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095012", IDENTITY)).thenReturn(obj1); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertFalse(messageDto.getInternalError()); - assertFalse(messageDto.getIsValid()); - } - - @Test - public void testLostPacketValidationCbeffNotFound() throws Exception { - Mockito.doThrow(new CbeffNotFoundException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertFalse(messageDto.getIsValid()); - } - - @Test - public void testLostPacketPreAbis() throws Exception { - - registrationStatusDto.setRegistrationId("reg1234"); - registrationStatusDto.setRegistrationType("LOST"); - Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); - Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - assertTrue(messageDto.getMessageBusAddress().toString() - .equalsIgnoreCase(MessageBusAddress.ABIS_HANDLER_BUS_IN.toString())); - } - - @Test - public void testApisResourceAccessException() throws Exception { - Mockito.doThrow(new ApisResourceAccessException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); - Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); - ApisResourceAccessException e=new ApisResourceAccessException(); - - - Mockito.doThrow(e).when(utility).getApplicantAge(any(),any(),any()); - Mockito.when(registrationStatusMapperUtil - .getStatusCode(RegistrationExceptionTypeCode.APIS_RESOURCE_ACCESS_EXCEPTION)).thenReturn("REPROCESS"); - MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); - - assertTrue(messageDto.getIsValid()); - assertTrue(messageDto.getInternalError()); - } +package io.mosip.registration.processor.biodedupe.stage; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.biodedupe.service.CbeffValidateAndVerificatonService; +import io.mosip.registration.processor.biodedupe.stage.exception.CbeffNotFoundException; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import org.apache.commons.io.IOUtils; +import org.json.simple.JSONObject; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.env.Environment; +import org.springframework.dao.DataAccessException; +import org.springframework.test.util.ReflectionTestUtils; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.code.ApiName; +import io.mosip.registration.processor.core.code.EventId; +import io.mosip.registration.processor.core.code.EventName; +import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.constant.AbisConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketDecryptionFailureException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.http.ResponseWrapper; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.spi.biodedupe.BioDedupeService; +import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; +import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; +import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; +import io.mosip.registration.processor.status.dao.RegistrationStatusDao; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; +import io.mosip.registration.processor.status.service.RegistrationStatusService; + +/** + * The Class BioDedupeStageTest. + */ +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({ "javax.management.*", "javax.net.ssl.*","com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" }) +@PrepareForTest({ Utilities.class }) +public class BioDedupeProcessorTest { + + /** The Constant ERROR. */ + private static final String ERROR = "ERROR"; + + /** The Constant IDENTITY. */ + private static final String IDENTITY = "identity"; + + /** The Constant ABIS_HANDLER_BUS_IN. */ + private static final String ABIS_HANDLER_BUS_IN = "abis-handler-bus-in"; + + /** The registration status service. */ + @Mock + private RegistrationStatusService registrationStatusService; + + @Mock + private CbeffValidateAndVerificatonService cbeffValidateAndVerificatonService; + + /** The packet info manager. */ + @Mock + private PacketInfoManager packetInfoManager; + + /** The bio dedupe service. */ + @Mock + private BioDedupeService bioDedupeService; + + /** The registration status dao. */ + @Mock + private RegistrationStatusDao registrationStatusDao; + + /** The packet info dao. */ + @Mock + private PacketInfoDao packetInfoDao; + + @Mock + private IdRepoService idRepoService; + + /** The dto. */ + MessageDTO dto = new MessageDTO(); + + /** The registration status dto. */ + InternalRegistrationStatusDto registrationStatusDto = new InternalRegistrationStatusDto(); + + /** The audit log request builder. */ + @Mock + private AuditLogRequestBuilder auditLogRequestBuilder; + + /** The matched reg ids. */ + List matchedRegIds = new ArrayList(); + + /** The registration status mapper util. */ + @Mock + RegistrationExceptionMapperUtil registrationStatusMapperUtil; + + /** The bio dedupe processor. */ + @InjectMocks + private BioDedupeProcessor bioDedupeProcessor; + + + /** The stage name. */ + private String stageName = "BioDedupeStage"; + + /** The utilities. */ + @Mock + Utilities utilities; + + @Mock + Utility utility; + + /** The rest client service. */ + @Mock + private RegistrationProcessorRestClientService restClientService; + + /** The entity. */ + @Mock + RegistrationStatusEntity entity = new RegistrationStatusEntity(); + + /** The abis handler util. */ + @Mock + private ABISHandlerUtil abisHandlerUtil; + + /** The map identity json string to object. */ + @Mock + ObjectMapper mapIdentityJsonStringToObject; + + @Mock + LogDescription description; + + @Mock + private Environment env; + + @Mock + private PriorityBasedPacketManagerService priorityBasedPacketManagerService; + + /** + * Sets the up. + * + * @throws Exception + * the exception + */ + @Before + public void setUp() throws Exception { + Mockito.doNothing().when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); + Mockito.when(priorityBasedPacketManagerService.getFieldByMappingJsonKey(any(),any(),any(),any())).thenReturn("field"); + Mockito.when(priorityBasedPacketManagerService.getField(any(),any(),any(),any())).thenReturn("field"); + when(utilities.getDefaultSource(any(), any())).thenReturn("reg-client"); + ReflectionTestUtils.setField(bioDedupeProcessor, "infantDedupe", "Y"); + ReflectionTestUtils.setField(bioDedupeProcessor, "ageLimit", "4"); + + AuditResponseDto auditResponseDto = new AuditResponseDto(); + ResponseWrapper responseWrapper = new ResponseWrapper<>(); + responseWrapper.setResponse(auditResponseDto); + Mockito.doReturn(responseWrapper).when(auditLogRequestBuilder).createAuditRequestBuilder( + "test case description", EventId.RPR_405.toString(), EventName.UPDATE.toString(), + EventType.BUSINESS.toString(), "1234testcase", ApiName.AUDIT); + + dto.setRid("reg1234"); + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("new"); + + Mockito.doNothing().when(registrationStatusService).updateRegistrationStatus(any(), any(), any()); + Mockito.doNothing().when(description).setMessage(any()); + + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())) + .thenReturn("1233445566".getBytes("UTF-16")); + Mockito.when(registrationStatusMapperUtil.getStatusCode(any())).thenReturn(ERROR); + Mockito.doNothing().when(packetInfoManager).saveManualAdjudicationData(any(), any(), any(), any(), any(),any(),any()); + Mockito.doNothing().when(packetInfoManager).saveRegLostUinDet(any(), any(), any(), any(), any()); + + + ClassLoader classLoader = getClass().getClassLoader(); + + File mappingJsonFile = new File(classLoader.getResource("RegistrationProcessorIdentity.json").getFile()); + InputStream is = new FileInputStream(mappingJsonFile); + String value = IOUtils.toString(is); + Mockito.when(utilities.getRegistrationProcessorMappingJson(anyString())).thenReturn(JsonUtil + .getJSONObject(JsonUtil.objectMapperReadValue(value, JSONObject.class), MappingJsonConstants.IDENTITY)); + Mockito.when(bioDedupeService.getFileByRegId(any(),any())).thenReturn("test".getBytes()); + + } + + /** + * Test bio dedupe success. + * + * @throws Exception + * the exception + */ + @Test + public void testNewInsertionPostProcessing() throws Exception { + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getMessageBusAddress().toString() + .equalsIgnoreCase(MessageBusAddress.ABIS_HANDLER_BUS_IN.toString())); + + } + + /** + * Test new insertion to uin success. + * + * @throws Exception + * the exception + */ + @Test + public void testNewInsertionToUinSuccess() throws Exception { + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + ReflectionTestUtils.setField(bioDedupeProcessor, "infantDedupe", "N"); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); + Mockito.when(utility.getApplicantAge(any(), any(), any())).thenReturn(2); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + + } + + /** + * Test new insertion adult CBEFF not found exception. + * + * @throws Exception + * the exception + */ + @Test + public void testNewInsertionAdultCBEFFNotFoundException() throws Exception { + Mockito.doThrow(new CbeffNotFoundException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); + Mockito.when(utility.getApplicantAge(any(), any(), any())).thenReturn(12); + Mockito.when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.CBEFF_NOT_PRESENT_EXCEPTION)).thenReturn("FAILED"); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getIsValid()); + } + + /** + * Test new exception. + * + * @throws Exception + * the exception + */ + @Test + @Ignore + public void testNewException() throws Exception { + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + + ReflectionTestUtils.setField(bioDedupeProcessor, "ageLimit", "age"); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); + Mockito.when(utility.getApplicantAge(any(), any(), any())).thenReturn(12); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getInternalError()); + assertFalse(messageDto.getIsValid()); + } + + /** + * Test new insertion IO exception. + * + * @throws Exception + * the exception + */ + @Test + public void testNewInsertionIOException() throws Exception { + Mockito.doThrow(new IOException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); + Mockito.when(utility.getApplicantAge(any(), any(), any())).thenThrow(new IOException("IOException")); + Mockito.when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.IOEXCEPTION)).thenReturn("ERROR"); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getInternalError()); + assertFalse(messageDto.getIsValid()); + } + + /** + * Test data access exception. + */ + @Test + public void testDataAccessException() { + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())) + .thenThrow(new DataAccessException("DataAccessException") { + private static final long serialVersionUID = 1L; + }); + Mockito.when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.DATA_ACCESS_EXCEPTION)).thenReturn("REPROCESS"); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getInternalError()); + assertTrue(messageDto.getIsValid()); + } + + /** + * Test new identify to UIN stage. + * + * @throws Exception + * the exception + */ + @Test + public void testNewIdentifyToUINStage() throws Exception { + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test new identify to manual stage. + * + * @throws Exception + * the exception + */ + @Test + public void testNewIdentifyToManualStage() throws Exception { + + Set set = new HashSet<>(); + set.add("1"); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(set); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + + } + + /** + * Test update insertion to handler. + * + * @throws Exception + * the exception + */ + @Test + public void testUpdateInsertionToHandler() throws Exception { + + PowerMockito.mockStatic(Utilities.class); + Mockito.when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); + + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("Update"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertEquals(messageDto.getMessageBusAddress().getAddress(), ABIS_HANDLER_BUS_IN); + } + + /** + * Test update insertion to UIN. + * + * @throws Exception + * the exception + */ + @Test + public void testUpdateInsertionToUIN() throws Exception { + + PowerMockito.mockStatic(Utilities.class); + Mockito.when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); + Mockito.when(priorityBasedPacketManagerService.getField(any(),any(),any(),any())).thenReturn(null); + Mockito.when(priorityBasedPacketManagerService.getFieldByMappingJsonKey(any(),any(),any(),any())).thenReturn(null); + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("Update"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test bio de dup update packet handler processing success. + * + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + * @throws PacketDecryptionFailureException + * @throws RegistrationProcessorCheckedException + */ + @Test + public void testBioDeDupUpdatePacketHandlerProcessingSuccess() throws ApisResourceAccessException, IOException, + io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("UPDATE"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + + Set matchedRidList = new HashSet<>(); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test bio de dup update packet handler processing failure. + * + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + * @throws PacketDecryptionFailureException + * @throws RegistrationProcessorCheckedException + */ + @Test + public void testBioDeDupUpdatePacketHandlerProcessingFailure() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("UPDATE"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test lost packet validation matched id empty. + * + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + * @throws PacketDecryptionFailureException + * @throws RegistrationProcessorCheckedException + */ + @Test + public void testLostPacketValidationMatchedIdEmpty() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertFalse(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test lost packet validation single matched reg id. + * + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + * @throws PacketDecryptionFailureException + * @throws RegistrationProcessorCheckedException + */ + @Test + public void testLostPacketValidationSingleMatchedRegId() throws ApisResourceAccessException, IOException, + PacketDecryptionFailureException, io.mosip.kernel.core.exception.IOException, JsonProcessingException, PacketManagerException { + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test lost packet validation multiple matched reg id. + * + * @throws Exception + * the exception + */ + @Test + public void testLostPacketValidationMultipleMatchedRegId() throws Exception { + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + matchedRidList.add("27847657360002520190320095011"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + Mockito.when(priorityBasedPacketManagerService.getField("reg1234","gender","LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("MALE"); + Mockito.when(priorityBasedPacketManagerService.getField("reg1234","dob", "LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("2016/01/01"); + + Map map = new LinkedHashMap<>(); + map.put("gender", "MALE"); + map.put("dateOfBirth", "2016/01/01"); + JSONObject j1 = new JSONObject(map); + + Mockito.when(idRepoService.getIdJsonFromIDRepo(any(), any())).thenReturn(j1); + Mockito.when(utility.getApplicantAge(any(), any(), any())).thenReturn(12); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertFalse(messageDto.getIsValid()); + assertFalse(messageDto.getInternalError()); + } + + /** + * Test lost packet validation multiple matched reg id demo match. + * + * @throws Exception + * the exception + */ + @SuppressWarnings("unchecked") + @Test + public void testLostPacketValidationSingleDemoMatch() throws Exception { + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + matchedRidList.add("27847657360002520190320095011"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + JSONObject obj1 = new JSONObject(); + obj1.put("dateOfBirth", "2016/01/01"); + + JSONObject obj2 = new JSONObject(); + obj2.put("dateOfBirth", "2016/01/02"); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertFalse(messageDto.getInternalError()); + assertFalse(messageDto.getIsValid()); + } + + @SuppressWarnings("unchecked") + @Test + public void testPacketValidationSingleDemoMatch() throws Exception { + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + matchedRidList.add("27847657360002520190320095011"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + JSONObject obj1 = new JSONObject(); + obj1.put("dateOfBirth", "2016/01/01"); + + JSONObject obj2 = new JSONObject(); + obj2.put("dateOfBirth", "2016/01/02"); + LinkedHashMap map = new LinkedHashMap(); + map.put("language", "eng"); + map.put("value", "Male"); + obj2.put("gender", map); + + Mockito.when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn(IDENTITY); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); + Mockito.when(priorityBasedPacketManagerService.getField("reg1234","dob","LOST", ProviderStageName.BIO_DEDUPE)).thenReturn("2016/01/01"); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertFalse(messageDto.getInternalError()); + assertTrue(messageDto.getIsValid()); + } + + @SuppressWarnings("unchecked") + @Test + public void testLostPacketValidationMultipleDemoMatch() throws Exception { + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Set matchedRidList = new HashSet<>(); + matchedRidList.add("27847657360002520190320095010"); + matchedRidList.add("27847657360002520190320095011"); + matchedRidList.add("27847657360002520190320095012"); + Mockito.when(abisHandlerUtil.getUniqueRegIds(any(), any(), anyInt(), any(), any())).thenReturn(matchedRidList); + + JSONObject obj1 = new JSONObject(); + obj1.put("dateOfBirth", "2016/01/01"); + + JSONObject obj2 = new JSONObject(); + obj2.put("dateOfBirth", "2016/01/02"); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095010", IDENTITY)).thenReturn(obj1); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095011", IDENTITY)).thenReturn(obj2); + Mockito.when(idRepoService.getIdJsonFromIDRepo("27847657360002520190320095012", IDENTITY)).thenReturn(obj1); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertFalse(messageDto.getInternalError()); + assertFalse(messageDto.getIsValid()); + } + + @Test + public void testLostPacketValidationCbeffNotFound() throws Exception { + Mockito.doThrow(new CbeffNotFoundException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.POST_ABIS_IDENTIFICATION); + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + Mockito.when(restClientService.getApi(any(), any(), anyString(), any(), any())).thenReturn(null); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertFalse(messageDto.getIsValid()); + } + + @Test + public void testLostPacketPreAbis() throws Exception { + + registrationStatusDto.setRegistrationId("reg1234"); + registrationStatusDto.setRegistrationType("LOST"); + Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(AbisConstant.PRE_ABIS_IDENTIFICATION); + Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + assertTrue(messageDto.getMessageBusAddress().toString() + .equalsIgnoreCase(MessageBusAddress.ABIS_HANDLER_BUS_IN.toString())); + } + + @Test + public void testApisResourceAccessException() throws Exception { + Mockito.doThrow(new ApisResourceAccessException("Exception")).when(cbeffValidateAndVerificatonService).validateBiometrics(any(), any()); + Mockito.when(bioDedupeService.getFileByRegId(anyString(),anyString())).thenReturn(null); + ApisResourceAccessException e=new ApisResourceAccessException(); + + + Mockito.doThrow(e).when(utility).getApplicantAge(any(), any(), any()); + Mockito.when(registrationStatusMapperUtil + .getStatusCode(RegistrationExceptionTypeCode.APIS_RESOURCE_ACCESS_EXCEPTION)).thenReturn("REPROCESS"); + MessageDTO messageDto = bioDedupeProcessor.process(dto, stageName); + + assertTrue(messageDto.getIsValid()); + assertTrue(messageDto.getInternalError()); + } } \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStage.java b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStage.java index 836c0b35b81..9484076fa86 100644 --- a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStage.java +++ b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStage.java @@ -50,6 +50,7 @@ import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.status.code.RegistrationStatusCode; import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; @@ -77,7 +78,7 @@ public class BiometricAuthenticationStage extends MosipVerticleAPIManager { AuditLogRequestBuilder auditLogRequestBuilder; @Autowired - private Utilities utility; + private Utility utility; /** The registration status service. */ @Autowired diff --git a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/test/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStageTest.java b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/test/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStageTest.java index 97d50d9bfba..5e603fb63fc 100644 --- a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/test/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStageTest.java +++ b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/test/java/io/mosip/registration/processor/biometric/authentication/stage/BiometricAuthenticationStageTest.java @@ -75,6 +75,7 @@ import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; @@ -208,7 +209,10 @@ public Integer getPort() { private RegistrationProcessorRestClientService registrationProcessorRestService; @Mock - private Utilities utility; + private Utilities utilities; + + @Mock + private Utility utility; @Mock ObjectMapper mapIdentityJsonStringToObject; @@ -240,7 +244,7 @@ public void setUp() throws Exception { ReflectionTestUtils.setField(biometricAuthenticationStage, "ageLimit", "5"); - when(utility.getGetRegProcessorDemographicIdentity()).thenReturn("identity"); + when(utilities.getGetRegProcessorDemographicIdentity()).thenReturn("identity"); list = new ArrayList(); @@ -285,7 +289,7 @@ public void setUp() throws Exception { JSONObject jsonObject = Mockito.mock(JSONObject.class); when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678"); - when(utility.retrieveIdrepoJson(any())).thenReturn(jsonObject); + when(utilities.retrieveIdrepoJson(any())).thenReturn(jsonObject); FieldValue fieldValue = new FieldValue(); FieldValue fieldValue1 = new FieldValue(); fieldValue1.setLabel("authenticationBiometricFileName"); @@ -297,8 +301,8 @@ public void setUp() throws Exception { metadata.add(fieldValue1); - when(utility.getDefaultSource(any(), any())).thenReturn("reg-client"); - when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(21); + when(utilities.getDefaultSource(any(), any())).thenReturn("reg-client"); + when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(21); regentity.setRegistrationType("update"); when(syncRegistrationservice.findByWorkflowInstanceId(any())).thenReturn(regentity); diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java index 98750026c1f..60d358a67a3 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/java/io/mosip/registration/processor/stages/demodedupe/DemodedupeProcessor.java @@ -55,6 +55,7 @@ import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.stages.app.constants.DemoDedupeConstants; import io.mosip.registration.processor.stages.dto.DemoDedupeStatusDTO; @@ -99,7 +100,7 @@ public class DemodedupeProcessor { /** The utility. */ @Autowired - Utilities utility; + Utilities utilities; /** The registration status dao. */ @Autowired @@ -112,6 +113,9 @@ public class DemodedupeProcessor { @Autowired private Environment env; + @Autowired + Utility utility; + /** The is match found. */ private volatile boolean isMatchFound = false; @@ -168,9 +172,10 @@ public MessageDTO process(MessageDTO object, String stageName) { IndividualDemographicDedupe demographicData = packetInfoManager. getIdentityKeysAndFetchValuesFromJSON(registrationId, registrationStatusDto.getRegistrationType(), ProviderStageName.DEMO_DEDUPE); - JSONObject regProcessorIdentityJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); - String uinFieldCheck = utility.getUIn(registrationId, registrationStatusDto.getRegistrationType(), ProviderStageName.DEMO_DEDUPE); - JSONObject jsonObject = utility.retrieveIdrepoJson(uinFieldCheck); + JSONObject regProcessorIdentityJson = utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + String uinFieldCheck = utility.getUIn(registrationId, registrationStatusDto.getRegistrationType(), + ProviderStageName.DEMO_DEDUPE); + JSONObject jsonObject = utilities.retrieveIdrepoJson(uinFieldCheck); if (jsonObject == null) { DemoDedupeStatusDTO demoDedupeStatusDTO = insertDemodedupDetailsAndPerformDedup(demographicData, registrationStatusDto, duplicateDtos, object, moduleId, moduleName, isDemoDedupeSkip, description); @@ -355,7 +360,8 @@ private DemoDedupeStatusDTO insertDemodedupDetailsAndPerformDedup(IndividualDemo if (packetStatus.equalsIgnoreCase(AbisConstant.PRE_ABIS_IDENTIFICATION)) { packetInfoManager.saveIndividualDemographicDedupeUpdatePacket(demographicData, registrationId, moduleId, registrationStatusDto.getRegistrationType(),moduleName,registrationStatusDto.getIteration(), registrationStatusDto.getWorkflowInstanceId()); - int age = utility.getApplicantAge(registrationId, registrationStatusDto.getRegistrationType(), ProviderStageName.DEMO_DEDUPE); + int age = utility.getApplicantAge(registrationId, registrationStatusDto.getRegistrationType(), + ProviderStageName.DEMO_DEDUPE); int ageThreshold = Integer.parseInt(ageLimit); if (age < ageThreshold) { if (infantDedupe.equalsIgnoreCase(GLOBAL_CONFIG_TRUE_VALUE)) { diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java index 69787f9dc25..7bda26ca2e9 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/test/java/io/mosip/registrationprocessor/stages/demodedupe/DemodedupeProcessorTest.java @@ -80,6 +80,7 @@ import io.mosip.registration.processor.packet.storage.repository.BasePacketRepository; import io.mosip.registration.processor.packet.storage.utils.ABISHandlerUtil; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.rest.client.audit.dto.AuditResponseDto; import io.mosip.registration.processor.stages.demodedupe.DemoDedupe; @@ -148,7 +149,10 @@ public class DemodedupeProcessorTest { private RegistrationStatusDao registrationStatusDao; @Mock - private Utilities utility; + private Utilities utilities; + + @Mock + private Utility utility; private InternalRegistrationStatusDto registrationStatusDto; @@ -181,7 +185,7 @@ public class DemodedupeProcessorTest { */ @Before public void setUp() throws Exception { - when(utility.getDefaultSource(any(), any())).thenReturn(source); + when(utilities.getDefaultSource(any(), any())).thenReturn(source); ReflectionTestUtils.setField(demodedupeProcessor, "infantDedupe", "Y"); ReflectionTestUtils.setField(demodedupeProcessor, "ageLimit", "4"); dto.setRid("2018701130000410092018110735"); @@ -308,7 +312,7 @@ public void setUp() throws Exception { String mappingJsonString = IOUtils.toString(inputStream,"UTF-8"); JSONObject mappingJsonObj= new ObjectMapper().readValue(mappingJsonString, JSONObject.class); - Mockito.when(utility.getRegistrationProcessorMappingJson(anyString())).thenReturn(JsonUtil.getJSONObject(mappingJsonObj, MappingJsonConstants.IDENTITY)); + Mockito.when(utilities.getRegistrationProcessorMappingJson(anyString())).thenReturn(JsonUtil.getJSONObject(mappingJsonObj, MappingJsonConstants.IDENTITY)); } @@ -348,7 +352,7 @@ public void testDemoDedupeUpdatePacketSuccess() throws Exception { IdentityJsonValues identityJsonValues = new IdentityJsonValues(); identityJsonValues.setValue("fullName"); - when(utility.getDefaultSource(any(), any())).thenReturn(source); + when(utilities.getDefaultSource(any(), any())).thenReturn(source); Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("2345"); JSONArray arr = new JSONArray(); @@ -356,7 +360,7 @@ public void testDemoDedupeUpdatePacketSuccess() throws Exception { JSONObject obj = new JSONObject(); obj.put("fullName", arr); - Mockito.when(utility.retrieveIdrepoJson(anyString())).thenReturn(obj); + Mockito.when(utilities.retrieveIdrepoJson(anyString())).thenReturn(obj); byte[] b = "sds".getBytes(); List emptyDuplicateDtoSet = new ArrayList<>(); @@ -383,10 +387,10 @@ public void testDemoDedupeUpdatePacketException() throws Exception { IdentityJsonValues identityJsonValues = new IdentityJsonValues(); identityJsonValues.setValue("fullName"); - when(utility.getDefaultSource(any(),any())).thenReturn(source); + when(utilities.getDefaultSource(any(),any())).thenReturn(source); Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("2345"); - Mockito.when(utility.retrieveIdrepoJson(any())).thenReturn(null); + Mockito.when(utilities.retrieveIdrepoJson(any())).thenReturn(null); byte[] b = "sds".getBytes(); List emptyDuplicateDtoSet = new ArrayList<>(); @@ -413,7 +417,7 @@ public void testDemoDedupeResUpdatePacketSuccess() throws Exception { IdentityJsonValues identityJsonValues = new IdentityJsonValues(); identityJsonValues.setValue("fullName"); - when(utility.getDefaultSource(any(),any())).thenReturn(source); + when(utilities.getDefaultSource(any(),any())).thenReturn(source); Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("2345"); JSONArray arr = new JSONArray(); @@ -421,7 +425,7 @@ public void testDemoDedupeResUpdatePacketSuccess() throws Exception { JSONObject obj = new JSONObject(); obj.put("fullName", arr); - Mockito.when(utility.retrieveIdrepoJson(anyString())).thenReturn(obj); + Mockito.when(utilities.retrieveIdrepoJson(anyString())).thenReturn(obj); byte[] b = "sds".getBytes(); List emptyDuplicateDtoSet = new ArrayList<>(); @@ -458,7 +462,7 @@ public void testDemoDedupeResUpdatePacketSuccess() throws Exception { public void testDemoDedupeSuccessNotDuplicateAfterAuth() throws Exception { byte[] b = "sds".getBytes(); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); PowerMockito.mockStatic(JsonUtil.class); PowerMockito.mockStatic(IOUtils.class); PowerMockito.when(JsonUtil.class, "inputStreamtoJavaObject", inputStream, PacketMetaInfo.class) @@ -502,7 +506,7 @@ public void testDemoDedupePotentialMatchSuccess() throws Exception { registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.find(any(),any(),any(),any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -539,7 +543,7 @@ public void testDemoDedupePotentialMatchWithEmpty() throws Exception { Mockito.when(abisHandlerUtil.getUniqueRegIds(anyString(), anyString(), anyInt(), any(), any())) .thenReturn(matchedRegIds); doNothing().when(packetInfoManager).saveManualAdjudicationData(anySet(), any(), any(), any(), any(),any(),any()); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -579,7 +583,7 @@ public void testDemoDedupeWithOnePotentialMatch() throws Exception { Mockito.when(abisHandlerUtil.getUniqueRegIds(anyString(), anyString(), anyInt(), any(), any())) .thenReturn(matchedRegIds); doNothing().when(packetInfoManager).saveManualAdjudicationData(anySet(), any(), any(), any(), any(),any(),any()); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertFalse(messageDto.getIsValid()); @@ -614,7 +618,7 @@ public void testDemoDedupeEmptyMatch() throws Exception { Mockito.when(abisHandlerUtil.getUniqueRegIds(anyString(), anyString(), anyInt(), any(), any())) .thenReturn(matchedRegIds); doNothing().when(packetInfoManager).saveManualAdjudicationData(anySet(), any(), any(), any(), any(),any(),any()); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -643,7 +647,7 @@ public void testDemoDedupePotentialMatchAbisResponseNotProcessed() throws Except registrationStatusDto.setRegistrationType(RegistrationType.NEW.toString()); Mockito.when(registrationStatusDao.find(any(),any(),any(),any())).thenReturn(entity); Mockito.when(packetInfoManager.getAbisResponseRecords(anyString(), anyString())).thenReturn(abisResponseDtos); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertTrue(messageDto.getIsValid()); @@ -673,7 +677,7 @@ public void testDemoDedupeFailure() throws ApisResourceAccessException, IOExcept Mockito.when(abisHandlerUtil.getPacketStatus(any())).thenReturn(RegistrationType.NEW.toString()); Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); registrationStatusDto.setRetryCount(3); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); demodedupeProcessor.process(dto, stageName); } @@ -698,7 +702,7 @@ public void testResourceException() throws ApisResourceAccessException, IOExcept when(env.getProperty(DEMODEDUPEENABLE)).thenReturn("true"); List emptyDuplicateDtoSet = new ArrayList<>(); - when(utility.getDefaultSource(any(),any())).thenReturn(source); + when(utilities.getDefaultSource(any(),any())).thenReturn(source); Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); @@ -706,7 +710,7 @@ public void testResourceException() throws ApisResourceAccessException, IOExcept Mockito.when(registrationStatusMapperUtil .getStatusCode(RegistrationExceptionTypeCode.APIS_RESOURCE_ACCESS_EXCEPTION)).thenReturn("REPROCESS"); Mockito.when(demoDedupe.performDedupe(anyString())).thenReturn(emptyDuplicateDtoSet); - when(utility.getDefaultSource(any(), any())).thenReturn(source); + when(utilities.getDefaultSource(any(), any())).thenReturn(source); ApisResourceAccessException exp = new ApisResourceAccessException("errorMessage"); Mockito.doThrow(exp).when(utility).getApplicantAge(anyString(),anyString(), any()); @@ -727,7 +731,7 @@ public void testFSAdapterExceptionException() Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); Mockito.when(registrationStatusMapperUtil .getStatusCode(RegistrationExceptionTypeCode.OBJECT_STORE_EXCEPTION)).thenReturn("REPROCESS"); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertEquals(true, messageDto.getInternalError()); assertTrue(messageDto.getIsValid()); @@ -742,7 +746,7 @@ public void testIllegalArgumentException() throws ApisResourceAccessException, I Mockito.when(registrationStatusService.getRegistrationStatus(any(),any(),any(), any())).thenReturn(registrationStatusDto); Mockito.when(registrationStatusMapperUtil .getStatusCode(RegistrationExceptionTypeCode.ILLEGAL_ARGUMENT_EXCEPTION)).thenReturn("ERROR"); - Mockito.when(utility.getApplicantAge(anyString(),anyString(), any())).thenReturn(20); + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(20); MessageDTO messageDto = demodedupeProcessor.process(dto, stageName); assertEquals(true, messageDto.getInternalError()); assertFalse(messageDto.getIsValid()); diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml index c145fe1cedc..6e751769e18 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/pom.xml @@ -100,11 +100,6 @@ powermock-api-mockito2 test - - org.apache.activemq - activemq-client - 6.1.2 - diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/service/impl/ManualAdjudicationServiceImpl.java b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/service/impl/ManualAdjudicationServiceImpl.java index f84631a0d01..dfa792dcddb 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/service/impl/ManualAdjudicationServiceImpl.java +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/java/io/mosip/registration/processor/adjudication/service/impl/ManualAdjudicationServiceImpl.java @@ -99,6 +99,7 @@ import io.mosip.registration.processor.packet.storage.repository.BasePacketRepository; import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.status.code.RegistrationStatusCode; import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; @@ -165,7 +166,10 @@ public class ManualAdjudicationServiceImpl implements ManualAdjudicationService private CbeffUtil cbeffutil; @Autowired - private Utilities utility; + private Utilities utilities; + + @Autowired + private Utility utility; @Autowired private IdRepoService idRepoService; @@ -433,7 +437,7 @@ private String getDataShareUrl(String id, String process) throws Exception { // set biometrics - JSONObject regProcessorIdentityJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + JSONObject regProcessorIdentityJson = utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); String individualBiometricsLabel = JsonUtil.getJSONValue( JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.INDIVIDUAL_BIOMETRICS), MappingJsonConstants.VALUE); @@ -470,7 +474,7 @@ private String getDataShareUrlfromIdRepo(String id) throws DataShareException, A List documents=responseDTO.getDocuments(); requestDto=setDocuments(policyMap, requestDto, null, null, documents); - JSONObject regProcessorIdentityJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + JSONObject regProcessorIdentityJson = utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); String individualBiometricsLabel = JsonUtil.getJSONValue( JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.INDIVIDUAL_BIOMETRICS), MappingJsonConstants.VALUE); @@ -550,7 +554,7 @@ private Map getDemographicMap(Map policyMap){ return demographicMap; } private DataShareRequestDto setDocuments(Map policyMap,DataShareRequestDto requestDto, String id, String process, List documents) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException{ - JSONObject docJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT); + JSONObject docJson = utilities.getRegistrationProcessorMappingJson(MappingJsonConstants.DOCUMENT); for (Object doc : docJson.keySet()) { if (doc != null) { HashMap docmap = (HashMap) docJson.get(doc.toString()); @@ -783,7 +787,8 @@ private List addReferenceURLs(String id,InternalRegistrationStatus referenceURLs.add(referenceURL); if(registrationStatusDto.getRegistrationType().equalsIgnoreCase(RegistrationType.UPDATE.name()) || registrationStatusDto.getRegistrationType().equalsIgnoreCase(RegistrationType.RES_UPDATE.name())) { - String uinField = utility.getUIn(id, registrationStatusDto.getRegistrationType(), ProviderStageName.MANUAL_ADJUDICATION); + String uinField = utility.getUIn(id, registrationStatusDto.getRegistrationType(), + ProviderStageName.MANUAL_ADJUDICATION); ReferenceURL referenceURL1=new ReferenceURL(); referenceURL1.setSource(ID_REPO); referenceURL1.setStatus(PROCESSED); diff --git a/registration-processor/core-processor/registration-processor-verification-stage/pom.xml b/registration-processor/core-processor/registration-processor-verification-stage/pom.xml index 4f2f719067c..ee8b01a90c0 100644 --- a/registration-processor/core-processor/registration-processor-verification-stage/pom.xml +++ b/registration-processor/core-processor/registration-processor-verification-stage/pom.xml @@ -107,11 +107,6 @@ powermock-api-mockito2 test - - org.apache.activemq - activemq-client - 6.1.2 - diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index 3b87c0e7e57..896552fef1a 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -350,6 +350,10 @@ com.hazelcast hazelcast 3.9.4 + + org.apache.activemq + activemq-client + 6.1.2 diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java index 58d937d355b..c2a0dd30ad1 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/java/io/mosip/registration/processor/credentialrequestor/stage/CredentialRequestorStage.java @@ -30,6 +30,7 @@ import io.mosip.registration.processor.credentialrequestor.dto.CredentialPartner; import io.mosip.registration.processor.credentialrequestor.stage.exception.VidNotAvailableException; import io.mosip.registration.processor.credentialrequestor.util.CredentialPartnerUtil; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.status.code.RegistrationStatusCode; @@ -147,6 +148,9 @@ public class CredentialRequestorStage extends MosipVerticleAPIManager { @Autowired private Utilities utilities; + @Autowired + private PriorityBasedPacketManagerService packetManagerService; + @Autowired private CredentialPartnerUtil credentialPartnerUtil; @@ -371,7 +375,8 @@ private void getAdditionalCredentialFields(String regId, String process, List metaInfoFields, Map additionalAttributes) { try { - Map metaInfo = utilities.getPacketManagerService().getMetaInfo(regId, process, ProviderStageName.CREDENTIAL_REQUESTOR); + Map metaInfo = packetManagerService.getMetaInfo(regId, process, + ProviderStageName.CREDENTIAL_REQUESTOR); JSONArray metadata = new JSONArray(metaInfo.get(JsonConstant.METADATA)); for(int i=0; i getCredentialPartners(String regId, String regist } // adding additional metadata so that it can be used for MVEL expression - Map metaInfo = utilities.getPacketManagerService().getMetaInfo(regId, registrationType, ProviderStageName.CREDENTIAL_REQUESTOR); + Map metaInfo = packetManagerService.getMetaInfo(regId, registrationType, + ProviderStageName.CREDENTIAL_REQUESTOR); if (MapUtils.isNotEmpty(metaInfo)) { String metadata = metaInfo.get(JsonConstant.METADATA); if (!StringUtils.isEmpty(metadata)) { diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java index bc56aa0f744..47c221d61ec 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java @@ -13,7 +13,7 @@ @ComponentScan(basePackages= {"io.mosip.registration.processor.status.*","io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.core.token.*", "io.mosip.registration.processor.core.config", "io.mosip.registration.processor.transaction.*", "${mosip.auth.adapter.impl.basepackage}"}, -excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = {RegistrationStatusBeanConfig.class, + excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusBeanConfig.class, RestConfigBean.class})) public class RegistrationTransactionServiceApplication { diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java index df8303af2fe..a6fd768eb87 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGenerator.java @@ -4,6 +4,7 @@ import io.mosip.registration.processor.core.constant.ProviderStageName; import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; import io.mosip.registration.processor.stages.packetclassifier.dto.FieldDTO; import io.mosip.registration.processor.stages.packetclassifier.tagging.TagGenerator; @@ -38,7 +39,7 @@ public class AgeGroupTagGenerator implements TagGenerator { /** Frequently used util methods are available in this bean */ @Autowired - private Utilities utility; + private Utility utility; private static String RANGE_DELIMITER = "-"; diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/test/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGeneratorTest.java b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/test/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGeneratorTest.java index 5294039003b..b684e4cd3cd 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/test/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGeneratorTest.java +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/test/java/io/mosip/registration/processor/stages/packetclassifier/tagging/impl/AgeGroupTagGeneratorTest.java @@ -1,106 +1,107 @@ -package io.mosip.registration.processor.stages.packetclassifier.tagging.impl; - -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; -import org.springframework.cloud.context.config.annotation.RefreshScope; - -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.registration.processor.packet.storage.utils.Utilities; - -/** - * The Class PacketValidatorStageTest. - */ -@RefreshScope -@RunWith(PowerMockRunner.class) -@PowerMockIgnore({ "javax.management.*", "javax.net.ssl.*", "com.sun.org.apache.xerces.*", - "javax.xml.*", "org.xml.*" }) -public class AgeGroupTagGeneratorTest { - - @InjectMocks - private AgeGroupTagGenerator ageGroupTagGenerator; - - @Mock - private Utilities utility; - - private static String tagName = "AGE_GROUP"; - Map ageGroupRangeMap; - - @Before - public void setup() throws Exception { - - ageGroupRangeMap = new HashMap<>(); - ageGroupRangeMap.put("CHILD", "0-17"); - ageGroupRangeMap.put("ADULT", "18-59"); - ageGroupRangeMap.put("SENIOR_CITIZEN", "60-200"); - - Whitebox.setInternalState(ageGroupTagGenerator, "tagName", tagName); - Whitebox.setInternalState(ageGroupTagGenerator, "notAvailableTagValue", "--TAG_VALUE_NOT_AVAILABLE--"); - Whitebox.setInternalState(ageGroupTagGenerator, "ageGroupRangeMap", ageGroupRangeMap); - - Whitebox.invokeMethod(ageGroupTagGenerator, "generateParsedAgeGroupRangeMap"); - - } - - @Test - public void testGenerateTagsForChildGroup() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(17); - Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); - assertEquals(tags.get(tagName), "CHILD"); - } - - @Test - public void testGenerateTagsForAdultGroup() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(30); - Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); - assertEquals(tags.get(tagName), "ADULT"); - } - - @Test - public void testGenerateTagsForSeniorCitizenGroup() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(65); - Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); - assertEquals(tags.get(tagName), "SENIOR_CITIZEN"); - } - - @Test - public void testGenerateTagsForLostPacket() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(-1); - Map tags = ageGroupTagGenerator.generateTags("1234", "123", "LOST", null, null, 0); - assertEquals(tags.get(tagName), "--TAG_VALUE_NOT_AVAILABLE--"); - } - - @Test(expected = BaseCheckedException.class) - public void testGenerateTagsForAgeGroupNotFound() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(201); - ageGroupTagGenerator.generateTags("1234", "123", "LOST", null, null, 0); - } - - @Test(expected = BaseCheckedException.class) - public void testGenerateTagsForUtilityThrowningIOException() throws Exception { - Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenThrow(new IOException()); - ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); - } - - @Test - public void getRequiredIdObjectFieldNamesTest() throws Exception { - List result = ageGroupTagGenerator.getRequiredIdObjectFieldNames(); - assertEquals(result, null); - } - -} +package io.mosip.registration.processor.stages.packetclassifier.tagging.impl; + +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; +import org.springframework.cloud.context.config.annotation.RefreshScope; + +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; + +/** + * The Class PacketValidatorStageTest. + */ +@RefreshScope +@RunWith(PowerMockRunner.class) +@PowerMockIgnore({ "javax.management.*", "javax.net.ssl.*", "com.sun.org.apache.xerces.*", + "javax.xml.*", "org.xml.*" }) +public class AgeGroupTagGeneratorTest { + + @InjectMocks + private AgeGroupTagGenerator ageGroupTagGenerator; + + @Mock + private Utility utility; + + private static String tagName = "AGE_GROUP"; + Map ageGroupRangeMap; + + @Before + public void setup() throws Exception { + + ageGroupRangeMap = new HashMap<>(); + ageGroupRangeMap.put("CHILD", "0-17"); + ageGroupRangeMap.put("ADULT", "18-59"); + ageGroupRangeMap.put("SENIOR_CITIZEN", "60-200"); + + Whitebox.setInternalState(ageGroupTagGenerator, "tagName", tagName); + Whitebox.setInternalState(ageGroupTagGenerator, "notAvailableTagValue", "--TAG_VALUE_NOT_AVAILABLE--"); + Whitebox.setInternalState(ageGroupTagGenerator, "ageGroupRangeMap", ageGroupRangeMap); + + Whitebox.invokeMethod(ageGroupTagGenerator, "generateParsedAgeGroupRangeMap"); + + } + + @Test + public void testGenerateTagsForChildGroup() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(17); + Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); + assertEquals(tags.get(tagName), "CHILD"); + } + + @Test + public void testGenerateTagsForAdultGroup() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(30); + Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); + assertEquals(tags.get(tagName), "ADULT"); + } + + @Test + public void testGenerateTagsForSeniorCitizenGroup() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(65); + Map tags = ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); + assertEquals(tags.get(tagName), "SENIOR_CITIZEN"); + } + + @Test + public void testGenerateTagsForLostPacket() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(-1); + Map tags = ageGroupTagGenerator.generateTags("1234", "123", "LOST", null, null, 0); + assertEquals(tags.get(tagName), "--TAG_VALUE_NOT_AVAILABLE--"); + } + + @Test(expected = BaseCheckedException.class) + public void testGenerateTagsForAgeGroupNotFound() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenReturn(201); + ageGroupTagGenerator.generateTags("1234", "123", "LOST", null, null, 0); + } + + @Test(expected = BaseCheckedException.class) + public void testGenerateTagsForUtilityThrowningIOException() throws Exception { + Mockito.when(utility.getApplicantAge(anyString(), anyString(), any())).thenThrow(new IOException()); + ageGroupTagGenerator.generateTags("1234", "123", "NEW", null, null, 0); + } + + @Test + public void getRequiredIdObjectFieldNamesTest() throws Exception { + List result = ageGroupTagGenerator.getRequiredIdObjectFieldNames(); + assertEquals(result, null); + } + +} diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/PacketValidatorImpl.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/PacketValidatorImpl.java index b8b101258c4..d4cdb4f0958 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/PacketValidatorImpl.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/PacketValidatorImpl.java @@ -1,299 +1,303 @@ -package io.mosip.registration.processor.stages.validator.impl; - -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.simple.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.cbeffutil.exception.CbeffException; -import io.mosip.kernel.core.exception.BiometricSignatureValidationException; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.constant.RegistrationType; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.FieldValue; -import io.mosip.registration.processor.core.packet.dto.packetvalidator.PacketValidationDto; -import io.mosip.registration.processor.core.spi.packet.validator.PacketValidator; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; -import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.stages.utils.ApplicantDocumentValidation; -import io.mosip.registration.processor.stages.utils.BiometricsXSDValidator; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; - -@Component -@RefreshScope -public class PacketValidatorImpl implements PacketValidator { - - private static Logger regProcLogger = RegProcessorLogger.getLogger(PacketValidatorImpl.class); - private static final String VALIDATIONFALSE = "false"; - public static final String APPROVED = "APPROVED"; - public static final String REJECTED = "REJECTED"; - private static final String VALIDATEAPPLICANTDOCUMENT = "mosip.regproc.packet.validator.validate-applicant-document"; - private static final String VALIDATEAPPLICANTDOCUMENTPROCESS = "mosip.regproc.packet.validator.validate-applicant-document.processes"; - - @Autowired - private PriorityBasedPacketManagerService packetManagerService; - - @Autowired - private Utilities utility; - - @Autowired - private Environment env; - - @Autowired - ObjectMapper mapper; - - @Autowired - private BiometricsXSDValidator biometricsXSDValidator; - - @Autowired - private BiometricsSignatureValidator biometricsSignatureValidator; - - @Autowired - private ApplicantDocumentValidation applicantDocumentValidation; - - @Override - public boolean validate(String id, String process, PacketValidationDto packetValidationDto) - throws ApisResourceAccessException, RegistrationProcessorCheckedException, IOException, - JsonProcessingException, PacketManagerException { - String uin = null; - try { - ValidatePacketResponse response = packetManagerService.validate(id, process, - ProviderStageName.PACKET_VALIDATOR); - if (!response.isValid()) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getMessage()); - packetValidationDto - .setPacketValidatonStatusCode(StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getCode()); - packetValidationDto - .setPacketValidaionFailureMessage(StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getMessage()); - return false; - } - - //Check consent - if(!checkConsentForPacket(id,process,ProviderStageName.PACKET_VALIDATOR)) - { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + StatusUtil.PACKET_CONSENT_VALIDATION.getMessage()); - packetValidationDto - .setPacketValidatonStatusCode(StatusUtil.PACKET_CONSENT_VALIDATION.getCode()); - packetValidationDto - .setPacketValidaionFailureMessage(StatusUtil.PACKET_CONSENT_VALIDATION.getMessage()); - return false; - } - - - - if (process.equalsIgnoreCase(RegistrationType.UPDATE.toString()) - || process.equalsIgnoreCase(RegistrationType.RES_UPDATE.toString())) { - uin = utility.getUIn(id, process, ProviderStageName.PACKET_VALIDATOR); - if (uin == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + PlatformErrorMessages.RPR_PVM_INVALID_UIN.getMessage()); - throw new IdRepoAppException(PlatformErrorMessages.RPR_PVM_INVALID_UIN.getMessage()); - } - JSONObject jsonObject = utility.retrieveIdrepoJson(uin); - if (jsonObject == null) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + PlatformErrorMessages.RPR_PIS_IDENTITY_NOT_FOUND.getMessage()); - throw new IdRepoAppException(PlatformErrorMessages.RPR_PIS_IDENTITY_NOT_FOUND.getMessage()); - } - String status = utility.retrieveIdrepoJsonStatus(uin); - if (process.equalsIgnoreCase(RegistrationType.UPDATE.toString()) - && status.equalsIgnoreCase(RegistrationType.DEACTIVATED.toString())) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + PlatformErrorMessages.RPR_PVM_UPDATE_DEACTIVATED.getMessage()); - throw new RegistrationProcessorCheckedException( - PlatformErrorMessages.RPR_PVM_UPDATE_DEACTIVATED.getCode(), "UIN is Deactivated"); - } - } - - // document validation - if (!applicantDocumentValidation(id, process, packetValidationDto)) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getMessage()); - return false; - } - - // check if uin is in idrepisitory - if (RegistrationType.UPDATE.name().equalsIgnoreCase(process) - || RegistrationType.RES_UPDATE.name().equalsIgnoreCase(process)) { - - if (!utility.uinPresentInIdRepo(String.valueOf(uin))) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======>" + StatusUtil.UIN_NOT_FOUND_IDREPO.getMessage()); - packetValidationDto.setPacketValidaionFailureMessage(StatusUtil.UIN_NOT_FOUND_IDREPO.getMessage()); - packetValidationDto.setPacketValidatonStatusCode(StatusUtil.UIN_NOT_FOUND_IDREPO.getCode()); - return false; - } - } - - if (!biometricsXSDValidation(id, process, packetValidationDto)) { - return false; - } - } catch (PacketManagerException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - id, RegistrationStatusCode.FAILED.toString() + e.getMessage() + ExceptionUtils.getStackTrace(e)); - throw e; - } catch (JSONException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - id, RegistrationStatusCode.FAILED.toString() + e.getMessage() + ExceptionUtils.getStackTrace(e)); - packetValidationDto.setPacketValidaionFailureMessage( - StatusUtil.JSON_PARSING_EXCEPTION.getMessage() + e.getMessage()); - packetValidationDto.setPacketValidatonStatusCode(StatusUtil.JSON_PARSING_EXCEPTION.getCode()); - } - - packetValidationDto.setValid(true); - return packetValidationDto.isValid(); - } - - private boolean biometricsXSDValidation(String id, String process, PacketValidationDto packetValidationDto) - throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException, - RegistrationProcessorCheckedException, JSONException { - List fields = Arrays.asList(MappingJsonConstants.INDIVIDUAL_BIOMETRICS, - MappingJsonConstants.AUTHENTICATION_BIOMETRICS, MappingJsonConstants.INTRODUCER_BIO, - MappingJsonConstants.OFFICERBIOMETRICFILENAME, MappingJsonConstants.SUPERVISORBIOMETRICFILENAME); - - Map metaInfoMap = packetManagerService.getMetaInfo(id, process, - ProviderStageName.PACKET_VALIDATOR); - - for (String field : fields) { - BiometricRecord biometricRecord = null; - if (field.equals(MappingJsonConstants.OFFICERBIOMETRICFILENAME) - || field.equals(MappingJsonConstants.SUPERVISORBIOMETRICFILENAME)) { - String value = getOperationsDataFromMetaInfo(id, process, field, metaInfoMap); - if (value != null && !value.isEmpty()) { - biometricRecord = packetManagerService.getBiometrics(id, field, process, - ProviderStageName.PACKET_VALIDATOR); - } - } else { - String value = packetManagerService.getField(id, field, process, ProviderStageName.PACKET_VALIDATOR); - if (value != null && !value.isEmpty()) { - biometricRecord = packetManagerService.getBiometricsByMappingJsonKey(id, field, process, - ProviderStageName.PACKET_VALIDATOR); - } - } - - if (biometricRecord != null) { - try { - biometricsXSDValidator.validateXSD(biometricRecord); - biometricsSignatureValidator.validateSignature(id, process, biometricRecord, metaInfoMap); - } catch (Exception e) { - if (e instanceof CbeffException) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======> " + StatusUtil.XSD_VALIDATION_EXCEPTION.getMessage()); - packetValidationDto.setPacketValidaionFailureMessage( - StatusUtil.XSD_VALIDATION_EXCEPTION.getMessage()); - packetValidationDto.setPacketValidatonStatusCode(StatusUtil.XSD_VALIDATION_EXCEPTION.getCode()); - return false; - } else if (e instanceof BiometricSignatureValidationException) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), - LoggerFileConstant.REGISTRATIONID.toString(), id, - "ERROR =======> " + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage()); - packetValidationDto.setPacketValidaionFailureMessage( - StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage() + "--> " - + e.getMessage()); - packetValidationDto.setPacketValidatonStatusCode( - StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getCode()); - return false; - } else { - throw new RegistrationProcessorCheckedException( - PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getCode(), - PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getMessage(), e); - } - } - } - } - return true; - } - - private String getOperationsDataFromMetaInfo(String id, String process, String fileName, - Map metaInfoMap) - throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { - String metadata = metaInfoMap.get(JsonConstant.OPERATIONSDATA); - String value = null; - if (StringUtils.isNotEmpty(metadata)) { - JSONArray jsonArray = new JSONArray(metadata); - - for (int i = 0; i < jsonArray.length(); i++) { - if (!jsonArray.isNull(i)) { - org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); - FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); - if (fieldValue.getLabel().equalsIgnoreCase(fileName)) { - value = fieldValue.getValue(); - break; - } - } - } - } - return value; - } - - - private boolean applicantDocumentValidation(String registrationId, String process, - PacketValidationDto packetValidationDto) - throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException { - String validateApplicant=env.getProperty(VALIDATEAPPLICANTDOCUMENT); - if (validateApplicant!=null && validateApplicant.trim().equalsIgnoreCase(VALIDATIONFALSE)) - return true; - else { - String validateApplicantDocument=env.getProperty(VALIDATEAPPLICANTDOCUMENTPROCESS); - if(validateApplicantDocument!=null && validateApplicantDocument.contains(process)) { - boolean result = applicantDocumentValidation.validateDocument(registrationId, process); - if (!result) { - packetValidationDto.setPacketValidaionFailureMessage(StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getMessage()); - packetValidationDto.setPacketValidatonStatusCode(StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getCode()); - } - return result; - } - return true; - } - } - - private boolean checkConsentForPacket(String id, String process, ProviderStageName stageName) - throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { - - String val = packetManagerService.getField(id, MappingJsonConstants.CONSENT, process, stageName); - if (null!=val && StringUtils.isNotEmpty(val)) { - if (val.equalsIgnoreCase("N")) - return false; - } - return true; - - } - - - +package io.mosip.registration.processor.stages.validator.impl; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.simple.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.cbeffutil.exception.CbeffException; +import io.mosip.kernel.core.exception.BiometricSignatureValidationException; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.constant.RegistrationType; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.packet.dto.packetvalidator.PacketValidationDto; +import io.mosip.registration.processor.core.spi.packet.validator.PacketValidator; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; +import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; +import io.mosip.registration.processor.stages.utils.ApplicantDocumentValidation; +import io.mosip.registration.processor.stages.utils.BiometricsXSDValidator; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; + +@Component +@RefreshScope +public class PacketValidatorImpl implements PacketValidator { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(PacketValidatorImpl.class); + private static final String VALIDATIONFALSE = "false"; + public static final String APPROVED = "APPROVED"; + public static final String REJECTED = "REJECTED"; + private static final String VALIDATEAPPLICANTDOCUMENT = "mosip.regproc.packet.validator.validate-applicant-document"; + private static final String VALIDATEAPPLICANTDOCUMENTPROCESS = "mosip.regproc.packet.validator.validate-applicant-document.processes"; + + @Autowired + private PriorityBasedPacketManagerService packetManagerService; + + @Autowired + private Utilities utililites; + + @Autowired + private Utility utility; + + @Autowired + private Environment env; + + @Autowired + ObjectMapper mapper; + + @Autowired + private BiometricsXSDValidator biometricsXSDValidator; + + @Autowired + private BiometricsSignatureValidator biometricsSignatureValidator; + + @Autowired + private ApplicantDocumentValidation applicantDocumentValidation; + + @Override + public boolean validate(String id, String process, PacketValidationDto packetValidationDto) + throws ApisResourceAccessException, RegistrationProcessorCheckedException, IOException, + JsonProcessingException, PacketManagerException { + String uin = null; + try { + ValidatePacketResponse response = packetManagerService.validate(id, process, + ProviderStageName.PACKET_VALIDATOR); + if (!response.isValid()) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getMessage()); + packetValidationDto + .setPacketValidatonStatusCode(StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getCode()); + packetValidationDto + .setPacketValidaionFailureMessage(StatusUtil.PACKET_MANAGER_VALIDATION_FAILURE.getMessage()); + return false; + } + + //Check consent + if(!checkConsentForPacket(id,process,ProviderStageName.PACKET_VALIDATOR)) + { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + StatusUtil.PACKET_CONSENT_VALIDATION.getMessage()); + packetValidationDto + .setPacketValidatonStatusCode(StatusUtil.PACKET_CONSENT_VALIDATION.getCode()); + packetValidationDto + .setPacketValidaionFailureMessage(StatusUtil.PACKET_CONSENT_VALIDATION.getMessage()); + return false; + } + + + + if (process.equalsIgnoreCase(RegistrationType.UPDATE.toString()) + || process.equalsIgnoreCase(RegistrationType.RES_UPDATE.toString())) { + uin = utility.getUIn(id, process, ProviderStageName.PACKET_VALIDATOR); + if (uin == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + PlatformErrorMessages.RPR_PVM_INVALID_UIN.getMessage()); + throw new IdRepoAppException(PlatformErrorMessages.RPR_PVM_INVALID_UIN.getMessage()); + } + JSONObject jsonObject = utililites.retrieveIdrepoJson(uin); + if (jsonObject == null) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + PlatformErrorMessages.RPR_PIS_IDENTITY_NOT_FOUND.getMessage()); + throw new IdRepoAppException(PlatformErrorMessages.RPR_PIS_IDENTITY_NOT_FOUND.getMessage()); + } + String status = utililites.retrieveIdrepoJsonStatus(uin); + if (process.equalsIgnoreCase(RegistrationType.UPDATE.toString()) + && status.equalsIgnoreCase(RegistrationType.DEACTIVATED.toString())) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + PlatformErrorMessages.RPR_PVM_UPDATE_DEACTIVATED.getMessage()); + throw new RegistrationProcessorCheckedException( + PlatformErrorMessages.RPR_PVM_UPDATE_DEACTIVATED.getCode(), "UIN is Deactivated"); + } + } + + // document validation + if (!applicantDocumentValidation(id, process, packetValidationDto)) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getMessage()); + return false; + } + + // check if uin is in idrepisitory + if (RegistrationType.UPDATE.name().equalsIgnoreCase(process) + || RegistrationType.RES_UPDATE.name().equalsIgnoreCase(process)) { + + if (!utililites.uinPresentInIdRepo(String.valueOf(uin))) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======>" + StatusUtil.UIN_NOT_FOUND_IDREPO.getMessage()); + packetValidationDto.setPacketValidaionFailureMessage(StatusUtil.UIN_NOT_FOUND_IDREPO.getMessage()); + packetValidationDto.setPacketValidatonStatusCode(StatusUtil.UIN_NOT_FOUND_IDREPO.getCode()); + return false; + } + } + + if (!biometricsXSDValidation(id, process, packetValidationDto)) { + return false; + } + } catch (PacketManagerException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + id, RegistrationStatusCode.FAILED.toString() + e.getMessage() + ExceptionUtils.getStackTrace(e)); + throw e; + } catch (JSONException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + id, RegistrationStatusCode.FAILED.toString() + e.getMessage() + ExceptionUtils.getStackTrace(e)); + packetValidationDto.setPacketValidaionFailureMessage( + StatusUtil.JSON_PARSING_EXCEPTION.getMessage() + e.getMessage()); + packetValidationDto.setPacketValidatonStatusCode(StatusUtil.JSON_PARSING_EXCEPTION.getCode()); + } + + packetValidationDto.setValid(true); + return packetValidationDto.isValid(); + } + + private boolean biometricsXSDValidation(String id, String process, PacketValidationDto packetValidationDto) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException, + RegistrationProcessorCheckedException, JSONException { + List fields = Arrays.asList(MappingJsonConstants.INDIVIDUAL_BIOMETRICS, + MappingJsonConstants.AUTHENTICATION_BIOMETRICS, MappingJsonConstants.INTRODUCER_BIO, + MappingJsonConstants.OFFICERBIOMETRICFILENAME, MappingJsonConstants.SUPERVISORBIOMETRICFILENAME); + + Map metaInfoMap = packetManagerService.getMetaInfo(id, process, + ProviderStageName.PACKET_VALIDATOR); + + for (String field : fields) { + BiometricRecord biometricRecord = null; + if (field.equals(MappingJsonConstants.OFFICERBIOMETRICFILENAME) + || field.equals(MappingJsonConstants.SUPERVISORBIOMETRICFILENAME)) { + String value = getOperationsDataFromMetaInfo(id, process, field, metaInfoMap); + if (value != null && !value.isEmpty()) { + biometricRecord = packetManagerService.getBiometrics(id, field, process, + ProviderStageName.PACKET_VALIDATOR); + } + } else { + String value = packetManagerService.getField(id, field, process, ProviderStageName.PACKET_VALIDATOR); + if (value != null && !value.isEmpty()) { + biometricRecord = packetManagerService.getBiometricsByMappingJsonKey(id, field, process, + ProviderStageName.PACKET_VALIDATOR); + } + } + + if (biometricRecord != null) { + try { + biometricsXSDValidator.validateXSD(biometricRecord); + biometricsSignatureValidator.validateSignature(id, process, biometricRecord, metaInfoMap); + } catch (Exception e) { + if (e instanceof CbeffException) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======> " + StatusUtil.XSD_VALIDATION_EXCEPTION.getMessage()); + packetValidationDto.setPacketValidaionFailureMessage( + StatusUtil.XSD_VALIDATION_EXCEPTION.getMessage()); + packetValidationDto.setPacketValidatonStatusCode(StatusUtil.XSD_VALIDATION_EXCEPTION.getCode()); + return false; + } else if (e instanceof BiometricSignatureValidationException) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), + LoggerFileConstant.REGISTRATIONID.toString(), id, + "ERROR =======> " + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage()); + packetValidationDto.setPacketValidaionFailureMessage( + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage() + "--> " + + e.getMessage()); + packetValidationDto.setPacketValidatonStatusCode( + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getCode()); + return false; + } else { + throw new RegistrationProcessorCheckedException( + PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getCode(), + PlatformErrorMessages.RPR_SYS_IO_EXCEPTION.getMessage(), e); + } + } + } + } + return true; + } + + private String getOperationsDataFromMetaInfo(String id, String process, String fileName, + Map metaInfoMap) + throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { + String metadata = metaInfoMap.get(JsonConstant.OPERATIONSDATA); + String value = null; + if (StringUtils.isNotEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + + for (int i = 0; i < jsonArray.length(); i++) { + if (!jsonArray.isNull(i)) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); + if (fieldValue.getLabel().equalsIgnoreCase(fileName)) { + value = fieldValue.getValue(); + break; + } + } + } + } + return value; + } + + + private boolean applicantDocumentValidation(String registrationId, String process, + PacketValidationDto packetValidationDto) + throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException { + String validateApplicant=env.getProperty(VALIDATEAPPLICANTDOCUMENT); + if (validateApplicant!=null && validateApplicant.trim().equalsIgnoreCase(VALIDATIONFALSE)) + return true; + else { + String validateApplicantDocument=env.getProperty(VALIDATEAPPLICANTDOCUMENTPROCESS); + if(validateApplicantDocument!=null && validateApplicantDocument.contains(process)) { + boolean result = applicantDocumentValidation.validateDocument(registrationId, process); + if (!result) { + packetValidationDto.setPacketValidaionFailureMessage(StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getMessage()); + packetValidationDto.setPacketValidatonStatusCode(StatusUtil.APPLICANT_DOCUMENT_VALIDATION_FAILED.getCode()); + } + return result; + } + return true; + } + } + + private boolean checkConsentForPacket(String id, String process, ProviderStageName stageName) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + + String val = packetManagerService.getField(id, MappingJsonConstants.CONSENT, process, stageName); + if (null!=val && StringUtils.isNotEmpty(val)) { + if (val.equalsIgnoreCase("N")) + return false; + } + return true; + + } + + + } \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/validator/PacketValidatorImplTest.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/validator/PacketValidatorImplTest.java index a87cb089541..1c08e13d055 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/validator/PacketValidatorImplTest.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/validator/PacketValidatorImplTest.java @@ -1,386 +1,390 @@ -package io.mosip.registration.processor.stages.validator; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.when; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.io.IOUtils; -import org.assertj.core.util.Lists; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.simple.JSONObject; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.powermock.api.mockito.PowerMockito; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.test.context.TestPropertySource; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.cbeffutil.exception.CbeffException; -import io.mosip.kernel.core.exception.BiometricSignatureValidationException; -import io.mosip.kernel.core.idobjectvalidator.spi.IdObjectValidator; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.PacketFiles; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.PacketValidatorException; -import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; -import io.mosip.registration.processor.core.packet.dto.FieldValue; -import io.mosip.registration.processor.core.packet.dto.FieldValueArray; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.packet.dto.PacketMetaInfo; -import io.mosip.registration.processor.core.packet.dto.applicantcategory.ApplicantTypeDocument; -import io.mosip.registration.processor.core.packet.dto.idjson.Document; -import io.mosip.registration.processor.core.packet.dto.packetvalidator.PacketValidationDto; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; -import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException; -import io.mosip.registration.processor.packet.storage.exception.IdentityNotFoundException; -import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import io.mosip.registration.processor.stages.utils.ApplicantDocumentValidation; -import io.mosip.registration.processor.stages.utils.BiometricsXSDValidator; -import io.mosip.registration.processor.stages.validator.impl.BiometricsSignatureValidator; -import io.mosip.registration.processor.stages.validator.impl.PacketValidatorImpl; -import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; -import io.mosip.registration.processor.status.repositary.SyncRegistrationRepository; - -@RunWith(MockitoJUnitRunner.class) -@TestPropertySource(locations = "classpath:application.properties") -public class PacketValidatorImplTest { - - @InjectMocks - private io.mosip.registration.processor.core.spi.packet.validator.PacketValidator PacketValidator = new PacketValidatorImpl(); - - @Mock - IdObjectValidator idObjectValidator; - - @Mock - private Utilities utility; - - @Mock - private BiometricsXSDValidator biometricsXSDValidator; - - @Mock - private BiometricsSignatureValidator biometricsSignatureValidator; - - @Mock - private Environment env; - - @Mock - ApplicantTypeDocument applicantTypeDocument; - - @Mock - private IdRepoService idRepoService; - - @Mock - private PriorityBasedPacketManagerService packetManagerService; - - @Mock - private SyncRegistrationRepository registrationRepositary; - - @Mock - private RegistrationProcessorRestClientService registrationProcessorRestService; - - @Mock - private RegistrationExceptionMapperUtil registrationStatusMapperUtil; - - @Mock - private ApplicantDocumentValidation applicantDocumentValidation; - - @Mock - ObjectMapper mapper; - - @Value("${packetmanager.name.source.default}") - private String source; - - private PacketMetaInfo packetMetaInfo = new PacketMetaInfo(); - - private FileInputStream inputStream; - - private PacketValidationDto packetValidationDto; - - public static final String APPROVED = "APPROVED"; - public static final String REJECTED = "REJECTED"; - private static final String VALIDATEAPPLICANTDOCUMENT = "mosip.regproc.packet.validator.validate-applicant-document"; - private static final String VALIDATEAPPLICANTDOCUMENTPROCESS = "mosip.regproc.packet.validator.validate-applicant-document.processes"; - - private static final String PRIMARY_LANGUAGE = "mosip.primary-language"; - - private static final String SECONDARY_LANGUAGE = "mosip.secondary-language"; - - JSONObject jsonObject = Mockito.mock(JSONObject.class); - Map metamap = new HashMap<>(); - - @Before - public void setup() throws Exception { - packetValidationDto = new PacketValidationDto(); - - Identity identity = new Identity(); - - FieldValue registrationType = new FieldValue(); - registrationType.setLabel("registrationType"); - registrationType.setValue("resupdate"); - - FieldValue preRegistrationId = new FieldValue(); - registrationType.setLabel("preRegistrationId"); - registrationType.setValue("123456789"); - - FieldValue applicantType = new FieldValue(); - applicantType.setLabel("applicantType"); - applicantType.setValue("Child"); - - FieldValue isVerified = new FieldValue(); - isVerified.setLabel("isVerified"); - isVerified.setValue("Verified"); - - identity.setMetaData(Arrays.asList(registrationType, applicantType, isVerified, preRegistrationId)); - - Document documentPob = new Document(); - documentPob.setDocumentCategory("pob"); - documentPob.setDocumentName("ProofOfBirth"); - Document document = new Document(); - document.setDocumentCategory("ProofOfRelation"); - document.setDocumentName("ProofOfRelation"); - List documents = new ArrayList(); - documents.add(documentPob); - documents.add(document); - - List fieldValueArrayList = new ArrayList(); - - FieldValueArray applicantBiometric = new FieldValueArray(); - applicantBiometric.setLabel(PacketFiles.APPLICANTBIOMETRICSEQUENCE.name()); - List applicantBiometricValues = new ArrayList(); - applicantBiometricValues.add(PacketFiles.BOTHTHUMBS.name()); - applicantBiometric.setValue(applicantBiometricValues); - fieldValueArrayList.add(applicantBiometric); - FieldValueArray introducerBiometric = new FieldValueArray(); - introducerBiometric.setLabel(PacketFiles.INTRODUCERBIOMETRICSEQUENCE.name()); - List introducerBiometricValues = new ArrayList(); - introducerBiometricValues.add("introducerLeftThumb"); - introducerBiometric.setValue(introducerBiometricValues); - fieldValueArrayList.add(introducerBiometric); - FieldValueArray applicantDemographic = new FieldValueArray(); - applicantDemographic.setLabel(PacketFiles.APPLICANTDEMOGRAPHICSEQUENCE.name()); - List applicantDemographicValues = new ArrayList(); - applicantDemographicValues.add(PacketFiles.APPLICANTPHOTO.name()); - applicantDemographicValues.add("ProofOfBirth"); - applicantDemographicValues.add("ProofOfAddress"); - applicantDemographic.setValue(applicantDemographicValues); - fieldValueArrayList.add(applicantDemographic); - identity.setHashSequence(fieldValueArrayList); - List sequence2 = new ArrayList<>(); - sequence2.add("audit"); - List fieldValueArrayListSequence = new ArrayList(); - FieldValueArray hashsequence2 = new FieldValueArray(); - hashsequence2.setLabel(PacketFiles.OTHERFILES.name()); - hashsequence2.setValue(sequence2); - fieldValueArrayListSequence.add(hashsequence2); - identity.setHashSequence2(fieldValueArrayListSequence); - packetMetaInfo.setIdentity(identity); - - ClassLoader classLoader = getClass().getClassLoader(); - File file = new File(classLoader.getResource("ID.json").getFile()); - inputStream = new FileInputStream(file); - // Mockito.when(packetReaderService.getFile(anyString(), - // anyString(),anyString())).thenReturn(inputStream); - // when(packetReaderService.getFile(anyString(),anyString(),anyString())).thenReturn(inputStream); - - - byte[] data = "{}".getBytes(); - when(env.getProperty(anyString())).thenReturn("true").thenReturn("NEW"); - - Mockito.when(utility.uinPresentInIdRepo(any())).thenReturn(true); - ValidatePacketResponse validatePacketResponse = new ValidatePacketResponse(); - validatePacketResponse.setValid(true); - when(packetManagerService.validate(anyString(), anyString(), any())).thenReturn(validatePacketResponse); - BiometricRecord biometricRecord = new BiometricRecord(); - BIR bir = new BIR.BIRBuilder().build(); - biometricRecord.setSegments(Lists.newArrayList(bir, bir)); - when(packetManagerService.getField(any(), any(), any(), any())).thenReturn("biometricsField"); - doNothing().when(biometricsXSDValidator).validateXSD(any()); - when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) - .thenReturn(biometricRecord); - when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(true); - - JSONArray jsonArray = new JSONArray(); - org.json.JSONObject jsonObject = new org.json.JSONObject(); - jsonObject.put(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename"); - jsonArray.put(0, jsonObject); - metamap.put(JsonConstant.OPERATIONSDATA, jsonArray.toString()); - Mockito.when(packetManagerService.getMetaInfo(anyString(), any(), any())).thenReturn(metamap); - Mockito.when(mapper.readValue(anyString(), any(Class.class))) - .thenReturn(new FieldValue(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename")); - } - - @Test - public void testValidationSuccess() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), - any()); - assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test(expected = PacketManagerException.class) - public void testPacketManagerException() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - when(packetManagerService.getField(any(), any(), any(), any())).thenThrow(new PacketManagerException("","")); - assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testDocumentValidationFailure() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - - when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(false); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testdocumentValidationFailed() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(false); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testUpdateValidationSuccess() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); - Mockito.when(utility.retrieveIdrepoJson(any())).thenReturn(jsonObject); - Mockito.when(utility.retrieveIdrepoJsonStatus(any())).thenReturn("ACTIVE"); - Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), - any()); - assertTrue(PacketValidator.validate("123456789", "UPDATE", packetValidationDto)); - } - - @Test - public void testUINNotPresentinIDrepo() throws PacketValidatorException, ApisResourceAccessException, IOException, - RegistrationProcessorCheckedException, JsonProcessingException, PacketManagerException { - Mockito.when(utility.uinPresentInIdRepo(any())).thenReturn(false); - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); - Mockito.when(utility.retrieveIdrepoJson(any())).thenReturn(jsonObject); - Mockito.when(utility.retrieveIdrepoJsonStatus(any())).thenReturn("ACTIVE"); - - assertFalse(PacketValidator.validate("123456789", "UPDATE", packetValidationDto)); - } - - @Test(expected = IdRepoAppException.class) - public void testValidationUINNull() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn(null); - - PacketValidator.validate("123456789", "UPDATE", packetValidationDto); - } - - @Test(expected = IdRepoAppException.class) - public void testValidationJsonNull() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); - Mockito.when(utility.retrieveIdrepoJson(any())).thenReturn(null); - - PacketValidator.validate("123456789", "UPDATE", packetValidationDto); - } - - @Test(expected = RegistrationProcessorCheckedException.class) - public void testValidationStatusDeactived() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); - Mockito.when(utility.retrieveIdrepoJson(any())).thenReturn(jsonObject); - Mockito.when(utility.retrieveIdrepoJsonStatus(any())).thenReturn("deactivated"); - - PacketValidator.validate("123456789", "UPDATE", packetValidationDto); - } - - @Test - public void testValidationConfigSuccess() throws PacketValidatorException, ApisResourceAccessException, - JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, - BiometricSignatureValidationException, JSONException { - Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), - any()); - when(env.getProperty(VALIDATEAPPLICANTDOCUMENT)).thenReturn("false"); - assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test(expected = RegistrationProcessorCheckedException.class) - public void testBiometricsXSDValidatonException() throws Exception { - doThrow(new Exception("IO Exception occurred")).when(biometricsXSDValidator).validateXSD(any()); - PacketValidator.validate("123456789", "NEW", packetValidationDto); - } - - @Test - public void testBiometricsXSDValidatonFailure() throws Exception { - doThrow(new CbeffException("CbeffException occurred")).when(biometricsXSDValidator).validateXSD(any()); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testBiometricsSignatureValidatonFailure() throws Exception { - doThrow(new BiometricSignatureValidationException("JWT signature Validation Failed")) - .when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), any()); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testPacketManagerValidationFailure() - throws IOException, IdentityNotFoundException, ApisResourceAccessException, JsonProcessingException, - RegistrationProcessorCheckedException, PacketManagerException { - ValidatePacketResponse validatePacketResponse = new ValidatePacketResponse(); - validatePacketResponse.setValid(false); - when(packetManagerService.validate(anyString(), anyString(), any())).thenReturn(validatePacketResponse); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test(expected = PacketManagerException.class) - public void testPacketManagerValidationException() throws PacketManagerException, ApisResourceAccessException, - JsonProcessingException, IOException, RegistrationProcessorCheckedException { - when(packetManagerService.validate(anyString(), anyString(), any())).thenThrow(PacketManagerException.class); - assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - - @Test - public void testJsonException() throws PacketManagerException, ApisResourceAccessException, JsonProcessingException, - IOException, RegistrationProcessorCheckedException, JSONException { - org.json.JSONObject jsonObject = new org.json.JSONObject(); - jsonObject.put(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename"); - metamap.put(JsonConstant.OPERATIONSDATA, jsonObject.toString()); - Mockito.when(packetManagerService.getMetaInfo(anyString(), any(), any())).thenReturn(metamap); - assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); - } - +package io.mosip.registration.processor.stages.validator; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.when; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.IOUtils; +import org.assertj.core.util.Lists; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.simple.JSONObject; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.powermock.api.mockito.PowerMockito; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.test.context.TestPropertySource; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.cbeffutil.exception.CbeffException; +import io.mosip.kernel.core.exception.BiometricSignatureValidationException; +import io.mosip.kernel.core.idobjectvalidator.spi.IdObjectValidator; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.PacketFiles; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.PacketValidatorException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.packet.dto.FieldValueArray; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.packet.dto.PacketMetaInfo; +import io.mosip.registration.processor.core.packet.dto.applicantcategory.ApplicantTypeDocument; +import io.mosip.registration.processor.core.packet.dto.idjson.Document; +import io.mosip.registration.processor.core.packet.dto.packetvalidator.PacketValidationDto; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; +import io.mosip.registration.processor.packet.storage.exception.IdRepoAppException; +import io.mosip.registration.processor.packet.storage.exception.IdentityNotFoundException; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; +import io.mosip.registration.processor.stages.utils.ApplicantDocumentValidation; +import io.mosip.registration.processor.stages.utils.BiometricsXSDValidator; +import io.mosip.registration.processor.stages.validator.impl.BiometricsSignatureValidator; +import io.mosip.registration.processor.stages.validator.impl.PacketValidatorImpl; +import io.mosip.registration.processor.status.entity.SyncRegistrationEntity; +import io.mosip.registration.processor.status.repositary.SyncRegistrationRepository; + +@RunWith(MockitoJUnitRunner.class) +@TestPropertySource(locations = "classpath:application.properties") +public class PacketValidatorImplTest { + + @InjectMocks + private io.mosip.registration.processor.core.spi.packet.validator.PacketValidator PacketValidator = new PacketValidatorImpl(); + + @Mock + IdObjectValidator idObjectValidator; + + @Mock + private Utilities utilities; + + @Mock + private Utility utility; + + @Mock + private BiometricsXSDValidator biometricsXSDValidator; + + @Mock + private BiometricsSignatureValidator biometricsSignatureValidator; + + @Mock + private Environment env; + + @Mock + ApplicantTypeDocument applicantTypeDocument; + + @Mock + private IdRepoService idRepoService; + + @Mock + private PriorityBasedPacketManagerService packetManagerService; + + @Mock + private SyncRegistrationRepository registrationRepositary; + + @Mock + private RegistrationProcessorRestClientService registrationProcessorRestService; + + @Mock + private RegistrationExceptionMapperUtil registrationStatusMapperUtil; + + @Mock + private ApplicantDocumentValidation applicantDocumentValidation; + + @Mock + ObjectMapper mapper; + + @Value("${packetmanager.name.source.default}") + private String source; + + private PacketMetaInfo packetMetaInfo = new PacketMetaInfo(); + + private FileInputStream inputStream; + + private PacketValidationDto packetValidationDto; + + public static final String APPROVED = "APPROVED"; + public static final String REJECTED = "REJECTED"; + private static final String VALIDATEAPPLICANTDOCUMENT = "mosip.regproc.packet.validator.validate-applicant-document"; + private static final String VALIDATEAPPLICANTDOCUMENTPROCESS = "mosip.regproc.packet.validator.validate-applicant-document.processes"; + + private static final String PRIMARY_LANGUAGE = "mosip.primary-language"; + + private static final String SECONDARY_LANGUAGE = "mosip.secondary-language"; + + JSONObject jsonObject = Mockito.mock(JSONObject.class); + Map metamap = new HashMap<>(); + + @Before + public void setup() throws Exception { + packetValidationDto = new PacketValidationDto(); + + Identity identity = new Identity(); + + FieldValue registrationType = new FieldValue(); + registrationType.setLabel("registrationType"); + registrationType.setValue("resupdate"); + + FieldValue preRegistrationId = new FieldValue(); + registrationType.setLabel("preRegistrationId"); + registrationType.setValue("123456789"); + + FieldValue applicantType = new FieldValue(); + applicantType.setLabel("applicantType"); + applicantType.setValue("Child"); + + FieldValue isVerified = new FieldValue(); + isVerified.setLabel("isVerified"); + isVerified.setValue("Verified"); + + identity.setMetaData(Arrays.asList(registrationType, applicantType, isVerified, preRegistrationId)); + + Document documentPob = new Document(); + documentPob.setDocumentCategory("pob"); + documentPob.setDocumentName("ProofOfBirth"); + Document document = new Document(); + document.setDocumentCategory("ProofOfRelation"); + document.setDocumentName("ProofOfRelation"); + List documents = new ArrayList(); + documents.add(documentPob); + documents.add(document); + + List fieldValueArrayList = new ArrayList(); + + FieldValueArray applicantBiometric = new FieldValueArray(); + applicantBiometric.setLabel(PacketFiles.APPLICANTBIOMETRICSEQUENCE.name()); + List applicantBiometricValues = new ArrayList(); + applicantBiometricValues.add(PacketFiles.BOTHTHUMBS.name()); + applicantBiometric.setValue(applicantBiometricValues); + fieldValueArrayList.add(applicantBiometric); + FieldValueArray introducerBiometric = new FieldValueArray(); + introducerBiometric.setLabel(PacketFiles.INTRODUCERBIOMETRICSEQUENCE.name()); + List introducerBiometricValues = new ArrayList(); + introducerBiometricValues.add("introducerLeftThumb"); + introducerBiometric.setValue(introducerBiometricValues); + fieldValueArrayList.add(introducerBiometric); + FieldValueArray applicantDemographic = new FieldValueArray(); + applicantDemographic.setLabel(PacketFiles.APPLICANTDEMOGRAPHICSEQUENCE.name()); + List applicantDemographicValues = new ArrayList(); + applicantDemographicValues.add(PacketFiles.APPLICANTPHOTO.name()); + applicantDemographicValues.add("ProofOfBirth"); + applicantDemographicValues.add("ProofOfAddress"); + applicantDemographic.setValue(applicantDemographicValues); + fieldValueArrayList.add(applicantDemographic); + identity.setHashSequence(fieldValueArrayList); + List sequence2 = new ArrayList<>(); + sequence2.add("audit"); + List fieldValueArrayListSequence = new ArrayList(); + FieldValueArray hashsequence2 = new FieldValueArray(); + hashsequence2.setLabel(PacketFiles.OTHERFILES.name()); + hashsequence2.setValue(sequence2); + fieldValueArrayListSequence.add(hashsequence2); + identity.setHashSequence2(fieldValueArrayListSequence); + packetMetaInfo.setIdentity(identity); + + ClassLoader classLoader = getClass().getClassLoader(); + File file = new File(classLoader.getResource("ID.json").getFile()); + inputStream = new FileInputStream(file); + // Mockito.when(packetReaderService.getFile(anyString(), + // anyString(),anyString())).thenReturn(inputStream); + // when(packetReaderService.getFile(anyString(),anyString(),anyString())).thenReturn(inputStream); + + + byte[] data = "{}".getBytes(); + when(env.getProperty(anyString())).thenReturn("true").thenReturn("NEW"); + + Mockito.when(utilities.uinPresentInIdRepo(any())).thenReturn(true); + ValidatePacketResponse validatePacketResponse = new ValidatePacketResponse(); + validatePacketResponse.setValid(true); + when(packetManagerService.validate(anyString(), anyString(), any())).thenReturn(validatePacketResponse); + BiometricRecord biometricRecord = new BiometricRecord(); + BIR bir = new BIR.BIRBuilder().build(); + biometricRecord.setSegments(Lists.newArrayList(bir, bir)); + when(packetManagerService.getField(any(), any(), any(), any())).thenReturn("biometricsField"); + doNothing().when(biometricsXSDValidator).validateXSD(any()); + when(packetManagerService.getBiometricsByMappingJsonKey(anyString(), any(), any(), any())) + .thenReturn(biometricRecord); + when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(true); + + JSONArray jsonArray = new JSONArray(); + org.json.JSONObject jsonObject = new org.json.JSONObject(); + jsonObject.put(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename"); + jsonArray.put(0, jsonObject); + metamap.put(JsonConstant.OPERATIONSDATA, jsonArray.toString()); + Mockito.when(packetManagerService.getMetaInfo(anyString(), any(), any())).thenReturn(metamap); + Mockito.when(mapper.readValue(anyString(), any(Class.class))) + .thenReturn(new FieldValue(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename")); + } + + @Test + public void testValidationSuccess() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), + any()); + assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test(expected = PacketManagerException.class) + public void testPacketManagerException() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + when(packetManagerService.getField(any(), any(), any(), any())).thenThrow(new PacketManagerException("","")); + assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testDocumentValidationFailure() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + + when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(false); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testdocumentValidationFailed() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + when(applicantDocumentValidation.validateDocument(any(), any())).thenReturn(false); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testUpdateValidationSuccess() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); + Mockito.when(utilities.retrieveIdrepoJson(any())).thenReturn(jsonObject); + Mockito.when(utilities.retrieveIdrepoJsonStatus(any())).thenReturn("ACTIVE"); + Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), + any()); + assertTrue(PacketValidator.validate("123456789", "UPDATE", packetValidationDto)); + } + + @Test + public void testUINNotPresentinIDrepo() throws PacketValidatorException, ApisResourceAccessException, IOException, + RegistrationProcessorCheckedException, JsonProcessingException, PacketManagerException { + Mockito.when(utilities.uinPresentInIdRepo(any())).thenReturn(false); + Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); + Mockito.when(utilities.retrieveIdrepoJson(any())).thenReturn(jsonObject); + Mockito.when(utilities.retrieveIdrepoJsonStatus(any())).thenReturn("ACTIVE"); + + assertFalse(PacketValidator.validate("123456789", "UPDATE", packetValidationDto)); + } + + @Test(expected = IdRepoAppException.class) + public void testValidationUINNull() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn(null); + + PacketValidator.validate("123456789", "UPDATE", packetValidationDto); + } + + @Test(expected = IdRepoAppException.class) + public void testValidationJsonNull() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); + Mockito.when(utilities.retrieveIdrepoJson(any())).thenReturn(null); + + PacketValidator.validate("123456789", "UPDATE", packetValidationDto); + } + + @Test(expected = RegistrationProcessorCheckedException.class) + public void testValidationStatusDeactived() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.when(utility.getUIn(anyString(), anyString(), any())).thenReturn("12345678l"); + Mockito.when(utilities.retrieveIdrepoJson(any())).thenReturn(jsonObject); + Mockito.when(utilities.retrieveIdrepoJsonStatus(any())).thenReturn("deactivated"); + + PacketValidator.validate("123456789", "UPDATE", packetValidationDto); + } + + @Test + public void testValidationConfigSuccess() throws PacketValidatorException, ApisResourceAccessException, + JsonProcessingException, RegistrationProcessorCheckedException, IOException, PacketManagerException, + BiometricSignatureValidationException, JSONException { + Mockito.doNothing().when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), + any()); + when(env.getProperty(VALIDATEAPPLICANTDOCUMENT)).thenReturn("false"); + assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test(expected = RegistrationProcessorCheckedException.class) + public void testBiometricsXSDValidatonException() throws Exception { + doThrow(new Exception("IO Exception occurred")).when(biometricsXSDValidator).validateXSD(any()); + PacketValidator.validate("123456789", "NEW", packetValidationDto); + } + + @Test + public void testBiometricsXSDValidatonFailure() throws Exception { + doThrow(new CbeffException("CbeffException occurred")).when(biometricsXSDValidator).validateXSD(any()); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testBiometricsSignatureValidatonFailure() throws Exception { + doThrow(new BiometricSignatureValidationException("JWT signature Validation Failed")) + .when(biometricsSignatureValidator).validateSignature(anyString(), anyString(), any(), any()); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testPacketManagerValidationFailure() + throws IOException, IdentityNotFoundException, ApisResourceAccessException, JsonProcessingException, + RegistrationProcessorCheckedException, PacketManagerException { + ValidatePacketResponse validatePacketResponse = new ValidatePacketResponse(); + validatePacketResponse.setValid(false); + when(packetManagerService.validate(anyString(), anyString(), any())).thenReturn(validatePacketResponse); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test(expected = PacketManagerException.class) + public void testPacketManagerValidationException() throws PacketManagerException, ApisResourceAccessException, + JsonProcessingException, IOException, RegistrationProcessorCheckedException { + when(packetManagerService.validate(anyString(), anyString(), any())).thenThrow(PacketManagerException.class); + assertFalse(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + + @Test + public void testJsonException() throws PacketManagerException, ApisResourceAccessException, JsonProcessingException, + IOException, RegistrationProcessorCheckedException, JSONException { + org.json.JSONObject jsonObject = new org.json.JSONObject(); + jsonObject.put(MappingJsonConstants.OFFICERBIOMETRICFILENAME, "officerBiometricFilename"); + metamap.put(JsonConstant.OPERATIONSDATA, jsonObject.toString()); + Mockito.when(packetManagerService.getMetaInfo(anyString(), any(), any())).thenReturn(metamap); + assertTrue(PacketValidator.validate("123456789", "NEW", packetValidationDto)); + } + } \ No newline at end of file diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java index 107761b6d20..efda5590749 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java @@ -1,215 +1,206 @@ -package io.mosip.registration.processor.core.config; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.core.env.Environment; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; - -import brave.Tracer; -import brave.Tracing; -import io.mosip.kernel.core.exception.ExceptionUtils; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.eventbus.MosipEventBusFactory; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.queue.factory.MosipQueueConnectionFactoryImpl; -import io.mosip.registration.processor.core.queue.impl.MosipActiveMqImpl; -import io.mosip.registration.processor.core.spi.queue.MosipQueueConnectionFactory; -import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; -import io.mosip.registration.processor.core.token.validation.TokenValidator; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.mosip.registration.processor.core.util.PropertiesUtil; -import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; -import io.vertx.config.ConfigRetriever; -import io.vertx.config.ConfigRetrieverOptions; -import io.vertx.config.ConfigStoreOptions; -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; - -@PropertySource("classpath:bootstrap.properties") -@Configuration -public class CoreConfigBean { - - private static Logger regProcLogger = RegProcessorLogger.getLogger(CoreConfigBean.class); - - private enum HttpConstants { - HTTP("http://"), HTTPS("https://"); - - private String url; - - HttpConstants(String url) { - this.url = url; - } - - String getUrl() { - return url; - } - - } - - @Bean - public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Environment environment) throws InterruptedException { - try { - Vertx vertx = Vertx.vertx(); - List configStores = new ArrayList<>(); - List configUrls = CoreConfigBean.getUrls(environment); - configUrls.forEach(url -> { - if (url.startsWith(HttpConstants.HTTP.getUrl())) - configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) - .setConfig(new JsonObject().put("url", url).put("timeout", - Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)))); - else - configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) - .setConfig(new JsonObject().put("url", url) - .put("timeout", Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)) - .put("httpClientConfiguration", - new JsonObject().put("trustAll", true).put("ssl", true)))); - }); - ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions(); - configStores.forEach(configRetrieverOptions::addStore); - ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0)); - regProcLogger.info(this.getClass().getName(), "", "", "Getting values from config Server"); - CompletableFuture configLoader = new CompletableFuture(); - retriever.getConfig(json -> { - if (json.succeeded()) { - JsonObject jsonObject = json.result(); - if (jsonObject != null) { - jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(), - sourceValue.getValue().toString())); - } - configLoader.complete(json.result()); - json.mapEmpty(); - retriever.close(); - vertx.close(); - } else { - regProcLogger.info(this.getClass().getName(), "", json.cause().getLocalizedMessage(), - json.cause().getMessage()); - json.otherwiseEmpty(); - retriever.close(); - vertx.close(); - } - }); - configLoader.get(); - } catch (InterruptedException interruptedException) { - regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(interruptedException)); - throw interruptedException; - } catch (Exception exception) { - regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(exception)); - } - return new PropertySourcesPlaceholderConfigurer(); - } - - private static List getAppNames(Environment env) { - String names = env.getProperty(ConfigurationUtil.APPLICATION_NAMES); - if(names==null) { - throw new RuntimeException(ConfigurationUtil.APPLICATION_NAMES+" property not found in env"); - } - return Stream.of(names.split(",")).collect(Collectors.toList()); - } - - private static List getProfiles(Environment env) { - String names = env.getProperty(ConfigurationUtil.ACTIVE_PROFILES); - if(names==null) { - throw new RuntimeException(ConfigurationUtil.ACTIVE_PROFILES+" property not found in env"); - } - return Stream.of(names.split(",")).collect(Collectors.toList()); - } - - public static List getUrls(Environment environment) { - List configUrls = new ArrayList<>(); - List appNames = getAppNames(environment); - String uri = environment.getProperty(ConfigurationUtil.CLOUD_CONFIG_URI); - String label = environment.getProperty(ConfigurationUtil.CLOUD_CONFIG_LABEL); - List profiles = getProfiles(environment); - profiles.forEach(profile -> { - appNames.forEach(app -> { - String url = uri + "/" + app + "/" + profile + "/" + label; - configUrls.add(url); - }); - }); - appNames.forEach(appName -> { - }); - - return configUrls; - } - - @Bean - MosipQueueManager getMosipQueueManager() { - return new MosipActiveMqImpl(); - } - - @Bean - MosipQueueConnectionFactory getMosipQueueConnectionFactory() { - return new MosipQueueConnectionFactoryImpl(); - } - - @Bean - public TokenValidator getTokenValidator() { - return new TokenValidator(); - } - - @Primary - @Bean - public MosipRouter getMosipRouter() { - return new MosipRouter(); - } - - @Bean - public DigitalSignatureUtility getDigitalSignatureUtility() { - return new DigitalSignatureUtility(); - } - - @Bean - public LogDescription getLogDescription() { - return new LogDescription(); - } - - @Bean - public RegistrationExceptionMapperUtil getRegistrationExceptionMapperUtil() { - return new RegistrationExceptionMapperUtil(); - } - - @Bean - public MosipEventBusFactory getMosipEventBusFactory() { - return new MosipEventBusFactory(); - } - - @Bean - public Tracing tracing() { - return Tracing.newBuilder().build(); - } - - @Bean - public Tracer tracer() { - return tracing().tracer(); - } - - @Bean - public ObjectMapper getObjectMapper() { - ObjectMapper objectMapper = new ObjectMapper().registerModule(new AfterburnerModule()) - .registerModule(new JavaTimeModule()); - objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); - return objectMapper; - } - - @Bean - public PropertiesUtil getPropertiesUtil() { - return new PropertiesUtil(); - } -} +package io.mosip.registration.processor.core.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.module.afterburner.AfterburnerModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.env.Environment; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +import brave.Tracer; +import brave.Tracing; +import io.mosip.kernel.core.exception.ExceptionUtils; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.core.abstractverticle.MosipRouter; +import io.mosip.registration.processor.core.eventbus.MosipEventBusFactory; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.queue.factory.MosipQueueConnectionFactoryImpl; +import io.mosip.registration.processor.core.queue.impl.MosipActiveMqImpl; +import io.mosip.registration.processor.core.spi.queue.MosipQueueConnectionFactory; +import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; +import io.mosip.registration.processor.core.token.validation.TokenValidator; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.mosip.registration.processor.core.util.PropertiesUtil; +import io.mosip.registration.processor.core.util.RegistrationExceptionMapperUtil; +import io.vertx.config.ConfigRetriever; +import io.vertx.config.ConfigRetrieverOptions; +import io.vertx.config.ConfigStoreOptions; +import io.vertx.core.Vertx; +import io.vertx.core.json.JsonObject; + +@PropertySource("classpath:bootstrap.properties") +@Configuration +public class CoreConfigBean { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(CoreConfigBean.class); + + private enum HttpConstants { + HTTP("http://"), HTTPS("https://"); + + private String url; + + HttpConstants(String url) { + this.url = url; + } + + String getUrl() { + return url; + } + + } + + @Bean + public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Environment environment) throws InterruptedException { + try { + Vertx vertx = Vertx.vertx(); + List configStores = new ArrayList<>(); + List configUrls = CoreConfigBean.getUrls(environment); + configUrls.forEach(url -> { + if (url.startsWith(HttpConstants.HTTP.getUrl())) + configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) + .setConfig(new JsonObject().put("url", url).put("timeout", + Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)))); + else + configStores.add(new ConfigStoreOptions().setType(ConfigurationUtil.CONFIG_SERVER_TYPE) + .setConfig(new JsonObject().put("url", url) + .put("timeout", Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT)) + .put("httpClientConfiguration", + new JsonObject().put("trustAll", true).put("ssl", true)))); + }); + ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions(); + configStores.forEach(configRetrieverOptions::addStore); + ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0)); + regProcLogger.info(this.getClass().getName(), "", "", "Getting values from config Server"); + CompletableFuture configLoader = new CompletableFuture(); + retriever.getConfig(json -> { + if (json.succeeded()) { + JsonObject jsonObject = json.result(); + if (jsonObject != null) { + jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(), + sourceValue.getValue().toString())); + } + configLoader.complete(json.result()); + json.mapEmpty(); + retriever.close(); + vertx.close(); + } else { + regProcLogger.info(this.getClass().getName(), "", json.cause().getLocalizedMessage(), + json.cause().getMessage()); + json.otherwiseEmpty(); + retriever.close(); + vertx.close(); + } + }); + configLoader.get(); + } catch (InterruptedException interruptedException) { + regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(interruptedException)); + throw interruptedException; + } catch (Exception exception) { + regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(exception)); + } + return new PropertySourcesPlaceholderConfigurer(); + } + + private static List getAppNames(Environment env) { + String names = env.getProperty(ConfigurationUtil.APPLICATION_NAMES); + if(names==null) { + throw new RuntimeException(ConfigurationUtil.APPLICATION_NAMES+" property not found in env"); + } + return Stream.of(names.split(",")).collect(Collectors.toList()); + } + + private static List getProfiles(Environment env) { + String names = env.getProperty(ConfigurationUtil.ACTIVE_PROFILES); + if(names==null) { + throw new RuntimeException(ConfigurationUtil.ACTIVE_PROFILES+" property not found in env"); + } + return Stream.of(names.split(",")).collect(Collectors.toList()); + } + + public static List getUrls(Environment environment) { + List configUrls = new ArrayList<>(); + List appNames = getAppNames(environment); + String uri = environment.getProperty(ConfigurationUtil.CLOUD_CONFIG_URI); + String label = environment.getProperty(ConfigurationUtil.CLOUD_CONFIG_LABEL); + List profiles = getProfiles(environment); + profiles.forEach(profile -> { + appNames.forEach(app -> { + String url = uri + "/" + app + "/" + profile + "/" + label; + configUrls.add(url); + }); + }); + appNames.forEach(appName -> { + }); + + return configUrls; + } + + @Bean + MosipQueueManager getMosipQueueManager() { + return new MosipActiveMqImpl(); + } + + @Bean + MosipQueueConnectionFactory getMosipQueueConnectionFactory() { + return new MosipQueueConnectionFactoryImpl(); + } + + @Bean + public TokenValidator getTokenValidator() { + return new TokenValidator(); + } + + @Primary + @Bean + public MosipRouter getMosipRouter() { + return new MosipRouter(); + } + + @Bean + public DigitalSignatureUtility getDigitalSignatureUtility() { + return new DigitalSignatureUtility(); + } + + @Bean + public LogDescription getLogDescription() { + return new LogDescription(); + } + + @Bean + public RegistrationExceptionMapperUtil getRegistrationExceptionMapperUtil() { + return new RegistrationExceptionMapperUtil(); + } + + @Bean + public MosipEventBusFactory getMosipEventBusFactory() { + return new MosipEventBusFactory(); + } + + @Bean + public Tracing tracing() { + return Tracing.newBuilder().build(); + } + + @Bean + public Tracer tracer() { + return tracing().tracer(); + } + + @Bean + public PropertiesUtil getPropertiesUtil() { + return new PropertiesUtil(); + } +} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java index c9ad2de5e5d..9df212c8818 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/configserverloader/PropertyLoaderConfig.java @@ -41,7 +41,7 @@ String getUrl() { } - /* @Bean + @Bean public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Environment environment) throws InterruptedException { try { Vertx vertx = Vertx.vertx(); @@ -91,5 +91,5 @@ public PropertySourcesPlaceholderConfigurer getPropertiesFromConfigServer(Enviro regProcLogger.error(this.getClass().getName(), "", "", ExceptionUtils.getStackTrace(exception)); } return new PropertySourcesPlaceholderConfigurer(); - }*/ + } } diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java index 81e3590b5b4..5bef45dfed6 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/config/PacketStorageBeanConfig.java @@ -39,6 +39,7 @@ import io.mosip.registration.processor.packet.storage.utils.BioSdkUtil; import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; import io.mosip.registration.processor.packet.storage.utils.Utilities; +import io.mosip.registration.processor.packet.storage.utils.Utility; @Configuration @PropertySource("classpath:bootstrap.properties") @@ -122,4 +123,14 @@ public PacketManagerHelper packetManagerHelper() { public IdSchemaUtil getIdSchemaUtil() { return new IdSchemaUtil(); } + + @Bean + public Utility getUtility() { + return new Utility(); + } + + @Bean + public PriorityBasedPacketManagerService getPriorityBasedPacketManagerService() { + return new PriorityBasedPacketManagerService(); + } } diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtil.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtil.java index 898f48a3c36..5cbc48437c0 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtil.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/ABISHandlerUtil.java @@ -1,242 +1,245 @@ -package io.mosip.registration.processor.packet.storage.utils; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.code.AbisStatusCode; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.constant.AbisConstant; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.Identity; -import io.mosip.registration.processor.core.packet.dto.abis.AbisRequestDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisResponseDetDto; -import io.mosip.registration.processor.core.packet.dto.abis.AbisResponseDto; -import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; -import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; -import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; -import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.SyncTypeDto; - -/** - * The Class ABISHandlerUtil. - * - * @author Nagalakshmi - * @author Horteppa - */ -@Component -public class ABISHandlerUtil { - - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(ABISHandlerUtil.class); - - /** The utilities. */ - @Autowired - Utilities utilities; - - /** The packet info manager. */ - @Autowired - private PacketInfoManager packetInfoManager; - - /** The packet info dao. */ - @Autowired - private PacketInfoDao packetInfoDao; - - @Autowired - private IdRepoService idRepoService; - - /** - * Gets the unique reg ids. - * - * @param registrationId the registration id - * @param registrationType the registration type - * @return the unique reg ids - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - */ - public Set getUniqueRegIds(String registrationId, String registrationType, - int iteration, String workflowInstanceId, ProviderStageName stageName) throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - registrationId, "ABISHandlerUtil::getUniqueRegIds()::entry"); - - String latestTransactionId = utilities.getLatestTransactionId(registrationId, registrationType, iteration, workflowInstanceId); - - List regBioRefIds = packetInfoDao.getAbisRefIdByWorkflowInstanceId(workflowInstanceId); - - List machedRefIds = new ArrayList<>(); - Set uniqueRIDs = new HashSet<>(); - List abisResponseDetDtoList = new ArrayList<>(); - - if (!regBioRefIds.isEmpty()) { - List abisResponseDtoList = packetInfoManager.getAbisResponseRecords(regBioRefIds.get(0), - latestTransactionId, AbisConstant.IDENTIFY); - for (AbisResponseDto abisResponseDto : abisResponseDtoList) { - abisResponseDetDtoList.addAll(packetInfoManager.getAbisResponseDetails(abisResponseDto.getId())); - } - if (!abisResponseDetDtoList.isEmpty()) { - for (AbisResponseDetDto abisResponseDetDto : abisResponseDetDtoList) { - machedRefIds.add(abisResponseDetDto.getMatchedBioRefId()); - } - if (!CollectionUtils.isEmpty(machedRefIds)) { - List matchedRegIds = packetInfoDao.getAbisRefRegIdsByMatchedRefIds(machedRefIds); - if (!CollectionUtils.isEmpty(matchedRegIds)) { - List matchedRegistrationStatusEntities = packetInfoDao - .getWithoutStatusCode(matchedRegIds, - RegistrationStatusCode.REJECTED.toString()); - List processingRegistrationStatusEntities = matchedRegistrationStatusEntities - .stream() - .filter(e -> RegistrationStatusCode.PROCESSING.toString().equals(e.getStatusCode())) - .collect(Collectors.toList()); - List processingRegIds = processingRegistrationStatusEntities.stream() - .map(RegistrationStatusEntity::getRegId) - .collect(Collectors.toList()); - List matchedProcessedRegIds = matchedRegistrationStatusEntities.stream() - .map(RegistrationStatusEntity::getRegId).collect(Collectors.toList()); - uniqueRIDs.addAll(processingRegIds); - Set processedRegIds = getUniqueRegIds(matchedProcessedRegIds, registrationId, - registrationType, - stageName); - for(String rid:processedRegIds) { - if(!uniqueRIDs.contains(rid)) - uniqueRIDs.add(rid); - } - } - } - } - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), - registrationId, "ABISHandlerUtil::getUniqueRegIds()::exit"); - - return uniqueRIDs; - - } - - /** - * Gets the packet status. - * - * @param registrationStatusDto - * the registration status dto - * @return the packet status - */ - public String getPacketStatus(InternalRegistrationStatusDto registrationStatusDto) { - // get all identify requests for latest transaction id - List identifyRequests = getAllIdentifyRequest(registrationStatusDto.getRegistrationId(), - registrationStatusDto.getRegistrationType(), registrationStatusDto.getIteration(), registrationStatusDto.getWorkflowInstanceId()); - - // if there are no identify requests present - if (CollectionUtils.isEmpty(identifyRequests)) - return AbisConstant.PRE_ABIS_IDENTIFICATION; - // if there are unprocessed pending identify request for same transaction id then consider it as duplicate - else if (isIdentifyRequestsPendingForLatestTransactionId(identifyRequests)) - return AbisConstant.DUPLICATE_FOR_SAME_TRANSACTION_ID; - // else if all the identify requests processed for latest transaction id - else - return AbisConstant.POST_ABIS_IDENTIFICATION; - } - - /** - * This method returns all identify requests - * - * @param registrationId - * the registration id - * @return the matched reg ids - */ - private List getAllIdentifyRequest(String registrationId, String process, int iteration, String workflowInstanceId) { - String latestTransactionId = utilities.getLatestTransactionId(registrationId, process, iteration, workflowInstanceId); - - List regBioRefIds = packetInfoDao.getAbisRefIdByWorkflowInstanceId(workflowInstanceId); - - if (!regBioRefIds.isEmpty()) { - List abisRequestDtoList = packetInfoManager.getInsertOrIdentifyRequest(regBioRefIds.get(0), latestTransactionId); - if (!CollectionUtils.isEmpty(abisRequestDtoList)) { - return abisRequestDtoList.stream().filter(reqDto -> - reqDto.getRequestType().equalsIgnoreCase(AbisStatusCode.IDENTIFY.toString())).collect(Collectors.toList()); - } - } - - return null; - } - - /** - * This method returns all unprocessed identify requests - * - * @param identifyRequests - * @return - */ - private boolean isIdentifyRequestsPendingForLatestTransactionId(List identifyRequests) { - // check if any of the identify request is not processed for same transaction id - return identifyRequests.stream().filter( - identifyReq -> !identifyReq.getStatusCode().equalsIgnoreCase(AbisStatusCode.PROCESSED.toString())) - .findAny().isPresent(); - } - - /** - * Gets the unique reg ids. - * - * @param matchedRegistrationIds the matched registration ids - * @param registrationId the registration id - * @param registrationType the registration type - * @return the unique reg ids - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws io.mosip.kernel.core.exception.IOException - */ - public Set getUniqueRegIds(List matchedRegistrationIds, String registrationId, - String registrationType, ProviderStageName stageName) throws ApisResourceAccessException, IOException, - JsonProcessingException, PacketManagerException { - - Map filteredRegMap = new LinkedHashMap<>(); - Set filteredRIds = new HashSet<>(); - - for (String machedRegId : matchedRegistrationIds) { - - String matchedUin = idRepoService.getUinByRid(machedRegId, - utilities.getGetRegProcessorDemographicIdentity()); - - if (registrationType.equalsIgnoreCase(SyncTypeDto.UPDATE.toString())) { - String packetUin = utilities.getUIn(registrationId, registrationType, stageName); - if (matchedUin != null && !packetUin.equals(matchedUin)) { - filteredRegMap.put(matchedUin, machedRegId); - } - } - if (registrationType.equalsIgnoreCase(SyncTypeDto.NEW.toString()) && matchedUin != null) { - filteredRegMap.put(matchedUin, machedRegId); - } - - if (registrationType.equalsIgnoreCase(SyncTypeDto.LOST.toString()) && matchedUin != null) { - filteredRegMap.put(matchedUin, machedRegId); - } - - } - if (!filteredRegMap.isEmpty()) { - filteredRIds = new HashSet(filteredRegMap.values()); - } - - return filteredRIds; - - } - -} +package io.mosip.registration.processor.packet.storage.utils; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.code.AbisStatusCode; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.entity.RegistrationStatusEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; +import io.mosip.registration.processor.core.constant.AbisConstant; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.Identity; +import io.mosip.registration.processor.core.packet.dto.abis.AbisRequestDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisResponseDetDto; +import io.mosip.registration.processor.core.packet.dto.abis.AbisResponseDto; +import io.mosip.registration.processor.core.spi.packetmanager.PacketInfoManager; +import io.mosip.registration.processor.packet.manager.idreposervice.IdRepoService; +import io.mosip.registration.processor.packet.storage.dao.PacketInfoDao; +import io.mosip.registration.processor.packet.storage.dto.ApplicantInfoDto; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.SyncTypeDto; + +/** + * The Class ABISHandlerUtil. + * + * @author Nagalakshmi + * @author Horteppa + */ +@Component +public class ABISHandlerUtil { + + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(ABISHandlerUtil.class); + + /** The utilities. */ + @Autowired + Utilities utilities; + + @Autowired + Utility utility; + + /** The packet info manager. */ + @Autowired + private PacketInfoManager packetInfoManager; + + /** The packet info dao. */ + @Autowired + private PacketInfoDao packetInfoDao; + + @Autowired + private IdRepoService idRepoService; + + /** + * Gets the unique reg ids. + * + * @param registrationId the registration id + * @param registrationType the registration type + * @return the unique reg ids + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + */ + public Set getUniqueRegIds(String registrationId, String registrationType, + int iteration, String workflowInstanceId, ProviderStageName stageName) throws ApisResourceAccessException, JsonProcessingException, PacketManagerException, IOException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + registrationId, "ABISHandlerUtil::getUniqueRegIds()::entry"); + + String latestTransactionId = utilities.getLatestTransactionId(registrationId, registrationType, iteration, workflowInstanceId); + + List regBioRefIds = packetInfoDao.getAbisRefIdByWorkflowInstanceId(workflowInstanceId); + + List machedRefIds = new ArrayList<>(); + Set uniqueRIDs = new HashSet<>(); + List abisResponseDetDtoList = new ArrayList<>(); + + if (!regBioRefIds.isEmpty()) { + List abisResponseDtoList = packetInfoManager.getAbisResponseRecords(regBioRefIds.get(0), + latestTransactionId, AbisConstant.IDENTIFY); + for (AbisResponseDto abisResponseDto : abisResponseDtoList) { + abisResponseDetDtoList.addAll(packetInfoManager.getAbisResponseDetails(abisResponseDto.getId())); + } + if (!abisResponseDetDtoList.isEmpty()) { + for (AbisResponseDetDto abisResponseDetDto : abisResponseDetDtoList) { + machedRefIds.add(abisResponseDetDto.getMatchedBioRefId()); + } + if (!CollectionUtils.isEmpty(machedRefIds)) { + List matchedRegIds = packetInfoDao.getAbisRefRegIdsByMatchedRefIds(machedRefIds); + if (!CollectionUtils.isEmpty(matchedRegIds)) { + List matchedRegistrationStatusEntities = packetInfoDao + .getWithoutStatusCode(matchedRegIds, + RegistrationStatusCode.REJECTED.toString()); + List processingRegistrationStatusEntities = matchedRegistrationStatusEntities + .stream() + .filter(e -> RegistrationStatusCode.PROCESSING.toString().equals(e.getStatusCode())) + .collect(Collectors.toList()); + List processingRegIds = processingRegistrationStatusEntities.stream() + .map(RegistrationStatusEntity::getRegId) + .collect(Collectors.toList()); + List matchedProcessedRegIds = matchedRegistrationStatusEntities.stream() + .map(RegistrationStatusEntity::getRegId).collect(Collectors.toList()); + uniqueRIDs.addAll(processingRegIds); + Set processedRegIds = getUniqueRegIds(matchedProcessedRegIds, registrationId, + registrationType, + stageName); + for(String rid:processedRegIds) { + if(!uniqueRIDs.contains(rid)) + uniqueRIDs.add(rid); + } + } + } + } + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), + registrationId, "ABISHandlerUtil::getUniqueRegIds()::exit"); + + return uniqueRIDs; + + } + + /** + * Gets the packet status. + * + * @param registrationStatusDto + * the registration status dto + * @return the packet status + */ + public String getPacketStatus(InternalRegistrationStatusDto registrationStatusDto) { + // get all identify requests for latest transaction id + List identifyRequests = getAllIdentifyRequest(registrationStatusDto.getRegistrationId(), + registrationStatusDto.getRegistrationType(), registrationStatusDto.getIteration(), registrationStatusDto.getWorkflowInstanceId()); + + // if there are no identify requests present + if (CollectionUtils.isEmpty(identifyRequests)) + return AbisConstant.PRE_ABIS_IDENTIFICATION; + // if there are unprocessed pending identify request for same transaction id then consider it as duplicate + else if (isIdentifyRequestsPendingForLatestTransactionId(identifyRequests)) + return AbisConstant.DUPLICATE_FOR_SAME_TRANSACTION_ID; + // else if all the identify requests processed for latest transaction id + else + return AbisConstant.POST_ABIS_IDENTIFICATION; + } + + /** + * This method returns all identify requests + * + * @param registrationId + * the registration id + * @return the matched reg ids + */ + private List getAllIdentifyRequest(String registrationId, String process, int iteration, String workflowInstanceId) { + String latestTransactionId = utilities.getLatestTransactionId(registrationId, process, iteration, workflowInstanceId); + + List regBioRefIds = packetInfoDao.getAbisRefIdByWorkflowInstanceId(workflowInstanceId); + + if (!regBioRefIds.isEmpty()) { + List abisRequestDtoList = packetInfoManager.getInsertOrIdentifyRequest(regBioRefIds.get(0), latestTransactionId); + if (!CollectionUtils.isEmpty(abisRequestDtoList)) { + return abisRequestDtoList.stream().filter(reqDto -> + reqDto.getRequestType().equalsIgnoreCase(AbisStatusCode.IDENTIFY.toString())).collect(Collectors.toList()); + } + } + + return null; + } + + /** + * This method returns all unprocessed identify requests + * + * @param identifyRequests + * @return + */ + private boolean isIdentifyRequestsPendingForLatestTransactionId(List identifyRequests) { + // check if any of the identify request is not processed for same transaction id + return identifyRequests.stream().filter( + identifyReq -> !identifyReq.getStatusCode().equalsIgnoreCase(AbisStatusCode.PROCESSED.toString())) + .findAny().isPresent(); + } + + /** + * Gets the unique reg ids. + * + * @param matchedRegistrationIds the matched registration ids + * @param registrationId the registration id + * @param registrationType the registration type + * @return the unique reg ids + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws io.mosip.kernel.core.exception.IOException + */ + public Set getUniqueRegIds(List matchedRegistrationIds, String registrationId, + String registrationType, ProviderStageName stageName) throws ApisResourceAccessException, IOException, + JsonProcessingException, PacketManagerException { + + Map filteredRegMap = new LinkedHashMap<>(); + Set filteredRIds = new HashSet<>(); + + for (String machedRegId : matchedRegistrationIds) { + + String matchedUin = idRepoService.getUinByRid(machedRegId, + utilities.getGetRegProcessorDemographicIdentity()); + + if (registrationType.equalsIgnoreCase(SyncTypeDto.UPDATE.toString())) { + String packetUin = utility.getUIn(registrationId, registrationType, stageName); + if (matchedUin != null && !packetUin.equals(matchedUin)) { + filteredRegMap.put(matchedUin, machedRegId); + } + } + if (registrationType.equalsIgnoreCase(SyncTypeDto.NEW.toString()) && matchedUin != null) { + filteredRegMap.put(matchedUin, machedRegId); + } + + if (registrationType.equalsIgnoreCase(SyncTypeDto.LOST.toString()) && matchedUin != null) { + filteredRegMap.put(matchedUin, machedRegId); + } + + } + if (!filteredRegMap.isEmpty()) { + filteredRIds = new HashSet(filteredRegMap.values()); + } + + return filteredRIds; + + } + +} diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java index 3fbce8cc8e6..e496746a82e 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/PacketManagerService.java @@ -48,7 +48,7 @@ import io.mosip.registration.processor.packet.storage.dto.ValidatePacketResponse; @Component -public class PacketManagerService extends PriorityBasedPacketManagerService { +public class PacketManagerService { private static Logger regProcLogger = RegProcessorLogger.getLogger(PacketManagerService.class); private static final String ID = "mosip.commmons.packetmanager"; @@ -61,15 +61,13 @@ public class PacketManagerService extends PriorityBasedPacketManagerService { @Autowired private ObjectMapper objectMapper; - @Autowired - private Utilities utilities; - @PostConstruct private void setObjectMapper() { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); } - protected String getField(String id, String field, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public String getField(String id, String field, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { FieldDto fieldDto = new FieldDto(id, field, source, process, false); RequestWrapper request = new RequestWrapper<>(); @@ -96,7 +94,8 @@ protected String getField(String id, String field, String source, String process return responseField; } - protected Map getFields(String id, List fields, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public Map getFields(String id, List fields, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { FieldDtos fieldDto = new FieldDtos(id, fields, source, process, false); RequestWrapper request = new RequestWrapper<>(); @@ -120,11 +119,13 @@ protected Map getFields(String id, List fields, String s return fieldResponseDto.getFields(); } - protected Document getDocument(String id, String documentName, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public Document getDocument(String id, String documentName, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { return getDocument(id, documentName, null, process); } - protected Document getDocument(String id, String documentName, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public Document getDocument(String id, String documentName, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { DocumentDto fieldDto = new DocumentDto(id, documentName, source, process); RequestWrapper request = new RequestWrapper<>(); @@ -148,7 +149,8 @@ protected Document getDocument(String id, String documentName, String source, St return document; } - protected ValidatePacketResponse validate(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public ValidatePacketResponse validate(String id, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { InfoDto fieldDto = new InfoDto(id, source, process, false); RequestWrapper request = new RequestWrapper<>(); @@ -171,7 +173,8 @@ protected ValidatePacketResponse validate(String id, String source, String proce return validatePacketResponse; } - protected List getAudits(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public List getAudits(String id, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { InfoDto fieldDto = new InfoDto(id, source, process, false); List response = new ArrayList<>(); @@ -200,7 +203,9 @@ protected List getAudits(String id, String source, String proc return response; } - protected BiometricRecord getBiometrics(String id, String person, List modalities, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public BiometricRecord getBiometrics(String id, String person, List modalities, String source, + String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { BiometricRequestDto fieldDto = new BiometricRequestDto(id, person, modalities, source, process, false); @@ -227,7 +232,8 @@ protected BiometricRecord getBiometrics(String id, String person, List m } - protected Map getMetaInfo(String id, String source, String process) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public Map getMetaInfo(String id, String source, String process) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { InfoDto fieldDto = new InfoDto(id, source, process, false); RequestWrapper request = new RequestWrapper<>(); @@ -252,7 +258,8 @@ protected Map getMetaInfo(String id, String source, String proce return fieldResponseDto.getFields(); } - protected InfoResponseDto info(String id) throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { + public InfoResponseDto info(String id) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException { InfoRequestDto infoRequestDto = new InfoRequestDto(id); RequestWrapper request = new RequestWrapper<>(); diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java index b4418f83811..4f7f74b8871 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utilities.java @@ -137,10 +137,6 @@ public class Utilities { @Value("${registration.processor.applicant.type}") private String getRegProcessorApplicantType; - /** The dob format. */ - @Value("${registration.processor.applicant.dob.format}") - private String dobFormat; - /** The elapse time. */ @Value("${registration.processor.reprocess.elapse.time}") private long elapseTime; @@ -160,20 +156,10 @@ public class Utilities { @Value("#{'${registration.processor.queue.trusted.packages}'.split(',')}") private List trustedPackages; - @Autowired - private PacketInfoDao packetInfoDao; - - @Autowired - private PriorityBasedPacketManagerService packetManagerService; - /** The registration status dao. */ @Autowired private RegistrationStatusDao registrationStatusDao; - /** The packet info manager. */ - @Autowired - private PacketInfoManager packetInfoManager; - /** The Constant INBOUNDQUEUENAME. */ private static final String INBOUNDQUEUENAME = "inboundQueueName"; @@ -230,58 +216,7 @@ public static String getJson(String configServerFileStorageURL, String uri) { return restTemplate.getForObject(configServerFileStorageURL + uri, String.class); } - /** - * get applicant age by registration id. Checks the id json if dob or age - * present, if yes returns age if both dob or age are not present then retrieves - * age from id repo - * - * @param id the registration id - * @return the applicant age - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws ApisResourceAccessException the packet decryption failure - * exception - * @throws RegistrationProcessorCheckedException - */ - public int getApplicantAge(String id, String process, ProviderStageName stageName) - throws IOException, ApisResourceAccessException, JsonProcessingException, PacketManagerException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, - "Utilities::getApplicantAge()::entry"); - - String applicantDob = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.DOB, process, - stageName); - String applicantAge = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.AGE, process, - stageName); - if (applicantDob != null) { - return calculateAge(applicantDob); - } else if (applicantAge != null) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, - "Utilities::getApplicantAge()::exit when applicantAge is not null"); - return Integer.valueOf(applicantAge); - } else { - String uin = getUIn(id, process, stageName); - JSONObject identityJSONOject = retrieveIdrepoJson(uin); - JSONObject regProcessorIdentityJson = getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); - String ageKey = JsonUtil - .getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.AGE), VALUE); - String dobKey = JsonUtil - .getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.DOB), VALUE); - String idRepoApplicantDob = JsonUtil.getJSONValue(identityJSONOject, dobKey); - if (idRepoApplicantDob != null) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, - "Utilities::getApplicantAge()::exit when ID REPO applicantDob is not null"); - return calculateAge(idRepoApplicantDob); - } - Integer idRepoApplicantAge = JsonUtil.getJSONValue(identityJSONOject, ageKey); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, - "Utilities::getApplicantAge()::exit when ID REPO applicantAge is not null"); - return idRepoApplicantAge != null ? idRepoApplicantAge : -1; - - } - } public String getDefaultSource(String process, ConfigEnum config) { Map configMap = null; @@ -574,32 +509,6 @@ public String getMappingJsonValue(String key, String packetSegment) throws IOExc } - /** - * Get UIN from identity json (used only for update/res update/activate/de - * activate packets). - * - * @param id the registration id - * @return the u in - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws IOException Signals that an I/O exception - * has occurred. - * @throws ApisResourceAccessException the apis resource access - * exception - * @throws RegistrationProcessorCheckedException - */ - public String getUIn(String id, String process, ProviderStageName stageName) - throws IOException, ApisResourceAccessException, PacketManagerException, JsonProcessingException { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, - "Utilities::getUIn()::entry"); - String UIN = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.UIN, process, stageName); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, - "Utilities::getUIn()::exit"); - - return UIN; - - } - /** * Gets the elapse status. * @@ -703,35 +612,7 @@ public JSONObject idrepoRetrieveIdentityByRid(String regId) throws ApisResourceA return null; } - /** - * Calculate age. - * - * @param applicantDob the applicant dob - * @return the int - */ - private int calculateAge(String applicantDob) { - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "Utilities::calculateAge():: entry"); - - DateFormat sdf = new SimpleDateFormat(dobFormat); - Date birthDate = null; - try { - birthDate = sdf.parse(applicantDob); - - } catch (ParseException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", "Utilities::calculateAge():: error with error message " - + PlatformErrorMessages.RPR_SYS_PARSING_DATE_EXCEPTION.getMessage()); - throw new ParsingException(PlatformErrorMessages.RPR_SYS_PARSING_DATE_EXCEPTION.getCode(), e); - } - LocalDate ld = new java.sql.Date(birthDate.getTime()).toLocalDate(); - Period p = Period.between(ld, LocalDate.now()); - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", - "Utilities::calculateAge():: exit"); - return p.getYears(); - - } /** * Validate abis queue json and return value. diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java new file mode 100644 index 00000000000..38af74a2743 --- /dev/null +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java @@ -0,0 +1,157 @@ +package io.mosip.registration.processor.packet.storage.utils; + +import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.Period; +import java.util.Date; + +import org.json.simple.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.RegistrationProcessorCheckedException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.packet.storage.exception.ParsingException; +import lombok.Data; + +@Component +@Data +public class Utility { + + private static Logger regProcLogger = RegProcessorLogger.getLogger(Utility.class); + + @Autowired + private PriorityBasedPacketManagerService packetManagerService; + + @Autowired + private Utilities utilities; + + /** The dob format. */ + @Value("${registration.processor.applicant.dob.format}") + private String dobFormat; + + private static final String VALUE = "value"; + + /** + * get applicant age by registration id. Checks the id json if dob or age + * present, if yes returns age if both dob or age are not present then retrieves + * age from id repo + * + * @param id the registration id + * @return the applicant age + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws ApisResourceAccessException the packet decryption failure + * exception + * @throws RegistrationProcessorCheckedException + */ + public int getApplicantAge(String id, String process, ProviderStageName stageName) + throws IOException, ApisResourceAccessException, JsonProcessingException, PacketManagerException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, + "Utility::getApplicantAge()::entry"); + + String applicantDob = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.DOB, process, + stageName); + String applicantAge = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.AGE, process, + stageName); + if (applicantDob != null) { + return calculateAge(applicantDob); + } else if (applicantAge != null) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, + "Utility::getApplicantAge()::exit when applicantAge is not null"); + return Integer.valueOf(applicantAge); + } else { + String uin = getUIn(id, process, stageName); + JSONObject identityJSONOject = utilities.retrieveIdrepoJson(uin); + JSONObject regProcessorIdentityJson = utilities + .getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + String ageKey = JsonUtil + .getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.AGE), VALUE); + String dobKey = JsonUtil + .getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.DOB), VALUE); + String idRepoApplicantDob = JsonUtil.getJSONValue(identityJSONOject, dobKey); + if (idRepoApplicantDob != null) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, + "Utility::getApplicantAge()::exit when ID REPO applicantDob is not null"); + return calculateAge(idRepoApplicantDob); + } + Integer idRepoApplicantAge = JsonUtil.getJSONValue(identityJSONOject, ageKey); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), id, + "Utility::getApplicantAge()::exit when ID REPO applicantAge is not null"); + return idRepoApplicantAge != null ? idRepoApplicantAge : -1; + + } + + } + + /** + * Calculate age. + * + * @param applicantDob the applicant dob + * @return the int + */ + private int calculateAge(String applicantDob) { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "Utility::calculateAge():: entry"); + + DateFormat sdf = new SimpleDateFormat(dobFormat); + Date birthDate = null; + try { + birthDate = sdf.parse(applicantDob); + + } catch (ParseException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", "Utility::calculateAge():: error with error message " + + PlatformErrorMessages.RPR_SYS_PARSING_DATE_EXCEPTION.getMessage()); + throw new ParsingException(PlatformErrorMessages.RPR_SYS_PARSING_DATE_EXCEPTION.getCode(), e); + } + LocalDate ld = new java.sql.Date(birthDate.getTime()).toLocalDate(); + Period p = Period.between(ld, LocalDate.now()); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), "", + "Utility::calculateAge():: exit"); + + return p.getYears(); + + } + + /** + * Get UIN from identity json (used only for update/res update/activate/de + * activate packets). + * + * @param id the registration id + * @return the u in + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws IOException Signals that an I/O exception + * has occurred. + * @throws ApisResourceAccessException the apis resource access + * exception + * @throws RegistrationProcessorCheckedException + */ + public String getUIn(String id, String process, ProviderStageName stageName) + throws IOException, ApisResourceAccessException, PacketManagerException, JsonProcessingException { + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, + "Utility::getUIn()::entry"); + String UIN = packetManagerService.getFieldByMappingJsonKey(id, MappingJsonConstants.UIN, process, stageName); + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), id, + "Utility::getUIn()::exit"); + + return UIN; + + } +} diff --git a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java index 9102ddcb981..96703c73784 100644 --- a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java +++ b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java @@ -1,17 +1,25 @@ -package io.mosip.registration.processor; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan( basePackages = { "io.mosip.registration.processor.status.*", - "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.util", - "io.mosip.registration.processor.core.config","${mosip.auth.adapter.impl.basepackage}"} ) -public class RegistrationProcessorLandingZoneApplication { - - public static void main(String[] args) { - SpringApplication.run(RegistrationProcessorLandingZoneApplication.class, args); - } - -} +package io.mosip.registration.processor; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.ComponentScan.Filter; + +import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; +import io.mosip.registration.processor.rest.client.config.RestConfigBean; + +@SpringBootApplication +@ComponentScan( basePackages = { "io.mosip.registration.processor.status.*", + "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.util", + "io.mosip.registration.processor.core.config", + "${mosip.auth.adapter.impl.basepackage}" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { + RestConfigBean.class, PropertyLoaderConfig.class })) +public class RegistrationProcessorLandingZoneApplication { + + public static void main(String[] args) { + SpringApplication.run(RegistrationProcessorLandingZoneApplication.class, args); + } + +} diff --git a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/util/LandingZoneConfig.java b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/util/LandingZoneConfig.java index 256bba93b8a..a88ba413376 100644 --- a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/util/LandingZoneConfig.java +++ b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/util/LandingZoneConfig.java @@ -1,54 +1,48 @@ -package io.mosip.registration.processor.util; - -import java.io.InputStream; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.context.annotation.Primary; -import org.springframework.scheduling.annotation.EnableScheduling; - -import io.mosip.commons.khazana.impl.S3Adapter; -import io.mosip.commons.khazana.impl.SwiftAdapter; -import io.mosip.commons.khazana.spi.ObjectStoreAdapter; -import io.mosip.registration.processor.core.spi.filesystem.manager.FileManager; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.packet.manager.dto.DirectoryPathDto; -import io.mosip.registration.processor.packet.manager.service.impl.FileManagerImpl; -import io.mosip.registration.processor.rest.client.service.impl.RegistrationProcessorRestClientServiceImpl; - -@Configuration -@EnableAspectJAutoProxy -@EnableScheduling -public class LandingZoneConfig { - private static final String s3_Adapter = "S3Adapter"; - private static final String swift_Adapter = "SwiftAdapter"; - - @Value("${registration.processor.objectstore.adapter.name}") - private String adapter; - - @Bean - @Primary - public ObjectStoreAdapter objectStoreAdapter() { - if (adapter.equalsIgnoreCase(s3_Adapter)) - return new S3Adapter(); - else if (adapter.equalsIgnoreCase(swift_Adapter)) - return new SwiftAdapter(); - else - throw new UnsupportedOperationException("No adapter implementation found for configuration: registration.processor.objectstore.adapter.name"); - } - - @Bean - @Primary - public FileManager filemanager() { - return new FileManagerImpl(); - } - - @Bean - @Primary - public RegistrationProcessorRestClientService getRegistrationProcessorRestClientService() { - return new RegistrationProcessorRestClientServiceImpl(); - } - -} +package io.mosip.registration.processor.util; + +import java.io.InputStream; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.context.annotation.Primary; +import org.springframework.scheduling.annotation.EnableScheduling; + +import io.mosip.commons.khazana.impl.S3Adapter; +import io.mosip.commons.khazana.impl.SwiftAdapter; +import io.mosip.commons.khazana.spi.ObjectStoreAdapter; +import io.mosip.registration.processor.core.spi.filesystem.manager.FileManager; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.packet.manager.dto.DirectoryPathDto; +import io.mosip.registration.processor.packet.manager.service.impl.FileManagerImpl; +import io.mosip.registration.processor.rest.client.service.impl.RegistrationProcessorRestClientServiceImpl; + +@Configuration +@EnableAspectJAutoProxy +@EnableScheduling +public class LandingZoneConfig { + private static final String s3_Adapter = "S3Adapter"; + private static final String swift_Adapter = "SwiftAdapter"; + + @Value("${registration.processor.objectstore.adapter.name}") + private String adapter; + + @Bean + @Primary + public ObjectStoreAdapter objectStoreAdapter() { + if (adapter.equalsIgnoreCase(s3_Adapter)) + return new S3Adapter(); + else if (adapter.equalsIgnoreCase(swift_Adapter)) + return new SwiftAdapter(); + else + throw new UnsupportedOperationException("No adapter implementation found for configuration: registration.processor.objectstore.adapter.name"); + } + + @Bean + @Primary + public FileManager filemanager() { + return new FileManagerImpl(); + } + +} diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java index 1a49bd6d4cf..1072a286135 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/entity/BaseRegistrationEntity.java @@ -17,6 +17,7 @@ // repository(RegistrationRepository) + @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class BaseRegistrationEntity { diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java index ca7d398e1f1..46bc948d061 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java @@ -4,16 +4,13 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.ComponentScan.Filter; import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; -import io.mosip.registration.processor.core.kernel.beans.KernelConfig; -import io.mosip.registration.processor.packet.storage.config.PacketStorageBeanConfig; -import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionApi; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowActionJob; import io.mosip.registration.processor.workflowmanager.verticle.WorkflowInternalActionVerticle; @@ -28,7 +25,7 @@ "io.mosip.registration.processor.core.kernel.beans", "io.mosip.registration.processor.packet.storage.config", "io.mosip.kernel.websub.api.config.publisher" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { - KernelConfig.class, HibernateDaoConfig.class })) + HibernateDaoConfig.class, PropertyLoaderConfig.class })) public class WorkflowManagerApplication { public static void main(String[] args) { diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/config/WorkflowManagerConfigBeans.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/config/WorkflowManagerConfigBeans.java index 46547cf52eb..99ff67a1673 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/config/WorkflowManagerConfigBeans.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/config/WorkflowManagerConfigBeans.java @@ -11,6 +11,7 @@ import io.mosip.registration.processor.core.workflow.dto.WorkflowCompletedEventDTO; import io.mosip.registration.processor.core.workflow.dto.WorkflowPausedForAdditionalInfoEventDTO; import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.rest.client.service.impl.RegistrationProcessorRestClientServiceImpl; import io.mosip.registration.processor.workflowmanager.service.WorkflowActionService; import io.mosip.registration.processor.workflowmanager.service.WorkflowSearchService; diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticle.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticle.java index 6df752465f0..7f40ba964cc 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticle.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticle.java @@ -1,622 +1,627 @@ -package io.mosip.registration.processor.workflowmanager.verticle; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.packet.storage.utils.Utilities; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.JSONException; -import org.json.simple.JSONObject; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.exception.JsonProcessingException; -import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; -import io.mosip.registration.processor.core.abstractverticle.MessageDTO; -import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; -import io.mosip.registration.processor.core.abstractverticle.MosipRouter; -import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; -import io.mosip.registration.processor.core.abstractverticle.WorkflowInternalActionDTO; -import io.mosip.registration.processor.core.code.EventId; -import io.mosip.registration.processor.core.code.EventName; -import io.mosip.registration.processor.core.code.EventType; -import io.mosip.registration.processor.core.code.ModuleName; -import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; -import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; -import io.mosip.registration.processor.core.code.WorkflowActionCode; -import io.mosip.registration.processor.core.code.WorkflowInternalActionCode; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.constant.ProviderStageName; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.WorkflowActionException; -import io.mosip.registration.processor.core.exception.WorkflowInternalActionException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; -import io.mosip.registration.processor.core.logger.LogDescription; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.AdditionalInfoRequestDto; -import io.mosip.registration.processor.core.status.util.StatusUtil; -import io.mosip.registration.processor.core.workflow.dto.WorkflowCompletedEventDTO; -import io.mosip.registration.processor.core.workflow.dto.WorkflowPausedForAdditionalInfoEventDTO; -import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; -import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; -import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; -import io.mosip.registration.processor.status.code.RegistrationStatusCode; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.exception.TablenotAccessibleException; -import io.mosip.registration.processor.status.service.AdditionalInfoRequestService; -import io.mosip.registration.processor.status.service.AnonymousProfileService; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.workflowmanager.service.WorkflowActionService; -import io.mosip.registration.processor.workflowmanager.util.WebSubUtil; -import io.vertx.core.json.JsonObject; -@Component -public class WorkflowInternalActionVerticle extends MosipVerticleAPIManager { - - private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.reprocessor."; - - /** The Constant USER. */ - private static final String USER = "MOSIP_SYSTEM"; - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(WorkflowInternalActionVerticle.class); - - /** The registration status service. */ - @Autowired - RegistrationStatusService registrationStatusService; - - /** The audit log request builder. */ - @Autowired - AuditLogRequestBuilder auditLogRequestBuilder; - - @Value("${vertx.cluster.configuration}") - private String clusterManagerUrl; - - /** server port number. */ - @Value("${mosip.regproc.workflow-manager.internal.action.server.port}") - private String port; - - /** worker pool size. */ - @Value("${worker.pool.size}") - private Integer workerPoolSize; - - @Value("${mosip.regproc.workflow-manager.internal.action.eventbus.port}") - private String eventBusPort; - - @Value("${mosip.regproc.workflow-manager.internal.action.max-allowed-iteration}") - private int defaultMaxAllowedIteration; - - @Value("${mosip.anonymous.profile.eventbus.address}") - private String anonymousProfileBusAddress; - - @Autowired - MosipRouter router; - - @Autowired - AdditionalInfoRequestService additionalInfoRequestService; - - @Autowired - private WorkflowActionService workflowActionService; - - @Autowired - private AnonymousProfileService anonymousProfileService; - - private MosipEventBus mosipEventBus = null; - - public static String MODULE_NAME = ModuleName.WORKFLOW_INTERNAL_ACTION.toString(); - - public static String MODULE_ID = PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode(); - - /** The web sub util. */ - @Autowired - private WebSubUtil webSubUtil; - - @Autowired - private Utilities utility; - - @Autowired - private IdSchemaUtil idSchemaUtil; - - @Autowired - private PacketManagerService packetManagerService; - - @Autowired - private Environment env; - - /** - * Deploy verticle. - */ - public void deployVerticle() { - mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); - this.consume(mosipEventBus, MessageBusAddress.WORKFLOW_INTERNAL_ACTION_ADDRESS, 0); - } - - @Override - public void start() { - router.setRoute( - this.postUrl(getVertx(), MessageBusAddress.WORKFLOW_INTERNAL_ACTION_ADDRESS, null)); - this.createServer(router.getRouter(), Integer.parseInt(port)); - } - - @Override - public Integer getEventBusPort() { - return Integer.parseInt(eventBusPort); - } - @Override - public void consume(MosipEventBus mosipEventBus, MessageBusAddress fromAddress, - long messageExpiryTimeLimit) { - mosipEventBus.consume(fromAddress, (msg, handler) -> { - - Map mdc = MDC.getCopyOfContextMap(); - vertx.executeBlocking(future -> { - MDC.setContextMap(mdc); - JsonObject jsonObject = (JsonObject) msg.getBody(); - WorkflowInternalActionDTO workflowEventDTO = jsonObject.mapTo(WorkflowInternalActionDTO.class); - MessageDTO result = process(workflowEventDTO); - future.complete(result); - }, false, handler); - MDC.clear(); - }); - } - - @Override - public MessageDTO process(MessageDTO object) { - LogDescription description = new LogDescription(); - boolean isTransactionSuccessful = false; - WorkflowInternalActionDTO workflowInternalActionDTO = (WorkflowInternalActionDTO) object; - String registrationId = workflowInternalActionDTO.getRid(); - regProcLogger.debug("WorkflowInternalActionVerticle called for registration id {}", registrationId); - WorkflowInternalActionCode workflowInternalActionCode = null; - try { - workflowInternalActionCode = WorkflowInternalActionCode.valueOf(workflowInternalActionDTO.getActionCode()); - switch (workflowInternalActionCode) { - case MARK_AS_PAUSED: - processPacketForPaused(workflowInternalActionDTO); - break; - case COMPLETE_AS_PROCESSED: - processCompleteAsProcessed(workflowInternalActionDTO); - break; - case COMPLETE_AS_REJECTED: - processCompleteAsRejected(workflowInternalActionDTO); - break; - case COMPLETE_AS_FAILED: - processCompleteAsFailed(workflowInternalActionDTO); - break; - case MARK_AS_REPROCESS: - processMarkAsReprocess(workflowInternalActionDTO); - break; - case PAUSE_AND_REQUEST_ADDITIONAL_INFO: - processPauseAndRequestAdditionalInfo(workflowInternalActionDTO); - break; - case RESTART_PARENT_FLOW: - processRestartParentFlow(workflowInternalActionDTO); - break; - case COMPLETE_AS_REJECTED_WITHOUT_PARENT_FLOW: - processCompleteAsRejectedWithoutParentFlow(workflowInternalActionDTO); - break; - case ANONYMOUS_PROFILE: - processAnonymousProfile(workflowInternalActionDTO); - break; - default: - throw new WorkflowInternalActionException( - PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION.getCode(), - PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION.getMessage()); - - } - isTransactionSuccessful = true; - description.setMessage(PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getMessage()); - description.setCode(PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - regProcLogger.debug("WorkflowInternalActionVerticle call ended for registration id {}", registrationId); - - } catch (DateTimeParseException e) { - updateDTOsAndLogError(description, registrationId, PlatformErrorMessages.RPR_WIA_DATE_TIME_EXCEPTION, e); - - } catch (TablenotAccessibleException e) { - - updateDTOsAndLogError(description, registrationId, - PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); - - } catch (WorkflowInternalActionException e) { - - updateDTOsAndLogError(description, registrationId, PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION, - e); - - } catch (Exception e) { - - updateDTOsAndLogError(description, registrationId, - PlatformErrorMessages.RPR_WORKFLOW_INTERNAL_ACTION_FAILED, - e); - - } finally { - regProcLogger.info("WorkflowEventUpdateVerticle status for registration id {} {}", registrationId, - description.getMessage()); - - updateAudit(description, isTransactionSuccessful, registrationId); - } - return object; - - } - - private void processAnonymousProfile(WorkflowInternalActionDTO workflowInternalActionDTO) - throws IOException, JSONException, BaseCheckedException { - - String json = null; - String registrationId = workflowInternalActionDTO.getRid(); - String registrationType = workflowInternalActionDTO.getReg_type(); - - regProcLogger.info("processAnonymousProfile called for registration id {}", registrationId); - - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( - registrationId, registrationType, workflowInternalActionDTO.getIteration(), - workflowInternalActionDTO.getWorkflowInstanceId()); - JSONObject regProcessorIdentityJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); - String idSchemaVersionValue = JsonUtil.getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.IDSCHEMA_VERSION), MappingJsonConstants.VALUE); - String schemaVersion = packetManagerService.getFieldByMappingJsonKey(registrationId, - idSchemaVersionValue, registrationType, ProviderStageName.WORKFLOW_MANAGER); - Map fieldTypeMap = idSchemaUtil.getIdSchemaFieldTypes( - Double.parseDouble(schemaVersion)); - Map fieldMap = packetManagerService.getFields(registrationId, - idSchemaUtil.getDefaultFields(Double.valueOf(schemaVersion)), registrationType, - ProviderStageName.WORKFLOW_MANAGER); - Map metaInfoMap = packetManagerService.getMetaInfo(registrationId, registrationType, - ProviderStageName.WORKFLOW_MANAGER); - BiometricRecord biometricRecord = packetManagerService.getBiometrics(registrationId, - MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationType, ProviderStageName.WORKFLOW_MANAGER); - json = anonymousProfileService.buildJsonStringFromPacketInfo(biometricRecord, fieldMap, fieldTypeMap, - metaInfoMap, registrationStatusDto.getStatusCode(), registrationStatusDto.getRegistrationStageName()); - anonymousProfileService.saveAnonymousProfile(registrationId, registrationStatusDto.getRegistrationStageName(), json); - - this.send(this.mosipEventBus, new MessageBusAddress(anonymousProfileBusAddress), workflowInternalActionDTO); - - regProcLogger.info("processAnonymousProfile ended for registration id {}", registrationId); - } - - private void processCompleteAsRejectedWithoutParentFlow(WorkflowInternalActionDTO workflowInternalActionDTO) { - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( - workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - } - - private void processMarkAsReprocess(WorkflowInternalActionDTO workflowInternalActionDTO) { - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService - .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REPROCESS.toString()); - registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - } - - private void processCompleteAsFailed(WorkflowInternalActionDTO workflowInternalActionDTO) - throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, - JsonProcessingException, IOException { - AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService - .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), - workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); - - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService - .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - if (additionalInfoRequestDto != null) { - Map tags = new HashMap(); - tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", - RegistrationStatusCode.FAILED.toString()); - packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), - tags); - InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService - .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); - List internalRegistrationStatusDtos = new ArrayList(); - internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); - workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, - WorkflowActionCode.RESUME_PROCESSING.toString()); - } else { - sendWorkflowCompletedWebSubEvent(registrationStatusDto); - } - - } - - private void processCompleteAsRejected(WorkflowInternalActionDTO workflowInternalActionDTO) - throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, - JsonProcessingException, IOException { - AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService - .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), - workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService - .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); - registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - - if (additionalInfoRequestDto != null) { - Map tags = new HashMap(); - tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", - RegistrationStatusCode.REJECTED.toString()); - packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); - InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService - .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); - List internalRegistrationStatusDtos = new ArrayList(); - internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); - workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, - WorkflowActionCode.RESUME_PROCESSING.toString()); - } else { - sendWorkflowCompletedWebSubEvent(registrationStatusDto); - } - - } - - private void processCompleteAsProcessed(WorkflowInternalActionDTO workflowInternalActionDTO) - throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException, - WorkflowActionException { - AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService - .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), - workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService - .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSED.toString()); - registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - if (additionalInfoRequestDto != null) { - Map tags = new HashMap(); - tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", - RegistrationStatusCode.PROCESSED.toString()); - packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); - InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService - .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); - mainFlowregistrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - List internalRegistrationStatusDtos = new ArrayList(); - internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); - workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, - WorkflowActionCode.RESUME_PROCESSING.toString()); - } else { - sendWorkflowCompletedWebSubEvent(registrationStatusDto); - } - - } - - private void processPacketForPaused(WorkflowInternalActionDTO workflowInternalActionDTO) { - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService - .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PAUSED.toString()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setDefaultResumeAction(workflowInternalActionDTO.getDefaultResumeAction()); - if (workflowInternalActionDTO.getResumeTimestamp() != null) { - LocalDateTime resumeTimeStamp = DateUtils - .parseToLocalDateTime(workflowInternalActionDTO.getResumeTimestamp()); - registrationStatusDto.setResumeTimeStamp(resumeTimeStamp); - } - registrationStatusDto.setUpdatedBy(USER); - String pauseRuleIds=""; - for(String matchedRuleId:workflowInternalActionDTO.getMatchedRuleIds()) { - if(pauseRuleIds.isEmpty()) - pauseRuleIds=matchedRuleId; - else - pauseRuleIds=pauseRuleIds+","+matchedRuleId; - } - registrationStatusDto.setPauseRuleIds(pauseRuleIds); - registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - - } - - private void updateAudit(LogDescription description, boolean isTransactionSuccessful, String registrationId) { - String moduleId = isTransactionSuccessful - ? PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode() - : description.getCode(); - - String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() - : EventId.RPR_405.toString(); - String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() - : EventName.EXCEPTION.toString(); - String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() - : EventType.SYSTEM.toString(); - - auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, - moduleId, MODULE_NAME, registrationId); - } - - private void updateDTOsAndLogError(LogDescription description, String registrationId, - PlatformErrorMessages platformErrorMessages, Exception e) { - description.setMessage(platformErrorMessages.getMessage()); - description.setCode(platformErrorMessages.getCode()); - regProcLogger.error("Error in WorkflowEventUpdateVerticle for registration id {} {} {} {}", registrationId, - platformErrorMessages.getMessage(), e.getMessage(), ExceptionUtils.getStackTrace(e)); - - } - - @Override - protected String getPropertyPrefix() { - return STAGE_PROPERTY_PREFIX; - } - - private void sendWorkflowCompletedWebSubEvent(InternalRegistrationStatusDto registrationStatusDto) { - WorkflowCompletedEventDTO workflowCompletedEventDTO = new WorkflowCompletedEventDTO(); - workflowCompletedEventDTO.setInstanceId(registrationStatusDto.getRegistrationId()); - workflowCompletedEventDTO.setResultCode(registrationStatusDto.getStatusCode()); - workflowCompletedEventDTO.setWorkflowType(registrationStatusDto.getRegistrationType()); - if (registrationStatusDto.getStatusCode().equalsIgnoreCase(RegistrationStatusCode.REJECTED.toString())) { - workflowCompletedEventDTO.setErrorCode(RegistrationExceptionTypeCode.PACKET_REJECTED.name()); - } - if (registrationStatusDto.getStatusCode().equalsIgnoreCase(RegistrationStatusCode.FAILED.toString())) { - workflowCompletedEventDTO.setErrorCode(RegistrationExceptionTypeCode.PACKET_FAILED.name()); - } - - webSubUtil.publishEvent(workflowCompletedEventDTO); - - } - - private void processRestartParentFlow(WorkflowInternalActionDTO workflowInternalActionDTO) - throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, - JsonProcessingException, IOException { - AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService - .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), - workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( - workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSED.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - if (additionalInfoRequestDto != null) { - Map tags = new HashMap(); - tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", - RegistrationStatusCode.PROCESSED.toString()); - packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); - - InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService - .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); - - List internalRegistrationStatusDtos = new ArrayList(); - internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); - workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, - WorkflowActionCode.RESUME_FROM_BEGINNING.toString()); - } else { - regProcLogger.error( - "Error in WorkflowEventUpdateVerticle:processRestartParentFlow for registration id {} {}", - workflowInternalActionDTO.getRid(), - PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_NOT_FOUND.getMessage()); - } - } - - private void processPauseAndRequestAdditionalInfo(WorkflowInternalActionDTO workflowInternalActionDTO) - throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, - JsonProcessingException, IOException { - AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService - .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), - workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); - InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( - workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), - workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); - if (additionalInfoRequestDto != null) { - regProcLogger.warn("Info in WorkflowEventUpdateVerticle:processRestartParentFlow for registration id {} {}", - workflowInternalActionDTO.getRid(), - PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_CANNOT_REQUEST.getMessage()); - registrationStatusDto - .setStatusComment(PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_CANNOT_REQUEST.getMessage()); - registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - Map tags = new HashMap(); - tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", - RegistrationStatusCode.FAILED.toString()); - packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); - InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService - .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); - mainFlowregistrationStatusDto - .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); - List internalRegistrationStatusDtos = new ArrayList(); - internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); - workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, - WorkflowActionCode.RESUME_PROCESSING.toString()); - } else { - List additionalInfoRequestDtos = additionalInfoRequestService. - getAdditionalInfoRequestByRegIdAndProcess( - workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getAdditionalInfoProcess()); - String iteration=env.getProperty("mosip.regproc.workflow-manager.internal.action.max-allowed-iteration." + workflowInternalActionDTO.getAdditionalInfoProcess()); - int maxAllowedIteration; - if(iteration!=null) { - maxAllowedIteration=Integer.parseInt(iteration); - }else { - maxAllowedIteration=defaultMaxAllowedIteration; - } - if (additionalInfoRequestDtos != null && !additionalInfoRequestDtos.isEmpty() && additionalInfoRequestDtos.get(0).getAdditionalInfoIteration()>=maxAllowedIteration) { - workflowInternalActionDTO.setActionMessage(StatusUtil.WORKFLOW_INTERNAL_ACTION_REJECTED_ITERATIONS_EXCEEDED_LIMIT.getMessage()); - processCompleteAsRejected(workflowInternalActionDTO); - }else { - registrationStatusDto.setStatusCode(RegistrationStatusCode.PAUSED_FOR_ADDITIONAL_INFO.toString()); - registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); - registrationStatusDto.setDefaultResumeAction(workflowInternalActionDTO.getDefaultResumeAction()); - if (workflowInternalActionDTO.getResumeTimestamp() != null) { - LocalDateTime resumeTimeStamp = DateUtils - .parseToLocalDateTime(workflowInternalActionDTO.getResumeTimestamp()); - registrationStatusDto.setResumeTimeStamp(resumeTimeStamp); - } - registrationStatusDto.setUpdatedBy(USER); - registrationStatusDto - .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); - registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); - registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); - String additionalRequestId = createAdditionalInfoRequest(workflowInternalActionDTO,additionalInfoRequestDtos); - sendWorkflowPausedForAdditionalInfoEvent(registrationStatusDto, additionalRequestId, - workflowInternalActionDTO.getAdditionalInfoProcess()); - } - } - } - - private String createAdditionalInfoRequest(WorkflowInternalActionDTO workflowInternalActionDTO,List additionalInfoRequestDtos) { - int iteration = 0; - if (additionalInfoRequestDtos != null && !additionalInfoRequestDtos.isEmpty()) { - iteration = additionalInfoRequestDtos.get(0).getAdditionalInfoIteration() + 1; - } else { - iteration = 1; - } - String additionalRequestId = createAdditionalRequestId(workflowInternalActionDTO, iteration); - AdditionalInfoRequestDto additionalInfoRequestDto = new AdditionalInfoRequestDto(); - additionalInfoRequestDto.setAdditionalInfoReqId(additionalRequestId); - additionalInfoRequestDto.setWorkflowInstanceId(workflowInternalActionDTO.getWorkflowInstanceId()); - additionalInfoRequestDto.setRegId(workflowInternalActionDTO.getRid()); - additionalInfoRequestDto.setAdditionalInfoProcess(workflowInternalActionDTO.getAdditionalInfoProcess()); - additionalInfoRequestDto.setAdditionalInfoIteration(iteration); - additionalInfoRequestDto.setTimestamp(LocalDateTime.now(ZoneId.of("UTC"))); - additionalInfoRequestService.addAdditionalInfoRequest(additionalInfoRequestDto); - return additionalRequestId; - } - - private String createAdditionalRequestId(WorkflowInternalActionDTO workflowInternalActionDTO, int iteration) { - String additionalRequestId = workflowInternalActionDTO.getRid() + "-" - + workflowInternalActionDTO.getAdditionalInfoProcess() + "-" + iteration; - return additionalRequestId; - } - - private void sendWorkflowPausedForAdditionalInfoEvent(InternalRegistrationStatusDto registrationStatusDto, - String additonalInfoRequestId, String additionalInfoProcess) { - WorkflowPausedForAdditionalInfoEventDTO workflowPausedForAdditionalInfoEventDTO = new WorkflowPausedForAdditionalInfoEventDTO(); - workflowPausedForAdditionalInfoEventDTO.setInstanceId(registrationStatusDto.getRegistrationId()); - workflowPausedForAdditionalInfoEventDTO.setWorkflowType(registrationStatusDto.getRegistrationType()); - workflowPausedForAdditionalInfoEventDTO.setAdditionalInfoProcess(additionalInfoProcess); - workflowPausedForAdditionalInfoEventDTO.setAdditionalInfoRequestId(additonalInfoRequestId); - webSubUtil.publishEvent(workflowPausedForAdditionalInfoEventDTO); - - } -} +package io.mosip.registration.processor.workflowmanager.verticle; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.packet.storage.utils.Utilities; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.JSONException; +import org.json.simple.JSONObject; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.exception.JsonProcessingException; +import io.mosip.registration.processor.core.abstractverticle.MessageBusAddress; +import io.mosip.registration.processor.core.abstractverticle.MessageDTO; +import io.mosip.registration.processor.core.abstractverticle.MosipEventBus; +import io.mosip.registration.processor.core.abstractverticle.MosipRouter; +import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; +import io.mosip.registration.processor.core.abstractverticle.WorkflowInternalActionDTO; +import io.mosip.registration.processor.core.code.EventId; +import io.mosip.registration.processor.core.code.EventName; +import io.mosip.registration.processor.core.code.EventType; +import io.mosip.registration.processor.core.code.ModuleName; +import io.mosip.registration.processor.core.code.RegistrationExceptionTypeCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionStatusCode; +import io.mosip.registration.processor.core.code.RegistrationTransactionTypeCode; +import io.mosip.registration.processor.core.code.WorkflowActionCode; +import io.mosip.registration.processor.core.code.WorkflowInternalActionCode; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.constant.ProviderStageName; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.WorkflowActionException; +import io.mosip.registration.processor.core.exception.WorkflowInternalActionException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.exception.util.PlatformSuccessMessages; +import io.mosip.registration.processor.core.logger.LogDescription; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.AdditionalInfoRequestDto; +import io.mosip.registration.processor.core.status.util.StatusUtil; +import io.mosip.registration.processor.core.workflow.dto.WorkflowCompletedEventDTO; +import io.mosip.registration.processor.core.workflow.dto.WorkflowPausedForAdditionalInfoEventDTO; +import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; +import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; +import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; +import io.mosip.registration.processor.status.code.RegistrationStatusCode; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.exception.TablenotAccessibleException; +import io.mosip.registration.processor.status.service.AdditionalInfoRequestService; +import io.mosip.registration.processor.status.service.AnonymousProfileService; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.workflowmanager.service.WorkflowActionService; +import io.mosip.registration.processor.workflowmanager.util.WebSubUtil; +import io.vertx.core.json.JsonObject; +@Component +public class WorkflowInternalActionVerticle extends MosipVerticleAPIManager { + + private static final String STAGE_PROPERTY_PREFIX = "mosip.regproc.reprocessor."; + + /** The Constant USER. */ + private static final String USER = "MOSIP_SYSTEM"; + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(WorkflowInternalActionVerticle.class); + + /** The registration status service. */ + @Autowired + RegistrationStatusService registrationStatusService; + + /** The audit log request builder. */ + @Autowired + AuditLogRequestBuilder auditLogRequestBuilder; + + @Value("${vertx.cluster.configuration}") + private String clusterManagerUrl; + + /** server port number. */ + @Value("${mosip.regproc.workflow-manager.internal.action.server.port}") + private String port; + + /** worker pool size. */ + @Value("${worker.pool.size}") + private Integer workerPoolSize; + + @Value("${mosip.regproc.workflow-manager.internal.action.eventbus.port}") + private String eventBusPort; + + @Value("${mosip.regproc.workflow-manager.internal.action.max-allowed-iteration}") + private int defaultMaxAllowedIteration; + + @Value("${mosip.anonymous.profile.eventbus.address}") + private String anonymousProfileBusAddress; + + @Autowired + MosipRouter router; + + @Autowired + AdditionalInfoRequestService additionalInfoRequestService; + + @Autowired + private WorkflowActionService workflowActionService; + + @Autowired + private AnonymousProfileService anonymousProfileService; + + private MosipEventBus mosipEventBus = null; + + public static String MODULE_NAME = ModuleName.WORKFLOW_INTERNAL_ACTION.toString(); + + public static String MODULE_ID = PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode(); + + /** The web sub util. */ + @Autowired + private WebSubUtil webSubUtil; + + @Autowired + private Utilities utility; + + @Autowired + private IdSchemaUtil idSchemaUtil; + + @Autowired + private PriorityBasedPacketManagerService priorityBasedpacketManagerService; + + @Autowired + private PacketManagerService packetManagerService; + + @Autowired + private Environment env; + + /** + * Deploy verticle. + */ + public void deployVerticle() { + mosipEventBus = this.getEventBus(this, clusterManagerUrl, workerPoolSize); + this.consume(mosipEventBus, MessageBusAddress.WORKFLOW_INTERNAL_ACTION_ADDRESS, 0); + } + + @Override + public void start() { + router.setRoute( + this.postUrl(getVertx(), MessageBusAddress.WORKFLOW_INTERNAL_ACTION_ADDRESS, null)); + this.createServer(router.getRouter(), Integer.parseInt(port)); + } + + @Override + public Integer getEventBusPort() { + return Integer.parseInt(eventBusPort); + } + @Override + public void consume(MosipEventBus mosipEventBus, MessageBusAddress fromAddress, + long messageExpiryTimeLimit) { + mosipEventBus.consume(fromAddress, (msg, handler) -> { + + Map mdc = MDC.getCopyOfContextMap(); + vertx.executeBlocking(future -> { + MDC.setContextMap(mdc); + JsonObject jsonObject = (JsonObject) msg.getBody(); + WorkflowInternalActionDTO workflowEventDTO = jsonObject.mapTo(WorkflowInternalActionDTO.class); + MessageDTO result = process(workflowEventDTO); + future.complete(result); + }, false, handler); + MDC.clear(); + }); + } + + @Override + public MessageDTO process(MessageDTO object) { + LogDescription description = new LogDescription(); + boolean isTransactionSuccessful = false; + WorkflowInternalActionDTO workflowInternalActionDTO = (WorkflowInternalActionDTO) object; + String registrationId = workflowInternalActionDTO.getRid(); + regProcLogger.debug("WorkflowInternalActionVerticle called for registration id {}", registrationId); + WorkflowInternalActionCode workflowInternalActionCode = null; + try { + workflowInternalActionCode = WorkflowInternalActionCode.valueOf(workflowInternalActionDTO.getActionCode()); + switch (workflowInternalActionCode) { + case MARK_AS_PAUSED: + processPacketForPaused(workflowInternalActionDTO); + break; + case COMPLETE_AS_PROCESSED: + processCompleteAsProcessed(workflowInternalActionDTO); + break; + case COMPLETE_AS_REJECTED: + processCompleteAsRejected(workflowInternalActionDTO); + break; + case COMPLETE_AS_FAILED: + processCompleteAsFailed(workflowInternalActionDTO); + break; + case MARK_AS_REPROCESS: + processMarkAsReprocess(workflowInternalActionDTO); + break; + case PAUSE_AND_REQUEST_ADDITIONAL_INFO: + processPauseAndRequestAdditionalInfo(workflowInternalActionDTO); + break; + case RESTART_PARENT_FLOW: + processRestartParentFlow(workflowInternalActionDTO); + break; + case COMPLETE_AS_REJECTED_WITHOUT_PARENT_FLOW: + processCompleteAsRejectedWithoutParentFlow(workflowInternalActionDTO); + break; + case ANONYMOUS_PROFILE: + processAnonymousProfile(workflowInternalActionDTO); + break; + default: + throw new WorkflowInternalActionException( + PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION.getCode(), + PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION.getMessage()); + + } + isTransactionSuccessful = true; + description.setMessage(PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getMessage()); + description.setCode(PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + regProcLogger.debug("WorkflowInternalActionVerticle call ended for registration id {}", registrationId); + + } catch (DateTimeParseException e) { + updateDTOsAndLogError(description, registrationId, PlatformErrorMessages.RPR_WIA_DATE_TIME_EXCEPTION, e); + + } catch (TablenotAccessibleException e) { + + updateDTOsAndLogError(description, registrationId, + PlatformErrorMessages.RPR_RGS_REGISTRATION_TABLE_NOT_ACCESSIBLE, e); + + } catch (WorkflowInternalActionException e) { + + updateDTOsAndLogError(description, registrationId, PlatformErrorMessages.RPR_WIA_UNKNOWN_WORKFLOW_ACTION, + e); + + } catch (Exception e) { + + updateDTOsAndLogError(description, registrationId, + PlatformErrorMessages.RPR_WORKFLOW_INTERNAL_ACTION_FAILED, + e); + + } finally { + regProcLogger.info("WorkflowEventUpdateVerticle status for registration id {} {}", registrationId, + description.getMessage()); + + updateAudit(description, isTransactionSuccessful, registrationId); + } + return object; + + } + + private void processAnonymousProfile(WorkflowInternalActionDTO workflowInternalActionDTO) + throws IOException, JSONException, BaseCheckedException { + + String json = null; + String registrationId = workflowInternalActionDTO.getRid(); + String registrationType = workflowInternalActionDTO.getReg_type(); + + regProcLogger.info("processAnonymousProfile called for registration id {}", registrationId); + + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( + registrationId, registrationType, workflowInternalActionDTO.getIteration(), + workflowInternalActionDTO.getWorkflowInstanceId()); + JSONObject regProcessorIdentityJson = utility.getRegistrationProcessorMappingJson(MappingJsonConstants.IDENTITY); + String idSchemaVersionValue = JsonUtil.getJSONValue(JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.IDSCHEMA_VERSION), MappingJsonConstants.VALUE); + String schemaVersion = priorityBasedpacketManagerService.getFieldByMappingJsonKey(registrationId, + idSchemaVersionValue, registrationType, ProviderStageName.WORKFLOW_MANAGER); + Map fieldTypeMap = idSchemaUtil.getIdSchemaFieldTypes( + Double.parseDouble(schemaVersion)); + Map fieldMap = priorityBasedpacketManagerService.getFields(registrationId, + idSchemaUtil.getDefaultFields(Double.valueOf(schemaVersion)), registrationType, + ProviderStageName.WORKFLOW_MANAGER); + Map metaInfoMap = priorityBasedpacketManagerService.getMetaInfo(registrationId, + registrationType, + ProviderStageName.WORKFLOW_MANAGER); + BiometricRecord biometricRecord = priorityBasedpacketManagerService.getBiometrics(registrationId, + MappingJsonConstants.INDIVIDUAL_BIOMETRICS, registrationType, ProviderStageName.WORKFLOW_MANAGER); + json = anonymousProfileService.buildJsonStringFromPacketInfo(biometricRecord, fieldMap, fieldTypeMap, + metaInfoMap, registrationStatusDto.getStatusCode(), registrationStatusDto.getRegistrationStageName()); + anonymousProfileService.saveAnonymousProfile(registrationId, registrationStatusDto.getRegistrationStageName(), json); + + this.send(this.mosipEventBus, new MessageBusAddress(anonymousProfileBusAddress), workflowInternalActionDTO); + + regProcLogger.info("processAnonymousProfile ended for registration id {}", registrationId); + } + + private void processCompleteAsRejectedWithoutParentFlow(WorkflowInternalActionDTO workflowInternalActionDTO) { + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( + workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + } + + private void processMarkAsReprocess(WorkflowInternalActionDTO workflowInternalActionDTO) { + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService + .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REPROCESS.toString()); + registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + } + + private void processCompleteAsFailed(WorkflowInternalActionDTO workflowInternalActionDTO) + throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, + JsonProcessingException, IOException { + AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService + .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), + workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); + + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService + .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + if (additionalInfoRequestDto != null) { + Map tags = new HashMap(); + tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", + RegistrationStatusCode.FAILED.toString()); + packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), + tags); + InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService + .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); + List internalRegistrationStatusDtos = new ArrayList(); + internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); + workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, + WorkflowActionCode.RESUME_PROCESSING.toString()); + } else { + sendWorkflowCompletedWebSubEvent(registrationStatusDto); + } + + } + + private void processCompleteAsRejected(WorkflowInternalActionDTO workflowInternalActionDTO) + throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, + JsonProcessingException, IOException { + AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService + .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), + workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService + .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.REJECTED.toString()); + registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + + if (additionalInfoRequestDto != null) { + Map tags = new HashMap(); + tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", + RegistrationStatusCode.REJECTED.toString()); + packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); + InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService + .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); + List internalRegistrationStatusDtos = new ArrayList(); + internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); + workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, + WorkflowActionCode.RESUME_PROCESSING.toString()); + } else { + sendWorkflowCompletedWebSubEvent(registrationStatusDto); + } + + } + + private void processCompleteAsProcessed(WorkflowInternalActionDTO workflowInternalActionDTO) + throws ApisResourceAccessException, PacketManagerException, JsonProcessingException, IOException, + WorkflowActionException { + AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService + .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), + workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService + .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSED.toString()); + registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + if (additionalInfoRequestDto != null) { + Map tags = new HashMap(); + tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", + RegistrationStatusCode.PROCESSED.toString()); + packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); + InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService + .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); + mainFlowregistrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + List internalRegistrationStatusDtos = new ArrayList(); + internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); + workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, + WorkflowActionCode.RESUME_PROCESSING.toString()); + } else { + sendWorkflowCompletedWebSubEvent(registrationStatusDto); + } + + } + + private void processPacketForPaused(WorkflowInternalActionDTO workflowInternalActionDTO) { + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService + .getRegistrationStatus(workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PAUSED.toString()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setDefaultResumeAction(workflowInternalActionDTO.getDefaultResumeAction()); + if (workflowInternalActionDTO.getResumeTimestamp() != null) { + LocalDateTime resumeTimeStamp = DateUtils + .parseToLocalDateTime(workflowInternalActionDTO.getResumeTimestamp()); + registrationStatusDto.setResumeTimeStamp(resumeTimeStamp); + } + registrationStatusDto.setUpdatedBy(USER); + String pauseRuleIds=""; + for(String matchedRuleId:workflowInternalActionDTO.getMatchedRuleIds()) { + if(pauseRuleIds.isEmpty()) + pauseRuleIds=matchedRuleId; + else + pauseRuleIds=pauseRuleIds+","+matchedRuleId; + } + registrationStatusDto.setPauseRuleIds(pauseRuleIds); + registrationStatusDto.setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + + } + + private void updateAudit(LogDescription description, boolean isTransactionSuccessful, String registrationId) { + String moduleId = isTransactionSuccessful + ? PlatformSuccessMessages.RPR_WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode() + : description.getCode(); + + String eventId = isTransactionSuccessful ? EventId.RPR_402.toString() + : EventId.RPR_405.toString(); + String eventName = isTransactionSuccessful ? EventName.UPDATE.toString() + : EventName.EXCEPTION.toString(); + String eventType = isTransactionSuccessful ? EventType.BUSINESS.toString() + : EventType.SYSTEM.toString(); + + auditLogRequestBuilder.createAuditRequestBuilder(description.getMessage(), eventId, eventName, eventType, + moduleId, MODULE_NAME, registrationId); + } + + private void updateDTOsAndLogError(LogDescription description, String registrationId, + PlatformErrorMessages platformErrorMessages, Exception e) { + description.setMessage(platformErrorMessages.getMessage()); + description.setCode(platformErrorMessages.getCode()); + regProcLogger.error("Error in WorkflowEventUpdateVerticle for registration id {} {} {} {}", registrationId, + platformErrorMessages.getMessage(), e.getMessage(), ExceptionUtils.getStackTrace(e)); + + } + + @Override + protected String getPropertyPrefix() { + return STAGE_PROPERTY_PREFIX; + } + + private void sendWorkflowCompletedWebSubEvent(InternalRegistrationStatusDto registrationStatusDto) { + WorkflowCompletedEventDTO workflowCompletedEventDTO = new WorkflowCompletedEventDTO(); + workflowCompletedEventDTO.setInstanceId(registrationStatusDto.getRegistrationId()); + workflowCompletedEventDTO.setResultCode(registrationStatusDto.getStatusCode()); + workflowCompletedEventDTO.setWorkflowType(registrationStatusDto.getRegistrationType()); + if (registrationStatusDto.getStatusCode().equalsIgnoreCase(RegistrationStatusCode.REJECTED.toString())) { + workflowCompletedEventDTO.setErrorCode(RegistrationExceptionTypeCode.PACKET_REJECTED.name()); + } + if (registrationStatusDto.getStatusCode().equalsIgnoreCase(RegistrationStatusCode.FAILED.toString())) { + workflowCompletedEventDTO.setErrorCode(RegistrationExceptionTypeCode.PACKET_FAILED.name()); + } + + webSubUtil.publishEvent(workflowCompletedEventDTO); + + } + + private void processRestartParentFlow(WorkflowInternalActionDTO workflowInternalActionDTO) + throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, + JsonProcessingException, IOException { + AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService + .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), + workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( + workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.PROCESSED.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + if (additionalInfoRequestDto != null) { + Map tags = new HashMap(); + tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", + RegistrationStatusCode.PROCESSED.toString()); + packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); + + InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService + .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); + + List internalRegistrationStatusDtos = new ArrayList(); + internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); + workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, + WorkflowActionCode.RESUME_FROM_BEGINNING.toString()); + } else { + regProcLogger.error( + "Error in WorkflowEventUpdateVerticle:processRestartParentFlow for registration id {} {}", + workflowInternalActionDTO.getRid(), + PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_NOT_FOUND.getMessage()); + } + } + + private void processPauseAndRequestAdditionalInfo(WorkflowInternalActionDTO workflowInternalActionDTO) + throws WorkflowActionException, ApisResourceAccessException, PacketManagerException, + JsonProcessingException, IOException { + AdditionalInfoRequestDto additionalInfoRequestDto = additionalInfoRequestService + .getAdditionalInfoRequestByRegIdAndProcessAndIteration(workflowInternalActionDTO.getRid(), + workflowInternalActionDTO.getReg_type(), workflowInternalActionDTO.getIteration()); + InternalRegistrationStatusDto registrationStatusDto = registrationStatusService.getRegistrationStatus( + workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getReg_type(), + workflowInternalActionDTO.getIteration(), workflowInternalActionDTO.getWorkflowInstanceId()); + if (additionalInfoRequestDto != null) { + regProcLogger.warn("Info in WorkflowEventUpdateVerticle:processRestartParentFlow for registration id {} {}", + workflowInternalActionDTO.getRid(), + PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_CANNOT_REQUEST.getMessage()); + registrationStatusDto + .setStatusComment(PlatformErrorMessages.RPR_WIA_ADDITIONALINFOPROCESS_CANNOT_REQUEST.getMessage()); + registrationStatusDto.setStatusCode(RegistrationStatusCode.FAILED.toString()); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + Map tags = new HashMap(); + tags.put(workflowInternalActionDTO.getReg_type() + "_FLOW_STATUS", + RegistrationStatusCode.FAILED.toString()); + packetManagerService.addOrUpdateTags(workflowInternalActionDTO.getRid(), tags); + InternalRegistrationStatusDto mainFlowregistrationStatusDto = registrationStatusService + .getRegistrationStatus(null, null, null, additionalInfoRequestDto.getWorkflowInstanceId()); + mainFlowregistrationStatusDto + .setLatestTransactionStatusCode(RegistrationTransactionStatusCode.REPROCESS.toString()); + List internalRegistrationStatusDtos = new ArrayList(); + internalRegistrationStatusDtos.add(mainFlowregistrationStatusDto); + workflowActionService.processWorkflowAction(internalRegistrationStatusDtos, + WorkflowActionCode.RESUME_PROCESSING.toString()); + } else { + List additionalInfoRequestDtos = additionalInfoRequestService. + getAdditionalInfoRequestByRegIdAndProcess( + workflowInternalActionDTO.getRid(), workflowInternalActionDTO.getAdditionalInfoProcess()); + String iteration=env.getProperty("mosip.regproc.workflow-manager.internal.action.max-allowed-iteration." + workflowInternalActionDTO.getAdditionalInfoProcess()); + int maxAllowedIteration; + if(iteration!=null) { + maxAllowedIteration=Integer.parseInt(iteration); + }else { + maxAllowedIteration=defaultMaxAllowedIteration; + } + if (additionalInfoRequestDtos != null && !additionalInfoRequestDtos.isEmpty() && additionalInfoRequestDtos.get(0).getAdditionalInfoIteration()>=maxAllowedIteration) { + workflowInternalActionDTO.setActionMessage(StatusUtil.WORKFLOW_INTERNAL_ACTION_REJECTED_ITERATIONS_EXCEEDED_LIMIT.getMessage()); + processCompleteAsRejected(workflowInternalActionDTO); + }else { + registrationStatusDto.setStatusCode(RegistrationStatusCode.PAUSED_FOR_ADDITIONAL_INFO.toString()); + registrationStatusDto.setStatusComment(workflowInternalActionDTO.getActionMessage()); + registrationStatusDto.setDefaultResumeAction(workflowInternalActionDTO.getDefaultResumeAction()); + if (workflowInternalActionDTO.getResumeTimestamp() != null) { + LocalDateTime resumeTimeStamp = DateUtils + .parseToLocalDateTime(workflowInternalActionDTO.getResumeTimestamp()); + registrationStatusDto.setResumeTimeStamp(resumeTimeStamp); + } + registrationStatusDto.setUpdatedBy(USER); + registrationStatusDto + .setLatestTransactionTypeCode(RegistrationTransactionTypeCode.INTERNAL_WORKFLOW_ACTION.toString()); + registrationStatusDto.setSubStatusCode(StatusUtil.WORKFLOW_INTERNAL_ACTION_SUCCESS.getCode()); + registrationStatusService.updateRegistrationStatusForWorkflowEngine(registrationStatusDto, MODULE_ID, MODULE_NAME); + String additionalRequestId = createAdditionalInfoRequest(workflowInternalActionDTO,additionalInfoRequestDtos); + sendWorkflowPausedForAdditionalInfoEvent(registrationStatusDto, additionalRequestId, + workflowInternalActionDTO.getAdditionalInfoProcess()); + } + } + } + + private String createAdditionalInfoRequest(WorkflowInternalActionDTO workflowInternalActionDTO,List additionalInfoRequestDtos) { + int iteration = 0; + if (additionalInfoRequestDtos != null && !additionalInfoRequestDtos.isEmpty()) { + iteration = additionalInfoRequestDtos.get(0).getAdditionalInfoIteration() + 1; + } else { + iteration = 1; + } + String additionalRequestId = createAdditionalRequestId(workflowInternalActionDTO, iteration); + AdditionalInfoRequestDto additionalInfoRequestDto = new AdditionalInfoRequestDto(); + additionalInfoRequestDto.setAdditionalInfoReqId(additionalRequestId); + additionalInfoRequestDto.setWorkflowInstanceId(workflowInternalActionDTO.getWorkflowInstanceId()); + additionalInfoRequestDto.setRegId(workflowInternalActionDTO.getRid()); + additionalInfoRequestDto.setAdditionalInfoProcess(workflowInternalActionDTO.getAdditionalInfoProcess()); + additionalInfoRequestDto.setAdditionalInfoIteration(iteration); + additionalInfoRequestDto.setTimestamp(LocalDateTime.now(ZoneId.of("UTC"))); + additionalInfoRequestService.addAdditionalInfoRequest(additionalInfoRequestDto); + return additionalRequestId; + } + + private String createAdditionalRequestId(WorkflowInternalActionDTO workflowInternalActionDTO, int iteration) { + String additionalRequestId = workflowInternalActionDTO.getRid() + "-" + + workflowInternalActionDTO.getAdditionalInfoProcess() + "-" + iteration; + return additionalRequestId; + } + + private void sendWorkflowPausedForAdditionalInfoEvent(InternalRegistrationStatusDto registrationStatusDto, + String additonalInfoRequestId, String additionalInfoProcess) { + WorkflowPausedForAdditionalInfoEventDTO workflowPausedForAdditionalInfoEventDTO = new WorkflowPausedForAdditionalInfoEventDTO(); + workflowPausedForAdditionalInfoEventDTO.setInstanceId(registrationStatusDto.getRegistrationId()); + workflowPausedForAdditionalInfoEventDTO.setWorkflowType(registrationStatusDto.getRegistrationType()); + workflowPausedForAdditionalInfoEventDTO.setAdditionalInfoProcess(additionalInfoProcess); + workflowPausedForAdditionalInfoEventDTO.setAdditionalInfoRequestId(additonalInfoRequestId); + webSubUtil.publishEvent(workflowPausedForAdditionalInfoEventDTO); + + } +} diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticleTest.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticleTest.java index d4adda30b5c..4b7a3226d9d 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticleTest.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/test/java/io/mosip/registration/processor/workflowmanager/verticle/WorkflowInternalActionVerticleTest.java @@ -25,6 +25,7 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; @@ -52,6 +53,7 @@ import io.mosip.registration.processor.core.workflow.dto.WorkflowPausedForAdditionalInfoEventDTO; import io.mosip.registration.processor.packet.storage.utils.IdSchemaUtil; import io.mosip.registration.processor.packet.storage.utils.PacketManagerService; +import io.mosip.registration.processor.packet.storage.utils.PriorityBasedPacketManagerService; import io.mosip.registration.processor.packet.storage.utils.Utilities; import io.mosip.registration.processor.rest.client.audit.builder.AuditLogRequestBuilder; import io.mosip.registration.processor.status.code.RegistrationStatusCode; @@ -92,6 +94,9 @@ public class WorkflowInternalActionVerticleTest { @Mock WorkflowActionService workflowActionService; + @Mock + private PriorityBasedPacketManagerService priorityBasedPacketManagerService; + @Mock private PacketManagerService packetManagerService; @@ -659,7 +664,7 @@ public void testProcessSuccessForAnonymousProfile() throws IOException, JSONExce workflowInternalActionDTO.setActionCode(WorkflowInternalActionCode.ANONYMOUS_PROFILE.toString()); workflowInternalActionDTO.setActionMessage("anonymous profile event"); - Mockito.when(packetManagerService.getFieldByMappingJsonKey(anyString(), anyString(), anyString(), any())) + Mockito.when(priorityBasedPacketManagerService.getFieldByMappingJsonKey(anyString(), anyString(), anyString(), any())) .thenReturn("1.0"); Mockito.when(idSchemaUtil.getDefaultFields(anyDouble())).thenReturn(Arrays.asList("")); @@ -672,14 +677,14 @@ public void testProcessSuccessForAnonymousProfile() throws IOException, JSONExce fieldMap.put("postalCode", "14022"); fieldMap.put("dateOfBirth", "1998/01/01"); fieldMap.put("phone", "6666666666"); - Mockito.when(packetManagerService.getFields(anyString(), any(), anyString(), any())).thenReturn(fieldMap); + Mockito.when(priorityBasedPacketManagerService.getFields(anyString(), any(), anyString(), any())).thenReturn(fieldMap); Map metaInfoMap = new HashedMap(); metaInfoMap.put("documents", "[{\"documentType\" : \"CIN\"},{\"documentType\" : \"RNC\"})]"); metaInfoMap.put("operationsData", "[{\"label\" : \"officerId\",\"value\" : \"110024\"},{\"label\" : \"officerBiometricFileName\",\"value\" : \"null\"})]"); metaInfoMap.put("creationDate", "2021-09-01T03:48:49.193Z"); - Mockito.when(packetManagerService.getMetaInfo(anyString(), anyString(), any())).thenReturn(metaInfoMap); + Mockito.when(priorityBasedPacketManagerService.getMetaInfo(anyString(), anyString(), any())).thenReturn(metaInfoMap); BiometricRecord biometricRecord = new BiometricRecord(); BIR bir = new BIR(); @@ -689,7 +694,7 @@ public void testProcessSuccessForAnonymousProfile() throws IOException, JSONExce entry.put("PAYLOAD", "{\"deviceServiceVersion\":\"0.9.5\",\"bioValue\":\"\",\"qualityScore\":\"80\",\"bioType\":\"Iris\"}"); bir.setOthers(entry); biometricRecord.setSegments(Arrays.asList(bir)); - Mockito.when(packetManagerService.getBiometrics(anyString(), anyString(), anyString(), any())) + Mockito.when(priorityBasedPacketManagerService.getBiometrics(anyString(), anyString(), anyString(), any())) .thenReturn(biometricRecord); org.json.simple.JSONObject identity = new org.json.simple.JSONObject(); From 507dcc99aea3e8e61730ed638052b2f029d21961 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Fri, 17 May 2024 16:42:59 +0530 Subject: [PATCH 05/27] MOSIP-32461 code fix Signed-off-by: Sowmya Ujjappa Banakar --- .../api/RegistrationStatusApiApplication.java | 9 ++++++--- ...egistrationTransactionServiceApplication.java | 8 +++++--- .../src/main/resources/bootstrap.properties | 1 + .../src/main/resources/bootstrap.properties | 3 ++- .../notification/NotificationApplication.java | 16 +++++++++++++--- .../config/RegistrationStatusBeanConfig.java | 2 ++ .../src/main/resources/bootstrap.properties | 5 +++-- 7 files changed, 32 insertions(+), 12 deletions(-) diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java index 675d6562308..0492f9e792b 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java @@ -10,6 +10,7 @@ import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; import io.mosip.registration.processor.core.abstractverticle.MosipVerticleManager; import io.mosip.registration.processor.core.abstractverticle.StageHealthCheckHandler; +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.core.eventbus.KafkaMosipEventBus; import io.mosip.registration.processor.core.eventbus.VertxMosipEventBus; import io.mosip.registration.processor.rest.client.config.RestConfigBean; @@ -26,10 +27,12 @@ @ComponentScan(basePackages = { "io.mosip.registration.processor.status.*", "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.core.token.*", "io.mosip.registration.processor.core.config", - "${mosip.auth.adapter.impl.basepackage}" }, + "${mosip.auth.adapter.impl.basepackage}", + "io.mosip.registration.processor.core.kernel.beans" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusServiceBeanConfig.class, - RegistrationStatusBeanConfig.class, RestConfigBean.class,KafkaMosipEventBus.class,VertxMosipEventBus.class - ,StageHealthCheckHandler.class,MosipVerticleManager.class,MosipVerticleAPIManager.class,MosipEventBus.class})) + RestConfigBean.class, KafkaMosipEventBus.class, VertxMosipEventBus.class, StageHealthCheckHandler.class, + MosipVerticleManager.class, MosipVerticleAPIManager.class, MosipEventBus.class, + PropertyLoaderConfig.class })) public class RegistrationStatusApiApplication { public static void main( String[] args ) diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java index 47c221d61ec..5df525fc863 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java @@ -6,15 +6,17 @@ import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.rest.client.config.RestConfigBean; import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; @SpringBootApplication @ComponentScan(basePackages= {"io.mosip.registration.processor.status.*","io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.core.token.*", "io.mosip.registration.processor.core.config", - "io.mosip.registration.processor.transaction.*", "${mosip.auth.adapter.impl.basepackage}"}, - excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusBeanConfig.class, - RestConfigBean.class})) + "io.mosip.registration.processor.transaction.*", "${mosip.auth.adapter.impl.basepackage}", + "io.mosip.registration.processor.core.kernel.beans" }, + excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RestConfigBean.class, + PropertyLoaderConfig.class })) public class RegistrationTransactionServiceApplication { public static void main(String[] args) { diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/resources/bootstrap.properties b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/resources/bootstrap.properties index 36e023660ff..221526dec56 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/resources/bootstrap.properties +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/resources/bootstrap.properties @@ -33,3 +33,4 @@ openapi.info.license.url=https://docs.mosip.io/platform/license mosipbox.public.url=http://localhost:8110 openapi.registrationProcessor.servers[0].url=${mosipbox.public.url}/registrationprocessor/v1/registrationtransaction openapi.registrationProcessor.servers[0].description=Registration Processor +spring.cloud.config.enabled=true \ No newline at end of file diff --git a/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties b/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties index f2fed9cf48e..4d1ec31ca62 100644 --- a/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties +++ b/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties @@ -13,4 +13,5 @@ mosip.regproc.camel.bridge.server.servlet.path=/registrationprocessor/v1/camelbr mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.camel.bridge.eventbus.kafka.commit.type} mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.camel.bridge.eventbus.kafka.max.poll.records} mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.camel.bridge.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.camel.bridge.eventbus.kafka.group.id} \ No newline at end of file +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.camel.bridge.eventbus.kafka.group.id} +spring.cloud.config.enabled=true \ No newline at end of file diff --git a/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java b/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java index 098639f8203..16256ac0496 100644 --- a/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java +++ b/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java @@ -2,7 +2,13 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.FilterType; +import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.scheduling.annotation.EnableScheduling; + +import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; +import io.mosip.registration.processor.rest.client.config.RestConfigBean; /** * Init class for Notification service. * @@ -10,10 +16,14 @@ * @since 1.0.0 * */ -@SpringBootApplication(scanBasePackages = { "io.mosip.registration.processor.notification.*", +@SpringBootApplication +@ComponentScan( basePackages = { "io.mosip.registration.processor.notification.*", "io.mosip.kernel.websub.api.*","${mosip.auth.adapter.impl.basepackage}", "io.mosip.registration.processor.message.sender.config", - "io.mosip.registration.processor.rest.client.config", "io.mosip.registration.processor.packet.storage.config", - "io.mosip.registration.processor.core.config", "io.mosip.registration.processor.packet.storage.dao" ,"io.mosip.registration.processor.status.config"}) + "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.packet.storage.config", + "io.mosip.registration.processor.core.config", "io.mosip.registration.processor.packet.storage.dao", + "io.mosip.registration.processor.status.*", + "io.mosip.registration.processor.core.kernel.beans" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { + RestConfigBean.class, PropertyLoaderConfig.class })) @EnableScheduling public class NotificationApplication { diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java index be257b8bba9..40807d2c2df 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/config/RegistrationStatusBeanConfig.java @@ -84,11 +84,13 @@ public TransactionService getTransactionService() { } @Bean + @Primary public RestApiClient getRestApiClient() { return new RestApiClient(); } @Bean + @Primary public SyncRegistrationService getSyncRegistrationService() { return new SyncRegistrationServiceImpl(); } diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties index 1d01df50adb..f3296070a8c 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties @@ -1,7 +1,7 @@ spring.cloud.config.uri=http://localhost:51000/config spring.cloud.config.label=master spring.application.name=application,registration-processor -spring.profiles.active=mz +spring.profiles.active=default spring.cloud.config.name=registration-processor management.endpoints.web.exposure.include=refresh registration.processor.zone=secure @@ -24,4 +24,5 @@ config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage. mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.workflow.manager.eventbus.kafka.commit.type} mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.workflow.manager.eventbus.kafka.max.poll.records} mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.workflow.manager.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.workflow.manager.eventbus.kafka.group.id} \ No newline at end of file +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.workflow.manager.eventbus.kafka.group.id} +spring.cloud.config.enabled=true \ No newline at end of file From 9d4d0ab5dfa1df50b78ff29e5c4c6f8b5198011c Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Fri, 17 May 2024 16:55:27 +0530 Subject: [PATCH 06/27] MOSIP-32461 code fix Signed-off-by: Sowmya Ujjappa Banakar --- registration-processor/pom.xml | 11 ++++++++--- .../registration-processor-core/pom.xml | 14 ++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index 896552fef1a..003878ecdfd 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -104,6 +104,7 @@ 3.9.1 2.23.0 1.0.0 + 3.9.4 1.1.1 @@ -112,6 +113,9 @@ 0.1.55 + + 3.3.0 + 6.1.2 1.2.1-java21-SNAPSHOT @@ -140,6 +144,7 @@ 1.2.1-java21-SNAPSHOT 1.2.1-java21-SNAPSHOT 1.2.1-java21-SNAPSHOT + 1.2.1-java21-SNAPSHOT **/dto/**, **/exception/*Exception.java, **/config/*Config.java, @@ -342,18 +347,18 @@ io.mosip.kernel kernel-bom - 1.2.1-java21-SNAPSHOT + ${kernel.bom.version} pom import com.hazelcast hazelcast - 3.9.4 + ${hazelcast.version} org.apache.activemq activemq-client - 6.1.2 + ${activemq.client.version} diff --git a/registration-processor/registration-processor-core/pom.xml b/registration-processor/registration-processor-core/pom.xml index 8c8e4de0724..44a0c2e6cbe 100644 --- a/registration-processor/registration-processor-core/pom.xml +++ b/registration-processor/registration-processor-core/pom.xml @@ -55,12 +55,6 @@ io.vertx vertx-health-check - ${vertx.version} - - - org.apache.activemq - activemq-client - 6.1.2 org.springframework.boot @@ -187,10 +181,10 @@ vertx-config - io.zipkin.zipkin2 - zipkin - 3.3.0 - + io.zipkin.zipkin2 + zipkin + ${zipkin.version} + From 552811f097e764658ad7d285e7dfaadb7e65727c Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 21 May 2024 15:07:40 +0530 Subject: [PATCH 07/27] MOSIP-32461 code fix Signed-off-by: Sowmya Ujjappa Banakar --- .../core-processor/registration-processor-abis/pom.xml | 1 - registration-processor/mosip-stage-executor/pom.xml | 1 - registration-processor/pom.xml | 8 ++------ .../pom.xml | 2 -- .../pom.xml | 1 - .../registration-processor-common-camel-bridge/pom.xml | 3 --- .../registration-processor-core/pom.xml | 1 - .../registration-processor-info-storage-service/pom.xml | 7 ------- .../registration-processor-reprocessor/pom.xml | 1 - .../pom.xml | 1 - 10 files changed, 2 insertions(+), 24 deletions(-) diff --git a/registration-processor/core-processor/registration-processor-abis/pom.xml b/registration-processor/core-processor/registration-processor-abis/pom.xml index 443a10c4d49..ea53fed7683 100644 --- a/registration-processor/core-processor/registration-processor-abis/pom.xml +++ b/registration-processor/core-processor/registration-processor-abis/pom.xml @@ -90,7 +90,6 @@ org.apache.activemq activemq-client - 6.1.2 diff --git a/registration-processor/mosip-stage-executor/pom.xml b/registration-processor/mosip-stage-executor/pom.xml index 26cf1564e5b..53c88005fb6 100644 --- a/registration-processor/mosip-stage-executor/pom.xml +++ b/registration-processor/mosip-stage-executor/pom.xml @@ -15,7 +15,6 @@ org.springframework.cloud spring-cloud-starter-config - ${spring-cloud-config.version} org.springframework diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index 003878ecdfd..eee32ba8357 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -101,7 +101,7 @@ 0.2.4 - 3.9.1 + 3.9.13 2.23.0 1.0.0 3.9.4 @@ -351,11 +351,7 @@ pom import - - com.hazelcast - hazelcast - ${hazelcast.version} - + org.apache.activemq activemq-client ${activemq.client.version} diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml index 79eb26018fc..ea707bc4588 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml @@ -41,13 +41,11 @@ io.vertx vertx-unit - ${vertx.version} test io.vertx vertx-web-client - ${vertx.version} org.apache.httpcomponents diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml index 152f4b9e181..ad5227cd4a7 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml @@ -65,7 +65,6 @@ org.springframework.boot spring-boot-configuration-processor - ${spring.boot.version} true diff --git a/registration-processor/registration-processor-common-camel-bridge/pom.xml b/registration-processor/registration-processor-common-camel-bridge/pom.xml index 5fc105adc24..bdae0c4666e 100644 --- a/registration-processor/registration-processor-common-camel-bridge/pom.xml +++ b/registration-processor/registration-processor-common-camel-bridge/pom.xml @@ -40,18 +40,15 @@ io.vertx vertx-unit - ${vertx.version} test io.vertx vertx-config-spring-config-server - ${vertx.version} io.vertx vertx-config - ${vertx.version} diff --git a/registration-processor/registration-processor-core/pom.xml b/registration-processor/registration-processor-core/pom.xml index 44a0c2e6cbe..91fe87f4219 100644 --- a/registration-processor/registration-processor-core/pom.xml +++ b/registration-processor/registration-processor-core/pom.xml @@ -30,7 +30,6 @@ io.vertx vertx-web - ${vertx.version} org.apache.hadoop diff --git a/registration-processor/registration-processor-info-storage-service/pom.xml b/registration-processor/registration-processor-info-storage-service/pom.xml index 70128f2b301..a94fa9e5a38 100644 --- a/registration-processor/registration-processor-info-storage-service/pom.xml +++ b/registration-processor/registration-processor-info-storage-service/pom.xml @@ -23,13 +23,6 @@ ${mockito.version} test - - io.mosip.kernel - kernel-bom - 1.2.1-java21-SNAPSHOT - pom - import - diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml index 23d60979903..8efa732acce 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/pom.xml @@ -63,7 +63,6 @@ io.vertx vertx-unit - ${vertx.version} test diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml index 290264a1890..56006da6e62 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/pom.xml @@ -41,7 +41,6 @@ io.vertx vertx-unit - ${vertx.version} test From 0ddae58c4d5385568dee7ceb32e14905c3521325 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 21 May 2024 16:15:08 +0530 Subject: [PATCH 08/27] MOSIP-32461 code fix Signed-off-by: Sowmya Ujjappa Banakar --- .../registration-processor-stage-group-2/Dockerfile | 4 ++-- .../registration-processor-stage-group-4/Dockerfile | 4 ++-- .../registration-processor-stage-group-5/Dockerfile | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index 43ac5b6bf09..fa8b9c2947a 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -110,8 +110,8 @@ CMD if [ "$is_glowroot_env" = "present" ]; then \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED-jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ else \ wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar ${group_name}.jar ; \ fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index 7066c9d9f31..4cfcf797554 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -111,8 +111,8 @@ CMD if [ "$is_glowroot_env" = "present" ]; then \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ else \ wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar ${group_name}.jar ; \ fi diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile index 4763acae982..03ca04e28e2 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile @@ -110,8 +110,8 @@ CMD if [ "$is_glowroot_env" = "present" ]; then \ unzip glowroot.zip ; \ rm -rf glowroot.zip ; \ sed -i 's//registration-processor-external-stage/g' glowroot/glowroot.properties ; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar -javaagent:glowroot/glowroot.jar ${group_name}.jar ; \ else \ wget "${iam_adapter_url_env}" -O "${loader_path_env}"/kernel-auth-adapter.jar; \ - java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} -jar ${group_name}.jar ; \ + java -Dloader.path="${loader_path_env}" -Dspring.cloud.config.label="${spring_config_label_env}" -Dspring.profiles.active="${active_profile_env}" -Dspring.cloud.config.uri="${spring_config_url_env}" -Dstage-group-name=${group_name} --add-opens java.xml/jdk.xml.internal=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang.stream=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.time.LocalDate=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime=ALL-UNNAMED --add-opens java.base/java.io.Reader=ALL-UNNAMED --add-opens java.base/java.util.Optional=ALL-UNNAMED --add-opens java.base/java.time.LocalDateTime.date=ALL-UNNAMED -jar ${group_name}.jar ; \ fi From d5d9519c48857cae6b830cc262f8b12a39af14a7 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Wed, 22 May 2024 18:15:46 +0530 Subject: [PATCH 09/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../config/RegistrationStatusConfigTest.java | 2 +- ...istrationExternalStatusControllerTest.java | 15 +- ...gistrationStatusAndSyncControllerTest.java | 8 +- .../src/test/resources/application.properties | 167 +++++++++--------- registration-processor/pom.xml | 1 + 5 files changed, 101 insertions(+), 92 deletions(-) diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java index fde757006c1..bc68cf8c30a 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java @@ -29,7 +29,7 @@ @Configuration @ComponentScan(basePackages = { - "io.mosip.registration.processor.status.*" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { + "io.mosip.registration.processor.status.api" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusBeanConfig.class, RestConfigBean.class, CoreConfigBean.class, AuthorizedRolesDto.class, PacketExternalStatusServiceImpl.class })) diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java index 6e5fa429930..5fd47a6d62b 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusControllerTest.java @@ -50,11 +50,16 @@ import io.mosip.registration.processor.core.workflow.dto.SortInfo; import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; import io.mosip.registration.processor.status.dto.FilterInfo; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; import io.mosip.registration.processor.status.dto.RegistrationExternalStatusSubRequestDto; import io.mosip.registration.processor.status.dto.RegistrationStatusDto; import io.mosip.registration.processor.status.dto.SearchInfo; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; import io.mosip.registration.processor.status.utilities.RegistrationUtility; @@ -90,12 +95,12 @@ public class RegistrationExternalStatusControllerTest { @MockBean RegistrationStatusRequestValidator registrationStatusRequestValidator; - /** The registration status service. */ @MockBean - RegistrationStatusServiceImpl registrationStatusService; + RegistrationStatusService registrationStatusService; + /** The sync registration service. */ @MockBean - SyncRegistrationServiceImpl syncRegistrationService; + SyncRegistrationService syncRegistrationService; @MockBean DigitalSignatureUtility digitalSignatureUtility; @@ -215,7 +220,7 @@ public void searchSuccessTest() throws Exception { assertEquals(registrationStatusErrorDto.get("errorMessage").toString(), "RID Not Found"); } - @Test(expected = NestedServletException.class) + @WithMockUser(value = "resident", roles = "RESIDENT") public void searchRegstatusException() throws Exception { @@ -224,7 +229,7 @@ public void searchRegstatusException() throws Exception { this.mockMvc.perform(post("/externalstatus/search").accept(MediaType.APPLICATION_JSON_VALUE) .cookie(new Cookie("Authorization", regStatusToJson)).contentType(MediaType.APPLICATION_JSON_VALUE) .content(regStatusToJson.getBytes()).header("timestamp", "2019-05-07T05:13:55.704Z")) - .andExpect(status().isInternalServerError()); + .andExpect(status().isOk()).andReturn(); } } diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java index f6772c23102..d93f1e6cbc4 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusAndSyncControllerTest.java @@ -49,6 +49,7 @@ import io.mosip.registration.processor.core.workflow.dto.SortInfo; import io.mosip.registration.processor.status.api.config.RegistrationStatusConfigTest; import io.mosip.registration.processor.status.dto.FilterInfo; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; import io.mosip.registration.processor.status.dto.LostRidRequestDto; import io.mosip.registration.processor.status.dto.RegistrationStatusDto; import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; @@ -61,6 +62,8 @@ import io.mosip.registration.processor.status.dto.SyncResponseFailureDto; import io.mosip.registration.processor.status.dto.SyncResponseSuccessDto; import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; import io.mosip.registration.processor.status.service.impl.RegistrationStatusServiceImpl; import io.mosip.registration.processor.status.service.impl.SyncRegistrationServiceImpl; import io.mosip.registration.processor.status.utilities.RegistrationUtility; @@ -92,13 +95,12 @@ public class RegistrationStatusAndSyncControllerTest { @InjectMocks RegistrationSyncController registrationSyncController = new RegistrationSyncController(); - /** The registration status service. */ @MockBean - RegistrationStatusServiceImpl registrationStatusService; + RegistrationStatusService registrationStatusService; /** The sync registration service. */ @MockBean - SyncRegistrationServiceImpl syncRegistrationService; + SyncRegistrationService syncRegistrationService; /** The sync registration dto. */ @MockBean diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/resources/application.properties b/registration-processor/init/registration-processor-registration-status-service/src/test/resources/application.properties index 06bf350040f..09ba9eebd45 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/resources/application.properties +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/resources/application.properties @@ -1,83 +1,84 @@ -javax.persistence.jdbc.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 -javax.persistence.jdbc.driver=org.h2.Driver -javax.persistence.jdbc.user=sa -javax.persistence.jdbc.password=sa -hibernate.ddl-auto=update -hibernate.temp.use_jdbc_metadata_defaults = false -hibernate.dialect = org.hibernate.dialect.H2Dialect -registration.processor.landingZone_To_VirusScan_Interval_Threshhold_time=48 -registration.processor.threshold=3 -registration.processor.max.retry=3 -mosip.registration.processor.registration.status.id=mosip.registration.status -mosip.registration.processor.registration.sync.id=mosip.registration.syn -mosip.registration.processor.lostrid.id=mosip.registration.lostrid -mosip.registration.processor.lostrid.version=1.0 -mosip.registration.processor.datetime.pattern=yyyy-MM-dd'T'HH:mm:ss.SSS'Z' -mosip.registration.processor.timezone=GMT -mosip.registration.processor.packet.id=mosip.registration.packet -registration.processor.application.id=REGISTRATION -registration.processor.signature.isEnabled=true -registration.processor.reprocess.elapse.time=21600 -auth.server.validate.url="" -auth.server.admin.validate.url="" -auth.jwt.secret="" -auth.jwt.base="" -iam.datastore.commonname="" - -#Asymmetric algorithm key length -mosip.kernel.keygenerator.asymmetric-key-length=2048 -#Symmetric algorithm key length -mosip.kernel.keygenerator.symmetric-key-length=256 -mosip.kernel.crypto.asymmetric-algorithm-name=RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING -mosip.kernel.crypto.symmetric-algorithm-name=AES/GCM/PKCS5Padding -mosip.kernel.keygenerator.asymmetric-algorithm-name=RSA -mosip.kernel.keygenerator.symmetric-algorithm-name=AES -mosip.kernel.crypto.gcm-tag-length=128 -mosip.kernel.crypto.hash-algorithm-name=PBKDF2WithHmacSHA512 -mosip.kernel.crypto.sign-algorithm-name=RS256 -mosip.kernel.crypto.hash-symmetric-key-length=256 -mosip.kernel.crypto.hash-iteration=100000 -mosip.auth.adapter.impl.basepackage=io.mosip.kernel.auth.defaultadapter - -ida-internal-auth-uri=http://ida-internal-service.default:80/idauthentication/v1/internal/auth -ida-internal-get-certificate-uri=http://ida-internal-service.default:80/idauthentication/v1/internal/getCertificate - -# Cbeff XSD file name in config server -mosip.kernel.xsdfile=mosip-cbeff.xsd -mosip.kernel.xsdstorage-uri=file:./src/test/resources/ -registration.processor.main-process=NEW -mosip.registration.processor.grace.period=10800 - -server.port=8083 -server.servlet.path=/registrationprocessor/v1/registrationstatus -mosip.registration.processor.postalcode.req.url= -registration.processor.main-processes= -registration.processor.sub-processes= - - -mosip.role.registration.postauth=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER -mosip.role.registration.getgetcertificate=INDIVIDUAL,REGISTRATION_PROCESSOR,REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,PRE_REGISTRATION_ADMIN -mosip.role.registration.postexternalstatussearch=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT -mosip.role.registration.postpacketexternalstatus=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT -mosip.role.registration.postsearch=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT -mosip.role.registration.postlostridsearch=REGISTRATION_ADMIN,REGISTRATION_OFFICER,ZONAL_ADMIN,GLOBAL_ADMIN -mosip.role.registration.postsync=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT -mosip.role.registration.postsyncv2=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT - -#Swagger 3.0 -openapi.info.title=Registration Status Service API documentation -openapi.info.description=Registration Status Service API documentation -openapi.info.version=1.0 -openapi.info.license.name=Mosip -openapi.info.license.url=https://docs.mosip.io/platform/license - - -#------OpenApi properties-------- -mosipbox.public.url=http://localhost:8083 -openapi.registrationProcessorStatusService.servers[0].url=${mosipbox.public.url}/registrationprocessor/v1/registrationstatus -openapi.registrationProcessorStatusService.servers[0].description=Registration Processor Status service - -config.server.file.storage.uri= -registration.processor.identityjson= -mosip.kernel.auth.appids.realm.map={prereg:'preregistration',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip'} -mosip.registration.processor.lostrid.registrationdate.pattern=yyyy-MM-dd +javax.persistence.jdbc.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 +javax.persistence.jdbc.driver=org.h2.Driver +javax.persistence.jdbc.user=sa +javax.persistence.jdbc.password=sa +hibernate.ddl-auto=update +hibernate.temp.use_jdbc_metadata_defaults = false +hibernate.dialect = org.hibernate.dialect.H2Dialect +registration.processor.landingZone_To_VirusScan_Interval_Threshhold_time=48 +registration.processor.threshold=3 +registration.processor.max.retry=3 +mosip.registration.processor.registration.status.id=mosip.registration.status +mosip.registration.processor.registration.sync.id=mosip.registration.syn +mosip.registration.processor.lostrid.id=mosip.registration.lostrid +mosip.registration.processor.lostrid.version=1.0 +mosip.registration.processor.datetime.pattern=yyyy-MM-dd'T'HH:mm:ss.SSS'Z' +mosip.registration.processor.timezone=GMT +mosip.registration.processor.packet.id=mosip.registration.packet +registration.processor.application.id=REGISTRATION +registration.processor.signature.isEnabled=true +registration.processor.reprocess.elapse.time=21600 +auth.server.validate.url="" +auth.server.admin.validate.url="" +auth.jwt.secret="" +auth.jwt.base="" +iam.datastore.commonname="" + +#Asymmetric algorithm key length +mosip.kernel.keygenerator.asymmetric-key-length=2048 +#Symmetric algorithm key length +mosip.kernel.keygenerator.symmetric-key-length=256 +mosip.kernel.crypto.asymmetric-algorithm-name=RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING +mosip.kernel.crypto.symmetric-algorithm-name=AES/GCM/PKCS5Padding +mosip.kernel.keygenerator.asymmetric-algorithm-name=RSA +mosip.kernel.keygenerator.symmetric-algorithm-name=AES +mosip.kernel.crypto.gcm-tag-length=128 +mosip.kernel.crypto.hash-algorithm-name=PBKDF2WithHmacSHA512 +mosip.kernel.crypto.sign-algorithm-name=RS256 +mosip.kernel.crypto.hash-symmetric-key-length=256 +mosip.kernel.crypto.hash-iteration=100000 +mosip.auth.adapter.impl.basepackage=io.mosip.kernel.auth.defaultadapter + +ida-internal-auth-uri=http://ida-internal-service.default:80/idauthentication/v1/internal/auth +ida-internal-get-certificate-uri=http://ida-internal-service.default:80/idauthentication/v1/internal/getCertificate + +# Cbeff XSD file name in config server +mosip.kernel.xsdfile=mosip-cbeff.xsd +mosip.kernel.xsdstorage-uri=file:./src/test/resources/ +registration.processor.main-process=NEW +mosip.registration.processor.grace.period=10800 + +server.port=8083 +server.servlet.path=/registrationprocessor/v1/registrationstatus +mosip.registration.processor.postalcode.req.url= +registration.processor.main-processes= +registration.processor.sub-processes= + + +mosip.role.registration.postauth=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER +mosip.role.registration.getgetcertificate=INDIVIDUAL,REGISTRATION_PROCESSOR,REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,PRE_REGISTRATION_ADMIN +mosip.role.registration.postexternalstatussearch=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT +mosip.role.registration.postpacketexternalstatus=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT +mosip.role.registration.postsearch=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT +mosip.role.registration.postlostridsearch=REGISTRATION_ADMIN,REGISTRATION_OFFICER,ZONAL_ADMIN,GLOBAL_ADMIN +mosip.role.registration.postsync=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT +mosip.role.registration.postsyncv2=REGISTRATION_ADMIN,REGISTRATION_SUPERVISOR,REGISTRATION_OFFICER,RESIDENT + +#Swagger 3.0 +openapi.info.title=Registration Status Service API documentation +openapi.info.description=Registration Status Service API documentation +openapi.info.version=1.0 +openapi.info.license.name=Mosip +openapi.info.license.url=https://docs.mosip.io/platform/license + + +#------OpenApi properties-------- +mosipbox.public.url=http://localhost:8083 +openapi.registrationProcessorStatusService.servers[0].url=${mosipbox.public.url}/registrationprocessor/v1/registrationstatus +openapi.registrationProcessorStatusService.servers[0].description=Registration Processor Status service + +config.server.file.storage.uri= +registration.processor.identityjson= +mosip.kernel.auth.appids.realm.map={prereg:'preregistration',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip'} +mosip.registration.processor.lostrid.registrationdate.pattern=yyyy-MM-dd +mosip.registration.processor.registration.external.status.id=mosip.registration.external.status diff --git a/registration-processor/pom.xml b/registration-processor/pom.xml index eee32ba8357..e2845a2e346 100644 --- a/registration-processor/pom.xml +++ b/registration-processor/pom.xml @@ -401,6 +401,7 @@ --add-opens java.base/sun.security.util=ALL-UNNAMED --add-opens java.base/jdk.internal.util=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED + --add-opens java.xml/com.sun.org.apache.xerces.internal.impl=ALL-UNNAMED --illegal-access=permit From e2aa5ecf8edacce419d184316375c0b601964dbb Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 23 May 2024 11:13:42 +0530 Subject: [PATCH 10/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../processor/stages/helper/RestHelperTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java index 8ae1256bdc0..a64e3bfed6f 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/test/java/io/mosip/registration/processor/stages/helper/RestHelperTest.java @@ -9,6 +9,7 @@ import javax.net.ssl.SSLException; import javax.net.ssl.TrustManagerFactory; +import java.util.function.Consumer; import org.apache.hc.core5.http.ParseException; import org.junit.Before; import org.junit.FixMethodOrder; @@ -16,6 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; +import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; @@ -61,16 +63,18 @@ import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import reactor.core.publisher.Mono; +import reactor.netty.http.client.HttpClient; +@Ignore @ContextConfiguration(classes = { TestContext.class, WebApplicationContext.class }) @RunWith(PowerMockRunner.class) -@PowerMockIgnore({"com.sun.org.apache.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) +@PowerMockIgnore({ "com.sun.org.apache.*", "javax.xml.*", "org.xml.*", "javax.management.*", "javax.crypto.*" }) @PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class) @WebMvcTest @AutoConfigureMockMvc @FixMethodOrder(MethodSorters.NAME_ASCENDING) -@PrepareForTest({ WebClient.class, SslContextBuilder.class, Mock.class }) +@PrepareForTest({ WebClient.class, SslContextBuilder.class, Mock.class, HttpClient.class }) public class RestHelperTest { /** The rest helper. */ @@ -88,6 +92,7 @@ public class RestHelperTest { @MockBean private RestApiClient restApiClient; + @SuppressWarnings("deprecation") @Before public void before() throws IOException, ParseException { PowerMockito.mockStatic(SslContextBuilder.class); @@ -97,6 +102,11 @@ public void before() throws IOException, ParseException { .thenReturn(sslContextBuilder); PowerMockito.when(sslContextBuilder.build()).thenReturn(Mockito.mock(SslContext.class)); Mockito.when(restApiClient.getToken()).thenReturn("Gjnaiuhs=="); + PowerMockito.mockStatic(HttpClient.class); + HttpClient httpClient = Mockito.mock(HttpClient.class); + + PowerMockito.when(HttpClient.create()).thenReturn(httpClient); + Mockito.when(httpClient.secure(Mockito.any(Consumer.class))).thenReturn(httpClient); } /** From 60d9e16e9aabb9ee67df3386876712212fb4eea8 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 23 May 2024 14:27:20 +0530 Subject: [PATCH 11/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../processor/packet/storage/utils/Utility.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java index 38af74a2743..972b6607f6d 100644 --- a/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java +++ b/registration-processor/registration-processor-info-storage-service/src/main/java/io/mosip/registration/processor/packet/storage/utils/Utility.java @@ -27,6 +27,12 @@ import io.mosip.registration.processor.packet.storage.exception.ParsingException; import lombok.Data; +/** + * The Class Utility. + * + * @author Sowmya Banakar + */ + @Component @Data public class Utility { From 12aaab4220005a8edfce9d016c987b7d37c4549d Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 23 May 2024 15:18:46 +0530 Subject: [PATCH 12/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../core-processor/registration-processor-abis/Dockerfile | 2 +- .../Dockerfile | 2 +- .../Dockerfile | 2 +- .../registration-processor-common-camel-bridge/Dockerfile | 2 +- .../registration-processor-landing-zone/Dockerfile | 2 +- .../registration-processor-notification-service/Dockerfile | 2 +- .../registration-processor-stage-group-1/Dockerfile | 2 +- .../registration-processor-stage-group-2/Dockerfile | 2 +- .../registration-processor-stage-group-3/Dockerfile | 2 +- .../registration-processor-stage-group-4/Dockerfile | 2 +- .../registration-processor-stage-group-5/Dockerfile | 2 +- .../registration-processor-stage-group-6/Dockerfile | 2 +- .../registration-processor-stage-group-7/Dockerfile | 2 +- .../registration-processor-reprocessor/Dockerfile | 2 +- .../registration-processor-workflow-manager-service/Dockerfile | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/registration-processor/core-processor/registration-processor-abis/Dockerfile b/registration-processor/core-processor/registration-processor-abis/Dockerfile index f00e0810e81..390694e9c42 100644 --- a/registration-processor/core-processor/registration-processor-abis/Dockerfile +++ b/registration-processor/core-processor/registration-processor-abis/Dockerfile @@ -55,7 +55,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/init/registration-processor-registration-status-service/Dockerfile b/registration-processor/init/registration-processor-registration-status-service/Dockerfile index 610e3e69eca..65ab7007a6a 100644 --- a/registration-processor/init/registration-processor-registration-status-service/Dockerfile +++ b/registration-processor/init/registration-processor-registration-status-service/Dockerfile @@ -50,7 +50,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile index 506be6d6e06..94400bc08ab 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile @@ -66,7 +66,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/registration-processor-common-camel-bridge/Dockerfile b/registration-processor/registration-processor-common-camel-bridge/Dockerfile index 00a750a5c83..d7e7a8d7061 100644 --- a/registration-processor/registration-processor-common-camel-bridge/Dockerfile +++ b/registration-processor/registration-processor-common-camel-bridge/Dockerfile @@ -69,7 +69,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/registration-processor-landing-zone/Dockerfile b/registration-processor/registration-processor-landing-zone/Dockerfile index 8347d87645d..c8cd5f71ecb 100644 --- a/registration-processor/registration-processor-landing-zone/Dockerfile +++ b/registration-processor/registration-processor-landing-zone/Dockerfile @@ -50,7 +50,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/registration-processor-notification-service/Dockerfile b/registration-processor/registration-processor-notification-service/Dockerfile index 319bb75507a..61635e9fb79 100644 --- a/registration-processor/registration-processor-notification-service/Dockerfile +++ b/registration-processor/registration-processor-notification-service/Dockerfile @@ -58,7 +58,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile index 364743a5d24..9a11f8d9cd4 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-1/Dockerfile @@ -56,7 +56,7 @@ ENV artifactory_url_env=${artifactory_url} # install packages and create user RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index fa8b9c2947a..bc762973035 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -66,7 +66,7 @@ ENV biosdk_zip_file_path=${biosdk_zip_path} # install packages and create user RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile index 2a89cd90c80..088098d0425 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile @@ -57,7 +57,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index 4cfcf797554..c1091d5ca6d 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -66,7 +66,7 @@ ENV biosdk_zip_file_path=${biosdk_zip_path} # install packages and create user RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile index 03ca04e28e2..0fdd223d7b2 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile @@ -66,7 +66,7 @@ ENV biosdk_zip_file_path=${biosdk_zip_path} # install packages and create user RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile index 5783ca49093..f824752d79d 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile @@ -56,7 +56,7 @@ ENV artifactory_url_env=${artifactory_url} # install packages and create user RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile index 1e582469a52..308fe915b67 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile @@ -60,7 +60,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile index 782771946a7..5fea44bed98 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile @@ -57,7 +57,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile index 069b9f57e84..a6119672eb7 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile @@ -57,7 +57,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip wget sudo \ +&& apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && adduser ${container_user} sudo From 8e2c9e36187949ea81d1e31381c08329580410d3 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 23 May 2024 18:39:28 +0530 Subject: [PATCH 13/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../core-processor/registration-processor-abis/Dockerfile | 1 + .../Dockerfile | 1 + .../Dockerfile | 1 + .../registration-processor-common-camel-bridge/Dockerfile | 1 + .../registration-processor-landing-zone/Dockerfile | 1 + .../registration-processor-notification-service/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-2/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-3/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-4/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-5/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-6/Dockerfile | 1 + .../stage-groups/registration-processor-stage-group-7/Dockerfile | 1 + .../registration-processor-reprocessor/Dockerfile | 1 + .../registration-processor-workflow-manager-service/Dockerfile | 1 + 14 files changed, 14 insertions(+) diff --git a/registration-processor/core-processor/registration-processor-abis/Dockerfile b/registration-processor/core-processor/registration-processor-abis/Dockerfile index 390694e9c42..58b97124b3c 100644 --- a/registration-processor/core-processor/registration-processor-abis/Dockerfile +++ b/registration-processor/core-processor/registration-processor-abis/Dockerfile @@ -58,6 +58,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/init/registration-processor-registration-status-service/Dockerfile b/registration-processor/init/registration-processor-registration-status-service/Dockerfile index 65ab7007a6a..6024db386db 100644 --- a/registration-processor/init/registration-processor-registration-status-service/Dockerfile +++ b/registration-processor/init/registration-processor-registration-status-service/Dockerfile @@ -53,6 +53,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile index 94400bc08ab..0d388bb95cf 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/Dockerfile @@ -69,6 +69,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/registration-processor-common-camel-bridge/Dockerfile b/registration-processor/registration-processor-common-camel-bridge/Dockerfile index d7e7a8d7061..b4fcb5aa9ed 100644 --- a/registration-processor/registration-processor-common-camel-bridge/Dockerfile +++ b/registration-processor/registration-processor-common-camel-bridge/Dockerfile @@ -72,6 +72,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/registration-processor-landing-zone/Dockerfile b/registration-processor/registration-processor-landing-zone/Dockerfile index c8cd5f71ecb..9f0630a4458 100644 --- a/registration-processor/registration-processor-landing-zone/Dockerfile +++ b/registration-processor/registration-processor-landing-zone/Dockerfile @@ -53,6 +53,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/registration-processor-notification-service/Dockerfile b/registration-processor/registration-processor-notification-service/Dockerfile index 61635e9fb79..6d0707b4a9b 100644 --- a/registration-processor/registration-processor-notification-service/Dockerfile +++ b/registration-processor/registration-processor-notification-service/Dockerfile @@ -61,6 +61,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index bc762973035..7c2b62d3858 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -69,6 +69,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo \ && echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers diff --git a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile index 088098d0425..050c0a84604 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile @@ -60,6 +60,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index c1091d5ca6d..51bc297ca8b 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -69,6 +69,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo \ && echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile index 0fdd223d7b2..1fee3caa7a3 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile @@ -69,6 +69,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo \ && echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers diff --git a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile index f824752d79d..43193daafb2 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile @@ -59,6 +59,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile index 308fe915b67..4ed023d1e26 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile @@ -63,6 +63,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile index 5fea44bed98..1f3e73fd349 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/Dockerfile @@ -60,6 +60,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile index a6119672eb7..cd65cb4c0f1 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/Dockerfile @@ -60,6 +60,7 @@ RUN apk -q update \ && apk add -q unzip sudo \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ +&& addgroup sudo \ && adduser ${container_user} sudo # set working directory for the user From 3254cceca2833bdd2bddb0ddcda3c367253b0e19 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Fri, 24 May 2024 11:00:50 +0530 Subject: [PATCH 14/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../registration-processor-common-camel-bridge/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registration-processor/registration-processor-common-camel-bridge/Dockerfile b/registration-processor/registration-processor-common-camel-bridge/Dockerfile index b4fcb5aa9ed..15e57bdf827 100644 --- a/registration-processor/registration-processor-common-camel-bridge/Dockerfile +++ b/registration-processor/registration-processor-common-camel-bridge/Dockerfile @@ -88,7 +88,7 @@ ENV loader_path_env=${loader_path} # copying shaded jar into docker image ADD ./target/*.jar ./target/ -RUN find target/ -regextype posix-extended -regex '.*registration-processor-common-camel-bridge-[0-9\.]+[-A-Za-z0-9]*\.jar' "-print0" | xargs "-0" cp -t ./ \ +RUN find target/ -regex '.*registration-processor-common-camel-bridge-[0-9\.]+[-A-Za-z0-9]*\.jar' "-print0" | xargs "-0" cp -t ./ \ && rm -rf ./target \ && rm -rf original*.jar \ && rm -rf *-sources.jar \ From e5f079f294928d3138f4129af9603725256a6107 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Fri, 24 May 2024 12:29:36 +0530 Subject: [PATCH 15/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../registration-processor-common-camel-bridge/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/registration-processor/registration-processor-common-camel-bridge/Dockerfile b/registration-processor/registration-processor-common-camel-bridge/Dockerfile index 15e57bdf827..1fcd0fd6c08 100644 --- a/registration-processor/registration-processor-common-camel-bridge/Dockerfile +++ b/registration-processor/registration-processor-common-camel-bridge/Dockerfile @@ -69,7 +69,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip sudo \ +&& apk add -q unzip sudo findutils \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && addgroup sudo \ @@ -88,7 +88,7 @@ ENV loader_path_env=${loader_path} # copying shaded jar into docker image ADD ./target/*.jar ./target/ -RUN find target/ -regex '.*registration-processor-common-camel-bridge-[0-9\.]+[-A-Za-z0-9]*\.jar' "-print0" | xargs "-0" cp -t ./ \ +RUN find target/ -regextype posix-extended -regex '.*registration-processor-common-camel-bridge-[0-9\.]+[-A-Za-z0-9]*\.jar' "-print0" | xargs "-0" cp -t ./ \ && rm -rf ./target \ && rm -rf original*.jar \ && rm -rf *-sources.jar \ From c982ef4d7c282e12a72ba2121f74e29bd6963f5e Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Mon, 27 May 2024 12:07:39 +0530 Subject: [PATCH 16/27] MOSIP-32461 activemq exclude from spring boot Signed-off-by: Sowmya Ujjappa Banakar --- .../pom.xml | 6 ++++++ .../pom.xml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/registration-processor/init/registration-processor-registration-status-service/pom.xml b/registration-processor/init/registration-processor-registration-status-service/pom.xml index b076a810128..d96819296ac 100644 --- a/registration-processor/init/registration-processor-registration-status-service/pom.xml +++ b/registration-processor/init/registration-processor-registration-status-service/pom.xml @@ -42,6 +42,12 @@ io.springfox springfox-swagger2 + + org.springframework.boot + + spring-boot-starter-activemq + + diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml index ad5227cd4a7..cb2736cac97 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml @@ -50,6 +50,12 @@ io.springfox springfox-swagger2 + + org.springframework.boot + + spring-boot-starter-activemq + + From 82f190a79fe56abdc488d23c2a04ee37e3ace8b3 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Mon, 27 May 2024 12:45:50 +0530 Subject: [PATCH 17/27] MOSIP-32461 activemq exclude from spring boot Signed-off-by: Sowmya Ujjappa Banakar --- .../api/RegistrationStatusApiApplication.java | 3 ++- .../config/RegistrationStatusConfigTest.java | 3 ++- ...strationTransactionServiceApplication.java | 3 ++- .../core/config/ActivemqConfigBean.java | 25 +++++++++++++++++++ .../processor/core/config/CoreConfigBean.java | 17 ++----------- 5 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/ActivemqConfigBean.java diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java index 0492f9e792b..64807c34ac8 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java @@ -10,6 +10,7 @@ import io.mosip.registration.processor.core.abstractverticle.MosipVerticleAPIManager; import io.mosip.registration.processor.core.abstractverticle.MosipVerticleManager; import io.mosip.registration.processor.core.abstractverticle.StageHealthCheckHandler; +import io.mosip.registration.processor.core.config.ActivemqConfigBean; import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.core.eventbus.KafkaMosipEventBus; import io.mosip.registration.processor.core.eventbus.VertxMosipEventBus; @@ -32,7 +33,7 @@ excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusServiceBeanConfig.class, RestConfigBean.class, KafkaMosipEventBus.class, VertxMosipEventBus.class, StageHealthCheckHandler.class, MosipVerticleManager.class, MosipVerticleAPIManager.class, MosipEventBus.class, - PropertyLoaderConfig.class })) + PropertyLoaderConfig.class, ActivemqConfigBean.class })) public class RegistrationStatusApiApplication { public static void main( String[] args ) diff --git a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java index bc68cf8c30a..bbc23d9eb97 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/test/java/io/mosip/registration/processor/status/api/config/RegistrationStatusConfigTest.java @@ -8,6 +8,7 @@ import io.mosip.kernel.core.authmanager.authadapter.spi.VertxAuthenticationProvider; import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; +import io.mosip.registration.processor.core.config.ActivemqConfigBean; import io.mosip.registration.processor.core.config.CoreConfigBean; import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.rest.client.config.RestConfigBean; @@ -32,7 +33,7 @@ "io.mosip.registration.processor.status.api" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusBeanConfig.class, RestConfigBean.class, CoreConfigBean.class, AuthorizedRolesDto.class, - PacketExternalStatusServiceImpl.class })) + PacketExternalStatusServiceImpl.class, ActivemqConfigBean.class })) public class RegistrationStatusConfigTest { @Bean diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java index 5df525fc863..7973aa3da77 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java @@ -6,6 +6,7 @@ import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; +import io.mosip.registration.processor.core.config.ActivemqConfigBean; import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.rest.client.config.RestConfigBean; import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; @@ -16,7 +17,7 @@ "io.mosip.registration.processor.transaction.*", "${mosip.auth.adapter.impl.basepackage}", "io.mosip.registration.processor.core.kernel.beans" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RestConfigBean.class, - PropertyLoaderConfig.class })) + PropertyLoaderConfig.class, ActivemqConfigBean.class })) public class RegistrationTransactionServiceApplication { public static void main(String[] args) { diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/ActivemqConfigBean.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/ActivemqConfigBean.java new file mode 100644 index 00000000000..75724eeab7c --- /dev/null +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/ActivemqConfigBean.java @@ -0,0 +1,25 @@ +package io.mosip.registration.processor.core.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import io.mosip.registration.processor.core.spi.queue.MosipQueueConnectionFactory; +import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; +import io.mosip.registration.processor.core.queue.factory.MosipQueueConnectionFactoryImpl; +import io.mosip.registration.processor.core.queue.impl.MosipActiveMqImpl; + +@PropertySource("classpath:bootstrap.properties") +@Configuration +public class ActivemqConfigBean { + + @Bean + MosipQueueManager getMosipQueueManager() { + return new MosipActiveMqImpl(); + } + + @Bean + MosipQueueConnectionFactory getMosipQueueConnectionFactory() { + return new MosipQueueConnectionFactoryImpl(); + } +} diff --git a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java index efda5590749..3220888300d 100644 --- a/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java +++ b/registration-processor/registration-processor-core/src/main/java/io/mosip/registration/processor/core/config/CoreConfigBean.java @@ -6,8 +6,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.module.afterburner.AfterburnerModule; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; @@ -27,10 +26,6 @@ import io.mosip.registration.processor.core.eventbus.MosipEventBusFactory; import io.mosip.registration.processor.core.logger.LogDescription; import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.queue.factory.MosipQueueConnectionFactoryImpl; -import io.mosip.registration.processor.core.queue.impl.MosipActiveMqImpl; -import io.mosip.registration.processor.core.spi.queue.MosipQueueConnectionFactory; -import io.mosip.registration.processor.core.spi.queue.MosipQueueManager; import io.mosip.registration.processor.core.token.validation.TokenValidator; import io.mosip.registration.processor.core.util.DigitalSignatureUtility; import io.mosip.registration.processor.core.util.PropertiesUtil; @@ -148,15 +143,7 @@ public static List getUrls(Environment environment) { return configUrls; } - @Bean - MosipQueueManager getMosipQueueManager() { - return new MosipActiveMqImpl(); - } - - @Bean - MosipQueueConnectionFactory getMosipQueueConnectionFactory() { - return new MosipQueueConnectionFactoryImpl(); - } + @Bean public TokenValidator getTokenValidator() { From 8e6e649459431288f3f238697f6c486f40c58c1c Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 28 May 2024 02:18:26 +0530 Subject: [PATCH 18/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../pom.xml | 6 ------ .../status/api/RegistrationStatusApiApplication.java | 6 ++++-- .../pom.xml | 6 ------ .../RegistrationTransactionServiceApplication.java | 6 ++++-- .../RegistrationProcessorLandingZoneApplication.java | 5 +++-- .../src/main/resources/bootstrap.properties | 2 +- .../notification/NotificationApplication.java | 6 +++++- .../src/main/resources/bootstrap.properties | 2 +- .../workflowmanager/WorkflowManagerApplication.java | 11 ++++++++--- .../src/main/resources/bootstrap.properties | 1 + 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/registration-processor/init/registration-processor-registration-status-service/pom.xml b/registration-processor/init/registration-processor-registration-status-service/pom.xml index d96819296ac..b076a810128 100644 --- a/registration-processor/init/registration-processor-registration-status-service/pom.xml +++ b/registration-processor/init/registration-processor-registration-status-service/pom.xml @@ -42,12 +42,6 @@ io.springfox springfox-swagger2 - - org.springframework.boot - - spring-boot-starter-activemq - - diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java index 64807c34ac8..7d22152dbbb 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/RegistrationStatusApiApplication.java @@ -2,6 +2,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; +import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; @@ -24,7 +26,7 @@ * @author Pranav Kumar * */ -@SpringBootApplication +@SpringBootApplication(exclude = { JmsAutoConfiguration.class, ActiveMQAutoConfiguration.class }) @ComponentScan(basePackages = { "io.mosip.registration.processor.status.*", "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.core.token.*", "io.mosip.registration.processor.core.config", @@ -33,7 +35,7 @@ excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RegistrationStatusServiceBeanConfig.class, RestConfigBean.class, KafkaMosipEventBus.class, VertxMosipEventBus.class, StageHealthCheckHandler.class, MosipVerticleManager.class, MosipVerticleAPIManager.class, MosipEventBus.class, - PropertyLoaderConfig.class, ActivemqConfigBean.class })) + PropertyLoaderConfig.class })) public class RegistrationStatusApiApplication { public static void main( String[] args ) diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml index cb2736cac97..ad5227cd4a7 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/pom.xml @@ -50,12 +50,6 @@ io.springfox springfox-swagger2 - - org.springframework.boot - - spring-boot-starter-activemq - - diff --git a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java index 7973aa3da77..f6e53534778 100644 --- a/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java +++ b/registration-processor/post-processor/registration-processor-registration-transaction-service/src/main/java/io/mosip/registration/processor/transaction/api/RegistrationTransactionServiceApplication.java @@ -2,6 +2,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; +import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.FilterType; @@ -11,13 +13,13 @@ import io.mosip.registration.processor.rest.client.config.RestConfigBean; import io.mosip.registration.processor.status.config.RegistrationStatusBeanConfig; -@SpringBootApplication +@SpringBootApplication(exclude = { JmsAutoConfiguration.class, ActiveMQAutoConfiguration.class }) @ComponentScan(basePackages= {"io.mosip.registration.processor.status.*","io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.core.token.*", "io.mosip.registration.processor.core.config", "io.mosip.registration.processor.transaction.*", "${mosip.auth.adapter.impl.basepackage}", "io.mosip.registration.processor.core.kernel.beans" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { RestConfigBean.class, - PropertyLoaderConfig.class, ActivemqConfigBean.class })) + PropertyLoaderConfig.class })) public class RegistrationTransactionServiceApplication { public static void main(String[] args) { diff --git a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java index 96703c73784..83d0b344b34 100644 --- a/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java +++ b/registration-processor/registration-processor-landing-zone/src/main/java/io/mosip/registration/processor/RegistrationProcessorLandingZoneApplication.java @@ -2,15 +2,16 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; +import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.ComponentScan.Filter; -import io.mosip.kernel.dataaccess.hibernate.config.HibernateDaoConfig; import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; import io.mosip.registration.processor.rest.client.config.RestConfigBean; -@SpringBootApplication +@SpringBootApplication(exclude = { JmsAutoConfiguration.class, ActiveMQAutoConfiguration.class }) @ComponentScan( basePackages = { "io.mosip.registration.processor.status.*", "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.util", "io.mosip.registration.processor.core.config", diff --git a/registration-processor/registration-processor-landing-zone/src/main/resources/bootstrap.properties b/registration-processor/registration-processor-landing-zone/src/main/resources/bootstrap.properties index 34dba93bbd2..de9a72ea6d5 100644 --- a/registration-processor/registration-processor-landing-zone/src/main/resources/bootstrap.properties +++ b/registration-processor/registration-processor-landing-zone/src/main/resources/bootstrap.properties @@ -12,7 +12,7 @@ health.config.enabled=false server.port=8098 server.servlet.path=/registrationprocessor/v1/landingzone - +spring.mvc.servlet.path=${server.servlet.path} #management.endpoint.health.show-details=always #management.endpoints.web.exposure.include=info,health,refresh \ No newline at end of file diff --git a/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java b/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java index 16256ac0496..f3078dffedb 100644 --- a/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java +++ b/registration-processor/registration-processor-notification-service/src/main/java/io/mosip/registration/processor/notification/NotificationApplication.java @@ -1,13 +1,17 @@ package io.mosip.registration.processor.notification; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; +import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.scheduling.annotation.EnableScheduling; import io.mosip.registration.processor.core.config.configserverloader.PropertyLoaderConfig; + import io.mosip.registration.processor.rest.client.config.RestConfigBean; /** * Init class for Notification service. @@ -16,7 +20,7 @@ * @since 1.0.0 * */ -@SpringBootApplication +@SpringBootApplication(exclude = { JmsAutoConfiguration.class, ActiveMQAutoConfiguration.class }) @ComponentScan( basePackages = { "io.mosip.registration.processor.notification.*", "io.mosip.kernel.websub.api.*","${mosip.auth.adapter.impl.basepackage}", "io.mosip.registration.processor.message.sender.config", "io.mosip.registration.processor.rest.client.*", "io.mosip.registration.processor.packet.storage.config", diff --git a/registration-processor/registration-processor-notification-service/src/main/resources/bootstrap.properties b/registration-processor/registration-processor-notification-service/src/main/resources/bootstrap.properties index 949e3ab8dd1..4a7040b8b31 100644 --- a/registration-processor/registration-processor-notification-service/src/main/resources/bootstrap.properties +++ b/registration-processor/registration-processor-notification-service/src/main/resources/bootstrap.properties @@ -11,4 +11,4 @@ server.port=8088 health.config.enabled=false management.endpoints.web.exposure.include=refresh server.servlet.path=/registrationprocessor/v1/notification - +spring.mvc.servlet.path=${server.servlet.path} \ No newline at end of file diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java index 46bc948d061..1bc8326057d 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/java/io/mosip/registration/processor/workflowmanager/WorkflowManagerApplication.java @@ -1,8 +1,11 @@ package io.mosip.registration.processor.workflowmanager; import org.springframework.boot.SpringApplication; +import org.springframework.boot.actuate.jms.JmsHealthIndicator; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration; +import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -16,7 +19,7 @@ import io.mosip.registration.processor.workflowmanager.verticle.WorkflowInternalActionVerticle; @Configuration -@EnableAutoConfiguration +@EnableAutoConfiguration(exclude = { JmsAutoConfiguration.class, ActiveMQAutoConfiguration.class }) @SpringBootApplication @ComponentScan(basePackages = { "io.mosip.registration.processor.core.config", "${mosip.auth.adapter.impl.basepackage}", @@ -24,8 +27,10 @@ "io.mosip.registration.processor.status.config", "io.mosip.registration.processor.core.kernel.beans", "io.mosip.registration.processor.packet.storage.config", - "io.mosip.kernel.websub.api.config.publisher" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { - HibernateDaoConfig.class, PropertyLoaderConfig.class })) + "io.mosip.kernel.websub.api.config.publisher", + "io.mosip.registration.processor.packet.storage.utils.ActiveMqConnectionUtility" }, excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, value = { + HibernateDaoConfig.class, PropertyLoaderConfig.class +})) public class WorkflowManagerApplication { public static void main(String[] args) { diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties index f3296070a8c..f8519d90d7a 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties @@ -13,6 +13,7 @@ health.config.enabled=false eventbus.port=5754 server.port=8026 server.servlet.path=/registrationprocessor/v1/workflowmanager +spring.mvc.servlet.path=${server.servlet.path} mosip.regproc.workflow-manager.internal.action.server.port=8024 mosip.regproc.workflow-manager.internal.action.eventbus.port=5751 mosip.regproc.workflow-manager.workflowaction.server.port=8023 From c2cb7d90a45dad9eb0140e49b16f388b13733ae4 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 28 May 2024 18:58:56 +0530 Subject: [PATCH 19/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../registration-processor-credential-requestor-stage/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml index ea707bc4588..ffe7fe41341 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/pom.xml @@ -70,7 +70,7 @@ org.mvel mvel2 - 2.4.12.Final + 2.5.2.Final junit From aef11d8c3ffa23aa6ab819f25d58754b757f26bd Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Wed, 29 May 2024 13:28:18 +0530 Subject: [PATCH 20/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../Dockerfile | 41 ++++++++----------- .../Dockerfile | 39 ++++++++---------- 2 files changed, 35 insertions(+), 45 deletions(-) diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index 7c2b62d3858..a0764cc0545 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:21-jre-alpine +FROM mosipdev/openjdk-21-jre:latest ARG SOURCE ARG COMMIT_HASH @@ -49,7 +49,7 @@ ARG container_user=mosip ARG container_user_group=mosip # can be passed during Docker build as build time environment for github branch to pickup configuration from. -ARG container_user_uid=1002 +ARG container_user_uid=1001 # can be passed during Docker build as build time environment for github branch to pickup configuration from. ARG container_user_gid=1001 @@ -64,41 +64,36 @@ ENV biosdk_local_dir_name=${biosdk_local_dir} #ENV bio_sdk_folder_env=${bio_sdk_folder} ENV biosdk_zip_file_path=${biosdk_zip_path} -# install packages and create user -RUN apk -q update \ -&& apk add -q unzip sudo \ -&& addgroup -g ${container_user_gid} ${container_user_group} \ -&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ -&& addgroup sudo \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers +ARG stage_group_name=registration-processor-stage-group-2 -# set working directory for the user -WORKDIR /home/${container_user} +ENV group_name=${stage_group_name} ENV work_dir=/home/${container_user} ARG loader_path=${work_dir}/additional_jars/ -RUN mkdir -p ${loader_path} - ENV loader_path_env=${loader_path} -# change volume to whichever storage directory you want to use for this container. -#VOLUME /home/logs - -ARG stage_group_name=registration-processor-stage-group-2 - -ENV group_name=${stage_group_name} +# set working directory for the user +WORKDIR ${work_dir} ADD ./target/${group_name}-*.jar ${group_name}.jar ADD configure_start.sh configure_start.sh -RUN chmod +x configure_start.sh +# install packages and create user +RUN apt-get -y update \ +&& apt-get install -y unzip sudo \ +&& groupadd -g ${container_user_gid} ${container_user_group} \ +&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers \ +&& mkdir -p ${loader_path} \ +&& chmod +x configure_start.sh \ +&& chown -R ${container_user}:${container_user} ${work_dir} -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} +# change volume to whichever storage directory you want to use for this container. +#VOLUME /home/logs # select container user for all tasks USER ${container_user_uid}:${container_user_gid} diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index 51bc297ca8b..2e76d664c8d 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:21-jre-alpine +FROM mosipdev/openjdk-21-jre:latest ARG SOURCE ARG COMMIT_HASH @@ -64,41 +64,36 @@ ENV biosdk_local_dir_name=${biosdk_local_dir} #ENV bio_sdk_folder_env=${bio_sdk_folder} ENV biosdk_zip_file_path=${biosdk_zip_path} -# install packages and create user -RUN apk -q update \ -&& apk add -q unzip sudo \ -&& addgroup -g ${container_user_gid} ${container_user_group} \ -&& adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ -&& addgroup sudo \ -&& adduser ${container_user} sudo \ -&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers +ARG stage_group_name=registration-processor-stage-group-4 -# set working directory for the user -WORKDIR /home/${container_user} +ENV group_name=${stage_group_name} ENV work_dir=/home/${container_user} ARG loader_path=${work_dir}/additional_jars/ -RUN mkdir -p ${loader_path} - ENV loader_path_env=${loader_path} -# change volume to whichever storage directory you want to use for this container. -#VOLUME /home/logs - -ARG stage_group_name=registration-processor-stage-group-4 - -ENV group_name=${stage_group_name} +# set working directory for the user +WORKDIR ${work_dir} ADD ./target/${group_name}-*.jar ${group_name}.jar ADD configure_start.sh configure_start.sh -RUN chmod +x configure_start.sh +# install packages and create user +RUN apt-get -y update \ +&& apt-get install -y unzip sudo \ +&& groupadd -g ${container_user_gid} ${container_user_group} \ +&& useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ +&& adduser ${container_user} sudo \ +&& echo "%sudo ALL=(ALL) NOPASSWD:/home/${container_user}/${biosdk_local_dir}/install.sh" >> /etc/sudoers \ +&& mkdir -p ${loader_path} \ +&& chmod +x configure_start.sh \ +&& chown -R ${container_user}:${container_user} ${work_dir} -# change permissions of file inside working dir -RUN chown -R ${container_user}:${container_user} /home/${container_user} +# change volume to whichever storage directory you want to use for this container. +#VOLUME /home/logs # select container user for all tasks USER ${container_user_uid}:${container_user_gid} From 286fced6929971370c5dfde318c5574e55a0f09c Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Wed, 29 May 2024 17:54:08 +0530 Subject: [PATCH 21/27] MOSIP-32461 docker changes Signed-off-by: Sowmya Ujjappa Banakar --- .../registration-processor-stage-group-2/Dockerfile | 2 +- .../registration-processor-stage-group-3/Dockerfile | 2 +- .../registration-processor-stage-group-4/Dockerfile | 2 +- .../registration-processor-stage-group-5/Dockerfile | 2 +- .../registration-processor-stage-group-6/Dockerfile | 2 +- .../registration-processor-stage-group-7/Dockerfile | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile index a0764cc0545..04512853b24 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-2/Dockerfile @@ -83,7 +83,7 @@ ADD configure_start.sh configure_start.sh # install packages and create user RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ +&& apt-get install -y unzip sudo curl \ && groupadd -g ${container_user_gid} ${container_user_group} \ && useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile index 050c0a84604..f6d652039c6 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-3/Dockerfile @@ -57,7 +57,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip sudo \ +&& apk add -q unzip sudo bash curl \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && addgroup sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile index 2e76d664c8d..ee86e674ae4 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-4/Dockerfile @@ -83,7 +83,7 @@ ADD configure_start.sh configure_start.sh # install packages and create user RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ +&& apt-get install -y unzip sudo curl \ && groupadd -g ${container_user_gid} ${container_user_group} \ && useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile index d8e575613e4..e12007f5ce3 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-5/Dockerfile @@ -80,7 +80,7 @@ ADD configure_start.sh configure_start.sh # install packages and create user RUN apt-get -y update \ -&& apt-get install -y unzip sudo \ +&& apt-get install -y unzip sudo curl \ && groupadd -g ${container_user_gid} ${container_user_group} \ && useradd -u ${container_user_uid} -g ${container_user_group} -s /bin/bash -m ${container_user} \ && adduser ${container_user} sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile index 43193daafb2..e06cbab2b6c 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-6/Dockerfile @@ -56,7 +56,7 @@ ENV artifactory_url_env=${artifactory_url} # install packages and create user RUN apk -q update \ -&& apk add -q unzip sudo \ +&& apk add -q unzip sudo bash curl \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && addgroup sudo \ diff --git a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile index 4ed023d1e26..1d10a397fc1 100644 --- a/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile +++ b/registration-processor/stage-groups/registration-processor-stage-group-7/Dockerfile @@ -60,7 +60,7 @@ ARG container_user_uid=1002 ARG container_user_gid=1001 RUN apk -q update \ -&& apk add -q unzip sudo \ +&& apk add -q unzip sudo bash curl \ && addgroup -g ${container_user_gid} ${container_user_group} \ && adduser -s /bin/sh -u ${container_user_uid} -G ${container_user_group} -h /home/${container_user} --disabled-password ${container_user} \ && addgroup sudo \ From cb4cb66cd2acb4048abb0e7049f6dc20d12ef163 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Mon, 3 Jun 2024 17:57:17 +0530 Subject: [PATCH 22/27] MOSIP-32461 Code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../PacketExternalStatusController.java | 18 +- .../RegistrationExternalStatusController.java | 353 ++++++------ .../RegistrationStatusController.java | 520 +++++++++--------- .../RegistrationSyncController.java | 19 +- 4 files changed, 450 insertions(+), 460 deletions(-) diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusController.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusController.java index f2e75d4b2e8..06f9fdab5fb 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusController.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/PacketExternalStatusController.java @@ -122,27 +122,19 @@ public ResponseEntity packetExternalStatus( } List packetExternalStatusDTOList = packetExternalStatusService .getByPacketIds(packetIdList); - + PacketExternalStatusResponseDTO packetExternalStatusResponseDTO = buildPacketStatusResponse( + packetExternalStatusDTOList, packetExternalStatusRequestDTO.getRequest()); + String res = objectMapper.writeValueAsString(packetExternalStatusResponseDTO); if (isEnabled) { - PacketExternalStatusResponseDTO packetExternalStatusResponseDTO = buildPacketStatusResponse( - packetExternalStatusDTOList, packetExternalStatusRequestDTO.getRequest()); - HttpHeaders headers = new HttpHeaders(); - String res=null; - try { - - res=objectMapper.writeValueAsString(packetExternalStatusResponseDTO); - } catch (Exception e1) { - logger.error("Error while processing dto ",e1); - - } headers.add(RESPONSE_SIGNATURE, digitalSignatureUtility.getDigitalSignature(res)); return ResponseEntity.status(HttpStatus.OK).headers(headers) .body(res); } + return ResponseEntity.status(HttpStatus.OK) - .body(buildPacketStatusResponse(packetExternalStatusDTOList, packetExternalStatusRequestDTO.getRequest())); + .body(res); } catch (RegStatusAppException e) { throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); } catch (Exception e) { diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusController.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusController.java index 5e519400f12..ce2da849785 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusController.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationExternalStatusController.java @@ -1,178 +1,175 @@ -package io.mosip.registration.processor.status.api.controller; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.mosip.registration.processor.status.code.RegistrationExternalStatusCode; -import io.mosip.registration.processor.status.dto.ErrorDTO; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; -import io.mosip.registration.processor.status.dto.RegistrationExternalStatusSubRequestDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusErrorDto; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.SyncRegistrationService; -import io.mosip.registration.processor.status.sync.response.dto.RegExternalStatusResponseDTO; -import io.mosip.registration.processor.status.validator.RegistrationExternalStatusRequestValidator; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; - -@RefreshScope -@RestController -@Tag(name = "External Registration Status", description = "Registration External Status Controller") -public class RegistrationExternalStatusController { - - /** The registration status service. */ - @Autowired - RegistrationStatusService registrationStatusService; - - /** The sync registration service. */ - @Autowired - SyncRegistrationService syncRegistrationService; - - @Autowired - RegistrationExternalStatusRequestValidator registrationExternalStatusRequestValidator; - - @Autowired - private DigitalSignatureUtility digitalSignatureUtility; - - @Autowired - private Environment env; - - @Value("${registration.processor.signature.isEnabled}") - private Boolean isEnabled; - - @Autowired - ObjectMapper objMp; - - private static final String REG_EXTERNAL_STATUS_SERVICE_ID = "mosip.registration.processor.registration.external.status.id"; - private static final String RESPONSE_SIGNATURE = "Response-Signature"; - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - private static final String REG_EXTERNAL_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.external.status.version"; - - /** - * Search. - * - * @param registrationIds the registration ids - * @return the response entity - * @throws RegStatusAppException - */ - //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'REGISTRATION_SUPERVISOR','RESIDENT')") - @PreAuthorize("hasAnyRole(@authorizedRoles.getPostexternalstatussearch())") - @PostMapping(path = "/externalstatus/search", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Get the registration external status", description = "Get the registration external status", tags = { "External Registration Status" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Registration external status successfully fetched", - content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), - @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "400", description = "Unable to fetch the registration external status" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) - - public ResponseEntity search( - @RequestBody(required = true) RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO) - throws RegStatusAppException { - - try { - registrationExternalStatusRequestValidator.validate(registrationExternalStatusRequestDTO, - env.getProperty(REG_EXTERNAL_STATUS_SERVICE_ID)); - - List registrationIds = registrationExternalStatusRequestDTO.getRequest().stream() - .map(RegistrationExternalStatusSubRequestDto::getRegistrationId).collect(Collectors.toList()); - - List registrations = registrationStatusService - .getExternalStatusByIds(registrationIds); - - List requestIdsNotAvailable = registrationExternalStatusRequestDTO - .getRequest().stream() - .filter(request -> registrations.stream().noneMatch( - registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) - .collect(Collectors.toList()); - - List registrationIdsNotAvailable = requestIdsNotAvailable.stream() - .map(RegistrationExternalStatusSubRequestDto::getRegistrationId).collect(Collectors.toList()); - List registrationsList = syncRegistrationService - .getExternalStatusByIds(registrationIdsNotAvailable); - - if (registrationsList != null && !registrationsList.isEmpty()) { - registrations.addAll(registrationsList); - } - - if (isEnabled) { - RegExternalStatusResponseDTO response = buildRegistrationStatusResponse(registrations, - registrationExternalStatusRequestDTO.getRequest()); - - HttpHeaders headers = new HttpHeaders(); - String res=null; - res=objMp.writeValueAsString(response); - headers.add(RESPONSE_SIGNATURE, digitalSignatureUtility.getDigitalSignature(res)); - return ResponseEntity.status(HttpStatus.OK).headers(headers).body(res); - } - return ResponseEntity.status(HttpStatus.OK) - .body(buildRegistrationStatusResponse(registrations, registrationExternalStatusRequestDTO.getRequest())); - } catch (RegStatusAppException e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); - } catch (Exception e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_UNKNOWN_EXCEPTION, e); - } - } - - public RegExternalStatusResponseDTO buildRegistrationStatusResponse(List registrations, - List requestIds) { - - RegExternalStatusResponseDTO response = new RegExternalStatusResponseDTO(); - if (Objects.isNull(response.getId())) { - response.setId(env.getProperty(REG_EXTERNAL_STATUS_SERVICE_ID)); - } - response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); - response.setVersion(env.getProperty(REG_EXTERNAL_STATUS_APPLICATION_VERSION)); - response.setResponse(registrations); - List requestIdsNotAvailable = requestIds.stream() - .filter(request -> registrations.stream().noneMatch( - registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) - .collect(Collectors.toList()); - List errors = new ArrayList(); - if (!requestIdsNotAvailable.isEmpty()) { - - for (RegistrationExternalStatusSubRequestDto requestDto : requestIdsNotAvailable) { - RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); - - errorDto.setRegistrationId(requestDto.getRegistrationId()); - errors.add(errorDto); - } - } - response.setErrors(errors); - return response; - } - -} +package io.mosip.registration.processor.status.api.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.mosip.registration.processor.status.code.RegistrationExternalStatusCode; +import io.mosip.registration.processor.status.dto.ErrorDTO; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationExternalStatusRequestDTO; +import io.mosip.registration.processor.status.dto.RegistrationExternalStatusSubRequestDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusErrorDto; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; +import io.mosip.registration.processor.status.sync.response.dto.RegExternalStatusResponseDTO; +import io.mosip.registration.processor.status.validator.RegistrationExternalStatusRequestValidator; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; + +@RefreshScope +@RestController +@Tag(name = "External Registration Status", description = "Registration External Status Controller") +public class RegistrationExternalStatusController { + + /** The registration status service. */ + @Autowired + RegistrationStatusService registrationStatusService; + + /** The sync registration service. */ + @Autowired + SyncRegistrationService syncRegistrationService; + + @Autowired + RegistrationExternalStatusRequestValidator registrationExternalStatusRequestValidator; + + @Autowired + private DigitalSignatureUtility digitalSignatureUtility; + + @Autowired + private Environment env; + + @Value("${registration.processor.signature.isEnabled}") + private Boolean isEnabled; + + @Autowired + ObjectMapper objMp; + + private static final String REG_EXTERNAL_STATUS_SERVICE_ID = "mosip.registration.processor.registration.external.status.id"; + private static final String RESPONSE_SIGNATURE = "Response-Signature"; + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + private static final String REG_EXTERNAL_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.external.status.version"; + + /** + * Search. + * + * @param registrationIds the registration ids + * @return the response entity + * @throws RegStatusAppException + */ + //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'REGISTRATION_SUPERVISOR','RESIDENT')") + @PreAuthorize("hasAnyRole(@authorizedRoles.getPostexternalstatussearch())") + @PostMapping(path = "/externalstatus/search", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Get the registration external status", description = "Get the registration external status", tags = { "External Registration Status" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Registration external status successfully fetched", + content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), + @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "400", description = "Unable to fetch the registration external status" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) + + public ResponseEntity search( + @RequestBody(required = true) RegistrationExternalStatusRequestDTO registrationExternalStatusRequestDTO) + throws RegStatusAppException { + + try { + registrationExternalStatusRequestValidator.validate(registrationExternalStatusRequestDTO, + env.getProperty(REG_EXTERNAL_STATUS_SERVICE_ID)); + + List registrationIds = registrationExternalStatusRequestDTO.getRequest().stream() + .map(RegistrationExternalStatusSubRequestDto::getRegistrationId).collect(Collectors.toList()); + + List registrations = registrationStatusService + .getExternalStatusByIds(registrationIds); + + List requestIdsNotAvailable = registrationExternalStatusRequestDTO + .getRequest().stream() + .filter(request -> registrations.stream().noneMatch( + registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) + .collect(Collectors.toList()); + + List registrationIdsNotAvailable = requestIdsNotAvailable.stream() + .map(RegistrationExternalStatusSubRequestDto::getRegistrationId).collect(Collectors.toList()); + List registrationsList = syncRegistrationService + .getExternalStatusByIds(registrationIdsNotAvailable); + + if (registrationsList != null && !registrationsList.isEmpty()) { + registrations.addAll(registrationsList); + } + RegExternalStatusResponseDTO response = buildRegistrationStatusResponse(registrations, + registrationExternalStatusRequestDTO.getRequest()); + String res = objMp.writeValueAsString(response); + if (isEnabled) { + HttpHeaders headers = new HttpHeaders(); + headers.add(RESPONSE_SIGNATURE, digitalSignatureUtility.getDigitalSignature(res)); + return ResponseEntity.status(HttpStatus.OK).headers(headers).body(res); + } + return ResponseEntity.status(HttpStatus.OK) + .body(res); + } catch (RegStatusAppException e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); + } catch (Exception e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_UNKNOWN_EXCEPTION, e); + } + } + + public RegExternalStatusResponseDTO buildRegistrationStatusResponse(List registrations, + List requestIds) { + + RegExternalStatusResponseDTO response = new RegExternalStatusResponseDTO(); + if (Objects.isNull(response.getId())) { + response.setId(env.getProperty(REG_EXTERNAL_STATUS_SERVICE_ID)); + } + response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); + response.setVersion(env.getProperty(REG_EXTERNAL_STATUS_APPLICATION_VERSION)); + response.setResponse(registrations); + List requestIdsNotAvailable = requestIds.stream() + .filter(request -> registrations.stream().noneMatch( + registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) + .collect(Collectors.toList()); + List errors = new ArrayList(); + if (!requestIdsNotAvailable.isEmpty()) { + + for (RegistrationExternalStatusSubRequestDto requestDto : requestIdsNotAvailable) { + RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); + + errorDto.setRegistrationId(requestDto.getRegistrationId()); + errors.add(errorDto); + } + } + response.setErrors(errors); + return response; + } + +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusController.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusController.java index f3b0a6d6996..4714095ea1a 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusController.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationStatusController.java @@ -1,261 +1,259 @@ -package io.mosip.registration.processor.status.api.controller; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import org.apache.commons.collections.CollectionUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.cloud.context.config.annotation.RefreshScope; -import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.util.DigitalSignatureUtility; -import io.mosip.registration.processor.status.code.RegistrationExternalStatusCode; -import io.mosip.registration.processor.status.dto.ErrorDTO; -import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; -import io.mosip.registration.processor.status.dto.LostRidDto; -import io.mosip.registration.processor.status.dto.LostRidRequestDto; -import io.mosip.registration.processor.status.dto.LostRidResponseDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusErrorDto; -import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; -import io.mosip.registration.processor.status.dto.RegistrationStatusSubRequestDto; -import io.mosip.registration.processor.status.dto.SyncRegistrationDto; -import io.mosip.registration.processor.status.dto.SyncResponseDto; -import io.mosip.registration.processor.status.exception.RegStatusAppException; -import io.mosip.registration.processor.status.service.RegistrationStatusService; -import io.mosip.registration.processor.status.service.SyncRegistrationService; -import io.mosip.registration.processor.status.sync.response.dto.RegStatusResponseDTO; -import io.mosip.registration.processor.status.validator.LostRidRequestValidator; -import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; - -/** - * The Class RegistrationStatusController. - */ -@RefreshScope -@RestController -@Tag(name = "Registration Status", description = "Registration Status Controller") -public class RegistrationStatusController { - - /** The registration status service. */ - @Autowired - RegistrationStatusService registrationStatusService; - - /** The sync registration service. */ - @Autowired - SyncRegistrationService syncRegistrationService; - - /** The validator. */ - @Autowired - RegistrationStatusRequestValidator registrationStatusRequestValidator; - - @Autowired - LostRidRequestValidator lostRidRequestValidator; - - private static final String REG_STATUS_SERVICE_ID = "mosip.registration.processor.registration.status.id"; - private static final String REG_LOSTRID_SERVICE_ID = "mosip.registration.processor.lostrid.id"; - private static final String REG_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.status.version"; - private static final String REG_LOSTRID_APPLICATION_VERSION = "mosip.registration.processor.lostrid.version"; - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - private static final String RESPONSE_SIGNATURE = "Response-Signature"; - - @Autowired - private Environment env; - - @Value("${registration.processor.signature.isEnabled}") - private Boolean isEnabled; - - @Autowired - ObjectMapper objMp; - - /** - * The comma separate list of external statuses that should be considered as processed - * for search API response consumed by regclient - */ - @Value("#{'${mosip.registration.processor.registration.status.external-statuses-to-consider-processed:UIN_GENERATED,REREGISTER,REJECTED,REPROCESS_FAILED}'.split(',')}") - private List externalStatusesConsideredProcessed; - - @Value("${registration.processor.fetch.registration.records.limit:100}") - private int maxLimit; - - @Autowired - private DigitalSignatureUtility digitalSignatureUtility; - - /** - * Search. - * - * @param registrationStatusRequestDTO the registration ids - * @return the response entity - * @throws RegStatusAppException - */ - //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'REGISTRATION_SUPERVISOR','RESIDENT')") - @PreAuthorize("hasAnyRole(@authorizedRoles.getPostsearch())") - @PostMapping(path = "/search", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Get the registration entity", description = "Get the registration entity", tags = { "Registration Status" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Registration Entity successfully fetched", - content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), - @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "400", description = "Unable to fetch the Registration Entity" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) - public ResponseEntity search( - @RequestBody(required = true) RegistrationStatusRequestDTO registrationStatusRequestDTO) - throws RegStatusAppException { - - try { - registrationStatusRequestValidator.validate(registrationStatusRequestDTO, - env.getProperty(REG_STATUS_SERVICE_ID)); - - // if number of rids in request exceeds max limit then get status for first 100 ids. - List recordsToFetch = CollectionUtils.isNotEmpty(registrationStatusRequestDTO.getRequest()) - && registrationStatusRequestDTO.getRequest().size() > maxLimit ? - registrationStatusRequestDTO.getRequest().stream().limit(maxLimit).collect(Collectors.toList()) : registrationStatusRequestDTO.getRequest(); - - List registrations = registrationStatusService - .getByIds(recordsToFetch); - List requestIdsNotAvailable = recordsToFetch - .stream() - .filter(request -> registrations.stream().noneMatch( - registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) - .collect(Collectors.toList()); - - if (CollectionUtils.isNotEmpty(requestIdsNotAvailable)) { - List registrationsList = syncRegistrationService.getByIds(requestIdsNotAvailable); - if (registrationsList != null && !registrationsList.isEmpty()) { - registrations.addAll(syncRegistrationService.getByIds(requestIdsNotAvailable)); - } - } - - updatedConditionalStatusToProcessed(registrations); - - if (isEnabled) { - String response = objMp.writeValueAsString(buildRegistrationStatusResponse(registrations, - recordsToFetch)); - HttpHeaders headers = new HttpHeaders(); - headers.add(RESPONSE_SIGNATURE, digitalSignatureUtility.getDigitalSignature(response)); - return ResponseEntity.status(HttpStatus.OK).headers(headers).body(response); - } - return ResponseEntity.status(HttpStatus.OK) - .body(buildRegistrationStatusResponse(registrations, recordsToFetch)); - } catch (RegStatusAppException e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); - } catch (Exception e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_UNKNOWN_EXCEPTION, e); - } - } - - /** - * Search - * - * @param lostRidRequestDto - * @return - * @throws RegStatusAppException - */ - //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'ZONAL_ADMIN','GLOBAL_ADMIN')") - @PreAuthorize("hasAnyRole(@authorizedRoles.getPostlostridsearch())") - @PostMapping(path = "/lostridsearch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(summary = "Get the lost registration id", description = "Get the lost registration id", tags = { "Registration Status" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "Registration id successfully fetched", - content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), - @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "400", description = "Unable to fetch the Registration Entity" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) - public ResponseEntity searchLostRid( - @RequestBody(required = true) LostRidRequestDto lostRidRequestDto) - throws RegStatusAppException { - - try { - lostRidRequestValidator.validate(lostRidRequestDto); - List lostRidDtos = syncRegistrationService.searchLostRid(lostRidRequestDto.getRequest()); - return ResponseEntity.status(HttpStatus.OK) - .body(buildLostRidResponse(lostRidDtos)); - } catch (RegStatusAppException e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); - } catch (Exception e) { - throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_SEARCH, e); - } - } - - public RegStatusResponseDTO buildRegistrationStatusResponse(List registrations, - List requestIds) { - - RegStatusResponseDTO response = new RegStatusResponseDTO(); - if (Objects.isNull(response.getId())) { - response.setId(env.getProperty(REG_STATUS_SERVICE_ID)); - } - response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); - response.setVersion(env.getProperty(REG_STATUS_APPLICATION_VERSION)); - response.setResponse(registrations); - List requestIdsNotAvailable = requestIds.stream() - .filter(request -> registrations.stream().noneMatch( - registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) - .collect(Collectors.toList()); - List errors = new ArrayList(); - if (!requestIdsNotAvailable.isEmpty()) { - - for (RegistrationStatusSubRequestDto requestDto : requestIdsNotAvailable) { - RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); - - errorDto.setRegistrationId(requestDto.getRegistrationId()); - errors.add(errorDto); - } - } - response.setErrors(errors); - return response; - } - - private void updatedConditionalStatusToProcessed(List registrations) { - for(RegistrationStatusDto registrationStatusDto : registrations) { - if(externalStatusesConsideredProcessed.contains(registrationStatusDto.getStatusCode())) - registrationStatusDto.setStatusCode(RegistrationExternalStatusCode.PROCESSED.toString()); - } - } - - public LostRidResponseDto buildLostRidResponse(List lostRidDtos) { - - LostRidResponseDto response = new LostRidResponseDto(); - if (Objects.isNull(response.getId())) { - response.setId(env.getProperty(REG_LOSTRID_SERVICE_ID)); - } - response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); - response.setVersion(env.getProperty(REG_LOSTRID_APPLICATION_VERSION)); - response.setResponse(lostRidDtos); - List errors = new ArrayList(); - if (lostRidDtos.isEmpty()) { - RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), - PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); - errors.add(errorDto); - } - response.setErrors(errors); - return response; - } - -} +package io.mosip.registration.processor.status.api.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.util.DigitalSignatureUtility; +import io.mosip.registration.processor.status.code.RegistrationExternalStatusCode; +import io.mosip.registration.processor.status.dto.ErrorDTO; +import io.mosip.registration.processor.status.dto.InternalRegistrationStatusDto; +import io.mosip.registration.processor.status.dto.LostRidDto; +import io.mosip.registration.processor.status.dto.LostRidRequestDto; +import io.mosip.registration.processor.status.dto.LostRidResponseDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusErrorDto; +import io.mosip.registration.processor.status.dto.RegistrationStatusRequestDTO; +import io.mosip.registration.processor.status.dto.RegistrationStatusSubRequestDto; +import io.mosip.registration.processor.status.dto.SyncRegistrationDto; +import io.mosip.registration.processor.status.dto.SyncResponseDto; +import io.mosip.registration.processor.status.exception.RegStatusAppException; +import io.mosip.registration.processor.status.service.RegistrationStatusService; +import io.mosip.registration.processor.status.service.SyncRegistrationService; +import io.mosip.registration.processor.status.sync.response.dto.RegStatusResponseDTO; +import io.mosip.registration.processor.status.validator.LostRidRequestValidator; +import io.mosip.registration.processor.status.validator.RegistrationStatusRequestValidator; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; + +/** + * The Class RegistrationStatusController. + */ +@RefreshScope +@RestController +@Tag(name = "Registration Status", description = "Registration Status Controller") +public class RegistrationStatusController { + + /** The registration status service. */ + @Autowired + RegistrationStatusService registrationStatusService; + + /** The sync registration service. */ + @Autowired + SyncRegistrationService syncRegistrationService; + + /** The validator. */ + @Autowired + RegistrationStatusRequestValidator registrationStatusRequestValidator; + + @Autowired + LostRidRequestValidator lostRidRequestValidator; + + private static final String REG_STATUS_SERVICE_ID = "mosip.registration.processor.registration.status.id"; + private static final String REG_LOSTRID_SERVICE_ID = "mosip.registration.processor.lostrid.id"; + private static final String REG_STATUS_APPLICATION_VERSION = "mosip.registration.processor.registration.status.version"; + private static final String REG_LOSTRID_APPLICATION_VERSION = "mosip.registration.processor.lostrid.version"; + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + private static final String RESPONSE_SIGNATURE = "Response-Signature"; + + @Autowired + private Environment env; + + @Value("${registration.processor.signature.isEnabled}") + private Boolean isEnabled; + + @Autowired + ObjectMapper objMp; + + /** + * The comma separate list of external statuses that should be considered as processed + * for search API response consumed by regclient + */ + @Value("#{'${mosip.registration.processor.registration.status.external-statuses-to-consider-processed:UIN_GENERATED,REREGISTER,REJECTED,REPROCESS_FAILED}'.split(',')}") + private List externalStatusesConsideredProcessed; + + @Value("${registration.processor.fetch.registration.records.limit:100}") + private int maxLimit; + + @Autowired + private DigitalSignatureUtility digitalSignatureUtility; + + /** + * Search. + * + * @param registrationStatusRequestDTO the registration ids + * @return the response entity + * @throws RegStatusAppException + */ + //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'REGISTRATION_SUPERVISOR','RESIDENT')") + @PreAuthorize("hasAnyRole(@authorizedRoles.getPostsearch())") + @PostMapping(path = "/search", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Get the registration entity", description = "Get the registration entity", tags = { "Registration Status" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Registration Entity successfully fetched", + content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), + @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "400", description = "Unable to fetch the Registration Entity" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) + public ResponseEntity search( + @RequestBody(required = true) RegistrationStatusRequestDTO registrationStatusRequestDTO) + throws RegStatusAppException { + + try { + registrationStatusRequestValidator.validate(registrationStatusRequestDTO, + env.getProperty(REG_STATUS_SERVICE_ID)); + + // if number of rids in request exceeds max limit then get status for first 100 ids. + List recordsToFetch = CollectionUtils.isNotEmpty(registrationStatusRequestDTO.getRequest()) + && registrationStatusRequestDTO.getRequest().size() > maxLimit ? + registrationStatusRequestDTO.getRequest().stream().limit(maxLimit).collect(Collectors.toList()) : registrationStatusRequestDTO.getRequest(); + + List registrations = registrationStatusService + .getByIds(recordsToFetch); + List requestIdsNotAvailable = recordsToFetch + .stream() + .filter(request -> registrations.stream().noneMatch( + registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) + .collect(Collectors.toList()); + + if (CollectionUtils.isNotEmpty(requestIdsNotAvailable)) { + List registrationsList = syncRegistrationService.getByIds(requestIdsNotAvailable); + if (registrationsList != null && !registrationsList.isEmpty()) { + registrations.addAll(syncRegistrationService.getByIds(requestIdsNotAvailable)); + } + } + + updatedConditionalStatusToProcessed(registrations); + String response = objMp.writeValueAsString(buildRegistrationStatusResponse(registrations, recordsToFetch)); + if (isEnabled) { + HttpHeaders headers = new HttpHeaders(); + headers.add(RESPONSE_SIGNATURE, digitalSignatureUtility.getDigitalSignature(response)); + return ResponseEntity.status(HttpStatus.OK).headers(headers).body(response); + } + return ResponseEntity.status(HttpStatus.OK) + .body(response); + } catch (RegStatusAppException e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); + } catch (Exception e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_UNKNOWN_EXCEPTION, e); + } + } + + /** + * Search + * + * @param lostRidRequestDto + * @return + * @throws RegStatusAppException + */ + //@PreAuthorize("hasAnyRole('REGISTRATION_ADMIN', 'REGISTRATION_OFFICER', 'ZONAL_ADMIN','GLOBAL_ADMIN')") + @PreAuthorize("hasAnyRole(@authorizedRoles.getPostlostridsearch())") + @PostMapping(path = "/lostridsearch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(summary = "Get the lost registration id", description = "Get the lost registration id", tags = { "Registration Status" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Registration id successfully fetched", + content = @Content(schema = @Schema(implementation = RegistrationExternalStatusCode.class))), + @ApiResponse(responseCode = "201", description = "Created" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "400", description = "Unable to fetch the Registration Entity" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "401", description = "Unauthorized" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "403", description = "Forbidden" ,content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "404", description = "Not Found" ,content = @Content(schema = @Schema(hidden = true)))}) + public ResponseEntity searchLostRid( + @RequestBody(required = true) LostRidRequestDto lostRidRequestDto) + throws RegStatusAppException { + + try { + lostRidRequestValidator.validate(lostRidRequestDto); + List lostRidDtos = syncRegistrationService.searchLostRid(lostRidRequestDto.getRequest()); + return ResponseEntity.status(HttpStatus.OK) + .body(buildLostRidResponse(lostRidDtos)); + } catch (RegStatusAppException e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); + } catch (Exception e) { + throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_INVALID_SEARCH, e); + } + } + + public RegStatusResponseDTO buildRegistrationStatusResponse(List registrations, + List requestIds) { + + RegStatusResponseDTO response = new RegStatusResponseDTO(); + if (Objects.isNull(response.getId())) { + response.setId(env.getProperty(REG_STATUS_SERVICE_ID)); + } + response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); + response.setVersion(env.getProperty(REG_STATUS_APPLICATION_VERSION)); + response.setResponse(registrations); + List requestIdsNotAvailable = requestIds.stream() + .filter(request -> registrations.stream().noneMatch( + registration -> registration.getRegistrationId().equals(request.getRegistrationId()))) + .collect(Collectors.toList()); + List errors = new ArrayList(); + if (!requestIdsNotAvailable.isEmpty()) { + + for (RegistrationStatusSubRequestDto requestDto : requestIdsNotAvailable) { + RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); + + errorDto.setRegistrationId(requestDto.getRegistrationId()); + errors.add(errorDto); + } + } + response.setErrors(errors); + return response; + } + + private void updatedConditionalStatusToProcessed(List registrations) { + for(RegistrationStatusDto registrationStatusDto : registrations) { + if(externalStatusesConsideredProcessed.contains(registrationStatusDto.getStatusCode())) + registrationStatusDto.setStatusCode(RegistrationExternalStatusCode.PROCESSED.toString()); + } + } + + public LostRidResponseDto buildLostRidResponse(List lostRidDtos) { + + LostRidResponseDto response = new LostRidResponseDto(); + if (Objects.isNull(response.getId())) { + response.setId(env.getProperty(REG_LOSTRID_SERVICE_ID)); + } + response.setResponsetime(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN))); + response.setVersion(env.getProperty(REG_LOSTRID_APPLICATION_VERSION)); + response.setResponse(lostRidDtos); + List errors = new ArrayList(); + if (lostRidDtos.isEmpty()) { + RegistrationStatusErrorDto errorDto = new RegistrationStatusErrorDto( + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getCode(), + PlatformErrorMessages.RPR_RGS_RID_NOT_FOUND.getMessage()); + errors.add(errorDto); + } + response.setErrors(errors); + return response; + } + +} diff --git a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationSyncController.java b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationSyncController.java index 3c28e0f589d..83bd4aa5807 100644 --- a/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationSyncController.java +++ b/registration-processor/init/registration-processor-registration-status-service/src/main/java/io/mosip/registration/processor/status/api/controller/RegistrationSyncController.java @@ -108,15 +108,17 @@ public ResponseEntity syncRegistrationController( env.getProperty(REG_SYNC_SERVICE_ID), syncResponseList)) { syncResponseList = syncRegistrationService.sync(registrationSyncRequestDTO.getRequest(), referenceId, timeStamp); } + RegSyncResponseDTO responseDto = buildRegistrationSyncResponse(syncResponseList); + String res = objectMapper.writeValueAsString(responseDto); if (isEnabled) { - RegSyncResponseDTO responseDto = buildRegistrationSyncResponse(syncResponseList); + HttpHeaders headers = new HttpHeaders(); headers.add(RESPONSE_SIGNATURE, - digitalSignatureUtility.getDigitalSignature(objectMapper.writeValueAsString(responseDto))); - return ResponseEntity.ok().headers(headers).body(responseDto); + digitalSignatureUtility.getDigitalSignature(res)); + return ResponseEntity.ok().headers(headers).body(res); } - return ResponseEntity.ok().body(buildRegistrationSyncResponse(syncResponseList)); + return ResponseEntity.ok().body(res); } catch (JsonProcessingException e) { throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); @@ -155,15 +157,16 @@ public ResponseEntity syncRegistrationController2( env.getProperty(REG_SYNC_SERVICE_ID), syncResponseList)) { syncResponseList = syncRegistrationService.syncV2(registrationSyncRequestDTO.getRequest(), referenceId, timeStamp); } + RegSyncResponseDTO responseDto = buildRegistrationSyncResponse(syncResponseList); + String res = objectMapper.writeValueAsString(responseDto); if (isEnabled) { - RegSyncResponseDTO responseDto = buildRegistrationSyncResponse(syncResponseList); HttpHeaders headers = new HttpHeaders(); headers.add(RESPONSE_SIGNATURE, - digitalSignatureUtility.getDigitalSignature(objectMapper.writeValueAsString(responseDto))); - return ResponseEntity.ok().headers(headers).body(responseDto); + digitalSignatureUtility.getDigitalSignature(res)); + return ResponseEntity.ok().headers(headers).body(res); } - return ResponseEntity.ok().body(buildRegistrationSyncResponse(syncResponseList)); + return ResponseEntity.ok().body(res); } catch (JsonProcessingException e) { throw new RegStatusAppException(PlatformErrorMessages.RPR_RGS_DATA_VALIDATION_FAILED, e); From 9c7ace53cf28ca9ff5dae7d5299c4de121929803 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Mon, 3 Jun 2024 18:16:00 +0530 Subject: [PATCH 23/27] MOSIP-32461 Code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../impl/BiometricsSignatureValidator.java | 332 ++++---- .../stage/QualityClassifierStage.java | 2 +- .../impl/AnonymousProfileServiceImpl.java | 722 +++++++++--------- 3 files changed, 528 insertions(+), 528 deletions(-) diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java index 8580c83a092..3b002f82fa4 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java @@ -1,166 +1,166 @@ -package io.mosip.registration.processor.stages.validator.impl; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.JsonUtils; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import org.json.JSONArray; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.commons.BiometricsSignatureHelper; -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.exception.BiometricSignatureValidationException; -import io.mosip.kernel.core.http.RequestWrapper; -import io.mosip.kernel.core.http.ResponseWrapper; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.registration.processor.core.code.ApiName; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.packet.dto.FieldValue; -import io.mosip.registration.processor.core.packet.dto.JWTSignatureVerifyRequestDto; -import io.mosip.registration.processor.core.packet.dto.JWTSignatureVerifyResponseDto; -import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; -import io.mosip.registration.processor.core.status.util.StatusUtil; - -@Component -public class BiometricsSignatureValidator { - - private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; - private static Logger regProcLogger = RegProcessorLogger.getLogger(BiometricsSignatureValidator.class); - - /** The Constant TRUE. */ - private static final String TRUE = "true"; - - @Autowired - private RegistrationProcessorRestClientService registrationProcessorRestService; - - @Autowired - private Environment env; - - @Autowired - ObjectMapper mapper; - - @Value("#{T(java.util.Arrays).asList('${mosip.regproc.common.before-cbeff-others-attibute.reg-client-versions:}')}") - private List regClientVersionsBeforeCbeffOthersAttritube; - - public void validateSignature(String id, String process, BiometricRecord biometricRecord, - Map metaInfoMap) throws JSONException, BiometricSignatureValidationException, - ApisResourceAccessException, PacketManagerException, IOException, io.mosip.kernel.core.util.exception.JsonProcessingException { - - // backward compatibility check - String version = getRegClientVersionFromMetaInfo(id, process, metaInfoMap); - if (regClientVersionsBeforeCbeffOthersAttritube.contains(version)) { - return; - } - - List birs = biometricRecord.getSegments(); - for (BIR bir : birs) { - HashMap othersInfo = bir.getOthers(); - if (othersInfo == null) { - throw new BiometricSignatureValidationException("Others value is null inside BIR"); - } - - boolean exceptionValue = false; - for (Map.Entry other : othersInfo.entrySet()) { - if (other.getKey().equals(JsonConstant.BIOMETRICRECORDEXCEPTION)) { - if (other.getValue().equals(TRUE)) { - exceptionValue = true; - } - break; - } - } - - if (exceptionValue) { - continue; - } - - String token = BiometricsSignatureHelper.extractJWTToken(bir); - validateJWTToken(id, token); - } - - } - - private String getRegClientVersionFromMetaInfo(String id, String process, Map metaInfoMap) - throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { - String metadata = metaInfoMap.get(JsonConstant.METADATA); - String version = null; - if (StringUtils.isNotEmpty(metadata)) { - JSONArray jsonArray = new JSONArray(metadata); - - for (int i = 0; i < jsonArray.length(); i++) { - if (!jsonArray.isNull(i)) { - org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); - FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); - if (fieldValue.getLabel().equalsIgnoreCase(JsonConstant.REGCLIENTVERSION)) { - version = fieldValue.getValue(); - break; - } - } - } - } - return version; - } - - private void validateJWTToken(String id, String token) - throws JsonParseException, JsonMappingException, JsonProcessingException, IOException, JSONException, - BiometricSignatureValidationException, ApisResourceAccessException, io.mosip.kernel.core.util.exception.JsonProcessingException { - JWTSignatureVerifyRequestDto jwtSignatureVerifyRequestDto = new JWTSignatureVerifyRequestDto(); - jwtSignatureVerifyRequestDto.setApplicationId("REGISTRATION"); - jwtSignatureVerifyRequestDto.setReferenceId("SIGN"); - jwtSignatureVerifyRequestDto.setJwtSignatureData(token); - jwtSignatureVerifyRequestDto.setActualData(token.split("\\.")[1]); - - // in packet validator stage we are checking only the structural part of the - // packet so setting validTrust to false - jwtSignatureVerifyRequestDto.setValidateTrust(false); - jwtSignatureVerifyRequestDto.setDomain("Device"); - RequestWrapper request = new RequestWrapper<>(); - - request.setRequest(jwtSignatureVerifyRequestDto); - request.setVersion("1.0"); - DateTimeFormatter format = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); - LocalDateTime localdatetime = LocalDateTime - .parse(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN)), format); - request.setRequesttime(localdatetime); - - ResponseWrapper responseWrapper = (ResponseWrapper) registrationProcessorRestService - .postApi(ApiName.JWTVERIFY, "", "", request, ResponseWrapper.class); - if (responseWrapper.getResponse() != null) { - JWTSignatureVerifyResponseDto jwtResponse = mapper.readValue( - mapper.writeValueAsString(responseWrapper.getResponse()), JWTSignatureVerifyResponseDto.class); - - if (!jwtResponse.isSignatureValid()) { - regProcLogger.error(LoggerFileConstant.REGISTRATIONID.toString(), id, - "Request -> " + JsonUtils.javaObjectToJsonString(request) - ," Response -> " + JsonUtils.javaObjectToJsonString(responseWrapper)); - throw new BiometricSignatureValidationException( - StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getCode(), - StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage()); - } - } else { - throw new BiometricSignatureValidationException(responseWrapper.getErrors().get(0).getErrorCode(), - responseWrapper.getErrors().get(0).getMessage()); - } - - } - -} +package io.mosip.registration.processor.stages.validator.impl; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.JsonUtils; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import org.json.JSONArray; +import org.json.JSONException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.commons.BiometricsSignatureHelper; +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.exception.BiometricSignatureValidationException; +import io.mosip.kernel.core.http.RequestWrapper; +import io.mosip.kernel.core.http.ResponseWrapper; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.registration.processor.core.code.ApiName; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.packet.dto.JWTSignatureVerifyRequestDto; +import io.mosip.registration.processor.core.packet.dto.JWTSignatureVerifyResponseDto; +import io.mosip.registration.processor.core.spi.restclient.RegistrationProcessorRestClientService; +import io.mosip.registration.processor.core.status.util.StatusUtil; + +@Component +public class BiometricsSignatureValidator { + + private static final String DATETIME_PATTERN = "mosip.registration.processor.datetime.pattern"; + private static Logger regProcLogger = RegProcessorLogger.getLogger(BiometricsSignatureValidator.class); + + /** The Constant TRUE. */ + private static final String TRUE = "true"; + + @Autowired + private RegistrationProcessorRestClientService registrationProcessorRestService; + + @Autowired + private Environment env; + + @Autowired + ObjectMapper mapper; + + @Value("#{T(java.util.Arrays).asList('${mosip.regproc.common.before-cbeff-others-attibute.reg-client-versions:}')}") + private List regClientVersionsBeforeCbeffOthersAttritube; + + public void validateSignature(String id, String process, BiometricRecord biometricRecord, + Map metaInfoMap) throws JSONException, BiometricSignatureValidationException, + ApisResourceAccessException, PacketManagerException, IOException, io.mosip.kernel.core.util.exception.JsonProcessingException { + + // backward compatibility check + String version = getRegClientVersionFromMetaInfo(id, process, metaInfoMap); + if (regClientVersionsBeforeCbeffOthersAttritube.contains(version)) { + return; + } + + List birs = biometricRecord.getSegments(); + for (BIR bir : birs) { + HashMap othersInfo = (HashMap) bir.getOthers(); + if (othersInfo == null) { + throw new BiometricSignatureValidationException("Others value is null inside BIR"); + } + + boolean exceptionValue = false; + for (Map.Entry other : othersInfo.entrySet()) { + if (other.getKey().equals(JsonConstant.BIOMETRICRECORDEXCEPTION)) { + if (other.getValue().equals(TRUE)) { + exceptionValue = true; + } + break; + } + } + + if (exceptionValue) { + continue; + } + + String token = BiometricsSignatureHelper.extractJWTToken(bir); + validateJWTToken(id, token); + } + + } + + private String getRegClientVersionFromMetaInfo(String id, String process, Map metaInfoMap) + throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { + String metadata = metaInfoMap.get(JsonConstant.METADATA); + String version = null; + if (StringUtils.isNotEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + + for (int i = 0; i < jsonArray.length(); i++) { + if (!jsonArray.isNull(i)) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); + if (fieldValue.getLabel().equalsIgnoreCase(JsonConstant.REGCLIENTVERSION)) { + version = fieldValue.getValue(); + break; + } + } + } + } + return version; + } + + private void validateJWTToken(String id, String token) + throws JsonParseException, JsonMappingException, JsonProcessingException, IOException, JSONException, + BiometricSignatureValidationException, ApisResourceAccessException, io.mosip.kernel.core.util.exception.JsonProcessingException { + JWTSignatureVerifyRequestDto jwtSignatureVerifyRequestDto = new JWTSignatureVerifyRequestDto(); + jwtSignatureVerifyRequestDto.setApplicationId("REGISTRATION"); + jwtSignatureVerifyRequestDto.setReferenceId("SIGN"); + jwtSignatureVerifyRequestDto.setJwtSignatureData(token); + jwtSignatureVerifyRequestDto.setActualData(token.split("\\.")[1]); + + // in packet validator stage we are checking only the structural part of the + // packet so setting validTrust to false + jwtSignatureVerifyRequestDto.setValidateTrust(false); + jwtSignatureVerifyRequestDto.setDomain("Device"); + RequestWrapper request = new RequestWrapper<>(); + + request.setRequest(jwtSignatureVerifyRequestDto); + request.setVersion("1.0"); + DateTimeFormatter format = DateTimeFormatter.ofPattern(env.getProperty(DATETIME_PATTERN)); + LocalDateTime localdatetime = LocalDateTime + .parse(DateUtils.getUTCCurrentDateTimeString(env.getProperty(DATETIME_PATTERN)), format); + request.setRequesttime(localdatetime); + + ResponseWrapper responseWrapper = (ResponseWrapper) registrationProcessorRestService + .postApi(ApiName.JWTVERIFY, "", "", request, ResponseWrapper.class); + if (responseWrapper.getResponse() != null) { + JWTSignatureVerifyResponseDto jwtResponse = mapper.readValue( + mapper.writeValueAsString(responseWrapper.getResponse()), JWTSignatureVerifyResponseDto.class); + + if (!jwtResponse.isSignatureValid()) { + regProcLogger.error(LoggerFileConstant.REGISTRATIONID.toString(), id, + "Request -> " + JsonUtils.javaObjectToJsonString(request) + ," Response -> " + JsonUtils.javaObjectToJsonString(responseWrapper)); + throw new BiometricSignatureValidationException( + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getCode(), + StatusUtil.BIOMETRICS_SIGNATURE_VALIDATION_FAILURE.getMessage()); + } + } else { + throw new BiometricSignatureValidationException(responseWrapper.getErrors().get(0).getErrorCode(), + responseWrapper.getErrors().get(0).getMessage()); + } + + } + +} diff --git a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java index 4d044b91b73..097b6c8350c 100644 --- a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java +++ b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java @@ -423,7 +423,7 @@ private Map getQualityTags(List birs) throws BiometricExcep for (BIR bir : birs) { if (bir.getOthers() != null) { - HashMap othersInfo = bir.getOthers(); + HashMap othersInfo = (HashMap) bir.getOthers(); boolean exceptionValue = false; for (Map.Entry other : othersInfo.entrySet()) { if (other.getKey().equals(EXCEPTION)) { diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java index c4655e0c14f..7c28f5dda87 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java @@ -1,361 +1,361 @@ -package io.mosip.registration.processor.status.service.impl; - -import java.io.IOException; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.mosip.kernel.biometrics.entities.BIR; -import io.mosip.kernel.biometrics.entities.BiometricRecord; -import io.mosip.kernel.core.dataaccess.exception.DataAccessLayerException; -import io.mosip.kernel.core.exception.BaseCheckedException; -import io.mosip.kernel.core.logger.spi.Logger; -import io.mosip.kernel.core.util.CryptoUtil; -import io.mosip.kernel.core.util.DateUtils; -import io.mosip.kernel.core.util.StringUtils; -import io.mosip.registration.processor.core.anonymous.dto.AnonymousProfileDTO; -import io.mosip.registration.processor.core.anonymous.dto.BiometricInfoDTO; -import io.mosip.registration.processor.core.anonymous.dto.ExceptionsDTO; -import io.mosip.registration.processor.core.constant.JsonConstant; -import io.mosip.registration.processor.core.constant.LoggerFileConstant; -import io.mosip.registration.processor.core.constant.MappingJsonConstants; -import io.mosip.registration.processor.core.exception.ApisResourceAccessException; -import io.mosip.registration.processor.core.exception.PacketManagerException; -import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; -import io.mosip.registration.processor.core.logger.RegProcessorLogger; -import io.mosip.registration.processor.core.packet.dto.Document; -import io.mosip.registration.processor.core.packet.dto.FieldValue; -import io.mosip.registration.processor.core.util.JsonUtil; -import io.mosip.registration.processor.status.entity.AnonymousProfileEntity; -import io.mosip.registration.processor.status.entity.AnonymousProfilePKEntity; -import io.mosip.registration.processor.status.exception.TablenotAccessibleException; -import io.mosip.registration.processor.status.repositary.BaseRegProcRepository; -import io.mosip.registration.processor.status.service.AnonymousProfileService; -import io.mosip.registration.processor.status.utilities.RegistrationUtility; -@Component -public class AnonymousProfileServiceImpl implements AnonymousProfileService { - /** The reg proc logger. */ - private static Logger regProcLogger = RegProcessorLogger.getLogger(AnonymousProfileServiceImpl.class); - - /** The Anonymus Profile repository. */ - @Autowired - private BaseRegProcRepository anonymousProfileRepository; - - @Autowired - ObjectMapper mapper; - - @Autowired - private RegistrationUtility registrationUtility; - - /** - * The mandatory languages that should be used when dealing with field type that - * has values in multiple languages - */ - @Value("#{T(java.util.Arrays).asList('${mosip.mandatory-languages:}')}") - private List mandatoryLanguages; - - @Value("${registration.processor.applicant.dob.format:yyyy/MM/dd}") - private String dobFormat; - - @Value("${mosip.preferred-language.enabled:false}") - private boolean isPreferredLangEnabled; - - /** The constant for language label in JSON parsing */ - private static final String LANGUAGE_LABEL = "language"; - - /** The constant for value label in JSON parsing */ - private static final String VALUE_LABEL = "value"; - - /** The Constant TRUE. */ - private static final String TRUE = "true"; - - @Override - public void saveAnonymousProfile(String regId, String processStage, String profileJson) { - - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, - "AnonymousProfileServiceImpl::saveAnonymousProfile()::entry"); - try { - AnonymousProfileEntity anonymousProfileEntity=new AnonymousProfileEntity(); - AnonymousProfilePKEntity anonymousProfilePKEntity=new AnonymousProfilePKEntity(); - anonymousProfilePKEntity.setId(RegistrationUtility.generateId()); - anonymousProfileEntity.setId(anonymousProfilePKEntity); - anonymousProfileEntity.setProfile(profileJson); - anonymousProfileEntity.setProcessStage(processStage); - anonymousProfileEntity.setCreatedBy("SYSTEM"); - anonymousProfileEntity.setCreateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); - anonymousProfileEntity.setUpdateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); - anonymousProfileEntity.setIsDeleted(false); - - anonymousProfileRepository.save(anonymousProfileEntity); - } catch (DataAccessLayerException e) { - regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), - "", e.getMessage() + ExceptionUtils.getStackTrace(e)); - - throw new TablenotAccessibleException( - PlatformErrorMessages.RPR_RGS_ANONYMOUS_PROFILE_TABLE_NOT_ACCESSIBLE.getMessage(), e); - } - regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, - "AnonymousProfileServiceImpl::saveAnonymousProfile()::exit"); - - } - - @Override - public String buildJsonStringFromPacketInfo(BiometricRecord biometricRecord, Map fieldMap, - Map fieldTypeMap, Map metaInfoMap, String statusCode, String processStage) - throws JSONException, IOException, BaseCheckedException { - - regProcLogger.info("buildJsonStringFromPacketInfo method called"); - - AnonymousProfileDTO anonymousProfileDTO = new AnonymousProfileDTO(); - anonymousProfileDTO.setProcessName( - getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.METADATA, JsonConstant.REGISTRATIONTYPE)); - anonymousProfileDTO.setProcessStage(processStage); - anonymousProfileDTO.setStatus(statusCode); - anonymousProfileDTO.setDate(DateUtils.getUTCCurrentDateTimeString()); - anonymousProfileDTO.setStartDateTime(DateUtils.getUTCCurrentDateTimeString()); - anonymousProfileDTO.setEndDateTime(DateUtils.getUTCCurrentDateTimeString()); - - List channels = new ArrayList(); - - String mappingJsonString = registrationUtility.getMappingJson(); - org.json.simple.JSONObject mappingJsonObject = mapper.readValue(mappingJsonString, - org.json.simple.JSONObject.class); - org.json.simple.JSONObject regProcessorIdentityJson = JsonUtil.getJSONObject(mappingJsonObject, - MappingJsonConstants.IDENTITY); - // set birth year - String dobValue = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.DOB), - MappingJsonConstants.VALUE); - if (fieldMap.get(dobValue) != null) { - Date dob = DateUtils.parseToDate(fieldMap.get(dobValue), dobFormat); - anonymousProfileDTO.setYearOfBirth(DateUtils.parseDateToLocalDateTime(dob).getYear()); - } - - // preferred Lang Value - String preferredaLangValue = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.PREFERRED_LANGUAGE), - MappingJsonConstants.VALUE); - anonymousProfileDTO.setPreferredLanguages(fieldMap.get(preferredaLangValue) != null ? - Arrays.asList(fieldMap.get(preferredaLangValue)) : null); - - String language = null; - if (fieldMap.get(preferredaLangValue) != null && isPreferredLangEnabled) { - language = fieldMap.get(preferredaLangValue); - } else { - language = mandatoryLanguages.get(0); - } - - // set gender - String genderValue = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.GENDER), - MappingJsonConstants.VALUE); - if (fieldMap.get(genderValue) != null) - anonymousProfileDTO.setGender(getLanguageBasedValueForSimpleType(fieldMap.get(genderValue), language)); - - // set email and phone - String emailValue = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.EMAIL), - MappingJsonConstants.VALUE); - String phoneValue = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.PHONE), - MappingJsonConstants.VALUE); - if (fieldMap.get(emailValue) != null) - channels.add(emailValue); - if (fieldMap.get(phoneValue) != null) - channels.add(phoneValue); - anonymousProfileDTO.setChannel(channels); - - // set location hierarchy - String location = JsonUtil.getJSONValue( - JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.LOCATION_HIERARCHY_FOR_PROFILING), - MappingJsonConstants.VALUE); - List locationList = Arrays.asList(location.split(",")); - List locationValues = new ArrayList<>(); - for (String locationHirerchy : locationList) { - if (fieldMap.get(locationHirerchy) != null) { - locationValues.add(getValueBasedOnType(locationHirerchy, fieldMap.get(locationHirerchy), - fieldTypeMap.get(locationHirerchy), language)); - } - } - anonymousProfileDTO.setLocation(locationValues); - - anonymousProfileDTO.setDocuments(getDocumentsDataFromMetaInfo(metaInfoMap)); - anonymousProfileDTO.setEnrollmentCenterId( - getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.METADATA, JsonConstant.CENTERID)); - - List assisted = new ArrayList<>(); - String officerId = getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.OPERATIONSDATA, JsonConstant.OFFICERID); - if (officerId != null) { - assisted.add(officerId); - } - - String supervisorId = getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.OPERATIONSDATA, - JsonConstant.SUPERVISORID); - if (supervisorId != null) { - assisted.add(supervisorId); - } - anonymousProfileDTO.setAssisted(assisted); - getExceptionAndBiometricInfo(biometricRecord, anonymousProfileDTO); - - regProcLogger.info("buildJsonStringFromPacketInfo method call ended"); - return JsonUtil.objectMapperObjectToJson(anonymousProfileDTO); - } - - private String getLanguageBasedValueForSimpleType(String fieldValue, String language) throws JSONException { - JSONArray jsonArray = new JSONArray(fieldValue); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject jsonObject = jsonArray.getJSONObject(i); - if (jsonObject.getString(LANGUAGE_LABEL).equals(language)) { - if (jsonObject.isNull(VALUE_LABEL)) - return null; - return jsonObject.getString(VALUE_LABEL); - } - } - return null; - } - - private List getDocumentsDataFromMetaInfo(Map metaInfoMap) - throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { - String metadata = metaInfoMap.get(MappingJsonConstants.DOCUMENT); - List documentTypes = new ArrayList(); - if (StringUtils.isNotEmpty(metadata)) { - JSONArray jsonArray = new JSONArray(metadata); - - for (int i = 0; i < jsonArray.length(); i++) { - if (!jsonArray.isNull(i)) { - org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); - Document document = mapper.readValue(jsonObject.toString(), Document.class); - if (document.getDocumentType() != null) { - documentTypes.add(document.getDocumentType()); - } - } - } - } - return documentTypes; - } - - private String getFieldValueFromMetaInfo(Map metaInfoMap, String field, String label) - throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { - String metadata = metaInfoMap.get(field); - String value = null; - if (StringUtils.isNotEmpty(metadata)) { - JSONArray jsonArray = new JSONArray(metadata); - - for (int i = 0; i < jsonArray.length(); i++) { - if (!jsonArray.isNull(i)) { - org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); - FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); - if (fieldValue.getLabel().equalsIgnoreCase(label)) { - value = fieldValue.getValue(); - break; - } - } - } - } - return value; - } - - private void getExceptionAndBiometricInfo(BiometricRecord biometricRecord, AnonymousProfileDTO anonymousProfileDTO) - throws JSONException { - List biometrics = new ArrayList(); - List exceptions = new ArrayList(); - - List birs = biometricRecord.getSegments(); - for (BIR bir : birs) { - HashMap othersInfo = bir.getOthers(); - - if (othersInfo == null) { - continue; - } - - String retries = null; - String digitalID = null; - boolean exceptionValue = false; - for (Map.Entry other : othersInfo.entrySet()) { - if (other.getKey().equals(JsonConstant.BIOMETRICRECORDEXCEPTION) && other.getValue().equals(TRUE)) { - exceptionValue = true; - } - if (other.getKey().equals(JsonConstant.RETRY_COUNT)) { - retries = other.getValue(); - } - if (other.getKey().equals(JsonConstant.PAYLOAD) && StringUtils.isNotEmpty(other.getValue())) { - JSONObject jsonObject = new JSONObject(other.getValue()); - digitalID = jsonObject.getString(JsonConstant.DIGITALID); - } - } - - if (exceptionValue) { - ExceptionsDTO exceptionsDTO = new ExceptionsDTO(); - exceptionsDTO.setType(bir.getBdbInfo().getType().get(0).name()); - exceptionsDTO.setSubType(String.join(" ", bir.getBdbInfo().getSubtype())); - exceptions.add(exceptionsDTO); - } else { - BiometricInfoDTO biometricInfoDTO = new BiometricInfoDTO(); - biometricInfoDTO.setType(bir.getBdbInfo().getType().get(0).name()); - if (!bir.getBdbInfo().getSubtype().isEmpty()) { - biometricInfoDTO.setSubType(String.join(" ", bir.getBdbInfo().getSubtype())); - } - biometricInfoDTO.setQualityScore(bir.getBdbInfo().getQuality().getScore()); - biometricInfoDTO.setAttempts(retries); - if (digitalID != null) { - byte[] digitalIdBytes=null; - try { - digitalIdBytes= CryptoUtil.decodeURLSafeBase64(digitalID.split("\\.")[1]); - } catch (IllegalArgumentException exception) { - digitalIdBytes = CryptoUtil.decodePlainBase64(digitalID.split("\\.")[1]); - } - biometricInfoDTO.setDigitalId(new String(digitalIdBytes)); - } - biometrics.add(biometricInfoDTO); - } - - } - anonymousProfileDTO.setBiometricInfo(biometrics); - anonymousProfileDTO.setExceptions(exceptions); - } - - private String getValueBasedOnType(String fieldName, String value, String type, String language) - throws JSONException, BaseCheckedException { - - switch (type) { - case "simpleType": - return getLanguageBasedValueForSimpleType(value,language); - case "string": - return value; - case "number": - return value; - case "documentType": - JSONObject documentTypeJSON = new JSONObject(value); - if(documentTypeJSON.isNull(VALUE_LABEL)) - return null; - return documentTypeJSON.getString(VALUE_LABEL); - case "biometricsType": - JSONObject biometricsTypeJSON = new JSONObject(value); - if(biometricsTypeJSON.isNull(VALUE_LABEL)) - return null; - return biometricsTypeJSON.getString(VALUE_LABEL); - default: - throw new BaseCheckedException( - PlatformErrorMessages.RPR_PCM_UNKNOWN_SCHEMA_DATA_TYPE.getCode(), - PlatformErrorMessages.RPR_PCM_UNKNOWN_SCHEMA_DATA_TYPE.getMessage() + - " Field name: " + fieldName + " type: " + type); - } - } - - -} +package io.mosip.registration.processor.status.service.impl; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.mosip.kernel.biometrics.entities.BIR; +import io.mosip.kernel.biometrics.entities.BiometricRecord; +import io.mosip.kernel.core.dataaccess.exception.DataAccessLayerException; +import io.mosip.kernel.core.exception.BaseCheckedException; +import io.mosip.kernel.core.logger.spi.Logger; +import io.mosip.kernel.core.util.CryptoUtil; +import io.mosip.kernel.core.util.DateUtils; +import io.mosip.kernel.core.util.StringUtils; +import io.mosip.registration.processor.core.anonymous.dto.AnonymousProfileDTO; +import io.mosip.registration.processor.core.anonymous.dto.BiometricInfoDTO; +import io.mosip.registration.processor.core.anonymous.dto.ExceptionsDTO; +import io.mosip.registration.processor.core.constant.JsonConstant; +import io.mosip.registration.processor.core.constant.LoggerFileConstant; +import io.mosip.registration.processor.core.constant.MappingJsonConstants; +import io.mosip.registration.processor.core.exception.ApisResourceAccessException; +import io.mosip.registration.processor.core.exception.PacketManagerException; +import io.mosip.registration.processor.core.exception.util.PlatformErrorMessages; +import io.mosip.registration.processor.core.logger.RegProcessorLogger; +import io.mosip.registration.processor.core.packet.dto.Document; +import io.mosip.registration.processor.core.packet.dto.FieldValue; +import io.mosip.registration.processor.core.util.JsonUtil; +import io.mosip.registration.processor.status.entity.AnonymousProfileEntity; +import io.mosip.registration.processor.status.entity.AnonymousProfilePKEntity; +import io.mosip.registration.processor.status.exception.TablenotAccessibleException; +import io.mosip.registration.processor.status.repositary.BaseRegProcRepository; +import io.mosip.registration.processor.status.service.AnonymousProfileService; +import io.mosip.registration.processor.status.utilities.RegistrationUtility; +@Component +public class AnonymousProfileServiceImpl implements AnonymousProfileService { + /** The reg proc logger. */ + private static Logger regProcLogger = RegProcessorLogger.getLogger(AnonymousProfileServiceImpl.class); + + /** The Anonymus Profile repository. */ + @Autowired + private BaseRegProcRepository anonymousProfileRepository; + + @Autowired + ObjectMapper mapper; + + @Autowired + private RegistrationUtility registrationUtility; + + /** + * The mandatory languages that should be used when dealing with field type that + * has values in multiple languages + */ + @Value("#{T(java.util.Arrays).asList('${mosip.mandatory-languages:}')}") + private List mandatoryLanguages; + + @Value("${registration.processor.applicant.dob.format:yyyy/MM/dd}") + private String dobFormat; + + @Value("${mosip.preferred-language.enabled:false}") + private boolean isPreferredLangEnabled; + + /** The constant for language label in JSON parsing */ + private static final String LANGUAGE_LABEL = "language"; + + /** The constant for value label in JSON parsing */ + private static final String VALUE_LABEL = "value"; + + /** The Constant TRUE. */ + private static final String TRUE = "true"; + + @Override + public void saveAnonymousProfile(String regId, String processStage, String profileJson) { + + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, + "AnonymousProfileServiceImpl::saveAnonymousProfile()::entry"); + try { + AnonymousProfileEntity anonymousProfileEntity=new AnonymousProfileEntity(); + AnonymousProfilePKEntity anonymousProfilePKEntity=new AnonymousProfilePKEntity(); + anonymousProfilePKEntity.setId(RegistrationUtility.generateId()); + anonymousProfileEntity.setId(anonymousProfilePKEntity); + anonymousProfileEntity.setProfile(profileJson); + anonymousProfileEntity.setProcessStage(processStage); + anonymousProfileEntity.setCreatedBy("SYSTEM"); + anonymousProfileEntity.setCreateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); + anonymousProfileEntity.setUpdateDateTime(LocalDateTime.now(ZoneId.of("UTC"))); + anonymousProfileEntity.setIsDeleted(false); + + anonymousProfileRepository.save(anonymousProfileEntity); + } catch (DataAccessLayerException e) { + regProcLogger.error(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.REGISTRATIONID.toString(), + "", e.getMessage() + ExceptionUtils.getStackTrace(e)); + + throw new TablenotAccessibleException( + PlatformErrorMessages.RPR_RGS_ANONYMOUS_PROFILE_TABLE_NOT_ACCESSIBLE.getMessage(), e); + } + regProcLogger.debug(LoggerFileConstant.SESSIONID.toString(), LoggerFileConstant.USERID.toString(), regId, + "AnonymousProfileServiceImpl::saveAnonymousProfile()::exit"); + + } + + @Override + public String buildJsonStringFromPacketInfo(BiometricRecord biometricRecord, Map fieldMap, + Map fieldTypeMap, Map metaInfoMap, String statusCode, String processStage) + throws JSONException, IOException, BaseCheckedException { + + regProcLogger.info("buildJsonStringFromPacketInfo method called"); + + AnonymousProfileDTO anonymousProfileDTO = new AnonymousProfileDTO(); + anonymousProfileDTO.setProcessName( + getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.METADATA, JsonConstant.REGISTRATIONTYPE)); + anonymousProfileDTO.setProcessStage(processStage); + anonymousProfileDTO.setStatus(statusCode); + anonymousProfileDTO.setDate(DateUtils.getUTCCurrentDateTimeString()); + anonymousProfileDTO.setStartDateTime(DateUtils.getUTCCurrentDateTimeString()); + anonymousProfileDTO.setEndDateTime(DateUtils.getUTCCurrentDateTimeString()); + + List channels = new ArrayList(); + + String mappingJsonString = registrationUtility.getMappingJson(); + org.json.simple.JSONObject mappingJsonObject = mapper.readValue(mappingJsonString, + org.json.simple.JSONObject.class); + org.json.simple.JSONObject regProcessorIdentityJson = JsonUtil.getJSONObject(mappingJsonObject, + MappingJsonConstants.IDENTITY); + // set birth year + String dobValue = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.DOB), + MappingJsonConstants.VALUE); + if (fieldMap.get(dobValue) != null) { + Date dob = DateUtils.parseToDate(fieldMap.get(dobValue), dobFormat); + anonymousProfileDTO.setYearOfBirth(DateUtils.parseDateToLocalDateTime(dob).getYear()); + } + + // preferred Lang Value + String preferredaLangValue = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.PREFERRED_LANGUAGE), + MappingJsonConstants.VALUE); + anonymousProfileDTO.setPreferredLanguages(fieldMap.get(preferredaLangValue) != null ? + Arrays.asList(fieldMap.get(preferredaLangValue)) : null); + + String language = null; + if (fieldMap.get(preferredaLangValue) != null && isPreferredLangEnabled) { + language = fieldMap.get(preferredaLangValue); + } else { + language = mandatoryLanguages.get(0); + } + + // set gender + String genderValue = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.GENDER), + MappingJsonConstants.VALUE); + if (fieldMap.get(genderValue) != null) + anonymousProfileDTO.setGender(getLanguageBasedValueForSimpleType(fieldMap.get(genderValue), language)); + + // set email and phone + String emailValue = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.EMAIL), + MappingJsonConstants.VALUE); + String phoneValue = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.PHONE), + MappingJsonConstants.VALUE); + if (fieldMap.get(emailValue) != null) + channels.add(emailValue); + if (fieldMap.get(phoneValue) != null) + channels.add(phoneValue); + anonymousProfileDTO.setChannel(channels); + + // set location hierarchy + String location = JsonUtil.getJSONValue( + JsonUtil.getJSONObject(regProcessorIdentityJson, MappingJsonConstants.LOCATION_HIERARCHY_FOR_PROFILING), + MappingJsonConstants.VALUE); + List locationList = Arrays.asList(location.split(",")); + List locationValues = new ArrayList<>(); + for (String locationHirerchy : locationList) { + if (fieldMap.get(locationHirerchy) != null) { + locationValues.add(getValueBasedOnType(locationHirerchy, fieldMap.get(locationHirerchy), + fieldTypeMap.get(locationHirerchy), language)); + } + } + anonymousProfileDTO.setLocation(locationValues); + + anonymousProfileDTO.setDocuments(getDocumentsDataFromMetaInfo(metaInfoMap)); + anonymousProfileDTO.setEnrollmentCenterId( + getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.METADATA, JsonConstant.CENTERID)); + + List assisted = new ArrayList<>(); + String officerId = getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.OPERATIONSDATA, JsonConstant.OFFICERID); + if (officerId != null) { + assisted.add(officerId); + } + + String supervisorId = getFieldValueFromMetaInfo(metaInfoMap, JsonConstant.OPERATIONSDATA, + JsonConstant.SUPERVISORID); + if (supervisorId != null) { + assisted.add(supervisorId); + } + anonymousProfileDTO.setAssisted(assisted); + getExceptionAndBiometricInfo(biometricRecord, anonymousProfileDTO); + + regProcLogger.info("buildJsonStringFromPacketInfo method call ended"); + return JsonUtil.objectMapperObjectToJson(anonymousProfileDTO); + } + + private String getLanguageBasedValueForSimpleType(String fieldValue, String language) throws JSONException { + JSONArray jsonArray = new JSONArray(fieldValue); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject jsonObject = jsonArray.getJSONObject(i); + if (jsonObject.getString(LANGUAGE_LABEL).equals(language)) { + if (jsonObject.isNull(VALUE_LABEL)) + return null; + return jsonObject.getString(VALUE_LABEL); + } + } + return null; + } + + private List getDocumentsDataFromMetaInfo(Map metaInfoMap) + throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { + String metadata = metaInfoMap.get(MappingJsonConstants.DOCUMENT); + List documentTypes = new ArrayList(); + if (StringUtils.isNotEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + + for (int i = 0; i < jsonArray.length(); i++) { + if (!jsonArray.isNull(i)) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + Document document = mapper.readValue(jsonObject.toString(), Document.class); + if (document.getDocumentType() != null) { + documentTypes.add(document.getDocumentType()); + } + } + } + } + return documentTypes; + } + + private String getFieldValueFromMetaInfo(Map metaInfoMap, String field, String label) + throws ApisResourceAccessException, PacketManagerException, IOException, JSONException { + String metadata = metaInfoMap.get(field); + String value = null; + if (StringUtils.isNotEmpty(metadata)) { + JSONArray jsonArray = new JSONArray(metadata); + + for (int i = 0; i < jsonArray.length(); i++) { + if (!jsonArray.isNull(i)) { + org.json.JSONObject jsonObject = (org.json.JSONObject) jsonArray.get(i); + FieldValue fieldValue = mapper.readValue(jsonObject.toString(), FieldValue.class); + if (fieldValue.getLabel().equalsIgnoreCase(label)) { + value = fieldValue.getValue(); + break; + } + } + } + } + return value; + } + + private void getExceptionAndBiometricInfo(BiometricRecord biometricRecord, AnonymousProfileDTO anonymousProfileDTO) + throws JSONException { + List biometrics = new ArrayList(); + List exceptions = new ArrayList(); + + List birs = biometricRecord.getSegments(); + for (BIR bir : birs) { + HashMap othersInfo = (HashMap) bir.getOthers(); + + if (othersInfo == null) { + continue; + } + + String retries = null; + String digitalID = null; + boolean exceptionValue = false; + for (Map.Entry other : othersInfo.entrySet()) { + if (other.getKey().equals(JsonConstant.BIOMETRICRECORDEXCEPTION) && other.getValue().equals(TRUE)) { + exceptionValue = true; + } + if (other.getKey().equals(JsonConstant.RETRY_COUNT)) { + retries = other.getValue(); + } + if (other.getKey().equals(JsonConstant.PAYLOAD) && StringUtils.isNotEmpty(other.getValue())) { + JSONObject jsonObject = new JSONObject(other.getValue()); + digitalID = jsonObject.getString(JsonConstant.DIGITALID); + } + } + + if (exceptionValue) { + ExceptionsDTO exceptionsDTO = new ExceptionsDTO(); + exceptionsDTO.setType(bir.getBdbInfo().getType().get(0).name()); + exceptionsDTO.setSubType(String.join(" ", bir.getBdbInfo().getSubtype())); + exceptions.add(exceptionsDTO); + } else { + BiometricInfoDTO biometricInfoDTO = new BiometricInfoDTO(); + biometricInfoDTO.setType(bir.getBdbInfo().getType().get(0).name()); + if (!bir.getBdbInfo().getSubtype().isEmpty()) { + biometricInfoDTO.setSubType(String.join(" ", bir.getBdbInfo().getSubtype())); + } + biometricInfoDTO.setQualityScore(bir.getBdbInfo().getQuality().getScore()); + biometricInfoDTO.setAttempts(retries); + if (digitalID != null) { + byte[] digitalIdBytes=null; + try { + digitalIdBytes= CryptoUtil.decodeURLSafeBase64(digitalID.split("\\.")[1]); + } catch (IllegalArgumentException exception) { + digitalIdBytes = CryptoUtil.decodePlainBase64(digitalID.split("\\.")[1]); + } + biometricInfoDTO.setDigitalId(new String(digitalIdBytes)); + } + biometrics.add(biometricInfoDTO); + } + + } + anonymousProfileDTO.setBiometricInfo(biometrics); + anonymousProfileDTO.setExceptions(exceptions); + } + + private String getValueBasedOnType(String fieldName, String value, String type, String language) + throws JSONException, BaseCheckedException { + + switch (type) { + case "simpleType": + return getLanguageBasedValueForSimpleType(value,language); + case "string": + return value; + case "number": + return value; + case "documentType": + JSONObject documentTypeJSON = new JSONObject(value); + if(documentTypeJSON.isNull(VALUE_LABEL)) + return null; + return documentTypeJSON.getString(VALUE_LABEL); + case "biometricsType": + JSONObject biometricsTypeJSON = new JSONObject(value); + if(biometricsTypeJSON.isNull(VALUE_LABEL)) + return null; + return biometricsTypeJSON.getString(VALUE_LABEL); + default: + throw new BaseCheckedException( + PlatformErrorMessages.RPR_PCM_UNKNOWN_SCHEMA_DATA_TYPE.getCode(), + PlatformErrorMessages.RPR_PCM_UNKNOWN_SCHEMA_DATA_TYPE.getMessage() + + " Field name: " + fieldName + " type: " + type); + } + } + + +} From e18c161f9680ca8b1311e769c4f276415e9e3488 Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 4 Jun 2024 11:17:06 +0530 Subject: [PATCH 24/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../validator/impl/BiometricsSignatureValidator.java | 5 ++++- .../quality/classifier/stage/QualityClassifierStage.java | 8 ++++++-- .../status/service/impl/AnonymousProfileServiceImpl.java | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java index 3b002f82fa4..c48d8c0e3f6 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java @@ -74,7 +74,10 @@ public void validateSignature(String id, String process, BiometricRecord biometr List birs = biometricRecord.getSegments(); for (BIR bir : birs) { - HashMap othersInfo = (HashMap) bir.getOthers(); + Map othersInfo = null; + if(bir.getOthers() instanceof HashMap) { + othersInfo = (Map) bir.getOthers(); + } if (othersInfo == null) { throw new BiometricSignatureValidationException("Others value is null inside BIR"); } diff --git a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java index 097b6c8350c..f1fda098bda 100644 --- a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java +++ b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java @@ -423,8 +423,12 @@ private Map getQualityTags(List birs) throws BiometricExcep for (BIR bir : birs) { if (bir.getOthers() != null) { - HashMap othersInfo = (HashMap) bir.getOthers(); + Map othersInfo = null; + if (bir.getOthers() instanceof HashMap) { + othersInfo = (Map) bir.getOthers(); + } boolean exceptionValue = false; + if(othersInfo!=null) { for (Map.Entry other : othersInfo.entrySet()) { if (other.getKey().equals(EXCEPTION)) { if (other.getValue().equals(TRUE)) { @@ -433,7 +437,7 @@ private Map getQualityTags(List birs) throws BiometricExcep break; } } - + } if (exceptionValue) { continue; } diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java index 7c28f5dda87..10817ce65f9 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java @@ -277,7 +277,10 @@ private void getExceptionAndBiometricInfo(BiometricRecord biometricRecord, Anony List birs = biometricRecord.getSegments(); for (BIR bir : birs) { - HashMap othersInfo = (HashMap) bir.getOthers(); + Map othersInfo = null; + if (bir.getOthers() instanceof HashMap) { + othersInfo = (Map) bir.getOthers(); + } if (othersInfo == null) { continue; From 0eacc93ddc648e7dc88d02f990b408e3f5e4f3ed Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Tue, 4 Jun 2024 11:40:24 +0530 Subject: [PATCH 25/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../stages/validator/impl/BiometricsSignatureValidator.java | 2 +- .../quality/classifier/stage/QualityClassifierStage.java | 2 +- .../status/service/impl/AnonymousProfileServiceImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java index c48d8c0e3f6..78498a63154 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/java/io/mosip/registration/processor/stages/validator/impl/BiometricsSignatureValidator.java @@ -75,7 +75,7 @@ public void validateSignature(String id, String process, BiometricRecord biometr List birs = biometricRecord.getSegments(); for (BIR bir : birs) { Map othersInfo = null; - if(bir.getOthers() instanceof HashMap) { + if (bir.getOthers() instanceof Map) { othersInfo = (Map) bir.getOthers(); } if (othersInfo == null) { diff --git a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java index f1fda098bda..92119deef87 100644 --- a/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java +++ b/registration-processor/pre-processor/registration-processor-quality-classifier-stage/src/main/java/io/mosip/registration/processor/quality/classifier/stage/QualityClassifierStage.java @@ -424,7 +424,7 @@ private Map getQualityTags(List birs) throws BiometricExcep if (bir.getOthers() != null) { Map othersInfo = null; - if (bir.getOthers() instanceof HashMap) { + if (bir.getOthers() instanceof Map) { othersInfo = (Map) bir.getOthers(); } boolean exceptionValue = false; diff --git a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java index 10817ce65f9..a36077bc8cd 100644 --- a/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java +++ b/registration-processor/registration-processor-registration-status-service-impl/src/main/java/io/mosip/registration/processor/status/service/impl/AnonymousProfileServiceImpl.java @@ -278,7 +278,7 @@ private void getExceptionAndBiometricInfo(BiometricRecord biometricRecord, Anony List birs = biometricRecord.getSegments(); for (BIR bir : birs) { Map othersInfo = null; - if (bir.getOthers() instanceof HashMap) { + if (bir.getOthers() instanceof Map) { othersInfo = (Map) bir.getOthers(); } From b963bd00e252312abfed3925233a00c7749d656e Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 13 Jun 2024 13:01:47 +0530 Subject: [PATCH 26/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../src/main/resources/bootstrap.properties | 2 +- .../src/main/resources/bootstrap.properties | 2 +- .../src/main/resources/bootstrap.properties | 46 ++++++------- .../src/main/resources/bootstrap.properties | 48 ++++++------- .../src/main/resources/bootstrap.properties | 48 ++++++------- .../src/main/resources/bootstrap.properties | 67 ++++++++++--------- .../src/main/resources/bootstrap.properties | 54 +++++++-------- .../src/main/resources/bootstrap.properties | 51 +++++++------- .../src/main/resources/bootstrap.properties | 48 ++++++------- .../src/main/resources/bootstrap.properties | 8 +-- .../src/main/resources/bootstrap.properties | 64 +++++++++--------- .../src/main/resources/bootstrap.properties | 40 +++++------ .../src/main/resources/bootstrap.properties | 46 ++++++------- .../src/main/resources/bootstrap.properties | 42 ++++++------ .../src/main/resources/bootstrap.properties | 67 ++++++++++--------- .../src/main/resources/bootstrap.properties | 44 ++++++------ .../src/main/resources/bootstrap.properties | 5 +- .../src/main/resources/bootstrap.properties | 2 +- .../src/main/resources/bootstrap.properties | 2 +- 19 files changed, 345 insertions(+), 341 deletions(-) diff --git a/registration-processor/core-processor/registration-processor-abis-handler-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-abis-handler-stage/src/main/resources/bootstrap.properties index 1e0fdbc3313..e7cd3ab5eef 100644 --- a/registration-processor/core-processor/registration-processor-abis-handler-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-abis-handler-stage/src/main/resources/bootstrap.properties @@ -9,7 +9,7 @@ packet.info.storage.service=registration-processor-packet-info-storage-service config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ management.endpoints.web.exposure.include=refresh registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml #server.port=9071 ##disabling health check so that client doesnt try to load properties from sprint config server every ## 5 minutes (should not be done in production) diff --git a/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/resources/bootstrap.properties index 38f0529276a..2b9824b9909 100644 --- a/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-abis-middleware-stage/src/main/resources/bootstrap.properties @@ -9,7 +9,7 @@ packet.info.storage.service=registration-processor-packet-info-storage-service config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ management.endpoints.web.exposure.include=refresh registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml #disabling health check so that client doesnt try to load properties from sprint config server every # 5 minutes (should not be done in production) health.config.enabled=false diff --git a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/resources/bootstrap.properties index b02fdad1d2a..e779b1c0160 100644 --- a/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-bio-dedupe-stage/src/main/resources/bootstrap.properties @@ -1,23 +1,23 @@ -#spring.cloud.config.uri=localhost -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -#spring.profiles.active=mz -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#server.port=9096 -##disabling health check so that client doesnt try to load properties from sprint config server every -## 5 minutes (should not be done in production) -#health.config.enabled=false -#eventbus.port=5718 -#server.servlet.path=/registrationprocessor/v1/biodedupe -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.bio.dedupe.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.bio.dedupe.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.bio.dedupe.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.bio.dedupe.eventbus.kafka.group.id} +#spring.cloud.config.uri=localhost +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +#spring.profiles.active=mz +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#server.port=9096 +##disabling health check so that client doesnt try to load properties from sprint config server every +## 5 minutes (should not be done in production) +#health.config.enabled=false +#eventbus.port=5718 +#server.servlet.path=/registrationprocessor/v1/biodedupe +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.bio.dedupe.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.bio.dedupe.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.bio.dedupe.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.bio.dedupe.eventbus.kafka.group.id} diff --git a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/resources/bootstrap.properties index 597f72b3596..ce08719b019 100644 --- a/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-biometric-authentication-stage/src/main/resources/bootstrap.properties @@ -1,24 +1,24 @@ -#spring.cloud.config.uri=localhost -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -#spring.profiles.active=dev -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -#server.port=8020 -#eventbus.port=5777 -#server.servlet.path=/registrationprocessor/v1/bioauth -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.biometric.authentication.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.biometric.authentication.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.biometric.authentication.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.biometric.authentication.eventbus.kafka.group.id} +#spring.cloud.config.uri=localhost +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +#spring.profiles.active=dev +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +#server.port=8020 +#eventbus.port=5777 +#server.servlet.path=/registrationprocessor/v1/bioauth +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.biometric.authentication.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.biometric.authentication.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.biometric.authentication.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.biometric.authentication.eventbus.kafka.group.id} diff --git a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/resources/bootstrap.properties index 1fcdb67ada1..01726f4d038 100644 --- a/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-demo-dedupe-stage/src/main/resources/bootstrap.properties @@ -1,24 +1,24 @@ -#spring.cloud.config.uri=localhost -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -#spring.profiles.active=dev -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -#server.port=8091 -#eventbus.port=5717 -# -#server.servlet.path=/registrationprocessor/v1/demodedupe -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.demo.dedupe.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.demo.dedupe.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.demo.dedupe.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.demo.dedupe.eventbus.kafka.group.id} +#spring.cloud.config.uri=localhost +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +#spring.profiles.active=dev +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +#server.port=8091 +#eventbus.port=5717 +# +#server.servlet.path=/registrationprocessor/v1/demodedupe +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.demo.dedupe.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.demo.dedupe.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.demo.dedupe.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.demo.dedupe.eventbus.kafka.group.id} diff --git a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/resources/bootstrap.properties index 3332883ab08..482c605f16a 100644 --- a/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-manual-adjudication-stage/src/main/resources/bootstrap.properties @@ -1,33 +1,34 @@ -#spring.cloud.config.uri=localhost -#spring.cloud.config.uri=http://localhost:51000/config -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -spring.profiles.active=mz -spring.cloud.config.name=registration-processor -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -config.server.file.storage.uri=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/ -#management.security.enabled=false -#server.servlet.path=/registrationprocessor/v1/manualverification -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -#server.port=8084 -#eventbus.port=5720 - -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.manual.adjudication.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.manual.adjudication.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.manual.adjudication.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.manual.adjudication.eventbus.kafka.group.id} - -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.show-sql=true - -activemq.message.format=text - -registration.processor.manual.adjudication.policy.id=mpolicy-default-adjudication -registration.processor.manual.adjudication.subscriber.id=mpartner-default-adjudication -registration.processor.queue.manual.adjudication.request.messageTTL=0 -registration.processor.manual.adjudication.reprocess.buffer.time=30 +#spring.cloud.config.uri=localhost +#spring.cloud.config.uri=http://localhost:51000/config +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +spring.profiles.active=mz +spring.cloud.config.name=registration-processor +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +packet.info.storage.service=registration-processor-packet-info-storage-service +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +#management.security.enabled=false +#server.servlet.path=/registrationprocessor/v1/manualverification +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +#server.port=8084 +#eventbus.port=5720 + +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.manual.adjudication.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.manual.adjudication.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.manual.adjudication.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.manual.adjudication.eventbus.kafka.group.id} + +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.show-sql=true + +activemq.message.format=text + +registration.processor.manual.adjudication.policy.id=mpolicy-default-adjudication +registration.processor.manual.adjudication.subscriber.id=mpartner-default-adjudication +registration.processor.queue.manual.adjudication.request.messageTTL=0 +registration.processor.manual.adjudication.reprocess.buffer.time=30 diff --git a/registration-processor/core-processor/registration-processor-uin-generator-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-uin-generator-stage/src/main/resources/bootstrap.properties index 38d85cea967..e8bde812399 100644 --- a/registration-processor/core-processor/registration-processor-uin-generator-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-uin-generator-stage/src/main/resources/bootstrap.properties @@ -1,28 +1,28 @@ -#spring.cloud.config.uri=http://localhost:51000/config -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -#spring.profiles.active=mz - -#spring.profiles.active=default -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#server.port=8099 -health.config.enabled=false -#eventbus.port=5719 -#server.servlet.path=/registrationprocessor/v1/uin-generator - -IDSCHEMAURL=https://dev.mosip.net/v1/syncdata/latestidschema -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.uin.generator.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.uin.generator.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.uin.generator.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.uin.generator.eventbus.kafka.group.id} - - +#spring.cloud.config.uri=http://localhost:51000/config +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +#spring.profiles.active=mz + +#spring.profiles.active=default +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#server.port=8099 +health.config.enabled=false +#eventbus.port=5719 +#server.servlet.path=/registrationprocessor/v1/uin-generator + +IDSCHEMAURL=https://dev.mosip.net/v1/syncdata/latestidschema +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.uin.generator.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.uin.generator.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.uin.generator.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.uin.generator.eventbus.kafka.group.id} + + #uingenerator.lost.packet.allowed.update.fields=null \ No newline at end of file diff --git a/registration-processor/core-processor/registration-processor-verification-stage/src/main/resources/bootstrap.properties b/registration-processor/core-processor/registration-processor-verification-stage/src/main/resources/bootstrap.properties index c44622edfa3..5c6e2afdf86 100644 --- a/registration-processor/core-processor/registration-processor-verification-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/core-processor/registration-processor-verification-stage/src/main/resources/bootstrap.properties @@ -1,25 +1,26 @@ -#spring.cloud.config.uri=http://localhost:51000/config -#spring.cloud.config.label=master -spring.application.name=application,registration-processor -spring.profiles.active=mz -spring.cloud.config.name=registration-processor -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -config.server.file.storage.uri=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/ -#management.security.enabled=false -#server.servlet.path=/registrationprocessor/v1/manualverification -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -#server.port=8084 -#eventbus.port=5720 - -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.verification.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.verification.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.verification.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.verification.eventbus.kafka.group.id} - -spring.jpa.properties.hibernate.format_sql=true -spring.jpa.show-sql=true +#spring.cloud.config.uri=http://localhost:51000/config +#spring.cloud.config.label=master +spring.application.name=application,registration-processor +spring.profiles.active=mz +spring.cloud.config.name=registration-processor +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +#management.security.enabled=false +#server.servlet.path=/registrationprocessor/v1/manualverification +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +#server.port=8084 +#eventbus.port=5720 + +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.verification.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.verification.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.verification.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.verification.eventbus.kafka.group.id} + +spring.jpa.properties.hibernate.format_sql=true +spring.jpa.show-sql=true diff --git a/registration-processor/init/registration-processor-packet-receiver-stage/src/main/resources/bootstrap.properties b/registration-processor/init/registration-processor-packet-receiver-stage/src/main/resources/bootstrap.properties index c6640938381..9afd19cf6c1 100644 --- a/registration-processor/init/registration-processor-packet-receiver-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/init/registration-processor-packet-receiver-stage/src/main/resources/bootstrap.properties @@ -1,25 +1,25 @@ -spring.cloud.config.uri=http://localhost:51000/config -spring.cloud.config.label=master -spring.profiles.active=default -spring.application.name=application,registration-processor -spring.cloud.config.name=registration-processor -management.endpoints.web.exposure.include=refresh -registration.processor.zone=dmz -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -server.port=8081 -server.servlet.path=/registrationprocessor/v1/packetreceiver -packet.receiver.stage=registration-processor-packet-receiver-stage -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.receiver.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ - -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5711 -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.receiver.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.receiver.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.receiver.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.receiver.eventbus.kafka.group.id} -#Since packet is not even uploaded to packetmanager, tag loading to message is disabled +spring.cloud.config.uri=http://localhost:51000/config +spring.cloud.config.label=master +spring.profiles.active=default +spring.application.name=application,registration-processor +spring.cloud.config.name=registration-processor +management.endpoints.web.exposure.include=refresh +registration.processor.zone=dmz +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +server.port=8081 +server.servlet.path=/registrationprocessor/v1/packetreceiver +packet.receiver.stage=registration-processor-packet-receiver-stage +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.receiver.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ + +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5711 +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.receiver.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.receiver.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.receiver.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.receiver.eventbus.kafka.group.id} +#Since packet is not even uploaded to packetmanager, tag loading to message is disabled mosip.regproc.message.tag.loading.disable=true \ No newline at end of file diff --git a/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties b/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties index 84c3600122c..edacc1fdc75 100644 --- a/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties +++ b/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties @@ -1,12 +1,12 @@ -spring.cloud.config.uri=localhost +spring.cloud.config.uri=http://localhost:51000/config spring.cloud.config.label=master -spring.application.name=application,registration-processor -spring.profiles.active=dev +spring.application.name=registration-processor,application +spring.profiles.active=default spring.cloud.config.name=registration-processor config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ management.endpoints.web.exposure.include=refresh registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml #management.security.enabled=false #disabling health check so that client doesnt try to load properties from sprint config server every # 5 minutes (should not be done in production) diff --git a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties index e812af75ff3..8b58c76bc3e 100644 --- a/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/post-processor/registration-processor-credential-requestor-stage/src/main/resources/bootstrap.properties @@ -1,33 +1,33 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.application.name=application,registration-processor -spring.profiles.active=dev -spring.cloud.config.name=application,registration-processor -registration.processor.identityjson=RegistrationProcessorIdentity.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -server.port=8099 -server.servlet.path=/registrationprocessor/v1/credential-requestor - -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5722 -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.credentialrequestor.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.credentialrequestor.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.credentialrequestor.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.credentialrequestor.eventbus.kafka.group.id} -mosip.registration.processor.digitalcard.credentialtype=PDFCard -mosip.registration.processor.print.credentialtype=euin -mosip.registration.processor.digitalcard.template=RPR_UIN_CARD_TEMPLATE -mosip.registration.processor.print.template=RPR_UIN_CARD_TEMPLATE -# this property is used to define issuers eg partnerid:credentialType:templateTypeCode -mosip.registration.processor.default.internal.issuers=mpartner-default-digitalcard#PDFCard#RPR_UIN_CARD_TEMPLATE - +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.application.name=application,registration-processor +spring.profiles.active=dev +spring.cloud.config.name=application,registration-processor +registration.processor.identityjson=RegistrationProcessorIdentity.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +server.port=8099 +server.servlet.path=/registrationprocessor/v1/credential-requestor + +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5722 +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.credentialrequestor.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.credentialrequestor.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.credentialrequestor.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.credentialrequestor.eventbus.kafka.group.id} +mosip.registration.processor.digitalcard.credentialtype=PDFCard +mosip.registration.processor.print.credentialtype=euin +mosip.registration.processor.digitalcard.template=RPR_UIN_CARD_TEMPLATE +mosip.registration.processor.print.template=RPR_UIN_CARD_TEMPLATE +# this property is used to define issuers eg partnerid:credentialType:templateTypeCode +mosip.registration.processor.default.internal.issuers=mpartner-default-digitalcard#PDFCard#RPR_UIN_CARD_TEMPLATE + mosip.registration.processor.default.issuers=mpartner-default-print#euin#RPR_UIN_CARD_TEMPLATE \ No newline at end of file diff --git a/registration-processor/post-processor/registration-processor-message-sender-stage/src/main/resources/bootstrap.properties b/registration-processor/post-processor/registration-processor-message-sender-stage/src/main/resources/bootstrap.properties index 0903a6d1fe6..13e9e201443 100644 --- a/registration-processor/post-processor/registration-processor-message-sender-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/post-processor/registration-processor-message-sender-stage/src/main/resources/bootstrap.properties @@ -1,21 +1,21 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.profiles.active=dev -spring.application.name=application,registration-processor -registration.processor.identityjson=RegistrationProcessorIdentity.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ - -server.port=8088 -health.config.enabled=false -management.endpoints.web.exposure.include=refresh -eventbus.port=5721 -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -server.servlet.path=/registrationprocessor/v1/sender-stage -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.message.sender.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.message.sender.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.message.sender.eventbus.kafka.poll.frequency} +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.profiles.active=dev +spring.application.name=application,registration-processor +registration.processor.identityjson=RegistrationProcessorIdentity.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ + +server.port=8088 +health.config.enabled=false +management.endpoints.web.exposure.include=refresh +eventbus.port=5721 +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +server.servlet.path=/registrationprocessor/v1/sender-stage +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.message.sender.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.message.sender.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.message.sender.eventbus.kafka.poll.frequency} mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.message.sender.eventbus.kafka.group.id} \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/resources/bootstrap.properties b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/resources/bootstrap.properties index d5cde9edd6b..51a0537f58d 100644 --- a/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/pre-processor/registration-processor-packet-classifier-stage/src/main/resources/bootstrap.properties @@ -1,24 +1,24 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.profiles.active=mz -spring.application.name=application,registration-processor -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -mosip.regproc.packet.classifier.server.port=8092 -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -mosip.regproc.packet.classifier.eventbus.port=5724 -server.servlet.path=/registrationprocessor/v1/packetclassifier -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.classifier.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.classifier.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.classifier.eventbus.kafka.poll.frequency} +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.profiles.active=mz +spring.application.name=application,registration-processor +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +mosip.regproc.packet.classifier.server.port=8092 +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +mosip.regproc.packet.classifier.eventbus.port=5724 +server.servlet.path=/registrationprocessor/v1/packetclassifier +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.classifier.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.classifier.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.classifier.eventbus.kafka.poll.frequency} mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.classifier.eventbus.kafka.group.id} \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/resources/bootstrap.properties b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/resources/bootstrap.properties index d7259bdadc6..257e4dfd028 100644 --- a/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/pre-processor/registration-processor-packet-uploader-stage/src/main/resources/bootstrap.properties @@ -1,22 +1,22 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.profiles.active=dev -spring.application.name=application,registration-processor -spring.cloud.config.name=registration-processor -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -packet.uploader.stage=registration-processor-packet-uploader-stage -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.uploader.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ -server.port=8087 -server.servlet.path=/registrationprocessor/v1/uploader -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5714 -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.uploader.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.uploader.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.uploader.eventbus.kafka.poll.frequency} +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.profiles.active=dev +spring.application.name=application,registration-processor +spring.cloud.config.name=registration-processor +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +packet.uploader.stage=registration-processor-packet-uploader-stage +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.uploader.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ +server.port=8087 +server.servlet.path=/registrationprocessor/v1/uploader +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5714 +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.uploader.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.uploader.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.uploader.eventbus.kafka.poll.frequency} mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.uploader.eventbus.kafka.group.id} \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/resources/bootstrap.properties b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/resources/bootstrap.properties index 357c90a91f9..e750d838f4f 100644 --- a/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/pre-processor/registration-processor-packet-validator-stage/src/main/resources/bootstrap.properties @@ -1,34 +1,35 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.profiles.active=mz -spring.application.name=application,registration-processor -spring.cloud.config.name=registration-processor -registration.processor.identityjson=identity-mapping.json -registration.processor.demographic.identity=identity -packet.info.storage.service=registration-processor-packet-info-storage-service -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ -mosip.kernel.jsonvalidator.property-source=APPLICATION_CONTEXT -mosip.kernel.jsonvalidator.schema-name=mosip-identity-json-schema.json -mosip.kernel.jsonvalidator.file-storage-uri=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/ -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -server.port=8088 -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5715 -server.servlet.path=/registrationprocessor/v1/packetvalidator -#packet.validator.provider=io.mosip.registration.processor.stages.validator.impl.PacketValidatorImpl -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.validator.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.validator.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.validator.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.validator.eventbus.kafka.group.id} -app.componentscan.basepackages=io.mosip.registration.processor.core.config,io.mosip.registration.processor.stages.config,io.mosip.registration.processor.status.config,io.mosip.registration.processor.rest.client.config,io.mosip.registration.processor.packet.storage.config,io.mosip.registration.processor.packet.manager.config,io.mosip.kernel.idobjectvalidator.config,io.mosip.registration.processor.core.kernel.beans,io.mosip.registration.processor.stages.packetclassifier.tagging.impl - -#All the verticle that needs to be deployed in this application should be given in the below config -mosip.regproc.verticle.deploy.classes=io.mosip.registration.processor.stages.packet.validator.PacketValidatorStage,io.mosip.registration.processor.stages.packetclassifier.PacketClassifierStage -mosip.regproc.packet.classifier.server.port=8092 +spring.cloud.config.uri=http://localhost:51000/config +spring.cloud.config.label=master +spring.application.name=registration-processor,application +spring.profiles.active=default +spring.application.name=application,registration-processor +spring.cloud.config.name=registration-processor +registration.processor.identityjson=identity-mapping.json +registration.processor.demographic.identity=identity +packet.info.storage.service=registration-processor-packet-info-storage-service +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ +mosip.kernel.jsonvalidator.property-source=APPLICATION_CONTEXT +mosip.kernel.jsonvalidator.schema-name=mosip-identity-json-schema.json +mosip.kernel.jsonvalidator.file-storage-uri=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/ +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +server.port=8088 +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5715 +server.servlet.path=/registrationprocessor/v1/packetvalidator +#packet.validator.provider=io.mosip.registration.processor.stages.validator.impl.PacketValidatorImpl +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.packet.validator.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.packet.validator.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.packet.validator.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.packet.validator.eventbus.kafka.group.id} +app.componentscan.basepackages=io.mosip.registration.processor.core.config,io.mosip.registration.processor.stages.config,io.mosip.registration.processor.status.config,io.mosip.registration.processor.rest.client.config,io.mosip.registration.processor.packet.storage.config,io.mosip.registration.processor.packet.manager.config,io.mosip.kernel.idobjectvalidator.config,io.mosip.registration.processor.core.kernel.beans,io.mosip.registration.processor.stages.packetclassifier.tagging.impl + +#All the verticle that needs to be deployed in this application should be given in the below config +mosip.regproc.verticle.deploy.classes=io.mosip.registration.processor.stages.packet.validator.PacketValidatorStage,io.mosip.registration.processor.stages.packetclassifier.PacketClassifierStage +mosip.regproc.packet.classifier.server.port=8092 mosip.regproc.packet.classifier.eventbus.port=5724 \ No newline at end of file diff --git a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/main/resources/bootstrap.properties b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/main/resources/bootstrap.properties index 4424c53b881..752f9a5e887 100644 --- a/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/main/resources/bootstrap.properties +++ b/registration-processor/pre-processor/registration-processor-securezone-notification-stage/src/main/resources/bootstrap.properties @@ -1,23 +1,23 @@ -spring.cloud.config.uri=localhost -spring.cloud.config.label=master -spring.profiles.active=dev -spring.application.name=application,registration-processor -spring.cloud.config.name=registration-processor -management.endpoints.web.exposure.include=refresh -registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -#management.security.enabled=false -config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.uploader.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ -server.port=8090 -server.servlet.path=/registrationprocessor/v1/securezone -#disabling health check so that client doesnt try to load properties from sprint config server every -# 5 minutes (should not be done in production) -health.config.enabled=false -eventbus.port=5712 -#Kafka event bus configruations -mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.securezone.notification.eventbus.kafka.commit.type} -mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.securezone.notification.eventbus.kafka.max.poll.records} -mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.securezone.notification.eventbus.kafka.poll.frequency} -mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.securezone.notification.eventbus.kafka.group.id} -#Since packet is not even uploaded to packetmanager, tag loading to message is disabled +spring.cloud.config.uri=localhost +spring.cloud.config.label=master +spring.profiles.active=dev +spring.application.name=application,registration-processor +spring.cloud.config.name=registration-processor +management.endpoints.web.exposure.include=refresh +registration.processor.zone=secure +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +#management.security.enabled=false +config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.uploader.stage}/${spring.profiles.active}/${spring.cloud.config.label}/ +server.port=8090 +server.servlet.path=/registrationprocessor/v1/securezone +#disabling health check so that client doesnt try to load properties from sprint config server every +# 5 minutes (should not be done in production) +health.config.enabled=false +eventbus.port=5712 +#Kafka event bus configruations +mosip.regproc.eventbus.kafka.commit.type=${mosip.regproc.securezone.notification.eventbus.kafka.commit.type} +mosip.regproc.eventbus.kafka.max.poll.records=${mosip.regproc.securezone.notification.eventbus.kafka.max.poll.records} +mosip.regproc.eventbus.kafka.poll.frequency=${mosip.regproc.securezone.notification.eventbus.kafka.poll.frequency} +mosip.regproc.eventbus.kafka.group.id=${mosip.regproc.securezone.notification.eventbus.kafka.group.id} +#Since packet is not even uploaded to packetmanager, tag loading to message is disabled mosip.regproc.message.tag.loading.disable=true \ No newline at end of file diff --git a/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties b/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties index 4d1ec31ca62..beac2dade79 100644 --- a/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties +++ b/registration-processor/registration-processor-common-camel-bridge/src/main/resources/bootstrap.properties @@ -5,8 +5,9 @@ spring.application.name=application,registration-processor health.config.enabled=false mosip.regproc.camel.bridge.eventbus.port=5723 registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml -camel.routes.url=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/ +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +camel.bridge=registration-processor-common-camel-bridge +camel.routes.url=${spring.cloud.config.uri}/${camel.bridge}/${spring.profiles.active}/${spring.cloud.config.label}/ mosip.regproc.camel.bridge.server.port=8022 mosip.regproc.camel.bridge.server.servlet.path=/registrationprocessor/v1/camelbridge #Kafka event bus configruations diff --git a/registration-processor/workflow-engine/registration-processor-reprocessor/src/main/resources/bootstrap.properties b/registration-processor/workflow-engine/registration-processor-reprocessor/src/main/resources/bootstrap.properties index 1403ff403b7..932c66feef9 100644 --- a/registration-processor/workflow-engine/registration-processor-reprocessor/src/main/resources/bootstrap.properties +++ b/registration-processor/workflow-engine/registration-processor-reprocessor/src/main/resources/bootstrap.properties @@ -5,7 +5,7 @@ spring.profiles.active=dev spring.cloud.config.name=registration-processor management.endpoints.web.exposure.include=refresh registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml #management.security.enabled=false #disabling health check so that client doesnt try to load properties from sprint config server every # 5 minutes (should not be done in production) diff --git a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties index f8519d90d7a..347bc8974b8 100644 --- a/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties +++ b/registration-processor/workflow-engine/registration-processor-workflow-manager-service/src/main/resources/bootstrap.properties @@ -5,7 +5,7 @@ spring.profiles.active=default spring.cloud.config.name=registration-processor management.endpoints.web.exposure.include=refresh registration.processor.zone=secure -vertx.cluster.configuration=${spring.cloud.config.uri}/*/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml +vertx.cluster.configuration=${spring.cloud.config.uri}/${spring.application.name}/${spring.profiles.active}/${spring.cloud.config.label}/hazelcast_${registration.processor.zone}.xml #management.security.enabled=false #disabling health check so that client doesnt try to load properties from sprint config server every # 5 minutes (should not be done in production) From b3db20cb3c7d0a4e9a0e8bd5b7a92ea6046adb4a Mon Sep 17 00:00:00 2001 From: Sowmya Ujjappa Banakar Date: Thu, 13 Jun 2024 13:05:15 +0530 Subject: [PATCH 27/27] MOSIP-32461 code changes Signed-off-by: Sowmya Ujjappa Banakar --- .../src/main/resources/bootstrap.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties b/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties index edacc1fdc75..81709f09f42 100644 --- a/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties +++ b/registration-processor/mosip-stage-executor/src/main/resources/bootstrap.properties @@ -1,7 +1,7 @@ -spring.cloud.config.uri=http://localhost:51000/config +spring.cloud.config.uri=localhost spring.cloud.config.label=master -spring.application.name=registration-processor,application -spring.profiles.active=default +spring.application.name=application,registration-processor +spring.profiles.active=dev spring.cloud.config.name=registration-processor config.server.file.storage.uri=${spring.cloud.config.uri}/${packet.info.storage.service}/${spring.profiles.active}/${spring.cloud.config.label}/ management.endpoints.web.exposure.include=refresh