コード例 #1
0
  public static void getArticle(HttpServletRequest request) throws Exception {
    long groupId = ParamUtil.getLong(request, "groupId");
    long classNameId = ParamUtil.getLong(request, "classNameId");
    long classPK = ParamUtil.getLong(request, "classPK");
    String articleId = ParamUtil.getString(request, "articleId");
    String structureId = ParamUtil.getString(request, "structureId");

    JournalArticle article = null;

    if (Validator.isNotNull(articleId)) {
      article =
          JournalArticleServiceUtil.getLatestArticle(
              groupId, articleId, WorkflowConstants.STATUS_ANY);
    } else if ((classNameId > 0) && (classPK > 0)) {
      String className = PortalUtil.getClassName(classNameId);

      article = JournalArticleServiceUtil.getLatestArticle(groupId, className, classPK);
    } else if (Validator.isNotNull(structureId)) {
      JournalStructure structure = null;

      try {
        structure = JournalStructureServiceUtil.getStructure(groupId, structureId);
      } catch (NoSuchStructureException nsse1) {
        ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

        if (groupId == themeDisplay.getCompanyGroupId()) {
          return;
        }

        try {
          structure =
              JournalStructureServiceUtil.getStructure(
                  themeDisplay.getCompanyGroupId(), structureId);
        } catch (NoSuchStructureException nsse2) {
          return;
        }
      }

      article =
          JournalArticleServiceUtil.getArticle(
              groupId, JournalStructure.class.getName(), structure.getId());

      article.setNew(true);

      article.setId(0);
      article.setClassNameId(0);
      article.setClassPK(0);
      article.setArticleId(null);
      article.setVersion(0);
    }

    request.setAttribute(WebKeys.JOURNAL_ARTICLE, article);
  }
コード例 #2
0
  @Override
  public String getRowCheckBox(
      HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

    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;
        }
      }
    }

    boolean showInput = false;

    String name = null;

    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("Checkbox', '");
    sb.append(_liferayPortletResponse.getNamespace());
    sb.append(RowChecker.ROW_IDS);
    sb.append(JournalArticle.class.getSimpleName());
    sb.append("Checkbox']");

    String checkBoxRowIds = sb.toString();

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