use of org.onap.so.apihandlerinfra.validation.SubscriberInfoValidation 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);
}
}
Aggregations