@Override
  protected boolean hasPermissions(
      PermissionChecker permissionChecker,
      SocialActivity activity,
      String actionId,
      ServiceContext serviceContext)
      throws Exception {

    int activityType = activity.getType();

    if (activityType == JournalActivityKeys.ADD_ARTICLE) {
      JournalArticle article = _journalArticleLocalService.getLatestArticle(activity.getClassPK());

      return JournalFolderPermission.contains(
          permissionChecker, article.getGroupId(), article.getFolderId(), ActionKeys.ADD_ARTICLE);
    } else if (activityType == JournalActivityKeys.UPDATE_ARTICLE) {
      return JournalArticlePermission.contains(
          permissionChecker, activity.getClassPK(), ActionKeys.UPDATE);
    }

    return JournalArticlePermission.contains(permissionChecker, activity.getClassPK(), actionId);
  }
Пример #2
0
  @Override
  public String getRowCheckBox(
      HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

    if (!_journalDisplayContext.isShowEditActions()) {
      return StringPool.BLANK;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    JournalArticle article = null;
    JournalFolder folder = null;

    String articleId = GetterUtil.getString(primaryKey);

    try {
      article = JournalArticleServiceUtil.getArticle(themeDisplay.getScopeGroupId(), articleId);
    } catch (Exception e1) {
      if (e1 instanceof NoSuchArticleException) {
        try {
          long folderId = GetterUtil.getLong(primaryKey);

          folder = JournalFolderServiceUtil.getFolder(folderId);
        } catch (Exception e2) {
          return StringPool.BLANK;
        }
      }
    }

    String name = null;
    boolean showInput = false;

    if (article != null) {
      name = JournalArticle.class.getSimpleName();

      try {
        if (JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.DELETE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.EXPIRE)
            || JournalArticlePermission.contains(_permissionChecker, article, ActionKeys.UPDATE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    } else if (folder != null) {
      name = JournalFolder.class.getSimpleName();

      try {
        if (JournalFolderPermission.contains(_permissionChecker, folder, ActionKeys.DELETE)) {

          showInput = true;
        }
      } catch (Exception e) {
      }
    }

    if (!showInput) {
      return StringPool.BLANK;
    }

    StringBundler sb = new StringBundler(9);

    sb.append("['");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalFolder.class.getSimpleName());
    sb.append("', '");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalArticle.class.getSimpleName());
    sb.append("']");

    String checkBoxRowIds = sb.toString();

    return getRowCheckBox(
        request,
        checked,
        disabled,
        _liferayPortletResponse.getNamespace() + RowChecker.ROW_IDS + name + "",
        primaryKey,
        checkBoxRowIds,
        "'#" + getAllRowIds() + "'",
        StringPool.BLANK);
  }