From 6407c774fb07ee0a59808c33d71d112f52a27743 Mon Sep 17 00:00:00 2001 From: AjayRaturi123 <104556215+AjayRaturi123@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:36:42 +0530 Subject: [PATCH 1/4] Update api in yml. --- .../src/main/resources/sde-open-api.yml | 465 ++++++++++++------ 1 file changed, 324 insertions(+), 141 deletions(-) diff --git a/modules/sde-core/src/main/resources/sde-open-api.yml b/modules/sde-core/src/main/resources/sde-open-api.yml index 11b01b5ba..d0bb85e17 100644 --- a/modules/sde-core/src/main/resources/sde-open-api.yml +++ b/modules/sde-core/src/main/resources/sde-open-api.yml @@ -4,10 +4,10 @@ info: description: This Service handles all DFT data provider and consumer operations version: '1.0' servers: - - url: https://dft-api.dev.demo.catena-x.net/api + - url: https://dft-api.int.demo.catena-x.net/api description: Generated server url security: - - Authentication: [] + - bearerAuth: [] paths: /{submodel}/upload: post: @@ -20,13 +20,11 @@ paths: required: true schema: type: string - example: null - name: meta_data in: query required: true schema: type: string - example: null requestBody: content: application/json: @@ -38,9 +36,6 @@ paths: file: type: string format: binary - example: null - example: null - example: null responses: '200': description: OK @@ -48,8 +43,6 @@ paths: '*/*': schema: type: string - example: null - example: null /{submodel}/manualentry: post: tags: @@ -61,13 +54,11 @@ paths: required: true schema: type: string - example: null requestBody: content: application/json: schema: $ref: '#/components/schemas/SubmodelJsonRequestObjectNode' - example: null required: true responses: '200': @@ -76,8 +67,6 @@ paths: '*/*': schema: type: string - example: null - example: null /subscribe-data-offers: post: tags: @@ -88,7 +77,6 @@ paths: application/json: schema: $ref: '#/components/schemas/ConsumerRequest' - example: null required: true responses: '200': @@ -97,8 +85,24 @@ paths: '*/*': schema: type: object - example: null - example: null + /role: + post: + tags: + - role-management-controller + operationId: saveRole + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RolePojo' + required: true + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/RolePojo' /role/{role}/permissions: get: tags: @@ -110,7 +114,6 @@ paths: required: true schema: type: string - example: null responses: '200': description: OK @@ -118,33 +121,25 @@ paths: '*/*': schema: type: array - maxItems: 3 - example: null items: type: string - example: null - example: null post: tags: - role-management-controller - operationId: fileUpload_1 + operationId: saveRolePermission parameters: - name: role in: path required: true schema: type: string - example: null requestBody: content: application/json: schema: type: array - example: null items: type: string - example: null - example: null required: true responses: '200': @@ -153,23 +148,72 @@ paths: '*/*': schema: type: string - example: null - example: null + /contract-agreements/{negotiationId}/provider/decline: + post: + tags: + - contract-management-controller + operationId: declineContractProvider + parameters: + - name: negotiationId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + /contract-agreements/{negotiationId}/provider/cancel: + post: + tags: + - contract-management-controller + operationId: cancelContractProvider + parameters: + - name: negotiationId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + /contract-agreements/{negotiationId}/consumer/cancel: + post: + tags: + - contract-management-controller + operationId: cancelContractConsumer + parameters: + - name: negotiationId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: object /connectors-discovery: post: tags: - - consumer-controller + - portal-proxy-controller operationId: fetchConnectorInfo requestBody: content: application/json: schema: type: array - example: null items: type: string - example: null - example: null required: true responses: '200': @@ -178,11 +222,8 @@ paths: '*/*': schema: type: array - maxItems: 3 - example: null items: $ref: '#/components/schemas/ConnectorInfo' - example: null /{submodel}/public/{uuid}: get: tags: @@ -194,13 +235,11 @@ paths: required: true schema: type: string - example: null - name: uuid in: path required: true schema: type: string - example: null responses: '200': description: OK @@ -210,9 +249,6 @@ paths: type: object additionalProperties: type: object - example: null - example: null - example: null /user/role/permissions: get: tags: @@ -225,17 +261,55 @@ paths: '*/*': schema: type: array - maxItems: 3 - example: null items: type: string - example: null - example: null + /usecases: + get: + tags: + - submodel-controller + operationId: getAllUsecases + responses: + '200': + description: OK + content: + '*/*': + schema: + type: array + items: + type: object + additionalProperties: + type: object + /unified-bpn-validation/{bpn}: + get: + tags: + - portal-proxy-controller + operationId: unifiedBpnValidation + parameters: + - name: bpn + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + $ref: '#/components/schemas/UnifiedBpnValidationResponse' /submodels: get: tags: - submodel-controller operationId: getAllSubmodels + parameters: + - name: usecases + in: query + required: false + schema: + type: array + items: + type: string responses: '200': description: OK @@ -243,15 +317,10 @@ paths: '*/*': schema: type: array - maxItems: 3 - example: null items: type: object additionalProperties: type: string - example: null - example: null - example: null /submodels/{submodelName}: get: tags: @@ -263,7 +332,6 @@ paths: required: true schema: type: string - example: null responses: '200': description: OK @@ -273,9 +341,30 @@ paths: type: object additionalProperties: type: object - example: null - example: null - example: null + /submodels/schema-details: + get: + tags: + - submodel-controller + operationId: getAllSubmodelswithDetails + parameters: + - name: usecases + in: query + required: false + schema: + type: array + items: + type: string + responses: + '200': + description: OK + content: + '*/*': + schema: + type: array + items: + type: object + additionalProperties: + type: object /query-data-offers: get: tags: @@ -287,7 +376,18 @@ paths: required: true schema: type: string - example: null + - name: maxLimit + in: query + required: false + schema: + type: integer + format: int32 + - name: offset + in: query + required: false + schema: + type: integer + format: int32 responses: '200': description: OK @@ -295,8 +395,6 @@ paths: '*/*': schema: type: object - example: null - example: null /processing-report: get: tags: @@ -309,14 +407,12 @@ paths: schema: type: integer format: int32 - example: null - name: pageSize in: query required: true schema: type: integer format: int32 - example: null responses: '200': description: OK @@ -324,7 +420,33 @@ paths: application/json: schema: $ref: '#/components/schemas/ProcessReportPageResponse' - example: null + /processing-report/{submodel}/success-details/{id}: + get: + tags: + - process-report-controller + operationId: getProcessSuccessDetailsReportById + parameters: + - name: id + in: path + required: true + schema: + type: string + - name: submodel + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + type: array + items: + type: string /processing-report/{id}: get: tags: @@ -336,7 +458,6 @@ paths: required: true schema: type: string - example: null responses: '200': description: OK @@ -344,7 +465,26 @@ paths: application/json: schema: $ref: '#/components/schemas/ProcessReport' - example: null + /processing-report/failure-details/{id}: + get: + tags: + - process-report-controller + operationId: getProcessFailureDetailsReportById + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ProcessFailureDetails' /ping: get: tags: @@ -357,12 +497,10 @@ paths: '*/*': schema: type: string - example: null - example: null /legal-entities: get: tags: - - consumer-controller + - portal-proxy-controller operationId: fetchLegalEntitiesData parameters: - name: searchText @@ -370,21 +508,18 @@ paths: required: true schema: type: string - example: null - name: page in: query required: true schema: type: integer format: int32 - example: null - name: size in: query required: true schema: type: integer format: int32 - example: null responses: '200': description: OK @@ -392,31 +527,69 @@ paths: '*/*': schema: type: array - maxItems: 3 - example: null items: $ref: '#/components/schemas/LegalEntityResponse' - example: null - /contract-offers: + /contract-agreements/{negotiationId}/consumer/decline: get: tags: - - consumer-controller - operationId: queryOnDataOffersStatus + - contract-management-controller + operationId: declineContractConsumer + parameters: + - name: negotiationId + in: path + required: true + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + /contract-agreements/provider: + get: + tags: + - contract-management-controller + operationId: contractAgreementsProvider + parameters: + - name: maxLimit + in: query + required: false + schema: + type: integer + format: int32 + - name: offset + in: query + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + /contract-agreements/consumer: + get: + tags: + - contract-management-controller + operationId: contractAgreementsConsumer parameters: - - name: limit + - name: maxLimit in: query required: false schema: type: integer format: int32 - example: null - name: offset in: query required: false schema: type: integer format: int32 - example: null responses: '200': description: OK @@ -424,8 +597,30 @@ paths: application/json: schema: type: object - example: null - example: null + /cache/clear-memebercompany-bpnnumber: + get: + tags: + - ping-controller + operationId: clearBpnnumberCache + responses: + '200': + description: OK + content: + '*/*': + schema: + type: string + /cache/clear-ddtrurl: + get: + tags: + - ping-controller + operationId: clearDdtrurlCache + responses: + '200': + description: OK + content: + '*/*': + schema: + type: string /{submodel}/delete/{processId}: delete: tags: @@ -437,22 +632,34 @@ paths: required: true schema: type: string - example: null - name: submodel in: path required: true schema: type: string - example: null responses: '200': description: OK content: application/json: schema: - type: string - example: null - example: null + type: object + additionalProperties: + type: string + /role/{role}: + delete: + tags: + - role-management-controller + operationId: deleteRole + parameters: + - name: role + in: path + required: true + schema: + type: string + responses: + '200': + description: OK components: schemas: SubmodelJsonRequestObjectNode: @@ -460,31 +667,23 @@ components: properties: row_data: type: array - example: null items: type: object - example: null type_of_access: type: string - example: null bpn_numbers: type: array - example: null items: type: string - example: null usage_policies: type: array - example: null items: $ref: '#/components/schemas/UsagePolicies' - example: null UsagePolicies: type: object properties: type: type: string - example: null enum: - DURATION - PURPOSE @@ -492,16 +691,13 @@ components: - CUSTOM value: type: string - example: null typeOfAccess: type: string - example: null enum: - RESTRICTED - UNRESTRICTED durationUnit: type: string - example: null enum: - YEAR - MONTH @@ -509,7 +705,6 @@ components: - HOUR - MINUTE - SECOND - example: null ConsumerRequest: required: - connectorId @@ -520,21 +715,16 @@ components: properties: connectorId: type: string - example: null providerUrl: type: string - example: null offers: type: array - example: null items: $ref: '#/components/schemas/OfferRequest' policies: type: array - example: null items: $ref: '#/components/schemas/UsagePolicies' - example: null OfferRequest: required: - assetId @@ -543,51 +733,55 @@ components: properties: offerId: type: string - example: null assetId: type: string - example: null policyId: type: string - example: null - example: null + RolePojo: + type: object + properties: + role: + type: string + description: + type: string ConnectorInfo: type: object properties: bpn: type: string - example: null connectorEndpoint: type: array - example: null items: type: string - example: null - example: null + UnifiedBpnValidationResponse: + type: object + properties: + msg: + type: string + bpnStatus: + type: string + enum: + - FULL_PARTNER + - NOT_PARTNER + - PARTNER ProcessReport: type: object properties: processId: type: string - example: null csvType: type: string - example: null numberOfItems: type: integer format: int32 - example: null numberOfFailedItems: type: integer format: int32 - example: null numberOfSucceededItems: type: integer format: int32 - example: null status: type: string - example: null enum: - IN_PROGRESS - COMPLETED @@ -595,73 +789,62 @@ components: startDate: type: string format: date-time - example: null endDate: type: string format: date-time - example: null bpnNumbers: type: array - example: null items: type: string - example: null typeOfAccess: type: string - example: null usagePolicies: type: string - example: null numberOfUpdatedItems: type: integer format: int32 - example: null numberOfDeletedItems: type: integer format: int32 - example: null referenceProcessId: type: string - example: null - example: null ProcessReportPageResponse: type: object properties: pageNumber: type: integer format: int32 - example: null pageSize: type: integer format: int32 - example: null totalItems: type: integer format: int64 - example: null items: type: array - example: null items: $ref: '#/components/schemas/ProcessReport' - example: null + ProcessFailureDetails: + type: object + properties: + uuid: + type: string + processId: + type: string + log: + type: string + dateTime: + type: string + format: date-time LegalEntityResponse: type: object properties: name: type: string - example: null bpn: type: string - example: null - example: null securitySchemes: - Authentication: - type: oauth2 - flows: - authorizationCode: - authorizationUrl: https://centralidp.dev.demo.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/auth - tokenUrl: https://centralidp.dev.demo.catena-x.net/auth/realms/CX-Central/protocol/openid-connect/token - scopes: - read: read access for user - write: write access for user + bearerAuth: + type: http + scheme: bearer + bearerFormat: JWT From f29e4a43fe268b09d4a3a199629ba9c864919fbf Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Mon, 14 Aug 2023 13:23:14 +0530 Subject: [PATCH 2/4] added missing license header --- .../src/main/resources/sde-open-api.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/sde-core/src/main/resources/sde-open-api.yml b/modules/sde-core/src/main/resources/sde-open-api.yml index d0bb85e17..dab5f4d83 100644 --- a/modules/sde-core/src/main/resources/sde-open-api.yml +++ b/modules/sde-core/src/main/resources/sde-open-api.yml @@ -1,3 +1,23 @@ +#******************************************************************************** +# Copyright (c) 2023 T-Systems International GmbH +# Copyright (c) 2023 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. + +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0. +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# SPDX-License-Identifier: Apache-2.0 +#*******************************************************************************/ + openapi: 3.0.1 info: title: DFT/SDE API information From 557641d9cb49ad42d1f022db30f7b40a6149c950 Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Mon, 14 Aug 2023 19:25:12 +0530 Subject: [PATCH 3/4] correct variable for business partner search --- .../tractusx/sde/portal/api/IPartnerPoolExternalServiceApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sde-external-services/portal/src/main/java/org/eclipse/tractusx/sde/portal/api/IPartnerPoolExternalServiceApi.java b/modules/sde-external-services/portal/src/main/java/org/eclipse/tractusx/sde/portal/api/IPartnerPoolExternalServiceApi.java index a7c55c714..75b4b899c 100644 --- a/modules/sde-external-services/portal/src/main/java/org/eclipse/tractusx/sde/portal/api/IPartnerPoolExternalServiceApi.java +++ b/modules/sde-external-services/portal/src/main/java/org/eclipse/tractusx/sde/portal/api/IPartnerPoolExternalServiceApi.java @@ -29,6 +29,6 @@ public interface IPartnerPoolExternalServiceApi { @GetMapping(path = "/api/catena/legal-entities") - LegalEntityData fetchLegalEntityData(@RequestParam String name, @RequestParam Integer page, @RequestParam Integer size); + LegalEntityData fetchLegalEntityData(@RequestParam String legalName, @RequestParam Integer page, @RequestParam Integer size); } From c4141d51e4ce7226c0e83a53ed216a5e7c2fa4ae Mon Sep 17 00:00:00 2001 From: Sachin Argade Date: Wed, 16 Aug 2023 10:35:59 +0530 Subject: [PATCH 4/4] Handle globaly FeignException --- .../GlobalDefaultExceptionHandler.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/sde-common/src/main/java/org/eclipse/tractusx/sde/common/exception/GlobalDefaultExceptionHandler.java b/modules/sde-common/src/main/java/org/eclipse/tractusx/sde/common/exception/GlobalDefaultExceptionHandler.java index 42ed0cf53..97f7de166 100644 --- a/modules/sde-common/src/main/java/org/eclipse/tractusx/sde/common/exception/GlobalDefaultExceptionHandler.java +++ b/modules/sde-common/src/main/java/org/eclipse/tractusx/sde/common/exception/GlobalDefaultExceptionHandler.java @@ -35,6 +35,11 @@ import org.springframework.web.context.request.WebRequest; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import feign.FeignException; import jakarta.validation.ConstraintViolationException; import lombok.extern.slf4j.Slf4j; @@ -65,6 +70,29 @@ public ResponseEntity> handleValidationException(ValidationE return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); } + @ExceptionHandler(FeignException.class) + public ResponseEntity> handleFeignException(FeignException ex, WebRequest request) { + log.error("FeignException: " + ex.getMessage()); + log.error("FeignException RequestBody: " + ex.request()); + log.error("FeignException ResponseBody: " + ex.contentUTF8()); + ObjectMapper objmap = new ObjectMapper(); + Map errorResponse = new HashMap<>(); + errorResponse.put("msg", "Error in remote service execution"); + try { + @SuppressWarnings("unchecked") + Map map = objmap.readValue(ex.contentUTF8(), Map.class); + Object object = map.get("errors"); + if (object != null) + errorResponse = prepareErrorResponse(object.toString()); + } catch (JsonMappingException e) { + log.error("FeignException JsonMappingException " + e.getMessage()); + } catch (JsonProcessingException e) { + log.error("FeignException JsonProcessingException " + e.getMessage()); + } + + return new ResponseEntity<>(errorResponse, HttpStatus.BAD_REQUEST); + } + @ExceptionHandler(ConstraintViolationException.class) public ResponseEntity> handleConstraintValidationException(ConstraintViolationException ex, WebRequest request) {