diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js
index b7056d8c03..46b4ed70b7 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.effective-policy.view/view.js
@@ -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")};
}
diff --git a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java
index 678705d9ed..0223ed73bc 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/merged/MergedEvaluationPoint.java
@@ -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) {
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java
index d06c3cb0ee..eae94ce7c8 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerServiceImpl.java
@@ -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);
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
index fb3c8143f3..2d681cf93c 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/enforcement/PolicyEnforcementDelegatorImpl.java
@@ -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) {
diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java
index 78bb608890..23b1a29420 100644
--- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java
+++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java
@@ -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);
}
diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml
index 39b4b0fedd..44d131dea2 100644
--- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml
+++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml
@@ -43,7 +43,9 @@
5
8
20
-
+
+
+
Merged
android