protected void addSubscription( long subscriptionId, long companyId, long userId, String userName, Date createDate, Date modifiedDate, long classNameId, long classPK, String frequency) throws SystemException { Subscription subscription = subscriptionPersistence.create(subscriptionId); subscription.setCompanyId(companyId); subscription.setUserId(userId); subscription.setUserName(userName); subscription.setCreateDate(createDate); subscription.setModifiedDate(modifiedDate); subscription.setClassNameId(classNameId); subscription.setClassPK(classPK); subscription.setFrequency(frequency); subscriptionPersistence.update(subscription); }
public Subscription addSubscription( long userId, long groupId, String className, long classPK, String frequency) throws PortalException, SystemException { // Subscription User user = userPersistence.findByPrimaryKey(userId); long classNameId = PortalUtil.getClassNameId(className); Date now = new Date(); long subscriptionId = counterLocalService.increment(); Subscription subscription = subscriptionPersistence.fetchByC_U_C_C(user.getCompanyId(), userId, classNameId, classPK); if (subscription == null) { subscription = subscriptionPersistence.create(subscriptionId); subscription.setCompanyId(user.getCompanyId()); subscription.setUserId(user.getUserId()); subscription.setUserName(user.getFullName()); subscription.setCreateDate(now); subscription.setModifiedDate(now); subscription.setClassNameId(classNameId); subscription.setClassPK(classPK); subscription.setFrequency(frequency); subscriptionPersistence.update(subscription, false); } if (groupId > 0) { // Asset try { assetEntryLocalService.getEntry(className, classPK); } catch (Exception e) { assetEntryLocalService.updateEntry( userId, groupId, className, classPK, null, 0, null, null, false, null, null, null, null, null, String.valueOf(groupId), null, null, null, null, 0, 0, null, false); } // Social if (className.equals(MBThread.class.getName())) { MBThread mbThread = mbThreadLocalService.getMBThread(classPK); JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("threadId", classPK); socialActivityLocalService.addActivity( userId, groupId, MBMessage.class.getName(), mbThread.getRootMessageId(), SocialActivityConstants.TYPE_SUBSCRIBE, extraDataJSONObject.toString(), 0); } else { socialActivityLocalService.addActivity( userId, groupId, className, classPK, SocialActivityConstants.TYPE_SUBSCRIBE, StringPool.BLANK, 0); } socialEquityLogLocalService.addEquityLogs( userId, className, classPK, ActionKeys.SUBSCRIBE, StringPool.BLANK); } return subscription; }