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();
}
try {
PolicyManagementDAOFactory.beginTransaction();
if (!firstTimeComplianceData.isEmpty()) {
if (!firstTimeComplianceData.isEmpty()) {
try {
PolicyManagementDAOFactory.beginTransaction();
monitoringDAO.addComplianceDetails(firstTimeComplianceData);
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()) {

Loading…
Cancel
Save