From 388701c3a24f81d6f061b079ca5aa5392fb51100 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 7 Jul 2015 11:54:24 +0530 Subject: [PATCH] Adding partial commit to add a interface for plugins to implement to notify devices for monotoring --- .../device/mgt/common/EnrolmentInfo.java | 2 +- .../common/spi/PolicyMonitoringService.java | 3 +++ .../impl/ComplianceDecisionPointImpl.java | 26 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java index 4a56cc567f5..82e3fb57d40 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EnrolmentInfo.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.common; public class EnrolmentInfo { public enum Status { - CREATED, ACTIVE, INACTIVE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED + CREATED, ACTIVE, INACTIVE, UNREACHABLE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED } public enum OwnerShip { diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java index 86af5a0693b..890a72aaee0 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/spi/PolicyMonitoringService.java @@ -19,6 +19,7 @@ package org.wso2.carbon.policy.mgt.common.spi; +import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; @@ -28,6 +29,8 @@ import java.util.List; public interface PolicyMonitoringService { + void notifyDevices(List devices) throws PolicyComplianceException; + List checkPolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy, Object response) throws PolicyComplianceException; } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java index e089f032043..313b4272767 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -19,15 +19,36 @@ package org.wso2.carbon.policy.mgt.core.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; +import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.core.dao.EnrolmentDAO; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceDecisionPoint; import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; +import org.wso2.carbon.policy.mgt.core.mgt.impl.PolicyManagerImpl; public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { + + private static final Log log = LogFactory.getLog(ComplianceDecisionPointImpl.class); + + private EnrolmentDAO enrolmentDAO; + private DeviceDAO deviceDAO; + + private PolicyManager policyManager; + + public ComplianceDecisionPointImpl() { + enrolmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO(); + deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); + policyManager = new PolicyManagerImpl(); + } + @Override public String getNoneComplianceRule(Policy policy) throws PolicyComplianceException { - return null; + return policy.getCompliance(); } @Override @@ -66,7 +87,8 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { } @Override - public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws PolicyComplianceException { + public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws + PolicyComplianceException { } }