|
|
@ -21,7 +21,6 @@ package org.wso2.carbon.policy.mgt.core.mgt.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
@ -30,12 +29,8 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
|
|
|
import org.wso2.carbon.device.mgt.core.config.policy.PolicyConfiguration;
|
|
|
|
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.dto.DeviceType;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
|
|
|
|
|
|
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
|
|
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
|
|
|
@ -56,8 +51,6 @@ import java.util.Map;
|
|
|
|
public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
|
|
|
|
|
|
|
|
private PolicyDAO policyDAO;
|
|
|
|
private PolicyDAO policyDAO;
|
|
|
|
// private DeviceDAO deviceDAO;
|
|
|
|
|
|
|
|
private DeviceTypeDAO deviceTypeDAO;
|
|
|
|
|
|
|
|
private MonitoringDAO monitoringDAO;
|
|
|
|
private MonitoringDAO monitoringDAO;
|
|
|
|
private ComplianceDecisionPoint complianceDecisionPoint;
|
|
|
|
private ComplianceDecisionPoint complianceDecisionPoint;
|
|
|
|
private PolicyConfiguration policyConfiguration;
|
|
|
|
private PolicyConfiguration policyConfiguration;
|
|
|
@ -69,8 +62,6 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
|
|
|
|
|
|
|
|
public MonitoringManagerImpl() {
|
|
|
|
public MonitoringManagerImpl() {
|
|
|
|
this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO();
|
|
|
|
this.policyDAO = PolicyManagementDAOFactory.getPolicyDAO();
|
|
|
|
// this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
|
|
|
|
|
|
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
|
|
|
|
|
|
|
this.monitoringDAO = PolicyManagementDAOFactory.getMonitoringDAO();
|
|
|
|
this.monitoringDAO = PolicyManagementDAOFactory.getMonitoringDAO();
|
|
|
|
this.complianceDecisionPoint = new ComplianceDecisionPointImpl();
|
|
|
|
this.complianceDecisionPoint = new ComplianceDecisionPointImpl();
|
|
|
|
this.policyConfiguration =
|
|
|
|
this.policyConfiguration =
|
|
|
@ -84,7 +75,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
|
|
|
|
|
|
|
|
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
|
|
|
List<ComplianceFeature> complianceFeatures = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
|
|
|
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
|
|
|
PolicyManager manager = new PolicyManagerImpl();
|
|
|
|
PolicyManager manager = new PolicyManagerImpl();
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
|
|
|
|
Policy policy = manager.getAppliedPolicyToDevice(deviceIdentifier);
|
|
|
@ -179,7 +170,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
|
|
|
public boolean isCompliance(DeviceIdentifier deviceIdentifier) throws PolicyComplianceException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
|
|
|
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
PolicyManagementDAOFactory.openConnection();
|
|
|
|
PolicyManagementDAOFactory.openConnection();
|
|
|
|
ComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
|
|
|
|
ComplianceData complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo()
|
|
|
@ -209,7 +200,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
ComplianceData complianceData;
|
|
|
|
ComplianceData complianceData;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
PolicyManagementDAOFactory.openConnection();
|
|
|
|
PolicyManagementDAOFactory.openConnection();
|
|
|
|
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
|
|
|
DeviceManagementProviderService service = PolicyManagementDataHolder.getInstance().getDeviceManagementService();
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
Device device = service.getDevice(deviceIdentifier);
|
|
|
|
complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
|
|
|
|
complianceData = monitoringDAO.getCompliance(device.getId(), device.getEnrolmentInfo().getId());
|
|
|
|
List<ComplianceFeature> complianceFeatures =
|
|
|
|
List<ComplianceFeature> complianceFeatures =
|
|
|
@ -374,17 +365,13 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<DeviceType> getDeviceTypes() throws PolicyComplianceException {
|
|
|
|
public List<String> getDeviceTypes() throws PolicyComplianceException {
|
|
|
|
|
|
|
|
|
|
|
|
List<DeviceType> deviceTypes = new ArrayList<>();
|
|
|
|
List<String> deviceTypes = new ArrayList<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.openConnection();
|
|
|
|
deviceTypes = PolicyManagementDataHolder.getInstance().getDeviceManagementService().getAvailableDeviceTypes();
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
deviceTypes = deviceTypeDAO.getDeviceTypes(tenantId);
|
|
|
|
throw new PolicyComplianceException("Error occurred while getting the device types.", e);
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.error("Error occurred while getting the device types.", e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return deviceTypes;
|
|
|
|
return deviceTypes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|