Code refactoring

revert-70aa11f8
Supun94 8 years ago
parent eb1575126f
commit 2751d4b856

@ -20,7 +20,5 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js")["utility"];
var deviceType = context.uriParams.deviceType;
var deviceId = context.uriParams.deviceId;
new Log().info("Device Type : "+deviceType);
new Log().info("Device ID : "+deviceId);
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
}

@ -78,13 +78,23 @@ public class MergedEvaluationPoint implements PolicyEvaluationPoint {
profile.setUpdatedDate(currentTimestamp);
profile.setDeviceType(deviceIdentifier.getType());
profile.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
// Set effective policy name
policy.setPolicyName(effectivePolicyName);
policy.setOwnershipType(pipDevice.getOwnershipType());
// Set effective policy Active and Updated
policy.setActive(true);
policy.setUpdated(true);
policy.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
policy.setDescription("This is a system generated effective policy by merging relevant policies.");
String policyIds = "";
Collections.sort(policyList);
for (Policy appliedPolicy : policyList) {
policyIds += appliedPolicy.getId() + ", ";
}
policyIds = policyIds.substring(0, policyIds.length() - 2);
policy.setDescription("This is a system generated effective policy by merging Policy Id : " + policyIds);
// Need to set compliance of the effective policy. Get compliance of first policy using priority order
policy.setCompliance(policyList.get(0).getCompliance());
// Change default 0 effective policy id to (-1)
policy.setId(-1);
return policy;
} catch (PolicyManagementException e) {

@ -98,6 +98,7 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
policy = policyEvaluationPoint.
getEffectivePolicy(deviceIdentifier);
if (policy == null) {
policyAdministratorPoint.removePolicyUsed(deviceIdentifier);
return null;
}
this.getPAP().setPolicyUsed(deviceIdentifier, policy);

@ -89,7 +89,12 @@ public class PolicyEnforcementDelegatorImpl implements PolicyEnforcementDelegato
Policy policy = policyManagerService.getPEP().getEffectivePolicy(identifier);
policyAdministratorPoint = policyManagerService.getPAP();
policyAdministratorPoint.setPolicyUsed(identifier, policy);
if (policy != null) {
policyAdministratorPoint.setPolicyUsed(identifier, policy);
} else {
policyAdministratorPoint.removePolicyUsed(identifier);
return null;
}
return policy;
//return PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint().getEffectivePolicy(identifier);
} catch (PolicyEvaluationException e) {

@ -879,10 +879,8 @@ public class PolicyManagerImpl implements PolicyManager {
PolicyManagementDAOFactory.beginTransaction();
Policy policySaved = policyDAO.getAppliedPolicy(deviceId, device.getEnrolmentInfo().getId());
if (policySaved != null) {
if (policySaved.getId() != 0) {
policyDAO.updateEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy);
}
if (policySaved != null && policySaved.getId() != 0) {
policyDAO.updateEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy);
} else {
policyDAO.addEffectivePolicyToDevice(deviceId, device.getEnrolmentInfo().getId(), policy);
}

@ -43,7 +43,9 @@
<MaxRetries>5</MaxRetries>
<MinRetriesToMarkUnreachable>8</MinRetriesToMarkUnreachable>
<MinRetriesToMarkInactive>20</MinRetriesToMarkInactive>
<!--<PolicyEvaluationPoint>Simple</PolicyEvaluationPoint>-->
<!--Set the policy evaluation point name-->
<!--Simple -> Simple policy evaluation point-->
<!--Merged -> Merged policy evaluation point -->
<PolicyEvaluationPoint>Merged</PolicyEvaluationPoint>
<Platforms>
<Platform>android</Platform>

Loading…
Cancel
Save