X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fservlets%2FComponentInstanceServlet.java;h=675d3343cb3d998b076e9beb208a8c8f32c2ac19;hb=5f3e9912406897ee18c424b940881ce08d59bb44;hp=551540023b694c22cc8972442bc4dae5f69aa0a7;hpb=e020ca3c855ec9555213abfdd89e14d72310177d;p=sdc.git diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java index 551540023b..675d3343cb 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java @@ -35,12 +35,12 @@ import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.servers.Server; import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -62,13 +62,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; +import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; +import org.openecomp.sdc.be.components.impl.ComponentBusinessLogicProvider; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; import org.openecomp.sdc.be.components.impl.ComponentNodeFilterBusinessLogic; import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; 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.BusinessLogicException; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; @@ -77,9 +77,13 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datamodel.ForwardingPaths; import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.CreatedFrom; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.enums.PropertySource; +import org.openecomp.sdc.be.datatypes.tosca.ToscaGetFunctionType; import org.openecomp.sdc.be.externalapi.servlet.representation.ReplaceVNFInfo; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.ServletUtils; @@ -94,9 +98,10 @@ import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; import org.openecomp.sdc.be.model.RequirementDefinition; import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.User; +import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintDeserialiser; +import org.openecomp.sdc.be.resources.data.ComponentMetadataData; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; -import org.openecomp.sdc.be.user.UserBusinessLogic; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.log.elements.LoggerSupportability; @@ -111,7 +116,7 @@ import org.springframework.stereotype.Controller; */ @Loggable(prepend = true, value = Loggable.DEBUG, trim = false) @Path("/v1/catalog") -@Tags({@Tag(name = "SDCE-2 APIs")}) +@Tag(name = "SDCE-2 APIs") @Server(url = "/sdc2/rest") @Controller public class ComponentInstanceServlet extends AbstractValidationsServlet { @@ -121,6 +126,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { private static final String GET_GROUP_ARTIFACT_BY_ID_UNEXPECTED_EXCEPTION = "getGroupArtifactById unexpected exception"; private static final String GET_START_HANDLE_REQUEST_OF = "(GET) Start handle request of {}"; private static final String START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS = "Start handle request of updateResourceInstanceProperty. Received property is {}"; + private static final String START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_ATTRIBUTE_RECEIVED_ATTRIBUTE_IS = "Start handle request of updateResourceInstanceAttribute. Received attribute is {}"; private static final String UPDATE_RESOURCE_INSTANCE = "Update Resource Instance"; private static final String RESOURCE_INSTANCE_UPDATE_RESOURCE_INSTANCE = "Resource Instance - updateResourceInstance"; private static final String UPDATE_RESOURCE_INSTANCE_WITH_EXCEPTION = "update resource instance with exception"; @@ -138,14 +144,17 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { private static final String SERVICES = "services"; private final GroupBusinessLogic groupBL; private final ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic; + private final ComponentBusinessLogicProvider componentBusinessLogicProvider; @Inject - public ComponentInstanceServlet(UserBusinessLogic userBusinessLogic, GroupBusinessLogic groupBL, + public ComponentInstanceServlet(GroupBusinessLogic groupBL, ComponentInstanceBusinessLogic componentInstanceBL, ComponentsUtils componentsUtils, ServletUtils servletUtils, - ResourceImportManager resourceImportManager, ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic) { - super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager); + ResourceImportManager resourceImportManager, ComponentNodeFilterBusinessLogic nodeFilterBusinessLogic, + ComponentBusinessLogicProvider componentBusinessLogicProvider) { + super(componentInstanceBL, componentsUtils, servletUtils, resourceImportManager); this.groupBL = groupBL; this.nodeFilterBusinessLogic = nodeFilterBusinessLogic; + this.componentBusinessLogicProvider = componentBusinessLogicProvider; } @POST @@ -158,7 +167,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "409", description = "Component instance already exist")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response createComponentInstance(@Parameter(description = "RI object to be created", required = true) String data, @PathParam("componentId") final String containerComponentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { @@ -199,7 +207,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "200", description = "Resource instance updated"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateComponentInstanceMetadata(@PathParam("componentId") final String componentId, @PathParam("componentInstanceId") final String componentInstanceId, @Parameter(description = "valid values: resources / services / products", schema = @Schema(allowableValues = { @@ -278,7 +285,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "200", description = "Resource instance updated"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateMultipleComponentInstance(@PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services / products", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME, @@ -325,7 +331,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "ResourceInstance deleted"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response deleteResourceInstance(@PathParam("componentId") final String componentId, @PathParam("resourceInstanceId") final String resourceInstanceId, @Parameter(description = "valid values: resources / services / products", schema = @Schema(allowableValues = { @@ -368,7 +373,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "403", description = "Missing information"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "409", description = "Relationship already exist")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response associateRIToRI( @Parameter(description = "unique id of the container component") @PathParam("componentId") final String componentId, @Parameter(description = "allowed values are resources /services / products", schema = @Schema(allowableValues = { @@ -415,7 +419,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Relationship deleted"), @ApiResponse(responseCode = "403", description = "Missing information"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response dissociateRIFromRI( @Parameter(description = "allowed values are resources /services / products", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME, @@ -458,7 +461,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "RI created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "409", description = "Relationship already exist")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response createAndAssociateRIToRI(@PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME, @@ -513,7 +515,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateResourceInstanceProperties(@Parameter(description = "service id") @PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, @@ -527,6 +528,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE, StatusCode.STARTED, "Starting to update Resource Instance Properties for component {} ", componentId + " by " + userId); Wrapper errorWrapper = new Wrapper<>(); + ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); List propertiesToUpdate = new ArrayList<>(); if (errorWrapper.isEmpty()) { Either, ResponseFormat> propertiesToUpdateEither = convertMultipleProperties( @@ -535,13 +537,13 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { errorWrapper.setInnerElement(propertiesToUpdateEither.right().value()); } else { propertiesToUpdate = propertiesToUpdateEither.left().value(); + handleDeprecatedComponentInstancePropertyStructure(propertiesToUpdate, componentTypeEnum); } } if (!errorWrapper.isEmpty()) { return buildErrorResponse(errorWrapper.getInnerElement()); } log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_PROPERTY_RECEIVED_PROPERTY_IS, propertiesToUpdate); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); if (componentInstanceBusinessLogic == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); @@ -567,6 +569,41 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), result); } + private void handleDeprecatedComponentInstancePropertyStructure(final List propertiesToUpdate, + final ComponentTypeEnum componentTypeEnum) { + propertiesToUpdate.stream().forEach(property -> { + if (property.getGetInputValues() != null) { + property.getGetInputValues().stream() + .forEach(getInputValue -> property.setToscaFunction(createToscaFunction(getInputValue, componentTypeEnum))); + } + }); + } + + private ToscaGetFunctionDataDefinition createToscaFunction(final GetInputValueDataDefinition getInput, + final ComponentTypeEnum componentTypeEnum) { + final String[] inputIdSplit = getInput.getInputId().split("\\."); + + ToscaGetFunctionDataDefinition toscaFunction = new ToscaGetFunctionDataDefinition(); + toscaFunction.setFunctionType(ToscaGetFunctionType.GET_INPUT); + toscaFunction.setPropertyUniqueId(getInput.getInputId()); + toscaFunction.setPropertySource(PropertySource.SELF); + toscaFunction.setPropertyName(inputIdSplit[1]); + toscaFunction.setSourceName(getSourceName(inputIdSplit[0], componentTypeEnum)); + toscaFunction.setSourceUniqueId(inputIdSplit[0]); + toscaFunction.setPropertyPathFromSource(Collections.singletonList(inputIdSplit[1])); + + return toscaFunction; + } + + private String getSourceName(final String componentId, final ComponentTypeEnum componentTypeEnum) { + ComponentBusinessLogic compBL = componentBusinessLogicProvider.getInstance(componentTypeEnum); + final Either componentEither = compBL.getComponentMetadata(componentId); + if (componentEither.isLeft()) { + return componentEither.left().value().getMetadataDataDefinition().getName(); + } + return ""; + } + @POST @Path("/{containerComponentType}/{componentId}/resourceInstance/{componentInstanceId}/inputs") @Consumes(MediaType.APPLICATION_JSON) @@ -576,7 +613,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateResourceInstanceInput(@Parameter(description = "service id") @PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, @@ -641,59 +677,65 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { * @return */ @POST - @Path("/{containerComponentType}/{componentId}/resourceInstance/{componentInstanceId}/attribute") + @Path("/{containerComponentType}/{componentId}/resourceInstance/{componentInstanceId}/attributes") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Operation(description = "Update resource instance attribute", method = "POST", summary = "Returns updated resource instance attribute", responses = { + @Operation(description = "Update resource instance attribute", method = "POST", summary = "Returns updated resource instance property", responses = { @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))), @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateResourceInstanceAttribute(@Parameter(description = "service id") @PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, ComponentTypeEnum.SERVICE_PARAM_NAME})) @PathParam("containerComponentType") final String containerComponentType, @Parameter(description = "resource instance id") @PathParam("componentInstanceId") final String componentInstanceId, - @Parameter(description = "id of user initiating the operation") @HeaderParam(value = Constants.USER_ID_HEADER) String userId, - @Context final HttpServletRequest request) throws IOException { - String url = request.getMethod() + " " + request.getRequestURI(); + @Parameter(description = "id of user initiating the operation") @HeaderParam(value = Constants.USER_ID_HEADER) final String userId, + @Context final HttpServletRequest request, + @Parameter(description = "Component Instance Properties JSON Array", required = true) final String componentInstanceAttributesJsonArray) { + final String url = request.getMethod() + " " + request.getRequestURI(); log.debug(START_HANDLE_REQUEST_OF, url); - loggerSupportability - .log(LoggerSupportabilityActions.UPDATE_RESOURCE, StatusCode.STARTED, "Starting to update Resource Instance Attribute for component {} ", - componentId + " by " + userId); - try { - Wrapper errorWrapper = new Wrapper<>(); - Wrapper dataWrapper = new Wrapper<>(); - Wrapper attributeWrapper = new Wrapper<>(); - Wrapper blWrapper = new Wrapper<>(); - validateInputStream(request, dataWrapper, errorWrapper); - if (errorWrapper.isEmpty()) { - validateClassParse(dataWrapper.getInnerElement(), attributeWrapper, () -> ComponentInstanceProperty.class, errorWrapper); - } - if (errorWrapper.isEmpty()) { - validateComponentInstanceBusinessLogic(request, containerComponentType, blWrapper, errorWrapper); - } - if (errorWrapper.isEmpty()) { - ComponentInstanceBusinessLogic componentInstanceLogic = blWrapper.getInnerElement(); - ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); - log.debug("Start handle request of ComponentInstanceAttribute. Received attribute is {}", attributeWrapper.getInnerElement()); - Either eitherAttribute = componentInstanceLogic - .createOrUpdateAttributeValue(componentTypeEnum, componentId, componentInstanceId, attributeWrapper.getInnerElement(), userId); - if (eitherAttribute.isRight()) { - errorWrapper.setInnerElement(eitherAttribute.right().value()); - } else { - attributeWrapper.setInnerElement(eitherAttribute.left().value()); - } + loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE, StatusCode.STARTED, + "Starting to update Resource Instance Attributes for component {} ", componentId + " by " + userId); + final Wrapper errorWrapper = new Wrapper<>(); + List attributesToUpdate = new ArrayList<>(); + if (errorWrapper.isEmpty()) { + final Either, ResponseFormat> attributesToUpdateEither = convertMultipleAttributes( + componentInstanceAttributesJsonArray); + if (attributesToUpdateEither.isRight()) { + errorWrapper.setInnerElement(attributesToUpdateEither.right().value()); + } else { + attributesToUpdate = attributesToUpdateEither.left().value(); } - loggerSupportability - .log(LoggerSupportabilityActions.UPDATE_RESOURCE, StatusCode.COMPLETE, "Ended update Resource Instance Attribute for component {} ", - componentId + " by " + userId); - return buildResponseFromElement(errorWrapper, attributeWrapper); - } catch (Exception e) { - log.error(CREATE_AND_ASSOCIATE_RI_FAILED_WITH_EXCEPTION, e.getMessage(), e); - throw e; } + if (!errorWrapper.isEmpty()) { + return buildErrorResponse(errorWrapper.getInnerElement()); + } + log.debug(START_HANDLE_REQUEST_OF_UPDATE_RESOURCE_INSTANCE_ATTRIBUTE_RECEIVED_ATTRIBUTE_IS, attributesToUpdate); + final ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); + if (componentInstanceBusinessLogic == null) { + log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); + return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); + } + final Either, ResponseFormat> actionResponse = componentInstanceBusinessLogic + .createOrUpdateAttributeValues(componentTypeEnum, componentId, componentInstanceId, attributesToUpdate, userId); + if (actionResponse.isRight()) { + return buildErrorResponse(actionResponse.right().value()); + } + final List resourceInstanceAttributes = actionResponse.left().value(); + final ObjectMapper mapper = new ObjectMapper(); + String result; + loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE, StatusCode.COMPLETE, + "Ended update Resource Instance Attributes for component {} ", componentId + " by " + userId); + try { + result = mapper.writeValueAsString(resourceInstanceAttributes); + } catch (JsonProcessingException e) { + log.error(UPDATE_RESOURCE_INSTANCE_WITH_EXCEPTION, e.getMessage(), e); + throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR); + } + loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE, StatusCode.COMPLETE, + "Ended update Resource Instance Attributes for component {} ", componentId + " by user " + userId); + return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), result); } @DELETE @@ -705,7 +747,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response deleteResourceInstanceProperty(@Parameter(description = "service id") @PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, @@ -749,7 +790,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response changeResourceInstanceVersion(@PathParam("componentId") final String componentId, @PathParam("componentInstanceId") final String componentInstanceId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { @@ -796,7 +836,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Resource instance created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateGroupInstanceProperty(@Parameter(description = "service id") @PathParam("componentId") final String componentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { ComponentTypeEnum.RESOURCE_PARAM_NAME, @@ -854,7 +893,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))), @ApiResponse(responseCode = "200", description = "group found"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "404", description = "Group not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getGroupArtifactById(@PathParam("containerComponentType") final String containerComponentType, @PathParam("componentId") final String componentId, @PathParam("componentInstanceId") final String componentInstanceId, @@ -888,7 +926,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "200", description = "Properties found"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "404", description = "Component/Component Instance - not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getInstancePropertiesById(@PathParam("containerComponentType") final String containerComponentType, @PathParam("containerComponentId") final String containerComponentId, @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @@ -910,7 +947,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "200", description = "Attributes found"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "404", description = "Component/Component Instance - not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getInstanceAttributesById(@PathParam("containerComponentType") final String containerComponentType, @PathParam("containerComponentId") final String containerComponentId, @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @@ -933,7 +969,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "200", description = "Properties found"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "404", description = "Component/Component Instance/Capability - not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getInstanceCapabilityPropertiesById(@PathParam("containerComponentType") final String containerComponentType, @PathParam("containerComponentId") final String containerComponentId, @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @@ -966,7 +1001,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "404", description = "Component/Component Instance/Capability - not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateInstanceCapabilityProperty(@PathParam("containerComponentType") final String containerComponentType, @PathParam("containerComponentId") final String containerComponentId, @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @@ -1023,7 +1057,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "404", description = "Component/Component Instance/Requirement - not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response updateInstanceRequirement(@PathParam("containerComponentType") final String containerComponentType, @PathParam("containerComponentId") final String containerComponentId, @PathParam("componentInstanceUniqueId") final String componentInstanceUniqueId, @@ -1039,7 +1072,7 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { try { log.debug(START_HANDLE_REQUEST_OF, url); ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType); - if (componentInstanceBusinessLogic == null) { + if (componentTypeEnum == null) { log.debug(UNSUPPORTED_COMPONENT_TYPE, containerComponentType); return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType)); } @@ -1081,7 +1114,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"), @ApiResponse(responseCode = "409", description = "Service proxy already exist")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response createServiceProxy(@Parameter(description = "RI object to be created", required = true) String data, @PathParam("containerComponentId") final String containerComponentId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { @@ -1122,7 +1154,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Service proxy deleted"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response deleteServiceProxy(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId, @Parameter(description = "valid values: resources / services / products", schema = @Schema(allowableValues = { @@ -1158,7 +1189,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "201", description = "Service proxy created"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "400", description = "Invalid content / Missing content")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response changeServiceProxyVersion(@PathParam("containerComponentId") final String containerComponentId, @PathParam("serviceProxyId") final String serviceProxyId, @Parameter(description = "valid values: resources / services", schema = @Schema(allowableValues = { @@ -1202,7 +1232,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))), @ApiResponse(responseCode = "200", description = "relation found"), @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "404", description = "Relation not found")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response getRelationById(@PathParam("containerComponentType") final String containerComponentType, @PathParam("componentId") final String componentId, @PathParam("relationId") final String relationId, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) { @@ -1258,6 +1287,18 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { return Either.left(Arrays.asList(convertStatus.left().value())); } + private Either, ResponseFormat> convertMultipleAttributes(final String dataList) { + if (StringUtils.isEmpty(dataList)) { + return Either.right(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_BODY)); + } + final Either convertStatus = getComponentsUtils(). + convertJsonToObjectUsingObjectMapper(dataList, new User(), ComponentInstanceAttribute[].class, null, ComponentTypeEnum.RESOURCE_INSTANCE); + if (convertStatus.isRight()) { + return Either.right(convertStatus.right().value()); + } + return Either.left(Arrays.asList(convertStatus.left().value())); + } + private Either, ResponseFormat> convertMultipleInputs(String dataList) { if (StringUtils.isEmpty(dataList)) { return Either.right(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_BODY)); @@ -1492,7 +1533,6 @@ public class ComponentInstanceServlet extends AbstractValidationsServlet { @ApiResponse(responseCode = "405", description = "Method Not Allowed : Invalid HTTP method type used ( PUT,DELETE,POST will be rejected) - POL4050"), @ApiResponse(responseCode = "500", description = "The GET request failed either due to internal SDC problem. ECOMP Component should continue the attempts to get the needed information - POL5000"), @ApiResponse(responseCode = "409", description = "Service already exist")}) - @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE) public Response replaceVNF(@Parameter(description = "The user id", required = true) @HeaderParam(value = Constants.USER_ID_HEADER) String userId, @Parameter(description = "X-ECOMP-RequestID header", required = false) @HeaderParam(value = Constants.X_ECOMP_REQUEST_ID_HEADER) String requestId, @Parameter(description = "X-ECOMP-InstanceID header", required = true) @HeaderParam(value = Constants.X_ECOMP_INSTANCE_ID_HEADER) final String instanceIdHeader,