use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class DomainMgmtService method addDomainTag.
/**
* Adds a domain-tag relation.
*
* @param domainTag the specified domain-tag relation
* @throws ServiceException service exception
*/
@Transactional
public void addDomainTag(final JSONObject domainTag) throws ServiceException {
try {
final String domainId = domainTag.optString(Domain.DOMAIN + "_" + Keys.OBJECT_ID);
final JSONObject domain = domainRepository.get(domainId);
domain.put(Domain.DOMAIN_TAG_COUNT, domain.optInt(Domain.DOMAIN_TAG_COUNT) + 1);
domainRepository.update(domainId, domain);
domainTagRepository.add(domainTag);
// Refresh cache
domainCache.loadDomains();
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Adds a domain-tag relation failed", e);
throw new ServiceException(e);
}
}
use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class DomainMgmtService method updateDomain.
/**
* Updates the specified domain by the given domain id.
*
* @param domainId the given domain id
* @param domain the specified domain
* @throws ServiceException service exception
*/
@Transactional
public void updateDomain(final String domainId, final JSONObject domain) throws ServiceException {
try {
domainRepository.update(domainId, domain);
// Refresh cache
domainCache.loadDomains();
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Updates a domain [id=" + domainId + "] failed", e);
throw new ServiceException(e);
}
}
Aggregations