Avoid unnecessary db connection

merge-requests/541/head
Charitha Goonetilleke 5 years ago
parent f59242d6b8
commit 9280810b24

@ -289,20 +289,20 @@ public class MonitoringManagerImpl implements MonitoringManager {
PolicyManagementDAOFactory.closeConnection(); PolicyManagementDAOFactory.closeConnection();
} }
try { if (!firstTimeComplianceData.isEmpty()) {
PolicyManagementDAOFactory.beginTransaction(); try {
if (!firstTimeComplianceData.isEmpty()) { PolicyManagementDAOFactory.beginTransaction();
monitoringDAO.addComplianceDetails(firstTimeComplianceData); monitoringDAO.addComplianceDetails(firstTimeComplianceData);
PolicyManagementDAOFactory.commitTransaction(); PolicyManagementDAOFactory.commitTransaction();
} catch (MonitoringDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Error occurred from monitoring dao.", e);
} catch (PolicyManagerDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Error occurred reading the applied policies to devices.", e);
} finally {
PolicyManagementDAOFactory.closeConnection();
} }
} catch (MonitoringDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Error occurred from monitoring dao.", e);
} catch (PolicyManagerDAOException e) {
PolicyManagementDAOFactory.rollbackTransaction();
throw new PolicyComplianceException("Error occurred reading the applied policies to devices.", e);
} finally {
PolicyManagementDAOFactory.closeConnection();
} }
if (!notifiableDeviceEnrollments.isEmpty()) { if (!notifiableDeviceEnrollments.isEmpty()) {

Loading…
Cancel
Save