use of org.simbasecurity.api.service.thrift.TRule in project simba-os by cegeka.
the class PolicyServiceImpl method removeRule.
@Override
public void removeRule(TPolicy policy, TRule rule) throws TException {
simbaExceptionHandlingCaller.call(() -> {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
Rule attachedRule = ruleRepository.refreshWithOptimisticLocking(rule.getId(), rule.getVersion());
audit.log("Rule ''{0}'' removed from ''{1}''", attachedRule.getName(), attachedPolicy.getName());
attachedPolicy.removeRule(attachedRule);
});
}
use of org.simbasecurity.api.service.thrift.TRule in project simba-os by cegeka.
the class PolicyServiceImpl method addRules.
@Override
public void addRules(TPolicy policy, Set<TRule> rules) throws TException {
simbaExceptionHandlingCaller.call(() -> {
Policy attachedPolicy = policyRepository.refreshWithOptimisticLocking(policy.getId(), policy.getVersion());
Set<Rule> attachedRules = rules.stream().map(r -> ruleRepository.refreshWithOptimisticLocking(r.getId(), r.getVersion())).collect(Collectors.toSet());
audit.log("Rules ''{0}'' added to policy ''{1}''", join(attachedRules, Rule::getName), attachedPolicy.getName());
attachedPolicy.addRules(attachedRules);
});
}
Aggregations