From fbab79aeaccf74385c9a55b697a1055a86bdf171 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Tue, 21 Jun 2022 15:06:12 +0100 Subject: Block interface operation edit in checkedin VFC VFC interface operation could be edited even when checked in, due to an incorrect viewOnly input passed to the modal component. Blocks edition also in the backend, by verifying if the component can be edited. Change-Id: I816e28897273aaa677237ca55794bb3dc8460975 Issue-ID: SDC-4058 Signed-off-by: andre.schmid Signed-off-by: JvD_Ericsson --- .../impl/ComponentInterfaceOperationBusinessLogic.java | 2 ++ .../sdc/be/servlets/ComponentInterfaceOperationServlet.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'catalog-be/src/main/java') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java index 461edd11dc..eb8b35ec60 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java @@ -166,11 +166,13 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic } public Optional updateResourceInterfaceOperation(final String componentId, + final String user, final InterfaceDefinition interfaceDefinition, final ComponentTypeEnum componentTypeEnum, final Wrapper errorWrapper, final boolean shouldLock) throws BusinessLogicException { final var component = getComponent(componentId); + validateCanWorkOnComponent(component, user); ResponseFormat responseFormat; Map componentInterfaceMap = component.getInterfaces(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInterfaceOperationServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInterfaceOperationServlet.java index 3b8bfe5bd7..64b8500979 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInterfaceOperationServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInterfaceOperationServlet.java @@ -50,6 +50,7 @@ import org.openecomp.sdc.be.components.impl.ComponentInterfaceOperationBusinessL import org.openecomp.sdc.be.components.impl.ResourceImportManager; import org.openecomp.sdc.be.components.impl.aaf.AafPermission; import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed; +import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; @@ -171,14 +172,14 @@ public class ComponentInterfaceOperationServlet extends AbstractValidationsServl LOGGER.debug(START_HANDLE_REQUEST_OF, request.getMethod(), request.getRequestURI()); LOGGER.debug(MODIFIER_ID_IS, userId); final User userModifier = componentInterfaceOperationBusinessLogic.validateUser(userId); - final ComponentTypeEnum componentTypeEnum = RESOURCE; final byte[] bytes = IOUtils.toByteArray(request.getInputStream()); if (bytes == null || bytes.length == 0) { LOGGER.error(INTERFACE_OPERATION_CONTENT_INVALID); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT)); } + final ComponentTypeEnum componentType = RESOURCE; final String data = new String(bytes); - final Optional mappedInterfaceOperationData = getMappedInterfaceData(data, userModifier, componentTypeEnum); + final Optional mappedInterfaceOperationData = getMappedInterfaceData(data, userModifier, componentType); if (mappedInterfaceOperationData.isEmpty()) { LOGGER.error(INTERFACE_OPERATION_CONTENT_INVALID, data); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT)); @@ -186,7 +187,7 @@ public class ComponentInterfaceOperationServlet extends AbstractValidationsServl final Wrapper errorWrapper = new Wrapper<>(); try { final Optional actionResponse = componentInterfaceOperationBusinessLogic - .updateResourceInterfaceOperation(componentId, mappedInterfaceOperationData.get(), componentTypeEnum, + .updateResourceInterfaceOperation(componentId, userId, mappedInterfaceOperationData.get(), componentType, errorWrapper, true); if (actionResponse.isEmpty()) { LOGGER.error(FAILED_TO_UPDATE_INTERFACE_OPERATION, componentId); @@ -195,6 +196,9 @@ public class ComponentInterfaceOperationServlet extends AbstractValidationsServl LOGGER.debug(INTERFACE_OPERATION_SUCCESSFULLY_UPDATED, componentId); return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), actionResponse.get()); } + } catch (final ComponentException e) { + //let it be handled by org.openecomp.sdc.be.servlets.exception.ComponentExceptionMapper + throw e; } catch (final Exception e) { BeEcompErrorManager.getInstance().logBeRestApiGeneralError(UPDATE_INTERFACE_OPERATION); LOGGER.error(FAILED_TO_UPDATE_INTERFACE_OPERATION_WITH_ERROR, e); -- cgit 1.2.3-korg