From 70c17bb345b6ed957290eec776c026d3a25f48a1 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Thu, 15 Sep 2022 14:20:35 +0100 Subject: Fix types not refreshing after model change Loads the capability, requirement and node types based on the current VFC model. Removes the frontend cache that was being hold by the ReqAndCapabilitiesService. Issue-ID: SDC-4175 Signed-off-by: franciscovila Change-Id: I6ab9d1781c6d65e0d78ff69baf468fb9d24f9afd --- .../sdc/be/servlets/TypesFetchServlet.java | 46 ++++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java index f461378637..df7fcd5e17 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java @@ -99,12 +99,26 @@ public class TypesFetchServlet extends AbstractValidationsServlet { private final ArtifactsBusinessLogic artifactsBusinessLogic; @Inject - public TypesFetchServlet(UserBusinessLogic userBusinessLogic, ComponentInstanceBusinessLogic componentInstanceBL, ComponentsUtils componentsUtils, - ServletUtils servletUtils, ResourceImportManager resourceImportManager, PropertyBusinessLogic propertyBusinessLogic, - RelationshipTypeBusinessLogic relationshipTypeBusinessLogic, CapabilitiesBusinessLogic capabilitiesBusinessLogic, - InterfaceOperationBusinessLogic interfaceOperationBusinessLogic, ResourceBusinessLogic resourceBusinessLogic, - ArtifactsBusinessLogic artifactsBusinessLogic) { - super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager); + public TypesFetchServlet( + UserBusinessLogic userBusinessLogic, + ComponentInstanceBusinessLogic componentInstanceBL, + ComponentsUtils componentsUtils, + ServletUtils servletUtils, + ResourceImportManager resourceImportManager, + PropertyBusinessLogic propertyBusinessLogic, + RelationshipTypeBusinessLogic relationshipTypeBusinessLogic, + CapabilitiesBusinessLogic capabilitiesBusinessLogic, + InterfaceOperationBusinessLogic interfaceOperationBusinessLogic, + ResourceBusinessLogic resourceBusinessLogic, + ArtifactsBusinessLogic artifactsBusinessLogic + ) { + super( + userBusinessLogic, + componentInstanceBL, + componentsUtils, + servletUtils, + resourceImportManager + ); this.propertyBusinessLogic = propertyBusinessLogic; this.relationshipTypeBusinessLogic = relationshipTypeBusinessLogic; this.capabilitiesBusinessLogic = capabilitiesBusinessLogic; @@ -281,7 +295,11 @@ public class TypesFetchServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "404", description = "Node types not found")}) @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) - public Response getAllNodeTypesServlet(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { + public Response getAllNodeTypesServlet( + @Context final HttpServletRequest request, + @HeaderParam(value = Constants.USER_ID_HEADER) String userId, + @Parameter(description = "model", required = false) @QueryParam("model") String modelName + ) { Wrapper responseWrapper = new Wrapper<>(); Wrapper userWrapper = new Wrapper<>(); ServletContext context = request.getSession().getServletContext(); @@ -290,15 +308,16 @@ public class TypesFetchServlet extends AbstractValidationsServlet { try { init(); validateUserExist(responseWrapper, userWrapper, userId); + modelName = ValidationUtils.sanitizeInputString(modelName); if (responseWrapper.isEmpty()) { String url = request.getMethod() + " " + request.getRequestURI(); log.debug("Start handle request of {} | modifier id is {}", url, userId); - response = getComponent(resourceBusinessLogic, true, userId); + response = getComponent(resourceBusinessLogic, true, userId, modelName); if (response.isRight()) { return response.right().value(); } componentMap = new HashMap<>(response.left().value()); - response = getComponent(resourceBusinessLogic, false, userId); + response = getComponent(resourceBusinessLogic, false, userId, modelName); if (response.isRight()) { return response.right().value(); } @@ -340,13 +359,16 @@ public class TypesFetchServlet extends AbstractValidationsServlet { } - - private Either, Response> getComponent(ComponentBusinessLogic resourceBL, boolean isAbstract, String userId) { + private Either, Response> getComponent( + ComponentBusinessLogic resourceBL, + boolean isAbstract, String userId, + final String modelName + ) { Either, ResponseFormat> actionResponse; List componentList; actionResponse = resourceBL .getLatestVersionNotAbstractComponentsMetadata(isAbstract, HighestFilterEnum.HIGHEST_ONLY, ComponentTypeEnum.RESOURCE, null, userId, - null, false); + modelName, false); if (actionResponse.isRight()) { log.debug(FAILED_TO_GET_ALL_NON_ABSTRACT, ComponentTypeEnum.RESOURCE.getValue()); return Either.right(buildErrorResponse(actionResponse.right().value())); -- cgit 1.2.3-korg