deviceOrganization
#238
Closed
isuri
wants to merge 65 commits from isuri/device-mgt-core:deviceOrganization
into master
pull from: isuri/device-mgt-core:deviceOrganization
merge into: community:master
community:master
community:dep-upgrade
community:build-improvement
community:device-tagging
community:master-4.2.0-backup
community:apim420
community:fix-access-authorization
community:APPM_Imp
community:appm_improvement
community:scope_role_map
community:revert
community:vpp-v2
community:api-performance
community:improvement/fix-task-deletion
community:try_it
community:license
community:temp
community:feature/traccar-sync
community:4.x.x
community:release-temp
community:kernel-4.6.x
community:kernel-4.4.x
community:revert-52ce2907
community:revert-70ac1926
community:corrective-policy
community:vpp
community:reporting
community:feature/appm-store/pbac
community:cherry-pick-b7435168
community:3.x.x
community:revert-70aa11f8
Reviewers
Request review
No Label
pending upstream
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: community/device-mgt-core#238
Reference in new issue
There is no content yet.
Delete Branch 'isuri/device-mgt-core:deviceOrganization'
Deleting a branch is permanent. It CANNOT be undone. Continue?
No
Yes
* @return True if a record with the specified deviceId and parentDeviceId exists, false otherwise.
* @throws DeviceOrganizationMgtDAOException If an error occurs while checking the existence of the record.
*/
boolean organizationExists(int deviceId, int parentDeviceId) throws DeviceOrganizationMgtDAOException;
Following the same practice for naming convention. ex- isDeviceOrganizationExist()
Following the same practice for naming convention. ex- isDeviceOrganizationExist()
* @return true if a record with the given device ID exists, false otherwise.
* @throws DeviceOrganizationMgtDAOException If an error occurs while querying the database.
*/
boolean doesDeviceIdExist(int deviceId) throws DeviceOrganizationMgtDAOException;
Standard is use 'is' or 'has' as a prefix. Ex - isDeviceIdExist
private int organizationId;
private int deviceId;
private Integer parentDeviceId;
Any reason to use Wrapper type?
@Override
public void addDeviceOrganizationList(List<DeviceOrganization> deviceOrganizationList)
throws DeviceOrganizationMgtPluginException {
for (DeviceOrganization deviceOrganization : deviceOrganizationList) {
chek null
* {@inheritDoc}
*/
@Override
public boolean organizationExists(int deviceID, int parentDeviceID) throws DeviceOrganizationMgtPluginException {
validate deviceID and parentDeviceID
* {@inheritDoc}
*/
@Override
public DeviceOrganization getDeviceOrganizationByUniqueKey(int deviceID, int parentDeviceID)
validate deviceID and parentDeviceID
b9b2c97841
WIP: deviceOrganizationto deviceOrganization 1 year ago@Override
public Response addDeviceOrganization(DeviceOrganization deviceOrganizationRequest) {
if (deviceOrganizationRequest == null) {
String errorMessage = "The payload of the device organization is incorrect.";
Log the error message
done
!(deviceOrganizationRequest.getParentDeviceId() == null ||
deviceOrganizationRequest.getParentDeviceId() >= 0)
) {
String errorMessage = "The payload of the device organization is incorrect.";
Log the error message
done
)
public interface DeviceOrganizationMgtService {
String SCOPE = "scope";
Better to move this to a constant file
a45f4712ba
public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtService {
private static final Log log = LogFactory.getLog(DeviceOrganizationMgtServiceImpl.class);
Gson gson = new Gson();
Make the variable static and final
a45f4712ba
boolean resp = deviceOrganizationService.addDeviceOrganization(deviceOrganizationRequest);
SuccessResponse response = new SuccessResponse();
response.setSuccess(resp);
return Response.status(Response.Status.OK).entity(response).build();
Should be returning response code 201(CREATED) since this is a 'create' request.
public static final String DATE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
private Gson gson;
private static final String UTF_8 = "UTF-8";
Better to use the StandardCharsets.UTF_8 constant from java.nio.charset package which can be find in the JDK toolkit instead of using in class variable
a45f4712ba
InputStream entityStream)
throws IOException, WebApplicationException {
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
Better to use the StandardCharsets.UTF_8
if (validator == null) {
log.warn("Bean Validation provider could not be found, no validation will be performed");
} else {
log.debug("Validation In-Interceptor initialized successfully");
Add isDebugEnabled check for the debug logs writing
https://www.igorkromin.net/index.php/2015/05/12/are-guard-statements-like-isdebugenabled-necessary-when-using-log4j/
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
DeviceNode child = getDeviceFromResultSet(rs);
Declare the variable outside the loop to optimize memory allocation
a45f4712ba
parentAdded = true; // Set the flag to true after adding the parent device.
}
DeviceOrganization organization = loadDeviceOrganization(rs);
Declare the variable outside the loop to optimize memory allocation
stmt.setInt(1, node.getDeviceId());
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
DeviceNode parent = getDeviceFromResultSet(rs);
Declare the variable outside the loop to optimize memory allocation
childAdded = true;
}
DeviceOrganization organization = loadDeviceOrganization(rs);
Declare the variable outside the loop to optimize memory allocation
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
DeviceOrganization deviceOrganization = loadDeviceOrganization(rs);
Declare the variable outside the loop to optimize memory allocation
stmt.setInt(2, request.getOffSet());
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
DeviceOrganization deviceOrganization = loadDeviceOrganizationWithDeviceDetails(rs);
Declare the variable outside the loop to optimize memory allocation
https://roadmap.entgra.net/issues/10491
Reviewers