Fix device enrolment and syncing with MSSQL db #113

Merged
tcdlpds merged 5 commits from prathabanKavin/device-mgt-core:mssqlenrolmentfix2 into master 1 year ago

Purpose

Details

  • Fix dbscripts to support events and events mapping
  • Fix config operation implementation in MSSQL
## Purpose * Fixes https://roadmap.entgra.net/issues/9859 * Fixes https://roadmap.entgra.net/issues/9892 ## Details * Fix dbscripts to support events and events mapping * Fix config operation implementation in MSSQL
prathabanKavin added 2 commits 1 year ago
tcdlpds requested changes 1 year ago
Connection connection = OperationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_OPERATION(TYPE, CREATED_TIMESTAMP, RECEIVED_TIMESTAMP, OPERATION_CODE, " +
"INITIATED_BY, OPERATION_DETAILS) VALUES (?, ?, ?, ?, ?, ?)";
stmt = connection.prepareStatement(sql, new String[]{"id"});
Owner

Use try with resources.

Use try with resources.
Owner

Use try with resources.

Use try with resources.
prathabanKavin marked this conversation as resolved
throw new OperationManagementDAOException("Error occurred while adding command operation", e);
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
OperationManagementDAOUtil.cleanupResources(stmt, rs);
Owner

When you do modifications with try with resources, you can remove this finally block.

When you do modifications with try with resources, you can remove this finally block.
prathabanKavin marked this conversation as resolved
Connection conn = OperationManagementDAOFactory.getConnection();
String sql = "SELECT OPERATION_ID, ENABLED, OPERATION_CONFIG FROM DM_CONFIG_OPERATION WHERE OPERATION_ID = ?";
String sql = "SELECT ID, ENABLED, OPERATION_DETAILS FROM DM_OPERATION WHERE ID = ? AND TYPE='CONFIG'";
stmt = conn.prepareStatement(sql);
Owner

Use try with resources

Use try with resources
prathabanKavin marked this conversation as resolved
"AND STATUS = ?) dm ON dm.OPERATION_ID = co.OPERATION_ID";
"AND STATUS = ?) dm ON dm.OPERATION_ID = co.ID WHERE co.TYPE = 'CONFIG'";
stmt = conn.prepareStatement(sql);
Owner

Use try with resources.

Use try with resources.
prathabanKavin marked this conversation as resolved
operations.add(configOperation);
}
} catch (IOException e) {
throw new OperationManagementDAOException("IO Error occurred while de serialize the configuration " +
Owner

Log the error

Log the error
prathabanKavin marked this conversation as resolved
prathabanKavin added 1 commit 1 year ago
tcdlpds requested changes 1 year ago
} finally {
OperationManagementDAOUtil.cleanupResources(stmt);
String msg = "Error occurred while adding command operation" + e;
log.error(msg);
Owner

log error as well. E.g - log.error(msg, e)

log error as well. E.g - log.error(msg, e)
prathabanKavin marked this conversation as resolved
OperationManagementDAOUtil.cleanupResources(stmt);
String msg = "Error occurred while adding command operation" + e;
log.error(msg);
throw new OperationManagementDAOException(msg);
Owner

Throw error, e.g - throw new OperationManagementDAOException(msg, e);

Throw error, e.g - throw new OperationManagementDAOException(msg, e);
prathabanKavin marked this conversation as resolved
} catch (IOException e) {
String msg = "IO Error occurred while de serialize the policy operation " +
"object" + e;
log.error(msg);
Owner

Log and throw error as well.

Log and throw error as well.
prathabanKavin marked this conversation as resolved
} catch (ClassNotFoundException e) {
String msg = "Class not found error occurred while de serialize the policy " +
"operation object" + e;
log.error(msg);
Owner

Log and throw error as well.

Log and throw error as well.
prathabanKavin marked this conversation as resolved
} catch (IOException e) {
String msg = "IO Error occurred while de serialize the configuration " +
"operation object" + e;
log.error(msg);
Owner

Log and throw error as well

Log and throw error as well
prathabanKavin marked this conversation as resolved
} catch (ClassNotFoundException e) {
String msg = "Class not found error occurred while de serialize the " +
"configuration operation object" + e;
log.error(msg);
Owner

Log and throw error as well

Log and throw error as well
prathabanKavin marked this conversation as resolved
prathabanKavin added 1 commit 1 year ago
prathabanKavin requested review from tcdlpds 1 year ago
prathabanKavin added 1 commit 1 year ago
tcdlpds merged commit bd35583737 into master 1 year ago

Reviewers

tcdlpds was requested for review 1 year ago
The pull request has been merged as bd35583737.
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#113
Loading…
There is no content yet.