Add application installation monitoring feature #436

Merged
tcdlpds merged 12 commits from prathabanKavin/device-mgt-core:appm_syncbr into master 5 months ago
## Purpose * Fixes https://roadmap.entgra.net/issues/11098
prathabanKavin added 8 commits 5 months ago
prathabanKavin added 1 commit 5 months ago
b70986464d
Add operation log of a subscription
tcdlpds requested changes 5 months ago
package io.entgra.device.mgt.core.application.mgt.common.dto;
Owner

Add license

Add license
prathabanKavin marked this conversation as resolved
package io.entgra.device.mgt.core.application.mgt.common.dto;
Owner

Add license

Add license
prathabanKavin marked this conversation as resolved
package io.entgra.device.mgt.core.device.mgt.core.dto;
Owner

Add license

Add license
prathabanKavin marked this conversation as resolved
/*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
Owner

Revert this change

Revert this change
prathabanKavin marked this conversation as resolved
return operation;
}
public static JSONObject convertBlobToJsonObject(Blob blob) throws SQLException {
Owner

Add Java Doc comment.

IMO it is better if we throw different exception, since these exceptions are not SQL exceptions.

Add Java Doc comment. IMO it is better if we throw different exception, since these exceptions are not SQL exceptions.
prathabanKavin marked this conversation as resolved
jsonString = new JSONObject(obj).toString();
}
} catch (ClassNotFoundException e) {
throw new SQLException("Failed to deserialize object from BLOB", e);
Owner

Log and throw the exception

Log and throw the exception
prathabanKavin marked this conversation as resolved
jsonString = new String(blobBytes, "UTF-8");
}
} catch (IOException e) {
throw new SQLException("Failed to convert BLOB to JSON string", e);
Owner

Log and throw the exception

Log and throw the exception
prathabanKavin marked this conversation as resolved
// Convert JSON string to JSONObject
if (jsonString == null || jsonString.isEmpty()) {
throw new SQLException("Converted JSON string is null or empty");
Owner

Log and throw the exception

Log and throw the exception
prathabanKavin marked this conversation as resolved
prathabanKavin added 1 commit 5 months ago
tcdlpds requested changes 5 months ago
}
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while retrieving owners and device IDs for owner: " + owner, e);
Owner

Log and throw the error

Log and throw the error
prathabanKavin marked this conversation as resolved
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?";
try (Connection conn = this.getConnection();
Owner

Remove 'Connection conn = this.getConnection()' from try-with-resources block.

Remove 'Connection conn = this.getConnection()' from try-with-resources block.
prathabanKavin marked this conversation as resolved
}
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while retrieving owner and status for device ID: "
Owner

Log and throw the error

Log and throw the error
prathabanKavin marked this conversation as resolved
"FROM DM_ENROLMENT " +
"WHERE TENANT_ID = ?";
try (Connection conn = this.getConnection();
Owner

Remove 'Connection conn = this.getConnection()' from try-with-resources block.

Remove 'Connection conn = this.getConnection()' from try-with-resources block.
prathabanKavin marked this conversation as resolved
}
}
} catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while retrieving devices for tenant ID: "
Owner

Log and throw the error

Log and throw the error
prathabanKavin marked this conversation as resolved
" AND g.TENANT_ID = ? " +
"LIMIT ? OFFSET ?";
try (Connection conn = GroupManagementDAOFactory.getConnection();
Owner

Remove 'Connection conn = GroupManagementDAOFactory.getConnection()' from try-with-resources block.

Remove 'Connection conn = GroupManagementDAOFactory.getConnection()' from try-with-resources block.
prathabanKavin marked this conversation as resolved
}
}
} catch (SQLException e) {
throw new GroupManagementDAOException("Error occurred while retrieving group details and device IDs for group: "
Owner

log and throw the exception

log and throw the exception
prathabanKavin marked this conversation as resolved
}
@Override
public OwnerWithDeviceDTO getOwnersWithDeviceIds(String owner) throws DeviceManagementDAOException {
Owner

In these methods, we have get the value from DB and return it.

  1. If we do so, we do not need to assign those returning values into object.

  2. IMO we can improve these methods by evaluating the return value. In that kind of case, it is fine to assign returning value to object and do kind of a validation and return.

    e.g:- If DAO layer returns null, then we can throw exception if the method does not suppose to get null for the query.

Please check all the methods in this file and do the modifications according to the use case.

In these methods, we have get the value from DB and return it. 1. If we do so, we do not need to assign those returning values into object. 2. IMO we can improve these methods by evaluating the return value. In that kind of case, it is fine to assign returning value to object and do kind of a validation and return. e.g:- If DAO layer returns null, then we can throw exception if the method does not suppose to get null for the query. Please check all the methods in this file and do the modifications according to the use case.
prathabanKavin marked this conversation as resolved
prathabanKavin added 1 commit 5 months ago
tcdlpds requested changes 5 months ago
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?";
try (Connection conn = this.getConnection();
Owner

Remove 'Connection conn = this.getConnection();' from try-with-resources

e.g:- Correct way of doing this. Please note this is a sample

        Connection conn = this.getDBConnection();
        String sql = "SELECT COUNT(*) AS count " +
                "FROM AP_DEVICE_SUBSCRIPTION " +
                "WHERE AP_APP_RELEASE_ID = ? " +
                "AND TENANT_ID = ? " +
                "AND UNSUBSCRIBED = TRUE";

        try (PreparedStatement ps = conn.prepareStatement(sql)) {
        
        .........
Remove 'Connection conn = this.getConnection();' from try-with-resources e.g:- Correct way of doing this. Please note this is a sample Connection conn = this.getDBConnection(); String sql = "SELECT COUNT(*) AS count " + "FROM AP_DEVICE_SUBSCRIPTION " + "WHERE AP_APP_RELEASE_ID = ? " + "AND TENANT_ID = ? " + "AND UNSUBSCRIBED = TRUE"; try (PreparedStatement ps = conn.prepareStatement(sql)) { .........
prathabanKavin marked this conversation as resolved
prathabanKavin added 1 commit 5 months ago
tcdlpds approved these changes 5 months ago
tcdlpds changed title from Sync application installation monitoring feature to Add application installation monitoring feature 5 months ago
tcdlpds merged commit 6099c68d88 into master 5 months ago

Reviewers

tcdlpds approved these changes 5 months ago
The pull request has been merged as 6099c68d88.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: community/device-mgt-core#436
Loading…
There is no content yet.