deviceOrganization #238

Closed
isuri wants to merge 65 commits from isuri/device-mgt-core:deviceOrganization into master
isuri commented 1 year ago
There is no content yet.
isuri added 9 commits 1 year ago
isuri requested review from charithag 1 year ago
isuri added 1 commit 1 year ago
thameera requested changes 1 year ago
* @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;
Collaborator

Following the same practice for naming convention. ex- isDeviceOrganizationExist()

Following the same practice for naming convention. ex- isDeviceOrganizationExist()
Collaborator

Following the same practice for naming convention. ex- isDeviceOrganizationExist()

Following the same practice for naming convention. ex- isDeviceOrganizationExist()
isuri marked this conversation as resolved
* @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;
Collaborator

Standard is use 'is' or 'has' as a prefix. Ex - isDeviceIdExist

Standard is use 'is' or 'has' as a prefix. Ex - isDeviceIdExist
isuri marked this conversation as resolved
private int organizationId;
private int deviceId;
private Integer parentDeviceId;
Collaborator

Any reason to use Wrapper type?

Any reason to use Wrapper type?
isuri marked this conversation as resolved
@Override
public void addDeviceOrganizationList(List<DeviceOrganization> deviceOrganizationList)
throws DeviceOrganizationMgtPluginException {
for (DeviceOrganization deviceOrganization : deviceOrganizationList) {
Collaborator

chek null

chek null
isuri marked this conversation as resolved
* {@inheritDoc}
*/
@Override
public boolean organizationExists(int deviceID, int parentDeviceID) throws DeviceOrganizationMgtPluginException {
Collaborator

validate deviceID and parentDeviceID

validate deviceID and parentDeviceID
isuri marked this conversation as resolved
* {@inheritDoc}
*/
@Override
public DeviceOrganization getDeviceOrganizationByUniqueKey(int deviceID, int parentDeviceID)
Collaborator

validate deviceID and parentDeviceID

validate deviceID and parentDeviceID
isuri marked this conversation as resolved
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 4 commits 1 year ago
isuri added 1 commit 1 year ago
isuri added 2 commits 1 year ago
isuri added 21 commits 1 year ago
9767f7e90f
Add validation for user deletion (#244)
isuri added 46 commits 1 year ago
548aba7da9
revert b9b2c97841
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 1 commit 1 year ago
isuri added 2 commits 1 year ago
isuri requested review from tcdlpds 1 year ago
isuri changed title from WIP: deviceOrganization to deviceOrganization 1 year ago
tcdlpds requested changes 1 year ago
@Override
public Response addDeviceOrganization(DeviceOrganization deviceOrganizationRequest) {
if (deviceOrganizationRequest == null) {
String errorMessage = "The payload of the device organization is incorrect.";
Owner

Log the error message

Log the error message
Poster

done

done
isuri marked this conversation as resolved
!(deviceOrganizationRequest.getParentDeviceId() == null ||
deviceOrganizationRequest.getParentDeviceId() >= 0)
) {
String errorMessage = "The payload of the device organization is incorrect.";
Owner

Log the error message

Log the error message
Poster

done

done
isuri marked this conversation as resolved
isuri added 33 commits 12 months ago
isuri added 1 commit 12 months ago
isuri added 4 commits 12 months ago
isuri added 2 commits 12 months ago
isuri requested review from tcdlpds 12 months ago
isuri added 1 commit 12 months ago
isuri added 1 commit 12 months ago
pahansith requested changes 11 months ago
)
public interface DeviceOrganizationMgtService {
String SCOPE = "scope";

Better to move this to a constant file

Better to move this to a constant file
Poster
https://repository.entgra.net/community/device-mgt-core/commit/a45f4712ba585b85aafc90de778098f69d736f61
isuri marked this conversation as resolved
public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtService {
private static final Log log = LogFactory.getLog(DeviceOrganizationMgtServiceImpl.class);
Gson gson = new Gson();

Make the variable static and final

Make the variable static and final
Poster
https://repository.entgra.net/community/device-mgt-core/commit/a45f4712ba585b85aafc90de778098f69d736f61
isuri marked this conversation as resolved
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.

Should be returning response code 201(CREATED) since this is a 'create' request.
isuri marked this conversation as resolved
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

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
Poster
https://repository.entgra.net/community/device-mgt-core/commit/a45f4712ba585b85aafc90de778098f69d736f61
isuri marked this conversation as resolved
InputStream entityStream)
throws IOException, WebApplicationException {
InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");

Better to use the StandardCharsets.UTF_8

Better to use the StandardCharsets.UTF_8
isuri marked this conversation as resolved
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

Add isDebugEnabled check for the debug logs writing
Poster
https://www.igorkromin.net/index.php/2015/05/12/are-guard-statements-like-isdebugenabled-necessary-when-using-log4j/
isuri marked this conversation as resolved
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
DeviceNode child = getDeviceFromResultSet(rs);

Declare the variable outside the loop to optimize memory allocation

Declare the variable outside the loop to optimize memory allocation
Poster
https://repository.entgra.net/community/device-mgt-core/commit/a45f4712ba585b85aafc90de778098f69d736f61
isuri marked this conversation as resolved
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

Declare the variable outside the loop to optimize memory allocation
isuri marked this conversation as resolved
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

Declare the variable outside the loop to optimize memory allocation
isuri marked this conversation as resolved
childAdded = true;
}
DeviceOrganization organization = loadDeviceOrganization(rs);

Declare the variable outside the loop to optimize memory allocation

Declare the variable outside the loop to optimize memory allocation
isuri marked this conversation as resolved
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

Declare the variable outside the loop to optimize memory allocation
isuri marked this conversation as resolved
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

Declare the variable outside the loop to optimize memory allocation
isuri marked this conversation as resolved
isuri added 1 commit 11 months ago
isuri requested review from pahansith 11 months ago
isuri added 2 commits 11 months ago
isuri added 1 commit 10 months ago
Poster
https://roadmap.entgra.net/issues/10491
isuri added 2 commits 10 months ago
charithag approved these changes 10 months ago
isuri closed this pull request 10 months ago

Reviewers

thameera requested changes 1 year ago
tcdlpds was requested for review 12 months ago
pahansith was requested for review 11 months ago
charithag approved these changes 10 months ago
Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

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