001
014
015 package com.liferay.portlet.social.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.transaction.Propagation;
020 import com.liferay.portal.kernel.transaction.Transactional;
021 import com.liferay.portal.model.User;
022 import com.liferay.portlet.social.model.SocialActivityLimit;
023 import com.liferay.portlet.social.service.base.SocialActivityLimitLocalServiceBaseImpl;
024
025
028 public class SocialActivityLimitLocalServiceImpl
029 extends SocialActivityLimitLocalServiceBaseImpl {
030
031 @Override
032 @Transactional(
033 propagation = Propagation.REQUIRES_NEW,
034 rollbackFor = {PortalException.class, SystemException.class})
035 public SocialActivityLimit addActivityLimit(
036 long userId, long groupId, long classNameId, long classPK,
037 int activityType, String activityCounterName, int limitPeriod)
038 throws PortalException, SystemException {
039
040 User user = userPersistence.findByPrimaryKey(userId);
041
042 long activityLimitId = counterLocalService.increment();
043
044 SocialActivityLimit activityLimit =
045 socialActivityLimitPersistence.create(activityLimitId);
046
047 activityLimit.setGroupId(groupId);
048 activityLimit.setCompanyId(user.getCompanyId());
049 activityLimit.setUserId(userId);
050 activityLimit.setClassNameId(classNameId);
051 activityLimit.setClassPK(classPK);
052 activityLimit.setActivityType(activityType);
053 activityLimit.setActivityCounterName(activityCounterName);
054 activityLimit.setCount(limitPeriod, 0);
055
056 socialActivityLimitPersistence.update(activityLimit, false);
057
058 return activityLimit;
059 }
060
061 }