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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations