Search in sources :

Example 1 with CustomWorkflowValidation

use of org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation in project so by onap.

the class MsoRequest method parse.

// Parse request JSON
public void parse(ServiceInstancesRequest sir, Map<String, String> instanceIdMap, Actions action, String version, String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException {
    logger.debug("Validating the Service Instance request");
    List<ValidationRule> rules = new ArrayList<>();
    logger.debug("Incoming version is: {} coverting to int: {}", version, reqVersion);
    RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters();
    ValidationInformation info = new ValidationInformation(sir, instanceIdMap, action, reqVersion, aLaCarteFlag, requestParameters);
    rules.add(new InstanceIdMapValidation());
    String workflowUuid = null;
    if (instanceIdMap != null) {
        workflowUuid = instanceIdMap.get("workflowUuid");
    }
    if (workflowUuid != null) {
        rules.add(new CustomWorkflowValidation());
    } else if (reqVersion >= 6 && action == Action.inPlaceSoftwareUpdate) {
        rules.add(new InPlaceSoftwareUpdateValidation());
    } else if (reqVersion >= 6 && action == Action.applyUpdatedConfig) {
        rules.add(new ApplyUpdatedConfigValidation());
    } else if (action == Action.addMembers || action == Action.removeMembers) {
        rules.add(new MembersValidation());
    } else {
        rules.add(new RequestScopeValidation());
        rules.add(new RequestParametersValidation());
        rules.add(new RequestInfoValidation());
        rules.add(new ModelInfoValidation());
        rules.add(new CloudConfigurationValidation());
        rules.add(new SubscriberInfoValidation());
        if (!enforceDLP) {
            rules.add(new PlatformLOBValidation());
            rules.add(new ProjectOwningEntityValidation());
        }
        rules.add(new RelatedInstancesValidation());
        rules.add(new ConfigurationParametersValidation());
    }
    if (reqVersion >= 7 && requestParameters != null && requestParameters.getUserParams() != null) {
        for (Map<String, Object> params : requestParameters.getUserParams()) {
            if (params.containsKey("service")) {
                ObjectMapper obj = new ObjectMapper();
                String input = obj.writeValueAsString(params.get("service"));
                Service validate = obj.readValue(input, Service.class);
                info.setUserParams(validate);
                rules.add(new UserParamsValidation());
                break;
            }
        }
    }
    for (ValidationRule rule : rules) {
        rule.validate(info);
    }
}
Also used : ValidationInformation(org.onap.so.apihandlerinfra.validation.ValidationInformation) ApplyUpdatedConfigValidation(org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation) RequestParametersValidation(org.onap.so.apihandlerinfra.validation.RequestParametersValidation) ArrayList(java.util.ArrayList) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) CustomWorkflowValidation(org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation) RelatedInstancesValidation(org.onap.so.apihandlerinfra.validation.RelatedInstancesValidation) ProjectOwningEntityValidation(org.onap.so.apihandlerinfra.validation.ProjectOwningEntityValidation) UserParamsValidation(org.onap.so.apihandlerinfra.validation.UserParamsValidation) InPlaceSoftwareUpdateValidation(org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation) ModelInfoValidation(org.onap.so.apihandlerinfra.validation.ModelInfoValidation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConfigurationParametersValidation(org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation) MembersValidation(org.onap.so.apihandlerinfra.validation.MembersValidation) RequestScopeValidation(org.onap.so.apihandlerinfra.validation.RequestScopeValidation) Service(org.onap.so.serviceinstancebeans.Service) ValidationRule(org.onap.so.apihandlerinfra.validation.ValidationRule) InstanceIdMapValidation(org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation) RequestInfoValidation(org.onap.so.apihandlerinfra.validation.RequestInfoValidation) PlatformLOBValidation(org.onap.so.apihandlerinfra.validation.PlatformLOBValidation) SubscriberInfoValidation(org.onap.so.apihandlerinfra.validation.SubscriberInfoValidation) CloudConfigurationValidation(org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 ApplyUpdatedConfigValidation (org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation)1 CloudConfigurationValidation (org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation)1 ConfigurationParametersValidation (org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation)1 CustomWorkflowValidation (org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation)1 InPlaceSoftwareUpdateValidation (org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation)1 InstanceIdMapValidation (org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation)1 MembersValidation (org.onap.so.apihandlerinfra.validation.MembersValidation)1 ModelInfoValidation (org.onap.so.apihandlerinfra.validation.ModelInfoValidation)1 PlatformLOBValidation (org.onap.so.apihandlerinfra.validation.PlatformLOBValidation)1 ProjectOwningEntityValidation (org.onap.so.apihandlerinfra.validation.ProjectOwningEntityValidation)1 RelatedInstancesValidation (org.onap.so.apihandlerinfra.validation.RelatedInstancesValidation)1 RequestInfoValidation (org.onap.so.apihandlerinfra.validation.RequestInfoValidation)1 RequestParametersValidation (org.onap.so.apihandlerinfra.validation.RequestParametersValidation)1 RequestScopeValidation (org.onap.so.apihandlerinfra.validation.RequestScopeValidation)1 SubscriberInfoValidation (org.onap.so.apihandlerinfra.validation.SubscriberInfoValidation)1 UserParamsValidation (org.onap.so.apihandlerinfra.validation.UserParamsValidation)1 ValidationInformation (org.onap.so.apihandlerinfra.validation.ValidationInformation)1 ValidationRule (org.onap.so.apihandlerinfra.validation.ValidationRule)1