public void unsubscribe(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); if (!themeDisplay.isSignedIn()) { return; } long[] subscriptionIds = StringUtil.split(ParamUtil.getString(actionRequest, "subscriptionIds"), 0L); for (long subscriptionId : subscriptionIds) { if (subscriptionId <= 0) { continue; } Subscription subscription = SubscriptionLocalServiceUtil.getSubscription(subscriptionId); if (themeDisplay.getUserId() != subscription.getUserId()) { throw new PrincipalException(); } SubscriptionLocalServiceUtil.deleteSubscription(subscription); } }
public void deleteGroupKBArticles(long groupId) throws PortalException, SystemException { // KB articles List<KBArticle> kbArticles = getSiblingKBArticles( groupId, KBArticleConstants.DEFAULT_PARENT_RESOURCE_PRIM_KEY, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, new KBArticlePriorityComparator()); for (KBArticle kbArticle : kbArticles) { deleteKBArticle(kbArticle); } // Subscriptions Group group = groupLocalService.getGroup(groupId); List<Subscription> subscriptions = subscriptionLocalService.getSubscriptions( group.getCompanyId(), KBArticle.class.getName(), groupId); for (Subscription subscription : subscriptions) { unsubscribeGroupKBArticles(subscription.getUserId(), groupId); } }
protected void deleteSubscriptions(KBArticle kbArticle) throws PortalException, SystemException { List<Subscription> subscriptions = subscriptionLocalService.getSubscriptions( kbArticle.getCompanyId(), KBArticle.class.getName(), kbArticle.getResourcePrimKey()); for (Subscription subscription : subscriptions) { unsubscribeKBArticle(subscription.getUserId(), subscription.getClassPK()); } }
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 static Set<Long> getThreadSubscriptionClassPKs(long userId) { List<Subscription> subscriptions = SubscriptionLocalServiceUtil.getUserSubscriptions(userId, MBThread.class.getName()); Set<Long> classPKs = new HashSet<Long>(subscriptions.size()); for (Subscription subscription : subscriptions) { classPKs.add(subscription.getClassPK()); } return classPKs; }
public static Set<Long> getCategorySubscriptionClassPKs(long userId) throws SystemException { List<Subscription> subscriptions = SubscriptionLocalServiceUtil.getUserSubscriptions(userId, MBCategory.class.getName()); Set<Long> classPKs = new HashSet<Long>(subscriptions.size()); for (Subscription subscription : subscriptions) { classPKs.add(subscription.getClassPK()); } return classPKs; }
@Override public Set<Long> getFileEntryTypeSubscriptionClassPKs(long userId) throws SystemException { List<Subscription> subscriptions = SubscriptionLocalServiceUtil.getUserSubscriptions(userId, DLFileEntryType.class.getName()); Set<Long> classPKs = new HashSet<Long>(subscriptions.size()); for (Subscription subscription : subscriptions) { classPKs.add(subscription.getClassPK()); } return classPKs; }
/** * Adds the subscription to the database. Also notifies the appropriate model listeners. * * @param subscription the subscription * @return the subscription that was added */ @Indexable(type = IndexableType.REINDEX) @Override public Subscription addSubscription(Subscription subscription) { subscription.setNew(true); return subscriptionPersistence.update(subscription); }
@Override public void deleteSubscription(Subscription subscription) throws PortalException, SystemException { // Subscription subscriptionPersistence.remove(subscription); // Social AssetEntry assetEntry = assetEntryPersistence.fetchByC_C(subscription.getClassNameId(), subscription.getClassPK()); if (assetEntry != null) { String className = PortalUtil.getClassName(subscription.getClassNameId()); socialActivityLocalService.addActivity( subscription.getUserId(), assetEntry.getGroupId(), className, subscription.getClassPK(), SocialActivityConstants.TYPE_UNSUBSCRIBE, StringPool.BLANK, 0); socialEquityLogLocalService.deactivateEquityLogs( subscription.getUserId(), className, subscription.getClassPK(), ActionKeys.SUBSCRIBE, StringPool.BLANK); } }
protected long getSubscriptionId(long userId, MicroblogsEntry microblogsEntry) { try { Subscription subscription = subscriptionLocalService.getSubscription( microblogsEntry.getCompanyId(), userId, MicroblogsEntry.class.getName(), microblogsEntry.getParentMicroblogsEntryId()); return subscription.getSubscriptionId(); } catch (PortalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } } return 0; }
public int compareTo(Subscription subscription) { long primaryKey = subscription.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } Subscription subscription = null; try { subscription = (Subscription) obj; } catch (ClassCastException cce) { return false; } long primaryKey = subscription.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
protected void importSubscription(Subscription subscription, long calendarBookingId) throws SystemException { addSubscription( counterLocalService.increment(), subscription.getCompanyId(), subscription.getUserId(), subscription.getUserName(), subscription.getCreateDate(), subscription.getModifiedDate(), classNameLocalService.getClassNameId(CalendarBooking.class), calendarBookingId, subscription.getFrequency()); }
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; }
@Override public Long get(Subscription subscription) { return subscription.getSubscriptionId(); }