mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fixing the operations connection close problems
This commit is contained in:
parent
f4b2a9ca3a
commit
f2b8f978f5
@ -76,7 +76,7 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
log.debug("operation:[" + operation.toString() + "]");
|
log.debug("operation:[" + operation.toString() + "]");
|
||||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||||
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" +
|
log.debug("device identifier id:[" + deviceIdentifier.getId() + "] type:[" +
|
||||||
deviceIdentifier.getType() + "]");
|
deviceIdentifier.getType() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -129,10 +129,15 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
int enrolmentId;
|
int enrolmentId;
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
OperationManagementDAOFactory.openConnection();
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
OperationManagementDAOFactory.openConnection();
|
||||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
|
|
||||||
if (enrolmentId < 0) {
|
if (enrolmentId < 0) {
|
||||||
throw new OperationManagementException("Device not found for given device " +
|
throw new OperationManagementException("Device not found for given device " +
|
||||||
@ -170,14 +175,20 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>();
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
OperationManagementDAOFactory.openConnection();
|
OperationManagementDAOFactory.openConnection();
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
|
|
||||||
if (enrolmentId < 0) {
|
if (enrolmentId < 0) {
|
||||||
throw new OperationManagementException("Device not found for the given device Identifier:" +
|
throw new OperationManagementException("Device not found for the given device Identifier:" +
|
||||||
deviceId.getId() + " and given type:" + deviceId.getType());
|
deviceId.getId() + " and given type:" + deviceId.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
dtoOperationList.addAll(commandOperationDAO.getOperationsByDeviceAndStatus(
|
dtoOperationList.addAll(commandOperationDAO.getOperationsByDeviceAndStatus(
|
||||||
@ -223,10 +234,15 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
Operation operation = null;
|
Operation operation = null;
|
||||||
int enrolmentId;
|
int enrolmentId;
|
||||||
try {
|
try {
|
||||||
OperationManagementDAOFactory.openConnection();
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
OperationManagementDAOFactory.openConnection();
|
||||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
|
|
||||||
if (enrolmentId < 0) {
|
if (enrolmentId < 0) {
|
||||||
throw new OperationManagementException("Device not found for given device " +
|
throw new OperationManagementException("Device not found for given device " +
|
||||||
@ -274,11 +290,19 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("operation Id:" + operationId + " status:" + operation.getStatus());
|
log.debug("operation Id:" + operationId + " status:" + operation.getStatus());
|
||||||
}
|
}
|
||||||
|
int enrolmentId;
|
||||||
try {
|
try {
|
||||||
OperationManagementDAOFactory.beginTransaction();
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
OperationManagementDAOFactory.beginTransaction();
|
||||||
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
|
|
||||||
if (operation.getStatus() != null) {
|
if (operation.getStatus() != null) {
|
||||||
operationDAO.updateOperationStatus(enrolmentId, operationId,
|
operationDAO.updateOperationStatus(enrolmentId, operationId,
|
||||||
@ -337,10 +361,16 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
deviceId.getId());
|
deviceId.getId());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
OperationManagementDAOFactory.openConnection();
|
OperationManagementDAOFactory.openConnection();
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
if (enrolmentId < 0) {
|
if (enrolmentId < 0) {
|
||||||
throw new OperationManagementException("Device not found for given device identifier:" +
|
throw new OperationManagementException("Device not found for given device identifier:" +
|
||||||
deviceId.getId() + " type:" + deviceId.getType());
|
deviceId.getId() + " type:" + deviceId.getType());
|
||||||
@ -393,12 +423,17 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
List<org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation> dtoOperationList =
|
||||||
new ArrayList<>();
|
new ArrayList<>();
|
||||||
|
int enrolmentId;
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
OperationManagementDAOFactory.openConnection();
|
OperationManagementDAOFactory.openConnection();
|
||||||
|
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
int enrolmentId = deviceDAO.getEnrolmentByStatus(deviceId, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
|
|
||||||
if (enrolmentId < 0) {
|
if (enrolmentId < 0) {
|
||||||
throw new OperationManagementException("Device not found for device id:" + deviceId.getId() + " " +
|
throw new OperationManagementException("Device not found for device id:" + deviceId.getId() + " " +
|
||||||
"type:" + deviceId.getType());
|
"type:" + deviceId.getType());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user