コード例 #1
0
  @Override
  protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalArticleLocalServiceUtil.getNotInTrashArticlesCount(
        folder.getGroupId(), folder.getFolderId());
  }
コード例 #2
0
  @Override
  protected List<? extends WorkflowedModel> getChildrenWorkflowedModels(
      BaseModel<?> parentBaseModel) throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalArticleLocalServiceUtil.getArticles(folder.getGroupId(), folder.getFolderId());
  }
コード例 #3
0
  @Override
  protected void expireBaseModelVersions(
      BaseModel<?> baseModel, boolean expireAllVersions, ServiceContext serviceContext)
      throws Exception {

    JournalArticle article = (JournalArticle) baseModel;

    if (expireAllVersions) {
      JournalArticleLocalServiceUtil.expireArticle(
          article.getUserId(),
          article.getGroupId(),
          article.getArticleId(),
          article.getUrlTitle(),
          serviceContext);
    } else {
      JournalArticleLocalServiceUtil.expireArticle(
          article.getUserId(), article.getGroupId(),
          article.getArticleId(), article.getVersion(),
          article.getUrlTitle(), serviceContext);
    }
  }
コード例 #4
0
  @Override
  protected BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext)
      throws Exception {

    JournalArticle article = JournalArticleLocalServiceUtil.getArticle(primaryKey);

    return JournalTestUtil.updateArticle(
        article,
        "Content: Enterprise. Open Source. For Life.",
        article.getContent(),
        false,
        true,
        serviceContext);
  }
コード例 #5
0
  @Override
  protected BaseModel<?> expireBaseModel(BaseModel<?> baseModel, ServiceContext serviceContext)
      throws Exception {

    JournalArticle article = (JournalArticle) baseModel;

    return JournalArticleLocalServiceUtil.expireArticle(
        article.getUserId(),
        article.getGroupId(),
        article.getArticleId(),
        article.getVersion(),
        StringPool.BLANK,
        serviceContext);
  }
  @Override
  protected String getPath(SocialActivity activity, ServiceContext serviceContext)
      throws Exception {

    JournalArticle article = JournalArticleLocalServiceUtil.getLatestArticle(activity.getClassPK());

    Layout layout = article.getLayout();

    if (layout != null) {
      String groupFriendlyURL =
          PortalUtil.getGroupFriendlyURL(layout.getLayoutSet(), serviceContext.getThemeDisplay());

      return groupFriendlyURL
          .concat(JournalArticleConstants.CANONICAL_URL_SEPARATOR)
          .concat(article.getUrlTitle());
    }

    return null;
  }
  @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 =
          JournalArticleLocalServiceUtil.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);
  }
