Search in sources :

Example 1 with TGroup

use of org.simbasecurity.api.service.thrift.TGroup in project simba-os by cegeka.

the class GroupServiceImpl method removeRole.

@Override
public void removeRole(TGroup group, TRole role) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        audit.log("Role ''{0}'' removed from group ''{1}''", attachedRole.getName(), attachedGroup.getName());
        attachedGroup.removeRole(attachedRole);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Example 2 with TGroup

use of org.simbasecurity.api.service.thrift.TGroup in project simba-os by cegeka.

the class GroupServiceImpl method addRoles.

@Override
public void addRoles(TGroup group, List<TRole> roles) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        Collection<Role> attachedRoles = roles.stream().map(r -> roleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toList());
        audit.log("Roles ''{0}'' added to group ''{1}''", join(attachedRoles, Role::getName));
        attachedGroup.addRoles(attachedRoles);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TRole(org.simbasecurity.api.service.thrift.TRole) RoleRepository(org.simbasecurity.core.domain.repository.RoleRepository) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group) Collection(java.util.Collection) TException(org.apache.thrift.TException) Autowired(org.springframework.beans.factory.annotation.Autowired) SimbaExceptionHandlingCaller(org.simbasecurity.core.service.errors.SimbaExceptionHandlingCaller) Collectors(java.util.stream.Collectors) ManagementAudit(org.simbasecurity.core.audit.ManagementAudit) TUser(org.simbasecurity.api.service.thrift.TUser) GroupRepository(org.simbasecurity.core.domain.repository.GroupRepository) List(java.util.List) StringUtil.join(org.simbasecurity.common.util.StringUtil.join) Service(org.springframework.stereotype.Service) GroupService(org.simbasecurity.api.service.thrift.GroupService) ThriftAssembler(org.simbasecurity.core.service.thrift.ThriftAssembler) Transactional(org.springframework.transaction.annotation.Transactional) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Example 3 with TGroup

use of org.simbasecurity.api.service.thrift.TGroup in project simba-os by cegeka.

the class GroupServiceImpl method addRole.

@Override
public void addRole(TGroup group, TRole role) throws TException {
    simbaExceptionHandlingCaller.call(() -> {
        Role attachedRole = roleRepository.refreshWithOptimisticLocking(role.getId(), role.getVersion());
        Group attachedGroup = groupRepository.refreshWithOptimisticLocking(group.getId(), group.getVersion());
        audit.log("Role ''{0}'' added to group ''{1}''", attachedRole.getName(), attachedGroup.getName());
        attachedGroup.addRole(attachedRole);
    });
}
Also used : TRole(org.simbasecurity.api.service.thrift.TRole) Role(org.simbasecurity.core.domain.Role) TGroup(org.simbasecurity.api.service.thrift.TGroup) Group(org.simbasecurity.core.domain.Group)

Aggregations

TGroup (org.simbasecurity.api.service.thrift.TGroup)3 TRole (org.simbasecurity.api.service.thrift.TRole)3 Group (org.simbasecurity.core.domain.Group)3 Role (org.simbasecurity.core.domain.Role)3 Collection (java.util.Collection)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 TException (org.apache.thrift.TException)1 GroupService (org.simbasecurity.api.service.thrift.GroupService)1 TUser (org.simbasecurity.api.service.thrift.TUser)1 StringUtil.join (org.simbasecurity.common.util.StringUtil.join)1 ManagementAudit (org.simbasecurity.core.audit.ManagementAudit)1 GroupRepository (org.simbasecurity.core.domain.repository.GroupRepository)1 RoleRepository (org.simbasecurity.core.domain.repository.RoleRepository)1 SimbaExceptionHandlingCaller (org.simbasecurity.core.service.errors.SimbaExceptionHandlingCaller)1 ThriftAssembler (org.simbasecurity.core.service.thrift.ThriftAssembler)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1