Search in sources :

Example 1 with PropertyServiceUnexpectedException

use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.

the class PropertyServiceImpl method findSubjectsProperties.

@Override
public Map<String, Map<String, String>> findSubjectsProperties(String appName, String domainName, List<String> subjectsIds) {
    if (CollectionUtils.isEmpty(subjectsIds)) {
        return new HashMap<String, Map<String, String>>();
    }
    checkArgumentsHaveText(appName, domainName);
    try {
        long appId = appNameAlias.getAliasFor(appName);
        long domainId = domainNameAlias.getAliasFor(domainName);
        Map<String, Map<String, String>> ret = new HashMap<String, Map<String, String>>();
        for (String subjectId : subjectsIds) {
            Map<String, String> properties = internalFindSubjectProperties(appId, domainId, subjectId);
            if (properties != null && properties.size() > 0) {
                ret.put(subjectId, properties);
            }
        }
        return ret;
    } catch (Throwable t) {
        throw new PropertyServiceUnexpectedException("Failed to find subjects properties", t);
    }
}
Also used : HashMap(java.util.HashMap) PropertyServiceUnexpectedException(org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with PropertyServiceUnexpectedException

use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.

the class PropertyServiceImpl method findSubjectProperties.

@Override
public Map<String, String> findSubjectProperties(String appName, String domainName, String subjectId) {
    checkArgumentsHaveText(appName, domainName, subjectId);
    try {
        long appId = appNameAlias.getAliasFor(appName);
        long domainId = domainNameAlias.getAliasFor(domainName);
        return internalFindSubjectProperties(appId, domainId, subjectId);
    } catch (Throwable t) {
        throw new PropertyServiceUnexpectedException("Failed to find subject properties", t);
    }
}
Also used : PropertyServiceUnexpectedException(org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException)

Example 3 with PropertyServiceUnexpectedException

use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.

the class PropertyServiceImpl method putSubjectProperty.

@Override
@Transactional(rollbackFor = Throwable.class)
public void putSubjectProperty(String appName, String domainName, String subjectId, String name, String value) {
    checkArgumentsHaveText(appName, domainName, subjectId, name);
    try {
        long appId = appNameAlias.getAliasFor(appName);
        long domainId = domainNameAlias.getAliasFor(domainName);
        long propertyNameId = propertyNameAlias.getAliasFor(name);
        propertyDao.putProperty(appId, domainId, subjectId, propertyNameId, value);
    } catch (Throwable t) {
        propagatePropertyNameIfTruncationError(t, name);
        throw new PropertyServiceUnexpectedException("Failed to put property", t);
    }
}
Also used : PropertyServiceUnexpectedException(org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with PropertyServiceUnexpectedException

use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.

the class PropertyServiceImpl method deleteSubjectProperties.

@Override
@Transactional(rollbackFor = Throwable.class)
public void deleteSubjectProperties(String appName, String domainName, String subjectId) {
    checkArgumentsHaveText(appName, domainName, subjectId);
    try {
        long appId = appNameAlias.getAliasFor(appName);
        long domainId = domainNameAlias.getAliasFor(domainName);
        propertyDao.deleteSubjectProperties(appId, domainId, subjectId);
    } catch (Throwable t) {
        throw new PropertyServiceUnexpectedException("Failed to delete subject properties", t);
    }
}
Also used : PropertyServiceUnexpectedException(org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with PropertyServiceUnexpectedException

use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.

the class StringIdAliasServiceEagerImpl method loadAllAliases.

protected final BiMap<String, Long> loadAllAliases() {
    try {
        BiMap<String, Long> ret = HashBiMap.create();
        long maxOffset = -2;
        for (long offset = 0; maxOffset == -2 || offset < maxOffset; offset = offset + EAGER_LOAD_BATCH_SIZE) {
            PagerParams pagerParams = new PagerParams(offset, EAGER_LOAD_BATCH_SIZE);
            PaginatedList<AliasEntry> loadedAliases = stringIdAliasDao.loadAllAliases(pagerParams);
            maxOffset = loadedAliases.getTotalResults() - 1;
            for (Entry<String, Long> entry : loadedAliases.getItems()) {
                ret.put(entry.getKey(), entry.getValue());
            }
        }
        return ret;
    } catch (Throwable t) {
        String msg = "Failed to eagerly load alias map";
        log.error(msg, t);
        throw new PropertyServiceUnexpectedException(msg, t);
    }
}
Also used : PagerParams(org.summerb.easycrud.api.dto.PagerParams) PropertyServiceUnexpectedException(org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException) AliasEntry(org.summerb.properties.impl.dao.AliasEntry)

Aggregations

PropertyServiceUnexpectedException (org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException)11 Transactional (org.springframework.transaction.annotation.Transactional)5 HashMap (java.util.HashMap)2 Map (java.util.Map)1 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)1 PagerParams (org.summerb.easycrud.api.dto.PagerParams)1 NamedProperty (org.summerb.properties.api.dto.NamedProperty)1 AliasEntry (org.summerb.properties.impl.dao.AliasEntry)1