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;
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;
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;
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;
*/
@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 {
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";
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
@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 = {
@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 = {
@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,
@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 = {
@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 = {
@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,
@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,
@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,
loggerSupportability.log(LoggerSupportabilityActions.UPDATE_COMPONENT_INSTANCE, StatusCode.STARTED,
"Starting to update Resource Instance Properties for component {} ", componentId + " by " + userId);
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
+ ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
List<ComponentInstanceProperty> propertiesToUpdate = new ArrayList<>();
if (errorWrapper.isEmpty()) {
Either<List<ComponentInstanceProperty>, ResponseFormat> propertiesToUpdateEither = convertMultipleProperties(
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));
return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), result);
}
+ private void handleDeprecatedComponentInstancePropertyStructure(final List<ComponentInstanceProperty> 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<ComponentMetadataData, StorageOperationStatus> 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)
@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,
* @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<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<String> dataWrapper = new Wrapper<>();
- Wrapper<ComponentInstanceProperty> attributeWrapper = new Wrapper<>();
- Wrapper<ComponentInstanceBusinessLogic> 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<ComponentInstanceProperty, ResponseFormat> 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<ResponseFormat> errorWrapper = new Wrapper<>();
+ List<ComponentInstanceAttribute> attributesToUpdate = new ArrayList<>();
+ if (errorWrapper.isEmpty()) {
+ final Either<List<ComponentInstanceAttribute>, 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<List<ComponentInstanceAttribute>, ResponseFormat> actionResponse = componentInstanceBusinessLogic
+ .createOrUpdateAttributeValues(componentTypeEnum, componentId, componentInstanceId, attributesToUpdate, userId);
+ if (actionResponse.isRight()) {
+ return buildErrorResponse(actionResponse.right().value());
+ }
+ final List<ComponentInstanceAttribute> 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
@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,
@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 = {
@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,
@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,
@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,
@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,
@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,
@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,
@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,
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));
}
@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 = {
@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 = {
@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 = {
@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) {
return Either.left(Arrays.asList(convertStatus.left().value()));
}
+ private Either<List<ComponentInstanceAttribute>, ResponseFormat> convertMultipleAttributes(final String dataList) {
+ if (StringUtils.isEmpty(dataList)) {
+ return Either.right(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_BODY));
+ }
+ final Either<ComponentInstanceAttribute[], ResponseFormat> 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<List<ComponentInstanceInput>, ResponseFormat> convertMultipleInputs(String dataList) {
if (StringUtils.isEmpty(dataList)) {
return Either.right(getComponentsUtils().getResponseFormat(ActionStatus.MISSING_BODY));
@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,