From 425c0e74983f8988cb8a43b79a22967c3f897ce1 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Sat, 28 May 2016 04:52:00 +0530 Subject: [PATCH] Improving swagger annotations of CDM-F core APIs further --- .../api/ActivityInfoProviderService.java | 4 +- .../api/ConfigurationManagementService.java | 6 +- .../mgt/jaxrs/service/api/Dashboard.java | 136 +- .../service/api/DeviceManagementService.java | 40 +- .../service/api/GroupManagementService.java | 140 +- .../api/NotificationManagementService.java | 9 +- .../service/api/PolicyManagementService.java | 21 +- .../service/api/RoleManagementService.java | 22 +- .../service/api/UserManagementService.java | 26 +- .../ApplicationManagementAdminService.java | 6 +- .../admin/DeviceManagementAdminService.java | 3 +- .../admin/GroupManagementAdminService.java | 3 +- .../api/admin/UserManagementAdminService.java | 3 +- .../mgt/jaxrs/service/impl/DashboardImpl.java | 1268 ++++++++--------- .../impl/DeviceManagementServiceImpl.java | 5 +- .../impl/GroupManagementServiceImpl.java | 189 ++- .../impl/PolicyManagementServiceImpl.java | 3 + .../impl/RoleManagementServiceImpl.java | 4 + .../src/main/webapp/WEB-INF/cxf-servlet.xml | 4 +- .../mgt/common/operation/mgt/Activity.java | 26 + 20 files changed, 999 insertions(+), 919 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java index a2b09ad564..f7606437e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ActivityInfoProviderService.java @@ -32,6 +32,7 @@ import javax.ws.rs.core.Response; * Activity related REST-API implementation. */ @API(name = "Activities", version = "1.0.0", context = "/devicemgt_admin/activities", tags = {"devicemgt_admin"}) + @Path("/activities") @Api(value = "Activity Info Provider", description = "Activity related information manipulation. For example operation details " + "and responses from devices.") @@ -48,7 +49,8 @@ public interface ActivityInfoProviderService { response = Activity.class, value = "Retrieve details of a particular activity.", notes = "This will return information of a particular activity i.e. meta information of an operation, " + - "etc; including the responses from the devices.") + "etc; including the responses from the devices.", + tags = "Activity Info Provider") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java index e6b4c51bd9..8127eed800 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/ConfigurationManagementService.java @@ -45,7 +45,8 @@ public interface ConfigurationManagementService { httpMethod = "GET", value = "Get the general platform configurations.", notes = "Get the general platform level configuration details.", - response = PlatformConfiguration.class) + response = PlatformConfiguration.class, + tags = "Configuration Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -90,7 +91,8 @@ public interface ConfigurationManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", value = "Update General Platform Configurations.", - notes = "This resource is used to update the general platform configuration.") + notes = "This resource is used to update the general platform configuration.", + tags = "Configuration Management") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java index 8dbf6bf3c5..c910074006 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/Dashboard.java @@ -7,75 +7,75 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; -@Path("/dashboard") -@Api(value = "Dashboard", description = "Dashboard related operations are described here.") +//@Path("/dashboard") +//@Api(value = "Dashboard", description = "Dashboard related operations are described here.") @SuppressWarnings("NonJaxWsWebServices") public interface Dashboard { - String CONNECTIVITY_STATUS = "connectivity-status"; - String POTENTIAL_VULNERABILITY = "potential-vulnerability"; - String NON_COMPLIANT_FEATURE_CODE = "non-compliant-feature-code"; - String PLATFORM = "platform"; - String OWNERSHIP = "ownership"; - // Constants related to pagination - String PAGINATION_ENABLED = "pagination-enabled"; - String START_INDEX = "start"; - String RESULT_COUNT = "length"; - - @GET - @Path("device-count-overview") - Response getOverviewDeviceCounts(); - - @GET - @Path("device-counts-by-potential-vulnerabilities") - Response getDeviceCountsByPotentialVulnerabilities(); - - @GET - @Path("non-compliant-device-counts-by-features") - Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount); - - @GET - @Path("device-counts-by-groups") - Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership); - - @GET - @Path("feature-non-compliant-device-counts-by-groups") - Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership); - @GET - @Path("filtered-device-count-over-total") - Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership); - - @GET - @Path("feature-non-compliant-device-count-over-total") - Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership); - - @GET - @Path("devices-with-details") - Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership, - @QueryParam(PAGINATION_ENABLED) String paginationEnabled, - @QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount); - - @GET - @Path("feature-non-compliant-devices-with-details") - Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership, - @QueryParam(PAGINATION_ENABLED) String paginationEnabled, - @QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount); +// String CONNECTIVITY_STATUS = "connectivity-status"; +// String POTENTIAL_VULNERABILITY = "potential-vulnerability"; +// String NON_COMPLIANT_FEATURE_CODE = "non-compliant-feature-code"; +// String PLATFORM = "platform"; +// String OWNERSHIP = "ownership"; +// // Constants related to pagination +// String PAGINATION_ENABLED = "pagination-enabled"; +// String START_INDEX = "start"; +// String RESULT_COUNT = "length"; +// +// @GET +// @Path("device-count-overview") +// Response getOverviewDeviceCounts(); +// +// @GET +// @Path("device-counts-by-potential-vulnerabilities") +// Response getDeviceCountsByPotentialVulnerabilities(); +// +// @GET +// @Path("non-compliant-device-counts-by-features") +// Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount); +// +// @GET +// @Path("device-counts-by-groups") +// Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership); +// +// @GET +// @Path("feature-non-compliant-device-counts-by-groups") +// Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership); +// @GET +// @Path("filtered-device-count-over-total") +// Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership); +// +// @GET +// @Path("feature-non-compliant-device-count-over-total") +// Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership); +// +// @GET +// @Path("devices-with-details") +// Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership, +// @QueryParam(PAGINATION_ENABLED) String paginationEnabled, +// @QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount); +// +// @GET +// @Path("feature-non-compliant-devices-with-details") +// Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership, +// @QueryParam(PAGINATION_ENABLED) String paginationEnabled, +// @QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 98932dbb94..aaa45cdf61 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -42,6 +42,7 @@ import java.util.List; * Device related REST-API. This can be used to manipulated device related details. */ @API(name = "Device", version = "1.0.0", context = "/api/device-mgt/admin/devices", tags = {"devicemgt_admin"}) + @Path("/devices") @Api(value = "Device Management", description = "This API carries all device management related operations " + "such as get all the available devices, etc.") @@ -56,7 +57,8 @@ public interface DeviceManagementService { value = "Get the list of devices enrolled with the system.", notes = "Returns all devices enrolled with the system.", response = Device.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Management") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.", response = Device.class, @@ -136,7 +138,8 @@ public interface DeviceManagementService { notes = "This will return device information such as CPU usage, memory usage etc for supplied device " + "identifiers.", response = DeviceInfo.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -198,7 +201,8 @@ public interface DeviceManagementService { httpMethod = "GET", value = "Get information of the requested device.", notes = "Returns information of the requested device.", - response = Device.class) + response = Device.class, + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -259,7 +263,8 @@ public interface DeviceManagementService { value = "Get the device location of a given device and a device type.", notes = "This will return the device location including latitude and longitude as well the " + "physical address.", - response = DeviceLocation.class) + response = DeviceLocation.class, + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -306,7 +311,8 @@ public interface DeviceManagementService { "Using this REST API you can get the features that can be carried out on a preferred device type," + " such as iOS, Android or Windows.", response = Feature.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -380,7 +386,8 @@ public interface DeviceManagementService { value = "Advanced search for devices.", notes = "Carry out an advanced search of devices.", response = DeviceWrapper.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -421,10 +428,6 @@ public interface DeviceManagementService { }) @Permission(scope = "device-search", permissions = {"/permission/admin/device-mgt/admin/devices/list"}) Response searchDevices( - @ApiParam( - name = "searchContext", - value = "List of search conditions.", - required = true) SearchContext searchContext, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", @@ -434,7 +437,12 @@ public interface DeviceManagementService { name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); + @QueryParam("limit") int limit, + @ApiParam( + name = "searchContext", + value = "List of search conditions.", + required = true) + SearchContext searchContext); @GET @Path("/{type}/{id}/applications") @@ -444,7 +452,8 @@ public interface DeviceManagementService { value = "Getting installed application details of a device.", responseContainer = "List", notes = "Get the list of applications that a device has subscribed.", - response = Application.class) + response = Application.class, + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -530,7 +539,9 @@ public interface DeviceManagementService { notes = "You will carry out many operations on a device. In a situation where you wish to view the all" + " the operations carried out on a device it is not feasible to show all the details on one page" + " therefore the details are paginated.", - response = Operation.class) + response = Operation.class, + responseContainer = "List", + tags = "Device Management") @ApiResponses( value = { @ApiResponse( @@ -615,7 +626,8 @@ public interface DeviceManagementService { notes = "When a device registers with WSO2 EMM a policy is enforced on the device. Initially the EMM " + "filters the policies based on the Platform (device type), filters based on the device ownership" + " type , filters based on the user role or name and finally the policy is enforced on the device.", - response = Policy.class) + response = Policy.class, + tags = "Device Management") @ApiResponses( value = { @ApiResponse( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java index 4f6072460f..46588ccbc9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java @@ -26,79 +26,77 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -@Path("/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +//@Path("/groups") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) public interface GroupManagementService { - @GET - @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) - Response getGroups(@QueryParam("offset") int offset, @QueryParam("limit") int limit); - - @POST - @Permission(scope = "group-add", permissions = {"/permission/admin/device-mgt/user/groups/add"}) - Response createGroup(DeviceGroup group); - - @Path("/{groupName}") - @GET - @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/view"}) - Response getGroup(@PathParam("groupName") String groupName); - - @Path("/{groupName}") - @PUT - @Permission(scope = "group-modify", permissions = {"/permission/admin/device-mgt/user/groups/update"}) - Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup); - - @Path("/{groupName}") - @DELETE - @Permission(scope = "group-remove", permissions = {"/permission/admin/device-mgt/user/groups/remove"}) - Response deleteGroup(@PathParam("groupName") String groupName); - - @Path("/share-group-with-user") - @POST - @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/share"}) - Response shareGroupWithUser(String groupName, String targetUser); - - @Path("/share-group-with-role") - @POST - @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/share"}) - Response shareGroupWithRole(String groupName, String targetRole); - - @Path("/remove-share-with-user") - @POST - @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/unshare"}) - Response removeShareWithUser(@PathParam("groupName") String groupName, @QueryParam("username") String targetUser); - - @Path("/remove-share-with-role") - @POST - @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/unshare"}) - Response removeShareWithRole(@PathParam("groupName") String groupName, @QueryParam("roleName") String targetUser); - - @GET - @Path("/{groupName}/users") - @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) - Response getUsersOfGroup(@PathParam("groupName") String groupName); - - @GET - @Path("/{groupName}/devices") - @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/admin/groups/roles"}) - Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, - @QueryParam("limit") int limit); - - @POST - @Path("/{groupName}/devices") - @Produces("application/json") - @Permission(scope = "group-add", permissions = {"/permission/admin/device-mgt/user/groups/devices/add"}) - Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier); - - @DELETE - @Path("/{groupName}/devices") - @Permission(scope = "group-remove", permissions = {"/permission/admin/device-mgt/user/groups/devices/remove"}) - Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, - @QueryParam("id") String id); +// @GET +// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) +// Response getGroups(@QueryParam("user") String user, @QueryParam("offset") int offset, +// @QueryParam("limit") int limit); +// +// @POST +// @Permission(scope = "group-add", permissions = {"/permission/admin/device-mgt/user/groups/add"}) +// Response createGroup(DeviceGroup group); +// +// @Path("/{groupName}") +// @GET +// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/view"}) +// Response getGroup(@PathParam("groupName") String groupName); +// +// @Path("/{groupName}") +// @PUT +// @Permission(scope = "group-modify", permissions = {"/permission/admin/device-mgt/user/groups/update"}) +// Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup); +// +// @Path("/{groupName}") +// @DELETE +// @Permission(scope = "group-remove", permissions = {"/permission/admin/device-mgt/user/groups/remove"}) +// Response deleteGroup(@PathParam("groupName") String groupName); +// +// @Path("/{groupName}/share-with-user") +// @POST +// @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/share"}) +// Response shareGroupWithUser(@PathParam("groupName") String groupName, String targetUser); +// +// @Path("/{groupName}/share-with-role") +// @POST +// @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/share"}) +// Response shareGroupWithRole(@PathParam("groupName") String groupName, String targetRole); +// +// @Path("/{groupName}/remove-share-with-user") +// @POST +// @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/unshare"}) +// Response removeShareWithUser(@PathParam("groupName") String groupName, String targetUser); +// +// @Path("/{groupName}/remove-share-with-role") +// @POST +// @Permission(scope = "group-share", permissions = {"/permission/admin/device-mgt/user/groups/unshare"}) +// Response removeShareWithRole(@PathParam("groupName") String groupName, String targetUser); +// +// @GET +// @Path("/{groupName}/users") +// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/user/groups/list"}) +// Response getUsersOfGroup(@PathParam("groupName") String groupName); +// +// @GET +// @Path("/{groupName}/devices") +// @Permission(scope = "group-view", permissions = {"/permission/admin/device-mgt/admin/groups/roles"}) +// Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, +// @QueryParam("limit") int limit); +// +// @POST +// @Path("/{groupName}/devices") +// @Produces("application/json") +// @Permission(scope = "group-add", permissions = {"/permission/admin/device-mgt/user/groups/devices/add"}) +// Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier); +// +// @DELETE +// @Path("/{groupName}/devices") +// @Permission(scope = "group-remove", permissions = {"/permission/admin/device-mgt/user/groups/devices/remove"}) +// Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, +// @QueryParam("id") String id); - @GET - Response getGroupsByUser(@QueryParam("user") String user); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java index 6f585ec7e2..c7a9766144 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/NotificationManagementService.java @@ -46,7 +46,8 @@ public interface NotificationManagementService { notes = "Get the details of all notifications that were pushed to the device in WSO2 EMM using " + "this REST API", response = Notification.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Notification Management") @ApiResponses( value = { @ApiResponse( @@ -112,7 +113,8 @@ public interface NotificationManagementService { httpMethod = "PUT", value = "Update the device notification status", notes = "When a user has read the the device notifications, the device notification status must " - + "change from NEW to CHECKED. Update the device notification status using this REST API.") + + "change from NEW to CHECKED. Update the device notification status using this REST API.", + tags = "Device Notification Management") @ApiResponses( value = { @ApiResponse( @@ -167,7 +169,8 @@ public interface NotificationManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Add a device notification.", - notes = "Add a device notification, which will then be sent to a device.") + notes = "Add a device notification, which will then be sent to a device.", + tags = "Device Notification Management") @ApiResponses( value = { @ApiResponse(code = 201, message = "Created. \n Notification has been added successfully.", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index fcb115759b..27960f4e9a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -45,7 +45,8 @@ public interface PolicyManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Add a new policy.", - notes = "This particular resource can be used to add a new policy, which will be created in in-active state.") + notes = "This particular resource can be used to add a new policy, which will be created in in-active state.", + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse( @@ -97,7 +98,8 @@ public interface PolicyManagementService { value = "Get details of policies.", responseContainer = "List", notes = "Retrieve the details of all the policies that have been created in EMM.", - response = Policy.class) + response = Policy.class, + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse( @@ -153,7 +155,8 @@ public interface PolicyManagementService { httpMethod = "GET", value = "Get details of a policy.", notes = "Retrieve the details of a given policy that has been created in EMM.", - response = Policy.class) + response = Policy.class, + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse( @@ -207,7 +210,8 @@ public interface PolicyManagementService { httpMethod = "PUT", value = "Update a policy.", notes = "If you wish to make changes to an existing policy, that can be done by updating the policy using " + - "this resource.") + "this resource.", + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse( @@ -259,7 +263,8 @@ public interface PolicyManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Remove multiple policies.", - notes = "In situations where you need to delete more than one policy you can do so using this API.") + notes = "In situations where you need to delete more than one policy you can do so using this API.", + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse( @@ -294,7 +299,8 @@ public interface PolicyManagementService { httpMethod = "PUT", value = "Activating policies.", notes = "Using the REST API command you are able to publish a policy in order to bring a policy that is " + - "in the inactive state to the active state.") + "in the inactive state to the active state.", + tags = "Device Policy Management") @ApiResponses( value = { @ApiResponse(code = 200, message = "Policies have been successfully activated."), @@ -315,7 +321,8 @@ public interface PolicyManagementService { httpMethod = "PUT", value = "Deactivating policies.", notes = "Using the REST API command you are able to unpublish a policy in order to bring a policy that " + - "is in the active state to the inactive state.") + "is in the active state to the inactive state.", + tags = "Device Policy Management") @ApiResponses(value = { @ApiResponse(code = 200, message = "Policies have been successfully deactivated."), @ApiResponse(code = 500, message = "Error in deactivating policies.") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java index ab13308b3c..d24381aa62 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/RoleManagementService.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.Response; import java.util.List; @API(name = "Role", version = "1.0.0", context = "/devicemgt_admin/roles", tags = {"devicemgt_admin"}) + @Path("/roles") @Api(value = "Role Management", description = "Role management related operations can be found here.") @Produces(MediaType.APPLICATION_JSON) @@ -45,7 +46,8 @@ public interface RoleManagementService { responseContainer = "List", notes = "If you wish to get the details of all the roles in EMM, you can do so using this REST API. All " + "internal roles, roles created for Service-providers and application related roles are omitted.", - response = String.class) + response = String.class, + tags = "Role Management") @ApiResponses( value = { @ApiResponse( @@ -119,7 +121,8 @@ public interface RoleManagementService { "out by a role. Therefore if you wish to retrieve the permission details of a role, you can do " + "so using this REST API.", response = UIPermissionNode.class, - responseContainer = "List" + responseContainer = "List", + tags = "Role Management" ) @ApiResponses( value = { @@ -174,7 +177,8 @@ public interface RoleManagementService { httpMethod = "GET", value = "Get details of a role.", notes = "If you wish to get the details of a role in EMM, you can do so using this REST API.", - response = RoleWrapper.class) + response = RoleWrapper.class, + tags = "Role Management") @ApiResponses( value = { @ApiResponse( @@ -226,7 +230,8 @@ public interface RoleManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Add a role.", - notes = "You are able to add a new role to EMM using the REST API.") + notes = "You are able to add a new role to EMM using the REST API.", + tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 201, @@ -279,7 +284,8 @@ public interface RoleManagementService { httpMethod = "PUT", value = "Update a role.", notes = "There will be situations where you will need to update the role details, such as the permissions" + - " or the role name. In such situation you can update the role details.") + " or the role name. In such situation you can update the role details.", + tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -331,7 +337,8 @@ public interface RoleManagementService { httpMethod = "DELETE", value = "Delete a role.", notes = "In a situation when your Organization identifies that a specific role is no longer required you " + - "will need to remove the role details from EMM.") + "will need to remove the role details from EMM.", + tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -364,7 +371,8 @@ public interface RoleManagementService { "a role using this REST API." + "Example: Your Organization hires 30 new engineers. Updating the role details for each user can " + "be cumbersome, therefore you can define all the new employees that belong to the engineering " + - "role using this API.") + "role using this API.", + tags = "Role Management") @ApiResponses( value = { @ApiResponse( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index 514928ba7c..64fc9bd47e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -31,6 +31,7 @@ import java.util.Date; @API(name = "User Management API", version = "1.0.0", context = "/devicemgt_admin/users", tags = {"devicemgt_admin"}) + @Path("/users") @Api(value = "User Management", description = "User management related operations can be found here.") @Produces(MediaType.APPLICATION_JSON) @@ -43,7 +44,8 @@ public interface UserManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Add a user.", - notes = "A new user can be added to the user management system via this resource") + notes = "A new user can be added to the user management system via this resource", + tags = "User Management") @ApiResponses( value = { @ApiResponse( @@ -92,13 +94,13 @@ public interface UserManagementService { @GET @Path("/{username}") @ApiOperation( - consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "GET", value = "Getting details of a user.", notes = "If you wish to get the details of a specific user that is registered with EMM," + " you can do so using the REST API.", - response = UserWrapper.class) + response = UserWrapper.class, + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -151,7 +153,8 @@ public interface UserManagementService { httpMethod = "PUT", value = "Update details of a user", notes = "There will be situations where you will want to update the user details. In such " - + "situation you can update the user details using this REST API.") + + "situation you can update the user details using this REST API.", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -203,7 +206,8 @@ public interface UserManagementService { httpMethod = "DELETE", value = "Deleting a user.", notes = "In a situation where an employee leaves the organization you will need to remove the" - + " user details from EMM. In such situations you can use this REST API to remove a user.") + + " user details from EMM. In such situations you can use this REST API to remove a user.", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -230,7 +234,8 @@ public interface UserManagementService { notes = "A user can be assigned to one or more role in EMM. Using this REST API you are " + "able to get the role/roles a user is assigned to.", response = String.class, - responseContainer = "List") + responseContainer = "List", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -276,7 +281,8 @@ public interface UserManagementService { notes = "If you wish to get the details of all the users registered with EMM, you can do so " + "using the REST API", response = UserWrapper.class, - responseContainer = "List") + responseContainer = "List", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -341,7 +347,8 @@ public interface UserManagementService { + "You will be given a list of users having the user name with the exact order of the " + "characters you provided.", response = String.class, - responseContainer = "List") + responseContainer = "List", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, @@ -401,7 +408,8 @@ public interface UserManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Changing the user password.", - notes = "A user is able to change the password to secure their EMM profile via this REST API.") + notes = "A user is able to change the password to secure their EMM profile via this REST API.", + tags = "User Management") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java index 68ded82c25..744ef787fd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/ApplicationManagementAdminService.java @@ -46,7 +46,8 @@ public interface ApplicationManagementAdminService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Application installation API.(Internal API)", - notes = "This is an internal API used for application installation on a device.") + notes = "This is an internal API used for application installation on a device.", + tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 200, @@ -79,7 +80,8 @@ public interface ApplicationManagementAdminService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Application un-installation API.(Internal API)", - notes = "This is an internal API used for application uninstallation on a device.") + notes = "This is an internal API used for application un-installation on a device.", + tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java index 2feecee226..ce0bcac4fa 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/DeviceManagementAdminService.java @@ -43,7 +43,8 @@ public interface DeviceManagementAdminService { value = "Get devices by name.", notes = "Get devices by name of the device and tenant that they belong to.", response = Device.class, - responseContainer = "List") + responseContainer = "List", + tags = "Device Management Administrative Service") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of devices.", response = Device.class, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java index 5a62530e52..7e63ae239f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java @@ -42,7 +42,8 @@ public interface GroupManagementAdminService { value = "Get groups by the name.", notes = "Get devices the name of device and tenant.", response = DeviceGroupWrapper.class, - responseContainer = "List") + responseContainer = "List", + tags = "Group Management Administrative Service") @ApiResponses(value = { @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.", response = DeviceGroupWrapper.class, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java index 5b83766226..d6e748aa77 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/UserManagementAdminService.java @@ -41,7 +41,8 @@ public interface UserManagementAdminService { produces = MediaType.APPLICATION_JSON, httpMethod = "POST", value = "Change the user password.", - notes = "A user is able to change the password to secure their EMM profile via this REST API.") + notes = "A user is able to change the password to secure their EMM profile via this REST API.", + tags = "User Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 200, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java index 78f131bdce..46ef0fec8c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DashboardImpl.java @@ -46,643 +46,643 @@ import java.util.List; * [3] Non-compliant Devices by Features, * [4] Device Groupings and etc. */ - -@Consumes({"application/json"}) -@Produces({"application/json"}) +// +//@Consumes({"application/json"}) +//@Produces({"application/json"}) @SuppressWarnings("NonJaxWsWebServices") public class DashboardImpl implements Dashboard { - private static Log log = LogFactory.getLog(DashboardImpl.class); - - private static final String FLAG_TRUE = "true"; - private static final String FLAG_FALSE = "false"; - // Constants related to common error-response messages - private static final String INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY = "Received an invalid value for " + - "query parameter : " + POTENTIAL_VULNERABILITY + ", Should be either NON_COMPLIANT or UNMONITORED."; - private static final String INVALID_QUERY_PARAM_VALUE_START_INDEX = "Received an invalid value for " + - "query parameter : " + START_INDEX + ", Should not be lesser than 0."; - private static final String INVALID_QUERY_PARAM_VALUE_RESULT_COUNT = "Received an invalid value for " + - "query parameter : " + RESULT_COUNT + ", Should not be lesser than 5."; - private static final String INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Received an invalid value for " + - "query parameter : " + PAGINATION_ENABLED + ", Should be either true or false."; - private static final String REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE = "Missing required query " + - "parameter : " + NON_COMPLIANT_FEATURE_CODE; - private static final String REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Missing required query " + - "parameter : " + PAGINATION_ENABLED; - private static final String ERROR_IN_RETRIEVING_REQUESTED_DATA = "Error in retrieving requested data."; - - @GET - @Path("device-count-overview") - public Response getOverviewDeviceCounts() { - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); - - // getting total device count - DeviceCountByGroup totalDeviceCount; - try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve total device count.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - List totalDeviceCountInListEntry = new ArrayList<>(); - totalDeviceCountInListEntry.add(totalDeviceCount); - - dashboardGadgetDataWrapper1.setContext("Total-device-count"); - dashboardGadgetDataWrapper1.setGroupingAttribute(null); - dashboardGadgetDataWrapper1.setData(totalDeviceCountInListEntry); - - // getting device counts by connectivity statuses - List deviceCountsByConnectivityStatuses; - try { - deviceCountsByConnectivityStatuses = gadgetDataService.getDeviceCountsByConnectivityStatuses(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve device counts by connectivity statuses.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); - - dashboardGadgetDataWrapper2.setContext("Device-counts-by-connectivity-statuses"); - dashboardGadgetDataWrapper2.setGroupingAttribute(CONNECTIVITY_STATUS); - dashboardGadgetDataWrapper2.setData(deviceCountsByConnectivityStatuses); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper1); - responsePayload.add(dashboardGadgetDataWrapper2); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("device-counts-by-potential-vulnerabilities") - public Response getDeviceCountsByPotentialVulnerabilities() { - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - List deviceCountsByPotentialVulnerabilities; - try { - deviceCountsByPotentialVulnerabilities = gadgetDataService.getDeviceCountsByPotentialVulnerabilities(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve device counts by potential vulnerabilities.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper.setContext("Device-counts-by-potential-vulnerabilities"); - dashboardGadgetDataWrapper.setGroupingAttribute(POTENTIAL_VULNERABILITY); - dashboardGadgetDataWrapper.setData(deviceCountsByPotentialVulnerabilities); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("non-compliant-device-counts-by-features") - public Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount) { - - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - DashboardPaginationGadgetDataWrapper - dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); - - PaginationResult paginationResult; - try { - paginationResult = gadgetDataService. - getNonCompliantDeviceCountsByFeatures(startIndex, resultCount); - } catch (InvalidStartIndexValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a non-compliant set " + - "of device counts by features.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); - } catch (InvalidResultCountValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a non-compliant set " + - "of device counts by features.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a non-compliant set of device counts by features.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - dashboardPaginationGadgetDataWrapper.setContext("Non-compliant-device-counts-by-features"); - dashboardPaginationGadgetDataWrapper.setGroupingAttribute(NON_COMPLIANT_FEATURE_CODE); - dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); - dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardPaginationGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("device-counts-by-groups") - public Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - ExtendedFilterSet filterSet = new ExtendedFilterSet(); - filterSet.setConnectivityStatus(connectivityStatus); - filterSet.setPotentialVulnerability(potentialVulnerability); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - // creating device-Counts-by-platforms Data Wrapper - List deviceCountsByPlatforms; - try { - deviceCountsByPlatforms = gadgetDataService.getDeviceCountsByPlatforms(filterSet); - } catch (InvalidPotentialVulnerabilityValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper1.setContext("Device-counts-by-platforms"); - dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM); - dashboardGadgetDataWrapper1.setData(deviceCountsByPlatforms); - - // creating device-Counts-by-ownership-types Data Wrapper - List deviceCountsByOwnerships; - try { - deviceCountsByOwnerships = gadgetDataService.getDeviceCountsByOwnershipTypes(filterSet); - } catch (InvalidPotentialVulnerabilityValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper2.setContext("Device-counts-by-ownerships"); - dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP); - dashboardGadgetDataWrapper2.setData(deviceCountsByOwnerships); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper1); - responsePayload.add(dashboardGadgetDataWrapper2); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("feature-non-compliant-device-counts-by-groups") - public Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership) { - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - BasicFilterSet filterSet = new BasicFilterSet(); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - // creating feature-non-compliant-device-Counts-by-platforms Data Wrapper - List featureNonCompliantDeviceCountsByPlatforms; - try { - featureNonCompliantDeviceCountsByPlatforms = gadgetDataService. - getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet); - } catch (InvalidFeatureCodeValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of feature " + - "non-compliant device counts by platforms.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of feature non-compliant " + - "device counts by platforms.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper1.setContext("Feature-non-compliant-device-counts-by-platforms"); - dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM); - dashboardGadgetDataWrapper1.setData(featureNonCompliantDeviceCountsByPlatforms); - - // creating feature-non-compliant-device-Counts-by-ownership-types Data Wrapper - List featureNonCompliantDeviceCountsByOwnerships; - try { - featureNonCompliantDeviceCountsByOwnerships = gadgetDataService. - getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet); - } catch (InvalidFeatureCodeValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of feature " + - "non-compliant device counts by ownerships.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of feature non-compliant " + - "device counts by ownerships.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper2.setContext("Feature-non-compliant-device-counts-by-ownerships"); - dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP); - dashboardGadgetDataWrapper2.setData(featureNonCompliantDeviceCountsByOwnerships); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper1); - responsePayload.add(dashboardGadgetDataWrapper2); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("filtered-device-count-over-total") - public Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - ExtendedFilterSet filterSet = new ExtendedFilterSet(); - filterSet.setConnectivityStatus(connectivityStatus); - filterSet.setPotentialVulnerability(potentialVulnerability); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - // creating filteredDeviceCount Data Wrapper - DeviceCountByGroup filteredDeviceCount; - try { - filteredDeviceCount = gadgetDataService.getDeviceCount(filterSet); - } catch (InvalidPotentialVulnerabilityValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered device count over the total.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered device count over the total.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - // creating TotalDeviceCount Data Wrapper - DeviceCountByGroup totalDeviceCount; - try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve the total device count over filtered.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - List filteredDeviceCountOverTotalDataWrapper = new ArrayList<>(); - filteredDeviceCountOverTotalDataWrapper.add(filteredDeviceCount); - filteredDeviceCountOverTotalDataWrapper.add(totalDeviceCount); - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper.setContext("Filtered-device-count-over-total"); - dashboardGadgetDataWrapper.setGroupingAttribute(null); - dashboardGadgetDataWrapper.setData(filteredDeviceCountOverTotalDataWrapper); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("feature-non-compliant-device-count-over-total") - public Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - BasicFilterSet filterSet = new BasicFilterSet(); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - // creating featureNonCompliantDeviceCount Data Wrapper - DeviceCountByGroup featureNonCompliantDeviceCount; - try { - featureNonCompliantDeviceCount = gadgetDataService. - getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet); - } catch (InvalidFeatureCodeValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - // creating TotalDeviceCount Data Wrapper - DeviceCountByGroup totalDeviceCount; - try { - totalDeviceCount = gadgetDataService.getTotalDeviceCount(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve the total device count over filtered feature non-compliant.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - List featureNonCompliantDeviceCountOverTotalDataWrapper = new ArrayList<>(); - featureNonCompliantDeviceCountOverTotalDataWrapper.add(featureNonCompliantDeviceCount); - featureNonCompliantDeviceCountOverTotalDataWrapper.add(totalDeviceCount); - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper.setContext("Feature-non-compliant-device-count-over-total"); - dashboardGadgetDataWrapper.setGroupingAttribute(null); - dashboardGadgetDataWrapper.setData(featureNonCompliantDeviceCountOverTotalDataWrapper); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - } - - @GET - @Path("devices-with-details") - public Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, - @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership, - @QueryParam(PAGINATION_ENABLED) String paginationEnabled, - @QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount) { - - if (paginationEnabled == null) { - - log.error("Bad request on retrieving a filtered set of devices with details @ " + - "Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); - - } else if (FLAG_TRUE.equals(paginationEnabled)) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - ExtendedFilterSet filterSet = new ExtendedFilterSet(); - filterSet.setConnectivityStatus(connectivityStatus); - filterSet.setPotentialVulnerability(potentialVulnerability); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - PaginationResult paginationResult; - try { - paginationResult = gadgetDataService. - getDevicesWithDetails(filterSet, startIndex, resultCount); - } catch (InvalidPotentialVulnerabilityValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); - } catch (InvalidStartIndexValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); - } catch (InvalidResultCountValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardPaginationGadgetDataWrapper - dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); - dashboardPaginationGadgetDataWrapper.setContext("Filtered-and-paginated-devices-with-details"); - dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null); - dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); - dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardPaginationGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - - } else if (FLAG_FALSE.equals(paginationEnabled)) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - ExtendedFilterSet filterSet = new ExtendedFilterSet(); - filterSet.setConnectivityStatus(connectivityStatus); - filterSet.setPotentialVulnerability(potentialVulnerability); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - List devicesWithDetails; - try { - devicesWithDetails = gadgetDataService.getDevicesWithDetails(filterSet); - } catch (InvalidPotentialVulnerabilityValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of devices with details.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper.setContext("Filtered-devices-with-details"); - dashboardGadgetDataWrapper.setGroupingAttribute(null); - dashboardGadgetDataWrapper.setData(devicesWithDetails); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - - } else { - - log.error("Bad request on retrieving a filtered set of devices with details @ " + - "Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); - - } - } - - @GET - @Path("feature-non-compliant-devices-with-details") - public Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, - @QueryParam(PLATFORM) String platform, - @QueryParam(OWNERSHIP) String ownership, - @QueryParam(PAGINATION_ENABLED) String paginationEnabled, - @QueryParam(START_INDEX) int startIndex, - @QueryParam(RESULT_COUNT) int resultCount) { - if (paginationEnabled == null) { - - log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " + - "details @ Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); - - } else if (FLAG_TRUE.equals(paginationEnabled)) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - BasicFilterSet filterSet = new BasicFilterSet(); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - PaginationResult paginationResult; - try { - paginationResult = gadgetDataService. - getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, - filterSet, startIndex, resultCount); - } catch (InvalidFeatureCodeValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of " + - "feature non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); - } catch (InvalidStartIndexValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of " + - "feature non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); - } catch (InvalidResultCountValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of " + - "feature non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of feature " + - "non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardPaginationGadgetDataWrapper - dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); - dashboardPaginationGadgetDataWrapper. - setContext("Filtered-and-paginated-feature-non-compliant-devices-with-details"); - dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null); - dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); - dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardPaginationGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - - } else if (FLAG_FALSE.equals(paginationEnabled)) { - - // getting gadget data service - GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); - - // constructing filter set - BasicFilterSet filterSet = new BasicFilterSet(); - filterSet.setPlatform(platform); - filterSet.setOwnership(ownership); - - List featureNonCompliantDevicesWithDetails; - try { - featureNonCompliantDevicesWithDetails = gadgetDataService. - getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet); - } catch (InvalidFeatureCodeValueException e) { - log.error("Bad request and error occurred @ Gadget Data Service layer due to " + - "invalid (query) parameter value. This was while trying to execute relevant data service " + - "function @ Dashboard API layer to retrieve a filtered set of " + - "feature non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); - } catch (DataAccessLayerException e) { - log.error("An internal error occurred while trying to execute relevant data service function " + - "@ Dashboard API layer to retrieve a filtered set of feature " + - "non-compliant devices with details.", e); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). - entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); - } - - DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); - dashboardGadgetDataWrapper.setContext("Filtered-feature-non-compliant-devices-with-details"); - dashboardGadgetDataWrapper.setGroupingAttribute(null); - dashboardGadgetDataWrapper.setData(featureNonCompliantDevicesWithDetails); - - List responsePayload = new ArrayList<>(); - responsePayload.add(dashboardGadgetDataWrapper); - - return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); - - } else { - - log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " + - "details @ Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED); - return Response.status(HttpStatus.SC_BAD_REQUEST). - entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); - - } - } +// private static Log log = LogFactory.getLog(DashboardImpl.class); +// +// private static final String FLAG_TRUE = "true"; +// private static final String FLAG_FALSE = "false"; +// // Constants related to common error-response messages +// private static final String INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY = "Received an invalid value for " + +// "query parameter : " + POTENTIAL_VULNERABILITY + ", Should be either NON_COMPLIANT or UNMONITORED."; +// private static final String INVALID_QUERY_PARAM_VALUE_START_INDEX = "Received an invalid value for " + +// "query parameter : " + START_INDEX + ", Should not be lesser than 0."; +// private static final String INVALID_QUERY_PARAM_VALUE_RESULT_COUNT = "Received an invalid value for " + +// "query parameter : " + RESULT_COUNT + ", Should not be lesser than 5."; +// private static final String INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Received an invalid value for " + +// "query parameter : " + PAGINATION_ENABLED + ", Should be either true or false."; +// private static final String REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE = "Missing required query " + +// "parameter : " + NON_COMPLIANT_FEATURE_CODE; +// private static final String REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED = "Missing required query " + +// "parameter : " + PAGINATION_ENABLED; +// private static final String ERROR_IN_RETRIEVING_REQUESTED_DATA = "Error in retrieving requested data."; +// +// @GET +// @Path("device-count-overview") +// public Response getOverviewDeviceCounts() { +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); +// +// // getting total device count +// DeviceCountByGroup totalDeviceCount; +// try { +// totalDeviceCount = gadgetDataService.getTotalDeviceCount(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve total device count.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// List totalDeviceCountInListEntry = new ArrayList<>(); +// totalDeviceCountInListEntry.add(totalDeviceCount); +// +// dashboardGadgetDataWrapper1.setContext("Total-device-count"); +// dashboardGadgetDataWrapper1.setGroupingAttribute(null); +// dashboardGadgetDataWrapper1.setData(totalDeviceCountInListEntry); +// +// // getting device counts by connectivity statuses +// List deviceCountsByConnectivityStatuses; +// try { +// deviceCountsByConnectivityStatuses = gadgetDataService.getDeviceCountsByConnectivityStatuses(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve device counts by connectivity statuses.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); +// +// dashboardGadgetDataWrapper2.setContext("Device-counts-by-connectivity-statuses"); +// dashboardGadgetDataWrapper2.setGroupingAttribute(CONNECTIVITY_STATUS); +// dashboardGadgetDataWrapper2.setData(deviceCountsByConnectivityStatuses); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper1); +// responsePayload.add(dashboardGadgetDataWrapper2); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("device-counts-by-potential-vulnerabilities") +// public Response getDeviceCountsByPotentialVulnerabilities() { +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// List deviceCountsByPotentialVulnerabilities; +// try { +// deviceCountsByPotentialVulnerabilities = gadgetDataService.getDeviceCountsByPotentialVulnerabilities(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve device counts by potential vulnerabilities.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper.setContext("Device-counts-by-potential-vulnerabilities"); +// dashboardGadgetDataWrapper.setGroupingAttribute(POTENTIAL_VULNERABILITY); +// dashboardGadgetDataWrapper.setData(deviceCountsByPotentialVulnerabilities); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("non-compliant-device-counts-by-features") +// public Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount) { +// +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// DashboardPaginationGadgetDataWrapper +// dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); +// +// PaginationResult paginationResult; +// try { +// paginationResult = gadgetDataService. +// getNonCompliantDeviceCountsByFeatures(startIndex, resultCount); +// } catch (InvalidStartIndexValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a non-compliant set " + +// "of device counts by features.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); +// } catch (InvalidResultCountValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a non-compliant set " + +// "of device counts by features.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST).entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a non-compliant set of device counts by features.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// dashboardPaginationGadgetDataWrapper.setContext("Non-compliant-device-counts-by-features"); +// dashboardPaginationGadgetDataWrapper.setGroupingAttribute(NON_COMPLIANT_FEATURE_CODE); +// dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); +// dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardPaginationGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("device-counts-by-groups") +// public Response getDeviceCountsByGroups(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// ExtendedFilterSet filterSet = new ExtendedFilterSet(); +// filterSet.setConnectivityStatus(connectivityStatus); +// filterSet.setPotentialVulnerability(potentialVulnerability); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// // creating device-Counts-by-platforms Data Wrapper +// List deviceCountsByPlatforms; +// try { +// deviceCountsByPlatforms = gadgetDataService.getDeviceCountsByPlatforms(filterSet); +// } catch (InvalidPotentialVulnerabilityValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of device counts by platforms.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper1.setContext("Device-counts-by-platforms"); +// dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM); +// dashboardGadgetDataWrapper1.setData(deviceCountsByPlatforms); +// +// // creating device-Counts-by-ownership-types Data Wrapper +// List deviceCountsByOwnerships; +// try { +// deviceCountsByOwnerships = gadgetDataService.getDeviceCountsByOwnershipTypes(filterSet); +// } catch (InvalidPotentialVulnerabilityValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of device counts by ownerships.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper2.setContext("Device-counts-by-ownerships"); +// dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP); +// dashboardGadgetDataWrapper2.setData(deviceCountsByOwnerships); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper1); +// responsePayload.add(dashboardGadgetDataWrapper2); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("feature-non-compliant-device-counts-by-groups") +// public Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership) { +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// BasicFilterSet filterSet = new BasicFilterSet(); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// // creating feature-non-compliant-device-Counts-by-platforms Data Wrapper +// List featureNonCompliantDeviceCountsByPlatforms; +// try { +// featureNonCompliantDeviceCountsByPlatforms = gadgetDataService. +// getFeatureNonCompliantDeviceCountsByPlatforms(nonCompliantFeatureCode, filterSet); +// } catch (InvalidFeatureCodeValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of feature " + +// "non-compliant device counts by platforms.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of feature non-compliant " + +// "device counts by platforms.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper1 = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper1.setContext("Feature-non-compliant-device-counts-by-platforms"); +// dashboardGadgetDataWrapper1.setGroupingAttribute(PLATFORM); +// dashboardGadgetDataWrapper1.setData(featureNonCompliantDeviceCountsByPlatforms); +// +// // creating feature-non-compliant-device-Counts-by-ownership-types Data Wrapper +// List featureNonCompliantDeviceCountsByOwnerships; +// try { +// featureNonCompliantDeviceCountsByOwnerships = gadgetDataService. +// getFeatureNonCompliantDeviceCountsByOwnershipTypes(nonCompliantFeatureCode, filterSet); +// } catch (InvalidFeatureCodeValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of feature " + +// "non-compliant device counts by ownerships.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of feature non-compliant " + +// "device counts by ownerships.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper2 = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper2.setContext("Feature-non-compliant-device-counts-by-ownerships"); +// dashboardGadgetDataWrapper2.setGroupingAttribute(OWNERSHIP); +// dashboardGadgetDataWrapper2.setData(featureNonCompliantDeviceCountsByOwnerships); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper1); +// responsePayload.add(dashboardGadgetDataWrapper2); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("filtered-device-count-over-total") +// public Response getFilteredDeviceCountOverTotal(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// ExtendedFilterSet filterSet = new ExtendedFilterSet(); +// filterSet.setConnectivityStatus(connectivityStatus); +// filterSet.setPotentialVulnerability(potentialVulnerability); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// // creating filteredDeviceCount Data Wrapper +// DeviceCountByGroup filteredDeviceCount; +// try { +// filteredDeviceCount = gadgetDataService.getDeviceCount(filterSet); +// } catch (InvalidPotentialVulnerabilityValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered device count over the total.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered device count over the total.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// // creating TotalDeviceCount Data Wrapper +// DeviceCountByGroup totalDeviceCount; +// try { +// totalDeviceCount = gadgetDataService.getTotalDeviceCount(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve the total device count over filtered.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// List filteredDeviceCountOverTotalDataWrapper = new ArrayList<>(); +// filteredDeviceCountOverTotalDataWrapper.add(filteredDeviceCount); +// filteredDeviceCountOverTotalDataWrapper.add(totalDeviceCount); +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper.setContext("Filtered-device-count-over-total"); +// dashboardGadgetDataWrapper.setGroupingAttribute(null); +// dashboardGadgetDataWrapper.setData(filteredDeviceCountOverTotalDataWrapper); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("feature-non-compliant-device-count-over-total") +// public Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// BasicFilterSet filterSet = new BasicFilterSet(); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// // creating featureNonCompliantDeviceCount Data Wrapper +// DeviceCountByGroup featureNonCompliantDeviceCount; +// try { +// featureNonCompliantDeviceCount = gadgetDataService. +// getFeatureNonCompliantDeviceCount(nonCompliantFeatureCode, filterSet); +// } catch (InvalidFeatureCodeValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a feature non-compliant device count over the total.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// // creating TotalDeviceCount Data Wrapper +// DeviceCountByGroup totalDeviceCount; +// try { +// totalDeviceCount = gadgetDataService.getTotalDeviceCount(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve the total device count over filtered feature non-compliant.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// List featureNonCompliantDeviceCountOverTotalDataWrapper = new ArrayList<>(); +// featureNonCompliantDeviceCountOverTotalDataWrapper.add(featureNonCompliantDeviceCount); +// featureNonCompliantDeviceCountOverTotalDataWrapper.add(totalDeviceCount); +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper.setContext("Feature-non-compliant-device-count-over-total"); +// dashboardGadgetDataWrapper.setGroupingAttribute(null); +// dashboardGadgetDataWrapper.setData(featureNonCompliantDeviceCountOverTotalDataWrapper); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// } +// +// @GET +// @Path("devices-with-details") +// public Response getDevicesWithDetails(@QueryParam(CONNECTIVITY_STATUS) String connectivityStatus, +// @QueryParam(POTENTIAL_VULNERABILITY) String potentialVulnerability, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership, +// @QueryParam(PAGINATION_ENABLED) String paginationEnabled, +// @QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount) { +// +// if (paginationEnabled == null) { +// +// log.error("Bad request on retrieving a filtered set of devices with details @ " + +// "Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); +// +// } else if (FLAG_TRUE.equals(paginationEnabled)) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// ExtendedFilterSet filterSet = new ExtendedFilterSet(); +// filterSet.setConnectivityStatus(connectivityStatus); +// filterSet.setPotentialVulnerability(potentialVulnerability); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// PaginationResult paginationResult; +// try { +// paginationResult = gadgetDataService. +// getDevicesWithDetails(filterSet, startIndex, resultCount); +// } catch (InvalidPotentialVulnerabilityValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); +// } catch (InvalidStartIndexValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); +// } catch (InvalidResultCountValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardPaginationGadgetDataWrapper +// dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); +// dashboardPaginationGadgetDataWrapper.setContext("Filtered-and-paginated-devices-with-details"); +// dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null); +// dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); +// dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardPaginationGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// +// } else if (FLAG_FALSE.equals(paginationEnabled)) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// ExtendedFilterSet filterSet = new ExtendedFilterSet(); +// filterSet.setConnectivityStatus(connectivityStatus); +// filterSet.setPotentialVulnerability(potentialVulnerability); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// List devicesWithDetails; +// try { +// devicesWithDetails = gadgetDataService.getDevicesWithDetails(filterSet); +// } catch (InvalidPotentialVulnerabilityValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_POTENTIAL_VULNERABILITY).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of devices with details.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper.setContext("Filtered-devices-with-details"); +// dashboardGadgetDataWrapper.setGroupingAttribute(null); +// dashboardGadgetDataWrapper.setData(devicesWithDetails); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// +// } else { +// +// log.error("Bad request on retrieving a filtered set of devices with details @ " + +// "Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); +// +// } +// } +// +// @GET +// @Path("feature-non-compliant-devices-with-details") +// public Response getFeatureNonCompliantDevicesWithDetails(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, +// @QueryParam(PLATFORM) String platform, +// @QueryParam(OWNERSHIP) String ownership, +// @QueryParam(PAGINATION_ENABLED) String paginationEnabled, +// @QueryParam(START_INDEX) int startIndex, +// @QueryParam(RESULT_COUNT) int resultCount) { +// if (paginationEnabled == null) { +// +// log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " + +// "details @ Dashboard API layer. " + REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); +// +// } else if (FLAG_TRUE.equals(paginationEnabled)) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// BasicFilterSet filterSet = new BasicFilterSet(); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// PaginationResult paginationResult; +// try { +// paginationResult = gadgetDataService. +// getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, +// filterSet, startIndex, resultCount); +// } catch (InvalidFeatureCodeValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of " + +// "feature non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); +// } catch (InvalidStartIndexValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of " + +// "feature non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_START_INDEX).build(); +// } catch (InvalidResultCountValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of " + +// "feature non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_RESULT_COUNT).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of feature " + +// "non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardPaginationGadgetDataWrapper +// dashboardPaginationGadgetDataWrapper = new DashboardPaginationGadgetDataWrapper(); +// dashboardPaginationGadgetDataWrapper. +// setContext("Filtered-and-paginated-feature-non-compliant-devices-with-details"); +// dashboardPaginationGadgetDataWrapper.setGroupingAttribute(null); +// dashboardPaginationGadgetDataWrapper.setData(paginationResult.getData()); +// dashboardPaginationGadgetDataWrapper.setTotalRecordCount(paginationResult.getRecordsTotal()); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardPaginationGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// +// } else if (FLAG_FALSE.equals(paginationEnabled)) { +// +// // getting gadget data service +// GadgetDataService gadgetDataService = DeviceMgtAPIUtils.getGadgetDataService(); +// +// // constructing filter set +// BasicFilterSet filterSet = new BasicFilterSet(); +// filterSet.setPlatform(platform); +// filterSet.setOwnership(ownership); +// +// List featureNonCompliantDevicesWithDetails; +// try { +// featureNonCompliantDevicesWithDetails = gadgetDataService. +// getFeatureNonCompliantDevicesWithDetails(nonCompliantFeatureCode, filterSet); +// } catch (InvalidFeatureCodeValueException e) { +// log.error("Bad request and error occurred @ Gadget Data Service layer due to " + +// "invalid (query) parameter value. This was while trying to execute relevant data service " + +// "function @ Dashboard API layer to retrieve a filtered set of " + +// "feature non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(REQUIRED_QUERY_PARAM_VALUE_NON_COMPLIANT_FEATURE_CODE).build(); +// } catch (DataAccessLayerException e) { +// log.error("An internal error occurred while trying to execute relevant data service function " + +// "@ Dashboard API layer to retrieve a filtered set of feature " + +// "non-compliant devices with details.", e); +// return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR). +// entity(ERROR_IN_RETRIEVING_REQUESTED_DATA).build(); +// } +// +// DashboardGadgetDataWrapper dashboardGadgetDataWrapper = new DashboardGadgetDataWrapper(); +// dashboardGadgetDataWrapper.setContext("Filtered-feature-non-compliant-devices-with-details"); +// dashboardGadgetDataWrapper.setGroupingAttribute(null); +// dashboardGadgetDataWrapper.setData(featureNonCompliantDevicesWithDetails); +// +// List responsePayload = new ArrayList<>(); +// responsePayload.add(dashboardGadgetDataWrapper); +// +// return Response.status(HttpStatus.SC_OK).entity(responsePayload).build(); +// +// } else { +// +// log.error("Bad request on retrieving a filtered set of feature non-compliant devices with " + +// "details @ Dashboard API layer. " + INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED); +// return Response.status(HttpStatus.SC_BAD_REQUEST). +// entity(INVALID_QUERY_PARAM_VALUE_PAGINATION_ENABLED).build(); +// +// } +// } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index b984bb699e..b36903c9c7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -42,11 +42,14 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.Date; import java.util.List; @Path("/devices") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) public class DeviceManagementServiceImpl implements DeviceManagementService{ private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class); @@ -177,7 +180,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService{ @POST @Path("/search-devices") @Override - public Response searchDevices(SearchContext searchContext, @QueryParam("offset") int offset, int limit) { + public Response searchDevices(@QueryParam("offset") int offset, int limit, SearchContext searchContext) { SearchManagerService searchManagerService; List devices; try { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java index 8ac90acd47..dd8529f322 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java @@ -33,106 +33,105 @@ import org.wso2.carbon.device.mgt.jaxrs.service.api.GroupManagementService; import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.List; +//@Path("/groups") +//@Produces(MediaType.APPLICATION_JSON) +//@Consumes(MediaType.APPLICATION_JSON) public class GroupManagementServiceImpl implements GroupManagementService { - private static final Log log = LogFactory.getLog(GroupManagementServiceImpl.class); - - @Override - public Response getGroups(@QueryParam("offset") int offset, @QueryParam("limit") int limit) { - return null; - } - - @Override - public Response createGroup(DeviceGroup group) { - return null; - } - - @Override - public Response getGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup) { - return null; - } - - @Override - public Response deleteGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response shareGroupWithUser(String groupName, String targetUser) { - return null; - } - - @Override - public Response shareGroupWithRole(String groupName, String targetRole) { - return null; - } - - @Override - public Response removeShareWithUser(@PathParam("groupName") String groupName, - @QueryParam("username") String targetUser) { - return null; - } - - @Override - public Response removeShareWithRole(@PathParam("groupName") String groupName, - @QueryParam("roleName") String targetUser) { - return null; - } - - @Override - public Response getUsersOfGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, - @QueryParam("limit") int limit) { - return null; - } - - @Override - public Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier) { - return null; - } - - @Override - public Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, - @QueryParam("id") String id) { - return null; - } - - @Override - public Response getGroupsByUser(@QueryParam("user") String user) { - try { - List groupWrappers = new ArrayList<>(); - GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService(); - List deviceGroups = service.getGroups(user); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - for (DeviceGroup dg : deviceGroups) { - DeviceGroupWrapper gw = new DeviceGroupWrapper(); - gw.setId(dg.getId()); - gw.setOwner(dg.getOwner()); - gw.setName(dg.getName()); - gw.setTenantId(tenantId); - groupWrappers.add(gw); - } - return Response.status(Response.Status.OK).entity(groupWrappers).build(); - } catch (GroupManagementException e) { - String error = "Error occurred while getting the groups related to users for policy."; - log.error(error, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } - } +// private static final Log log = LogFactory.getLog(GroupManagementServiceImpl.class); +// +// @Override +// public Response getGroups(@QueryParam("user") String user, @QueryParam("offset") int offset, +// @QueryParam("limit") int limit) { +// try { +// List groupWrappers = new ArrayList<>(); +// GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService(); +// List deviceGroups = service.getGroups(user); +// int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); +// for (DeviceGroup dg : deviceGroups) { +// DeviceGroupWrapper gw = new DeviceGroupWrapper(); +// gw.setId(dg.getId()); +// gw.setOwner(dg.getOwner()); +// gw.setName(dg.getName()); +// gw.setTenantId(tenantId); +// groupWrappers.add(gw); +// } +// return Response.status(Response.Status.OK).entity(groupWrappers).build(); +// } catch (GroupManagementException e) { +// String error = "Error occurred while getting the groups related to users for policy."; +// log.error(error, e); +// return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); +// } +// } +// +// @Override +// public Response createGroup(DeviceGroup group) { +// return null; +// } +// +// @Override +// public Response getGroup(@PathParam("groupName") String groupName) { +// return null; +// } +// +// @Override +// public Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup) { +// return null; +// } +// +// @Override +// public Response deleteGroup(@PathParam("groupName") String groupName) { +// return null; +// } +// +// @Override +// public Response shareGroupWithUser(String groupName, String targetUser) { +// return null; +// } +// +// @Override +// public Response shareGroupWithRole(String groupName, String targetRole) { +// return null; +// } +// +// @Override +// public Response removeShareWithUser(@PathParam("groupName") String groupName, +// @QueryParam("username") String targetUser) { +// return null; +// } +// +// @Override +// public Response removeShareWithRole(@PathParam("groupName") String groupName, +// @QueryParam("roleName") String targetUser) { +// return null; +// } +// +// @Override +// public Response getUsersOfGroup(@PathParam("groupName") String groupName) { +// return null; +// } +// +// @Override +// public Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, +// @QueryParam("limit") int limit) { +// return null; +// } +// +// @Override +// public Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier) { +// return null; +// } +// +// @Override +// public Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, +// @QueryParam("id") String id) { +// return null; +// } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java index f5183b74e3..09409fc2ea 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/PolicyManagementServiceImpl.java @@ -36,10 +36,13 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException; import org.wso2.carbon.policy.mgt.core.PolicyManagerService; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; @Path("/policies") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) public class PolicyManagementServiceImpl implements PolicyManagementService { private static final Log log = LogFactory.getLog(PolicyManagementServiceImpl.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 0a1aabc144..f4f8662dcb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -33,11 +33,15 @@ import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UserAdminException; import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +@Path("/roles") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) public class RoleManagementServiceImpl implements RoleManagementService { private static final Log log = LogFactory.getLog(RoleManagementServiceImpl.class); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index 6299d10ff4..9ad8d52e24 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -35,7 +35,7 @@ - + @@ -70,7 +70,7 @@ - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java index 9b59982b16..deee7cbe6d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/operation/mgt/Activity.java @@ -19,18 +19,44 @@ package org.wso2.carbon.device.mgt.common.operation.mgt; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + import java.util.List; +@ApiModel(value = "Activity", description = "An activity instance carries a unique identifier that can be " + + "used to identify a particular operation instance uniquely") public class Activity { public enum Type { CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY } + @ApiModelProperty( + name = "activityId", + value = "Activity identifier", + required = true) private String activityId; + @ApiModelProperty( + name = "code", + value = "Activity code", + required = true) private String code; + @ApiModelProperty( + name = "type", + value = "Activity type", + required = true, + allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY") private Type type; + @ApiModelProperty( + name = "createdTimeStamp", + value = "Timestamp recorded when the activity took place", + required = true) private String createdTimeStamp; + @ApiModelProperty( + name = "activityStatuses", + value = "Collection of statuses corresponding to the activity", + required = true) private List activityStatus; public String getActivityId() {