revert-70aa11f8
manoj 9 years ago
commit 286a04dd31

@ -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());

@ -52,12 +52,9 @@
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Policy Management Common Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.policy.mgt.common.internal</Private-Package>
<Import-Package>
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.*,
</Import-Package>
<Export-Package>

@ -17,7 +17,7 @@
*/
package org.wso2.carbon.policy.mgt.common.Monitor;
package org.wso2.carbon.policy.mgt.common.monitor;
import java.util.List;

@ -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;
}

@ -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;

@ -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 {

@ -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;

@ -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.*
</Import-Package>
<Export-Package>
!org.wso2.carbon.policy.mgt.core.internal,
@ -132,6 +133,12 @@
<artifactId>org.wso2.carbon.ndatasource.rdbms</artifactId>
</dependency>
<!--Ntask dependencies-->
<dependency>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.ntask.core</artifactId>
</dependency>
<!-- Policy Management Dependencies-->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>

@ -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;
}

@ -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);
}
}

@ -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 {

@ -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;

@ -0,0 +1,72 @@
/*
* 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;
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 {
}
}

@ -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;

@ -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;

@ -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);
}
}

@ -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<String, String> map) {
}
@Override
public void init() {
}
@Override
public void execute() {
}
}

@ -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);
}
}

@ -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,

@ -25,7 +25,7 @@
<test name="DAO Unit Tests" preserve-order="true">
<parameter name="dbType" value="H2"/>
<classes>
<!--<class name="org.wso2.carbon.policy.mgt.core.PolicyDAOTestCase"/>-->
<class name="org.wso2.carbon.policy.mgt.core.PolicyDAOTestCase"/>
</classes>
</test>
</suite>

@ -905,6 +905,13 @@
<artifactId>jackson-jaxrs</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.ntask.core</artifactId>
<version>${carbon.commons.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Loading…
Cancel
Save