protected void sendNotificationEvent( final MicroblogsEntry microblogsEntry, ServiceContext serviceContext) throws PortalException { final JSONObject notificationEventJSONObject = JSONFactoryUtil.createJSONObject(); notificationEventJSONObject.put("className", MicroblogsEntry.class.getName()); notificationEventJSONObject.put("classPK", microblogsEntry.getMicroblogsEntryId()); notificationEventJSONObject.put( "entryTitle", MicroblogsUtil.getProcessedContent( StringUtil.shorten(microblogsEntry.getContent(), 50), serviceContext)); AssetRendererFactory<MicroblogsEntry> assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClass(MicroblogsEntry.class); AssetRenderer<MicroblogsEntry> assetRenderer = assetRendererFactory.getAssetRenderer(microblogsEntry.getMicroblogsEntryId()); String entryURL = StringPool.BLANK; try { entryURL = assetRenderer.getURLViewInContext( serviceContext.getLiferayPortletRequest(), serviceContext.getLiferayPortletResponse(), null); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } } notificationEventJSONObject.put("entryURL", entryURL); notificationEventJSONObject.put("userId", microblogsEntry.getUserId()); final List<Long> receiverUserIds = MicroblogsUtil.getSubscriberUserIds(microblogsEntry); Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { MessageBusUtil.sendMessage( DestinationNames.ASYNC_SERVICE, new NotificationProcessCallable( receiverUserIds, microblogsEntry, notificationEventJSONObject)); return null; } }; TransactionCommitCallbackUtil.registerCallback(callable); }
public static boolean contains( PermissionChecker permissionChecker, MicroblogsEntry microblogsEntry, String actionId) { if (actionId.equals(ActionKeys.DELETE) || actionId.equals(ActionKeys.UPDATE)) { if (permissionChecker.hasOwnerPermission( microblogsEntry.getCompanyId(), MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId(), microblogsEntry.getUserId(), actionId)) { return true; } return false; } if (permissionChecker.hasOwnerPermission( microblogsEntry.getCompanyId(), MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId(), microblogsEntry.getUserId(), actionId)) { return true; } if (microblogsEntry.getSocialRelationType() == 0) { return true; } if ((microblogsEntry.getUserId() != permissionChecker.getUserId()) && SocialRelationLocalServiceUtil.hasRelation( permissionChecker.getUserId(), microblogsEntry.getUserId(), microblogsEntry.getSocialRelationType())) { return true; } return false; }
@Override public MicroblogsEntry deleteMicroblogsEntry(MicroblogsEntry microblogsEntry) throws PortalException { // Microblogs entry microblogsEntryPersistence.remove(microblogsEntry); // Asset assetEntryLocalService.deleteEntry( MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId()); // Social socialActivityLocalService.deleteActivities( MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId()); return microblogsEntry; }
public void updateAsset( MicroblogsEntry microblogsEntry, long[] assetCategoryIds, String[] assetTagNames) throws PortalException, SystemException { Group group = GroupLocalServiceUtil.getCompanyGroup(microblogsEntry.getCompanyId()); AssetEntryLocalServiceUtil.updateEntry( microblogsEntry.getUserId(), group.getGroupId(), MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId(), assetCategoryIds, assetTagNames); }
protected void sendNotificationEvent(MicroblogsEntry microblogsEntry) throws PortalException, SystemException { JSONObject notificationEventJSONObject = JSONFactoryUtil.createJSONObject(); notificationEventJSONObject.put("body", microblogsEntry.getContent()); notificationEventJSONObject.put("entryId", microblogsEntry.getMicroblogsEntryId()); notificationEventJSONObject.put("entryKeyName", "receiverMicroblogsEntryId"); notificationEventJSONObject.put("mvcPath", "/microblogs/view.jsp"); notificationEventJSONObject.put("portletId", "1_WAR_microblogsportlet"); notificationEventJSONObject.put("title", "x-commented-on-your-post"); notificationEventJSONObject.put("userId", microblogsEntry.getUserId()); NotificationEvent notificationEvent = NotificationEventFactoryUtil.createNotificationEvent( System.currentTimeMillis(), "6_WAR_soportlet", notificationEventJSONObject); notificationEvent.setDeliveryRequired(0); ChannelHubManagerUtil.sendNotificationEvent( microblogsEntry.getCompanyId(), microblogsEntry.getReceiverUserId(), notificationEvent); }