From b797ed1f5bb73fb1f35271ee15ca6a774008d198 Mon Sep 17 00:00:00 2001 From: Arshana Date: Sun, 16 Oct 2022 12:59:30 +0530 Subject: [PATCH] Fix context path of the API getFeaturesOfDevice --- .../mgt/jaxrs/service/api/DeviceManagementService.java | 10 +--------- .../service/impl/DeviceManagementServiceImpl.java | 7 ++----- .../service/impl/DeviceManagementServiceImplTest.java | 4 ++-- 3 files changed, 5 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/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 585e4ffecf..3304be7c14 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 @@ -1209,7 +1209,7 @@ public interface DeviceManagementService { @GET @Produces(MediaType.APPLICATION_JSON) - @Path("/{type}/{id}/features") + @Path("/device-type/{type}/features") @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", @@ -1280,14 +1280,6 @@ public interface DeviceManagementService { @PathParam("type") @Size(max = 45) String type, - @ApiParam( - name = "id", - value = "The device identifier of the device.\n" + - "INFO: Make sure to add the ID of a device that is already registered with WSO2 IoTS.", - required = true) - @PathParam("id") - @Size(max = 45) - String id, @ApiParam( name = "If-Modified-Since", value = "Checks if the requested variant was modified, since the specified date-time. \n" + 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 7570227203..3bcdeafbab 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 @@ -890,16 +890,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } @GET - @Path("/{type}/{id}/features") + @Path("/device-type/{type}/features") @Override public Response getFeaturesOfDevice( @PathParam("type") @Size(max = 45) String type, - @PathParam("id") @Size(max = 45) String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) { List features = new ArrayList<>(); DeviceManagementProviderService dms; try { - RequestValidationUtil.validateDeviceIdentifier(type, id); dms = DeviceMgtAPIUtils.getDeviceManagementService(); FeatureManager fm; try { @@ -913,8 +911,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { features = fm.getFeatures(); } } catch (DeviceManagementException e) { - String msg = "Error occurred while retrieving the list of features of '" + type + "' device, which " + - "carries the id '" + id + "'"; + String msg = "Error occurred while retrieving the list of features of '" + type + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java index 7b995660ad..db085319f0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/test/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -590,7 +590,7 @@ public class DeviceManagementServiceImplTest { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService")) .toReturn(this.deviceManagementProviderService); Response response = this.deviceManagementService - .getFeaturesOfDevice(TEST_DEVICE_TYPE, UUID.randomUUID().toString(), null); + .getFeaturesOfDevice(TEST_DEVICE_TYPE, null); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); } @@ -601,7 +601,7 @@ public class DeviceManagementServiceImplTest { Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())) .thenThrow(new DeviceTypeNotFoundException()); Response response = this.deviceManagementService - .getFeaturesOfDevice(TEST_DEVICE_TYPE, UUID.randomUUID().toString(), null); + .getFeaturesOfDevice(TEST_DEVICE_TYPE, null); Assert.assertEquals(response.getStatus(), Response.Status.NOT_FOUND.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); }