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