From e733f7345e33e6347a6aba03af4766121bdf5ac4 Mon Sep 17 00:00:00 2001 From: flaminiaScarciofolo <113031535+flaminiaScarciofolo@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:48:49 +0200 Subject: [PATCH] [SELC-4667] Fix: Refactor update user request (#403) --- .../connector/api/UserApiConnector.java | 2 +- .../model/user/UpdateUserRequestDto.java | 10 + .../connector/model/user/UserInfo.java | 13 +- .../rest/docs/openapi/selfcare-user-docs.json | 2616 ++++++++--------- .../connector/rest/UserConnectorImpl.java | 9 +- .../rest/model/mapper/UserMapper.java | 30 +- .../connector/rest/UserConnectorImplTest.java | 4 +- .../dashboard/core/UserV2Service.java | 7 +- .../dashboard/core/UserV2ServiceImpl.java | 2 +- .../dashboard/core/UserV2ServiceImplTest.java | 6 +- .../web/controller/UserV2Controller.java | 2 +- .../web/model/mapper/UserMapper.java | 4 - .../web/model/mapper/UserMapperV2.java | 6 +- .../web/controller/UserV2ControllerTest.java | 2 +- 14 files changed, 1215 insertions(+), 1498 deletions(-) create mode 100644 connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UpdateUserRequestDto.java diff --git a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/UserApiConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/UserApiConnector.java index 6c410f35f..a02449adf 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/UserApiConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/UserApiConnector.java @@ -29,7 +29,7 @@ public interface UserApiConnector { Boolean hasPermission(String institutionId, String permission, String productId); - void updateUser(String userId, String institutionId, MutableUserFieldsDto userDto); + void updateUser(String userId, String institutionId, UpdateUserRequestDto userDto); Collection getUsers(String institutionId, UserInfo.UserInfoFilter userInfoFilter, String loggedUserId); diff --git a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UpdateUserRequestDto.java b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UpdateUserRequestDto.java new file mode 100644 index 000000000..6711817de --- /dev/null +++ b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UpdateUserRequestDto.java @@ -0,0 +1,10 @@ +package it.pagopa.selfcare.dashboard.connector.model.user; + +import lombok.Data; + +@Data +public class UpdateUserRequestDto { + private String name; + private String surname; + private String email; +} diff --git a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UserInfo.java b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UserInfo.java index 52dad8572..c8d4239f1 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UserInfo.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/model/user/UserInfo.java @@ -1,15 +1,3 @@ -/* - * Party Process Micro Service - * This service is the party process - * - * OpenAPI spec version: {{version}} - * Contact: support@example.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - package it.pagopa.selfcare.dashboard.connector.model.user; import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; @@ -29,6 +17,7 @@ public class UserInfo { private Map products; private String status; private String institutionId; + private String userMailUuid; @Data public static class UserInfoFilter { diff --git a/connector/rest/docs/openapi/selfcare-user-docs.json b/connector/rest/docs/openapi/selfcare-user-docs.json index ad8b189e2..10c0fe6c5 100644 --- a/connector/rest/docs/openapi/selfcare-user-docs.json +++ b/connector/rest/docs/openapi/selfcare-user-docs.json @@ -1,1731 +1,1489 @@ { - "openapi": "3.0.3", - "info": { - "title": "user-ms API", - "version": "1.0.0" + "openapi" : "3.0.3", + "info" : { + "title" : "user-ms API", + "version" : "1.0.0" }, - "paths": { - "/authorize/{institutionId}": { - "get": { - "tags": [ - "User Permission Controller" - ], - "summary": "Get permission for a user in an institution", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "minLength": 1, - "type": "string" - } - }, - { - "name": "permission", - "in": "query", - "required": true, - "schema": { - "$ref": "#/components/schemas/PermissionTypeEnum" - } - }, - { - "name": "productId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "boolean" + "servers" : [ { + "url" : "http://localhost:8080", + "description" : "Auto generated value" + }, { + "url" : "http://0.0.0.0:8080", + "description" : "Auto generated value" + } ], + "paths" : { + "/authorize/{institutionId}" : { + "get" : { + "tags" : [ "User Permission Controller" ], + "summary" : "Get permission for a user in an institution", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "minLength" : 1, + "type" : "string" + } + }, { + "name" : "permission", + "in" : "query", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/PermissionTypeEnum" + } + }, { + "name" : "productId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "boolean" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/institutions/{institutionId}/products/{productId}/createdAt": { - "put": { - "tags": [ - "Institution Controller" - ], - "summary": "The API updates user's onboarded product with createdAt passed in input", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "createdAt", - "in": "query", - "required": true, - "schema": { - "$ref": "#/components/schemas/LocalDateTime" - } - }, - { - "name": "userIds", - "in": "query", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": {} - } - }, - "401": { - "description": "Not Authorized" - }, - "403": { - "description": "Not Allowed" + "/institutions/{institutionId}/products/{productId}/createdAt" : { + "put" : { + "tags" : [ "Institution Controller" ], + "summary" : "The API updates user's onboarded product with createdAt passed in input", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "createdAt", + "in" : "query", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/LocalDateTime" + } + }, { + "name" : "userIds", + "in" : "query", + "required" : true, + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { } + } + }, + "403" : { + "description" : "Not Allowed" + }, + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/institutions/{institutionId}/user-institutions": { - "get": { - "tags": [ - "Institution Controller" - ], - "summary": "The API retrieves users with optional filters in input as query params", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "productRoles", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "products", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "roles", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "states", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "userId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInstitutionResponse" + "/institutions/{institutionId}/user-institutions" : { + "get" : { + "tags" : [ "Institution Controller" ], + "summary" : "The API retrieves users with optional filters in input as query params", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productRoles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "products", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "roles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "states", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "userId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserInstitutionResponse" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/institutions/{institutionId}/users": { - "get": { - "tags": [ - "Institution Controller" - ], - "summary": "The API retrieves user's info including details of roles on products", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserProductResponse" + "/institutions/{institutionId}/users" : { + "get" : { + "tags" : [ "Institution Controller" ], + "summary" : "The API retrieves user's info including details of roles on products", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserProductResponse" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "The API retrieves paged users with optional filters in input as query params", - "parameters": [ - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "schema": { - "format": "int32", - "default": "0", - "type": "integer" - } - }, - { - "name": "productRoles", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "products", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "roles", - "in": "query", - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PartyRole" - } - } - }, - { - "name": "size", - "in": "query", - "schema": { - "format": "int32", - "default": "100", - "type": "integer" - } - }, - { - "name": "states", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "userId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInstitutionResponse" + "/users" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "The API retrieves paged users with optional filters in input as query params", + "parameters" : [ { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "page", + "in" : "query", + "schema" : { + "format" : "int32", + "default" : "0", + "type" : "integer" + } + }, { + "name" : "productRoles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "products", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "roles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/PartyRole" + } + } + }, { + "name" : "size", + "in" : "query", + "schema" : { + "format" : "int32", + "default" : "100", + "type" : "integer" + } + }, { + "name" : "states", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "userId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserInstitutionResponse" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] }, - "post": { - "tags": [ - "User Controller" - ], - "summary": "The createOrUpdateByFiscalCode function is used to create a new user or update an existing one.", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateUserDto" + "post" : { + "tags" : [ "User Controller" ], + "summary" : "The createOrUpdateByFiscalCode function is used to create a new user or update an existing one.", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/CreateUserDto" } } } }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "string" + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "string" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/emails": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "The API retrieves Users' emails using institution id and product id", - "parameters": [ - { - "name": "institutionId", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "query", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "string" + "/users/emails" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "The API retrieves Users' emails using institution id and product id", + "parameters" : [ { + "name" : "institutionId", + "in" : "query", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "query", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "type" : "string" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/ids": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "Retrieve all users given their userIds", - "parameters": [ - { - "name": "userIds", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInstitutionResponse" + "/users/ids" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "Retrieve all users given their userIds", + "parameters" : [ { + "name" : "userIds", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserInstitutionResponse" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/notification": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "Retrieve all SC-User for DataLake filtered by optional productId", - "parameters": [ - { - "name": "page", - "in": "query", - "schema": { - "format": "int32", - "default": "0", - "type": "integer" - } - }, - { - "name": "productId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "size", - "in": "query", - "schema": { - "format": "int32", - "default": "100", - "type": "integer" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UsersNotificationResponse" + "/users/notification" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "Retrieve all SC-User for DataLake filtered by optional productId", + "parameters" : [ { + "name" : "page", + "in" : "query", + "schema" : { + "format" : "int32", + "default" : "0", + "type" : "integer" + } + }, { + "name" : "productId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "size", + "in" : "query", + "schema" : { + "format" : "int32", + "default" : "100", + "type" : "integer" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UsersNotificationResponse" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/search": { - "post": { - "tags": [ - "User Controller" - ], - "summary": "Search user by fiscalCode", - "parameters": [ - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SearchUserDto" + "/users/search" : { + "post" : { + "tags" : [ "User Controller" ], + "summary" : "Search user by fiscalCode", + "parameters" : [ { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/SearchUserDto" } } } }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserDetailResponse" + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UserDetailResponse" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{id}": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "Retrieves user given userId and optional ProductId", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserResponse" + "/users/{id}" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "Retrieves user given userId and optional ProductId", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UserResponse" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{id}/details": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "Retrieves user's information from pdv: name, familyName, email, fiscalCode and workContacts", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "field", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserDetailResponse" + "/users/{id}/details" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "Retrieves user's information from pdv: name, familyName, email, fiscalCode and workContacts", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "field", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UserDetailResponse" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{id}/institution/{institutionId}/product/{productId}/status": { - "put": { - "tags": [ - "User Controller" - ], - "summary": "Service to update user product status", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "required": true, - "schema": { - "$ref": "#/components/schemas/OnboardedProductState" - } - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "401": { - "description": "Not Authorized" - }, - "403": { - "description": "Not Allowed" + "/users/{id}/institution/{institutionId}/product/{productId}/status" : { + "put" : { + "tags" : [ "User Controller" ], + "summary" : "Service to update user product status", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "status", + "in" : "query", + "required" : true, + "schema" : { + "$ref" : "#/components/schemas/OnboardedProductState" + } + } ], + "responses" : { + "204" : { + "description" : "No Content" + }, + "403" : { + "description" : "Not Allowed" + }, + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{id}/status": { - "put": { - "tags": [ - "User Controller" - ], - "summary": "Update user status with optional filter for institution, product, role and productRole", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "productRole", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "role", - "in": "query", - "schema": { - "$ref": "#/components/schemas/PartyRole" - } - }, - { - "name": "status", - "in": "query", - "schema": { - "$ref": "#/components/schemas/OnboardedProductState" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": {} - } - }, - "401": { - "description": "Not Authorized" - }, - "403": { - "description": "Not Allowed" + "/users/{id}/status" : { + "put" : { + "tags" : [ "User Controller" ], + "summary" : "Update user status with optional filter for institution, product, role and productRole", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "productRole", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "role", + "in" : "query", + "schema" : { + "$ref" : "#/components/schemas/PartyRole" + } + }, { + "name" : "status", + "in" : "query", + "schema" : { + "$ref" : "#/components/schemas/OnboardedProductState" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { } + } + }, + "403" : { + "description" : "Not Allowed" + }, + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{id}/user-registry": { - "put": { - "tags": [ - "User Controller" - ], - "summary": "Service to update user in user-registry and send notification when user data gets updated", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MutableUserFieldsDto" + "/users/{id}/user-registry" : { + "put" : { + "tags" : [ "User Controller" ], + "summary" : "Service to update user in user-registry and send notification when user data gets updated", + "parameters" : [ { + "name" : "id", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UpdateUserRequest" } } } }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": {} + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{userId}": { - "post": { - "tags": [ - "User Controller" - ], - "summary": "The createOrUpdateByUserId function is used to update existing user adding userRole.", - "parameters": [ - { - "name": "userId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AddUserRoleDto" + "/users/{userId}" : { + "post" : { + "tags" : [ "User Controller" ], + "summary" : "The createOrUpdateByUserId function is used to update existing user adding userRole.", + "parameters" : [ { + "name" : "userId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/AddUserRoleDto" } } } }, - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": {} + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{userId}/institution/{institutionId}": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "The retrieveUsers function is used to retrieve a list of users from the UserInstitution collection and userRegistry.\nAt first it try to retrieve a UserInstitution document associated with a logged user (admin)\nIf this userInstitution object is not null, so user has AdminRole, it try to retriew the userInstitutions filtered by given institutionId, roles, states, products and productRoles\nand optional given personId, otherwise it do the same query using the logged user id instead of personId.\nAfter that it retrieve personal user data, foreach userId retrieved, from userRegistry and return a stream of UserDataResponse objects containing the requested user data.", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "userId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "personId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "productRoles", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "products", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "roles", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - }, - { - "name": "states", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserDataResponse" + "/users/{userId}/institution/{institutionId}" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "The retrieveUsers function is used to retrieve a list of users from the UserInstitution collection and userRegistry.\nAt first it try to retrieve a UserInstitution document associated with a logged user (admin)\nIf this userInstitution object is not null, so user has AdminRole, it try to retriew the userInstitutions filtered by given institutionId, roles, states, products and productRoles\nand optional given personId, otherwise it do the same query using the logged user id instead of personId.\nAfter that it retrieve personal user data, foreach userId retrieved, from userRegistry and return a stream of UserDataResponse objects containing the requested user data.", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "userId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "personId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "productRoles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "products", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "roles", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + }, { + "name" : "states", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserDataResponse" } } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{userId}/institutions": { - "get": { - "tags": [ - "User Controller" - ], - "summary": "Retrieves products info and role which the user is enabled", - "parameters": [ - { - "name": "userId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "institutionId", - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "states", - "in": "query", - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserInfoResponse" + "/users/{userId}/institutions" : { + "get" : { + "tags" : [ "User Controller" ], + "summary" : "Retrieves products info and role which the user is enabled", + "parameters" : [ { + "name" : "userId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "institutionId", + "in" : "query", + "schema" : { + "type" : "string" + } + }, { + "name" : "states", + "in" : "query", + "schema" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/UserInfoResponse" } } } }, - "401": { - "description": "Not Authorized" + "403" : { + "description" : "Not Allowed" }, - "403": { - "description": "Not Allowed" + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } }, - "/users/{userId}/institutions/{institutionId}/products/{productId}": { - "delete": { - "tags": [ - "User Controller" - ], - "summary": "Delete logically the association institution and product", - "parameters": [ - { - "name": "institutionId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "productId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "userId", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "401": { - "description": "Not Authorized" - }, - "403": { - "description": "Not Allowed" + "/users/{userId}/institutions/{institutionId}/products/{productId}" : { + "delete" : { + "tags" : [ "User Controller" ], + "summary" : "Delete logically the association institution and product", + "parameters" : [ { + "name" : "institutionId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + }, { + "name" : "userId", + "in" : "path", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "204" : { + "description" : "No Content" + }, + "403" : { + "description" : "Not Allowed" + }, + "401" : { + "description" : "Not Authorized" } }, - "security": [ - { - "SecurityScheme": [] - } - ] + "security" : [ { + "SecurityScheme" : [ ] + } ] } } }, - "components": { - "schemas": { - "AddUserRoleDto": { - "required": [ - "institutionId", - "product" - ], - "type": "object", - "properties": { - "institutionId": { - "minLength": 1, - "type": "string" - }, - "product": { - "$ref": "#/components/schemas/Product" - }, - "institutionDescription": { - "type": "string" - }, - "institutionRootName": { - "type": "string" - } - } - }, - "CertifiableFieldResourceOfLocalDate": { - "type": "object", - "properties": { - "certification": { - "$ref": "#/components/schemas/CertificationEnum1" + "components" : { + "schemas" : { + "AddUserRoleDto" : { + "required" : [ "institutionId", "product" ], + "type" : "object", + "properties" : { + "institutionId" : { + "minLength" : 1, + "type" : "string" }, - "value": { - "$ref": "#/components/schemas/LocalDate" - } - } - }, - "CertifiableFieldResourceOfstring": { - "type": "object", - "properties": { - "certification": { - "$ref": "#/components/schemas/CertificationEnum" + "product" : { + "$ref" : "#/components/schemas/Product" }, - "value": { - "type": "string" - } - } - }, - "CertifiableFieldResponseString": { - "type": "object", - "properties": { - "value": { - "type": "string" + "institutionDescription" : { + "type" : "string" + }, + "institutionRootName" : { + "type" : "string" }, - "certified": { - "$ref": "#/components/schemas/CertificationEnum" + "hasToSendEmail" : { + "type" : "boolean" } } }, - "CertificationEnum": { - "enum": [ - "NONE", - "SPID" - ], - "type": "string" - }, - "CertificationEnum1": { - "enum": [ - "NONE", - "SPID" - ], - "type": "string" - }, - "CreateUserDto": { - "required": [ - "institutionId", - "user", - "product" - ], - "type": "object", - "properties": { - "institutionId": { - "minLength": 1, - "type": "string" - }, - "user": { - "$ref": "#/components/schemas/User" - }, - "product": { - "$ref": "#/components/schemas/Product1" - }, - "institutionDescription": { - "type": "string" - }, - "institutionRootName": { - "type": "string" + "CertifiableFieldResponseString" : { + "type" : "object", + "properties" : { + "value" : { + "type" : "string" + }, + "certified" : { + "$ref" : "#/components/schemas/CertificationEnum" } } }, - "Env": { - "enum": [ - "ROOT", - "DEV", - "COLL", - "PROD" - ], - "type": "string" - }, - "LocalDate": { - "format": "date", - "type": "string", - "example": "2022-03-10T00:00:00.000Z" + "CertificationEnum" : { + "enum" : [ "NONE", "SPID" ], + "type" : "string" }, - "LocalDateTime": { - "format": "date-time", - "type": "string", - "example": "2022-03-10T12:15:50.000Z" - }, - "MutableUserFieldsDto": { - "type": "object", - "properties": { - "birthDate": { - "$ref": "#/components/schemas/CertifiableFieldResourceOfLocalDate" + "CreateUserDto" : { + "required" : [ "institutionId", "user", "product" ], + "type" : "object", + "properties" : { + "institutionId" : { + "minLength" : 1, + "type" : "string" }, - "email": { - "$ref": "#/components/schemas/CertifiableFieldResourceOfstring" + "user" : { + "$ref" : "#/components/schemas/User" }, - "familyName": { - "$ref": "#/components/schemas/CertifiableFieldResourceOfstring" + "product" : { + "$ref" : "#/components/schemas/Product1" }, - "name": { - "$ref": "#/components/schemas/CertifiableFieldResourceOfstring" + "institutionDescription" : { + "type" : "string" }, - "workContacts": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/WorkContactResource" - } + "institutionRootName" : { + "type" : "string" + }, + "hasToSendEmail" : { + "type" : "boolean" } } }, - "OnboardedProductResponse": { - "type": "object", - "properties": { - "productId": { - "type": "string" + "Env" : { + "enum" : [ "ROOT", "DEV", "COLL", "PROD" ], + "type" : "string" + }, + "LocalDateTime" : { + "format" : "date-time", + "type" : "string", + "example" : "2022-03-10T12:15:50" + }, + "OnboardedProductResponse" : { + "type" : "object", + "properties" : { + "productId" : { + "type" : "string" }, - "tokenId": { - "type": "string" + "tokenId" : { + "type" : "string" }, - "status": { - "$ref": "#/components/schemas/OnboardedProductState" + "status" : { + "$ref" : "#/components/schemas/OnboardedProductState" }, - "productRole": { - "type": "string" + "productRole" : { + "type" : "string" }, - "role": { - "$ref": "#/components/schemas/PartyRole" + "role" : { + "$ref" : "#/components/schemas/PartyRole" }, - "env": { - "$ref": "#/components/schemas/Env" + "env" : { + "$ref" : "#/components/schemas/Env" }, - "createdAt": { - "$ref": "#/components/schemas/LocalDateTime" + "createdAt" : { + "$ref" : "#/components/schemas/LocalDateTime" }, - "updatedAt": { - "$ref": "#/components/schemas/LocalDateTime" + "updatedAt" : { + "$ref" : "#/components/schemas/LocalDateTime" } } }, - "OnboardedProductState": { - "enum": [ - "ACTIVE", - "PENDING", - "TOBEVALIDATED", - "SUSPENDED", - "DELETED", - "REJECTED" - ], - "type": "string" + "OnboardedProductState" : { + "enum" : [ "ACTIVE", "PENDING", "TOBEVALIDATED", "SUSPENDED", "DELETED", "REJECTED" ], + "type" : "string" }, - "PartyRole": { - "enum": [ - "MANAGER", - "DELEGATE", - "SUB_DELEGATE", - "OPERATOR" - ], - "type": "string" + "PartyRole" : { + "enum" : [ "MANAGER", "DELEGATE", "SUB_DELEGATE", "OPERATOR" ], + "type" : "string" }, - "PermissionTypeEnum": { - "enum": [ - "ADMIN", - "ANY" - ], - "type": "string" + "PermissionTypeEnum" : { + "enum" : [ "ADMIN", "ANY" ], + "type" : "string" }, - "Product": { - "required": [ - "productId", - "role" - ], - "type": "object", - "properties": { - "productId": { - "minLength": 1, - "type": "string" - }, - "role": { - "$ref": "#/components/schemas/PartyRole" - }, - "tokenId": { - "type": "string" - }, - "productRole": { - "type": "array", - "items": { - "type": "string" + "Product" : { + "required" : [ "productId", "role" ], + "type" : "object", + "properties" : { + "productId" : { + "minLength" : 1, + "type" : "string" + }, + "role" : { + "$ref" : "#/components/schemas/PartyRole" + }, + "tokenId" : { + "type" : "string" + }, + "productRoles" : { + "type" : "array", + "items" : { + "type" : "string" } } } }, - "Product1": { - "required": [ - "productId", - "role" - ], - "type": "object", - "properties": { - "productId": { - "minLength": 1, - "type": "string" - }, - "role": { - "$ref": "#/components/schemas/PartyRole" - }, - "tokenId": { - "type": "string" - }, - "productRole": { - "type": "array", - "items": { - "type": "string" + "Product1" : { + "required" : [ "productId", "role" ], + "type" : "object", + "properties" : { + "productId" : { + "minLength" : 1, + "type" : "string" + }, + "role" : { + "$ref" : "#/components/schemas/PartyRole" + }, + "tokenId" : { + "type" : "string" + }, + "productRoles" : { + "type" : "array", + "items" : { + "type" : "string" } } } }, - "QueueEvent": { - "enum": [ - "ADD", - "UPDATE" - ], - "type": "string" + "QueueEvent" : { + "enum" : [ "ADD", "UPDATE" ], + "type" : "string" + }, + "SearchUserDto" : { + "required" : [ "fiscalCode" ], + "type" : "object", + "properties" : { + "fiscalCode" : { + "pattern" : "\\S", + "type" : "string" + } + } }, - "SearchUserDto": { - "required": [ - "fiscalCode" - ], - "type": "object", - "properties": { - "fiscalCode": { - "type": "string" + "UpdateUserRequest" : { + "type" : "object", + "properties" : { + "name" : { + "type" : "string" + }, + "familyName" : { + "type" : "string" + }, + "email" : { + "type" : "string" } } }, - "User": { - "required": [ - "fiscalCode", - "institutionEmail" - ], - "type": "object", - "properties": { - "birthDate": { - "type": "string" - }, - "familyName": { - "minLength": 1, - "type": "string" - }, - "fiscalCode": { - "minLength": 1, - "type": "string" - }, - "name": { - "minLength": 1, - "type": "string" - }, - "institutionEmail": { - "minLength": 1, - "type": "string" + "User" : { + "required" : [ "fiscalCode", "institutionEmail" ], + "type" : "object", + "properties" : { + "birthDate" : { + "type" : "string" + }, + "familyName" : { + "type" : "string" + }, + "name" : { + "type" : "string" + }, + "fiscalCode" : { + "minLength" : 1, + "type" : "string" + }, + "institutionEmail" : { + "minLength" : 1, + "type" : "string" } } }, - "UserDataResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" + "UserDataResponse" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "userId": { - "type": "string" + "userId" : { + "type" : "string" }, - "institutionId": { - "type": "string" + "institutionId" : { + "type" : "string" }, - "institutionDescription": { - "type": "string" + "institutionDescription" : { + "type" : "string" }, - "institutionRootName": { - "type": "string" + "institutionRootName" : { + "type" : "string" }, - "userMailUuid": { - "type": "string" + "userMailUuid" : { + "type" : "string" }, - "role": { - "type": "string" + "role" : { + "type" : "string" }, - "status": { - "type": "string" + "status" : { + "type" : "string" }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OnboardedProductResponse" + "products" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/OnboardedProductResponse" } }, - "userResponse": { - "$ref": "#/components/schemas/UserResponse" + "userResponse" : { + "$ref" : "#/components/schemas/UserResponse" } } }, - "UserDetailResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" + "UserDetailResponse" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "fiscalCode": { - "type": "string" + "fiscalCode" : { + "type" : "string" }, - "name": { - "$ref": "#/components/schemas/CertifiableFieldResponseString" + "name" : { + "$ref" : "#/components/schemas/CertifiableFieldResponseString" }, - "familyName": { - "$ref": "#/components/schemas/CertifiableFieldResponseString" + "familyName" : { + "$ref" : "#/components/schemas/CertifiableFieldResponseString" }, - "email": { - "$ref": "#/components/schemas/CertifiableFieldResponseString" + "email" : { + "$ref" : "#/components/schemas/CertifiableFieldResponseString" }, - "workContacts": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/WorkContactResponse" + "workContacts" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/WorkContactResponse" } } } }, - "UserInfoResponse": { - "type": "object", - "properties": { - "userId": { - "type": "string" - }, - "institutions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserInstitutionRoleResponse" + "UserInfoResponse" : { + "type" : "object", + "properties" : { + "userId" : { + "type" : "string" + }, + "institutions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserInstitutionRoleResponse" } } } }, - "UserInstitutionResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" + "UserInstitutionResponse" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "userId": { - "type": "string" + "userId" : { + "type" : "string" }, - "institutionId": { - "type": "string" + "institutionId" : { + "type" : "string" }, - "institutionDescription": { - "type": "string" + "institutionDescription" : { + "type" : "string" }, - "institutionRootName": { - "type": "string" + "institutionRootName" : { + "type" : "string" }, - "userMailUuid": { - "type": "string" + "userMailUuid" : { + "type" : "string" }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OnboardedProductResponse" + "products" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/OnboardedProductResponse" } } } }, - "UserInstitutionRoleResponse": { - "type": "object", - "properties": { - "institutionId": { - "type": "string" + "UserInstitutionRoleResponse" : { + "type" : "object", + "properties" : { + "institutionId" : { + "type" : "string" }, - "institutionName": { - "type": "string" + "institutionName" : { + "type" : "string" }, - "institutionRootName": { - "type": "string" + "institutionRootName" : { + "type" : "string" }, - "role": { - "$ref": "#/components/schemas/PartyRole" + "role" : { + "$ref" : "#/components/schemas/PartyRole" }, - "status": { - "$ref": "#/components/schemas/OnboardedProductState" + "status" : { + "$ref" : "#/components/schemas/OnboardedProductState" } } }, - "UserNotificationResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" + "UserNotificationResponse" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "institutionId": { - "type": "string" + "institutionId" : { + "type" : "string" }, - "productId": { - "type": "string" + "productId" : { + "type" : "string" }, - "onboardingTokenId": { - "type": "string" + "onboardingTokenId" : { + "type" : "string" }, - "createdAt": { - "$ref": "#/components/schemas/LocalDateTime" + "createdAt" : { + "$ref" : "#/components/schemas/LocalDateTime" }, - "updatedAt": { - "$ref": "#/components/schemas/LocalDateTime" + "updatedAt" : { + "$ref" : "#/components/schemas/LocalDateTime" }, - "eventType": { - "$ref": "#/components/schemas/QueueEvent" + "eventType" : { + "$ref" : "#/components/schemas/QueueEvent" }, - "user": { - "$ref": "#/components/schemas/UserToNotify" + "user" : { + "$ref" : "#/components/schemas/UserToNotify" } } }, - "UserProductResponse": { - "type": "object", - "properties": { - "id": { - "type": "string" + "UserProductResponse" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "string" }, - "taxCode": { - "type": "string" + "taxCode" : { + "type" : "string" }, - "name": { - "type": "string" + "name" : { + "type" : "string" }, - "surname": { - "type": "string" + "surname" : { + "type" : "string" }, - "email": { - "type": "string" + "email" : { + "type" : "string" }, - "products": { - "type": "array", - "items": { - "$ref": "#/components/schemas/OnboardedProductResponse" + "products" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/OnboardedProductResponse" } } } }, - "UserResponse": { - "required": [ - "id", - "name", - "surname" - ], - "type": "object", - "properties": { - "id": { - "minLength": 1, - "type": "string" - }, - "taxCode": { - "type": "string" - }, - "name": { - "pattern": "\\S", - "type": "string" - }, - "surname": { - "pattern": "\\S", - "type": "string" - }, - "email": { - "type": "string" - }, - "workContacts": { - "type": "object", - "additionalProperties": { - "type": "string" + "UserResponse" : { + "required" : [ "id", "name", "surname" ], + "type" : "object", + "properties" : { + "id" : { + "minLength" : 1, + "type" : "string" + }, + "taxCode" : { + "type" : "string" + }, + "name" : { + "pattern" : "\\S", + "type" : "string" + }, + "surname" : { + "pattern" : "\\S", + "type" : "string" + }, + "email" : { + "type" : "string" + }, + "workContacts" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" } } } }, - "UserToNotify": { - "type": "object", - "properties": { - "userId": { - "type": "string" + "UserToNotify" : { + "type" : "object", + "properties" : { + "userId" : { + "type" : "string" }, - "name": { - "type": "string" + "name" : { + "type" : "string" }, - "familyName": { - "type": "string" + "familyName" : { + "type" : "string" }, - "email": { - "type": "string" + "email" : { + "type" : "string" }, - "role": { - "$ref": "#/components/schemas/PartyRole" + "role" : { + "$ref" : "#/components/schemas/PartyRole" }, - "productRole": { - "type": "string" + "productRole" : { + "type" : "string" }, - "relationshipStatus": { - "$ref": "#/components/schemas/OnboardedProductState" + "relationshipStatus" : { + "$ref" : "#/components/schemas/OnboardedProductState" } } }, - "UsersNotificationResponse": { - "type": "object", - "properties": { - "users": { - "type": "array", - "items": { - "$ref": "#/components/schemas/UserNotificationResponse" + "UsersNotificationResponse" : { + "type" : "object", + "properties" : { + "users" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/UserNotificationResponse" } } } }, - "WorkContactResource": { - "type": "object", - "properties": { - "email": { - "$ref": "#/components/schemas/CertifiableFieldResourceOfstring" - } - } - }, - "WorkContactResponse": { - "type": "object", - "properties": { - "email": { - "$ref": "#/components/schemas/CertifiableFieldResponseString" + "WorkContactResponse" : { + "type" : "object", + "properties" : { + "email" : { + "$ref" : "#/components/schemas/CertifiableFieldResponseString" } } } }, - "securitySchemes": { - "SecurityScheme": { - "type": "http", - "description": "Authentication", - "scheme": "bearer", - "bearerFormat": "JWT" + "securitySchemes" : { + "SecurityScheme" : { + "type" : "http", + "description" : "Authentication", + "scheme" : "bearer", + "bearerFormat" : "JWT" } } } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImpl.java index d98fedea0..75c6df705 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImpl.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImpl.java @@ -5,7 +5,6 @@ import it.pagopa.selfcare.dashboard.connector.api.UserApiConnector; import it.pagopa.selfcare.dashboard.connector.exception.ResourceNotFoundException; import it.pagopa.selfcare.dashboard.connector.model.institution.InstitutionBase; -import it.pagopa.selfcare.dashboard.connector.model.user.MutableUserFieldsDto; import it.pagopa.selfcare.dashboard.connector.model.user.User; import it.pagopa.selfcare.dashboard.connector.model.user.*; import it.pagopa.selfcare.dashboard.connector.rest.client.UserApiRestClient; @@ -138,10 +137,10 @@ public void deleteUserProduct(String userId, String institutionId, String produc } @Override - public void updateUser(String userId, String institutionId, MutableUserFieldsDto userDto) { + public void updateUser(String userId, String institutionId, UpdateUserRequestDto userDto) { log.trace("updateUser start"); log.debug("updateUser userId = {}, institutionId = {}, userDto = {}", userId, institutionId, userDto); - userApiRestClient._usersIdUserRegistryPut(userId, institutionId, userMapper.toMutableUserFieldsDto(userDto)); + userApiRestClient._usersIdUserRegistryPut(userId, institutionId, userMapper.toUpdateUserRequest(userDto)); log.trace("updateUser end"); } @@ -224,7 +223,7 @@ private it.pagopa.selfcare.user.generated.openapi.v1.dto.User buildUser(UserToCr } private Product1 buildProduct(String productId, List roles) { return Product1.builder() - .productRole(roles.stream().map(it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto.Role::getProductRole).toList()) + .productRoles(roles.stream().map(it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto.Role::getProductRole).toList()) .role(it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole.valueOf(roles.get(0).getPartyRole().name())) .productId(productId) .build(); @@ -237,7 +236,7 @@ public void createOrUpdateUserByUserId(String institutionId, String productId, S AddUserRoleDto addUserRoleDto = AddUserRoleDto.builder() .institutionId(institutionId) .product(Product.builder() - .productRole(roles.stream().map(it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto.Role::getProductRole).toList()) + .productRoles(roles.stream().map(it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto.Role::getProductRole).toList()) .role(it.pagopa.selfcare.user.generated.openapi.v1.dto.PartyRole.valueOf(roles.get(0).getPartyRole().name())) .productId(productId) .build()) diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/UserMapper.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/UserMapper.java index 22d325c73..d570fb3f7 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/UserMapper.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/UserMapper.java @@ -1,6 +1,5 @@ package it.pagopa.selfcare.dashboard.connector.rest.model.mapper; -import it.pagopa.selfcare.dashboard.connector.model.user.MutableUserFieldsDto; import it.pagopa.selfcare.dashboard.connector.model.user.User; import it.pagopa.selfcare.dashboard.connector.model.user.*; import it.pagopa.selfcare.user.generated.openapi.v1.dto.*; @@ -14,23 +13,8 @@ @Mapper(componentModel = "spring") public interface UserMapper { - - @Mapping(target = "email", expression = "java(toCertifiableFieldResourceOfString(userDto.getEmail()))") - @Mapping(target = "name", expression = "java(toCertifiableFieldResourceOfString(userDto.getName()))") - @Mapping(target = "familyName", expression = "java(toCertifiableFieldResourceOfString(userDto.getFamilyName()))") - @Mapping(target = "workContacts", expression = "java(toWorkContacts(userDto.getWorkContacts()))") - it.pagopa.selfcare.user.generated.openapi.v1.dto.MutableUserFieldsDto toMutableUserFieldsDto(MutableUserFieldsDto userDto); - - @Named("toCertifiableFieldResourceOfString") - default CertifiableFieldResourceOfstring toCertifiableFieldResourceOfString(CertifiedField field){ - if(field != null && field.getCertification() != null) { - return CertifiableFieldResourceOfstring.builder() - .certification(CertificationEnum.valueOf(field.getCertification().name())) - .value(field.getValue()) - .build(); - } - return null; - } + @Mapping(target = "familyName", source = "surname") + it.pagopa.selfcare.user.generated.openapi.v1.dto.UpdateUserRequest toUpdateUserRequest(UpdateUserRequestDto userDto); @Named("toCertifiedField") default CertifiedField toCertifiedField(CertifiableFieldResponseString field){ @@ -40,16 +24,6 @@ default CertifiedField toCertifiedField(CertifiableFieldResponseString f return null; } - @Named("toWorkContacts") - default Map toWorkContacts(Map workContactMap){ - Map resourceMap = new HashMap<>(); - if(workContactMap != null && !workContactMap.isEmpty()) { - workContactMap.forEach((s, workContact) -> resourceMap.put(s, WorkContactResource.builder().email(toCertifiableFieldResourceOfString(workContact.getEmail())).build())); - return resourceMap; - } - return null; - } - @Mapping(target = "name", expression = "java(toCertifiedField(response.getName()))") @Mapping(target = "familyName", expression = "java(toCertifiedField(response.getFamilyName()))") @Mapping(target = "email", expression = "java(toCertifiedField(response.getEmail()))") diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImplTest.java index 463335f87..85248b315 100644 --- a/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImplTest.java +++ b/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/UserConnectorImplTest.java @@ -232,12 +232,12 @@ void update() { // given final String userId = "userId"; final String institutionId = "institutionId"; - final var user = new MutableUserFieldsDto(); + final var user = new UpdateUserRequestDto(); // when userConnector.updateUser(userId, institutionId, user); // then verify(userApiRestClient, times(1)) - ._usersIdUserRegistryPut(userId, institutionId, it.pagopa.selfcare.user.generated.openapi.v1.dto.MutableUserFieldsDto.builder().build()); + ._usersIdUserRegistryPut(userId, institutionId,new UpdateUserRequest()); verifyNoMoreInteractions(userApiRestClient); } diff --git a/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2Service.java b/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2Service.java index aebf8847d..a95b8afd6 100644 --- a/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2Service.java +++ b/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2Service.java @@ -1,10 +1,7 @@ package it.pagopa.selfcare.dashboard.core; import it.pagopa.selfcare.dashboard.connector.model.institution.InstitutionBase; -import it.pagopa.selfcare.dashboard.connector.model.user.MutableUserFieldsDto; -import it.pagopa.selfcare.dashboard.connector.model.user.User; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import it.pagopa.selfcare.dashboard.connector.model.user.UserToCreate; +import it.pagopa.selfcare.dashboard.connector.model.user.*; import java.util.Collection; import java.util.List; @@ -24,7 +21,7 @@ public interface UserV2Service { User searchUserByFiscalCode(String fiscalCode, String institutionId); - void updateUser(String id, String institutionId, MutableUserFieldsDto userDto); + void updateUser(String id, String institutionId, UpdateUserRequestDto userDto); Collection getUsersByInstitutionId(String institutionId, String productId, List productRoles, String loggedUserId); diff --git a/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImpl.java index 13e0fec1f..3435419dd 100644 --- a/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImpl.java @@ -93,7 +93,7 @@ public User searchUserByFiscalCode(String fiscalCode, String institutionId) { } @Override - public void updateUser(String id, String institutionId, MutableUserFieldsDto userDto) { + public void updateUser(String id, String institutionId, UpdateUserRequestDto userDto) { log.trace("updateUser start"); log.debug(LogUtils.CONFIDENTIAL_MARKER, "updateUser id = {}, institutionId = {}, userDto = {}", id, institutionId, userDto); Assert.notNull(id, "UUID is required"); diff --git a/core/src/test/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImplTest.java index 7d84a3064..558d8103d 100644 --- a/core/src/test/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/dashboard/core/UserV2ServiceImplTest.java @@ -147,9 +147,7 @@ void updateUser() { //given final String institutionId = "institutionId"; final String userId = "userId"; - final MutableUserFieldsDto user = mockInstance(new MutableUserFieldsDto(), "setWorkContacts"); - WorkContact workContact = mockInstance(new WorkContact()); - user.setWorkContacts(Map.of(institutionId, workContact)); + final UpdateUserRequestDto user = mockInstance(new UpdateUserRequestDto()); Institution institutionMock = mockInstance(new Institution()); when(msCoreConnectorMock.getInstitution(Mockito.anyString())) .thenReturn(institutionMock); @@ -169,7 +167,7 @@ void updateUser_nullInstitution() { //given final String institutionId = "institutionId"; final String userId = "userId"; - final MutableUserFieldsDto user = mockInstance(new MutableUserFieldsDto(), "setWorkContacts"); + final UpdateUserRequestDto user = mockInstance(new UpdateUserRequestDto()); //when Executable executable = () -> userService.updateUser(userId, institutionId, user); //then diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/UserV2Controller.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/UserV2Controller.java index 901e80e0b..e24363dc7 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/UserV2Controller.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/UserV2Controller.java @@ -145,7 +145,7 @@ public void updateUser(@ApiParam("${swagger.dashboard.user.model.id}") UpdateUserDto updateUserDto) { log.trace("updateUser start"); log.debug(LogUtils.CONFIDENTIAL_MARKER, "userId = {}, institutionId = {}, userDto = {}", userId, institutionId, updateUserDto); - userService.updateUser(userId, institutionId, userMapperV2.fromUpdateUser(institutionId, updateUserDto)); + userService.updateUser(userId, institutionId, userMapperV2.fromUpdateUser(updateUserDto)); log.trace("updateUser end"); } diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapper.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapper.java index dfdd90d90..92907bfbc 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapper.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapper.java @@ -108,10 +108,6 @@ private static T toInstitutionUser(UserInfo resource.setName(CertifiedFieldMapper.toValue(model.getUser().getName())); resource.setSurname(CertifiedFieldMapper.toValue(model.getUser().getFamilyName())); resource.setEmail(CertifiedFieldMapper.toValue(model.getUser().getEmail())); - Optional.ofNullable(model.getUser().getWorkContact(model.getInstitutionId())) - .map(WorkContact::getEmail) - .map(CertifiedFieldMapper::toValue) - .ifPresent(resource::setEmail); } if (model.getProducts() != null) { resource.setProducts(model.getProducts().values().stream() diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapperV2.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapperV2.java index 3db868fe9..90690b9be 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapperV2.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/model/mapper/UserMapperV2.java @@ -19,11 +19,7 @@ public interface UserMapperV2 { @Mapping(target = "email", expression = "java(toCertifiedFieldResource(model.getEmail()))") UserResource toUserResource(User model); - @Mapping(source = "userDto.name", target = "name", qualifiedByName = "mapCertifiedField") - @Mapping(target = "email", ignore = true) - @Mapping(target = "workContacts", expression = "java(getEmail(userDto, institutionId))") - @Mapping(source = "userDto.surname", target = "familyName", qualifiedByName = "mapCertifiedField") - MutableUserFieldsDto fromUpdateUser(String institutionId, UpdateUserDto userDto); + UpdateUserRequestDto fromUpdateUser(UpdateUserDto userDto); @Named("toCertifiedFieldResource") default CertifiedFieldResource toCertifiedFieldResource(CertifiedField certifiedField){ diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/UserV2ControllerTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/UserV2ControllerTest.java index e06ce8521..927cc7002 100644 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/UserV2ControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/UserV2ControllerTest.java @@ -210,7 +210,7 @@ void updateUser(@Value("classpath:stubs/updateUserDto.json") Resource updateUser .andExpect(content().string(emptyString())); //then verify(userServiceMock, times(1)) - .updateUser(eq(id), eq(institutionId), any(MutableUserFieldsDto.class)); + .updateUser(eq(id), eq(institutionId), any(UpdateUserRequestDto.class)); Mockito.verifyNoMoreInteractions(userServiceMock); }