Search in sources :

Example 51 with Transactional

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);
    }
}
Also used : JSONObject(org.json.JSONObject) ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Example 52 with Transactional

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);
    }
}
Also used : ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Aggregations

Transactional (org.b3log.latke.repository.annotation.Transactional)52 ServiceException (org.b3log.latke.service.ServiceException)42 JSONObject (org.json.JSONObject)20 JSONArray (org.json.JSONArray)11 RepositoryException (org.b3log.latke.repository.RepositoryException)6 Query (org.b3log.latke.repository.Query)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 ExecutionException (java.util.concurrent.ExecutionException)1 PropertyFilter (org.b3log.latke.repository.PropertyFilter)1 RequestProcessing (org.b3log.latke.servlet.annotation.RequestProcessing)1 TextHTMLRenderer (org.b3log.latke.servlet.renderer.TextHTMLRenderer)1