Search in sources :

Example 1 with PermissionDefinitionModel

use of com.infiniteautomation.mango.rest.latest.model.permissions.PermissionDefinitionModel in project ma-modules-public by infiniteautomation.

the class PermissionsRestController method update.

@ApiOperation(value = "Update all of a Permission's Roles", notes = "If no roles are supplied then all existing assigned roles are removed")
@RequestMapping(method = RequestMethod.PUT, value = "/{name}")
public PermissionDefinitionModel update(@PathVariable String name, @ApiParam(value = "Permission", required = true) @RequestBody(required = true) PermissionDefinitionModel model) {
    PermissionDefinition def = ModuleRegistry.getPermissionDefinition(name);
    if (def == null) {
        throw new NotFoundRestException();
    }
    MangoPermission permission = model.getPermission() != null ? model.getPermission().getPermission() : null;
    service.update(permission, def);
    return new PermissionDefinitionModel(def);
}
Also used : PermissionDefinitionModel(com.infiniteautomation.mango.rest.latest.model.permissions.PermissionDefinitionModel) PermissionDefinition(com.serotonin.m2m2.module.PermissionDefinition) NotFoundRestException(com.infiniteautomation.mango.rest.latest.exception.NotFoundRestException) MangoPermission(com.infiniteautomation.mango.permission.MangoPermission) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MangoPermission (com.infiniteautomation.mango.permission.MangoPermission)1 NotFoundRestException (com.infiniteautomation.mango.rest.latest.exception.NotFoundRestException)1 PermissionDefinitionModel (com.infiniteautomation.mango.rest.latest.model.permissions.PermissionDefinitionModel)1 PermissionDefinition (com.serotonin.m2m2.module.PermissionDefinition)1 ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1