Search in sources :

Example 36 with Transactional

use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.

the class NotificationMgmtService method addCommentedNotification.

/**
 * Adds a 'commented' type notification with the specified request json object.
 *
 * @param requestJSONObject the specified request json object, for example,
 *                          "userId"; "",
 *                          "dataId": ""
 * @throws ServiceException service exception
 */
@Transactional
public void addCommentedNotification(final JSONObject requestJSONObject) throws ServiceException {
    try {
        requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_COMMENTED);
        addNotification(requestJSONObject);
    } catch (final RepositoryException e) {
        final String msg = "Adds notification [type=commented] failed";
        LOGGER.log(Level.ERROR, msg, e);
        throw new ServiceException(msg);
    }
}
Also used : ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Example 37 with Transactional

use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.

the class NotificationMgmtService method makeRead.

/**
 * Makes the specified notification have been read.
 *
 * @param notification the specified notification, return directly if this notification has been read
 *                     (notification.hasRead equals to {@code true})
 * @throws ServiceException service exception
 */
@Transactional
public void makeRead(final JSONObject notification) throws ServiceException {
    if (notification.optBoolean(Notification.NOTIFICATION_HAS_READ)) {
        return;
    }
    final String id = notification.optString(Keys.OBJECT_ID);
    try {
        final JSONObject record = notificationRepository.get(id);
        if (null == record) {
            return;
        }
        record.put(Notification.NOTIFICATION_HAS_READ, true);
        notificationRepository.update(id, record);
    } catch (final RepositoryException e) {
        final String msg = "Makes notification as read failed";
        LOGGER.log(Level.ERROR, msg, e);
        throw new ServiceException(msg);
    }
}
Also used : JSONObject(org.json.JSONObject) ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Example 38 with Transactional

use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.

the class NotificationMgmtService method addArticleRewardNotification.

/**
 * Adds a 'article reward' type notification with the specified request json object.
 *
 * @param requestJSONObject the specified request json object, for example,
 *                          "userId"; "",
 *                          "dataId": "" // reward id
 * @throws ServiceException service exception
 */
@Transactional
public void addArticleRewardNotification(final JSONObject requestJSONObject) throws ServiceException {
    try {
        requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_POINT_ARTICLE_REWARD);
        addNotification(requestJSONObject);
    } catch (final RepositoryException e) {
        final String msg = "Adds notification [type=article_reward] failed";
        LOGGER.log(Level.ERROR, msg, e);
        throw new ServiceException(msg);
    }
}
Also used : ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Example 39 with Transactional

use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.

the class NotificationMgmtService method addInvitecodeUsedNotification.

/**
 * Adds a 'invitecode used' type notification with the specified request json object.
 *
 * @param requestJSONObject the specified request json object, for example,
 *                          "userId"; "",
 *                          "dataId": "" // invited user id
 * @throws ServiceException service exception
 */
@Transactional
public void addInvitecodeUsedNotification(final JSONObject requestJSONObject) throws ServiceException {
    try {
        requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_INVITECODE_USED);
        addNotification(requestJSONObject);
    } catch (final RepositoryException e) {
        final String msg = "Adds notification [type=invitecode_used] failed";
        LOGGER.log(Level.ERROR, msg, e);
        throw new ServiceException(msg);
    }
}
Also used : ServiceException(org.b3log.latke.service.ServiceException) Transactional(org.b3log.latke.repository.annotation.Transactional)

Example 40 with Transactional

use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.

the class NotificationMgmtService method addArticleNewFollowerNotification.

/**
 * Adds a 'article new follower' type notification with the specified request json object.
 *
 * @param requestJSONObject the specified request json object, for example,
 *                          "userId": "",
 *                          "dataId": "" // article id-follower user id
 * @throws ServiceException service exception
 */
@Transactional
public void addArticleNewFollowerNotification(final JSONObject requestJSONObject) throws ServiceException {
    try {
        requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_ARTICLE_NEW_FOLLOWER);
        addNotification(requestJSONObject);
    } catch (final RepositoryException e) {
        final String msg = "Adds notification [type=article_new_follower] failed";
        LOGGER.log(Level.ERROR, msg, e);
        throw new ServiceException(msg);
    }
}
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