diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java index b417fe56a8c..0ed5d4c44b5 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/CertificateManagementAdminService.java @@ -17,8 +17,7 @@ import javax.ws.rs.core.Response; context = "api/certificate-mgt/v1.0/admin/certificates", tags = {"devicemgt_admin"}) -@Api(value = "Certificate Management", description = "This API carries all certificate management related operations " + - "such as get all the available devices, etc.") +@Api(value = "Certificate Management", description = "This API includes all the certificate management related operations") @Path("/admin/certificates") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -36,14 +35,14 @@ public interface CertificateManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "POST", - value = "Add a SSL certificate", - notes = "Add a new SSL certificate", + value = "Adding a new SSL certificate", + notes = "Add a new SSL certificate to the client end database.\n", tags = "Certificate Management") @ApiResponses( value = { @ApiResponse( code = 201, - message = "Created. \n Certificates have successfully been added", + message = "Created. \n Successfully added the certificate.", responseHeaders = { @ResponseHeader( name = "Content-Location", @@ -57,11 +56,11 @@ public interface CertificateManagementAdminService { "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 = 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", @@ -72,7 +71,7 @@ public interface CertificateManagementAdminService { 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."), @ApiResponse( code = 500, message = "Internal Server Error. \n Server error occurred while adding certificates.", @@ -82,8 +81,10 @@ public interface CertificateManagementAdminService { Response addCertificate( @ApiParam( name = "enrollmentCertificates", - value = "certificate with serial, " - + "pem and tenant id", + value = "The properties to add a new certificate. It includes the following:\n" + + "serial: The unique ID of the certificate.\n" + + "pem: Convert the OpenSSL certificate to the .pem format and base 64 encode the file.\n" + + "INFO: Upload the .pem file and base 64 encode it using a tool, such as the base64encode.in tool.", required = true) EnrollmentCertificate[] enrollmentCertificates); /** @@ -98,13 +99,13 @@ public interface CertificateManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "Getting Details of an SSL CertificateManagementAdminService", - notes = "Get the client side SSL certificate details", + value = "Getting Details of an SSL Certificate", + notes = "Get the client side SSL certificate details.", tags = "Certificate Management") @ApiResponses(value = { @ApiResponse( code = 200, - message = "OK. \n Successfully fetched information of the device.", + message = "OK. \n Successfully fetched the certificate details.", response = CertificateResponse.class, responseHeaders = { @ResponseHeader( @@ -116,7 +117,7 @@ public interface CertificateManagementAdminService { "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( @@ -129,22 +130,25 @@ public interface CertificateManagementAdminService { response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n No device is found under the provided type and id."), + message = "Not Found. \n The specified certificate does not exist."), @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while retrieving information requested certificate.", + "Server error occurred while retrieving the requested certificate information.", response = ErrorResponse.class) }) @Permission(name = "View certificates", permission = "/device-mgt/certificates/view") Response getCertificate( @ApiParam(name = "serialNumber", - value = "Provide the serial number of the certificate that you wish to get the details of", - required = true) + value = "The serial number of the certificate.", + required = true, + defaultValue = "124380353155528759302") @PathParam("serialNumber") String serialNumber, @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.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince ); @@ -159,8 +163,8 @@ public interface CertificateManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "GET", - value = "Get certificates", - notes = "You will have many certificates used for mutual SSL. In a situation where you wish to " + value = "Getting Details of Certificates", + notes = "Get all the details of the certificates you have used for mutual SSL. In a situation where you wish to " + "view all the certificate details, it is not feasible to show all the details on one " + "page therefore the details are paginated", tags = "Certificate Management" @@ -168,7 +172,7 @@ public interface CertificateManagementAdminService { @ApiResponses(value = { @ApiResponse( code = 200, - message = "OK. \n List of certificates enrolled in the system", + message = "OK. \n Successfully fetched the list of certificates.", response = CertificateList.class, responseContainer = "List", responseHeaders = { @@ -181,12 +185,12 @@ public interface CertificateManagementAdminService { "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 = 303, message = "See Other. \n " + - "Source can be retrieved from the URL specified at the Location header.", + "The source can be retrieved from the URL specified in the location header.\n", responseHeaders = { @ResponseHeader( name = "Content-Location", @@ -205,24 +209,28 @@ public interface CertificateManagementAdminService { @ApiResponse( code = 500, message = "Internal Server Error. \n " + - "Server error occurred while retrieving all certificates enrolled in the system.", + "Server error occurred while retrieving the certificate details.", response = ErrorResponse.class) }) @Permission(name = "View certificates", permission = "/device-mgt/certificates/view") Response getAllCertificates( @ApiParam( name = "offset", - value = "Starting point within the complete list of items qualified.", - required = false) + value = "The starting pagination index for the complete list of 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 certificate details you require from the starting pagination index/offset.", + required = false, + defaultValue = "5") @QueryParam("limit") int limit, @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.\n" + + "Example: Mon, 05 Jan 2014 15:10:00 +0200", required = false) @HeaderParam("If-Modified-Since") String ifModifiedSince); @@ -232,20 +240,20 @@ public interface CertificateManagementAdminService { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, httpMethod = "DELETE", - value = "Delete an SSL certificate", + value = "Deleting an SSL Certificate", notes = "Delete an SSL certificate that's on the client end", tags = "Certificate Management") @ApiResponses(value = { @ApiResponse( code = 200, - message = "OK. \n Certificate has successfully been removed"), + message = "OK. \n Successfully removed the certificate."), @ApiResponse( code = 400, message = "Bad Request. \n Invalid request or validation error.", response = ErrorResponse.class), @ApiResponse( code = 404, - message = "Not Found. \n Resource to be deleted does not exist."), + message = "Not Found. \n The specified resource does not exist."), @ApiResponse( code = 500, message = "Internal Server Error. \n " + @@ -255,9 +263,10 @@ public interface CertificateManagementAdminService { Response removeCertificate( @ApiParam( name = "serialNumber", - value = "Provide the serial number of the " - + "certificate that you wish to delete", - required = true) + value = "The serial number of the certificate.\n" + + "NOTE: Make sure that a certificate with the serial number you provide exists in the server. If no, first add a certificate.", + required = true, + defaultValue = "12438035315552875930") @PathParam("serialNumber") String serialNumber); } 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 79ed861d535..a9c010e1843 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 @@ -46,7 +46,7 @@ public interface ConfigurationManagementService { httpMethod = "GET", 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. " + + "General platform configurations include the settings on how often the device need to be monitored. " + "Using this REST API you can get the general platform level configurations.", tags = "Configuration Management") @ApiResponses( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java index 5c7b7e710d6..de032b83c7a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/DeviceManagementService.java @@ -230,6 +230,72 @@ public interface DeviceManagementService { @HeaderParam("If-Modified-Since") String ifModifiedSince); + //device delete request would looks like follows + //DELETE devices/type/virtual_firealarm/id/us06ww93auzp + @DELETE + @Path("/type/{device-type}/id/{device-id}") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = "DELETE", + value = "Delete the device speccified by device id", + notes = "Returns the status of the deleted device operation.", + tags = "Device Management") + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully fetched information of the device.", + response = Device.class, + responseHeaders = { + @ResponseHeader( + name = "Content-Type", + description = "The content type of the body"), + @ResponseHeader( + name = "ETag", + description = "Entity Tag of the response resource.\n" + + "Used by caches, or in conditional requests."), + @ResponseHeader( + name = "Last-Modified", + description = "Date and time the resource has been modified the last time.\n" + + "Used by caches, or in conditional requests."), + }), + @ApiResponse( + code = 304, + message = "Not Modified. 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 No device is found under the provided type and id.", + response = ErrorResponse.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n " + + "Server error occurred while retrieving information requested device.", + response = ErrorResponse.class) + }) + //TODO need to introduce delete permission + @Permission(name = "View Devices", permission = "/device-mgt/devices/owning-device/view") + Response deleteDevice( + @ApiParam( + name = "device-type", + value = "The device type, such as ios, android or windows.", + required = true) + @PathParam("device-type") + @Size(max = 45) + String deviceType, + @ApiParam( + name = "device-id", + value = "The device identifier of the device.", + required = true) + @PathParam("device-id") + @Size(max = 45) + String deviceId); + + @GET @Path("/{type}/{id}/features") @ApiOperation( diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java deleted file mode 100644 index a03d2b891c4..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/GroupManagementService.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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 org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@API(name = "GroupManagement", version = "1.0.0", context = "/api/device-mgt/v1.0/groups", tags = {"device_management"}) - -@Path("/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public interface GroupManagementService { - - @GET - @Permission(name = "View Group", permission = "/permission/admin/device-mgt/user/groups/list") - Response getGroups(@QueryParam("user") String user, @QueryParam("offset") int offset, - @QueryParam("limit") int limit); - - @POST - @Permission(name = "Add Group", permission = "/permission/admin/device-mgt/user/groups/add") - Response createGroup(DeviceGroup group); - - @Path("/{groupName}") - @GET - @Permission(name = "View Group", permission = "/permission/admin/device-mgt/user/groups/view") - Response getGroup(@PathParam("groupName") String groupName); - - @Path("/{groupName}") - @PUT - @Permission(name = "Update Group", permission = "/permission/admin/device-mgt/user/groups/update") - Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup); - - @Path("/{groupName}") - @DELETE - @Permission(name = "Remove Groups", permission = "/permission/admin/device-mgt/user/groups/remove") - Response deleteGroup(@PathParam("groupName") String groupName); - - @Path("/{groupName}/share-with-user") - @POST - @Permission(name = "Share Group to a User", permission = "/permission/admin/device-mgt/user/groups/share") - Response shareGroupWithUser(@PathParam("groupName") String groupName, String targetUser); - - @Path("/{groupName}/share-with-role") - @POST - @Permission(name = "Share Group to a Role", permission = "/permission/admin/device-mgt/user/groups/share") - Response shareGroupWithRole(@PathParam("groupName") String groupName, String targetRole); - - @Path("/{groupName}/remove-share-with-user") - @POST - @Permission(name = "Unshare a Group", permission = "/permission/admin/device-mgt/user/groups/unshare") - Response removeShareWithUser(@PathParam("groupName") String groupName, String targetUser); - - @Path("/{groupName}/remove-share-with-role") - @POST - @Permission(name = "Unshare a Group", permission = "/permission/admin/device-mgt/user/groups/unshare") - Response removeShareWithRole(@PathParam("groupName") String groupName, String targetUser); - - @GET - @Path("/{groupName}/users") - @Permission(name = "Get Users of Group", permission = "/permission/admin/device-mgt/user/groups/list") - Response getUsersOfGroup(@PathParam("groupName") String groupName); - - @GET - @Path("/{groupName}/devices") - @Permission(name = "Get Devices of Group", permission = "/permission/admin/device-mgt/groups/roles") - Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, - @QueryParam("limit") int limit); - - @POST - @Path("/{groupName}/devices") - @Produces("application/json") - @Permission(name = "Add Device to a Group", permission = "/permission/admin/device-mgt/user/groups/devices/add") - Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier); - - @DELETE - @Path("/{groupName}/devices") - @Permission(name = "Remove Devices from Group", - permission = "/permission/admin/device-mgt/user/groups/devices/remove") - Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, - @QueryParam("id") String id); - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java index d638f92ae02..7ed2d23388f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/PolicyManagementService.java @@ -79,7 +79,7 @@ public interface PolicyManagementService { ), @ApiResponse( code = 303, - message = "See Other. \n he source can be retrieved from the URL specified in 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", @@ -106,8 +106,7 @@ public interface PolicyManagementService { @ApiParam( name = "policy", value = "The properties required to add a new policy.", - required = true, - defaultValue = "{\"policyName\":\"test\",\"description\":\"test desc\",\"compliance\":\"ENFORCE\",\"ownershipType\":\"string\",\"active\":false,\"profile\":{\"profileId\":0,\"profileName\":\"string\",\"tenantId\":0,\"deviceType\":\"string\",\"createdDate\":\"2016-10-07T04:50:01.931Z\",\"updatedDate\":\"2016-10-07T04:50:01.931Z\",\"profileFeaturesList\":[{\"id\":0,\"featureCode\":\"string\",\"profileId\":0,\"deviceType\":\"string\",\"content\":{}}]},\"roles\":[\"string\"],\"deviceIdentifiers\":[{\"id\":\"string\",\"type\":\"string\"}],\"users\":[\"string\"]}") + required = true) @Valid PolicyWrapper policy); @GET @@ -174,7 +173,7 @@ public interface PolicyManagementService { int offset, @ApiParam( name = "limit", - value = "Maximum size of resource array to return.", + value = "Provide how many policy details you require from the starting pagination index/offset.", required = false, defaultValue = "5") @QueryParam("limit") @@ -427,7 +426,7 @@ public interface PolicyManagementService { produces = MediaType.APPLICATION_JSON, httpMethod = "PUT", value = "Applying Changes on Policies", - notes = "Policies in the active state will be applied to new device that register with WSO2 EMM based on" + + notes = "Policies in the active state will be applied to new devices that register with WSO2 EMM based on" + " the policy enforcement criteria . In a situation where you need to make changes to existing" + " policies (removing, activating, deactivating and updating) or add new policies, the existing" + " devices will not receive these changes immediately. Once all the required changes are made" + @@ -477,8 +476,7 @@ public interface PolicyManagementService { @ApiParam( name = "priorityUpdatedPolicies", value = "List of policies with priorities", - required = true, - defaultValue = "[{id:1,priority:2}]") + required = true) List priorityUpdatedPolicies); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java deleted file mode 100644 index 6894c4bac10..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/admin/GroupManagementAdminService.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.admin; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.ResponseHeader; -import org.wso2.carbon.apimgt.annotations.api.API; -import org.wso2.carbon.apimgt.annotations.api.Permission; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@API(name = "GroupManagementAdmin", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/groups", tags = {"device_management"}) - -@Path("/admin/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -@Api(value = "Group Management Administrative Service", description = "This an API intended to be used by " + - "'internal' components to log in as an admin user and do a selected number of operations. " + - "Further, this is strictly restricted to admin users only ") -public interface GroupManagementAdminService { - - @GET - @ApiOperation( - produces = MediaType.APPLICATION_JSON, - httpMethod = "GET", - value = "Grouping Devices", - notes = "Many devices can be registered with WSO2 IoTS. In order to manage them in an efficient manner, " + - "you can group devices and view the data gathered by the devices or share the groups with users so that they can monitor the devices in the respective group.", - response = DeviceGroupWrapper.class, - responseContainer = "List", - tags = "Group Management Administrative Service") - @ApiResponses(value = { - @ApiResponse(code = 200, message = "OK. \n Successfully fetched the list of groups.", - response = DeviceGroupWrapper.class, - responseContainer = "List", - responseHeaders = { - @ResponseHeader( - name = "Content-Type", - description = "The content type of the body"), - @ResponseHeader( - name = "ETag", - description = "Entity Tag of the response resource.\n" + - "Used by caches, or in conditional requests."), - @ResponseHeader( - name = "Last-Modified", - description = "Date and time the resource was last modified.\n" + - "Used by caches, or in conditional requests."), - }), - @ApiResponse( - code = 304, - 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 ErrorResponse. \n Server error occurred while fetching the list of device groups.") - }) - @Permission(name = "View All Groups", permission = "/permission/admin/device-mgt/user/groups/list") - Response getGroupsOfUser( - @ApiParam( - name = "username", - value = "The sername of the user.", - required = true) - @QueryParam("username") String username, - @ApiParam( - name = "If-Modified-Since", - value = "Timestamp of the last modified date", - required = false) - @HeaderParam("If-Modified-Since") String timestamp, - @ApiParam( - name = "offset", - value = "Starting point within the complete list of items qualified.", - required = false, - defaultValue = "0") - @QueryParam("offset") int offset, - @ApiParam( - name = "limit", - value = "Maximum size of resource array to return.", - required = false, - defaultValue = "5") - @QueryParam("limit") int limit); -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java index fa4e20d85ff..ccea8d9bd4d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -216,6 +216,20 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { } } + @DELETE + @Override + @Path("/type/{device-type}/id/{device-id}") + public Response deleteDevice(@PathParam("device-type") String deviceType, @PathParam("device-id") String deviceId) { + + log.info("Deleting " + deviceType + " " + deviceId + "is not supported"); + try { + return Response.status(Response.Status.BAD_REQUEST).entity("{Deleting device(s) is not supported}").build(); + } catch (Exception e) { + String msg = "Error occurred while deleting device(s)"; + log.error(msg, e); + return Response.serverError().entity(new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); + } + } @GET @Path("/{type}/{id}") diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java deleted file mode 100644 index 10e6fef2c92..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/GroupManagementServiceImpl.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * 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.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.common.DeviceIdentifier; -import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; -import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; -import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; -import org.wso2.carbon.device.mgt.jaxrs.service.api.GroupManagementService; -import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; -import org.wso2.carbon.policy.mgt.common.DeviceGroupWrapper; - -import javax.ws.rs.Consumes; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -@Path("/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class GroupManagementServiceImpl implements GroupManagementService { - - private static final Log log = LogFactory.getLog(GroupManagementServiceImpl.class); - - @Override - public Response getGroups(@QueryParam("user") String user, @QueryParam("offset") int offset, - @QueryParam("limit") int limit) { - try { - List groupWrappers = new ArrayList<>(); - GroupManagementProviderService service = DeviceMgtAPIUtils.getGroupManagementProviderService(); - List deviceGroups = service.getGroups(user); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - for (DeviceGroup dg : deviceGroups) { - DeviceGroupWrapper gw = new DeviceGroupWrapper(); - gw.setId(dg.getId()); - gw.setOwner(dg.getOwner()); - gw.setName(dg.getName()); - gw.setTenantId(tenantId); - groupWrappers.add(gw); - } - return Response.status(Response.Status.OK).entity(groupWrappers).build(); - } catch (GroupManagementException e) { - String error = "ErrorResponse occurred while getting the groups related to users for policy."; - log.error(error, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(error).build(); - } - } - - @Override - public Response createGroup(DeviceGroup group) { - return null; - } - - @Override - public Response getGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response updateGroup(@PathParam("groupName") String groupName, DeviceGroup deviceGroup) { - return null; - } - - @Override - public Response deleteGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response shareGroupWithUser(String groupName, String targetUser) { - return null; - } - - @Override - public Response shareGroupWithRole(String groupName, String targetRole) { - return null; - } - - @Override - public Response removeShareWithUser(@PathParam("groupName") String groupName, - @QueryParam("username") String targetUser) { - return null; - } - - @Override - public Response removeShareWithRole(@PathParam("groupName") String groupName, - @QueryParam("roleName") String targetUser) { - return null; - } - - @Override - public Response getUsersOfGroup(@PathParam("groupName") String groupName) { - return null; - } - - @Override - public Response getDevicesOfGroup(@PathParam("groupName") String groupName, @QueryParam("offset") int offset, - @QueryParam("limit") int limit) { - return null; - } - - @Override - public Response addDeviceToGroup(@PathParam("groupName") String groupName, DeviceIdentifier deviceIdentifier) { - return null; - } - - @Override - public Response removeDeviceFromGroup(@PathParam("groupName") String groupName, @QueryParam("type") String type, - @QueryParam("id") String id) { - return null; - } -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java deleted file mode 100644 index 9cf5253c2c9..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/GroupManagementAdminServiceImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.impl.admin; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.common.PaginationResult; -import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; -import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.GroupManagementAdminService; -import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@Path("/admin/groups") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class GroupManagementAdminServiceImpl implements GroupManagementAdminService { - - private static final Log log = LogFactory.getLog(GroupManagementAdminServiceImpl.class); - - @GET - @Override - public Response getGroupsOfUser( - @QueryParam("username") String username, - @HeaderParam("If-Modified-Since") String timestamp, - @QueryParam("offset") int offset, - @QueryParam("limit") int limit) { - try { - PaginationResult result = - DeviceMgtAPIUtils.getGroupManagementProviderService().getGroups(username, offset, limit); - if (result != null && result.getRecordsTotal() > 0) { - return Response.status(Response.Status.OK).entity(result).build(); - } else { - return Response.status(Response.Status.NOT_FOUND).build(); - } - } catch (GroupManagementException e) { - String msg = "ErrorResponse occurred while retrieving the groups of user '" + username + "'"; - log.error(msg, e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); - } - } - -} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml index a5f5ed308a9..18d9a09d5b1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -35,7 +35,7 @@ - + @@ -73,10 +73,10 @@ - + - + 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 1074b271cf2..d8dc9d48601 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 @@ -39,9 +39,6 @@ $(function () { }); var apiBasePath = "/api/device-mgt/v1.0"; -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; var body = "body"; /** @@ -54,31 +51,6 @@ $(document).on('draw.dt', function () { $(".icon .text").res_text(0.2); }); -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - $(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(''); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right', '0px'); - $('.modal-backdrop').remove(); -} - /** * Following click function would execute * when a user clicks on "Invite" link @@ -89,34 +61,48 @@ $("a#invite-user-link").click(function () { var inviteUserAPI = apiBasePath + "/users/send-invitation"; if (usernameList.length == 0) { - $(modalPopupContent).html($("#errorUsers").html()); + modalDialog.header("Operation cannot be performed !"); + modalDialog.content("Please select a user or a list of users to send invitation emails."); + modalDialog.footer(''); + modalDialog.showAsError(); } else { - $(modalPopupContent).html($('#invite-user-modal-content').html()); - } + modalDialog.header(""); + modalDialog.content("An invitation mail will be sent to the selected user(s) to initiate an enrolment process." + + " Do you wish to continue ?"); + modalDialog.footer('
yes' + + 'No
'); + modalDialog.show(); - showPopup(); + } $("a#invite-user-yes-link").click(function () { invokerUtil.post( inviteUserAPI, usernameList, function () { - $(modalPopupContent).html($('#invite-user-success-content').html()); + modalDialog.header("User invitation email for enrollment was successfully sent."); + modalDialog.footer(''); $("a#invite-user-success-link").click(function () { - hidePopup(); + modalPopup.hide(); }); }, function () { - $(modalPopupContent).html($('#invite-user-error-content').html()); + modalDialog.header(' Unexpected Error !'); + modalDialog.content('An unexpected error occurred. Try again later.'); + modalDialog.footer(''); $("a#invite-user-error-link").click(function () { - hidePopup(); + modalPopup.hide(); }); } ); }); $("a#invite-user-cancel-link").click(function () { - hidePopup(); + modalPopup.hide(); }); }); @@ -138,13 +124,16 @@ function getSelectedUsernames() { * on User Listing page in WSO2 MDM Console. */ function resetPassword(username) { - $(modalPopupContent).html($('#reset-password-window').html()); - showPopup(); + modalDialog.header(' Reset Password'); + modalDialog.content($("#modal-content-reset-password").html()); + modalDialog.footer(''); + modalDialog.show(); $("a#reset-password-yes-link").click(function () { - var newPassword = $("#new-password").val(); - var confirmedPassword = $("#confirmed-password").val(); - + var newPassword = $("#basic-modal-view .new-password").val(); + var confirmedPassword = $("#basic-modal-view .confirmed-password").val(); var errorMsgWrapper = "#notification-error-msg"; var errorMsg = "#notification-error-msg span"; if (!newPassword) { @@ -177,10 +166,10 @@ function resetPassword(username) { // The success callback function (data, textStatus, jqXHR) { if (jqXHR.status == 200) { - $(modalPopupContent).html($('#reset-password-success-content').html()); - $("a#reset-password-success-link").click(function () { - hidePopup(); - }); + modalDialog.header("Password reset is successful."); + modalDialog.content(""); + modalDialog.footer('
Ok
'); } }, // The error callback @@ -194,7 +183,7 @@ function resetPassword(username) { }); $("a#reset-password-cancel-link").click(function () { - hidePopup(); + modalDialog.hide(); }); } @@ -213,8 +202,16 @@ function removeUser(username) { if (domain) { removeUserAPI += '?domain=' + domain; } - $(modalPopupContent).html($('#remove-user-modal-content').html()); - showPopup(); + + modalDialog.header("Remove User"); + modalDialog.content("Do you really want to remove this user ?"); + modalDialog.footer('
Remove ' + + 'Cancel
'); + modalDialog.showAsAWarning(); + + $("a#remove-user-cancel-link").click(function () { + modalDialog.hide(); + }); $("a#remove-user-yes-link").click(function () { invokerUtil.delete( @@ -227,24 +224,24 @@ function removeUser(username) { $("#user-" + username).remove(); } // update modal-content with success message - $(modalPopupContent).html($('#remove-user-success-content').html()); - $("a#remove-user-success-link").click(function () { - hidePopup(); - }); + modalDialog.header("User Removed."); + modalDialog.content("Done. User was successfully removed."); + modalDialog.footer('
Ok
'); + } }, function () { - $(modalPopupContent).html($('#remove-user-error-content').html()); - $("a#remove-user-error-link").click(function () { - hidePopup(); - }); + modalDialog.hide(); + modalDialog.header("Operation cannot be performed !"); + modalDialog.content("An unexpected error occurred. Please try again later."); + modalDialog.footer('
Ok
'); + modalDialog.showAsError(); } ); }); - $("a#remove-user-cancel-link").click(function () { - hidePopup(); - }); } /** @@ -256,8 +253,10 @@ function InitiateViewOption() { if ($("#can-view").val()) { $(location).attr('href', $(this).data("url")); } else { - $(modalPopupContent).html($('#errorUserView').html()); - showPopup(); + modalDialog.header("Unauthorized action!"); + modalDialog.content("You don't have permissions to view users"); + modalDialog.footer('
Ok
'); + modalDialog.showAsError(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs index ea30ecbfc9f..b22af2dc104 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.users/users.hbs @@ -18,6 +18,7 @@ {{unit "cdmf.unit.ui.title" pageTitle="User Management"}} {{unit "cdmf.unit.data-tables-extended"}} +{{unit "cdmf.unit.ui.modal"}} {{#zone "breadcrumbs"}}
  • @@ -47,7 +48,7 @@ {{/zone}} {{#zone "content"}} - +
    {{#if canManage}} @@ -99,226 +100,26 @@
    -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    -