From 7fed00a14db8dd7ab5324badddb45827c175392f Mon Sep 17 00:00:00 2001 From: mharindu Date: Wed, 26 Aug 2015 18:10:10 +0530 Subject: [PATCH] Removed unnecessary logs and added null checks in MonitoringManager --- .../mgt/core/mgt/impl/MonitoringManagerImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 34a9ad9aaa..b4445af160 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 @@ -293,13 +293,16 @@ public class MonitoringManagerImpl implements MonitoringManager { } catch (PolicyManagerDAOException e) { PolicyManagementDAOFactory.rollbackTransaction(); throw new PolicyComplianceException("Error occurred reading the applied policies to devices.", e); + } catch (DeviceManagementException e) { + PolicyManagementDAOFactory.rollbackTransaction(); + throw new PolicyComplianceException("Error occurred while adding monitoring operation to DB."); } finally { PolicyManagementDAOFactory.closeConnection(); } } private void addMonitoringOperationsToDatabase(List devices) - throws PolicyComplianceException, OperationManagementException { + throws PolicyComplianceException, OperationManagementException, DeviceManagementException { List deviceIdentifiers = this.getDeviceIdentifiersFromDevices(devices); CommandOperation monitoringOperation = new CommandOperation(); @@ -308,9 +311,10 @@ public class MonitoringManagerImpl implements MonitoringManager { monitoringOperation.setCode(OPERATION_MONITOR); DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl(); + if (service == null) { + throw new DeviceManagementException("Error occurred while retrieving Device Management Service"); + } service.addOperation(monitoringOperation, deviceIdentifiers); -// PolicyManagementDataHolder.getInstance().getDeviceManagementService(). -// addOperation(monitoringOperation, deviceIdentifiers); } private List getDeviceIdentifiersFromDevices(List devices) {