From f87a3a6b0872e13752ebf930f1d785d62602d789 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 20 Feb 2018 14:33:33 +0530 Subject: [PATCH] Fixing the issue when marking as read notification The issue occures when the notification id is larger than 45 due to the restiction on paramater size. I have removed the related validation in order to resolve the issue. --- .../api/NotificationManagementService.java | 35 +++++++++++-------- .../NotificationManagementServiceImpl.java | 2 +- 2 files changed, 21 insertions(+), 16 deletions(-) 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 8610aa34619..2f98f96030f 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 @@ -18,17 +18,17 @@ */ package org.wso2.carbon.device.mgt.jaxrs.service.api; -import io.swagger.annotations.SwaggerDefinition; -import io.swagger.annotations.Info; -import io.swagger.annotations.ExtensionProperty; -import io.swagger.annotations.Extension; -import io.swagger.annotations.Tag; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Extension; +import io.swagger.annotations.ExtensionProperty; +import io.swagger.annotations.Info; import io.swagger.annotations.ResponseHeader; +import io.swagger.annotations.SwaggerDefinition; +import io.swagger.annotations.Tag; import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.mgt.common.notification.mgt.Notification; @@ -36,9 +36,15 @@ import org.wso2.carbon.device.mgt.jaxrs.NotificationList; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.util.Constants; -import javax.validation.constraints.Max; import javax.validation.constraints.Size; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -91,9 +97,9 @@ public interface NotificationManagementService { notes = "Get the details of all the notifications that were pushed to the devices registered with WSO2 EMM using this REST API.", tags = "Device Notification Management", extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:view") - }) + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:view") + }) } ) @ApiResponses( @@ -180,9 +186,9 @@ public interface NotificationManagementService { + "change from NEW to CHECKED. This API is used to update device notification status.", tags = "Device Notification Management", extensions = { - @Extension(properties = { - @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:mark-checked") - }) + @Extension(properties = { + @ExtensionProperty(name = Constants.SCOPE, value = "perm:notifications:mark-checked") + }) } ) @ApiResponses( @@ -207,8 +213,7 @@ public interface NotificationManagementService { value = "The notification ID.", required = true, defaultValue = "1") - @PathParam("id") @Max(45) - int id); + @PathParam("id") int id); @PUT 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 8bfbb0cd7d9..7fd4a2bfa87 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 @@ -81,7 +81,7 @@ public class NotificationManagementServiceImpl implements NotificationManagement @PUT @Path("/{id}/mark-checked") - public Response updateNotificationStatus(@PathParam("id") @Max(45)int id) { + public Response updateNotificationStatus(@PathParam("id") int id) { String msg; Notification.Status status = Notification.Status.CHECKED; Notification notification;