Skip to content

Commit

Permalink
[SELC-5865] Feat: Added InstitutionFromRootName in getDelegationReque…
Browse files Browse the repository at this point in the history
…st (#570)
  • Loading branch information
flaminiaScarciofolo authored Oct 25, 2024
1 parent f775cb3 commit a2eb1a9
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package it.pagopa.selfcare.onboarding.service;

import com.microsoft.azure.functions.ExecutionContext;
import it.pagopa.selfcare.onboarding.common.*;
import it.pagopa.selfcare.onboarding.common.InstitutionPaSubunitType;
import it.pagopa.selfcare.onboarding.common.InstitutionType;
import it.pagopa.selfcare.onboarding.common.OnboardingStatus;
import it.pagopa.selfcare.onboarding.common.Origin;
import it.pagopa.selfcare.onboarding.dto.OnboardingAggregateOrchestratorInput;
import it.pagopa.selfcare.onboarding.entity.*;
import it.pagopa.selfcare.onboarding.exception.GenericOnboardingException;
Expand Down Expand Up @@ -52,6 +55,7 @@
import static org.openapi.quarkus.core_json.model.DelegationResponse.StatusEnum.ACTIVE;

@ApplicationScoped
@SuppressWarnings({"java:S6813","java:S107"})
public class CompletionServiceDefault implements CompletionService {

@RestClient
Expand Down Expand Up @@ -174,7 +178,7 @@ public void persistUsers(Onboarding onboarding) {
userRoleDto.getProduct().setTokenId(onboarding.getId());
try (Response response = userApi.usersUserIdPost(user.getId(), onboarding.getUserRequestUid(), userRoleDto)) {
if (!SUCCESSFUL.equals(response.getStatusInfo().getFamily())) {
throw new RuntimeException("Impossible to create or update role for user with ID: " + user.getId());
throw new GenericOnboardingException("Impossible to create or update role for user with ID: " + user.getId());
}
}
}
Expand Down Expand Up @@ -289,6 +293,7 @@ private static DelegationRequest getDelegationRequest(Onboarding onboarding) {
delegationRequest.setFrom(onboarding.getInstitution().getId());
delegationRequest.setTo(onboarding.getAggregator().getId());
delegationRequest.setInstitutionToName(onboarding.getAggregator().getDescription());
delegationRequest.setInstitutionFromRootName(onboarding.getInstitution().getParentDescription());
return delegationRequest;
}

Expand All @@ -313,7 +318,7 @@ private boolean isInstitutionPresentOnIpa(Institution institution) {
if(e.getResponse().getStatus() == 404) {
return false;
}
throw new RuntimeException(e);
throw new GenericOnboardingException(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private String convertOnboardingStatusToNotificationStatus(OnboardingStatus stat
@Override
public InstitutionToNotify retrieveInstitution(InstitutionResponse institution) {
InstitutionToNotify toNotify = new InstitutionToNotify();
toNotify.setInstitutionType(InstitutionType.valueOf(institution.getInstitutionType().value()));
toNotify.setInstitutionType(InstitutionType.valueOf(institution.getInstitutionType()));
toNotify.setDescription(institution.getDescription());
toNotify.setDigitalAddress(institution.getDigitalAddress() == null ? alternativeEmail : institution.getDigitalAddress());
toNotify.setAddress(institution.getAddress());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.pagopa.selfcare.onboarding.utils;

import it.pagopa.selfcare.onboarding.common.PartyRole;
import it.pagopa.selfcare.onboarding.common.PricingPlan;
import it.pagopa.selfcare.onboarding.common.ProductId;
import it.pagopa.selfcare.onboarding.config.NotificationConfig;
Expand All @@ -17,7 +16,6 @@
import org.openapi.quarkus.party_registry_proxy_json.model.InstitutionResource;
import org.openapi.quarkus.party_registry_proxy_json.model.UOResource;

import java.time.OffsetDateTime;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -130,7 +128,7 @@ private boolean isProductAllowed(Onboarding onboarding) {
}

private boolean isAllowedInstitutionType(InstitutionResponse institution) {
return isNullOrEmpty(consumer.allowedInstitutionTypes()) || consumer.allowedInstitutionTypes().contains(institution.getInstitutionType().name());
return isNullOrEmpty(consumer.allowedInstitutionTypes()) || consumer.allowedInstitutionTypes().contains(institution.getInstitutionType());
}

private boolean isAllowedOrigin(String origin) {
Expand Down
170 changes: 142 additions & 28 deletions apps/onboarding-functions/src/main/openapi/core.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi" : "3.0.3",
"info" : {
"title" : "selc-ms-core",
"title" : "institution-ms",
"version" : "1.0-SNAPSHOT"
},
"servers" : [ {
Expand Down Expand Up @@ -219,7 +219,7 @@
},
"/delegations/from-taxcode" : {
"post" : {
"tags" : [ "Delegation" ],
"tags" : [ "Delegation", "internal-v1" ],
"summary" : "Create an association between institution and technical partner using taxCode for both instead of internal id. It is useful when we don't know institution's internal id.",
"description" : "Create an association between institution and technical partner using taxCode for both instead of internal id. It is useful when we don't know institution's internal id.",
"operationId" : "createDelegationFromInstitutionsTaxCodeUsingPOST",
Expand Down Expand Up @@ -1548,7 +1548,7 @@
},
"/institutions/{id}" : {
"get" : {
"tags" : [ "Institution", "external-v2" ],
"tags" : [ "Institution", "external-pnpg", "external-v2", "internal-v1" ],
"summary" : "Gets the corresponding institution using internal institution id",
"description" : "Gets the corresponding institution using internal institution id",
"operationId" : "retrieveInstitutionByIdUsingGET",
Expand Down Expand Up @@ -1751,6 +1751,16 @@
}
},
"responses" : {
"200" : {
"description" : "User already exists an onboarding in status ACTIVE or SUSPENDED with that productId",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/InstitutionResponse"
}
}
}
},
"201" : {
"description" : "Created",
"content" : {
Expand Down Expand Up @@ -1861,9 +1871,74 @@
} ]
}
},
"/institutions/{institutionId}/createdAt" : {
"put" : {
"/institutions/{id}/products/{productId}" : {
"delete" : {
"tags" : [ "Institution" ],
"summary" : "The service set DELETE status on onboarding association with the product and institutionId",
"description" : "The service set DELETE status on onboarding association with the product and institutionId",
"operationId" : "deleteOnboardedInstitutionUsingDELETE",
"parameters" : [ {
"name" : "productId",
"in" : "path",
"description" : "productId",
"required" : true,
"style" : "simple",
"schema" : {
"type" : "string"
}
}, {
"name" : "id",
"in" : "path",
"description" : "id",
"required" : true,
"style" : "simple",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"204" : {
"description" : "No Content"
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"404" : {
"description" : "Not Found",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"409" : {
"description" : "Conflict",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
}
},
"security" : [ {
"bearerAuth" : [ "global" ]
} ]
}
},
"/institutions/{institutionId}/created-at" : {
"put" : {
"tags" : [ "Institution", "internal-v1" ],
"summary" : "The service updates the createdAt field for the institution-product pair",
"description" : "The service updates the createdAt field for the institution-product pair",
"operationId" : "updateCreatedAtUsingPUT",
Expand Down Expand Up @@ -2011,7 +2086,7 @@
"style" : "simple",
"schema" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV"]
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PRV", "PSP", "PT", "REC", "SA", "SCP" ]
}
} ],
"responses" : {
Expand Down Expand Up @@ -2491,8 +2566,7 @@
"type" : "string"
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP","PRV" ]
"type" : "string"
},
"origin" : {
"type" : "string"
Expand Down Expand Up @@ -2662,6 +2736,9 @@
"institutionFromName" : {
"type" : "string"
},
"institutionFromRootName" : {
"type" : "string"
},
"institutionToName" : {
"type" : "string"
},
Expand Down Expand Up @@ -2741,8 +2818,7 @@
"type" : "string"
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"type" : "string"
},
"productId" : {
"type" : "string"
Expand Down Expand Up @@ -2850,12 +2926,11 @@
"type" : "string"
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"type" : "string"
},
"origin" : {
"type" : "string",
"enum" : [ "ADE", "ANAC", "INFOCAMERE", "IPA", "IVASS", "MOCK", "SELC", "UNKNOWN", "PDND_INFOCAMERE" ]
"enum" : [ "ADE", "ANAC", "INFOCAMERE", "IPA", "IVASS", "MOCK", "PDND_INFOCAMERE", "SELC", "UNKNOWN" ]
},
"originId" : {
"type" : "string"
Expand Down Expand Up @@ -2889,7 +2964,7 @@
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PRV", "PSP", "PT", "REC", "SA", "SCP" ]
},
"subunitCode" : {
"type" : "string"
Expand All @@ -2898,6 +2973,12 @@
"type" : "string",
"enum" : [ "AOO", "UO" ]
},
"supportEmail" : {
"type" : "string"
},
"supportPhone" : {
"type" : "string"
},
"taxCode" : {
"type" : "string"
}
Expand Down Expand Up @@ -3003,8 +3084,7 @@
"type" : "boolean"
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"type" : "string"
},
"onboardings" : {
"type" : "object",
Expand Down Expand Up @@ -3146,7 +3226,7 @@
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PRV", "PSP", "PT", "REC", "SA", "SCP" ]
},
"onboarding" : {
"type" : "array",
Expand Down Expand Up @@ -3247,12 +3327,14 @@
"type" : "boolean"
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"type" : "string"
},
"istatCode" : {
"type" : "string"
},
"logo" : {
"type" : "string"
},
"onboarding" : {
"type" : "array",
"items" : {
Expand Down Expand Up @@ -3358,7 +3440,7 @@
},
"institutionType" : {
"type" : "string",
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP", "PRV" ]
"enum" : [ "AS", "CON", "GSP", "PA", "PG", "PRV", "PSP", "PT", "REC", "SA", "SCP" ]
},
"ivassCode" : {
"type" : "string"
Expand Down Expand Up @@ -3401,6 +3483,21 @@
}
}
},
"InvalidParam" : {
"title" : "InvalidParam",
"required" : [ "name", "reason" ],
"type" : "object",
"properties" : {
"name" : {
"type" : "string",
"description" : "Invalid parameter name."
},
"reason" : {
"type" : "string",
"description" : "Invalid parameter reason."
}
}
},
"OnboardedProductResponse" : {
"title" : "OnboardedProductResponse",
"type" : "object",
Expand Down Expand Up @@ -3651,23 +3748,40 @@
},
"Problem" : {
"title" : "Problem",
"required" : [ "status", "title" ],
"type" : "object",
"properties" : {
"errors" : {
"detail" : {
"type" : "string",
"description" : "Human-readable description of this specific problem."
},
"instance" : {
"type" : "string",
"description" : "A URI that describes where the problem occurred."
},
"invalidParams" : {
"type" : "array",
"description" : "A list of invalid parameters details.",
"items" : {
"$ref" : "#/components/schemas/ProblemError"
"$ref" : "#/components/schemas/InvalidParam"
}
},
"status" : {
"type" : "integer",
"format" : "int32"
"description" : "The HTTP status code.",
"format" : "int32",
"example" : 500
},
"title" : {
"type" : "string",
"description" : "Short human-readable summary of the problem."
},
"type" : {
"type" : "string",
"description" : "A URL to a page with more details regarding the problem."
}
}
},
"ProblemError" : {
"title" : "ProblemError",
"type" : "object"
},
"description" : "A \"problem detail\" as a way to carry machine-readable details of errors (https://datatracker.ietf.org/doc/html/rfc7807)"
},
"RootParentResponse" : {
"title" : "RootParentResponse",
Expand Down
Loading

0 comments on commit a2eb1a9

Please sign in to comment.