From 88feb5a85246e503b4b9a9d1139c2a70eef016c0 Mon Sep 17 00:00:00 2001 From: madhawap Date: Tue, 28 Jun 2016 13:15:06 +0530 Subject: [PATCH 1/4] Add Pagination to Notification end points --- .../service/api/DeviceManagementService.java | 210 ++++++++++++------ .../api/NotificationManagementService.java | 24 +- .../service/api/PolicyManagementService.java | 95 +++++--- .../impl/DeviceManagementServiceImpl.java | 1 + .../NotificationManagementServiceImpl.java | 29 ++- .../mgt/NotificationManagementService.java | 7 + .../NotificationManagementServiceImpl.java | 47 ++++ .../notification/mgt/dao/NotificationDAO.java | 11 + .../mgt/dao/impl/NotificationDAOImpl.java | 162 ++++++++++++++ 9 files changed, 479 insertions(+), 107 deletions(-) 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 7b5b61e2da7..a3958d4dacf 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 @@ -90,53 +90,66 @@ public interface DeviceManagementService { message = "Internal Server ErrorResponse. \n Server error occurred while fetching the device list.", response = ErrorResponse.class) }) - @Permission(scope = "device-list", permissions = {"/permission/admin/device-mgt/admin/devices/list"}) + @Permission( + scope = "device-list", + permissions = {"/permission/admin/device-mgt/admin/devices/list"} + ) Response getDevices( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = false) - @QueryParam("type") String type, + @QueryParam("type") + String type, @ApiParam( - name = "user", value = "Username of owner of the devices.", + name = "user", + value = "Username of owner of the devices.", required = false) - @QueryParam("user") String user, + @QueryParam("user") + String user, @ApiParam( name = "roleName", value = "Role name of the devices to be fetched.", required = false) - @QueryParam("roleName") String roleName, + @QueryParam("roleName") + String roleName, @ApiParam( name = "ownership", allowableValues = "BYOD, COPE", value = "Ownership of the devices to be fetched registered under.", required = false) - @QueryParam("ownership") String ownership, + @QueryParam("ownership") + String ownership, @ApiParam( name = "status", value = "Enrollment status of devices to be fetched.", required = false) - @QueryParam("status") String status, + @QueryParam("status") + String status, @ApiParam( name = "since", value = "Last modified timestamp", required = false) - @QueryParam("since") String since, + @QueryParam("since") + String since, @ApiParam( name = "If-Modified-Since", value = "Timestamp of the last modified date", required = false) - @HeaderParam("If-Modified-Since") String timestamp, + @HeaderParam("If-Modified-Since") + String timestamp, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); + @QueryParam("limit") + int limit); @GET @@ -184,25 +197,32 @@ public interface DeviceManagementService { "Server error occurred while retrieving information requested device.", response = ErrorResponse.class) }) - @Permission(scope = "device-view", permissions = { + @Permission( + scope = "device-view", + permissions = { "/permission/admin/device-mgt/admin/devices/view", - "/permission/admin/device-mgt/user/devices/view"}) + "/permission/admin/device-mgt/user/devices/view" + } + ) Response getDevice( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = true) - @PathParam("type") String type, + @PathParam("type") + String type, @ApiParam( name = "id", value = "The device identifier of the device.", required = true) - @PathParam("id") String id, + @PathParam("id") + String id, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); + @HeaderParam("If-Modified-Since") + String ifModifiedSince); @GET @Path("/{type}/{id}/features") @@ -263,24 +283,31 @@ public interface DeviceManagementService { "Server error occurred while retrieving feature list of the device.", response = ErrorResponse.class) }) - @Permission(scope = "device-search", permissions = {"/permission/admin/device-mgt/admin/devices/view", - "/permission/admin/device-mgt/user/devices/view"}) + @Permission( + scope = "device-search", + permissions = {"/permission/admin/device-mgt/admin/devices/view", + "/permission/admin/device-mgt/user/devices/view" + } + ) Response getFeaturesOfDevice( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = true) - @PathParam("type") String type, + @PathParam("type") + String type, @ApiParam( name = "id", value = "The device identifier of the device.", required = true) - @PathParam("id") String id, + @PathParam("id") + String id, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); + @HeaderParam("If-Modified-Since") + String ifModifiedSince); @POST @Path("/search-devices") @@ -335,23 +362,28 @@ public interface DeviceManagementService { "Server error occurred while enrolling the device.", response = ErrorResponse.class) }) - @Permission(scope = "device-search", permissions = {"/permission/admin/device-mgt/admin/devices/list"}) + @Permission( + scope = "device-search", + permissions = {"/permission/admin/device-mgt/admin/devices/list" } + ) Response searchDevices( @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( 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); + SearchContext searchContext); @GET @Path("/{type}/{id}/applications") @@ -378,7 +410,8 @@ public interface DeviceManagementService { "Used by caches, or in conditional requests."), @ResponseHeader( name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + + description = "Date and time the resource has been modified the " + + "last time.\n" + "Used by caches, or in conditional requests.")}), @ApiResponse( code = 303, @@ -391,14 +424,16 @@ public interface DeviceManagementService { @ApiResponse( code = 304, message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested resource."), + "Empty body because the client already has the latest version of the " + + "requested resource."), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Device of which the application list is requested, is not found.", + message = "Not Found. \n Device of which the application list is requested, is " + + "not found.", response = ErrorResponse.class), @ApiResponse( code = 406, @@ -406,38 +441,47 @@ public interface DeviceManagementService { @ApiResponse( code = 500, message = "Internal Server ErrorResponse. \n " + - "Server error occurred while retrieving installed application list of the device.", + "Server error occurred while retrieving installed application list of " + + "the device.", response = ErrorResponse.class) }) - @Permission(scope = "operation-view", permissions = { + @Permission( + scope = "operation-view", + permissions = { "/permission/admin/device-mgt/admin/devices/view", "/permission/admin/device-mgt/user/devices/view" - }) + } + ) Response getInstalledApplications( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = true) - @PathParam("type") String type, + @PathParam("type") + String type, @ApiParam( name = "id", value = "The device identifier of the device.", required = true) - @PathParam("id") String id, + @PathParam("id") + String id, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, + @HeaderParam("If-Modified-Since") + String ifModifiedSince, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); + @QueryParam("limit") + int limit); @GET @@ -446,9 +490,9 @@ public interface DeviceManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "GET", value = "Getting paginated details for operations on a device.", - 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.", + 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.", tags = "Device Management") @ApiResponses( value = { @@ -467,7 +511,8 @@ public interface DeviceManagementService { "Used by caches, or in conditional requests."), @ResponseHeader( name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + + description = "Date and time the resource has been modified the " + + "last time.\n" + "Used by caches, or in conditional requests.")}), @ApiResponse( code = 303, @@ -480,14 +525,16 @@ public interface DeviceManagementService { @ApiResponse( code = 304, message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested resource."), + "Empty body because the client already has the latest version of the " + + "requested resource."), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Device of which the operation list is requested, is not found.", + message = "Not Found. \n Device of which the operation list is requested, is not " + + "found.", response = ErrorResponse.class), @ApiResponse( code = 406, @@ -495,39 +542,49 @@ public interface DeviceManagementService { @ApiResponse( code = 500, message = "Internal Server ErrorResponse. \n " + - "Server error occurred while retrieving operation list scheduled for the device.", + "Server error occurred while retrieving operation list scheduled for the " + + "device.", response = ErrorResponse.class) }) - @Permission(scope = "operation-view", permissions = { + @Permission( + scope = "operation-view", + permissions = { "/permission/admin/device-mgt/admin/devices/view", "/permission/admin/device-mgt/user/devices/view" - }) + } + ) Response getDeviceOperations( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = true) - @PathParam("type") String type, + @PathParam("type") + String type, @ApiParam( name = "id", value = "The device identifier of the device.", required = true) - @PathParam("id") String id, + @PathParam("id") + String id, @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Validates if the requested variant has not been modified since the time " + + "specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, + @HeaderParam("If-Modified-Since") + String ifModifiedSince, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); + @QueryParam("limit") + int limit); @GET @Path("/{type}/{id}/effective-policy") @@ -535,9 +592,10 @@ public interface DeviceManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "GET", value = "Get the effective policy calculated for a device.", - 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.", + 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.", tags = "Device Management") @ApiResponses( value = { @@ -555,7 +613,8 @@ public interface DeviceManagementService { "Used by caches, or in conditional requests."), @ResponseHeader( name = "Last-Modified", - description = "Date and time the resource has been modified the last time.\n" + + description = "Date and time the resource has been modified the " + + "last time.\n" + "Used by caches, or in conditional requests.")}), @ApiResponse( code = 303, @@ -568,14 +627,16 @@ public interface DeviceManagementService { @ApiResponse( code = 304, message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested resource."), + "Empty body because the client already has the latest version of the " + + "requested resource."), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Device of which the effective policy is requested, is not found.", + message = "Not Found. \n Device of which the effective policy is requested, is " + + "not found.", response = ErrorResponse.class), @ApiResponse( code = 406, @@ -583,27 +644,50 @@ public interface DeviceManagementService { @ApiResponse( code = 500, message = "Internal Server ErrorResponse. \n " + - "Server error occurred while retrieving the effective policy calculated for the device.", + "Server error occurred while retrieving the effective policy calculated " + + "for the device.", response = ErrorResponse.class) - }) + } + ) Response getEffectivePolicyOfDevice( @ApiParam( name = "type", value = "The device type, such as ios, android or windows.", required = true) - @PathParam("type") String type, + @PathParam("type") + String type, @ApiParam( name = "id", value = "Device Identifier", required = true) - @PathParam("id") String id, + @PathParam("id") + String id, @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Validates if the requested variant has not been modified since the time " + + "specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); + @HeaderParam("If-Modified-Since") + String ifModifiedSince); @GET @Path("/types") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "GET", + value = "Get the device type.", + notes = "You are able to register Android, iOS and Windows devices with WSO2 EMM. In order to" + + "retrieve the device type details that are registered this end-point van be used.", + tags = "Device Management") + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Registered device types have successfully retrieved"), + @ApiResponse( + code = 500, + message = "Error occurred while fetching the list of device types.") + } + ) Response getDeviceTypes(); } 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 6a215478852..de119c553e3 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 @@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.jaxrs.service.api; import io.swagger.annotations.*; import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.Permission; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.jaxrs.NotificationContext; import org.wso2.carbon.device.mgt.jaxrs.NotificationList; @@ -88,31 +89,36 @@ public interface NotificationManagementService { message = "Internal Server ErrorResponse. \n Server error occurred while fetching the notification list.", response = ErrorResponse.class) }) - @Permission(scope = "device-notification-view", permissions = { + @Permission( + scope = "device-notification-view", + permissions = { "/permission/admin/device-mgt/admin/notifications/view", "/permission/admin/device-mgt/user/notifications/view" - }) + }) Response getNotifications( - @ApiParam(name = "status", + @ApiParam( + name = "status", value = "Status of the notification.", allowableValues = "NEW, CHECKED", required = false) - @QueryParam("status") String status, + @QueryParam("status") + String status, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, + @HeaderParam("If-Modified-Since") + String ifModifiedSince, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); - - + @QueryParam("limit") + int limit); } 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 05515fb6553..0dc31a49fb7 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 @@ -94,12 +94,15 @@ public interface PolicyManagementService { "Server error occurred while adding a new policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/add"}) + @Permission( + scope = "policy-modify", + permissions = {"/permission/admin/device-mgt/admin/policies/add"}) Response addPolicy( @ApiParam( name = "policy", value = "Policy details related to the operation.", - required = true) PolicyWrapper policy); + required = true) + PolicyWrapper policy); @GET @ApiOperation( @@ -146,23 +149,28 @@ public interface PolicyManagementService { "policies."), response = ErrorResponse.class) }) - @Permission(scope = "policy-view", permissions = {"/permission/admin/device-mgt/admin/policies/list"}) + @Permission( + scope = "policy-view", + permissions = {"/permission/admin/device-mgt/admin/policies/list"}) Response getPolicies( @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince, + @HeaderParam("If-Modified-Since") + String ifModifiedSince, @ApiParam( name = "offset", value = "Starting point within the complete list of items qualified.", required = false) - @QueryParam("offset") int offset, + @QueryParam("offset") + int offset, @ApiParam( name = "limit", value = "Maximum size of resource array to return.", required = false) - @QueryParam("limit") int limit); + @QueryParam("limit") + int limit); @GET @Path("/{id}") @@ -209,18 +217,22 @@ public interface PolicyManagementService { "policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-view", permissions = {"/permission/admin/device-mgt/admin/policies/list"}) + @Permission( + scope = "policy-view", + permissions = {"/permission/admin/device-mgt/admin/policies/list"}) Response getPolicy( @ApiParam( name = "id", value = "Policy identifier", required = true) - @PathParam("id") int id, + @PathParam("id") + int id, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", required = false) - @HeaderParam("If-Modified-Since") String ifModifiedSince); + @HeaderParam("If-Modified-Since") + String ifModifiedSince); @PUT @Path("/{id}") @@ -269,16 +281,21 @@ public interface PolicyManagementService { "Server error occurred while updating the policy.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/update"}) + @Permission( + scope = "policy-modify", + permissions = {"/permission/admin/device-mgt/admin/policies/update"}) Response updatePolicy( @ApiParam( name = "id", - value = "The device identifier of the device.", required = true) - @PathParam("id") int id, + value = "The device identifier of the device.", + required = true) + @PathParam("id") + int id, @ApiParam( name = "policy", value = "Policy details related to the operation.", - required = true) PolicyWrapper policy); + required = true) + PolicyWrapper policy); @POST @Path("/remove-policy") @@ -311,12 +328,15 @@ public interface PolicyManagementService { "Server error occurred while bulk removing policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", permissions = {"/permission/admin/device-mgt/admin/policies/remove"}) + @Permission( + scope = "policy-modify", + permissions = {"/permission/admin/device-mgt/admin/policies/remove"}) Response removePolicies( @ApiParam( name = "policyIds", value = "Policy id list to be deleted.", - required = true) List policyIds); + required = true) + List policyIds); @POST @Path("/activate-policy") @@ -346,12 +366,16 @@ public interface PolicyManagementService { message = "ErrorResponse in activating policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", permissions = { + @Permission( + scope = "policy-modify", permissions = { "/permission/admin/device-mgt/admin/policies/update", "/permission/admin/device-mgt/admin/policies/add"}) Response activatePolicies( - @ApiParam(name = "policyIds", value = "Policy ID list to be activated.", - required = true) List policyIds); + @ApiParam( + name = "policyIds", + value = "Policy ID list to be activated.", + required = true) + List policyIds); @POST @Path("/deactivate-policy") @@ -363,7 +387,8 @@ public interface PolicyManagementService { 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.", tags = "Device Policy Management") - @ApiResponses(value = { + @ApiResponses( + value = { @ApiResponse( code = 200, message = "Policies have been successfully deactivated."), @@ -380,12 +405,17 @@ public interface PolicyManagementService { message = "ErrorResponse in deactivating policies.", response = ErrorResponse.class) }) - @Permission(scope = "policy-modify", permissions = { + @Permission( + scope = "policy-modify", + permissions = { "/permission/admin/device-mgt/admin/policies/update", "/permission/admin/device-mgt/admin/policies/add"}) Response deactivatePolicies( - @ApiParam(name = "policyIds", value = "Policy ID list to be deactivated.", - required = true) List policyIds); + @ApiParam( + name = "policyIds", + value = "Policy ID list to be deactivated.", + required = true) + List policyIds); @PUT @Produces("application/json") @@ -400,7 +430,8 @@ public interface PolicyManagementService { " policies (removing, activating, deactivating and updating) or add new policies, the existing" + " devices will not receive these changes immediately. Once all the required changes are made" + " you need to apply the changes to push the policy changes to the existing devices.") - @ApiResponses(value = { + @ApiResponses( + value = { @ApiResponse( code = 200, message = "Changes have been successfully updated."), @@ -420,10 +451,12 @@ public interface PolicyManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", value = "Prioritizing policies.", - notes = "", + notes = "If you wish to make changes to the existing policy priority order, you can do so by " + + "updating the priority order using this end-point", tags = "Device Policy Management" ) - @ApiResponses(value = { + @ApiResponses( + value = { @ApiResponse( code = 200, message = "Policy Priorities successfully updated."), @@ -436,9 +469,15 @@ public interface PolicyManagementService { message = "Exception in updating policy priorities.", response = ErrorResponse.class) }) - @Permission(scope = "", permissions = {}) - Response updatePolicyPriorities(@ApiParam(name = "priorityUpdatedPolicies", value = "", - required = true) List priorityUpdatedPolicies); + @Permission( + scope = "", + permissions = {}) + Response updatePolicyPriorities( + @ApiParam( + name = "priorityUpdatedPolicies", + value = "List of policies with priorities", + required = true) + List priorityUpdatedPolicies); } 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 31db04ba280..fe5088b2040 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 @@ -321,6 +321,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } + @GET @Override public Response getDeviceTypes() { List deviceTypes; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/NotificationManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/NotificationManagementServiceImpl.java index 8d7a2a72b12..7b510223e25 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/NotificationManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/NotificationManagementServiceImpl.java @@ -20,10 +20,16 @@ package org.wso2.carbon.device.mgt.jaxrs.service.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.jaxrs.NotificationContext; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; +import org.wso2.carbon.device.mgt.jaxrs.beans.NotificationList; import org.wso2.carbon.device.mgt.jaxrs.service.api.NotificationManagementService; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.*; import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.NotFoundException; @@ -47,24 +53,33 @@ public class NotificationManagementServiceImpl implements NotificationManagement @QueryParam("status") String status, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { + + PaginationRequest request = new PaginationRequest(offset, limit); + PaginationResult result = null; + + NotificationList notificationList = new NotificationList(); + int resultCount = 0; + String msg; - List notifications; try { if (status != null) { RequestValidationUtil.validateNotificationStatus(status); - notifications = - DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus( - Notification.Status.valueOf(status)); + result = DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus( + Notification.Status.valueOf(status),request); + resultCount = result.getRecordsTotal(); } else { - notifications = DeviceMgtAPIUtils.getNotificationManagementService().getAllNotifications(); + result = DeviceMgtAPIUtils.getNotificationManagementService().getAllNotifications(request); } - if (notifications == null || notifications.size() == 0) { + if (resultCount == 0) { throw new NotFoundException( new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No notification is " + "available to be retrieved.").build()); } - return Response.status(Response.Status.OK).entity(notifications).build(); + + notificationList.setNotifications((List) result.getData()); + notificationList.setCount(result.getRecordsTotal()); + return Response.status(Response.Status.OK).entity(notificationList).build(); } catch (NotificationManagementException e) { msg = "Error occurred while retrieving notification info"; log.error(msg, e); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/notification/mgt/NotificationManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/notification/mgt/NotificationManagementService.java index 303775b73fe..c854e472794 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/notification/mgt/NotificationManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/notification/mgt/NotificationManagementService.java @@ -19,6 +19,8 @@ package org.wso2.carbon.device.mgt.common.notification.mgt; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import java.util.List; @@ -69,6 +71,8 @@ public interface NotificationManagementService { */ List getAllNotifications() throws NotificationManagementException; + PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException; + /** * @param status - Status of the notifications to be fetched from database. * @return A list of notifications matching the given status. @@ -78,4 +82,7 @@ public interface NotificationManagementService { List getNotificationsByStatus(Notification.Status status) throws NotificationManagementException; + PaginationResult getNotificationsByStatus(Notification.Status status, + PaginationRequest request) throws NotificationManagementException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java index 858643e8874..ffac513ecaf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/NotificationManagementServiceImpl.java @@ -23,6 +23,8 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.EntityDoesNotExistException; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.TransactionManagementException; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; @@ -35,6 +37,7 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManageme import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; import java.sql.SQLException; +import java.util.ArrayList; import java.util.List; /** @@ -157,6 +160,50 @@ public class NotificationManagementServiceImpl implements NotificationManagement } } + @Override + public PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException { + PaginationResult paginationResult = new PaginationResult(); + List notifications = new ArrayList<>(); + int count =0; + try { + NotificationManagementDAOFactory.openConnection(); + notifications = notificationDAO.getAllNotifications(request, NotificationDAOUtil.getTenantId()); + count = notificationDAO.getNotificationCount(NotificationDAOUtil.getTenantId()); + paginationResult.setData(notifications); + paginationResult.setRecordsFiltered(count); + paginationResult.setRecordsTotal(count); + return paginationResult; + } catch (SQLException e) { + throw new NotificationManagementException("Error occurred while opening a connection to" + + " the data source", e); + } finally { + NotificationManagementDAOFactory.closeConnection(); + } + } + + @Override + public PaginationResult getNotificationsByStatus(Notification.Status status, + PaginationRequest request) throws NotificationManagementException{ + PaginationResult paginationResult = new PaginationResult(); + List notifications = new ArrayList<>(); + int count =0; + try { + NotificationManagementDAOFactory.openConnection(); + notifications = notificationDAO.getNotificationsByStatus(request, status, NotificationDAOUtil.getTenantId()); + count = notificationDAO.getNotificationCountByStatus(status, NotificationDAOUtil.getTenantId()); + paginationResult.setData(notifications); + paginationResult.setRecordsFiltered(count); + paginationResult.setRecordsTotal(count); + return paginationResult; + } catch (SQLException e) { + throw new NotificationManagementException("Error occurred while opening a connection " + + "to the data source", e); + } finally { + NotificationManagementDAOFactory.closeConnection(); + } + } + + @Override public List getNotificationsByStatus(Notification.Status status) throws NotificationManagementException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/NotificationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/NotificationDAO.java index a79bb4fc446..d2fc0efcb1c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/NotificationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/NotificationDAO.java @@ -18,6 +18,8 @@ package org.wso2.carbon.device.mgt.core.notification.mgt.dao; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; @@ -69,6 +71,12 @@ public interface NotificationDAO { */ List getAllNotifications(int tenantId) throws NotificationManagementException; + List getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException; + + int getNotificationCount(int tenantId) throws NotificationManagementException; + + int getNotificationCountByStatus(Notification.Status status, int tenantId) throws NotificationManagementException; + /** * This method is used to get all notifications based on notification-status. * @@ -80,4 +88,7 @@ public interface NotificationDAO { List getNotificationsByStatus(Notification.Status status, int tenantId) throws NotificationManagementException; + List getNotificationsByStatus(PaginationRequest request, Notification.Status status, int tenantId) throws + NotificationManagementException; + } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/NotificationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/NotificationDAOImpl.java index 00f9bc39ac6..695832b3d23 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/NotificationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/notification/mgt/dao/impl/NotificationDAOImpl.java @@ -18,8 +18,12 @@ package org.wso2.carbon.device.mgt.core.notification.mgt.dao.impl; +import org.wso2.carbon.device.mgt.common.PaginationRequest; +import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException; +import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException; +import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationDAO; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; @@ -143,6 +147,85 @@ public class NotificationDAOImpl implements NotificationDAO { return notifications; } + @Override + public List getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List notifications = null; + try { + conn = NotificationManagementDAOFactory.getConnection(); + String sql = + "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS, n1.DESCRIPTION," + + " d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + + "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; + + sql = sql + " LIMIT ?,?"; + + stmt = conn.prepareStatement(sql); + stmt.setInt(1, tenantId); + stmt.setInt(2, tenantId); + int paramIdx = 3; + + stmt.setInt(paramIdx++, request.getStartIndex()); + stmt.setInt(paramIdx, request.getRowCount()); + + rs = stmt.executeQuery(); + notifications = new ArrayList<>(); + while (rs.next()) { + notifications.add(this.getNotification(rs)); + } + } catch (SQLException e) { + throw new NotificationManagementException( + "Error occurred while retrieving information of all notifications", e); + } finally { + NotificationDAOUtil.cleanupResources(stmt, rs); + } + return notifications; + } + + + @Override + public int getNotificationCount(int tenantId) throws NotificationManagementException { + int notificationCount = 0; + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + conn = NotificationManagementDAOFactory.getConnection(); + String sql = + "SELECT COUNT(n1.NOTIFICATION_ID) AS NOTIFICATION_COUNT FROM DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT " + + "NOTIFICATION_ID, DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + + "TENANT_ID = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID AND TENANT_ID = ?"; + + /*if (deviceType != null && !deviceType.isEmpty()) { + sql = sql + " AND t.NAME = ?"; + isDeviceTypeProvided = true; + }*/ + stmt = conn.prepareStatement(sql); + stmt.setInt(1, tenantId); + stmt.setInt(2, tenantId); + //int paramIdx = 2; + /*if (isDeviceTypeProvided) { + stmt.setString(paramIdx++, request.getDeviceType()); + }*/ + + rs = stmt.executeQuery(); + if (rs.next()) { + notificationCount = rs.getInt("NOTIFICATION_COUNT"); + } + } catch (SQLException e) { + throw new NotificationManagementException("Error occurred while retrieving information of all " + + "notifications", e); + } finally { + NotificationDAOUtil.cleanupResources(stmt, rs); + } + return notificationCount; + } + + + @Override public List getNotificationsByStatus(Notification.Status status, int tenantId) throws NotificationManagementException { @@ -177,6 +260,85 @@ public class NotificationDAOImpl implements NotificationDAO { return notifications; } + + @Override + public int getNotificationCountByStatus(Notification.Status status, int tenantId) throws NotificationManagementException { + int notificationCountByStatus = 0; + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + try { + conn = NotificationManagementDAOFactory.getConnection(); + + String sql = "SELECT COUNT(n1.NOTIFICATION_ID) AS NOTIFICATION_COUNT FROM " + + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + + "AND TENANT_ID = ?"; + + stmt = conn.prepareStatement(sql); + stmt.setInt(1, tenantId); + stmt.setString(2, status.toString()); + stmt.setInt(3, tenantId); + + rs = stmt.executeQuery(); + if (rs.next()) { + notificationCountByStatus = rs.getInt("NOTIFICATION_COUNT"); + } + } catch (SQLException e) { + throw new NotificationManagementException("Error occurred while retrieving information of all " + + "notifications", e); + } finally { + NotificationDAOUtil.cleanupResources(stmt, rs); + } + return notificationCountByStatus; + } + + @Override + public List getNotificationsByStatus(PaginationRequest request, Notification.Status status, int tenantId) throws + NotificationManagementException{ + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + List notifications = null; + try { + conn = NotificationManagementDAOFactory.getConnection(); + String sql = "SELECT n1.NOTIFICATION_ID, n1.DEVICE_ID, n1.OPERATION_ID, n1.STATUS," + + " n1.DESCRIPTION, d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM " + + "DM_DEVICE d, DM_DEVICE_TYPE t, (SELECT NOTIFICATION_ID, DEVICE_ID, " + + "OPERATION_ID, STATUS, DESCRIPTION FROM DM_NOTIFICATION WHERE " + + "TENANT_ID = ? AND STATUS = ?) n1 WHERE n1.DEVICE_ID = d.ID AND d.DEVICE_TYPE_ID=t.ID " + + "AND TENANT_ID = ?"; + + sql = sql + " LIMIT ?,?"; + + stmt = conn.prepareStatement(sql); + stmt.setInt(1, tenantId); + stmt.setString(2, status.toString()); + stmt.setInt(3, tenantId); + + int paramIdx = 4; + + stmt.setInt(paramIdx++, request.getStartIndex()); + stmt.setInt(paramIdx, request.getRowCount()); + + + rs = stmt.executeQuery(); + notifications = new ArrayList<>(); + while (rs.next()) { + notifications.add(this.getNotification(rs)); + } + } catch (SQLException e) { + throw new NotificationManagementException( + "Error occurred while retrieving information of all " + + "notifications by status : " + status, e); + } finally { + NotificationDAOUtil.cleanupResources(stmt, rs); + } + return notifications; + + } + private Notification getNotification(ResultSet rs) throws SQLException { Notification notification = new Notification(); notification.setNotificationId(rs.getInt("NOTIFICATION_ID")); From d9b35c29cddba83ab0fb11e80bb48bbdcd7eb458 Mon Sep 17 00:00:00 2001 From: madhawap Date: Tue, 28 Jun 2016 15:04:04 +0530 Subject: [PATCH 2/4] swagger annotation fix to policy 'apply-changes' end point --- .../device/mgt/jaxrs/service/api/PolicyManagementService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 0dc31a49fb7..9b63bd0e479 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 @@ -429,7 +429,9 @@ public interface PolicyManagementService { " the policy enforcement criteria . In a situation where you need to make changes to existing" + " policies (removing, activating, deactivating and updating) or add new policies, the existing" + " devices will not receive these changes immediately. Once all the required changes are made" + - " you need to apply the changes to push the policy changes to the existing devices.") + " you need to apply the changes to push the policy changes to the existing devices.", + tags = "Device Policy Management" + ) @ApiResponses( value = { @ApiResponse( From bb6d2f2012c68754fa91574618034c2299a39943 Mon Sep 17 00:00:00 2001 From: Chatura Dilan Date: Tue, 28 Jun 2016 16:47:16 +0530 Subject: [PATCH 3/4] Fixed user search --- .../mgt/jaxrs/service/impl/UserManagementServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index 177290e9f4e..60b4388b1f1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -348,7 +348,7 @@ public class UserManagementServiceImpl implements UserManagementService { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); //As the listUsers function accepts limit only to accommodate offset we are passing offset + limit - String[] users = userStoreManager.listUsers(appliedFilter, appliedLimit); + String[] users = userStoreManager.listUsers(appliedFilter + "*", appliedLimit); userList = new ArrayList<>(users.length); BasicUserInfo user; for (String username : users) { From d34f29ab4637ddae5e83a1cfe7921abd1695ad23 Mon Sep 17 00:00:00 2001 From: dilanua Date: Tue, 28 Jun 2016 16:50:53 +0530 Subject: [PATCH 4/4] Fixing device types not retrieving issue --- .../mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java | 1 + .../src/main/webapp/META-INF/permissions.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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 fe5088b2040..62dca8864cb 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 @@ -322,6 +322,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @GET + @Path("/types") @Override public Response getDeviceTypes() { List deviceTypes; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml index 1e254bbce1e..a92a3c184b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/META-INF/permissions.xml @@ -589,13 +589,13 @@ Deactivate Policy - /device-mgt/user/policies/add + /device-mgt/admin/policies/add /policies/deactivate-policy PUT Remove Policy - /device-mgt/user/policies/remove + /device-mgt/admin/policies/remove /policies/remove-policy POST