Search in sources :

Example 16 with Role

use of org.simbasecurity.core.domain.Role in project simba-os by cegeka.

the class RoleManagerService method addPolicies.

@RequestMapping("addPolicies")
@ResponseBody
public void addPolicies(@JsonBody("role") RoleDTO role, @JsonBody("policies") List<PolicyDTO> policies) {
    Role attachedRole = roleRepository.refreshWithOptimisticLocking(role);
    Collection<Policy> attachedPolicies = policyRepository.refreshWithOptimisticLocking(policies);
    attachedRole.addPolicies(attachedPolicies);
    roleRepository.persist(attachedRole);
}
Also used : Role(org.simbasecurity.core.domain.Role) Policy(org.simbasecurity.core.domain.Policy) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Role (org.simbasecurity.core.domain.Role)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)8 Policy (org.simbasecurity.core.domain.Policy)6 Group (org.simbasecurity.core.domain.Group)4 TGroup (org.simbasecurity.api.service.thrift.TGroup)3 TRole (org.simbasecurity.api.service.thrift.TRole)3 RoleEntity (org.simbasecurity.core.domain.RoleEntity)3 User (org.simbasecurity.core.domain.User)3 Test (org.junit.Test)2 UserEntity (org.simbasecurity.core.domain.UserEntity)2 RoleDTO (org.simbasecurity.core.service.manager.dto.RoleDTO)2 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 GroupService (org.simbasecurity.api.service.thrift.GroupService)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 GroupEntity (org.simbasecurity.core.domain.GroupEntity)1 PolicyEntity (org.simbasecurity.core.domain.PolicyEntity)1