diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ApplicationController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ApplicationController.java index 5e98c3fa06..d40a48ae57 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ApplicationController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ApplicationController.java @@ -33,7 +33,9 @@ import java.util.List; -@Api(value = "Application", description = "Provides function for manage applications", basePath = "/kaaAdmin/rest") +@Api(value = "Application", + description = "Provides function for manage applications", + basePath = "/kaaAdmin/rest") @Controller public class ApplicationController extends AbstractAdminController { @@ -44,11 +46,14 @@ public class ApplicationController extends AbstractAdminController { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get all applications", - notes = "Returns all applications for the current authorized user within the current tenant. The current user must have one of the following " + - "roles: TENANT_ADMIN, TENANT_DEVELOPER or TENANT_USER.") + notes = "Returns all applications for the current authorized user within the current tenant." + + " The current user must have one of the following " + + "roles: TENANT_ADMIN, TENANT_DEVELOPER or TENANT_USER.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN, TENANT_DEVELOPER or TENANT_USER)"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the " + + "required role (TENANT_ADMIN, TENANT_DEVELOPER or TENANT_USER)"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "applications", method = RequestMethod.GET) @ResponseBody @@ -64,18 +69,26 @@ public List getApplications() throws KaaAdminServiceException { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get application based on application token", - notes = "Returns an application by applicationToken. The current user must have one of the following roles: TENANT_ADMIN, TENANT_DEVELOPER or " + - "TENANT_USER.") + notes = "Returns an application by applicationToken. The current user must " + + "have one of the following roles: TENANT_ADMIN, TENANT_DEVELOPER or " + + "TENANT_USER.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN, TENANT_DEVELOPER, or TENANT_USER) or " + - "Tenant ID of the application does not match the Tenant ID of the user"), - @ApiResponse(code = 404, message = "An application with the specified applicationToken does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, message = "The user is not authenticated" + + " or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_ADMIN, TENANT_DEVELOPER, or TENANT_USER) or " + + "Tenant ID of the application does not match the Tenant ID of the user"), + @ApiResponse(code = 404, + message = "An application with the specified applicationToken does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "application/{applicationToken}", method = RequestMethod.GET) @ResponseBody public ApplicationDto getApplicationByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return applicationService.getApplicationByApplicationToken(applicationToken); } @@ -88,22 +101,31 @@ public ApplicationDto getApplicationByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit application", - notes = "Creates or edits an application. To create an application you do not need to specify the application ID. To edit the application " + - "specify the application ID. If the application with the specified ID exists, it will be updated. " + - "By default for ever new application used credentials service \"Trustful\", " + - "if you want to use \"Internal\" or some custom credentials service you should specify it. " + - "Only users with the TENANT_ADMIN role " + - "are allowed to perform this operation.") + notes = "Creates or edits an application. To create an application " + + "you do not need to specify the application ID. To edit the application " + + "specify the application ID. If the application with the specified ID exists, " + + "it will be updated. " + + "By default for ever new application used credentials service \"Trustful\", " + + "if you want to use \"Internal\" or some custom credentials " + + "service you should specify it. " + + "Only users with the TENANT_ADMIN role " + + "are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN) or the Tenant ID of the application " + - "to be edited does not match the Tenant ID of the user"), - @ApiResponse(code = 404, message = "An application to be edited with the specified application ID does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role (TENANT_ADMIN) " + + "or the Tenant ID of the application " + + "to be edited does not match the Tenant ID of the user"), + @ApiResponse(code = 404, message = "An application to be edited " + + "with the specified application ID does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "application", method = RequestMethod.POST) @ResponseBody public ApplicationDto editApplication( - @ApiParam(name = "application", value = "ApplicationDto body. Mandatory fields: name, tenantId", required = true) + @ApiParam(name = "application", + value = "ApplicationDto body. Mandatory fields: name, tenantId", + required = true) @RequestBody ApplicationDto application) throws KaaAdminServiceException { return applicationService.editApplication(application); } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ConfigurationController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ConfigurationController.java index 2b546ec4a6..39f0afd5f6 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ConfigurationController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ConfigurationController.java @@ -41,7 +41,9 @@ import java.nio.charset.Charset; import java.util.List; -@Api(value = "Configuration", description = "Provides function for manage configuration", basePath = "/kaaAdmin/rest") +@Api(value = "Configuration", + description = "Provides function for manage configuration", + basePath = "/kaaAdmin/rest") @Controller public class ConfigurationController extends AbstractAdminController { @@ -55,18 +57,25 @@ public class ConfigurationController extends AbstractAdminController { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get configuration schemas", - notes = "Returns all configuration schemas for the specified application. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + - "to perform this operation. The application must be associated with the user who has submitted the request.") + notes = "Returns all configuration schemas for the specified application. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to perform this operation. The application must be associated with the user " + + "who has submitted the request.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Application with the specified applicationId does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "Application with the specified " + + "applicationId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "configurationSchemas/{applicationToken}", method = RequestMethod.GET) @ResponseBody public List getConfigurationSchemasByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return configurationService.getConfigurationSchemasByApplicationToken(applicationToken); @@ -80,19 +89,30 @@ public List getConfigurationSchemasByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get vacant configuration schemas", - notes = "Returns all vacant (not being used by endpoint group configurations) configuration schemas for the specified endpoint group. Only users " + - "with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.") + notes = "Returns all vacant (not being used by endpoint group configurations) " + + "configuration schemas for the specified endpoint group. Only users " + + "with the TENANT_DEVELOPER or TENANT_USER " + + "role are allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group to be edited with the specified endpointGroupId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "vacantConfigurationSchemas/{endpointGroupId}", method = RequestMethod.GET) + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group to be edited with" + + " the specified endpointGroupId does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) + @RequestMapping(value = "vacantConfigurationSchemas/{endpointGroupId}", + method = RequestMethod.GET) @ResponseBody public List getVacantConfigurationSchemasByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @PathVariable String endpointGroupId) throws KaaAdminServiceException { return configurationService.getVacantConfigurationSchemasByEndpointGroupId(endpointGroupId); @@ -106,18 +126,26 @@ public List getVacantConfigurationSchemasByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get configuration schema", - notes = "Returns a configuration schema by configuration schema ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + - "to perform this operation.") + notes = "Returns a configuration schema by configuration schema ID. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "The configuration schema with the specified configurationSchemaId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "The configuration schema with the " + + "specified configurationSchemaId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "configurationSchema/{configurationSchemaId}", method = RequestMethod.GET) + @RequestMapping(value = "configurationSchema/{configurationSchemaId}", + method = RequestMethod.GET) @ResponseBody public ConfigurationSchemaDto getConfigurationSchema( - @ApiParam(name = "configurationSchemaId", value = "A unique configuration schema identifier", required = true) + @ApiParam(name = "configurationSchemaId", + value = "A unique configuration schema identifier", + required = true) @PathVariable String configurationSchemaId) throws KaaAdminServiceException { return configurationService.getConfigurationSchema(configurationSchemaId); } @@ -130,19 +158,27 @@ public ConfigurationSchemaDto getConfigurationSchema( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create configuration schema", - notes = "Uploads a configuration schema. A unique version number will be generated (incrementally) for the uploaded schema, and the " + - "createUsername field of the schema will be set to the name of the user who uploaded it. Only users with the TENANT_DEVELOPER or " + - "TENANT_USER role are allowed to perform this operation.") + notes = "Uploads a configuration schema. A unique version " + + "number will be generated (incrementally) for the uploaded schema, and the " + + "createUsername field of the schema will be set to " + + "the name of the user who uploaded it. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "Specified configuration schema is not a valid avro schema"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 400, + message = "Specified configuration schema is not a valid avro schema"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "saveConfigurationSchema", method = RequestMethod.POST) @ResponseBody public ConfigurationSchemaDto saveConfigurationSchema( - @ApiParam(name = "configurationSchema", value = "ConfigurationSchemaDto body", required = true) + @ApiParam(name = "configurationSchema", + value = "ConfigurationSchemaDto body", + required = true) @RequestBody ConfigurationSchemaDto configurationSchema) throws KaaAdminServiceException { return configurationService.saveConfigurationSchema(configurationSchema); } @@ -156,24 +192,36 @@ public ConfigurationSchemaDto saveConfigurationSchema( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get configuration records", - notes = "Returns all configuration records for the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are " + - "allowed to request this information.") + notes = "Returns all configuration records for the specified endpoint group. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are " + + "allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group with the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "configurationRecords", method = RequestMethod.GET) @ResponseBody public List getConfigurationRecordsByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId, - @ApiParam(name = "includeDeprecated", value = "[“true” or ”false”] if “true”, all configuration records will be returned, including deprecated " + - "ones. If “false”, only active and inactive configuration records will be returned", required = true) - @RequestParam(value = "includeDeprecated") boolean includeDeprecated) throws KaaAdminServiceException { - return configurationService.getConfigurationRecordsByEndpointGroupId(endpointGroupId, includeDeprecated); + @ApiParam(name = "includeDeprecated", + value = "[“true” or ”false”] if “true”, all configuration " + + "records will be returned, including deprecated " + + "ones. If “false”, only active and inactive configuration " + + "records will be returned", required = true) + @RequestParam(value = "includeDeprecated") boolean includeDeprecated) + throws KaaAdminServiceException { + return configurationService.getConfigurationRecordsByEndpointGroupId( + endpointGroupId, includeDeprecated); } /** @@ -185,47 +233,70 @@ public List getConfigurationRecordsByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get configuration record", - notes = "Returns the configuration record for the specified endpoint group and configuration schema. Only users with the TENANT_DEVELOPER or " + - "TENANT_USER role are allowed to request this information.") + notes = "Returns the configuration record for the specified endpoint " + + "group and configuration schema. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " + - "requested configuration record"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have " + + "the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group with the specified endpointGroupId does not exist or " + + "the endpoint group does not have the " + + "requested configuration record"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "configurationRecord", method = RequestMethod.GET) @ResponseBody public ConfigurationRecordDto getConfigurationRecord( - @ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true) + @ApiParam(name = "schemaId", + value = "A unique configuration schema identifier", + required = true) @RequestParam(value = "schemaId") String schemaId, - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) - @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) + @RequestParam(value = "endpointGroupId") String endpointGroupId) + throws KaaAdminServiceException { return configurationService.getConfigurationRecord(schemaId, endpointGroupId); } @ApiOperation(value = "Get configuration record body", - notes = "Returns the configuration record string body for the specified endpoint group and configuration schema. Only users with the " + - "TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.") + notes = "Returns the configuration record string body for the specified endpoint group " + + "and configuration schema. Only users with the " + + "TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " + - "requested configuration record"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with " + + "the specified endpointGroupId does not exist or the endpoint group does not have the " + + "requested configuration record"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "configurationRecordBody", params = {"schemaId", "endpointGroupId"}, method = RequestMethod.GET) + @RequestMapping(value = "configurationRecordBody", + params = {"schemaId", "endpointGroupId"}, + method = RequestMethod.GET) @ResponseBody @ResponseStatus(HttpStatus.OK) public String getConfigurationRecordBody( - @ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true) + @ApiParam(name = "schemaId", + value = "A unique configuration schema identifier", + required = true) @RequestParam(value = "schemaId") String schemaId, - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam("endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { - String response = configurationService.getConfigurationRecord(schemaId, endpointGroupId).getActiveStructureDto().getBody(); + String response = configurationService.getConfigurationRecord( + schemaId, endpointGroupId).getActiveStructureDto().getBody(); String decodedResponse = new String(response.getBytes(), DECODING_CHARSET); return decodedResponse; } @@ -238,21 +309,29 @@ public String getConfigurationRecordBody( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit configuration", - notes = "Creates or updates a configuration. To create configuration you do not need to specify the configuration ID, createUsername field will " + - "be set to the name of the user who has uploaded it. To edit the configuration specify the configuration id. If a configuration with the " + - "specified ID exists, the configuration will be updated and its modifyUsername will be set to the user who has submitted the request. " + - "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Creates or updates a configuration. To create configuration you do not " + + "need to specify the configuration ID, createUsername field will " + + "be set to the name of the user who has uploaded it. To edit " + + "the configuration specify the configuration id. If a configuration with the " + + "specified ID exists, the configuration will be updated and its " + + "modifyUsername will be set to the user who has submitted the request. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER " + + "role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or a configuration with the specified " + - "configurationId not found"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId " + + "does not exist or a configuration with the specified " + + "configurationId not found"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "configuration", method = RequestMethod.POST) @ResponseBody public ConfigurationDto editConfiguration( - @ApiParam(name = "configuration", value = "ConfigurationDto body. Mandatory fields: applicationId, schemaId, endpointGroupId, body", required = true) + @ApiParam(name = "configuration", value = "ConfigurationDto body. Mandatory fields: " + + "applicationId, schemaId, endpointGroupId, body", required = true) @RequestBody ConfigurationDto configuration) throws KaaAdminServiceException { return configurationService.editConfiguration(configuration); } @@ -264,21 +343,30 @@ public ConfigurationDto editConfiguration( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit user configuration", - notes = "Creates or updates a configuration for the specific user under the application. TIf a configuration with the specified user ID does not " + - "exist, then it will be created. If a configuration with the specified user ID exists, the configuration will be updated. Only users " + - "with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Creates or updates a configuration for the specific user under the application. " + + "If a configuration with the specified user ID does not " + + "exist, then it will be created. If a configuration with the specified user ID exists," + + " the configuration will be updated. Only users " + + "with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A user with the specified userId or application with the specified appToken does not exists"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "A user with the specified userId or " + + "application with the specified appToken does not exists"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "userConfiguration", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void editUserConfiguration( - @ApiParam(name = "endpointUserConfiguration", value = "EndpointUserConfigurationDto body. Mandatory fields: userId, appToken, schemaVersion, " + - "body", required = true) - @RequestBody EndpointUserConfigurationDto endpointUserConfiguration) throws KaaAdminServiceException { + @ApiParam(name = "endpointUserConfiguration", + value = "EndpointUserConfigurationDto body. " + + "Mandatory fields: userId, appToken, schemaVersion, body", + required = true) + @RequestBody EndpointUserConfigurationDto endpointUserConfiguration) + throws KaaAdminServiceException { configurationService.editUserConfiguration(endpointUserConfiguration); } @@ -290,19 +378,28 @@ public void editUserConfiguration( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Activate configuration", - notes = "Activates a configuration. Sets the status field of the configuration to ACTIVE, increments the sequenceNumber field value by 1, and " + - "sets the activateUsername and activatedTime fields to the name of the user who has submitted the request and the activation time " + - "respectively. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Activates a configuration. Sets the status field of the configuration to ACTIVE, " + + "increments the sequenceNumber field value by 1, and " + + "sets the activateUsername and activatedTime fields to the name of the user " + + "who has submitted the request and the activation time " + + "respectively. Only users with the TENANT_DEVELOPER or TENANT_USER " + + "role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Configuration with the specified configurationId not found"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Configuration with the specified configurationId not found"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "activateConfiguration", method = RequestMethod.POST) @ResponseBody public ConfigurationDto activateConfiguration( - @ApiParam(name = "configurationId", value = "A unique configuration identifier", required = true) + @ApiParam(name = "configurationId", + value = "A unique configuration identifier", + required = true) @RequestBody String configurationId) throws KaaAdminServiceException { return configurationService.activateConfiguration(configurationId); } @@ -315,19 +412,27 @@ public ConfigurationDto activateConfiguration( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Deactivate configuration", - notes = "Deactivates a configuration. Sets the status field of the configuration to DEPRECATED, sets the deactivatedTime field value to the " + - "time of the deactivation request, and sets the deactivateUsername field to the name of the user who has submitted the request. " + - "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Deactivates a configuration. Sets the status field of the configuration " + + "to DEPRECATED, sets the deactivatedTime field value to the " + + "time of the deactivation request, and sets the deactivateUsername field to " + + "the name of the user who has submitted the request. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Configuration with the specified configurationId not found"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user " + + "does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Configuration with the specified configurationId not found"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "deactivateConfiguration", method = RequestMethod.POST) @ResponseBody public ConfigurationDto deactivateConfiguration( - @ApiParam(name = "configurationId", value = "A unique configuration identifier", required = true) + @ApiParam(name = "configurationId", + value = "A unique configuration identifier", + required = true) @RequestBody String configurationId) throws KaaAdminServiceException { return configurationService.deactivateConfiguration(configurationId); } @@ -340,28 +445,39 @@ public ConfigurationDto deactivateConfiguration( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Delete configuration record", - notes = "Deletes a configuration record by configuration schema ID and endpoint group ID. Only users with the TENANT_DEVELOPER or TENANT_USER " + - "role are allowed to perform this operation.") + notes = "Deletes a configuration record by configuration schema ID " + + "and endpoint group ID. Only users with the TENANT_DEVELOPER or TENANT_USER " + + "role are allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have the " + - "requested configuration record"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group with the specified endpointGroupId does not " + + "exist or the endpoint group does not have the " + + "requested configuration record"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "delConfigurationRecord", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void deleteConfigurationRecord( - @ApiParam(name = "schemaId", value = "A unique configuration schema identifier", required = true) + @ApiParam(name = "schemaId", + value = "A unique configuration schema identifier", + required = true) @RequestParam(value = "schemaId") String schemaId, - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) - @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) + @RequestParam(value = "endpointGroupId") String endpointGroupId) + throws KaaAdminServiceException { configurationService.deleteConfigurationRecord(schemaId, endpointGroupId); } /** - * Get configuration of specific endpoint user bu externalUId + * Get configuration of specific endpoint user bu externalUId. * * @param appToken the application token * @param schemaVersion the schema version @@ -369,14 +485,19 @@ public void deleteConfigurationRecord( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint user configuration by external user id", - notes = "Get endpoint user configuration by external user id." + - " Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.") + notes = "Get endpoint user configuration by external user id." + + " Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform " + + "this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified url is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have neither TENANT_DEVELOPER " + + "nor TENANT_USER role"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "configuration/{externalUId}/{appToken}/{schemaVersion}", method = RequestMethod.GET) + @RequestMapping(value = "configuration/{externalUId}/{appToken}/{schemaVersion}", + method = RequestMethod.GET) @ResponseBody public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion( @ApiParam(name = "externalUId", value = "the external user id", required = true) @@ -385,27 +506,34 @@ public EndpointUserConfigurationDto findUserConfigurationByExternalUIdAndAppToke @PathVariable String appToken, @ApiParam(name = "schemaVersion", value = "The schema version", required = true) @PathVariable Integer schemaVersion) throws KaaAdminServiceException { - return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion(externalUId, appToken, schemaVersion); + return configurationService.findUserConfigurationByExternalUIdAndAppTokenAndSchemaVersion( + externalUId, appToken, schemaVersion); } /** - * Get configuration of specific endpoint by endpointKeyHash + * Get configuration of specific endpoint by endpointKeyHash. * * @param endpointKeyHash the endpoint key hash * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get configuration of specific endpoint by endpointKeyHash", - notes = "Get configuration of specific endpoint by endpointKeyHash." + - " Only user with TENANT_DEVELOPER and TENANT_USER roles is allowed to perform this operation.") + notes = "Get configuration of specific endpoint by endpointKeyHash." + + " Only user with TENANT_DEVELOPER and TENANT_USER roles " + + "is allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified url is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have neither TENANT_DEVELOPER nor TENANT_USER role"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have neither " + + "TENANT_DEVELOPER nor TENANT_USER role"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "configuration/{endpointKeyHash}", method = RequestMethod.GET) @ResponseBody public String findEndpointConfigurationByEndpointKeyHash( - @ApiParam(name = "endpointKeyHash", value = "A unique identifier of the endpoint", required = true) + @ApiParam(name = "endpointKeyHash", + value = "A unique identifier of the endpoint", + required = true) @PathVariable String endpointKeyHash) throws KaaAdminServiceException { return configurationService.findEndpointConfigurationByEndpointKeyHash(endpointKeyHash); } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/DeviceManagementController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/DeviceManagementController.java index 1cad3fde7a..c192a1f7cd 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/DeviceManagementController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/DeviceManagementController.java @@ -33,7 +33,9 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; -@Api(value = "Device management", description = "Provides function for device management", basePath = "/kaaAdmin/rest") +@Api(value = "Device management", + description = "Provides function for device management", + basePath = "/kaaAdmin/rest") @Controller public class DeviceManagementController extends AbstractAdminController { @@ -47,20 +49,33 @@ public class DeviceManagementController extends AbstractAdminController { * @throws KaaAdminServiceException - if an exception occures. */ @ApiOperation(value = "Provision security credentials", - notes = " Using this credentials endpoint can interact with specified application. Only users with the TENANT_ADMIN role are allowed to submit " + - "this request.") + notes = " Using this credentials endpoint can interact with specified application. " + + "Only users with the TENANT_ADMIN role are allowed to submit " + + "this request.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "Parameter conditions \"applicationToken, credentialsBody\" not met for actual request parameters"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), - @ApiResponse(code = 404, message = "The requested item was not found"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "provisionCredentials", params = {"applicationToken", "credentialsBody"}, method = RequestMethod.POST) + @ApiResponse(code = 400, + message = "Parameter conditions \"applicationToken, " + + "credentialsBody\" not met for actual request parameters"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 404, + message = "The requested item was not found"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) + @RequestMapping(value = "provisionCredentials", + params = {"applicationToken", "credentialsBody"}, + method = RequestMethod.POST) @ResponseBody public CredentialsDto provisionCredentials( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @RequestParam String applicationToken, - @ApiParam(name = "credentialsBody", value = "The public key hash of the endpoint in Base64 URL safe format", required = true) + @ApiParam(name = "credentialsBody", + value = "The public key hash of the endpoint in Base64 URL safe format", + required = true) @RequestParam String credentialsBody) throws KaaAdminServiceException { return this.deviceManagementService.provisionCredentials(applicationToken, credentialsBody); @@ -77,18 +92,28 @@ public CredentialsDto provisionCredentials( @ApiOperation(value = "Provides the status of given credentials", notes = " Only users with the TENANT_ADMIN role are allowed to submit this request.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "Parameter conditions \"applicationToken, credentialsId\" not met for actual request parameters"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), - @ApiResponse(code = 404, message = "The requested item was not found"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 400, + message = "Parameter conditions \"applicationToken, credentialsId\" not met for actual " + + "request parameters"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 404, + message = "The requested item was not found"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "credentialsStatus", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ResponseBody public CredentialsStatus getCredentialsStatus( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @RequestParam String applicationToken, - @ApiParam(name = "credentialsId", value = "A unique credentials identifier", required = true) + @ApiParam(name = "credentialsId", + value = "A unique credentials identifier", + required = true) @RequestParam String credentialsId) throws KaaAdminServiceException { return this.deviceManagementService.getCredentialsStatus(applicationToken, credentialsId); @@ -106,22 +131,36 @@ public CredentialsStatus getCredentialsStatus( @ApiOperation(value = "Bind specified endpoint profile to the credentials", notes = " Only users with the TENANT_ADMIN role are allowed to submit this request.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "provisionRegistration", params = {"applicationToken", "credentialsId", "serverProfileVersion", "serverProfileBody"}, method = RequestMethod.POST) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) + @RequestMapping(value = "provisionRegistration", + params = {"applicationToken", "credentialsId", "serverProfileVersion", "serverProfileBody"}, + method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void provisionRegistration( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @RequestParam String applicationToken, - @ApiParam(name = "credentialsId", value = "A unique credentials identifier", required = true) + @ApiParam(name = "credentialsId", + value = "A unique credentials identifier", + required = true) @RequestParam String credentialsId, - @ApiParam(name = "serverProfileVersion", value = "The version number of server-side endpoint profile", required = true) + @ApiParam(name = "serverProfileVersion", + value = "The version number of server-side endpoint profile", + required = true) @RequestParam Integer serverProfileVersion, - @ApiParam(name = "serverProfileBody", value = "The body of server-side endpoint profile", required = true) + @ApiParam(name = "serverProfileBody", + value = "The body of server-side endpoint profile", + required = true) @RequestParam String serverProfileBody) throws KaaAdminServiceException { - this.deviceManagementService.provisionRegistration(applicationToken, credentialsId, serverProfileVersion, serverProfileBody); + this.deviceManagementService.provisionRegistration( + applicationToken, credentialsId, serverProfileVersion, serverProfileBody); } /** @@ -134,18 +173,27 @@ public void provisionRegistration( * @throws KaaAdminServiceException - if an exception occures. */ @ApiOperation(value = "Revoke security credentials from the corresponding credentials storage", - notes = "Launches an asynchronous process to terminate all active sessions of the endpoint that uses these credentials. Only users with the " + - "TENANT_ADMIN role are allowed to submit this request.") + notes = "Launches an asynchronous process to terminate all active " + + "sessions of the endpoint that uses these credentials. Only users with the " + + "TENANT_ADMIN role are allowed to submit this request.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_ADMIN)"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "revokeCredentials", params = {"applicationToken", "credentialsId"}, method = RequestMethod.POST) + @RequestMapping(value = "revokeCredentials", + params = {"applicationToken", "credentialsId"}, + method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void revokeCredentials( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @RequestParam String applicationToken, - @ApiParam(name = "credentialsId", value = "A unique credentials identifier", required = true) + @ApiParam(name = "credentialsId", + value = "A unique credentials identifier", + required = true) @RequestParam String credentialsId) throws KaaAdminServiceException { this.deviceManagementService.revokeCredentials(applicationToken, credentialsId); } @@ -161,19 +209,30 @@ public void revokeCredentials( * @throws KaaAdminServiceException - if an exception occures. */ @ApiOperation(value = "Notify the Kaa cluster about security credentials revocation", - notes = "If an endpoint is already registered with the specified credentials, this API all launches an asynchronous process to terminate all " + - "active sessions of the corresponding endpoint. Only users with the TENANT_ADMIN role are allowed to submit this request.") + notes = "If an endpoint is already registered with the specified credentials, " + + "this API all launches an asynchronous process to terminate all " + + "active sessions of the corresponding endpoint. Only users with the TENANT_ADMIN " + + "role are allowed to submit this request.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), - @ApiResponse(code = 404, message = "An endpoint group to be edited with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not " + + "have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 404, message = "An endpoint group to be edited with " + + "the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "notifyRevoked", params = {"applicationToken", "credentialsId"}, method = RequestMethod.POST) + @RequestMapping(value = "notifyRevoked", + params = {"applicationToken", "credentialsId"}, + method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public void onCredentialsRevoked( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @RequestParam String applicationToken, - @ApiParam(name = "credentialsId", value = "A unique credentials identifier", required = true) + @ApiParam(name = "credentialsId", + value = "A unique credentials identifier", + required = true) @RequestParam String credentialsId) throws KaaAdminServiceException { this.deviceManagementService.onCredentialsRevoked(applicationToken, credentialsId); } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ExceptionController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ExceptionController.java index 79a8107e3b..f78a42cf39 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ExceptionController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/ExceptionController.java @@ -36,7 +36,8 @@ public class ExceptionController { private static final Logger LOG = LoggerFactory.getLogger(ExceptionController.class); @ExceptionHandler(KaaAdminServiceException.class) - public void handleKaaAdminServiceException(KaaAdminServiceException ex, HttpServletResponse response) { + public void handleKaaAdminServiceException(KaaAdminServiceException ex, + HttpServletResponse response) { try { ServiceErrorCode errorCode = ex.getErrorCode(); switch (errorCode) { @@ -66,11 +67,12 @@ public void handleKaaAdminServiceException(KaaAdminServiceException ex, HttpServ break; case CONFLICT: response.sendError(HttpServletResponse.SC_CONFLICT, ex.getMessage()); + break; default: break; } - } catch (IOException e) { - LOG.error("Can't handle exception", e); + } catch (IOException ioEx) { + LOG.error("Can't handle exception", ioEx); } } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/GroupController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/GroupController.java index 141a5c24ad..fb7764fb8d 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/GroupController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/GroupController.java @@ -48,7 +48,9 @@ import javax.servlet.http.HttpServletRequest; -@Api(value = "Grouping", description = "Provides function for manage groups", basePath = "/kaaAdmin/rest") +@Api(value = "Grouping", + description = "Provides function for manage groups", + basePath = "/kaaAdmin/rest") @Controller public class GroupController extends AbstractAdminController { @@ -82,18 +84,24 @@ public class GroupController extends AbstractAdminController { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint groups based on application token", - notes = "Returns all endpoint groups for the specified application based on application token. Only users with the TENANT_DEVELOPER or " + - "TENANT_USER role are allowed to request this information.") + notes = "Returns all endpoint groups for the specified application " + + "based on application token. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to request this information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An application with the specified applicationToken does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not " + + "have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An application with the " + + "specified applicationToken does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "endpointGroups/{applicationToken}", method = RequestMethod.GET) @ResponseBody public List getEndpointGroupsByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return groupService.getEndpointGroupsByApplicationToken(applicationToken); } @@ -106,19 +114,26 @@ public List getEndpointGroupsByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint group based on endpoint group id", - notes = "Returns an endpoint group by Endpoint Group ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + - "information.") + notes = "Returns an endpoint group by Endpoint Group ID. Only users " + + "with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + + "information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated" + + "user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with" + + "the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "endpointGroup/{endpointGroupId}", method = RequestMethod.GET) @ResponseBody public EndpointGroupDto getEndpointGroup( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @PathVariable String endpointGroupId) throws KaaAdminServiceException { return groupService.getEndpointGroup(endpointGroupId); } @@ -131,19 +146,28 @@ public EndpointGroupDto getEndpointGroup( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit endpoint group", - notes = "Creates or edits an endpoint group. To create endpoint group you do not need to specify the endpoint group ID. To edit the endpoint group" + - " specify the endpoint group ID. If an endpoint group with the specified id exists, it will be updated. Only users with the " + - "TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Creates or edits an endpoint group. To create endpoint group you do not need " + + "to specify the endpoint group ID. To edit the endpoint group" + + " specify the endpoint group ID. If an endpoint group with the " + + "specified id exists, it will be updated. Only users with the " + + "TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group to be edited with the specified endpointGroupId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have " + + "the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group to be edited " + + "with the specified endpointGroupId does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "endpointGroup", method = RequestMethod.POST) @ResponseBody public EndpointGroupDto editEndpointGroup( - @ApiParam(name = "endpointGroup", value = "EndpointGroupDto body. Mandatory fields: name, applicationId, weight", required = true) + @ApiParam(name = "endpointGroup", + value = "EndpointGroupDto body. Mandatory fields: name, applicationId, weight", + required = true) @RequestBody EndpointGroupDto endpointGroup) throws KaaAdminServiceException { return groupService.editEndpointGroup(endpointGroup); } @@ -155,20 +179,28 @@ public EndpointGroupDto editEndpointGroup( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Delete endpoint group", - notes = "Deletes an endpoint group specified by endpoint group ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + - "perform this operation.") + notes = "Deletes an endpoint group specified by endpoint group ID. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + + "perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "delEndpointGroup", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void deleteEndpointGroup( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) - @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) + @RequestParam(value = "endpointGroupId") String endpointGroupId) + throws KaaAdminServiceException { groupService.deleteEndpointGroup(endpointGroupId); } @@ -181,24 +213,34 @@ public void deleteEndpointGroup( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get profile filter records", - notes = "Returns all profile filter records for the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are " + - "allowed to request this information.") + notes = "Returns all profile filter records for the specified endpoint group. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are " + + "allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId/includeDeprecated supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated" + + " or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required " + + "role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with the specified " + + "endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "profileFilterRecords", method = RequestMethod.GET) @ResponseBody public List getProfileFilterRecordsByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId, - @ApiParam(name = "includeDeprecated", value = "[“true” or ”false”] if “true”, all profile filter records will be returned, including deprecated " + - "ones. If “false”, only active and inactive profile filter records will be returned", required = true) - @RequestParam(value = "includeDeprecated") boolean includeDeprecated) throws KaaAdminServiceException { - return groupService.getProfileFilterRecordsByEndpointGroupId(endpointGroupId, includeDeprecated); + @ApiParam(name = "includeDeprecated", value = "[“true” or ”false”] if “true”, all profile " + + "filter records will be returned, including deprecated " + + "ones. If “false”, only active and inactive profile filter records will be returned", + required = true) + @RequestParam(value = "includeDeprecated") boolean includeDeprecated) + throws KaaAdminServiceException { + return groupService.getProfileFilterRecordsByEndpointGroupId( + endpointGroupId, includeDeprecated); } /** @@ -211,27 +253,41 @@ public List getProfileFilterRecordsByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get profile filter record", - notes = "Returns the profile filter record for the specified endpoint group and profile schema. Only users with the TENANT_DEVELOPER or " + - "TENANT_USER role are allowed to request this information. You need to provide either endpointProfileSchemaId or serverProfileSchemaId " + - "parameter or use both of them with endpointGroupId parameter.") + notes = "Returns the profile filter record for the specified endpoint group and " + + "profile schema. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to request this information. You need to provide either " + + "endpointProfileSchemaId or serverProfileSchemaId " + + "parameter or use both of them with endpointGroupId parameter.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or endpoint group does not have the " + - "specified profile filter record"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required " + + "role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId " + + "does not exist or endpoint group does not have the " + + "specified profile filter record"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "profileFilterRecord", method = RequestMethod.GET) @ResponseBody public ProfileFilterRecordDto getProfileFilterRecord( - @ApiParam(name = "endpointProfileSchemaId", value = "The client-side endpoint profile schema ID", required = false) - @RequestParam(value = "endpointProfileSchemaId", required = false) String endpointProfileSchemaId, - @ApiParam(name = "serverProfileSchemaId", value = "The server-side endpoint profile schema ID", required = false) - @RequestParam(value = "serverProfileSchemaId", required = false) String serverProfileSchemaId, - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) - @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { - return groupService.getProfileFilterRecord(endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId); + @ApiParam(name = "endpointProfileSchemaId", + value = "The client-side endpoint profile schema ID", + required = false) + @RequestParam(value = "endpointProfileSchemaId", + required = false) String endpointProfileSchemaId, + @ApiParam(name = "serverProfileSchemaId", + value = "The server-side endpoint profile schema ID", + required = false) + @RequestParam(value = "serverProfileSchemaId", + required = false) String serverProfileSchemaId, + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", required = true) + @RequestParam(value = "endpointGroupId") String endpointGroupId) + throws KaaAdminServiceException { + return groupService.getProfileFilterRecord( + endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId); } /** @@ -242,19 +298,27 @@ public ProfileFilterRecordDto getProfileFilterRecord( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get vacant profile schemas", - notes = "Returns all vacant (not being used by endpoint group profile filters) profile schemas for the specified endpoint group. Only users " + - "with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.") + notes = "Returns all vacant (not being used by endpoint group profile filters) " + + "profile schemas for the specified endpoint group. Only users " + + "with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does " + + "not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID " + + "of the authenticated user"), + @ApiResponse(code = 404, message = "An endpoint group with the specified " + + "endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "vacantProfileSchemas/{endpointGroupId}", method = RequestMethod.GET) @ResponseBody public List getVacantProfileSchemasByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @PathVariable String endpointGroupId) throws KaaAdminServiceException { return groupService.getVacantProfileSchemasByEndpointGroupId(endpointGroupId); @@ -268,22 +332,32 @@ public List getVacantProfileSchemasByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/edit profile filter", - notes = "Creates or updates a profile filter. To create profile filter you do not need to specify the profile filter ID, createUsername field " + - "will be set to the name of the user who has created it. To edit the profile filter specify the profile filer ID, if a profile filter " + - "with the specified ID exists, the profile filter will be updated and its modifyUsername will be set to the user who has submitted the " + - "request. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Creates or updates a profile filter. To create profile filter you do not " + + "need to specify the profile filter ID, createUsername field " + + "will be set to the name of the user who has created it. To edit the profile filter " + + "specify the profile filer ID, if a profile filter " + + "with the specified ID exists, the profile filter will be updated and " + + "its modifyUsername will be set to the user who has submitted the " + + "request. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or existing profile filter with the " + - "specified profileFilterId not found"), + @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId " + + "does not exist or existing profile filter with the " + + "specified profileFilterId not found"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "profileFilter", method = RequestMethod.POST) @ResponseBody public ProfileFilterDto editProfileFilter( - @ApiParam(name = "profileFilter", value = "ProfileFilterDto body. Mandatory fields: applicationId, body, either endpointProfileSchemaId or " + - "serverProfileSchemaId or both of them", required = true) + @ApiParam(name = "profileFilter", + value = "ProfileFilterDto body. Mandatory fields: applicationId," + + "body, either endpointProfileSchemaId or " + + "serverProfileSchemaId or both of them", + required = true) @RequestBody ProfileFilterDto profileFilter) throws KaaAdminServiceException { return groupService.editProfileFilter(profileFilter); } @@ -296,19 +370,29 @@ public ProfileFilterDto editProfileFilter( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Activate profile filter", - notes = "Activates a profile filter. Sets the status field of the profile filter to ACTIVE, increments the sequenceNumber field value by 1, " + - "and sets the activateUsername and activatedTime fields to the name of the user who submitted the request and the activation time " + - "respectively. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Activates a profile filter. Sets the status field of the profile filter to " + + "ACTIVE, increments the sequenceNumber field value by 1, " + + "and sets the activateUsername and activatedTime fields to the name of the user " + + "who submitted the request and the activation time " + + "respectively. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Profile filter with the specified profileFilterId not found"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Profile filter with the specified profileFilterId not found"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "activateProfileFilter", method = RequestMethod.POST) @ResponseBody public ProfileFilterDto activateProfileFilter( - @ApiParam(name = "profileFilterId", value = "A unique profile filter identifier", required = true) + @ApiParam(name = "profileFilterId", + value = "A unique profile filter identifier", + required = true) @RequestBody String profileFilterId) throws KaaAdminServiceException { return groupService.activateProfileFilter(profileFilterId); } @@ -321,19 +405,29 @@ public ProfileFilterDto activateProfileFilter( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Deactivate profile filter", - notes = "Deactivates a profile filter. Sets the status field of the profile filter to DEPRECATED, sets the deactivatedTime field value to the " + - "time of the deactivation request, and sets the deactivateUsername field to the name of the user who has submitted the request. " + - "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Deactivates a profile filter. Sets the status field of the profile " + + "filter to DEPRECATED, sets the deactivatedTime field value to the " + + "time of the deactivation request, and sets the deactivateUsername field " + + "to the name of the user who has submitted the request. " + + "Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Profile filter with the specified profileFilterId not found"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Profile filter with the specified profileFilterId not found"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "deactivateProfileFilter", method = RequestMethod.POST) @ResponseBody public ProfileFilterDto deactivateProfileFilter( - @ApiParam(name = "profileFilterId", value = "A unique profile filter identifier", required = true) + @ApiParam(name = "profileFilterId", + value = "A unique profile filter identifier", + required = true) @RequestBody String profileFilterId) throws KaaAdminServiceException { return groupService.deactivateProfileFilter(profileFilterId); } @@ -347,27 +441,41 @@ public ProfileFilterDto deactivateProfileFilter( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Delete profile filter record", - notes = "Deletes a profile filter record based on client-side endpoint profile schema ID, server-side endpoint profile schema ID and " + - "endpoint group ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation." + - "You need to provide either endpointProfileSchemaId or serverProfileSchemaId parameter or use both of them with endpointGroupId parameter.") + notes = "Deletes a profile filter record based on client-side endpoint profile " + + "schema ID, server-side endpoint profile schema ID and " + + "endpoint group ID. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation." + + "You need to provide either endpointProfileSchemaId or serverProfileSchemaId parameter" + + " or use both of them with endpointGroupId parameter.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "Invalid endpointGroupId/endpointProfileSchemaId/serverProfileSchemaId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + @ApiResponse(code = 400, message = "Invalid endpointGroupId/endpointProfileSchemaId/" + + "serverProfileSchemaId supplied"), + @ApiResponse(code = 401, message = "The user is not authenticated or " + + "invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the " + + "required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist or the endpoint group does not have " + - "the specified profile filter record"), + @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId " + + "does not exist or the endpoint group does not have " + + "the specified profile filter record"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "delProfileFilterRecord", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void deleteProfileFilterRecord( - @ApiParam(name = "endpointProfileSchemaId", value = "The client-side endpoint profile schema ID") - @RequestParam(value = "endpointProfileSchemaId", required = false) String endpointProfileSchemaId, - @ApiParam(name = "serverProfileSchemaId", value = "The server-side endpoint profile schema ID") - @RequestParam(value = "serverProfileSchemaId", required = false) String serverProfileSchemaId, - @ApiParam(name = "endpointGroupId", value = "The ID of the endpoint group.", required = true) - @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { - groupService.deleteProfileFilterRecord(endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId); + @ApiParam(name = "endpointProfileSchemaId", + value = "The client-side endpoint profile schema ID") + @RequestParam(value = "endpointProfileSchemaId", + required = false) String endpointProfileSchemaId, + @ApiParam(name = "serverProfileSchemaId", + value = "The server-side endpoint profile schema ID") + @RequestParam(value = "serverProfileSchemaId", + required = false) String serverProfileSchemaId, + @ApiParam(name = "endpointGroupId", + value = "The ID of the endpoint group.", required = true) + @RequestParam(value = "endpointGroupId") String endpointGroupId) + throws KaaAdminServiceException { + groupService.deleteProfileFilterRecord( + endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId); } /** @@ -381,28 +489,42 @@ public void deleteProfileFilterRecord( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint profiles based on endpoint group id", - notes = "Returns the endpoint profiles based on endpoint group id. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + - "to request this information. Default limit value equals \"20\", default offset value equals \"0\". Maximum limit value is \"500\".") + notes = "Returns the endpoint profiles based on endpoint group id. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to request this information. Default limit value equals \"20\", " + + "default offset value equals \"0\". Maximum limit value is \"500\".") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId/limit/offset supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the " + + "required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Endpoint group with the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "endpointProfileByGroupId", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) + @RequestMapping(value = "endpointProfileByGroupId", + method = RequestMethod.GET, + produces = APPLICATION_JSON_VALUE) @ResponseBody public EndpointProfilesPageDto getEndpointProfileByEndpointGroupId( @ApiParam(name = "endpointGroupId", value = "The id of the endpoint group.", required = true) @RequestParam("endpointGroupId") String endpointGroupId, - @ApiParam(name = "limit", value = "The maximum number of shown profiles. (optional parameter)", defaultValue = DEFAULT_LIMIT, required = false) + @ApiParam(name = "limit", + value = "The maximum number of shown profiles. (optional parameter)", + defaultValue = DEFAULT_LIMIT, required = false) @RequestParam(value = "limit", defaultValue = DEFAULT_LIMIT, required = false) String limit, - @ApiParam(name = "offset", value = "The offset from beginning of profiles list. (Optional parameter)", defaultValue = DEFAULT_OFFSET, + @ApiParam(name = "offset", + value = "The offset from beginning of profiles list. (Optional parameter)", + defaultValue = DEFAULT_OFFSET, required = false) - @RequestParam(value = "offset", defaultValue = DEFAULT_OFFSET, required = false) String offset, + @RequestParam(value = "offset", + defaultValue = DEFAULT_OFFSET, required = false) String offset, HttpServletRequest request) throws KaaAdminServiceException { - EndpointProfilesPageDto endpointProfilesPageDto = groupService.getEndpointProfileByEndpointGroupId(endpointGroupId, limit, - offset); + EndpointProfilesPageDto endpointProfilesPageDto = + groupService.getEndpointProfileByEndpointGroupId(endpointGroupId, limit, + offset); if (endpointProfilesPageDto.hasEndpointProfiles()) { PageLinkDto pageLinkDto = createNext(endpointProfilesPageDto.getPageLinkDto(), request); endpointProfilesPageDto.setNext(pageLinkDto.getNext()); @@ -421,29 +543,45 @@ public EndpointProfilesPageDto getEndpointProfileByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint profiles bodies based on endpoint group id", - notes = "Returns the endpoint profiles bodies based on endpoint group id. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + - "to request this information. Default limit value equals \"20\", default offset value equals \"0\". Maximum limit value is \"500\".") + notes = "Returns the endpoint profiles bodies based on endpoint group id. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to request this information. Default limit value equals \"20\", " + + "default offset value equals \"0\". Maximum limit value is \"500\".") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId/limit/offset supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "Endpoint group with the specified endpointGroupId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "endpointProfileBodyByGroupId", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE) + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not " + + "have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "Endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) + @RequestMapping(value = "endpointProfileBodyByGroupId", + method = RequestMethod.GET, + produces = APPLICATION_JSON_VALUE) @ResponseBody public EndpointProfilesBodyDto getEndpointProfileBodyByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "The id of the endpoint group.", required = true) + @ApiParam(name = "endpointGroupId", + value = "The id of the endpoint group.", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId, - @ApiParam(name = "limit", value = "The maximum number of shown profiles. (Optional parameter)", defaultValue = DEFAULT_LIMIT, required = false) + @ApiParam(name = "limit", + value = "The maximum number of shown profiles. (Optional parameter)", + defaultValue = DEFAULT_LIMIT, required = false) @RequestParam(value = "limit", defaultValue = DEFAULT_LIMIT, required = false) String limit, - @ApiParam(name = "offset", value = "The offset from beginning of profiles list. (Optional parameter)", defaultValue = DEFAULT_OFFSET, + @ApiParam(name = "offset", + value = "The offset from beginning of profiles list. (Optional parameter)", + defaultValue = DEFAULT_OFFSET, required = false) - @RequestParam(value = "offset", defaultValue = DEFAULT_OFFSET, required = false) String offset, + @RequestParam(value = "offset", + defaultValue = DEFAULT_OFFSET, + required = false) String offset, HttpServletRequest request) throws KaaAdminServiceException { - EndpointProfilesBodyDto endpointProfilesBodyDto = groupService.getEndpointProfileBodyByEndpointGroupId(endpointGroupId, limit, - offset); + EndpointProfilesBodyDto endpointProfilesBodyDto = + groupService.getEndpointProfileBodyByEndpointGroupId(endpointGroupId, limit, offset); if (endpointProfilesBodyDto.hasEndpointBodies()) { PageLinkDto pageLinkDto = createNext(endpointProfilesBodyDto.getPageLinkDto(), request); endpointProfilesBodyDto.setNext(pageLinkDto.getNext()); @@ -459,7 +597,10 @@ private PageLinkDto createNext(PageLinkDto pageLink, HttpServletRequest request) if (HTTP_PORT != port && HTTPS_PORT != port) { nextUrl.append(":").append(port); } - String next = nextUrl.append(request.getRequestURI()).append("?").append(pageLink.getNextUrlPart()).toString(); + String next = nextUrl.append(request.getRequestURI()) + .append("?") + .append(pageLink.getNextUrlPart()) + .toString(); pageLink.setNext(next); LOG.debug("Generated next url {}", next); } diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/NotificationController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/NotificationController.java index 367e4b7d24..0b0a3376bc 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/NotificationController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/NotificationController.java @@ -42,7 +42,9 @@ import java.util.List; -@Api(value = "Notifications", description = "Provides function for manage notifications", basePath = "/kaaAdmin/rest") +@Api(value = "Notifications", + description = "Provides function for manage notifications", + basePath = "/kaaAdmin/rest") @Controller public class NotificationController extends AbstractAdminController { @@ -54,19 +56,28 @@ public class NotificationController extends AbstractAdminController { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get notification schemas", - notes = "Returns notification schemas for an application. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + - "information. The Tenant ID value of the application must match the Tenant ID of the request submitter.") + notes = "Returns notification schemas for an application. Only users with " + + "the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + + "information. The Tenant ID value of the application must match the Tenant ID " + + "of the request submitter.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An application with the specified applicationToken does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An application with the specified applicationToken does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "notificationSchemas/{applicationToken}", method = RequestMethod.GET) @ResponseBody public List getNotificationSchemasByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return notificationService.getNotificationSchemasByApplicationToken(applicationToken); @@ -80,18 +91,25 @@ public List getNotificationSchemasByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get user notification schemas", - notes = "Returns user notification schemas for an application. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request " + - "this information.") + notes = "Returns user notification schemas for an application. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request " + + "this information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An application with the specified applicationToken does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An application with the specified applicationToken does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "userNotificationSchemas/{applicationToken}", method = RequestMethod.GET) @ResponseBody public List getUserNotificationSchemasByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return notificationService.getUserNotificationSchemasByApplicationToken(applicationToken); } @@ -104,18 +122,26 @@ public List getUserNotificationSchemasByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get notification schema", - notes = "Returns a notification schema by notification schema ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + - "request this information.") + notes = "Returns a notification schema by notification schema ID. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + + "request this information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A notification schema with the specified notificationSchemaId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "A notification schema with the specified " + + "notificationSchemaId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "notificationSchema/{notificationSchemaId}", method = RequestMethod.GET) @ResponseBody public NotificationSchemaDto getNotificationSchema( - @ApiParam(name = "notificationSchemaId", value = "A unique notification schema identifier", required = true) + @ApiParam(name = "notificationSchemaId", + value = "A unique notification schema identifier", + required = true) @PathVariable String notificationSchemaId) throws KaaAdminServiceException { return notificationService.getNotificationSchema(notificationSchemaId); } @@ -129,7 +155,8 @@ public NotificationSchemaDto getNotificationSchema( */ @RequestMapping(value = "createNotificationSchema", method = RequestMethod.POST) @ResponseBody - public NotificationSchemaDto createNotificationSchema(@RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { + public NotificationSchemaDto createNotificationSchema( + @RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { return notificationService.saveNotificationSchema(notificationSchema); } @@ -141,21 +168,31 @@ public NotificationSchemaDto createNotificationSchema(@RequestBody NotificationS * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit notification schema", - notes = "Creates or updates a notification schema. To create notification schema you do not need to specify the notification schema ID, " + - "createUsername field of the schema will be set to the name of the user who has uploaded it, a unique version number will be generated " + - "(incrementally) for this schema. To edit the notification schema specify the notification schema ID. If a notification schema with the " + - "specified ID exists, the configuration will be updated. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform " + - "this operation.") + notes = "Creates or updates a notification schema. To create notification schema " + + "you do not need to specify the notification schema ID, " + + "createUsername field of the schema will be set to the name of the user " + + "who has uploaded it, a unique version number will be generated " + + "(incrementally) for this schema. To edit the notification schema " + + "specify the notification schema ID. If a notification schema with the " + + "specified ID exists, the configuration will be updated. Only users with " + + "the TENANT_DEVELOPER or TENANT_USER role are allowed to perform " + + "this operation.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "The specified notification schema is not a valid avro schema"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 400, + message = "The specified notification schema is not a valid avro schema"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "saveNotificationSchema", method = RequestMethod.POST) @ResponseBody public NotificationSchemaDto saveNotificationSchema( - @ApiParam(name = "notificationSchema", value = "NotificationSchemaDto body.", required = true) + @ApiParam(name = "notificationSchema", + value = "NotificationSchemaDto body.", + required = true) @RequestBody NotificationSchemaDto notificationSchema) throws KaaAdminServiceException { return notificationService.saveNotificationSchema(notificationSchema); @@ -169,18 +206,26 @@ public NotificationSchemaDto saveNotificationSchema( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get topics", - notes = "Returns all topics for the specified application. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + - "information.") + notes = "Returns all topics for the specified application. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this " + + "information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An application with the specified applicationToken does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An application with the specified applicationToken does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "topics/{applicationToken}", method = RequestMethod.GET) @ResponseBody public List getTopicsByApplicationToken( - @ApiParam(name = "applicationToken", value = "A unique auto-generated application identifier", required = true) + @ApiParam(name = "applicationToken", + value = "A unique auto-generated application identifier", + required = true) @PathVariable String applicationToken) throws KaaAdminServiceException { return notificationService.getTopicsByApplicationToken(applicationToken); } @@ -193,18 +238,25 @@ public List getTopicsByApplicationToken( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get endpoint group topics", - notes = "Returns all topics for the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request " + - "this information.") + notes = "Returns all topics for the specified endpoint group. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request " + + "this information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group to with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group to with the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "topics", method = RequestMethod.GET) @ResponseBody public List getTopicsByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId) throws KaaAdminServiceException { return notificationService.getTopicsByEndpointGroupId(endpointGroupId); @@ -218,18 +270,26 @@ public List getTopicsByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get vacant topics", - notes = "Returns all vacant (not present in the endpoint group) topics for the specified endpoint group. Only users with the TENANT_DEVELOPER or " + - "TENANT_USER role are allowed to request this information.") + notes = "Returns all vacant (not present in the endpoint group) topics for " + + "the specified endpoint group. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to request this information.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "An endpoint group with the specified endpointGroupId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "An endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 500, + message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "vacantTopics/{endpointGroupId}", method = RequestMethod.GET) @ResponseBody public List getVacantTopicsByEndpointGroupId( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @PathVariable String endpointGroupId) throws KaaAdminServiceException { return notificationService.getVacantTopicsByEndpointGroupId(endpointGroupId); } @@ -242,12 +302,16 @@ public List getVacantTopicsByEndpointGroupId( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get topic", - notes = "Returns a topic by topic ID. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to request this information.") + notes = "Returns a topic by topic ID. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to request this information.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid topicId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 404, message = "The topic with the specified topicId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "topic/{topicId}", method = RequestMethod.GET) @@ -266,19 +330,27 @@ public TopicDto getTopic( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit topic", - notes = "Creates or edits a topic. To create topic you do not need to specify the topic ID. To edit the topic specify the topic ID. If a topic " + - "with the specified ID exists, it will be updated. Only users with theTENANT_DEVELOPER or TENANT_USER role are allowed to perform " + - "this operation.") + notes = "Creates or edits a topic. To create topic you do not need to specify " + + "the topic ID. To edit the topic specify the topic ID. If a topic " + + "with the specified ID exists, it will be updated. Only users with the " + + "TENANT_DEVELOPER or TENANT_USER role are allowed to perform " + + "this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A topic to be edited with the specified topicId does not exist"), - @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "A topic to be edited with the specified topicId does not exist"), + @ApiResponse(code = 500,message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "topic", method = RequestMethod.POST) @ResponseBody public TopicDto editTopic( - @ApiParam(name = "topic", value = "TopicDto body. Mandatory fields: applicationId, name, type", required = true) + @ApiParam(name = "topic", + value = "TopicDto body. Mandatory fields: applicationId, name, type", + required = true) @RequestBody TopicDto topic) throws KaaAdminServiceException { return notificationService.editTopic(topic); } @@ -290,12 +362,16 @@ public TopicDto editTopic( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Delete topic", - notes = "Deletes a topic. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation.") + notes = "Deletes a topic. Only users with the TENANT_DEVELOPER or " + + "TENANT_USER role are allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid topicId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 404, message = "The topic with the specified topicId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "delTopic", method = RequestMethod.POST) @@ -314,19 +390,27 @@ public void deleteTopic( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Add topic to endpoint group", - notes = "Adds the specified topic to the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + - "perform this operation.") + notes = "Adds the specified topic to the specified endpoint group. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed to " + + "perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A topic with the specified topicId or an endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "A topic with the specified topicId or an endpoint " + + "group with the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "addTopicToEpGroup", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void addTopicToEndpointGroup( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId, @ApiParam(name = "topicId", value = "A unique topic identifier", required = true) @RequestParam(value = "topicId") String topicId) throws KaaAdminServiceException { @@ -341,19 +425,27 @@ public void addTopicToEndpointGroup( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Remove topic from endpoint group", - notes = "Removes the specified topic from the specified endpoint group. Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + - "to perform this operation.") + notes = "Removes the specified topic from the specified endpoint group. " + + "Only users with the TENANT_DEVELOPER or TENANT_USER role are allowed " + + "to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid endpointGroupId supplied"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A topic with the specified topicId or an endpoint group with the specified endpointGroupId does not exist"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "A topic with the specified topicId or " + + "an endpoint group with the specified endpointGroupId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "removeTopicFromEpGroup", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) public void removeTopicFromEndpointGroup( - @ApiParam(name = "endpointGroupId", value = "A unique endpoint group identifier", required = true) + @ApiParam(name = "endpointGroupId", + value = "A unique endpoint group identifier", + required = true) @RequestParam(value = "endpointGroupId") String endpointGroupId, @ApiParam(name = "topicId", value = "A unique topic identifier", required = true) @RequestParam(value = "topicId") String topicId) throws KaaAdminServiceException { @@ -369,33 +461,41 @@ public void removeTopicFromEndpointGroup( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Send notification", - notes = "Sends a notification with the notification body from the specified file. Only users with the TENANT_DEVELOPER or TENANT_USER role are " + - "allowed to perform this operation. If you want to set notification time to leave, you must set expiredAt field in the parameter " + - "notification. If your notification schema contains one field \"message\" with Union type, notification body from the specified file " + - "looks like below: " + - "```{" + - " \"message\" : {" + - " \"string\" : \"Hello world!\"" + - " }" + - "}```. " + - "And for primitive string type of the field \"message\" notification body from the specified file looks like below: " + - "```{" + - " \"message\" : \"Hello world!\"" + - "}```") + notes = "Sends a notification with the notification body " + + "from the specified file. Only users with the TENANT_DEVELOPER or TENANT_USER role are" + + " allowed to perform this operation. If you want to set notification time to leave," + + " you must set expiredAt field in the parameter " + + "notification. If your notification schema contains one field \"message\" " + + "with Union type, notification body from the specified file " + + "looks like below: " + + "```{" + " \"message\" : {" + " \"string\" : \"Hello world!\"" + + " }" + "}```. " + "And for primitive string type of the field \"message\" " + + "notification body from the specified file looks like below: " + + "```{" + " \"message\" : \"Hello world!\"" + "}```") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified notification is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A file with the notification body was not found in the form data or an application with the specified ID " + - "does not exist or a topic with the specified ID does not exist"), + @ApiResponse(code = 404, message = "A file with the notification body " + + "was not found in the form data or an application with the specified ID " + + "does not exist or a topic with the specified ID does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "sendNotification", method = RequestMethod.POST, consumes = {"multipart/mixed", "multipart/form-data"}) + @RequestMapping(value = "sendNotification", + method = RequestMethod.POST, + consumes = {"multipart/mixed", "multipart/form-data"}) @ResponseBody public NotificationDto sendNotification( - @ApiParam(name = "notification", value = "NotificationDto body. Mandatory fields: applicationId, schemaId, topicId, type", required = true) + @ApiParam(name = "notification", + value = "NotificationDto body. Mandatory fields: applicationId, schemaId, topicId, type", + required = true) @RequestPart("notification") NotificationDto notification, - @ApiParam(name = "file", value = "A file with notification body according to the specified notification schema represented in json format", + @ApiParam(name = "file", + value = "A file with notification body according to the specified " + + "notification schema represented in json format", required = true) @RequestPart("file") MultipartFile file) throws KaaAdminServiceException { byte[] data = getFileContent(file); @@ -413,35 +513,47 @@ public NotificationDto sendNotification( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Send unicast notification", - notes = "Sends a unicast notification with the notification body from the specified file to the client identified by endpointKeyHash. Only users " + - "with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation. If you want to set notification time to leave, " + - "you must set expiredAt field in the parameter notification. If your notification schema contains one field \"message\" with Union type, " + - "notification body from the specified file looks like below: " + - "```{" + - " \"message\" : {" + - " \"string\" : \"Hello world!\"" + - " }" + - "}```. " + - "And for primitive string type of the field \"message\" notification body from the specified file looks like below: " + - "```{" + - " \"message\" : \"Hello world!\"" + - "}```") + notes = "Sends a unicast notification with the notification body from the specified " + + "file to the client identified by endpointKeyHash. Only users " + + "with the TENANT_DEVELOPER or TENANT_USER role are allowed to perform this operation." + + " If you want to set notification time to leave, " + + "you must set expiredAt field in the parameter notification. " + + "If your notification schema contains one field \"message\" with Union type, " + + "notification body from the specified file looks like below: " + + "```{" + " \"message\" : {" + " \"string\" : \"Hello world!\"" + + " }" + "}```. " + "And for primitive string type of the field \"message\" " + + "notification body from the specified file looks like below: " + + "```{" + " \"message\" : \"Hello world!\"" + "}```") @ApiResponses(value = { - @ApiResponse(code = 400, message = "The specified notification is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + - "of the application does not match the Tenant ID of the authenticated user"), - @ApiResponse(code = 404, message = "A file with the notification body was not found in the form data or an application with the specified ID does " + - "not exist or a topic with the specified ID does not exist"), + @ApiResponse(code = 400, + message = "The specified notification is not valid"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 403, + message = "The authenticated user does not have the required role " + + "(TENANT_DEVELOPER or TENANT_USER) or the Tenant ID " + + "of the application does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 404, + message = "A file with the notification body was not found in " + + "the form data or an application with the specified ID does " + + "not exist or a topic with the specified ID does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) - @RequestMapping(value = "sendUnicastNotification", method = RequestMethod.POST, consumes = {"multipart/mixed", "multipart/form-data"}) + @RequestMapping(value = "sendUnicastNotification", + method = RequestMethod.POST, + consumes = {"multipart/mixed", "multipart/form-data"}) @ResponseBody public EndpointNotificationDto sendUnicastNotification( - @ApiParam(name = "notification", value = "NotificationDto body. Mandatory fields: applicationId, schemaId, topicId, type", required = true) + @ApiParam(name = "notification", + value = "NotificationDto body. Mandatory fields: applicationId, schemaId, topicId, type", + required = true) @RequestPart("notification") NotificationDto notification, - @ApiParam(name = "endpointKeyHash", value = "The key hash of the endpoint in Base64 URL safe format", required = true) + @ApiParam(name = "endpointKeyHash", + value = "The key hash of the endpoint in Base64 URL safe format", + required = true) @RequestPart("endpointKeyHash") String clientKeyHash, - @ApiParam(name = "file", value = "A file with notification body according to the specified notification schema represented in json format", + @ApiParam(name = "file", + value = "A file with notification body according to the specified " + + "notification schema represented in json format", required = true) @RequestPart("file") MultipartFile file) throws KaaAdminServiceException { byte[] data = getFileContent(file); diff --git a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/UserController.java b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/UserController.java index 43e813ce83..2fab4deb8e 100644 --- a/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/UserController.java +++ b/server/node/src/main/java/org/kaaproject/kaa/server/admin/controller/UserController.java @@ -46,7 +46,9 @@ import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; -@Api(value = "User", description = "Provides function for manage users", basePath = "/kaaAdmin/rest") +@Api(value = "User", + description = "Provides function for manage users", + basePath = "/kaaAdmin/rest") @Controller public class UserController extends AbstractAdminController { @@ -58,7 +60,8 @@ public class UserController extends AbstractAdminController { * @throws Exception the exception */ @ApiOperation(value = "Get user authentication status", - notes = "Returns information about the current authorized user. Only authorized users are allowed to perform this operation.") + notes = "Returns information about the current authorized user. " + + "Only authorized users are allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "auth/checkAuth", method = RequestMethod.GET) @@ -89,13 +92,15 @@ public AuthResultDto checkAuth(HttpServletRequest request) throws Exception { public void createKaaAdmin( @ApiParam(name = "username", value = "A user name of the Kaa admin user", required = true) @RequestParam(value = "username") String username, - @ApiParam(name = "password", value = "A user password of the Kaa admin user; it must be no shorter than 6 characters", required = true) + @ApiParam(name = "password", value = "A user password of the Kaa admin user; " + + "it must be no shorter than 6 characters", required = true) @RequestParam(value = "password") String password) throws KaaAdminServiceException { if (!userFacade.isAuthorityExists(KaaAuthorityDto.KAA_ADMIN.name())) { kaaAuthService.createKaaAdmin(username, password); } else { - throw new KaaAdminServiceException("Kaa admin already exists. Can't create more than one kaa admin users.", + throw new KaaAdminServiceException("Kaa admin already exists. " + + "Can't create more than one kaa admin users.", ServiceErrorCode.PERMISSION_DENIED); } } @@ -110,30 +115,39 @@ public void createKaaAdmin( * @throws Exception the exception */ @ApiOperation(value = "Change user password", - notes = "Changes the password of a user. Only authorized users are allowed to perform this operation.") + notes = "Changes the password of a user. " + + "Only authorized users are allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified parameters are not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 401, + message = "The user is not authenticated or invalid credentials were provided"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "auth/changePassword", method = RequestMethod.POST) @ResponseBody public ResultCode changePassword( - @ApiParam(name = "username", value = "A user name of the user whose password is to be changed", required = true) + @ApiParam(name = "username", + value = "A user name of the user whose password is to be changed", + required = true) @RequestParam(value = "username") String username, @ApiParam(name = "oldPassword", value = "An old password of the user", required = true) @RequestParam(value = "oldPassword") String oldPassword, - @ApiParam(name = "newPassword", value = "A new password of the user; it must be no shorter than 6 characters", required = true) + @ApiParam(name = "newPassword", + value = "A new password of the user; it must be no shorter than 6 characters", + required = true) @RequestParam(value = "newPassword") String newPassword) throws Exception { ResultCode resultCode = kaaAuthService.changePassword(username, oldPassword, newPassword); if (resultCode == ResultCode.USER_NOT_FOUND) { - throw Utils.handleException(new IllegalArgumentException("User with specified username was not found.")); + throw Utils.handleException( + new IllegalArgumentException("User with specified username was not found.")); } else if (resultCode == ResultCode.PERMISSION_DENIED) { - throw Utils.handleException(new KaaAdminServiceException(ServiceErrorCode.PERMISSION_DENIED)); + throw Utils.handleException( + new KaaAdminServiceException(ServiceErrorCode.PERMISSION_DENIED)); } else if (resultCode == ResultCode.OLD_PASSWORD_MISMATCH) { throw Utils.handleException(new IllegalArgumentException("Current password is invalid.")); } else if (resultCode == ResultCode.BAD_PASSWORD_STRENGTH) { - throw Utils.handleException(new IllegalArgumentException("Password strength is insufficient.")); + throw Utils.handleException( + new IllegalArgumentException("Password strength is insufficient.")); } return resultCode; } @@ -145,9 +159,11 @@ public ResultCode changePassword( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get user profile", - notes = "Returns the user profile of the current user. Only authorized users are allowed to perform this operation.") + notes = "Returns the user profile of the current user. " + + "Only authorized users are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "userProfile", method = RequestMethod.GET) @ResponseBody @@ -162,14 +178,18 @@ public UserDto getUserProfile() throws KaaAdminServiceException { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Edit user profile", - notes = "Edits the user profile. Only authorized users are allowed to perform this operation.") + notes = "Edits the user profile. Only authorized " + + "users are allowed to perform this operation.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "userProfile", method = RequestMethod.POST) @ResponseBody public void editUserProfile( - @ApiParam(name = "userProfileUpdateDto", value = "UserProfileUpdateDto body.", required = true) + @ApiParam(name = "userProfileUpdateDto", + value = "UserProfileUpdateDto body.", + required = true) @RequestBody UserProfileUpdateDto userProfileUpdateDto) throws KaaAdminServiceException { userService.editUserProfile(userProfileUpdateDto); } @@ -181,11 +201,15 @@ public void editUserProfile( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get all users", - notes = "Returns a list of all users associated with the current authorized user: users whose Tenant ID values match the Tenant ID of the " + - "request submitter. Only users with the TENANT_ADMIN role are allowed to submit this request.") + notes = "Returns a list of all users associated with the current authorized " + + "user: users whose Tenant ID values match the Tenant ID of the " + + "request submitter. Only users with the TENANT_ADMIN " + + "role are allowed to submit this request.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN)"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the " + + "required role (TENANT_ADMIN)"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "users", method = RequestMethod.GET) @ResponseBody @@ -201,12 +225,15 @@ public List getUsers() throws KaaAdminServiceException { * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Get user", - notes = " Returns a user. Only users with the TENANT_ADMIN role are allowed to submit this request. The Tenant ID of requested user must be " + - "identical to the Tenant ID of the submitter.") + notes = " Returns a user. Only users with the TENANT_ADMIN role are allowed to submit " + + "this request. The Tenant ID of requested user must be " + + "identical to the Tenant ID of the submitter.") @ApiResponses(value = { - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required role (TENANT_ADMIN) or the Tenant ID of the requested user " + - "does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required role " + + "(TENANT_ADMIN) or the Tenant ID of the requested user " + + "does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 404, message = "The user with the specified userId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "user/{userId}", method = RequestMethod.GET) @@ -225,25 +252,33 @@ public UserDto getUser( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Create/Edit user", - notes = "Creates or edits a user. To create a user you do not need to specify the user ID, its Tenant ID will be set to the Tenant ID of the " + - "request submitter. A random password will be generated and presented in the success response in the tempPassword field. To edit user " + - "specify the user ID. If a user with the specified ID exists, it will be updated. Only users with the TENANT_ADMIN role can perform " + - "this operation.") + notes = "Creates or edits a user. To create a user you do not need to specify " + + "the user ID, its Tenant ID will be set to the Tenant ID of the " + + "request submitter. A random password will be generated and presented " + + "in the success response in the tempPassword field. To edit user " + + "specify the user ID. If a user with the specified ID exists, it will be updated. " + + "Only users with the TENANT_ADMIN role can perform " + + "this operation.") @ApiResponses(value = { - @ApiResponse(code = 400, message = "Some of the mandatory fields are not correct or are empty"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required TENANT_ADMIN role or the Tenant ID of the editing user " + - "does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 400, message = "Some of the mandatory " + + "fields are not correct or are empty"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required " + + "TENANT_ADMIN role or the Tenant ID of the editing user " + + "does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "user", method = RequestMethod.POST) @ResponseBody public UserDto editUser( - @ApiParam(name = "user", value = "UserDto body. Mandatory fields: username, firstName, lastName, mail, authority", required = true) + @ApiParam(name = "user", + value = "UserDto body. Mandatory fields: username, firstName, lastName, mail, authority", + required = true) @Valid @RequestBody UserDto user) throws KaaAdminServiceException { try { return userService.editUser(user); - } catch (Exception e) { - throw Utils.handleException(e); + } catch (Exception ex) { + throw Utils.handleException(ex); } } @@ -254,12 +289,15 @@ public UserDto editUser( * @throws KaaAdminServiceException the kaa admin service exception */ @ApiOperation(value = "Delete user", - notes = "Deletes a user specified by user ID. Only users with the TENANT_ADMIN role are allowed to perform this operation.") + notes = "Deletes a user specified by user ID. " + + "Only users with the TENANT_ADMIN role are allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified userId is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required TENANT_ADMIN role or the Tenant ID of the editing user " + - "does not match the Tenant ID of the authenticated user"), + @ApiResponse(code = 401, message = "The user is not authenticated " + + "or invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does not have the required " + + "TENANT_ADMIN role or the Tenant ID of the editing user " + + "does not match the Tenant ID of the authenticated user"), @ApiResponse(code = 404, message = "The user with the specified userId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "delUser", method = RequestMethod.POST) @@ -272,11 +310,14 @@ public void deleteUser( @ApiOperation(value = "Get tenant admins based on tenant id", - notes = "Gets the tenant admins by specified tenantId. Only user with KAA_ADMIN role is allowed to perform this operation.") + notes = "Gets the tenant admins by specified tenantId. Only user with KAA_ADMIN " + + "role is allowed to perform this operation.") @ApiResponses(value = { @ApiResponse(code = 400, message = "The specified tenantId is not valid"), - @ApiResponse(code = 401, message = "The user is not authenticated or invalid credentials were provided"), - @ApiResponse(code = 403, message = "The authenticated user does not have the required KAA_ADMIN role"), + @ApiResponse(code = 401, message = "The user is not authenticated or" + + " invalid credentials were provided"), + @ApiResponse(code = 403, message = "The authenticated user does " + + "not have the required KAA_ADMIN role"), @ApiResponse(code = 404, message = "The user with the specified tenantId does not exist"), @ApiResponse(code = 500, message = "An unexpected error occurred on the server side")}) @RequestMapping(value = "admins/{tenantId}", method = RequestMethod.POST)