Add a check if device status are filtered before adding to database

pull/250/head
Pramila Niroshan 1 year ago
parent 6399afe64c
commit a2544c1520

@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.util;
import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService;
import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager;
import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.java.security.SSLProtocolSocketFactory;
@ -153,6 +154,8 @@ public class DeviceMgtAPIUtils {
// private static IntegrationClientService integrationClientService;
private static MetadataManagementService metadataManagementService;
private static WhiteLabelManagementService whiteLabelManagementService;
private static DeviceStatusManagementService deviceStatusManagementService;
private static OTPManagementService otpManagementService;
private static volatile SubscriptionManager subscriptionManager;
@ -532,6 +535,28 @@ public class DeviceMgtAPIUtils {
return whiteLabelManagementService;
}
/**
* Initializing and accessing method for DeviceStatusManagementService.
*
* @return WhiteLabelManagementService instance
* @throws IllegalStateException if DeviceStatusManagementService cannot be initialized
*/
public static DeviceStatusManagementService getDeviceStatusManagmentService() {
if (deviceStatusManagementService == null) {
synchronized (DeviceMgtAPIUtils.class) {
if (deviceStatusManagementService == null) {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
deviceStatusManagementService = (DeviceStatusManagementService) ctx.getOSGiService(
DeviceStatusManagementService.class, null);
if (deviceStatusManagementService == null) {
throw new IllegalStateException("DeviceStatusManagementService Management service not initialized.");
}
}
}
}
return deviceStatusManagementService;
}
/**
* Initializing and accessing method for MetadataManagementService.
*

@ -20,6 +20,8 @@ package io.entgra.device.mgt.core.device.mgt.common.metadata.mgt;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
import java.util.List;
public interface DeviceStatusManagementService {
@ -51,7 +53,7 @@ public interface DeviceStatusManagementService {
*
* @throws MetadataManagementException if error while getting existing device status
*/
AllowedDeviceStatus getDeviceStatusFilters(int tenantId) throws MetadataManagementException;
List<AllowedDeviceStatus> getDeviceStatusFilters(int tenantId) throws MetadataManagementException;
/**
* This method is useful to get existing device status filters
@ -59,4 +61,6 @@ public interface DeviceStatusManagementService {
* @throws MetadataManagementException if error while getting existing device status check
*/
boolean getDeviceStatusCheck(int tenantId) throws MetadataManagementException;
boolean isDeviceStatusValid(String deviceType, String deviceStatus, int tenantId) throws MetadataManagementException;
}

@ -62,4 +62,35 @@ public interface EnrollmentDAO {
boolean updateOwnerOfEnrollment(List<Device> devices, String owner, int tenantId)
throws DeviceManagementDAOException;
/***
*This method is used to add the device status of the enrollment for given set of devices to given user.
*
* @param currentOwner of device.
* @param status going to add
* @param tenantId tenant id.
* @return either (1) true, if device status is succeeded or false.
* @throws DeviceManagementDAOException if an error occurs when updating device owner.
*/
boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException;
/***
*This method is used to add the device status of the enrollment for given set of devices to given user.
*
* @param config of Enrollment.
* @return either (1) true, if device status is succeeded or false.
* @throws DeviceManagementDAOException if an error occurs when updating device owner.
*/
boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException;
/***
*This method is used to add the device status of the enrollment for given set of devices to given user.
*
* @param enrolmentId of device.
* @param status going to add
* @return either (1) true, if device status is succeeded or false.
* @throws DeviceManagementDAOException if an error occurs when updating device owner.
*/
boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException;
}

