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 122f6883fa..f33b4041fd 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 @@ -34,8 +34,8 @@ import javax.ws.rs.core.Response; @API(name = "Configuration Management", version = "1.0.0", context = "/api/device-mgt/v1.0/configuration", tags = {"devicemgt_admin"}) @Path("/configuration") -@Api(value = "Configuration Management", description = "General Tenant Configuration management capabilities are exposed " + - "through this API") +@Api(value = "Configuration Management", description = "The general platform configuration management capabilities are exposed " + + "through this API.") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public interface ConfigurationManagementService { @@ -44,14 +44,16 @@ public interface ConfigurationManagementService { @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "Get the general platform configurations.", - notes = "Get the general platform level configuration details.", + value = "Getting General Platform Configurations", + notes = "WSO2 EMM monitors policies to verify that the devices comply with the policies enforced on them. " + + "General platform configurations include the settings on how often the the device need to be monitored. " + + "Using this REST API you can get the general platform level configurations.", tags = "Configuration Management") @ApiResponses( value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched general platform configuration.", + message = "OK. \n Successfully fetched the general platform configurations.", response = PlatformConfiguration.class, responseContainer = "List", responseHeaders = { @@ -70,22 +72,23 @@ public interface ConfigurationManagementService { ), @ApiResponse( code = 304, - message = "Not Modified. \n Empty body because the client has already the latest version of " + - "the requested resource."), + message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), @ApiResponse( code = 406, - message = "Not Acceptable.\n The requested media type is not supported"), + message = "Not Acceptable.\n The requested media type is not supported."), @ApiResponse( code = 500, message = "Internal Server Error. \n Server error occurred while fetching the general " + - "platform configuration.", + "platform configurations.", response = ErrorResponse.class) }) @Permission(name = "View Configurations", permission = "/device-mgt/platform-configurations/view") Response getConfiguration( @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Checks if the requested variant was modified, since the specified date-time.\n" + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z." + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince); @@ -95,14 +98,16 @@ public interface ConfigurationManagementService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", - value = "Update General Platform Configurations.", - notes = "This resource is used to update the general platform configuration.", + value = "Updating General Platform Configurations", + notes = "WSO2 EMM monitors policies to verify that the devices comply with the policies enforced on them." + + "General platform configurations include the settings on how often the the device need to be monitored." + + "Using this REST API you can update the general platform level configurations.", tags = "Configuration Management") @ApiResponses( value = { @ApiResponse( code = 200, - message = "OK. \n General platform configuration has been updated successfully", + message = "OK. \n Successfully updated the general platform configurations.", responseHeaders = { @ResponseHeader( name = "Content-Type", @@ -120,18 +125,18 @@ public interface ConfigurationManagementService { message = "Bad Request. \n Invalid request or validation error."), @ApiResponse( code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format."), + message = "Unsupported media type. \n The format of the requested entity was not supported."), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while modifying general platform configuration.", + "Server error occurred while modifying the general platform configurations.", response = ErrorResponse.class) }) @Permission(name = "Manage configurations", permission = "/device-mgt/platform-configurations/manage") Response updateConfiguration( @ApiParam( name = "configuration", - value = "The required properties to be updated in the platform configuration.", + value = "The properties required to update the platform configurations.", required = true) PlatformConfiguration configuration); 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 c910074006..0c4fd54ea2 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 @@ -1,81 +1,118 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + package org.wso2.carbon.device.mgt.jaxrs.service.api; import io.swagger.annotations.Api; +import org.wso2.carbon.apimgt.annotations.api.API; +import org.wso2.carbon.apimgt.annotations.api.Permission; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -//@Path("/dashboard") -//@Api(value = "Dashboard", description = "Dashboard related operations are described here.") +/** + * Device Analytics Dashboard related REST-APIs. This can be used to obtain device related analytics. + */ +@API(name = "Device Analytics Dashboard", + version = "1.0.0", context = "/api/device-mgt/v1.0/dashboard", tags = {"devicemgt_admin"}) + +@Path("/dashboard") +@Api(value = "Device Analytics Dashboard", + description = "Device Analytics Dashboard related information APIs are described here.") +@Produces(MediaType.APPLICATION_JSON) @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") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + Response getOverviewDeviceCounts(); + + @GET + @Path("device-counts-by-potential-vulnerabilities") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + Response getDeviceCountsByPotentialVulnerabilities(); + + @GET + @Path("non-compliant-device-counts-by-features") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + Response getNonCompliantDeviceCountsByFeatures(@QueryParam(START_INDEX) int startIndex, + @QueryParam(RESULT_COUNT) int resultCount); + + @GET + @Path("device-counts-by-groups") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + 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") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + Response getFeatureNonCompliantDeviceCountsByGroups(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, + @QueryParam(PLATFORM) String platform, + @QueryParam(OWNERSHIP) String ownership); + @GET + @Path("filtered-device-count-over-total") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + 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") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + Response getFeatureNonCompliantDeviceCountOverTotal(@QueryParam(NON_COMPLIANT_FEATURE_CODE) String nonCompliantFeatureCode, + @QueryParam(PLATFORM) String platform, + @QueryParam(OWNERSHIP) String ownership); + + @GET + @Path("devices-with-details") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + 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") + @Permission(name = "View Dashboard", permission = "/device-mgt/dashboard/view") + 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/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 4571c02a83..0a9b5e8056 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 @@ -44,15 +44,15 @@ public interface RoleManagementService { @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "Get the list of roles.", - 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.", + value = "Getting the List of Roles", + notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Using this API you can the list of roles that are in WSO2 EMM.\n" + + "Note: Internal roles, roles created for service-providers, and application related roles will not be given in the output.", tags = "Role Management") @ApiResponses( value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched the requested list of roles.", + message = "OK. \n Successfully fetched the list of roles in WSO2 EMM.", response = RoleList.class, responseHeaders = { @ResponseHeader( @@ -69,41 +69,45 @@ public interface RoleManagementService { }), @ApiResponse( code = 304, - message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), + message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), @ApiResponse( code = 406, message = "Not Acceptable.\n The requested media type is not supported"), @ApiResponse( code = 500, - message = "Internal Server Error. \n Server error occurred while fetching requested list of roles.", + message = "Internal Server Error. \n Server error occurred while fetching list of roles.", response = ErrorResponse.class) }) @Permission(name = "View Roles", permission = "/device-mgt/roles/view") Response getRoles( @ApiParam( name = "filter", - value = "Role name or a part of it to search.", + value = "Provide a character or a few characters in the role name.", required = false) @QueryParam("filter") String filter, @ApiParam( name = "user-store", - value = "From which user store the roles must be fetched.", + value = "The name of the UserStore you wish to get the list of roles.", required = false) @QueryParam("user-store") String userStoreName, @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Checks if the requested variant was modified, since the specified date-time." + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince, @ApiParam( name = "offset", - value = "Starting point within the complete list of items qualified.", - required = false) + value = "The starting pagination index for the complete list qualified items.", + required = false, + defaultValue = "0") @QueryParam("offset") int offset, @ApiParam( name = "limit", - value = "Maximum size of resource array to return.", - required = false) + value = "Provide how many roles details you require from the starting pagination index/offset.", + required = false, + defaultValue = "5") @QueryParam("limit") int limit); @GET @@ -111,10 +115,10 @@ public interface RoleManagementService { @ApiOperation( produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "Getting permission details of a role.", - notes = "In an organization an individual is associated a with set of responsibilities based on their " + - "role. In EMM you are able to configure permissions based on the responsibilities carried " + - "out by a role. Therefore if you wish to retrieve the permission details of a role, you can do " + + value = "Getting Permission Details of a Role", + notes = "An individual is associated a with set of responsibilities based on their " + + "role. In WSO2 EMM you are able to configure permissions based on the responsibilities carried " + + "out by various roles. 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", @@ -124,7 +128,7 @@ public interface RoleManagementService { value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched the permission list of the given role.", + message = "OK. \n Successfully fetched the permissions details for the specified role.", response = UIPermissionNode.class, responseContainer = "List", responseHeaders = { @@ -142,14 +146,14 @@ public interface RoleManagementService { }), @ApiResponse( code = 304, - message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), + message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource.\n"), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Role does not exist.", + message = "Not Found. \n The specified role does not exist.", response = ErrorResponse.class), @ApiResponse( code = 406, @@ -157,19 +161,22 @@ public interface RoleManagementService { response = ErrorResponse.class), @ApiResponse( code = 500, - message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.", + message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list for the requested role.", response = ErrorResponse.class) }) @Permission(name = "View Roles", permission = "/device-mgt/roles/view") Response getPermissionsOfRole( @ApiParam( name = "roleName", - value = "Name of the role.", - required = true) + value = "The name of the role.", + required = true, + defaultValue = "Engineer") @PathParam("roleName") String roleName, @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Checks if the requested variant was modified, since the specified date-time." + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince); @@ -178,15 +185,15 @@ public interface RoleManagementService { @ApiOperation( produces = MediaType.APPLICATION_JSON, 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.", + value = "Getting Details of a Role", + notes = "Get the permissions associated with a role and role specific details using this REST API.", response = RoleInfo.class, tags = "Role Management") @ApiResponses( value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched the requested role.", + message = "OK. \n Successfully fetched the details of the role.", response = RoleInfo.class, responseHeaders = { @ResponseHeader( @@ -203,15 +210,14 @@ public interface RoleManagementService { }), @ApiResponse( code = 304, - message = "Not Modified. \n Empty body because the client has already the latest version of" + - " the requested resource."), + message = "Not Modified. \n 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 Role does not exist.", + message = "Not Found. \n The specified role does not exist.", response = ErrorResponse.class), @ApiResponse( code = 406, @@ -219,7 +225,7 @@ public interface RoleManagementService { response = ErrorResponse.class), @ApiResponse( code = 500, - message = "Internal Server Error. \n Server error occurred while fetching the " + + message = "Internal Server Error. \n Server error occurred while fetching the details of" + "requested role.", response = ErrorResponse.class) }) @@ -227,12 +233,15 @@ public interface RoleManagementService { Response getRole( @ApiParam( name = "roleName", - value = "Name of the role.", - required = true) + value = "The name of the role.", + required = true, + defaultValue = "admin") @PathParam("roleName") String roleName, @ApiParam( name = "If-Modified-Since", - value = "Validates if the requested variant has not been modified since the time specified", + value = "Checks if the requested variant was modified, since the specified date-time." + + "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince); @@ -241,17 +250,17 @@ public interface RoleManagementService { consumes = MediaType.APPLICATION_JSON, 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.", + value = "Adding a Role", + notes = "WSO2 EMM supports role-based access control (RBAC) and role management. Add a new role to WSO2 EMM using this REST API.", tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 201, - message = "Created. \n Role has successfully been created", + message = "Created. \n Successfully created the role.", responseHeaders = { @ResponseHeader( name = "Content-Location", - description = "The URL of the role added."), + description = "The URL to the newly added role."), @ResponseHeader( name = "Content-Type", description = "The content type of the body"), @@ -265,7 +274,7 @@ public interface RoleManagementService { "Used by caches, or in conditional requests.")}), @ApiResponse( code = 303, - message = "See Other. \n Source can be retrieved from the URL specified at the Location header.", + message = "See Other. \n The source can be retrieved from the URL specified in the location header.", responseHeaders = { @ResponseHeader( name = "Content-Location", @@ -276,7 +285,7 @@ public interface RoleManagementService { response = ErrorResponse.class), @ApiResponse( code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format.", + message = "Unsupported media type. \n The format of the requested entity was not supported.", response = ErrorResponse.class), @ApiResponse( code = 500, @@ -287,7 +296,7 @@ public interface RoleManagementService { Response addRole( @ApiParam( name = "role", - value = "Details about the role to be added.", + value = "The properties required to add a new role.", required = true) RoleInfo role); @PUT @@ -296,14 +305,14 @@ public interface RoleManagementService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, 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.", + value = "Updating Role Details", + notes = "There will be situations where you need to update the role details, such as the permissions" + + " or the role name. Update the role details using this REST API.", tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 200, - message = "OK. \n Role has been updated successfully", + message = "OK. \n Successfully updated the specified role.", responseHeaders = { @ResponseHeader( name = "Content-Type", @@ -314,7 +323,7 @@ public interface RoleManagementService { "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 was last modified.\n" + "Used by caches, or in conditional requests.")}), @ApiResponse( code = 400, @@ -322,11 +331,11 @@ public interface RoleManagementService { response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Role to be deleted does not exist.", + message = "Not Found. \n The specified role does not exist.", response = ErrorResponse.class), @ApiResponse( code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format.", + message = "Unsupported media type. \n The format of the requested entity was not supported.\n", response = ErrorResponse.class), @ApiResponse( code = 500, @@ -337,33 +346,34 @@ public interface RoleManagementService { Response updateRole( @ApiParam( name = "roleName", - value = "Name of the role.", - required = true) + value = "The name of the role.", + required = true, + defaultValue = "engineer") @PathParam("roleName") String roleName, @ApiParam( name = "role", - value = "Details about the role to be added.", + value = "The properties required to update a role.", required = true) RoleInfo role); @DELETE @Path("/{roleName}") @ApiOperation( 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.", + value = "Deleting a Role", + notes = "Roles become obsolete over time due to various reasons. In a situation where your Organization identifies that a specific role is no longer required, you " + + "can delete a role using this REST API.", tags = "Role Management") @ApiResponses(value = { @ApiResponse( code = 200, - message = "OK. \n Role has successfully been removed"), + message = "OK. \n Successfully removed the specified role."), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Role to be deleted does not exist.", + message = "Not Found. \n The specified role does not exist.", response = ErrorResponse.class), @ApiResponse( code = 500, @@ -374,8 +384,9 @@ public interface RoleManagementService { Response deleteRole( @ApiParam( name = "roleName", - value = "Name of the role to de deleted.", - required = true) + value = "The name of the role that needs to de deleted.", + required = true, + defaultValue = "engineer") @PathParam("roleName") String roleName); @PUT @@ -384,19 +395,19 @@ public interface RoleManagementService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", - value = "Add users to a role.", - notes = "Defining the users to a role at the point of creating a new role is optional, " + - "therefore you are able to update the users that belong to a given role after you have created " + - "a role using this REST API." + + value = "Adding Users to a Role", + notes = "Defining users to a role at the point of creating a new role is optional. " + + "You can update the users that belong to a given role after you have created " + + "a role using this REST API.\n" + "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 " + + "be cumbersome. Therefore, you can define all the new employees that belong to the engineering " + "role using this API.", tags = "Role Management") @ApiResponses( value = { @ApiResponse( code = 200, - message = "OK. \n User list of the role has been updated successfully", + message = "OK. \n Successfully added the users to the specified role.", responseHeaders = { @ResponseHeader( name = "Content-Type", @@ -415,17 +426,17 @@ public interface RoleManagementService { response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Resource to be deleted does not exist.", + message = "Not Found. \n The specified role does not exist.", response = ErrorResponse.class), @ApiResponse( code = 415, - message = "Unsupported media type. \n The entity of the request was in a not " + + message = "Unsupported media type. \n The format of the requested entity was not supported.\n" + "supported format.", response = ErrorResponse.class), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while updating the user list of the role.", + "Server error occurred while adding the user to the specified role.", response = ErrorResponse.class) }) @Permission(name = "Manage Roles", permission = "/device-mgt/roles/manage") @@ -437,7 +448,10 @@ public interface RoleManagementService { @PathParam("roleName") String roleName, @ApiParam( name = "users", - value = "List of usernames to be added.", - required = true) List users); + value = "Define the users that belong to the role.\n" + + "Multiple users can be added to a role by using comma separated values. ", + required = true, + defaultValue = "[jim]" + ) List users); } 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 7ea6d8d5c5..1a5e3440ef 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 @@ -142,6 +142,11 @@ public interface UserManagementService { value = "Username of the user to be fetched.", required = true) @PathParam("username") String username, + @ApiParam( + name = "domain", + value = "Domain name of the user store.", + required = false) + @QueryParam("domain") String domain, @ApiParam( name = "If-Modified-Since", value = "Validates if the requested variant has not been modified since the time specified", @@ -199,6 +204,11 @@ public interface UserManagementService { value = "Username of the user to be updated.", required = true) @PathParam("username") String username, + @ApiParam( + name = "domain", + value = "Domain name of the user store.", + required = false) + @QueryParam("domain") String domain, @ApiParam( name = "userData", value = "User related details.", @@ -230,7 +240,12 @@ public interface UserManagementService { @Permission(name = "Manage Users", permission = "/device-mgt/users/manage") Response removeUser( @ApiParam(name = "username", value = "Username of the user to be deleted.", required = true) - @PathParam("username") String username); + @PathParam("username") String username, + @ApiParam( + name = "domain", + value = "Domain name of the user store.", + required = false) + @QueryParam("domain") String domain); @GET @Path("/{username}/roles") @@ -279,7 +294,12 @@ public interface UserManagementService { @Permission(name = "View Users", permission = "/device-mgt/users/view") Response getRolesOfUser( @ApiParam(name = "username", value = "Username of the user.", required = true) - @PathParam("username") String username); + @PathParam("username") String username, + @ApiParam( + name = "domain", + value = "Domain name of the user store.", + required = false) + @QueryParam("domain") String domain); @GET @ApiOperation( 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 e5bf357f75..fb7acdb95b 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 @@ -49,14 +49,14 @@ public interface ApplicationManagementAdminService { consumes = MediaType.APPLICATION_JSON, 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.", + value = "Installing an Application (Internal API)", + notes = "This is an internal API that can be used to install an application on a device.", response = Activity.class, tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 202, - message = "OK. \n Install application operation will be delivered to the given devices", + message = "Accepted. \n The install application operation will be delivered to the specified devices", response = Activity.class), @ApiResponse( code = 400, @@ -64,15 +64,15 @@ public interface ApplicationManagementAdminService { response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Resource to be processed does not exist."), + message = "Not Found. \n The specified resource does not exist."), @ApiResponse( code = 415, - message = "Unsupported media type. \n The entity of the request was in a not supported format."), + message = "Unsupported media type. \n The format of the requested entity was not supported."), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while bulk issuing application installation operations upon " + - "a given set of devices.", + "Server error occurred while executing the application install operation in bulk" + + " for a specified set of devices.", response = ErrorResponse.class) }) @Permission(name = "Install/Uninstall applications", permission = "/device-mgt/applications/manage") @@ -88,14 +88,14 @@ public interface ApplicationManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "POST", - value = "Application un-installation API.(Internal API)", - notes = "This is an internal API used for application un-installation on a device.", + value = "Uninstalling an Application (Internal API)\n", + notes = "This is an internal API that can be used to uninstall an application.", response = Activity.class, tags = "Application Management Administrative Service") @ApiResponses(value = { @ApiResponse( code = 202, - message = "OK. \n Uninstall application operation will be delivered to the provided devices", + message = "Accepted. \n The uninstall application operation will be delivered to the provided devices", response = Activity.class), @ApiResponse( code = 400, @@ -103,15 +103,14 @@ public interface ApplicationManagementAdminService { response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Resource to be processed does not exist."), + message = "Not Found. \n The specified resource does not exist."), @ApiResponse( code = 415, message = "Unsupported media type. \n The entity of the request was in a not supported format."), @ApiResponse( code = 500, - message = "Internal Server Error. \n " + - "Server error occurred while bulk issuing application un-installation operations upon " + - "a given set of devices.", + message = "Internal Server Error. \n Server error occurred while executing the application install operation in bulk" + + " for a specified set of devices.", response = ErrorResponse.class) }) @Permission(name = "Install/Uninstall applications", permission = "/device-mgt/applications/manage") 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 6b18ea8367..026910d8e2 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 @@ -78,6 +78,11 @@ public interface UserManagementAdminService { @PathParam("username") @Size(max = 45) String username, + @ApiParam( + name = "domain", + value = "Domain name of the user store.", + required = false) + @QueryParam("domain") String domain, @ApiParam( name = "credentials", value = "Credential.", 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 3bf8332bdb..ba5e00d0d8 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 = "ErrorResponse 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 = "ErrorResponse 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/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 43f52d812a..8ec2f898df 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 @@ -105,8 +105,11 @@ public class UserManagementServiceImpl implements UserManagementService { @GET @Path("/{username}") @Override - public Response getUser(@PathParam("username") String username, + public Response getUser(@PathParam("username") String username, @QueryParam("domain") String domain, @HeaderParam("If-Modified-Since") String ifModifiedSince) { + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { @@ -131,7 +134,10 @@ public class UserManagementServiceImpl implements UserManagementService { @PUT @Path("/{username}") @Override - public Response updateUser(@PathParam("username") String username, UserInfo userInfo) { + public Response updateUser(@PathParam("username") String username, @QueryParam("domain") String domain, UserInfo userInfo) { + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { @@ -205,7 +211,10 @@ public class UserManagementServiceImpl implements UserManagementService { @DELETE @Path("/{username}") @Override - public Response removeUser(@PathParam("username") String username) { + public Response removeUser(@PathParam("username") String username, @QueryParam("domain") String domain) { + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { @@ -233,7 +242,10 @@ public class UserManagementServiceImpl implements UserManagementService { @GET @Path("/{username}/roles") @Override - public Response getRolesOfUser(@PathParam("username") String username) { + public Response getRolesOfUser(@PathParam("username") String username, @QueryParam("domain") String domain) { + if (domain != null && !domain.isEmpty()) { + username = domain + '/' + username; + } try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); if (!userStoreManager.isExistingUser(username)) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java index 5fad04b0d9..d268eff282 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/UserManagementAdminServiceImpl.java @@ -37,7 +37,10 @@ public class UserManagementAdminServiceImpl implements UserManagementAdminServic @Override public Response resetUserPassword(@PathParam("username") @Size(max = 45) - String user, PasswordResetWrapper credentials) { + String user, @QueryParam("domain") String domain, PasswordResetWrapper credentials) { + if (domain != null && !domain.isEmpty()) { + user = domain + '/' + user; + } return CredentialManagementResponseBuilder.buildResetPasswordResponse(user, credentials); } 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 d5febd6217..2c720b4025 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 @@ -25,8 +25,8 @@ 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") +@ApiModel(value = "Activity", description = "Each activity instance has a unique identifier that can be " + + "used to identify an operation instance.") public class Activity { public enum Type { @@ -35,21 +35,21 @@ public class Activity { @ApiModelProperty( name = "activityId", - value = "Activity identifier", + value = "The unique activity identifier", required = true) @JsonProperty("activityId") private String activityId; @ApiModelProperty( name = "code", - value = "Activity code", + value = "The activity code", required = true) @JsonProperty("code") private String code; @ApiModelProperty( name = "type", - value = "Activity type", + value = "The type of the activity, such as CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY.", required = true, allowableValues = "CONFIG, MESSAGE, INFO, COMMAND, PROFILE, POLICY") @JsonProperty("type") @@ -57,14 +57,14 @@ public class Activity { @ApiModelProperty( name = "createdTimeStamp", - value = "Timestamp recorded when the activity took place", + value = "The recorded timestamp of when the activity took place.", required = true) @JsonProperty("createdTimestamp") private String createdTimeStamp; @ApiModelProperty( name = "activityStatuses", - value = "Collection of statuses corresponding to the activity", + value = "The collection of statuses for a given activity.", required = true) @JsonProperty("activityStatuses") private List activityStatus; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag index 7465f21649..ac30769bb4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag @@ -51,7 +51,12 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { } else { response["status"] = restAPIResponse["status"]; if (restAPIResponse["responseText"]) { - response["content"] = parse(restAPIResponse["responseText"]); + var responseText = ""; + try { + response["content"] = parse(restAPIResponse["responseText"]); + } catch (e) { + responseText = restAPIResponse["responseText"]; + } } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js index 43e30b530c..b229ab8ef8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/user.js @@ -177,10 +177,18 @@ var userModule = function () { */ publicMethods.getUser = function (username) { var carbonUser = privateMethods.getCarbonUser(); + var domain; + if (username.indexOf('/') > 0) { + domain = username.substr(0, username.indexOf('/')); + username = username.substr(username.indexOf('/') + 1); + } try { utility.startTenantFlow(carbonUser); var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" + encodeURIComponent(username); + if (domain) { + url += '?domain=' + domain; + } var response = privateMethods.callBackend(url, constants["HTTP_GET"]); response["content"] = parse(response.content); response["userDomain"] = carbonUser.domain; @@ -199,10 +207,18 @@ var userModule = function () { */ publicMethods.getRolesByUsername = function (username) { var carbonUser = privateMethods.getCarbonUser(); + var domain; + if (username.indexOf('/') > 0) { + domain = username.substr(0, username.indexOf('/')); + username = username.substr(username.indexOf('/') + 1); + } try { utility.startTenantFlow(carbonUser); var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" + encodeURIComponent(username) + "/roles"; + if (domain) { + url += '?domain=' + domain; + } var response = privateMethods.callBackend(url, constants["HTTP_GET"]); if (response.status == "success") { response.content = parse(response.content).roles; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js index 1600618775..b79e7c6a07 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-protected-service-invokers.js @@ -45,12 +45,13 @@ var invokers = function () { * If the token pair is not set in the session, this will return null. */ privateMethods.getAccessToken = function () { - var tokenPair = session.get(constants["TOKEN_PAIR"]); - if (tokenPair) { - return parse(tokenPair)["accessToken"]; - } else { - return null; + if (session) { + var tokenPair = session.get(constants["TOKEN_PAIR"]); + if (tokenPair) { + return parse(tokenPair)["accessToken"]; + } } + return null; }; /** @@ -80,7 +81,7 @@ var invokers = function () { if (devicemgtProps["isOAuthEnabled"]) { var accessToken = privateMethods.getAccessToken(); - if (!accessToken) { + if (accessToken == null) { userModule.logout(function () { response.sendRedirect(devicemgtProps["appContext"] + "login"); }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js index 602dbc0544..b27dfbe698 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.roles/public/js/role-listing.js @@ -83,7 +83,7 @@ function hidePopup() { * initial mode and with out select mode. */ function InitiateViewOption() { - $(location).attr('href', $(this).data("url")); + // $(location).attr('href', $(this).data("url")); } function loadRoles() { @@ -124,8 +124,8 @@ function loadRoles() { class: "remove-padding icon-only content-fill", data: null, defaultContent: "
" + - "" + - "
" + "" + + "" }, { class: "fade-edge", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js index 295195e3f7..00357909e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.edit/public/js/bottomJs.js @@ -235,8 +235,8 @@ $(document).ready(function () { roles = []; } addUserFormData.roles = roles; - - var addUserAPI = deviceMgtBasePath + "/users/" + username; + username = username.substr(username.indexOf('/') + 1); + var addUserAPI = deviceMgtBasePath + "/users/" + username + "?domain=" + domain; invokerUtil.put( addUserAPI, diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js index 2d5b88e35b..4a69e76672 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/public/js/listing.js @@ -45,7 +45,7 @@ var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /** - * + * * Fires the res_text when ever a data table redraw occurs making * the font icons change the size to respective screen resolution. * @@ -162,9 +162,15 @@ function resetPassword(username) { } else { var resetPasswordFormData = {}; resetPasswordFormData.newPassword = unescape(confirmedPassword); - - var resetPasswordServiceURL = apiBasePath + "/admin/users/"+ username +"/credentials"; - + var domain; + if (username.indexOf('/') > 0) { + domain = username.substr(0, username.indexOf('/')); + username = username.substr(username.indexOf('/') + 1); + } + var resetPasswordServiceURL = apiBasePath + "/admin/users/" + username + "/credentials"; + if (domain) { + resetPasswordServiceURL += '?domain=' + domain; + } invokerUtil.post( resetPasswordServiceURL, resetPasswordFormData, @@ -198,7 +204,15 @@ function resetPassword(username) { * on User Listing page in WSO2 MDM Console. */ function removeUser(username) { + var domain; + if (username.indexOf('/') > 0) { + domain = username.substr(0, username.indexOf('/')); + username = username.substr(username.indexOf('/') + 1); + } var removeUserAPI = apiBasePath + "/users/" + username; + if (domain) { + removeUserAPI += '?domain=' + domain; + } $(modalPopupContent).html($('#remove-user-modal-content').html()); showPopup(); @@ -207,7 +221,11 @@ function removeUser(username) { removeUserAPI, function (data, textStatus, jqXHR) { if (jqXHR.status == 200) { - $("#user-" + username).remove(); + if (domain) { + $("#user-" + domain + "\\/" + username).remove(); + } else { + $("#user-" + username).remove(); + } // update modal-content with success message $(modalPopupContent).html($('#remove-user-success-content').html()); $("a#remove-user-success-link").click(function () { @@ -281,9 +299,11 @@ function loadUsers() { { class: "remove-padding icon-only content-fill", data: null, - defaultContent: '
' + - '' + - '
' + render: function (data, type, row, meta) { + return '
' + + '' + + '
'; + } }, { class: "fade-edge", @@ -318,7 +338,7 @@ function loadUsers() { class: "text-right content-fill text-left-on-grid-view no-wrap", data: null, render: function (data, type, row, meta) { - return '  ' + ' ' + @@ -328,8 +348,9 @@ function loadUsers() { '' + - '' + - ''; + + var resetPasswordbtn = '' + @@ -340,8 +361,9 @@ function loadUsers() { '' + - '' + - ''; + + var removebtn = '' + @@ -353,6 +375,19 @@ function loadUsers() { '  Remove' + '' + ''; + + var returnbtnSet = ''; + if($("#can-edit").length > 0) { + returnbtnSet = returnbtnSet + editbtn; + } + if($("#can-reset-password").length > 0) { + returnbtnSet = returnbtnSet + resetPasswordbtn; + } + if($("#can-remove").length > 0) { + returnbtnSet = returnbtnSet + removebtn; + } + + return returnbtnSet; } } @@ -365,14 +400,16 @@ function loadUsers() { $('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options); $(loadingContentView).hide(); + } $(document).ready(function () { loadUsers(); - $(".viewEnabledIcon").click(function () { - InitiateViewOption(); + $(function () { + $('[data-toggle="tooltip"]').tooltip() }); if (!$("#can-invite").val()) { $("#invite-user-button").remove(); } + }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js index bc14c19c2a..339b60f069 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.js @@ -25,7 +25,7 @@ $.fn.datatables_extended = function(settings){ // EMM related function if (InitiateViewOption) { - $(".viewEnabledIcon").bind("click", InitiateViewOption); + $(document).on('click','.viewEnabledIcon',InitiateViewOption); } //--- End of EMM related codes diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js index 4f4a01efc7..3dc7ce83d0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.data-tables-extended/public/js/dataTables.extended.serversidepaging.js @@ -35,7 +35,7 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte // EMM related function if (InitiateViewOption) { - $(".viewEnabledIcon").bind("click", InitiateViewOption); + $(document).on('click','.viewEnabledIcon',InitiateViewOption); } var deviceType; @@ -239,14 +239,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte $(button).addClass("active").html('Cancel'); $(button).parent().next().children("button").removeClass("disabled"); // EMM related code - $(".viewEnabledIcon").unbind("click"); + $(document).off('click','.viewEnabledIcon'); //--- End of EMM related codes } else if ($(button).html() == 'Cancel') { thisTable.removeClass("table-selectable"); $(button).addClass("active").html('Select'); $(button).parent().next().children().addClass("disabled"); // EMM related function - $(".viewEnabledIcon").bind("click", InitiateViewOption); + $(document).on('click','.viewEnabledIcon',InitiateViewOption); //--- End of EMM related codes } }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs index b17fb40676..b542e9037c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/listing.hbs @@ -22,7 +22,7 @@

- Device Notifications +

Device Notifications



diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js index 22e8da110a..29026b8278 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/js/notification-listing.js @@ -65,6 +65,15 @@ function loadNotifications() { function showAdvanceOperation(operation, button) { $(button).addClass('selected'); $(button).siblings().removeClass('selected'); + + if ($(button).attr("id") == 'allNotifications') { + $("#ast-container").html('
You do not have any unread notifications
'); + } else if ($(button).attr("id") == 'unReadNotifications') { + $("#ast-container").html('
You do not have any notifications
'); + } else { + $("#ast-container").html('
You do not have any notifications
'); + } + var hiddenOperation = ".wr-hidden-operations-content > div"; $(hiddenOperation + '[data-operation="' + operation + '"]').show(); $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); @@ -82,7 +91,7 @@ $(document).ready(function () { loadNotifications(); - $("#ast-container").on("click", ".new-notification", function(e) { + $("#ast-container").on("click", ".new-notification", function (e) { var notificationId = $(this).data("id"); // var redirectUrl = $(this).data("url"); var query = deviceMgtAPIBaseURI + "/notifications" + "/" + notificationId + "/mark-checked"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs index 2206689845..4f98c03e9b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.notification.listing/public/templates/notification-listing.hbs @@ -57,7 +57,7 @@ {{description}} - + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs index e856208e3a..1fdef264e8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.platform.configuration/configuration.hbs @@ -35,16 +35,26 @@
- - - + + + + + + + + General Configurations {{#each deviceTypes}} - - - + + + + + + + + {{label}} Configurations {{/each}} @@ -79,9 +89,7 @@ placeholder="[ Required Field ]">
- +
@@ -107,12 +115,8 @@ "Exit" to complete the process and go back to the dashboard.
- + onclick="window.location.href='{{@app.context}}/platform-configuration'">Go back to configurations +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js index a622f40543..c22b5c2923 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js @@ -66,9 +66,7 @@ $(document).ready(function () { var changePasswordFormData = {}; changePasswordFormData["oldPassword"] = unescape((currentPassword)); changePasswordFormData["newPassword"] = unescape((newPassword)); - - var changePasswordAPI = "/api/device-mgt/v1.0/users/" + user + "/credentials"; - + var changePasswordAPI = "/api/device-mgt/v1.0/users/credentials"; invokerUtil.put( changePasswordAPI, changePasswordFormData, @@ -97,4 +95,4 @@ $(document).ready(function () { hidePopup(); }); }); -}); \ No newline at end of file +}); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs index eb958f6bfc..d2aba63fdc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs @@ -46,7 +46,7 @@
- +