use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class EventHandlersRestController method delete.
@ApiOperation(value = "Delete an EventHandler", response = AbstractEventHandlerModel.class)
@RequestMapping(method = RequestMethod.DELETE, value = "/{xid}")
public ResponseEntity<AbstractEventHandlerModel<?>> delete(@ApiParam(value = "XID of EventHandler to delete", required = true) @PathVariable String xid, @ApiParam(value = "User", required = true) @AuthenticationPrincipal PermissionHolder user) {
AbstractEventHandlerVO vo = service.delete(xid);
@SuppressWarnings("unchecked") AbstractEventHandlerModel<? extends AbstractEventHandlerVO> responseModel = modelMapper.map(vo, AbstractEventHandlerModel.class, user);
return ResponseEntity.ok(responseModel);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class EventHandlersRestController method partialUpdate.
@ApiOperation(value = "Partially update an Event Handler", notes = "Requires edit permission", response = AbstractEventHandlerModel.class)
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<AbstractEventHandlerModel<?>> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated maintenance event", required = true) @PatchVORequestBody(service = EventHandlerService.class, modelClass = AbstractEventHandlerModel.class) AbstractEventHandlerModel<? extends AbstractEventHandlerVO> model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
AbstractEventHandlerVO vo = service.update(xid, modelMapper.unMap(model, AbstractEventHandlerVO.class, user));
URI location = builder.path("/event-handlers/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
@SuppressWarnings("unchecked") AbstractEventHandlerModel<? extends AbstractEventHandlerVO> responseModel = modelMapper.map(vo, AbstractEventHandlerModel.class, user);
return new ResponseEntity<>(responseModel, headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class EventHandlersRestController method get.
@ApiOperation(value = "Get an Event Handler", response = AbstractEventHandlerModel.class)
@RequestMapping(method = RequestMethod.GET, value = "/{xid}")
public AbstractEventHandlerModel<?> get(@ApiParam(value = "XID to get", required = true) @PathVariable String xid, @ApiParam(value = "User", required = true) @AuthenticationPrincipal PermissionHolder user) {
AbstractEventHandlerVO vo = service.get(xid);
@SuppressWarnings("unchecked") AbstractEventHandlerModel<? extends AbstractEventHandlerVO> model = modelMapper.map(vo, AbstractEventHandlerModel.class, user);
return model;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class MaintenanceEventTypeModelMapping method map.
@Override
public MaintenanceEventTypeModel map(Object o, PermissionHolder user, RestModelMapper mapper) {
MaintenanceEventType type = (MaintenanceEventType) o;
MaintenanceEventVO vo = MaintenanceEventDao.getInstance().get(type.getReferenceId1());
MaintenanceEventTypeModel model;
if (vo != null)
model = new MaintenanceEventTypeModel(type, new MaintenanceEventModel(vo));
else
model = new MaintenanceEventTypeModel(type);
return model;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsService method validate.
@Override
public ProcessResult validate(MaintenanceEventVO vo) {
ProcessResult result = commonValidation(vo);
PermissionHolder user = Common.getUser();
permissionService.validatePermission(result, "togglePermission", user, vo.getTogglePermission());
return result;
}
Aggregations