コード例 #8
0
  public static String getURL(
      HttpServletRequest request,
      ThemeDisplay themeDisplay,
      AssetRendererFactory assetRendererFactory,
      AssetRenderer assetRenderer)
      throws Exception {

    long classPK = assetRenderer.getClassPK();
    String className = assetRendererFactory.getClassName();
    String portletId = PortletProviderUtil.getPortletId(className, PortletProvider.Action.VIEW);

    PortletURL portletURL = null;

    if (className.equals(BlogsEntry.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry");
      portletURL.setParameter("entryId", String.valueOf(classPK));
    } else if (className.equals(JournalArticle.class.getName())) {
      JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/journal_content/view");
      portletURL.setParameter("groupId", String.valueOf(journalArticle.getGroupId()));
      portletURL.setParameter("articleId", journalArticle.getArticleId());
    } else if (className.equals(KBArticle.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request,
              PortletKeys.KNOWLEDGE_BASE_ARTICLE_DEFAULT_INSTANCE,
              themeDisplay.getPlid(),
              PortletRequest.RENDER_PHASE);

      portletURL.setParameter("mvcPath", "/article/view_article.jsp");
      portletURL.setParameter("resourcePrimKey", String.valueOf(classPK));
    } else if (className.equals(MBMessage.class.getName())) {
      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/message_boards/view_message");
      portletURL.setParameter("messageId", String.valueOf(classPK));
    } else if (className.equals(WikiPage.class.getName())) {
      WikiPage wikiPage = WikiPageLocalServiceUtil.getPage(classPK);

      portletURL =
          PortletURLFactoryUtil.create(
              request, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

      portletURL.setParameter("struts_action", "/wiki/view");
      portletURL.setParameter("nodeId", String.valueOf(wikiPage.getNodeId()));
      portletURL.setParameter("title", wikiPage.getTitle());
    }

    String currentURL = PortalUtil.getCurrentURL(request);

    if (portletURL == null) {
      return currentURL;
    }

    portletURL.setWindowState(WindowState.MAXIMIZED);
    portletURL.setPortletMode(PortletMode.VIEW);

    portletURL.setParameter("returnToFullPageURL", currentURL);

    return portletURL.toString();
  }
コード例 #9
0
  public ArticleSearch getSearchContainer() throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    ArticleSearch articleSearchContainer =
        new ArticleSearch(_liferayPortletRequest, getPortletURL());

    OrderByComparator<JournalArticle> orderByComparator =
        JournalPortletUtil.getArticleOrderByComparator(getOrderByCol(), getOrderByType());

    articleSearchContainer.setOrderByCol(getOrderByCol());
    articleSearchContainer.setOrderByComparator(orderByComparator);
    articleSearchContainer.setOrderByType(getOrderByType());

    EntriesChecker entriesChecker =
        new EntriesChecker(_liferayPortletRequest, _liferayPortletResponse);

    entriesChecker.setCssClass("entry-selector");

    articleSearchContainer.setRowChecker(entriesChecker);

    EntriesMover entriesMover = new EntriesMover(themeDisplay.getScopeGroupId());

    articleSearchContainer.setRowMover(entriesMover);

    if (isNavigationMine() || isNavigationRecent()) {
      boolean includeOwner = true;

      if (isNavigationMine()) {
        includeOwner = false;
      }

      if (isNavigationRecent()) {
        articleSearchContainer.setOrderByCol("create-date");
        articleSearchContainer.setOrderByType(getOrderByType());
      }

      int total =
          JournalArticleServiceUtil.getGroupArticlesCount(
              themeDisplay.getScopeGroupId(),
              themeDisplay.getUserId(),
              getFolderId(),
              getStatus(),
              includeOwner);

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.getGroupArticles(
              themeDisplay.getScopeGroupId(),
              themeDisplay.getUserId(),
              getFolderId(),
              getStatus(),
              includeOwner,
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMStructureKey())) {
      int total =
          JournalArticleServiceUtil.getArticlesCountByStructureId(
              themeDisplay.getScopeGroupId(), getDDMStructureKey(), getStatus());

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.getArticlesByStructureId(
              themeDisplay.getScopeGroupId(),
              getDDMStructureKey(),
              getStatus(),
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (Validator.isNotNull(getDDMTemplateKey())) {
      List<Long> folderIds = new ArrayList<>(1);

      if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        folderIds.add(getFolderId());
      }

      int total =
          JournalArticleServiceUtil.searchCount(
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              folderIds,
              JournalArticleConstants.CLASSNAME_ID_DEFAULT,
              getKeywords(),
              -1.0,
              getDDMStructureKey(),
              getDDMTemplateKey(),
              null,
              null,
              getStatus(),
              null);

      articleSearchContainer.setTotal(total);

      List results =
          JournalArticleServiceUtil.search(
              themeDisplay.getCompanyId(),
              themeDisplay.getScopeGroupId(),
              folderIds,
              JournalArticleConstants.CLASSNAME_ID_DEFAULT,
              getKeywords(),
              -1.0,
              getDDMStructureKey(),
              getDDMTemplateKey(),
              null,
              null,
              getStatus(),
              null,
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              articleSearchContainer.getOrderByComparator());

      articleSearchContainer.setResults(results);
    } else if (isSearch()) {
      List<Long> folderIds = new ArrayList<>(1);

      if (getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        folderIds.add(getFolderId());
      }

      JournalWebConfiguration journalWebConfiguration =
          (JournalWebConfiguration) _request.getAttribute(JournalWebConfiguration.class.getName());

      if (journalWebConfiguration.journalArticlesSearchWithIndex()) {
        boolean orderByAsc = false;

        if (Validator.equals(getOrderByType(), "asc")) {
          orderByAsc = true;
        }

        Sort sort = null;

        if (Validator.equals(getOrderByCol(), "display-date")) {
          sort = new Sort("displayDate", Sort.LONG_TYPE, orderByAsc);
        } else if (Validator.equals(getOrderByCol(), "modified-date")) {
          sort = new Sort(Field.MODIFIED_DATE, Sort.LONG_TYPE, orderByAsc);
        }

        LinkedHashMap<String, Object> params = new LinkedHashMap<>();

        params.put("expandoAttributes", getKeywords());

        BaseModelSearchResult<JournalArticle> baseModelSearchResult =
            JournalArticleLocalServiceUtil.searchJournalArticles(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                getKeywords(),
                params,
                articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(),
                sort);

        int total = baseModelSearchResult.getLength();

        articleSearchContainer.setTotal(total);

        List results = baseModelSearchResult.getBaseModels();

        articleSearchContainer.setResults(results);
      } else {
        int total =
            JournalArticleServiceUtil.searchCount(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(),
                -1.0,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                null,
                null,
                getStatus(),
                null);

        articleSearchContainer.setTotal(total);

        List results =
            JournalArticleServiceUtil.search(
                themeDisplay.getCompanyId(),
                themeDisplay.getScopeGroupId(),
                folderIds,
                JournalArticleConstants.CLASSNAME_ID_DEFAULT,
                getKeywords(),
                -1.0,
                getDDMStructureKey(),
                getDDMTemplateKey(),
                null,
                null,
                getStatus(),
                null,
                articleSearchContainer.getStart(),
                articleSearchContainer.getEnd(),
                articleSearchContainer.getOrderByComparator());

        articleSearchContainer.setResults(results);
      }
    } else {
      int total =
          JournalFolderServiceUtil.getFoldersAndArticlesCount(
              themeDisplay.getScopeGroupId(), 0, getFolderId(), getStatus());

      articleSearchContainer.setTotal(total);

      OrderByComparator<Object> folderOrderByComparator = null;

      boolean orderByAsc = false;

      if (Validator.equals(getOrderByType(), "asc")) {
        orderByAsc = true;
      }

      if (Validator.equals(getOrderByCol(), "display-date")) {
        folderOrderByComparator = new FolderArticleDisplayDateComparator(orderByAsc);
      } else if (Validator.equals(getOrderByCol(), "modified-date")) {
        folderOrderByComparator = new FolderArticleModifiedDateComparator(orderByAsc);
      }

      List results =
          JournalFolderServiceUtil.getFoldersAndArticles(
              themeDisplay.getScopeGroupId(),
              0,
              getFolderId(),
              getStatus(),
              articleSearchContainer.getStart(),
              articleSearchContainer.getEnd(),
              folderOrderByComparator);

      articleSearchContainer.setResults(results);
    }

    return articleSearchContainer;
  }
コード例 #10
0
  @Override
  protected void moveBaseModelToTrash(long primaryKey) throws Exception {
    JournalArticle article = JournalArticleLocalServiceUtil.getArticle(primaryKey);

    JournalArticleLocalServiceUtil.moveArticleToTrash(TestPropsValues.getUserId(), article);
  }
コード例 #11
0
 @Override
 protected void deleteBaseModel(BaseModel<?> baseModel) throws Exception {
   JournalArticleLocalServiceUtil.deleteArticle((JournalArticle) baseModel);
 }
コード例 #12
0
 @Override
 protected BaseModel<?> getBaseModel(long primaryKey) throws Exception {
   return JournalArticleLocalServiceUtil.getArticle(primaryKey);
 }