import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
-import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
-import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datamodel.utils.PropertyValueConstraintValidationUtil;
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "409", description = "Service property already exist")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response createPropertyInService(
@Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
@Parameter(description = "Service property to be created", required = true) String data, @Context final HttpServletRequest request,
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "409", description = "Resource property already exist")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response createPropertyInResource(
@Parameter(description = "Resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
@Parameter(description = "Resource property to be created", required = true) String data, @Context final HttpServletRequest request,
@ApiResponse(responseCode = "200", description = "property"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Service property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getPropertyInService(
@Parameter(description = "service id of property", required = true) @PathParam("serviceId") final String serviceId,
@Parameter(description = "property id to get", required = true) @PathParam("propertyId") final String propertyId,
@ApiResponse(responseCode = "200", description = "property"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Resource property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getPropertyInResource(
@Parameter(description = "resource id of property", required = true) @PathParam("resourceId") final String resourceId,
@Parameter(description = "property id to get", required = true) @PathParam("propertyId") final String propertyId,
@ApiResponse(responseCode = "200", description = "property"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Service property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getPropertyListInService(
@Parameter(description = "service id of property", required = true) @PathParam("serviceId") final String serviceId,
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
@ApiResponse(responseCode = "200", description = "property"), @ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Resource property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getPropertyListInResource(
@Parameter(description = "resource id of property", required = true) @PathParam("resourceId") final String resourceId,
@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Service property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response deletePropertyInService(
@Parameter(description = "service id of property", required = true) @PathParam("serviceId") final String serviceId,
@Parameter(description = "Property id to delete", required = true) @PathParam("propertyId") final String propertyId,
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
@ApiResponse(responseCode = "404", description = "Resource property not found")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response deletePropertyInResource(
@Parameter(description = "resource id of property", required = true) @PathParam("resourceId") final String resourceId,
@Parameter(description = "Property id to delete", required = true) @PathParam("propertyId") final String propertyId,
@ApiResponse(responseCode = "200", description = "Service property updated"),
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response updatePropertyInService(
@Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
@Parameter(description = "Service property to update", required = true) String data, @Context final HttpServletRequest request,
@ApiResponse(responseCode = "200", description = "Resource property updated"),
@ApiResponse(responseCode = "403", description = "Restricted operation"),
@ApiResponse(responseCode = "400", description = "Invalid content / Missing content")})
- @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response updatePropertyInResource(
@Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
@Parameter(description = "Resource property to update", required = true) String data, @Context final HttpServletRequest request,
log.info("Property content is invalid - {}", data);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
}
+
+ //Validate value and Constraint of property and Fetch all data types from cache
+ Either<Boolean, ResponseFormat> constraintValidatorResponse = new PropertyValueConstraintValidationUtil()
+ .validatePropertyConstraints(properties.values(), applicationDataTypeCache,
+ propertyBusinessLogic.getComponentModelByComponentId(componentId));
+ if (constraintValidatorResponse.isRight()) {
+ log.error("Failed validation value and constraint of property: {}", constraintValidatorResponse.right().value());
+ return buildErrorResponse(constraintValidatorResponse.right().value());
+ }
+
Map.Entry<String, PropertyDefinition> entry = properties.entrySet().iterator().next();
PropertyDefinition newPropertyDefinition = entry.getValue();
newPropertyDefinition.setParentUniqueId(componentId);