use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.
the class StringIdAliasServiceEagerImpl method registerAlias.
/**
* Will register alias (or retrieve already stored, only - useful for multi
* server installation - environment - AKA webfarm)
*/
protected final synchronized long registerAlias(String str) {
// WARNING: This method must be called only after getALiasFor invoked at
// least once, otherwise NullPointerException might happen
Long ret = aliases.get(str);
// sanity check if someone has already stored it
if (ret != null) {
return ret.longValue();
}
long alias;
try {
try {
alias = doCreateAlias(str);
} catch (DuplicateKeyException dke) {
log.debug("Looks like alias already exist in database, will load it");
ret = stringIdAliasDao.findAliasFor(str);
if (ret == null) {
throw new PropertyServiceUnexpectedException("Failed to create alias because of duplicate, but later was unable to find that duplicate.");
}
alias = ret.longValue();
}
} catch (Throwable t) {
throw new PropertyServiceUnexpectedException("Failed to store alias", t);
}
// store it locally
aliases.put(str, alias);
// ret
return alias;
}
use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.
the class PropertyServiceImpl method findSubjectProperty.
@Override
public String findSubjectProperty(String appName, String domainName, String subjectId, String name) {
checkArgumentsHaveText(appName, domainName, subjectId, name);
try {
long appId = appNameAlias.getAliasFor(appName);
long domainId = domainNameAlias.getAliasFor(domainName);
long propertyNameId = propertyNameAlias.getAliasFor(name);
return propertyDao.findSubjectProperty(appId, domainId, subjectId, propertyNameId);
} catch (Throwable t) {
throw new PropertyServiceUnexpectedException("Failed to find subject property", t);
}
}
use of org.summerb.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);
}
}
use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.
the class PropertyServiceImpl method deleteSubjectsProperties.
@Override
@Transactional(rollbackFor = Throwable.class)
public void deleteSubjectsProperties(String appName, String domainName, List<String> subjectsIds) {
if (CollectionUtils.isEmpty(subjectsIds)) {
return;
}
checkArgumentsHaveText(appName, domainName);
try {
long appId = appNameAlias.getAliasFor(appName);
long domainId = domainNameAlias.getAliasFor(domainName);
for (String subjectId : subjectsIds) {
propertyDao.deleteSubjectProperties(appId, domainId, subjectId);
}
} catch (Throwable t) {
throw new PropertyServiceUnexpectedException("Failed to delete subject properties", t);
}
}
use of org.summerb.properties.api.exceptions.PropertyServiceUnexpectedException in project summerb by skarpushin.
the class PropertyServiceImpl method findSubjectsProperty.
@Override
public Map<String, String> findSubjectsProperty(String appName, String domainName, List<String> subjectsIds, String name) {
if (CollectionUtils.isEmpty(subjectsIds)) {
return new HashMap<String, String>();
}
checkArgumentsHaveText(appName, domainName, name);
try {
long appId = appNameAlias.getAliasFor(appName);
long domainId = domainNameAlias.getAliasFor(domainName);
long propertyNameId = propertyNameAlias.getAliasFor(name);
Map<String, String> ret = new HashMap<String, String>();
for (String subjectId : subjectsIds) {
String value = propertyDao.findSubjectProperty(appId, domainId, subjectId, propertyNameId);
if (value != null) {
ret.put(subjectId, value);
}
}
return ret;
} catch (Throwable t) {
throw new PropertyServiceUnexpectedException("Failed to find subject property", t);
}
}
Aggregations