From 2e8972288362e38be85ca7618597ebabcd327f03 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 6 Jul 2015 11:08:40 +0530 Subject: [PATCH 1/4] Fixing the monitoring dao --- .../carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java index e34f4eab84..6377212ff5 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/impl/MonitoringDAOImpl.java @@ -21,8 +21,8 @@ package org.wso2.carbon.policy.mgt.core.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAO; import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAOException; import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory; From 3c73bba40cc4ff980506c548a8be9fb2368504c7 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 6 Jul 2015 12:04:35 +0530 Subject: [PATCH 2/4] Commiting ppartialy to get updates --- .../impl/ComplianceDecisionPointImpl.java | 23 +++++++++++++++++++ pom.xml | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java 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 new file mode 100644 index 0000000000..8efd5fc203 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.wso2.carbon.policy.mgt.core.impl; + +public class ComplianceDecisionPointImpl { +} diff --git a/pom.xml b/pom.xml index 2aee3e9fbb..61f65c60c8 100644 --- a/pom.xml +++ b/pom.xml @@ -904,6 +904,13 @@ jackson-jaxrs ${jackson.version} + + + org.wso2.carbon.commons + org.wso2.carbon.ntask.core + ${carbon.commons.version} + + From e0dd398b270829c69411bed52adba4787d4d3047 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 6 Jul 2015 15:26:19 +0530 Subject: [PATCH 3/4] Fixing build failiures --- .../org.wso2.carbon.policy.mgt.common/pom.xml | 3 -- .../mgt/common/Monitor/ComplianceData.java | 2 +- .../Monitor/ComplianceDecisionPoint.java | 48 +++++++++++++++++ .../mgt/common/Monitor/ComplianceFeature.java | 2 +- .../Monitor/PolicyComplianceException.java | 2 +- .../common/spi/PolicyMonitoringService.java | 4 +- .../org.wso2.carbon.policy.mgt.core/pom.xml | 9 +++- .../policy/mgt/core/PolicyManagerService.java | 8 +-- .../mgt/core/PolicyManagerServiceImpl.java | 13 +++-- .../policy/mgt/core/dao/MonitoringDAO.java | 5 +- .../impl/ComplianceDecisionPointImpl.java | 51 ++++++++++++++++++- .../mgt/core/mgt/MonitoringManager.java | 6 +-- .../core/mgt/impl/MonitoringManagerImpl.java | 6 +-- .../core/service/PolicyManagementService.java | 11 ++-- .../policy/mgt/core/task/MonitoringTask.java | 42 +++++++++++++++ 15 files changed, 182 insertions(+), 30 deletions(-) create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java create mode 100644 components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml index 86e3b3e3a0..2fa5370241 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/pom.xml @@ -52,12 +52,9 @@ ${project.artifactId} ${carbon.device.mgt.version} Policy Management Common Bundle - org.wso2.carbon.policy.mgt.common.internal - org.apache.commons.logging, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.core.dto.*, - org.wso2.carbon.device.mgt.core.operation.*, javax.xml.bind.*, diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java index 85234fff61..ea64f96417 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceData.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java new file mode 100644 index 0000000000..fa751528ab --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceDecisionPoint.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.wso2.carbon.policy.mgt.common.monitor; + + +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.policy.mgt.common.Policy; + +public interface ComplianceDecisionPoint { + + String getNoneComplianceRule(Policy policy) throws PolicyComplianceException; + + void setDeviceAsUnreachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void reEnforcePolicy(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void markDeviceAsCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void deactivateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws + PolicyComplianceException; + + +} diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java index 7c4589a8ab..0e3e9a9536 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/ComplianceFeature.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; import org.wso2.carbon.policy.mgt.common.ProfileFeature; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java index d579546dd9..8d846eb49c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.common/src/main/java/org/wso2/carbon/policy/mgt/common/Monitor/PolicyComplianceException.java @@ -17,7 +17,7 @@ */ -package org.wso2.carbon.policy.mgt.common.Monitor; +package org.wso2.carbon.policy.mgt.common.monitor; public class PolicyComplianceException extends Exception { 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 4d5e34b368..86af5a0693 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 @@ -20,8 +20,8 @@ package org.wso2.carbon.policy.mgt.common.spi; 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; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import java.util.List; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml index bd87dba8f4..d66c087ac2 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/pom.xml @@ -71,7 +71,8 @@ org.wso2.carbon.context.*, org.wso2.carbon.user.api.*, org.wso2.carbon.device.mgt.core.*, - org.wso2.carbon.device.mgt.common.* + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.ntask.* !org.wso2.carbon.policy.mgt.core.internal, @@ -132,6 +133,12 @@ org.wso2.carbon.ndatasource.rdbms + + + org.wso2.carbon.commons + org.wso2.carbon.ntask.core + + org.wso2.carbon.devicemgt diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java index 3a5a48ab52..59e0c7a30d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/PolicyManagerService.java @@ -22,9 +22,9 @@ package org.wso2.carbon.policy.mgt.core; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; @@ -77,4 +77,6 @@ public interface PolicyManagerService { boolean checkCompliance(DeviceIdentifier deviceIdentifier, Object response) throws PolicyComplianceException; ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; + + boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException; } 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 c4fcd2a4e8..70e76eb1f2 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 @@ -27,18 +27,16 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation; import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation; import org.wso2.carbon.policy.mgt.common.*; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl; import org.wso2.carbon.policy.mgt.core.impl.PolicyInformationPointImpl; import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder; import org.wso2.carbon.policy.mgt.core.mgt.MonitoringManager; import org.wso2.carbon.policy.mgt.core.mgt.impl.MonitoringManagerImpl; -import org.wso2.carbon.policy.mgt.core.util.PolicyManagementConstants; import java.util.ArrayList; -import java.util.Date; import java.util.List; public class PolicyManagerServiceImpl implements PolicyManagerService { @@ -232,4 +230,9 @@ public class PolicyManagerServiceImpl implements PolicyManagerService { public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { return monitoringManager.getDevicePolicyCompliance(deviceIdentifier); } + + @Override + public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + return monitoringManager.isCompliance(deviceIdentifier); + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java index e97501dc05..a29928f8c4 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/dao/MonitoringDAO.java @@ -19,11 +19,10 @@ package org.wso2.carbon.policy.mgt.core.dao; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import java.util.List; -import java.util.Map; public interface MonitoringDAO { 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 8efd5fc203..e089f03204 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,5 +19,54 @@ package org.wso2.carbon.policy.mgt.core.impl; -public class ComplianceDecisionPointImpl { +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +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; + +public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { + @Override + public String getNoneComplianceRule(Policy policy) throws PolicyComplianceException { + return null; + } + + @Override + public void setDeviceAsUnreachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void setDeviceAsReachable(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void reEnforcePolicy(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void markDeviceAsNoneCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void markDeviceAsCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void deactivateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void activateDevice(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + + } + + @Override + public void validateDevicePolicyCompliance(DeviceIdentifier deviceIdentifier, Policy policy) throws PolicyComplianceException { + + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java index f0ca764d8c..8ad323f2eb 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/MonitoringManager.java @@ -20,9 +20,9 @@ package org.wso2.carbon.policy.mgt.core.mgt; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import java.util.List; 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 56c4f593b8..d5143122a3 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 @@ -26,9 +26,9 @@ 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.DeviceManagementDAOException; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java index a6cebdd59c..5c73fcedea 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/service/PolicyManagementService.java @@ -21,9 +21,9 @@ package org.wso2.carbon.policy.mgt.core.service; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.policy.mgt.common.FeatureManagementException; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceData; -import org.wso2.carbon.policy.mgt.common.Monitor.ComplianceFeature; -import org.wso2.carbon.policy.mgt.common.Monitor.PolicyComplianceException; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; +import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; +import org.wso2.carbon.policy.mgt.common.monitor.PolicyComplianceException; import org.wso2.carbon.policy.mgt.common.Policy; import org.wso2.carbon.policy.mgt.common.PolicyAdministratorPoint; import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint; @@ -132,4 +132,9 @@ public class PolicyManagementService implements PolicyManagerService { public ComplianceData getDeviceCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { return policyManagerService.getDeviceCompliance(deviceIdentifier); } + + @Override + public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException { + return policyManagerService.isCompliance(deviceIdentifier); + } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java new file mode 100644 index 0000000000..e68c55e921 --- /dev/null +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/task/MonitoringTask.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package org.wso2.carbon.policy.mgt.core.task; + +import org.wso2.carbon.ntask.core.Task; + +import java.util.Map; + +public class MonitoringTask implements Task { + + @Override + public void setProperties(Map map) { + + } + + @Override + public void init() { + + } + + @Override + public void execute() { + + } +} From 8bc7c5824aea1f56ee5db7229e92184ff9a4994c Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 6 Jul 2015 17:57:59 +0530 Subject: [PATCH 4/4] Fixing test case failures and device dao errors --- .../device/mgt/core/dao/impl/DeviceDAOImpl.java | 4 ++-- .../carbon/policy/mgt/core/PolicyDAOTestCase.java | 10 +++++----- .../src/test/resources/sql/CreateH2TestDB.sql | 15 +++++++++++++++ .../src/test/resources/testng.xml | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java index 4d9c85ee3b..0ba38db1e9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/DeviceDAOImpl.java @@ -115,10 +115,10 @@ public class DeviceDAOImpl implements DeviceDAO { try { conn = this.getConnection(); String sql = - "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + + "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " + "e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " + "t.NAME AS DEVICE_TYPE, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE " + - "t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?"; + "t.NAME = ? AND d.DEVICE_IDENTIFICATION = ? AND d.TENANT_ID = ?) d1 WHERE d1.ID = e.DEVICE_ID AND TENANT_ID = ?"; stmt = conn.prepareStatement(sql); stmt.setString(1, deviceId.getType()); stmt.setString(2, deviceId.getId()); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java index b7bfd89035..7276c82b5d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/java/org/wso2/carbon/policy/mgt/core/PolicyDAOTestCase.java @@ -24,10 +24,7 @@ import org.testng.annotations.Test; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.Feature; -import org.wso2.carbon.device.mgt.core.dao.DeviceDAO; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; -import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO; +import org.wso2.carbon.device.mgt.core.dao.*; import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl; @@ -56,6 +53,7 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { @Override public void init() throws Exception { initDatSource(); + System.setProperty("GetTenantIDForTest", "Super"); } @Test @@ -69,10 +67,12 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest { public void addDevice() throws DeviceManagementDAOException { DeviceDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceDAO(); + EnrolmentDAO enrolmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO(); DeviceType type = DeviceTypeCreator.getDeviceType(); devices = DeviceCreator.getDeviceList(type); for (Device device : devices) { - deviceTypeDAO.addDevice(type.getId(), device, -1234); + int id = deviceTypeDAO.addDevice(type.getId(), device, -1234); + enrolmentDAO.addEnrollment(id, device.getEnrolmentInfo(), -1234); } } 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 b4bfe487a2..ba7a42d068 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 @@ -21,6 +21,21 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( REFERENCES DM_DEVICE_TYPE (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, + OWNER VARCHAR(50) NOT NULL, + OWNERSHIP VARCHAR(45) NULL DEFAULT NULL, + STATUS VARCHAR(50) NULL, + DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL, + DATE_OF_LAST_UPDATE TIMESTAMP NULL DEFAULT NULL, + TENANT_ID INT NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES + DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + + CREATE TABLE IF NOT EXISTS DM_OPERATION ( ID INTEGER AUTO_INCREMENT NOT NULL, TYPE VARCHAR(50) NOT NULL, diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/testng.xml b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/testng.xml index 222c07c7f4..02107984d5 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/testng.xml +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/testng.xml @@ -25,7 +25,7 @@ - + \ No newline at end of file