|
|
@ -546,8 +546,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(),
|
|
|
|
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
|
|
|
|
device.getType());
|
|
|
|
boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(),
|
|
|
|
|
|
|
|
device.getEnrolmentInfo().getStatus().name(),tenantId);
|
|
|
|
|
|
|
|
if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
} else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
log.info("Device enrollment modified successfully",
|
|
|
|
log.info("Device enrollment modified successfully",
|
|
|
@ -666,7 +672,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(), device.getType());
|
|
|
|
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
|
|
|
|
|
|
|
|
boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(device.getType(),device.getEnrolmentInfo().getStatus().name(),tenantId);
|
|
|
|
|
|
|
|
if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
} else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
this.removeDeviceFromCache(deviceId);
|
|
|
|
this.removeDeviceFromCache(deviceId);
|
|
|
|
|
|
|
|
|
|
|
@ -3463,11 +3475,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
String type = deviceIdentifier.getType();
|
|
|
|
String type = deviceIdentifier.getType();
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
if (updatedRows > 0) {
|
|
|
|
if (updatedRows > 0) {
|
|
|
|
isUpdatedEnrollment = true;
|
|
|
|
isUpdatedEnrollment = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, enrolmentInfo, type);
|
|
|
|
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
|
|
|
|
DeviceManagementDAOFactory.commitTransaction();
|
|
|
|
boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, enrolmentInfo.getStatus().name(), tenantId);
|
|
|
|
|
|
|
|
if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
|
|
|
|
|
|
|
|
} else if (updatedRows == 1 && isEnableDeviceStatusCheck && isValidState) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
@ -3485,24 +3503,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
return isUpdatedEnrollment;
|
|
|
|
return isUpdatedEnrollment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Save the status according to status check(allowed device status)
|
|
|
|
|
|
|
|
* Before invoking this method the calling function should have started a transaction
|
|
|
|
|
|
|
|
* @param deviceStatusManagementService instance of deviceStatusManagementService
|
|
|
|
|
|
|
|
* @param tenantId ID of the tenant
|
|
|
|
|
|
|
|
* @param updatedRows number of updated rows
|
|
|
|
|
|
|
|
* @param enrolmentInfo enrollment info of the device
|
|
|
|
|
|
|
|
* @param type type of the device
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void addDeviceStatus(DeviceStatusManagementService deviceStatusManagementService, int tenantId,
|
|
|
|
|
|
|
|
int updatedRows,EnrolmentInfo enrolmentInfo,String type)
|
|
|
|
|
|
|
|
throws MetadataManagementException, DeviceManagementDAOException {
|
|
|
|
|
|
|
|
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
|
|
|
|
|
|
|
|
boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, enrolmentInfo.getStatus().name(), tenantId);
|
|
|
|
|
|
|
|
if (updatedRows == 1 && (!isEnableDeviceStatusCheck || isValidState)) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getTenantId() {
|
|
|
|
private int getTenantId() {
|
|
|
|
return CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
return CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
@ -4523,8 +4523,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
.getInstance().getDeviceStatusManagementService();
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
|
|
|
|
addDeviceStatus(deviceStatusManagementService, tenantId, updatedRows, device.getEnrolmentInfo(),
|
|
|
|
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
|
|
|
|
type);
|
|
|
|
boolean isValidState = deviceStatusManagementService.isDeviceStatusValid(type, String.valueOf(EnrolmentInfo.Status.REMOVED),tenantId);
|
|
|
|
|
|
|
|
if (updatedRows == 1 && !deviceStatusManagementService.getDeviceStatusCheck(tenantId)){
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
} else if (updatedRows ==1 && isEnableDeviceStatusCheck && isValidState ) {
|
|
|
|
|
|
|
|
enrollmentDAO.addDeviceStatus(device.getEnrolmentInfo().getId(), device.getEnrolmentInfo().getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
} catch (DeviceManagementDAOException e) {
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
DeviceManagementDAOFactory.rollbackTransaction();
|
|
|
|
String msg = "Error occurred while dis-enrolling device: " +
|
|
|
|
String msg = "Error occurred while dis-enrolling device: " +
|
|
|
|