mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Add Health Check API
This commit is contained in:
parent
50a7721926
commit
cb7323fc02
@ -674,4 +674,6 @@ public interface DeviceDAO {
|
|||||||
int tenantId,
|
int tenantId,
|
||||||
String packageName,
|
String packageName,
|
||||||
String version) throws DeviceManagementDAOException;
|
String version) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
|
int getFunctioningDevicesInSystem() throws DeviceManagementDAOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2617,4 +2617,25 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
|
|
||||||
return joiner.toString();
|
return joiner.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFunctioningDevicesInSystem() throws DeviceManagementDAOException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
int deviceCount = 0;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String sql = "SELECT COUNT(e.DEVICE_ID) AS DEVICE_COUNT FROM DM_ENROLMENT e WHERE STATUS != 'REMOVED'";
|
||||||
|
stmt = conn.prepareStatement(sql);
|
||||||
|
ResultSet rs = stmt.executeQuery();
|
||||||
|
|
||||||
|
if (rs.next()) {
|
||||||
|
deviceCount = rs.getInt("DEVICE_COUNT");
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new DeviceManagementDAOException("Error occurred while fetching count of functioning devices", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
return deviceCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -882,4 +882,6 @@ public interface DeviceManagementProviderService {
|
|||||||
* @throws ApplicationManagementException if any service level or DAO level error occurs.
|
* @throws ApplicationManagementException if any service level or DAO level error occurs.
|
||||||
*/
|
*/
|
||||||
List<String> getAppVersions(String packageName) throws ApplicationManagementException;
|
List<String> getAppVersions(String packageName) throws ApplicationManagementException;
|
||||||
|
|
||||||
|
int getFunctioningDevicesInSystem() throws DeviceManagementException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4120,4 +4120,28 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
deviceConfiguration.setDeviceOwner(deviceOwner);
|
deviceConfiguration.setDeviceOwner(deviceOwner);
|
||||||
return deviceConfiguration;
|
return deviceConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFunctioningDevicesInSystem() throws DeviceManagementException {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Get functioning devices count");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
return deviceDAO.getFunctioningDevicesInSystem();
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
String msg = "Error occurred while retrieving the device count";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while opening a connection to the data source";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = "Error occurred in getDeviceCount";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user