Search in sources :

Example 1 with PropertyServiceUnexpectedException

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

the class PropertyServiceImpl method putSubjectsProperty.

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

Example 2 with PropertyServiceUnexpectedException

use of org.summerb.microservices.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.microservices.properties.api.exceptions.PropertyServiceUnexpectedException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with PropertyServiceUnexpectedException

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

the class PropertyServiceImpl method putSubjectProperties.

@Transactional(rollbackFor = Throwable.class)
@Override
public void putSubjectProperties(String appName, String domainName, String subjectId, List<NamedProperty> namedProperties) {
    if (CollectionUtils.isEmpty(namedProperties)) {
        return;
    }
    checkArgumentsHaveText(appName, domainName, subjectId);
    String currentPropertyName = null;
    try {
        long appId = appNameAlias.getAliasFor(appName);
        long domainId = domainNameAlias.getAliasFor(domainName);
        for (NamedProperty namedProperty : namedProperties) {
            currentPropertyName = namedProperty.getName();
            long propertyNameId = propertyNameAlias.getAliasFor(currentPropertyName);
            String value = namedProperty.getPropertyValue();
            propertyDao.putProperty(appId, domainId, subjectId, propertyNameId, value);
        }
    } catch (Throwable t) {
        propagatePropertyNameIfTruncationError(t, currentPropertyName);
        throw new PropertyServiceUnexpectedException("Failed to put subject properties", t);
    }
}
Also used : NamedProperty(org.summerb.microservices.properties.api.dto.NamedProperty) PropertyServiceUnexpectedException(org.summerb.microservices.properties.api.exceptions.PropertyServiceUnexpectedException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with PropertyServiceUnexpectedException

use of org.summerb.microservices.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.microservices.properties.api.exceptions.PropertyServiceUnexpectedException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with PropertyServiceUnexpectedException

use of org.summerb.microservices.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.microservices.properties.api.exceptions.PropertyServiceUnexpectedException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PropertyServiceUnexpectedException (org.summerb.microservices.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.approaches.jdbccrud.api.dto.PagerParams)1 NamedProperty (org.summerb.microservices.properties.api.dto.NamedProperty)1 AliasEntry (org.summerb.microservices.properties.impl.dao.AliasEntry)1