Search in sources :

Example 1 with KBArticleSelector

use of com.liferay.knowledgebase.display.selector.KBArticleSelector in project liferay-ide by liferay.

the class DisplayPortlet method getKBArticle.

protected KBArticle getKBArticle(RenderRequest renderRequest) throws PortalException, SystemException {
    String mvcPath = ParamUtil.getString(renderRequest, "mvcPath");
    if (mvcPath.endsWith("/edit_article.jsp")) {
        long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey");
        return KBArticleLocalServiceUtil.getLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
    }
    PortletPreferences portletPreferences = renderRequest.getPreferences();
    long kbFolderClassNameId = ClassNameLocalServiceUtil.getClassNameId(KBFolderConstants.getClassName());
    long parentResourcePrimKey = GetterUtil.getLong(portletPreferences.getValue("resourcePrimKey", null));
    long parentResourceClassNameId = GetterUtil.getLong(portletPreferences.getValue("resourceClassNameId", null), kbFolderClassNameId);
    KBArticleSelector kbArticleSelector = KBArticleSelectorFactoryUtil.getKBArticleSelector(parentResourceClassNameId);
    String urlTitle = ParamUtil.getString(renderRequest, "urlTitle");
    String preferredKBFolderURLTitle = getPreferredKBFolderUrlTitle(renderRequest, portletPreferences);
    if (Validator.isNotNull(urlTitle)) {
        String kbFolderUrlTitle = ParamUtil.getString(renderRequest, "kbFolderUrlTitle");
        return kbArticleSelector.findByUrlTitle(PortalUtil.getScopeGroupId(renderRequest), preferredKBFolderURLTitle, parentResourcePrimKey, kbFolderUrlTitle, urlTitle);
    }
    long resourcePrimKey = ParamUtil.getLong(renderRequest, "resourcePrimKey", KBArticleConstants.DEFAULT_PARENT_RESOURCE_PRIM_KEY);
    return kbArticleSelector.findByResourcePrimKey(PortalUtil.getScopeGroupId(renderRequest), preferredKBFolderURLTitle, parentResourcePrimKey, resourcePrimKey);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) KBArticleSelector(com.liferay.knowledgebase.display.selector.KBArticleSelector)

Aggregations

KBArticleSelector (com.liferay.knowledgebase.display.selector.KBArticleSelector)1 PortletPreferences (javax.portlet.PortletPreferences)1