Changed getEffectiveFeatures method

revert-70aa11f8
Supun94 8 years ago
parent 367fa927b0
commit 272ba7b012

@ -37,24 +37,16 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
PIPDevice pipDevice;
@Override
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
public List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList, DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
PolicyAdministratorPoint policyAdministratorPoint;
PolicyInformationPoint policyInformationPoint;
policyManagerService = getPolicyManagerService();
try {
if (policyManagerService != null) {
policyInformationPoint = policyManagerService.getPIP();
PIPDevice pipDevice = policyInformationPoint.getDeviceData(deviceIdentifier);
policyList = policyInformationPoint.getRelatedPolicies(pipDevice);
if (!policyList.isEmpty()) {
//policy = policyList.get(0);
//policyList = new ArrayList<Policy>();
Policy effectivePolicy = policyResolve(policyList);
effectivePolicy.setActive(true);
//TODO : UNCOMMENT THE FOLLOWING CASE
policyAdministratorPoint = policyManagerService.getPAP();
policyAdministratorPoint.setPolicyUsed(deviceIdentifier, effectivePolicy);
return effectivePolicy.getProfile().getProfileFeaturesList();
@ -83,7 +75,7 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
Policy policy = new Policy();
Profile profile = new Profile();
profile.setProfileFeaturesList(getEffectiveFeatures(deviceIdentifier));
profile.setProfileFeaturesList(getEffectiveFeatures(policyList, deviceIdentifier));
policy.setProfile(profile);
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
profile.setCreatedDate(currentTimestamp);
@ -113,6 +105,8 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
// Iterate through all policies
Map<String, ProfileFeature> featureMap = new HashMap<>();
// Merge roles of policies
//Map<String, java.lang.Integer> rolesMap = new HashMap<>();
Iterator<Policy> policyIterator = policyList.iterator();
while (policyIterator.hasNext()) {
Policy policy = policyIterator.next();
@ -124,6 +118,16 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
featureMap.put(feature.getFeatureCode(), feature);
}
}
// List<String> policyRolesList = policy.getRoles();
//
// if (policyRolesList != null) {
// Iterator<String> roleIterator = policyRolesList.iterator();
// while (roleIterator.hasNext()) {
// String role = roleIterator.next();
// rolesMap.put(role,policy.getId());
// }
// }
}
// Get prioritized features list
@ -133,6 +137,7 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
Policy effectivePolicy = new Policy();
effectivePolicy.setProfile(profile);
//effectivePolicy.setRoles(rolesList);
return effectivePolicy;
}

@ -42,5 +42,5 @@ public interface PolicyEvaluationPoint {
* @param deviceIdentifier device information.
* @return returns the effective feature set.
*/
List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException;
List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList,DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException;
}

@ -51,7 +51,7 @@ public interface PolicyManagerService {
Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException;
List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws FeatureManagementException;
List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList,DeviceIdentifier deviceIdentifier) throws FeatureManagementException;
List<Policy> getPolicies(String deviceType) throws PolicyManagementException;

@ -133,11 +133,16 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
}
@Override
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws
public List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList,DeviceIdentifier deviceIdentifier) throws
FeatureManagementException {
try {
return PolicyManagementDataHolder.getInstance().
getPolicyEvaluationPoint().getEffectiveFeatures(deviceIdentifier);
PolicyEvaluationPoint policyEvaluationPoint = PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint();
if (policyEvaluationPoint != null) {
return policyEvaluationPoint.getEffectiveFeatures(policyList, deviceIdentifier);
} else {
throw new FeatureManagementException("Error occurred while getting the policy evaluation point " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType());
}
} catch (PolicyEvaluationException e) {
String msg = "Error occurred while getting the effective features from the PEP service " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType();

@ -72,7 +72,7 @@ public class SimplePolicyEvaluationTest implements PolicyEvaluationPoint {
}
@Override
public List<ProfileFeature> getEffectiveFeatures(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
public List<ProfileFeature> getEffectiveFeatures(List<Policy> policyList,DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
return null;
}

Loading…
Cancel
Save