mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'application-mgt-new' of https://gitlab.com/nipunnadeen/carbon-device-mgt into appm-new
This commit is contained in:
commit
4ac94746fa
@ -81,7 +81,6 @@ public class ReportManagementServiceImpl implements ReportManagementService {
|
|||||||
String msg = "No devices have enrolled between " + fromDate + " to " + toDate +
|
String msg = "No devices have enrolled between " + fromDate + " to " + toDate +
|
||||||
" or doesn't match with" +
|
" or doesn't match with" +
|
||||||
" given parameters";
|
" given parameters";
|
||||||
log.error(msg);
|
|
||||||
return Response.status(Response.Status.OK).entity(msg).build();
|
return Response.status(Response.Status.OK).entity(msg).build();
|
||||||
} else {
|
} else {
|
||||||
devices.setList((List<Device>) result.getData());
|
devices.setList((List<Device>) result.getData());
|
||||||
|
|||||||
@ -423,8 +423,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " +
|
String msg = "Error occurred while fetching the list of devices that matches to status " +
|
||||||
"'" + request.getStatus() + "'", e);
|
"'" + request.getStatus() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
@ -552,8 +554,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
|
String msg = "Error occurred while fetching the list of devices corresponding" +
|
||||||
"to the mentioned filtering criteria", e);
|
"to the mentioned filtering criteria";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -429,8 +429,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " +
|
String msg = "Error occurred while fetching the list of devices that matches to status " +
|
||||||
"'" + request.getStatus() + "'", e);
|
"'" + request.getStatus() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
@ -557,11 +559,10 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while retrieving information of all " +
|
String msg = "Error occurred while fetching the list of devices corresponding" +
|
||||||
"registered devices";
|
"to the mentioned filtering criteria";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
"to the mentioned filtering criteria", e);
|
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -406,8 +406,10 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " +
|
String msg = "Error occurred while fetching the list of devices that matches to status " +
|
||||||
"'" + request.getStatus() + "'", e);
|
"'" + request.getStatus() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
@ -535,13 +537,76 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
|
String msg = "Error occurred while fetching the list of devices corresponding" +
|
||||||
"to the mentioned filtering criteria", e);
|
"to the mentioned filtering criteria";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||||
|
List<Integer> deviceIds, int tenantId, String status)
|
||||||
|
throws DeviceManagementDAOException {
|
||||||
|
Connection conn;
|
||||||
|
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
int index = 1;
|
||||||
|
|
||||||
|
boolean isStatusProvided = false;
|
||||||
|
StringJoiner joiner = new StringJoiner(",",
|
||||||
|
"SELECT " +
|
||||||
|
"f.ID AS DEVICE_ID, f.NAME AS DEVICE_NAME, f.DESCRIPTION AS DESCRIPTION, " +
|
||||||
|
"f.DEVICE_TYPE_ID, f.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " +
|
||||||
|
"e.ID AS ENROLMENT_ID, e.OWNER, e.OWNERSHIP, e.DATE_OF_ENROLMENT, " +
|
||||||
|
"e.DATE_OF_LAST_UPDATE, e.STATUS, t.NAME AS DEVICE_TYPE " +
|
||||||
|
"FROM DM_ENROLMENT AS e,DM_DEVICE AS f, DM_DEVICE_TYPE t "+
|
||||||
|
"WHERE " +
|
||||||
|
"e.DEVICE_ID=f.ID AND " +
|
||||||
|
"e.DEVICE_ID IN (", ") AND e.TENANT_ID=?");
|
||||||
|
|
||||||
|
deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
|
||||||
|
String query = joiner.toString();
|
||||||
|
|
||||||
|
if (status != null && !status.isEmpty()) {
|
||||||
|
query = query + " AND e.STATUS=?";
|
||||||
|
isStatusProvided = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
query = query + " LIMIT ? OFFSET ?";
|
||||||
|
|
||||||
|
try (PreparedStatement ps = conn.prepareStatement(query)) {
|
||||||
|
|
||||||
|
for (Integer deviceId : deviceIds) {
|
||||||
|
ps.setObject(index++, deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ps.setInt(index++, tenantId);
|
||||||
|
if (isStatusProvided) {
|
||||||
|
ps.setString(index++, status);
|
||||||
|
}
|
||||||
|
ps.setInt(index++, offsetValue);
|
||||||
|
ps.setInt(index, limitValue);
|
||||||
|
|
||||||
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
devices.add(DeviceManagementDAOUtil.loadDevice(rs));
|
||||||
|
}
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while retrieving information of all registered devices " +
|
||||||
|
"according to device ids and the limit area.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
public List<Device> getSubscribedDevices(int offsetValue, int limitValue,
|
||||||
|
|||||||
@ -425,8 +425,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices that matches to status " +
|
String msg = "Error occurred while fetching the list of devices that matches to status " +
|
||||||
"'" + request.getStatus() + "'", e);
|
"'" + request.getStatus() + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
@ -490,8 +492,10 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while fetching the list of devices corresponding" +
|
String msg = "Error occurred while fetching the list of devices corresponding" +
|
||||||
"to the mentioned filtering criteria", e);
|
"to the mentioned filtering criteria";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user