コード例 #1
0
  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;
  }
コード例 #2
0
  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);
  }
コード例 #3
0
  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;
  }
コード例 #4
0
  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);
  }