use of org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm in project syncope by apache.
the class RealmDataBinderImpl method setTemplates.
private void setTemplates(final RealmTO realmTO, final Realm realm) {
// validate JEXL expressions from templates and proceed if fine
templateUtils.check(realmTO.getTemplates(), ClientExceptionType.InvalidRealm);
realmTO.getTemplates().forEach((key, template) -> {
AnyType type = anyTypeDAO.find(key);
if (type == null) {
LOG.debug("Invalid AnyType {} specified, ignoring...", key);
} else {
AnyTemplateRealm anyTemplate = realm.getTemplate(type).orElse(null);
if (anyTemplate == null) {
anyTemplate = entityFactory.newEntity(AnyTemplateRealm.class);
anyTemplate.setAnyType(type);
anyTemplate.setRealm(realm);
realm.add(anyTemplate);
}
anyTemplate.set(template);
}
});
// remove all templates not contained in the TO
realm.getTemplates().removeIf(template -> !realmTO.getTemplates().containsKey(template.getAnyType().getKey()));
}
Aggregations