Changed getEffectiveFeatures method

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

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

@ -42,5 +42,5 @@ public interface PolicyEvaluationPoint {
* @param deviceIdentifier device information. * @param deviceIdentifier device information.
* @return returns the effective feature set. * @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; 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; List<Policy> getPolicies(String deviceType) throws PolicyManagementException;

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

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

Loading…
Cancel
Save