|
|
@ -53,7 +53,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
private DeviceTypeDAO deviceTypeDAO;
|
|
|
|
private DeviceTypeDAO deviceTypeDAO;
|
|
|
|
private EnrolmentDAO enrolmentDAO;
|
|
|
|
private EnrolmentDAO enrolmentDAO;
|
|
|
|
private DeviceManagementPluginRepository pluginRepository;
|
|
|
|
private DeviceManagementPluginRepository pluginRepository;
|
|
|
|
private boolean isTest = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class);
|
|
|
|
private int tenantId;
|
|
|
|
private int tenantId;
|
|
|
@ -75,7 +74,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
DeviceManagementProviderServiceImpl(DeviceManagementPluginRepository pluginRepo, boolean test){
|
|
|
|
DeviceManagementProviderServiceImpl(DeviceManagementPluginRepository pluginRepo, boolean test){
|
|
|
|
this.pluginRepository = pluginRepo;
|
|
|
|
this.pluginRepository = pluginRepo;
|
|
|
|
initDataAccessObjects();
|
|
|
|
initDataAccessObjects();
|
|
|
|
isTest = test;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initDataAccessObjects() {
|
|
|
|
private void initDataAccessObjects() {
|
|
|
@ -108,7 +106,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.ACTIVE);
|
|
|
|
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.ACTIVE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int tenantId = getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceManagementDAOFactory.beginTransaction();
|
|
|
|
|
|
|
|
|
|
|
@ -724,14 +722,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
DeviceManagementDAOFactory.getConnection();
|
|
|
|
DeviceManagementDAOFactory.getConnection();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
allDevices = deviceDAO.getDevicesByStatus(status, tenantId);
|
|
|
|
allDevices = deviceDAO.getDevicesByStatus(status, tenantId);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
String errorMsg = "Error occurred while fetching the list of devices that matches to status: '"
|
|
|
|
throw new DeviceManagementException(
|
|
|
|
+ status + "'";
|
|
|
|
"Error occurred while fetching the list of devices that matches to status: '" + status + "'", e);
|
|
|
|
log.error(errorMsg, e);
|
|
|
|
|
|
|
|
throw new DeviceManagementException(errorMsg, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
DeviceManagementDAOFactory.closeConnection();
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
@ -753,19 +747,4 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
return devices;
|
|
|
|
return devices;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getTenantId() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ThreadLocal<Integer> tenantId = new ThreadLocal<Integer>();
|
|
|
|
|
|
|
|
int tenant = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isTest){
|
|
|
|
|
|
|
|
tenant = DeviceManagerUtil.currentTenant.get();
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
tenant = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return tenant;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|