From 044995ed971f257dac016950ce8f3bb5bd83e681 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 1 Sep 2015 15:03:09 +0530 Subject: [PATCH] Adding the activate method when policies are added. --- .../policy/mgt/core/mgt/impl/MonitoringManagerImpl.java | 9 ++++----- .../policy/mgt/core/mgt/impl/PolicyManagerImpl.java | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java index 6b52b04e7a..3a0dd3d78d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java @@ -59,7 +59,7 @@ import java.util.Map; public class MonitoringManagerImpl implements MonitoringManager { private PolicyDAO policyDAO; -// private DeviceDAO deviceDAO; + // private DeviceDAO deviceDAO; private DeviceTypeDAO deviceTypeDAO; private MonitoringDAO monitoringDAO; private ComplianceDecisionPoint complianceDecisionPoint; @@ -226,8 +226,6 @@ public class MonitoringManagerImpl implements MonitoringManager { @Override public void addMonitoringOperation(List devices) throws PolicyComplianceException { - ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl(); - //int tenantId = PolicyManagerUtil.getTenantId(); Map deviceIds = new HashMap<>(); List complianceDatas; @@ -327,10 +325,11 @@ public class MonitoringManagerImpl implements MonitoringManager { } } - // TODO : This should be uncommented, this is to mark the device as unreachable, But given the current implementation - // we are not able to do so. + // TODO : This should be uncommented, this is to mark the device as unreachable, But given the current + // implementation we are not able to do so. // if(!deviceToMarkUnreachable.isEmpty()) { +// ComplianceDecisionPoint decisionPoint = new ComplianceDecisionPointImpl(); // decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices( // new ArrayList<>(deviceToMarkUnreachable.values()))); // } 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 53c322236f..ffc3373fba 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 @@ -46,7 +46,6 @@ public class PolicyManagerImpl implements PolicyManager { private ProfileDAO profileDAO; private FeatureDAO featureDAO; private ProfileManager profileManager; - private PolicyCacheManager policyCacheManager; private static Log log = LogFactory.getLog(PolicyManagerImpl.class); public PolicyManagerImpl() { @@ -105,6 +104,9 @@ public class PolicyManagerImpl implements PolicyManager { policyDAO.addPolicyCriteriaProperties(policy.getPolicyCriterias()); } + if(policy.isActive()){ + policyDAO.activatePolicy(policy.getId()); + } PolicyManagementDAOFactory.commitTransaction(); } catch (PolicyManagerDAOException e) {