Search in sources :

Example 6 with ScriptEventHandlerVO

use of com.serotonin.m2m2.vo.event.ScriptEventHandlerVO in project ma-core-public by infiniteautomation.

the class ScriptEventHandlerDefinition method validate.

@Override
public void validate(ProcessResult response, ScriptEventHandlerVO existing, ScriptEventHandlerVO vo) {
    commonValidation(response, vo);
    if (vo.getScriptRoles() == null) {
        response.addContextualMessage("scriptRoles", "validate.permission.null");
    } else {
        PermissionHolder user = Common.getUser();
        Set<Role> roles = existing.getScriptRoles() == null ? null : existing.getScriptRoles();
        permissionService.validatePermissionHolderRoles(response, "scriptRoles", user, vo.getScriptRoles());
    }
}
Also used : Role(com.serotonin.m2m2.vo.role.Role) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder)

Aggregations

PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)4 Role (com.serotonin.m2m2.vo.role.Role)3 EvalContext (com.infiniteautomation.mango.spring.script.EvalContext)2 EventHandlerInterface (com.serotonin.m2m2.rt.event.handlers.EventHandlerInterface)2 ScriptEventHandlerRT (com.serotonin.m2m2.rt.event.handlers.ScriptEventHandlerRT)2 ScriptEventHandlerVO (com.serotonin.m2m2.vo.event.ScriptEventHandlerVO)2 BufferedReader (java.io.BufferedReader)2 BufferedWriter (java.io.BufferedWriter)2 InputStreamReader (java.io.InputStreamReader)2 OutputStreamWriter (java.io.OutputStreamWriter)2 JsonTypeName (com.fasterxml.jackson.annotation.JsonTypeName)1 RoleService (com.infiniteautomation.mango.spring.service.RoleService)1 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)1 Common (com.serotonin.m2m2.Common)1 ModuleRegistry (com.serotonin.m2m2.module.ModuleRegistry)1 ScriptEventHandlerDefinition (com.serotonin.m2m2.module.definitions.event.handlers.ScriptEventHandlerDefinition)1 ApiModel (io.swagger.annotations.ApiModel)1 Collections (java.util.Collections)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1