added 'updateNotificationStatus' endpoint and minor formattings to swagger annotations

4.x.x
madhawap 9 years ago
parent f100853031
commit dbf938416b

@ -91,7 +91,10 @@ public interface ActivityInfoProviderService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.", message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(scope = "activity-view", permissions = {"/permission/admin/device-mgt/admin/activities/view"}) @Permission(
scope = "activity-view",
permissions = {"/permission/admin/device-mgt/admin/activities/view"}
)
Response getActivity( Response getActivity(
@ApiParam( @ApiParam(
name = "id", name = "id",
@ -147,7 +150,10 @@ public interface ActivityInfoProviderService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.", message = "Internal Server ErrorResponse. \n Server error occurred while fetching activity data.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) })
@Permission(scope = "activity-view", permissions = {"/permission/admin/device-mgt/admin/activities/view"}) @Permission(
scope = "activity-view",
permissions = {"/permission/admin/device-mgt/admin/activities/view"}
)
Response getActivities( Response getActivities(
@ApiParam( @ApiParam(
name = "since", name = "since",

@ -47,7 +47,8 @@ public interface ConfigurationManagementService {
value = "Get the general platform configurations.", value = "Get the general platform configurations.",
notes = "Get the general platform level configuration details.", notes = "Get the general platform level configuration details.",
tags = "Configuration Management") tags = "Configuration Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully fetched general platform configuration.", message = "OK. \n Successfully fetched general platform configuration.",
@ -65,7 +66,8 @@ public interface ConfigurationManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ -77,15 +79,19 @@ public interface ConfigurationManagementService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the general " + message = "Internal Server ErrorResponse. \n Server error occurred while fetching the general " +
"platform configuration.", "platform configuration.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "configuration-view", )
permissions = {"/permission/admin/device-mgt/admin/platform-configs/view"}) @Permission(
scope = "configuration-view",
permissions = {"/permission/admin/device-mgt/admin/platform-configs/view"}
)
Response getConfiguration( Response getConfiguration(
@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
@ApiOperation( @ApiOperation(
@ -95,7 +101,8 @@ public interface ConfigurationManagementService {
value = "Update General Platform Configurations.", value = "Update General Platform Configurations.",
notes = "This resource is used to update the general platform configuration.", notes = "This resource is used to update the general platform configuration.",
tags = "Configuration Management") tags = "Configuration Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n General platform configuration has been updated successfully", message = "OK. \n General platform configuration has been updated successfully",
@ -125,13 +132,17 @@ public interface ConfigurationManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while modifying general platform configuration.", "Server error occurred while modifying general platform configuration.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "configuration-modify", )
permissions = {"/permission/admin/device-mgt/admin/platform-configs/modify"}) @Permission(
scope = "configuration-modify",
permissions = {"/permission/admin/device-mgt/admin/platform-configs/modify"}
)
Response updateConfiguration( Response updateConfiguration(
@ApiParam( @ApiParam(
name = "configuration", name = "configuration",
value = "The required properties to be updated in the platform configuration.", value = "The required properties to be updated in the platform configuration.",
required = true) PlatformConfiguration configuration); required = true)
PlatformConfiguration configuration);
} }

@ -88,13 +88,14 @@ public interface NotificationManagementService {
code = 500, code = 500,
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( @Permission(
scope = "device-notification-view", scope = "device-notification-view",
permissions = { 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( @ApiParam(
name = "status", name = "status",
@ -121,4 +122,15 @@ public interface NotificationManagementService {
required = false) required = false)
@QueryParam("limit") @QueryParam("limit")
int limit); int limit);
@PUT
@Path("{id}/{status}")
@ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT",
value = "",
notes = "",
tags = "Device Notification Management")
Response updateNotificationStatus(
@PathParam("id") int id);
} }

@ -69,7 +69,8 @@ public interface PolicyManagementService {
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,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.", message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
@ -93,10 +94,12 @@ public interface PolicyManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while adding a new policy.", "Server error occurred while adding a new policy.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-modify", scope = "policy-modify",
permissions = {"/permission/admin/device-mgt/admin/policies/add"}) permissions = {"/permission/admin/device-mgt/admin/policies/add"}
)
Response addPolicy( Response addPolicy(
@ApiParam( @ApiParam(
name = "policy", name = "policy",
@ -132,7 +135,8 @@ public interface PolicyManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ -148,10 +152,12 @@ public interface PolicyManagementService {
message = ("Internal Server ErrorResponse. \n Server error occurred while fetching " + message = ("Internal Server ErrorResponse. \n Server error occurred while fetching " +
"policies."), "policies."),
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-view", scope = "policy-view",
permissions = {"/permission/admin/device-mgt/admin/policies/list"}) permissions = {"/permission/admin/device-mgt/admin/policies/list"}
)
Response getPolicies( Response getPolicies(
@ApiParam( @ApiParam(
name = "If-Modified-Since", name = "If-Modified-Since",
@ -199,15 +205,15 @@ public interface PolicyManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse( @ApiResponse(
code = 404, code = 404,
message = "Not Found. \n No policy is found with the given id.", message = "Not Found. \n No policy is found with the given id.",
response = ErrorResponse.class response = ErrorResponse.class),
),
@ApiResponse( @ApiResponse(
code = 406, code = 406,
message = "Not Acceptable.\n The requested media type is not supported"), message = "Not Acceptable.\n The requested media type is not supported"),
@ -219,7 +225,8 @@ public interface PolicyManagementService {
}) })
@Permission( @Permission(
scope = "policy-view", scope = "policy-view",
permissions = {"/permission/admin/device-mgt/admin/policies/list"}) permissions = {"/permission/admin/device-mgt/admin/policies/list"}
)
Response getPolicy( Response getPolicy(
@ApiParam( @ApiParam(
name = "id", name = "id",
@ -263,7 +270,9 @@ public interface PolicyManagementService {
@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 = 400, code = 400,
message = "Bad Request. \n Invalid request or validation error.", message = "Bad Request. \n Invalid request or validation error.",
@ -280,10 +289,12 @@ public interface PolicyManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while updating the policy.", "Server error occurred while updating the policy.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-modify", scope = "policy-modify",
permissions = {"/permission/admin/device-mgt/admin/policies/update"}) permissions = {"/permission/admin/device-mgt/admin/policies/update"}
)
Response updatePolicy( Response updatePolicy(
@ApiParam( @ApiParam(
name = "id", name = "id",
@ -321,16 +332,19 @@ public interface PolicyManagementService {
response = ErrorResponse.class), response = ErrorResponse.class),
@ApiResponse( @ApiResponse(
code = 415, code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."), message = "Unsupported media type. \n The entity of the request was in a not "
+ "supported format."),
@ApiResponse( @ApiResponse(
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while bulk removing policies.", "Server error occurred while bulk removing policies.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-modify", scope = "policy-modify",
permissions = {"/permission/admin/device-mgt/admin/policies/remove"}) permissions = {"/permission/admin/device-mgt/admin/policies/remove"}
)
Response removePolicies( Response removePolicies(
@ApiParam( @ApiParam(
name = "policyIds", name = "policyIds",
@ -365,11 +379,13 @@ public interface PolicyManagementService {
code = 500, code = 500,
message = "ErrorResponse in activating policies.", message = "ErrorResponse in activating policies.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-modify", permissions = { 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( @ApiParam(
name = "policyIds", name = "policyIds",
@ -384,8 +400,8 @@ public interface PolicyManagementService {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "PUT", httpMethod = "PUT",
value = "Deactivating policies.", value = "Deactivating policies.",
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 "
"is in the active state to the inactive state.", + "policy that is in the active state to the inactive state.",
tags = "Device Policy Management") tags = "Device Policy Management")
@ApiResponses( @ApiResponses(
value = { value = {
@ -404,12 +420,14 @@ public interface PolicyManagementService {
code = 500, code = 500,
message = "ErrorResponse in deactivating policies.", message = "ErrorResponse in deactivating policies.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "policy-modify", scope = "policy-modify",
permissions = { 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( @ApiParam(
name = "policyIds", name = "policyIds",
@ -441,8 +459,12 @@ public interface PolicyManagementService {
code = 500, code = 500,
message = "ErrorResponse in deactivating policies.", message = "ErrorResponse in deactivating policies.",
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 applyChanges(); Response applyChanges();
@ -470,7 +492,8 @@ public interface PolicyManagementService {
code = 500, code = 500,
message = "Exception in updating policy priorities.", message = "Exception in updating policy priorities.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
)
@Permission( @Permission(
scope = "", scope = "",
permissions = {}) permissions = {})

@ -45,8 +45,9 @@ public interface RoleManagementService {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Get the list of roles.", value = "Get the list of roles.",
notes = "If you wish to get the details of all the roles in EMM, you can do so using this REST API. All " + notes = "If you wish to get the details of all the roles in EMM, you can do so using this REST "
"internal roles, roles created for Service-providers and application related roles are omitted.", + "API. All internal roles, roles created for Service-providers and application related "
+ "roles are omitted.",
tags = "Role Management") tags = "Role Management")
@ApiResponses( @ApiResponses(
value = { value = {
@ -64,12 +65,15 @@ public interface RoleManagementService {
"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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest "
+ "version of the requested resource."),
@ApiResponse( @ApiResponse(
code = 404, code = 404,
message = "Not Found. \n Resource does not exist.", message = "Not Found. \n Resource does not exist.",
@ -81,38 +85,47 @@ public interface RoleManagementService {
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching requested list of roles.", message = "Internal Server ErrorResponse. \n Server error occurred while fetching requested list of roles.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-view", permissions = { )
@Permission(
scope = "roles-view",
permissions = {
"/permission/admin/device-mgt/admin/roles/list", "/permission/admin/device-mgt/admin/roles/list",
"/permission/admin/device-mgt/admin/users/view", "/permission/admin/device-mgt/admin/users/view",
"/permission/admin/device-mgt/admin/policies/add", "/permission/admin/device-mgt/admin/policies/add",
"/permission/admin/device-mgt/admin/policies/update"}) "/permission/admin/device-mgt/admin/policies/update"}
)
Response getRoles( Response getRoles(
@ApiParam( @ApiParam(
name = "filter", name = "filter",
value = "Role name or a part of it to search.", value = "Role name or a part of it to search.",
required = false) required = false)
@QueryParam("filter") String filter, @QueryParam("filter")
String filter,
@ApiParam( @ApiParam(
name = "user-store", name = "user-store",
value = "From which user store the roles must be fetched.", value = "From which user store the roles must be fetched.",
required = false) required = false)
@QueryParam("user-store") String userStoreName, @QueryParam("user-store")
String userStoreName,
@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("/{roleName}/permissions") @Path("/{roleName}/permissions")
@ -120,9 +133,10 @@ public interface RoleManagementService {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Getting permission details of a role.", value = "Getting permission details of a role.",
notes = "In an organization an individual is associated a with set of responsibilities based on their " + notes = "In an organization an individual is associated a with set of responsibilities based "
"role. In EMM you are able to configure permissions based on the responsibilities carried " + + "on their role. In EMM you are able to configure permissions based on the "
"out by a role. Therefore if you wish to retrieve the permission details of a role, you can do " + + "responsibilities carried out by a role. Therefore if you wish to retrieve the "
+ "permission details of a role, you can do " +
"so using this REST API.", "so using this REST API.",
response = UIPermissionNode.class, response = UIPermissionNode.class,
responseContainer = "List", responseContainer = "List",
@ -145,12 +159,15 @@ public interface RoleManagementService {
"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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already 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.",
@ -164,21 +181,28 @@ public interface RoleManagementService {
message = "Not Acceptable.\n The requested media type is not supported"), message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse( @ApiResponse(
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the permission list of the requested role.", message = "Internal Server ErrorResponse. \n Server error occurred while fetching"
+ " the permission list of the requested role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-view", permissions = {"/permission/admin/device-mgt/admin/roles/list"}) )
@Permission(
scope = "roles-view",
permissions = {"/permission/admin/device-mgt/admin/roles/list"}
)
Response getPermissionsOfRole( Response getPermissionsOfRole(
@ApiParam( @ApiParam(
name = "roleName", name = "roleName",
value = "Name of the role.", value = "Name of the role.",
required = true) required = true)
@PathParam("roleName") String roleName, @PathParam("roleName")
String roleName,
@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("/{roleName}") @Path("/{roleName}")
@ -205,12 +229,15 @@ public interface RoleManagementService {
"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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of" + message = "Not Modified. \n Empty body because the client has already the "
+ "latest version of" +
" the requested resource."), " the requested resource."),
@ApiResponse( @ApiResponse(
code = 400, code = 400,
@ -228,19 +255,25 @@ public interface RoleManagementService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the " + message = "Internal Server ErrorResponse. \n Server error occurred while fetching the " +
"requested role.", "requested role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-view", permissions = {"/permission/admin/device-mgt/admin/roles/list"}) )
@Permission(
scope = "roles-view",
permissions = {"/permission/admin/device-mgt/admin/roles/list"}
)
Response getRole( Response getRole(
@ApiParam( @ApiParam(
name = "roleName", name = "roleName",
value = "Name of the role.", value = "Name of the role.",
required = true) required = true)
@PathParam("roleName") String roleName, @PathParam("roleName")
String roleName,
@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
@ApiOperation( @ApiOperation(
@ -250,7 +283,8 @@ public interface RoleManagementService {
value = "Add a role.", value = "Add a role.",
notes = "You are able to add a new role to EMM using the REST API.", notes = "You are able to add a new role to EMM using the REST API.",
tags = "Role Management") tags = "Role Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 201, code = 201,
message = "Created. \n Role has successfully been created", message = "Created. \n Role has successfully been created",
@ -268,33 +302,43 @@ public interface RoleManagementService {
@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,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.", message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = { responseHeaders = {
@ResponseHeader( @ResponseHeader(
name = "Content-Location", name = "Content-Location",
description = "The Source URL of the document.")}), description = "The Source URL of the document.")
}
),
@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 = 415, code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."), message = "Unsupported media type. \n The entity of the request was in a not "
+ "supported format."),
@ApiResponse( @ApiResponse(
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while adding a new role.", "Server error occurred while adding a new role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/add"}) )
@Permission(
scope = "roles-modify",
permissions = {"/permission/admin/device-mgt/admin/roles/add"}
)
Response addRole( Response addRole(
@ApiParam( @ApiParam(
name = "role", name = "role",
value = "Details about the role to be added.", value = "Details about the role to be added.",
required = true) RoleWrapper role); required = true)
RoleWrapper role);
@PUT @PUT
@Path("/{roleName}") @Path("/{roleName}")
@ -306,7 +350,8 @@ public interface RoleManagementService {
notes = "There will be situations where you will need to update the role details, such as the permissions" + notes = "There will be situations where you will need to update the role details, such as the permissions" +
" or the role name. In such situation you can update the role details.", " or the role name. In such situation you can update the role details.",
tags = "Role Management") tags = "Role Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Role has been updated successfully", message = "OK. \n Role has been updated successfully",
@ -324,7 +369,9 @@ public interface RoleManagementService {
@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 = 400, code = 400,
message = "Bad Request. \n Invalid request or validation error.", message = "Bad Request. \n Invalid request or validation error.",
@ -340,18 +387,24 @@ public interface RoleManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while updating the role.", "Server error occurred while updating the role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/update"}) )
@Permission(
scope = "roles-modify",
permissions = {"/permission/admin/device-mgt/admin/roles/update"}
)
Response updateRole( Response updateRole(
@ApiParam( @ApiParam(
name = "roleName", name = "roleName",
value = "Name of the role.", value = "Name of the role.",
required = true) required = true)
@PathParam("roleName") String roleName, @PathParam("roleName")
String roleName,
@ApiParam( @ApiParam(
name = "role", name = "role",
value = "Details about the role to be added.", value = "Details about the role to be added.",
required = true) RoleWrapper role); required = true)
RoleWrapper role);
@DELETE @DELETE
@Path("/{roleName}") @Path("/{roleName}")
@ -361,7 +414,8 @@ public interface RoleManagementService {
notes = "In a situation when your Organization identifies that a specific role is no longer required you " + notes = "In a situation when your Organization identifies that a specific role is no longer required you " +
"will need to remove the role details from EMM.", "will need to remove the role details from EMM.",
tags = "Role Management") tags = "Role Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Role has successfully been removed"), message = "OK. \n Role has successfully been removed"),
@ -377,14 +431,19 @@ public interface RoleManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while removing the role.", "Server error occurred while removing the role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/remove"}) )
@Permission(
scope = "roles-modify",
permissions = {"/permission/admin/device-mgt/admin/roles/remove"}
)
Response deleteRole( Response deleteRole(
@ApiParam( @ApiParam(
name = "roleName", name = "roleName",
value = "Name of the role to de deleted.", value = "Name of the role to de deleted.",
required = true) required = true)
@PathParam("roleName") String roleName); @PathParam("roleName")
String roleName);
@PUT @PUT
@Path("/{roleName}/users") @Path("/{roleName}/users")
@ -419,7 +478,9 @@ public interface RoleManagementService {
@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 = 400, code = 400,
message = "Bad Request. \n Invalid request or validation error.", message = "Bad Request. \n Invalid request or validation error.",
@ -435,17 +496,23 @@ public interface RoleManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while updating the user list of the role.", "Server error occurred while updating the user list of the role.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "roles-modify", permissions = {"/permission/admin/device-mgt/admin/roles/update"}) )
@Permission(
scope = "roles-modify",
permissions = {"/permission/admin/device-mgt/admin/roles/update"}
)
Response updateUsersOfRole( Response updateUsersOfRole(
@ApiParam( @ApiParam(
name = "roleName", name = "roleName",
value = "Name of the role.", value = "Name of the role.",
required = true) required = true)
@PathParam("roleName") String roleName, @PathParam("roleName")
String roleName,
@ApiParam( @ApiParam(
name = "users", name = "users",
value = "List of usernames to be added.", value = "List of usernames to be added.",
required = true) List<String> users); required = true)
List<String> users);
} }

@ -63,7 +63,9 @@ public interface UserManagementService {
@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,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.", message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
@ -86,13 +88,18 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while adding a new user.", "Server error occurred while adding a new user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/add"}) )
@Permission(
scope = "user-modify",
permissions = {"/permission/admin/device-mgt/admin/user/add"}
)
Response addUser( Response addUser(
@ApiParam( @ApiParam(
name = "user", name = "user",
value = "User related details.", value = "User related details.",
required = true) UserInfo user); required = true)
UserInfo user);
@GET @GET
@Path("/{username}") @Path("/{username}")
@ -104,7 +111,8 @@ public interface UserManagementService {
+ " you can do so using the REST API.", + " you can do so using the REST API.",
response = BasicUserInfo.class, response = BasicUserInfo.class,
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully fetched the requested role.", message = "OK. \n Successfully fetched the requested role.",
@ -121,10 +129,12 @@ public interface UserManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest "
+ "version of the requested resource."),
@ApiResponse( @ApiResponse(
code = 404, code = 404,
message = "Not Found. \n Resource does not exist.", message = "Not Found. \n Resource does not exist.",
@ -137,19 +147,25 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n Server error occurred while" + message = "Internal Server ErrorResponse. \n Server error occurred while" +
" fetching the requested user.", " fetching the requested user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/view"}) )
@Permission(
scope = "user-view",
permissions = {"/permission/admin/device-mgt/admin/user/view"}
)
Response getUser( Response getUser(
@ApiParam( @ApiParam(
name = "username", name = "username",
value = "Username of the user to be fetched.", value = "Username of the user to be fetched.",
required = true) required = true)
@PathParam("username") String username, @PathParam("username")
String username,
@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("/{username}") @Path("/{username}")
@ -161,7 +177,8 @@ public interface UserManagementService {
notes = "There will be situations where you will want to update the user details. In such " notes = "There will be situations where you will want to update the user details. In such "
+ "situation you can update the user details using this REST API.", + "situation you can update the user details using this REST API.",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n User has been updated successfully", message = "OK. \n User has been updated successfully",
@ -179,7 +196,9 @@ public interface UserManagementService {
@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 = 400, code = 400,
message = "Bad Request. \n Invalid request or validation error."), message = "Bad Request. \n Invalid request or validation error."),
@ -195,18 +214,24 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while updating the user.", "Server error occurred while updating the user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/update"}) )
@Permission(
scope = "user-modify",
permissions = {"/permission/admin/device-mgt/admin/user/update"}
)
Response updateUser( Response updateUser(
@ApiParam( @ApiParam(
name = "username", name = "username",
value = "Username of the user to be updated.", value = "Username of the user to be updated.",
required = true) required = true)
@PathParam("username") String username, @PathParam("username")
String username,
@ApiParam( @ApiParam(
name = "userData", name = "userData",
value = "User related details.", value = "User related details.",
required = true) UserInfo userData); required = true)
UserInfo userData);
@DELETE @DELETE
@Path("/{username}") @Path("/{username}")
@ -216,7 +241,8 @@ public interface UserManagementService {
notes = "In a situation where an employee leaves the organization you will need to remove the" notes = "In a situation where an employee leaves the organization you will need to remove the"
+ " user details from EMM. In such situations you can use this REST API to remove a user.", + " user details from EMM. In such situations you can use this REST API to remove a user.",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n User has successfully been removed"), message = "OK. \n User has successfully been removed"),
@ -228,13 +254,20 @@ public interface UserManagementService {
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while removing the user.", "Server error occurred while removing the user.",
response = ErrorResponse.class response = ErrorResponse.class)
}
)
@Permission(
scope = "user-modify",
permissions = {"/permission/admin/device-mgt/admin/user/remove"}
) )
})
@Permission(scope = "user-modify", permissions = {"/permission/admin/device-mgt/admin/user/remove"})
Response removeUser( Response removeUser(
@ApiParam(name = "username", value = "Username of the user to be deleted.", required = true) @ApiParam(
@PathParam("username") String username); name = "username",
value = "Username of the user to be deleted.",
required = true)
@PathParam("username")
String username);
@GET @GET
@Path("/{username}/roles") @Path("/{username}/roles")
@ -245,7 +278,8 @@ public interface UserManagementService {
notes = "A user can be assigned to one or more role in EMM. Using this REST API you are " notes = "A user can be assigned to one or more role in EMM. Using this REST API you are "
+ "able to get the role/roles a user is assigned to.", + "able to get the role/roles a user is assigned to.",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully fetched the role list assigned to the user.", message = "OK. \n Successfully fetched the role list assigned to the user.",
@ -262,7 +296,8 @@ public interface UserManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ -278,11 +313,19 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the role list" + message = "Internal Server ErrorResponse. \n Server error occurred while fetching the role list" +
" assigned to the user.", " assigned to the user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/view"}) )
@Permission(
scope = "user-view",
permissions = {"/permission/admin/device-mgt/admin/user/view"}
)
Response getRolesOfUser( Response getRolesOfUser(
@ApiParam(name = "username", value = "Username of the user.", required = true) @ApiParam(
@PathParam("username") String username); name = "username",
value = "Username of the user.",
required = true)
@PathParam("username")
String username);
@GET @GET
@ApiOperation( @ApiOperation(
@ -292,7 +335,8 @@ public interface UserManagementService {
notes = "If you wish to get the details of all the users registered with EMM, you can do so " notes = "If you wish to get the details of all the users registered with EMM, you can do so "
+ "using the REST API", + "using the REST API",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully fetched the requested role.", message = "OK. \n Successfully fetched the requested role.",
@ -309,7 +353,8 @@ public interface UserManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client already has the latest version of the requested resource."),
@ -320,29 +365,37 @@ public interface UserManagementService {
code = 500, code = 500,
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the user list.", message = "Internal Server ErrorResponse. \n Server error occurred while fetching the user list.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/list"}) )
@Permission(
scope = "user-view",
permissions = {"/permission/admin/device-mgt/admin/user/list"}
)
Response getUsers( Response getUsers(
@ApiParam( @ApiParam(
name = "filter", name = "filter",
value = "Username of the user details to be fetched.", value = "Username of the user details to be fetched.",
required = false) required = false)
@QueryParam("filter") String filter, @QueryParam("filter")
String filter,
@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
@Path("/search/usernames") @Path("/search/usernames")
@ -356,7 +409,8 @@ public interface UserManagementService {
+ "You will be given a list of users having the user name with the exact order of the " + "You will be given a list of users having the user name with the exact order of the "
+ "characters you provided.", + "characters you provided.",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Successfully fetched the username list that matches the given filter.", message = "OK. \n Successfully fetched the username list that matches the given filter.",
@ -374,7 +428,8 @@ public interface UserManagementService {
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 = 304, code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ -386,29 +441,37 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n Server error occurred while fetching the username " + message = "Internal Server ErrorResponse. \n Server error occurred while fetching the username " +
"list that matches the given filter.", "list that matches the given filter.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-view", permissions = {"/permission/admin/device-mgt/admin/user/list"}) )
@Permission(
scope = "user-view",
permissions = {"/permission/admin/device-mgt/admin/user/list"}
)
Response getUserNames( Response getUserNames(
@ApiParam( @ApiParam(
name = "filter", name = "filter",
value = "Username/part of the user name to search.", value = "Username/part of the user name to search.",
required = true) required = true)
@QueryParam("filter") String filter, @QueryParam("filter")
String filter,
@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);
@PUT @PUT
@Path("/{username}/credentials") @Path("/{username}/credentials")
@ -419,7 +482,8 @@ public interface UserManagementService {
value = "Changing the user password.", value = "Changing the user password.",
notes = "A user is able to change the password to secure their EMM profile via this REST API.", notes = "A user is able to change the password to secure their EMM profile via this REST API.",
tags = "User Management") tags = "User Management")
@ApiResponses(value = { @ApiResponses(
value = {
@ApiResponse( @ApiResponse(
code = 200, code = 200,
message = "OK. \n Credentials of the user have been updated successfully"), message = "OK. \n Credentials of the user have been updated successfully"),
@ -438,17 +502,23 @@ public interface UserManagementService {
message = "Internal Server ErrorResponse. \n " + message = "Internal Server ErrorResponse. \n " +
"Server error occurred while updating credentials of the user.", "Server error occurred while updating credentials of the user.",
response = ErrorResponse.class) response = ErrorResponse.class)
}) }
@Permission(scope = "user-modify", permissions = {"/permission/admin/login"}) )
@Permission(
scope = "user-modify",
permissions = {"/permission/admin/login"}
)
Response resetPassword( Response resetPassword(
@ApiParam( @ApiParam(
name = "username", name = "username",
value = "Username of the user.", value = "Username of the user.",
required = true) required = true)
@PathParam("username") String username, @PathParam("username")
String username,
@ApiParam( @ApiParam(
name = "credentials", name = "credentials",
value = "Credential.", value = "Credential.",
required = true) OldPasswordResetWrapper credentials); required = true)
OldPasswordResetWrapper credentials);
} }

@ -88,4 +88,29 @@ public class NotificationManagementServiceImpl implements NotificationManagement
} }
} }
@PUT
@Path("{id}/mark-checked")
public Response updateNotificationStatus(
@PathParam("id") int id) {
String msg;
Notification.Status status = Notification.Status.CHECKED;
Notification notification;
try {
DeviceMgtAPIUtils.getNotificationManagementService().updateNotificationStatus(id, status);
} catch (NotificationManagementException e) {
msg = "Error occurred while updating notification status.";
log.error(msg, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
}
try {
notification = DeviceMgtAPIUtils.getNotificationManagementService().getNotification(id);
return Response.status(Response.Status.OK).entity(notification).build();
} catch (NotificationManagementException e) {
msg = "Notification updated successfully. But the retrial of the updated notification failed";
log.error(msg, e);
return Response.status(Response.Status.OK).build();
}
}
} }

@ -71,6 +71,8 @@ public interface NotificationManagementService {
*/ */
List<Notification> getAllNotifications() throws NotificationManagementException; List<Notification> getAllNotifications() throws NotificationManagementException;
Notification getNotification(int notificationId) throws NotificationManagementException;
PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException; PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException;
/** /**

@ -160,6 +160,19 @@ public class NotificationManagementServiceImpl implements NotificationManagement
} }
} }
@Override
public Notification getNotification(int notificationId) throws NotificationManagementException {
try {
NotificationManagementDAOFactory.openConnection();
return notificationDAO.getNotification(NotificationDAOUtil.getTenantId(), notificationId);
} catch (SQLException e) {
throw new NotificationManagementException("Error occurred while opening a connection to" +
" the data source", e);
} finally {
NotificationManagementDAOFactory.closeConnection();
}
}
@Override @Override
public PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException { public PaginationResult getAllNotifications(PaginationRequest request) throws NotificationManagementException {
PaginationResult paginationResult = new PaginationResult(); PaginationResult paginationResult = new PaginationResult();

@ -71,6 +71,8 @@ public interface NotificationDAO {
*/ */
List<Notification> getAllNotifications(int tenantId) throws NotificationManagementException; List<Notification> getAllNotifications(int tenantId) throws NotificationManagementException;
Notification getNotification(int tenantId, int notificationId) throws NotificationManagementException;
List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException; List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws NotificationManagementException;
int getNotificationCount(int tenantId) throws NotificationManagementException; int getNotificationCount(int tenantId) throws NotificationManagementException;

@ -70,6 +70,35 @@ public class NotificationDAOImpl implements NotificationDAO {
return notificationId; return notificationId;
} }
@Override
public Notification getNotification(int tenantId, int notificationId) throws NotificationManagementException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs = null;
Notification notification = null;
try {
conn = NotificationManagementDAOFactory.getConnection();
String sql =
"SELECT NOTIFICATION_ID, OPERATION_ID, DESCRIPTION, STATUS FROM DM_NOTIFICATION WHERE " +
"TENANT_ID = ? AND NOTIFICATION_ID = ?";
stmt = conn.prepareStatement(sql);
stmt.setInt(1, tenantId);
stmt.setInt(2, notificationId);
rs = stmt.executeQuery();
while (rs.next()) {
notification = this.getNotification(rs);
}
} catch (SQLException e) {
throw new NotificationManagementException(
"Error occurred while retrieving information of all notifications", e);
} finally {
NotificationDAOUtil.cleanupResources(stmt, rs);
}
return notification;
}
@Override @Override
public int updateNotification(Notification notification) public int updateNotification(Notification notification)
throws NotificationManagementException { throws NotificationManagementException {

Loading…
Cancel
Save