RoleValidatorFactory respects owning-entity feature flag
[vid.git] / vid-app-common / src / main / java / org / onap / vid / roles / RoleValidatorFactory.java
index 1286540..f4334b1 100644 (file)
@@ -25,6 +25,7 @@ package org.onap.vid.roles;
 import java.util.List;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.properties.Features;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.togglz.core.manager.FeatureManager;
@@ -46,8 +47,18 @@ public class RoleValidatorFactory {
     }
 
     public RoleValidator by(List<Role> roles, boolean disableRoles) {
-        return disableRoles
-            ? new AlwaysValidRoleValidator()
-            : new RoleValidatorBySubscriberAndServiceType(roles);
+
+        if(disableRoles) {
+            return new AlwaysValidRoleValidator();
+        }
+        else if (featureManager.isActive(Features.FLAG_2006_USER_PERMISSIONS_BY_OWNING_ENTITY)){
+            return new RoleValidatorsComposer(
+                new RoleValidatorBySubscriberAndServiceType(roles),
+                new RoleValidatorByOwningEntity()
+            );
+        }
+        else {
+            return new RoleValidatorBySubscriberAndServiceType(roles);
+        }
     }
 }