Adjust RelatedInstancesValidation to enable child service requests
[so.git] / mso-api-handlers / mso-api-handler-infra / src / main / java / org / onap / so / apihandlerinfra / validation / RelatedInstancesValidation.java
index 3b87d91..801065f 100644 (file)
@@ -185,7 +185,10 @@ public class RelatedInstancesValidation implements ValidationRule {
                         && !(requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())
                                 && action == Action.createInstance)) {
                     isRelatedServiceInstancePresent = true;
-                    if (!relatedInstance.getInstanceId().equals(sir.getServiceInstanceId())) {
+                    // InstanceDirection.source indicates child service and this validation is for all
+                    // except child services.
+                    if (!InstanceDirection.source.equals(relatedInstance.getInstanceDirection())
+                            && !relatedInstance.getInstanceId().equals(sir.getServiceInstanceId())) {
                         throw new ValidationException(
                                 "serviceInstanceId matching the serviceInstanceId in request URI");
                     }