Resolved comments

classify-apps
Ruwin Dissanayake 2 weeks ago
parent ab87a8199a
commit a3fdff7437

@ -240,8 +240,6 @@ public class ApplicationDAOImpl implements ApplicationDAO {
} }
private Application loadApplicationDetails(ResultSet rs) throws DeviceManagementDAOException { private Application loadApplicationDetails(ResultSet rs) throws DeviceManagementDAOException {
ByteArrayInputStream bais;
ObjectInputStream ois;
Properties properties; Properties properties;
Application application = new Application(); Application application = new Application();
@ -252,12 +250,14 @@ public class ApplicationDAOImpl implements ApplicationDAO {
if (rs.getBytes("APP_PROPERTIES") != null) { if (rs.getBytes("APP_PROPERTIES") != null) {
byte[] appProperties = rs.getBytes("APP_PROPERTIES"); byte[] appProperties = rs.getBytes("APP_PROPERTIES");
bais = new ByteArrayInputStream(appProperties);
ois = new ObjectInputStream(bais); try (ByteArrayInputStream bais = new ByteArrayInputStream(appProperties);
ObjectInputStream ois = new ObjectInputStream(bais)) {
properties = (Properties) ois.readObject(); properties = (Properties) ois.readObject();
application.setAppProperties(properties); application.setAppProperties(properties);
} }
}
application.setCategory(rs.getString("CATEGORY")); application.setCategory(rs.getString("CATEGORY"));
application.setImageUrl(rs.getString("IMAGE_URL")); application.setImageUrl(rs.getString("IMAGE_URL"));
application.setLocationUrl(rs.getString("LOCATION_URL")); application.setLocationUrl(rs.getString("LOCATION_URL"));
@ -269,10 +269,16 @@ public class ApplicationDAOImpl implements ApplicationDAO {
application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER")); application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER"));
} catch (IOException e) { } catch (IOException e) {
String msg = "IO error occurred while retrieving application properties";
log.error(msg, e);
throw new DeviceManagementDAOException("IO error occurred fetch at app properties", e); throw new DeviceManagementDAOException("IO error occurred fetch at app properties", e);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
String msg = "Class not found error occurred while retrieving application properties";
log.error(msg, e);
throw new DeviceManagementDAOException("Class not found error occurred fetch at app properties", e); throw new DeviceManagementDAOException("Class not found error occurred fetch at app properties", e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "SQL error occurred while retrieving application properties";
log.error(msg, e);
throw new DeviceManagementDAOException("SQL error occurred fetch at application", e); throw new DeviceManagementDAOException("SQL error occurred fetch at application", e);
} }
return application; return application;
@ -620,16 +626,14 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, deviceId); int paramIndex = 1;
stmt.setInt(2, enrolmentId); stmt.setInt(paramIndex++, deviceId);
stmt.setInt(3, tenantId); stmt.setInt(paramIndex++, enrolmentId);
int paramIndex = 4; stmt.setInt(paramIndex++, tenantId);
if (isSystemApp != 0) { if (isSystemApp != 0) {
stmt.setInt(paramIndex, isSystemApp); stmt.setInt(paramIndex++, isSystemApp);
paramIndex++;
} }
stmt.setInt(paramIndex, limit); stmt.setInt(paramIndex++, limit);
paramIndex++;
stmt.setInt(paramIndex, offset); stmt.setInt(paramIndex, offset);
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) { while (rs.next()) {
@ -648,7 +652,6 @@ public class ApplicationDAOImpl implements ApplicationDAO {
return applicationList; return applicationList;
} }
public List<Application> getInstalledApplicationListOnDevice(int deviceId, int enrolmentId, int tenantId) public List<Application> getInstalledApplicationListOnDevice(int deviceId, int enrolmentId, int tenantId)
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
Connection conn; Connection conn;

Loading…
Cancel
Save