diff options
author | andre.schmid <andre.schmid@est.tech> | 2022-06-21 15:06:12 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-06-22 16:33:39 +0000 |
commit | fbab79aeaccf74385c9a55b697a1055a86bdf171 (patch) | |
tree | 8fa0640b7d26298c3bcb805098c88dfabd036c8c /catalog-be/src/main | |
parent | 9cbed7bdd05b0bad6814bd3eb1b43562387d4fd7 (diff) |
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 <andre.schmid@est.tech>
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Diffstat (limited to 'catalog-be/src/main')
2 files changed, 9 insertions, 3 deletions
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<Component> updateResourceInterfaceOperation(final String componentId, + final String user, final InterfaceDefinition interfaceDefinition, final ComponentTypeEnum componentTypeEnum, final Wrapper<ResponseFormat> errorWrapper, final boolean shouldLock) throws BusinessLogicException { final var component = getComponent(componentId); + validateCanWorkOnComponent(component, user); ResponseFormat responseFormat; Map<String, InterfaceDefinition> 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<InterfaceDefinition> mappedInterfaceOperationData = getMappedInterfaceData(data, userModifier, componentTypeEnum); + final Optional<InterfaceDefinition> 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<ResponseFormat> errorWrapper = new Wrapper<>(); try { final Optional<Component> 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); |