From 6a2b016852eaefec3dbddf5a9f0afc5ff8a153bf Mon Sep 17 00:00:00 2001 From: isuri Date: Thu, 7 Dec 2023 09:18:27 +0530 Subject: [PATCH] deviceOrg: success response add for api --- .../api/DeviceOrganizationMgtServiceImpl.java | 21 ++++++++++++++----- .../api/beans/SuccessResponse.java | 14 +++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/beans/SuccessResponse.java diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/DeviceOrganizationMgtServiceImpl.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/DeviceOrganizationMgtServiceImpl.java index 0732bb0290..f4a947f883 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/DeviceOrganizationMgtServiceImpl.java +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/DeviceOrganizationMgtServiceImpl.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api; import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.beans.SuccessResponse; import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.util.DeviceOrgAPIUtils; import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.util.RequestValidationUtil; import io.entgra.device.mgt.core.device.mgt.extensions.device.organization.dto.DeviceNodeResult; @@ -68,7 +69,9 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe } DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService(); boolean resp = deviceOrganizationService.addDeviceOrganization(deviceOrganizationRequest); - return Response.status(Response.Status.OK).entity(resp).build(); + SuccessResponse response = new SuccessResponse(); + response.setSuccess(resp); + return Response.status(Response.Status.OK).entity(response).build(); } catch (DeviceOrganizationMgtPluginException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } @@ -167,7 +170,9 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe } else { exists = deviceOrganizationService.isDeviceOrganizationExist(deviceId, Integer.valueOf(parentDeviceId)); } - return Response.status(Response.Status.OK).entity(exists).build(); + SuccessResponse response = new SuccessResponse(); + response.setSuccess(exists); + return Response.status(Response.Status.OK).entity(response).build(); } catch (DeviceOrganizationMgtPluginException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } @@ -200,7 +205,9 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe try { DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService(); boolean resp = deviceOrganizationService.updateDeviceOrganization(deviceOrganization); - return Response.status(Response.Status.OK).entity(resp).build(); + SuccessResponse response = new SuccessResponse(); + response.setSuccess(resp); + return Response.status(Response.Status.OK).entity(response).build(); } catch (DeviceOrganizationMgtPluginException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } @@ -213,7 +220,9 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe try { DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService(); boolean resp = deviceOrganizationService.deleteDeviceOrganizationByID(organizationId); - return Response.status(Response.Status.OK).entity(resp).build(); + SuccessResponse response = new SuccessResponse(); + response.setSuccess(resp); + return Response.status(Response.Status.OK).entity(response).build(); } catch (DeviceOrganizationMgtPluginException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } @@ -226,7 +235,9 @@ public class DeviceOrganizationMgtServiceImpl implements DeviceOrganizationMgtSe try { DeviceOrganizationService deviceOrganizationService = DeviceOrgAPIUtils.getDeviceOrganizationService(); boolean resp = deviceOrganizationService.deleteDeviceAssociations(deviceId); - return Response.status(Response.Status.OK).entity(resp).build(); + SuccessResponse response = new SuccessResponse(); + response.setSuccess(resp); + return Response.status(Response.Status.OK).entity(response).build(); } catch (DeviceOrganizationMgtPluginException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/beans/SuccessResponse.java b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/beans/SuccessResponse.java new file mode 100644 index 0000000000..f52615806f --- /dev/null +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/organization/api/beans/SuccessResponse.java @@ -0,0 +1,14 @@ +package io.entgra.device.mgt.core.device.mgt.extensions.device.organization.api.beans; + +public class SuccessResponse { + + private boolean isSuccess; + + public boolean isSuccess() { + return isSuccess; + } + + public void setSuccess(boolean success) { + isSuccess = success; + } +}