Search in sources :

Example 1 with ValueWrapper

use of eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper in project CzechIdMng by bcvsolutions.

the class AbstractSynchronizationExecutor method getValueByMappedAttribute.

protected Object getValueByMappedAttribute(AttributeMapping attribute, List<IcAttribute> icAttributes, SynchronizationContext context) {
    if (attribute == null || icAttributes == null) {
        return null;
    }
    if (attribute instanceof SysSystemAttributeMappingDto && context != null && context.getConfig() != null) {
        SysSystemAttributeMappingDto attributeMappingDto = (SysSystemAttributeMappingDto) attribute;
        // Set ID of this sync to attribute instance. A configuration of sync can be use in script.
        attributeMappingDto.setSyncConfigId(context.getConfig().getId());
    }
    // If is attribute marked as not "cached", then none cache is using
    if (!attribute.isCached()) {
        return systemAttributeMappingService.getValueByMappedAttribute(attribute, icAttributes);
    }
    AttributeValueWrapperDto key = new AttributeValueWrapperDto(attribute, icAttributes);
    ValueWrapper value = this.getCachedValue(key);
    if (value != null) {
        return value.get();
    }
    Object valueByMappedAttribute = systemAttributeMappingService.getValueByMappedAttribute(attribute, icAttributes);
    this.setCachedValue(key, valueByMappedAttribute);
    // 
    return valueByMappedAttribute;
}
Also used : ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) AttributeValueWrapperDto(eu.bcvsolutions.idm.acc.dto.AttributeValueWrapperDto)

Example 2 with ValueWrapper

use of eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method getCacheProcessedItems.

@Override
public SysProvisioningBreakItems getCacheProcessedItems(UUID systemId) {
    ValueWrapper cachedValueWrapper = this.idmCacheManager.getValue(CACHE_NAME, systemId);
    SysProvisioningBreakItems cache;
    if (cachedValueWrapper == null) {
        cache = localCache.get(systemId);
    } else {
        cache = (SysProvisioningBreakItems) cachedValueWrapper.get();
        localCache.remove(systemId);
    }
    // 
    return cache == null ? new SysProvisioningBreakItems() : cache;
}
Also used : ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) SysProvisioningBreakItems(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems)

Example 3 with ValueWrapper

use of eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper in project CzechIdMng by bcvsolutions.

the class DefaultPasswordFilterManager method getEcho.

@Override
public AccPasswordFilterEchoItemDto getEcho(UUID accountId) {
    ValueWrapper value = idmCacheManager.getValue(ECHO_CACHE_NAME, accountId);
    if (value == null) {
        return null;
    }
    Object echoAsObject = value.get();
    if (echoAsObject == null) {
        return null;
    }
    return (AccPasswordFilterEchoItemDto) echoAsObject;
}
Also used : ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) AccPasswordFilterEchoItemDto(eu.bcvsolutions.idm.acc.dto.AccPasswordFilterEchoItemDto)

Example 4 with ValueWrapper

use of eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper in project CzechIdMng by bcvsolutions.

the class DefaultIdmCacheManagerIntegrationTest method testCacheGetNotCreatesCache.

// TODO: do we need this? It would slow down retrieving entries from cache
@Ignore
@Test
public void testCacheGetNotCreatesCache() {
    ValueWrapper val = cacheManager.getValue(CACHE_NAME_5, "key");
    Assert.assertNull(val);
    Assert.assertNull(cacheManager.getAllAvailableCaches().stream().filter(c -> CACHE_NAME_5.equals(c.getId())).findFirst().orElse(null));
}
Also used : Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) Assert(org.junit.Assert) Before(org.junit.Before) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with ValueWrapper

use of eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper in project CzechIdMng by bcvsolutions.

the class DefaultFormService method getCachedDefinitions.

private FormDefinitionCache getCachedDefinitions(String type) {
    String cacheKey = getCacheKey(type);
    ValueWrapper value = cacheManager.getValue(FORM_DEFINITION_CACHE_NAME, cacheKey);
    if (value != null) {
        // never null
        return (FormDefinitionCache) value.get();
    }
    // 
    IdmFormDefinitionFilter filter = new IdmFormDefinitionFilter();
    filter.setType(type);
    List<IdmFormDefinitionDto> definitions = formDefinitionService.find(filter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmFormDefinition_.code.getName()))).getContent();
    // 
    // cache definition by id
    definitions.forEach(definition -> {
        // set mapped attributes - required to cache form definition with attributes
        IdmFormAttributeFilter attributeFilter = new IdmFormAttributeFilter();
        attributeFilter.setDefinitionId(definition.getId());
        definition.setTrimmed(false);
        definition.setFormAttributes(formAttributeService.find(attributeFilter, PageRequest.of(0, Integer.MAX_VALUE, Sort.by(IdmFormAttribute_.seq.getName(), IdmFormAttribute_.name.getName()))).getContent());
        // 
        FormDefinitionCache cachedDefinition = new FormDefinitionCache();
        cachedDefinition.putDefinition(definition);
        // 
        cacheManager.cacheValue(FORM_DEFINITION_CACHE_NAME, getCacheKey(definition.getId()), cachedDefinition);
    });
    // 
    // cache by type
    FormDefinitionCache cachedDefinitions = new FormDefinitionCache();
    cachedDefinitions.putDefinitions(definitions);
    cacheManager.cacheValue(FORM_DEFINITION_CACHE_NAME, cacheKey, cachedDefinitions);
    // 
    return cachedDefinitions;
}
Also used : FormDefinitionCache(eu.bcvsolutions.idm.core.eav.api.domain.FormDefinitionCache) IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) IdmFormDefinitionFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormDefinitionFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)

Aggregations

ValueWrapper (eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper)19 UUID (java.util.UUID)7 Set (java.util.Set)5 IdmAuthorizationPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmAuthorizationPolicyDto)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 IdmAuthorizationPolicyService (eu.bcvsolutions.idm.core.api.service.IdmAuthorizationPolicyService)3 IdmCacheManager (eu.bcvsolutions.idm.core.api.service.IdmCacheManager)3 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)3 AuthorizableType (eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType)3 AuthorizationEvaluatorDto (eu.bcvsolutions.idm.core.security.api.dto.AuthorizationEvaluatorDto)3 AuthorizationManager (eu.bcvsolutions.idm.core.security.api.service.AuthorizationManager)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 RoleConfiguration (eu.bcvsolutions.idm.core.api.config.domain.RoleConfiguration)2 ConfigurationMap (eu.bcvsolutions.idm.core.api.domain.ConfigurationMap)2 ContractState (eu.bcvsolutions.idm.core.api.domain.ContractState)2 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)2