@Override public PrivilegeTO getPrivilegeTO(final Privilege privilege) { PrivilegeTO privilegeTO = new PrivilegeTO(); privilegeTO.setKey(privilege.getKey()); privilegeTO.setDescription(privilege.getDescription()); privilegeTO.setApplication(privilege.getApplication().getKey()); privilegeTO.setSpec(privilege.getSpec()); return privilegeTO; }
@Override public void delete(final Application application) { application.getPrivileges().forEach(privilege -> { roleDAO.findByPrivilege(privilege).forEach(role -> { role.getPrivileges().remove(privilege); }); privilege.setApplication(null); }); application.getPrivileges().clear(); entityManager().remove(application); }
if (privilege == null) { privilege = entityFactory.newEntity(Privilege.class); privilege.setKey(privilegeTO.getKey()); privilege.setApplication(application); } else if (!application.equals(privilege.getApplication())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidPrivilege); sce.getElements().add( "Privilege " + privilege.getKey() + " already owned by " + privilege.getApplication()); throw sce; privilege.setDescription(privilegeTO.getDescription()); privilege.setSpec(privilegeTO.getSpec()); Privilege privilege = itor.next(); if (!applicationTO.getPrivileges().stream(). anyMatch(privilegeTO -> privilege.getKey().equals(privilegeTO.getKey()))) { privilege.setApplication(null); itor.remove();
@Override public boolean isValid(final Privilege privilege, final ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (privilege.getKey() == null || !KEY_PATTERN.matcher(privilege.getKey()).matches()) { context.buildConstraintViolationWithTemplate( getTemplate(EntityViolationType.InvalidKey, "Invalid privilege key")). addPropertyNode("key").addConstraintViolation(); return false; } return true; } }
forEach(privilege -> { PlainAttrValue attrValue = anyUtils.newPlainAttrValue(); attrValue.setStringValue(privilege.getKey()); values.add(attrValue); });