@ -40,6 +40,8 @@ import org.thingsboard.server.service.entitiy.alarm.TbAlarmCommentService;
import org.thingsboard.server.service.security.permission.Operation ;
import org.thingsboard.server.service.security.permission.Resource ;
import static org.thingsboard.server.controller.ControllerConstants.ALARM_COMMENT_ID_PARAM_DESCRIPTION ;
import static org.thingsboard.server.controller.ControllerConstants.ALARM_COMMENT_SORT_PROPERTY_ALLOWABLE_VALUES ;
import static org.thingsboard.server.controller.ControllerConstants.ALARM_ID_PARAM_DESCRIPTION ;
import static org.thingsboard.server.controller.ControllerConstants.ALARM_SORT_PROPERTY_ALLOWABLE_VALUES ;
import static org.thingsboard.server.controller.ControllerConstants.PAGE_DATA_PARAMETERS ;
@ -66,7 +68,8 @@ public class AlarmCommentController extends BaseController {
"When creating comment, platform generates Alarm Comment Id as " + UUID_WIKI_LINK +
"The newly created Alarm Comment id will be present in the response. Specify existing Alarm Comment id to update the alarm. " +
"Referencing non-existing Alarm Comment Id will cause 'Not Found' error. " +
"\nRemove 'id' and optionally 'userId' from the request body example (below) to create new Alarm comment entity. " +
"\n\n To create new Alarm comment entity it is enough to specify 'comment' json element with 'text' node, for example: {\"comment\": { \"text\": \"my comment\"}}. " +
"\n\n If comment type is not specified the default value 'OTHER' will be saved. If 'alarmId' or 'userId' specified in body it will be ignored." +
TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH
, produces = MediaType . APPLICATION_JSON_VALUE )
@PreAuthorize ( "hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')" )
@ -81,12 +84,12 @@ public class AlarmCommentController extends BaseController {
return tbAlarmCommentService . saveAlarmComment ( alarm , alarmComment , getCurrentUser ( ) ) ;
}
@ApiOperation ( value = "Delete Alarm comment(deleteAlarmComment)" ,
@ApiOperation ( value = "Delete Alarm comment (deleteAlarmComment)" ,
notes = "Deletes the Alarm comment. Referencing non-existing Alarm comment Id will cause an error." + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH , produces = MediaType . APPLICATION_JSON_VALUE )
@PreAuthorize ( "hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')" )
@RequestMapping ( value = "/alarm/{alarmId}/comment/{commentId}" , method = RequestMethod . DELETE )
@ResponseBody
public Boolean deleteAlarmComment ( @ApiParam ( value = ALARM_ID_PARAM_DESCRIPTION ) @PathVariable ( ALARM_ID ) String strAlarmId , @ApiParam ( value = ALARM_ID_PARAM_DESCRIPTION ) @PathVariable ( ALARM_COMMENT_ID ) String strCommentId ) throws ThingsboardException {
public Boolean deleteAlarmComment ( @ApiParam ( value = ALARM_ID_PARAM_DESCRIPTION ) @PathVariable ( ALARM_ID ) String strAlarmId , @ApiParam ( value = ALARM_COMMENT_ ID_PARAM_DESCRIPTION ) @PathVariable ( ALARM_COMMENT_ID ) String strCommentId ) throws ThingsboardException {
checkParameter ( ALARM_ID , strAlarmId ) ;
AlarmId alarmId = new AlarmId ( toUUID ( strAlarmId ) ) ;
Alarm alarm = checkAlarmId ( alarmId , Operation . DELETE ) ;
@ -97,7 +100,7 @@ public class AlarmCommentController extends BaseController {
}
@ApiOperation ( value = "Get Alarm comments (getAlarmComments)" ,
notes = "Returns a page of alarm comments. " +
notes = "Returns a page of alarm comments for specified alarm . " +
PAGE_DATA_PARAMETERS + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH , produces = MediaType . APPLICATION_JSON_VALUE )
@PreAuthorize ( "hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')" )
@RequestMapping ( value = "/alarm/{alarmId}/comment" , method = RequestMethod . GET )
@ -109,7 +112,7 @@ public class AlarmCommentController extends BaseController {
@RequestParam int pageSize ,
@ApiParam ( value = PAGE_NUMBER_DESCRIPTION , required = true )
@RequestParam int page ,
@ApiParam ( value = SORT_PROPERTY_DESCRIPTION , allowableValues = ALARM_SORT_PROPERTY_ALLOWABLE_VALUES )
@ApiParam ( value = SORT_PROPERTY_DESCRIPTION , allowableValues = ALARM_COMMENT_ SORT_PROPERTY_ALLOWABLE_VALUES )
@RequestParam ( required = false ) String sortProperty ,
@ApiParam ( value = SORT_ORDER_DESCRIPTION , allowableValues = SORT_ORDER_ALLOWABLE_VALUES )
@RequestParam ( required = false ) String sortOrder