From fde54d2d32595ddaeecd9a4bbc81a87f1fe1d7be Mon Sep 17 00:00:00 2001 From: geethkokila Date: Fri, 24 Jul 2015 12:26:57 +0530 Subject: [PATCH] Fixing the monitoring service --- .../internal/PolicyManagementDataHolder.java | 3 +- .../src/test/resources/sql/CreateH2TestDB.sql | 32 +++++++++++++++++++ .../src/main/resources/dbscripts/cdm/h2.sql | 31 ++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java index af03b36d566..dd4519eb5b6 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/internal/PolicyManagementDataHolder.java @@ -26,6 +26,7 @@ import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; +import java.util.HashMap; import java.util.Map; public class PolicyManagementDataHolder { @@ -35,7 +36,7 @@ public class PolicyManagementDataHolder { private PolicyEvaluationPoint policyEvaluationPoint; private PolicyInformationPoint policyInformationPoint; private DeviceManagementProviderService deviceManagementService; - private Map policyMonitoringServiceMap; + private Map policyMonitoringServiceMap = new HashMap<>(); private TaskService taskService; private static PolicyManagementDataHolder thisInstance = new PolicyManagementDataHolder(); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index ba7a42d0685..b7bd8e1f025 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -308,6 +308,38 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( ); + +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_ID INT NOT NULL, + POLICY_ID INT NOT NULL, + STATUS INT NULL, + LAST_SUCCESS_TIME TIMESTAMP NULL, + LAST_REQUESTED_TIME TIMESTAMP NULL, + LAST_FAILED_TIME TIMESTAMP NULL, + ATTEMPTS INT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + + +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( + ID INT NOT NULL AUTO_INCREMENT, + COMPLIANCE_STATUS_ID INT NOT NULL, + FEATURE_CODE INT NOT NULL, + STATUS INT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_COMPLIANCE_FEATURES_STATUS + FOREIGN KEY (COMPLIANCE_STATUS_ID) + REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + -- POLICY RELATED TABLES FINISHED -- diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql index 974111eea7d..6c742534ff5 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -281,6 +281,37 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( ON UPDATE NO ACTION ); +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( + ID INT NOT NULL AUTO_INCREMENT, + DEVICE_ID INT NOT NULL, + POLICY_ID INT NOT NULL, + STATUS INT NULL, + LAST_SUCCESS_TIME TIMESTAMP NULL, + LAST_REQUESTED_TIME TIMESTAMP NULL, + LAST_FAILED_TIME TIMESTAMP NULL, + ATTEMPTS INT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + + +CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( + ID INT NOT NULL AUTO_INCREMENT, + COMPLIANCE_STATUS_ID INT NOT NULL, + FEATURE_CODE INT NOT NULL, + STATUS INT NULL, + PRIMARY KEY (ID), + CONSTRAINT FK_COMPLIANCE_FEATURES_STATUS + FOREIGN KEY (COMPLIANCE_STATUS_ID) + REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION +); + CREATE TABLE IF NOT EXISTS DM_ENROLMENT ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL,