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;
}
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;
}
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;
}
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));
}
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;
}
Aggregations