@ -93,9 +93,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
stmt.setInt(4, enrolmentInfo.getId());
stmt.setInt(5, tenantId);
int updatedCount = stmt.executeUpdate();
if (updatedCount == 1){
addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
}
return updatedCount;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);
@ -256,11 +253,11 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
return true;
}
private boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
public boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
return addDeviceStatus(config.getId(), config.getStatus());
}
private boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -323,7 +320,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
return true;
}
private boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -345,9 +342,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
deviceId = rs.getInt("DEVICE_ID");
}
DeviceManagementDAOUtil.cleanupResources(stmt, null);
// if there was no record for the enrolment or the previous status is not the same as the current status
// we'll add a record
if (previousStatus == null || previousStatus != status){
if (deviceId == -1) {
// we need the device id in order to add a new record, therefore we get it from the enrolment table
sql = "SELECT DEVICE_ID FROM DM_ENROLMENT WHERE ID = ?";
@ -373,9 +367,6 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
stmt.setTimestamp(4, updateTime);
stmt.setString(5, changedBy);
stmt.execute();
} else {
// no need to update status since the last recorded status is the same as the current status
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device", e);
} finally {

@ -88,9 +88,6 @@ public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
stmt.setInt(4, enrolmentInfo.getId());
stmt.setInt(5, tenantId);
int updatedCount = stmt.executeUpdate();
if (updatedCount == 1){
addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
}
return updatedCount;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);
@ -251,11 +248,11 @@ public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
return true;
}
private boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
public boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
return addDeviceStatus(config.getId(), config.getStatus());
}
private boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -318,7 +315,7 @@ public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
return true;
}
private boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -340,9 +337,6 @@ public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
deviceId = rs.getInt("DEVICE_ID");
}
DeviceManagementDAOUtil.cleanupResources(stmt, null);
// if there was no record for the enrolment or the previous status is not the same as the current status
// we'll add a record
if (previousStatus == null || previousStatus != status){
if (deviceId == -1) {
// we need the device id in order to add a new record, therefore we get it from the enrolment table
sql = "SELECT DEVICE_ID FROM DM_ENROLMENT WHERE ID = ?";
@ -368,9 +362,6 @@ public class GenericEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
stmt.setTimestamp(4, updateTime);
stmt.setString(5, changedBy);
stmt.execute();
} else {
// no need to update status since the last recorded status is the same as the current status
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device", e);
} finally {

@ -87,9 +87,6 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
stmt.setInt(4, enrolmentInfo.getId());
stmt.setInt(5, tenantId);
int updatedCount = stmt.executeUpdate();
if (updatedCount == 1){
addDeviceStatus(enrolmentInfo.getId(), enrolmentInfo.getStatus());
}
return updatedCount;
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while updating enrolment configuration", e);
@ -250,11 +247,11 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
return true;
}
private boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
public boolean addDeviceStatus(EnrolmentInfo config) throws DeviceManagementDAOException {
return addDeviceStatus(config.getId(), config.getStatus());
}
private boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
public boolean addDeviceStatus(String currentOwner, EnrolmentInfo.Status status, int tenantId) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -317,7 +314,7 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
return true;
}
private boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
public boolean addDeviceStatus(int enrolmentId, EnrolmentInfo.Status status) throws DeviceManagementDAOException {
Connection conn;
String changedBy = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (changedBy == null){
@ -341,7 +338,6 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
DeviceManagementDAOUtil.cleanupResources(stmt, null);
// if there was no record for the enrolment or the previous status is not the same as the current status
// we'll add a record
if (previousStatus == null || previousStatus != status){
if (deviceId == -1) {
// we need the device id in order to add a new record, therefore we get it from the enrolment table
sql = "SELECT DEVICE_ID FROM DM_ENROLMENT WHERE ID = ?";
@ -367,9 +363,6 @@ public class SQLServerEnrollmentDAOImpl extends AbstractEnrollmentDAOImpl {
stmt.setTimestamp(4, updateTime);
stmt.setString(5, changedBy);
stmt.execute();
} else {
// no need to update status since the last recorded status is the same as the current status
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while setting the status of device", e);
} finally {

@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.metadata.mgt;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.TransactionManagementException;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.AllowedDeviceStatus;
@ -35,6 +36,7 @@ import io.entgra.device.mgt.core.device.mgt.core.metadata.mgt.dao.util.MetadataC
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.lang.reflect.Type;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@ -87,11 +89,15 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement
}
@Override
public AllowedDeviceStatus getDeviceStatusFilters(int tenantId) throws MetadataManagementException {
public List<AllowedDeviceStatus> getDeviceStatusFilters(int tenantId) throws MetadataManagementException {
try {
MetadataManagementDAOFactory.openConnection();
Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY);
return new Gson().fromJson(metadata.getMetaValue(), AllowedDeviceStatus.class);
Gson gson = new Gson();
Type listType = new TypeToken<List<AllowedDeviceStatus>>() {}.getType();
List<AllowedDeviceStatus> statusList = gson.fromJson(metadata.getMetaValue(), listType);
return statusList;
} catch (MetadataManagementDAOException e) {
String msg = "Error occurred while retrieving device status meta data for tenant:" + tenantId;
log.error(msg, e);
@ -112,19 +118,41 @@ public class DeviceStatusManagementServiceImpl implements DeviceStatusManagement
MetadataManagementDAOFactory.openConnection();
Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.IS_DEVICE_STATUS_CHECK_META_KEY);
String metaValue = metadata.getMetaValue();
return Boolean.parseBoolean(metaValue);
} catch (MetadataManagementDAOException e) {
String msg = "Error occurred while retrieving device status check meta data for tenant:" + tenantId;
log.error(msg, e);
throw new MetadataManagementException(msg, e);
} catch (SQLException e) {
String msg = "Error occurred while opening a connection to the data source";
log.error(msg, e);
throw new MetadataManagementException(msg, e);
} finally {
MetadataManagementDAOFactory.closeConnection();
}
}
@Override
public boolean isDeviceStatusValid(String deviceType, String deviceStatus, int tenantId) throws MetadataManagementException {
try {
MetadataManagementDAOFactory.openConnection();
Metadata metadata = metadataDAO.getMetadata(tenantId, MetadataConstants.ALLOWED_DEVICE_STATUS_META_KEY);
Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(metaValue, JsonObject.class);
if (jsonObject.has("deviceStatusCheck")) {
String deviceStatusCheckValue = jsonObject.get("deviceStatusCheck").getAsString();
return Boolean.parseBoolean(deviceStatusCheckValue);
} else {
// Handle the case where "deviceStatusCheck" key is not found
return false;
Type listType = new TypeToken<List<AllowedDeviceStatus>>() {
}.getType();
List<AllowedDeviceStatus> statusList = gson.fromJson(metadata.getMetaValue(), listType);
for (AllowedDeviceStatus status : statusList) {
if (status.getType().equalsIgnoreCase(deviceType)) {
List<String> allowedStatus = status.getStatus();
return allowedStatus.contains(deviceStatus);
}
}
return false; // Device type not found in metadata
} catch (MetadataManagementDAOException e) {
String msg = "Error occurred while retrieving device status check meta data for tenant:" + tenantId;
String msg = "Error occurred while retrieving device status meta data for tenant: " + tenantId;
log.error(msg, e);
throw new MetadataManagementException(msg, e);
} catch (SQLException e) {

@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.device.mgt.core.service;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
import io.entgra.device.mgt.core.device.mgt.extensions.logger.spi.EntgraLogger;
import io.entgra.device.mgt.core.notification.logger.DeviceEnrolmentLogContext;
import io.entgra.device.mgt.core.notification.logger.impl.EntgraDeviceEnrolmentLoggerImpl;
@ -484,6 +485,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device currentDevice = this.getDevice(deviceIdentifier, false);
DeviceManagementDAOFactory.beginTransaction();
device.setId(currentDevice.getId());
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
.getInstance().getDeviceStatusManagementService();
if (device.getEnrolmentInfo().getId() == 0) {
device.getEnrolmentInfo().setId(currentDevice.getEnrolmentInfo().getId());
}
@ -494,7 +497,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
device.setName(currentDevice.getName());
}
deviceDAO.updateDevice(device, tenantId);
enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
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();
log.info("Device enrolled successfully", deviceEnrolmentLogContextBuilder.setDeviceId(String.valueOf(currentDevice.getId())).setDeviceType(String.valueOf(currentDevice.getType())).setOwner(currentDevice.getEnrolmentInfo().getOwner()).setOwnership(String.valueOf(currentDevice.getEnrolmentInfo().getOwnership())).setTenantID(String.valueOf(tenantId)).setTenantDomain(tenantDomain).setUserName(userName).build());
@ -602,7 +612,16 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED);
DeviceManagementDAOFactory.beginTransaction();
enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
.getInstance().getDeviceStatusManagementService();
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
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());
}
deviceDAO.updateDevice(device, tenantId);
DeviceManagementDAOFactory.commitTransaction();
this.removeDeviceFromCache(deviceId);
@ -3325,7 +3344,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
isDeviceUpdated = disenrollDevice(deviceIdentifier);
} else {
enrolmentInfo.setStatus(newStatus);
isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId);
isDeviceUpdated = updateEnrollment(deviceId, enrolmentInfo, tenantId, deviceIdentifier);
}
this.removeDeviceFromCache(deviceIdentifier);
return isDeviceUpdated;
@ -3356,7 +3375,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
}
private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId)
private boolean updateEnrollment(int deviceId, EnrolmentInfo enrolmentInfo, int tenantId, DeviceIdentifier deviceIdentifier)
throws DeviceManagementException {
if (log.isDebugEnabled()) {
log.debug("Update enrollment of device: " + deviceId);
@ -3365,10 +3384,21 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
try {
DeviceManagementDAOFactory.beginTransaction();
int updatedRows = enrollmentDAO.updateEnrollment(enrolmentInfo, tenantId);
String type = deviceIdentifier.getType();
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
.getInstance().getDeviceStatusManagementService();
DeviceManagementDAOFactory.commitTransaction();
if (updatedRows > 0) {
isUpdatedEnrollment = true;
}
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
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) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while updating the enrollment information device for" +
@ -4397,13 +4427,25 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
device.getEnrolmentInfo().setStatus(EnrolmentInfo.Status.REMOVED);
// different try blocks are used to isolate transactions
try {
enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
String type = device.getType();
DeviceStatusManagementService deviceStatusManagementService = DeviceManagementDataHolder
.getInstance().getDeviceStatusManagementService();
int updatedRows = enrollmentDAO.updateEnrollment(device.getEnrolmentInfo(), tenantId);
boolean isEnableDeviceStatusCheck = deviceStatusManagementService.getDeviceStatusCheck(tenantId);
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) {
DeviceManagementDAOFactory.rollbackTransaction();
String msg = "Error occurred while dis-enrolling device: " +
device.getName();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
} catch (MetadataManagementException e) {
throw new RuntimeException(e);
}
try {
deviceDAO.updateDevice(device, tenantId);

@ -17,6 +17,7 @@
*/
package io.entgra.device.mgt.core.device.mgt.core.task;
import io.entgra.device.mgt.core.device.mgt.common.exceptions.MetadataManagementException;
import io.entgra.device.mgt.core.server.bootup.heartbeat.beacon.service.HeartBeatManagementService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -68,7 +69,7 @@ public class DeviceTaskManagerTest extends BaseDeviceManagementTest {
private OperationManager operationManager;
@BeforeClass
public void init() throws DeviceManagementException, RegistryException {
public void init() throws DeviceManagementException, RegistryException, MetadataManagementException {
log.info("Initializing Device Task Manager Test Suite");
this.deviceIds = new ArrayList<>();
for (int i = 0; i < 5; i++) {

@ -168,24 +168,49 @@
<Type>android</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
<DeviceStatusItem>
<Type>ios</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
<DeviceStatusItem>
<Type>windows</Type>
<AllowedStatus>
<Status>ACTIVE</Status>
<Status>CREATED</Status>
<Status>INACTIVE</Status>
<Status>UNREACHABLE</Status>
<Status>UNCLAIMED</Status>
<Status>SUSPENDED</Status>
<Status>BLOCKED</Status>
<Status>REMOVED</Status>
<Status>SUSPENDED</Status>
<Status>DISENROLLMENT_REQUESTED</Status>
</AllowedStatus>
</DeviceStatusItem>
</DeviceStatusConfigurations>
CREATED, ACTIVE, INACTIVE, UNREACHABLE, UNCLAIMED, SUSPENDED, BLOCKED, REMOVED, DISENROLLMENT_REQUESTED,
<AppRegistration>
<Tags>
<Tag>analytics_management</Tag>

Loading…
Cancel
Save