Search in sources :

Example 1 with AnyTemplateRealm

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()));
}
Also used : AnyTemplateRealm(org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType)

Aggregations

AnyTemplateRealm (org.apache.syncope.core.persistence.api.entity.AnyTemplateRealm)1 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)1