Search in sources :

Example 36 with KBFolder

use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.

the class KBFolderKBArticleSelector method findByUrlTitle.

@Override
public KBArticle findByUrlTitle(long groupId, String preferredKBFolderUrlTitle, long ancestorResourcePrimKey, String kbFolderUrlTitle, String urlTitle) throws PortalException, SystemException {
    KBFolder ancestorKBFolder = _rootKBFolder;
    if (ancestorResourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        ancestorKBFolder = KBFolderLocalServiceUtil.fetchKBFolder(ancestorResourcePrimKey);
        if (ancestorKBFolder == null) {
            return null;
        }
    }
    KBFolder kbFolder = _rootKBFolder;
    if (Validator.isNotNull(kbFolderUrlTitle)) {
        if (kbFolderUrlTitle.equals(ancestorKBFolder.getUrlTitle())) {
            kbFolder = ancestorKBFolder;
        } else {
            kbFolder = KBFolderLocalServiceUtil.fetchKBFolderByUrlTitle(groupId, ancestorKBFolder.getKbFolderId(), kbFolderUrlTitle);
        }
    }
    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(groupId, kbFolder.getKbFolderId(), urlTitle);
    if ((kbArticle == null) || !isDescendant(kbArticle, ancestorKBFolder)) {
        return findClosestMatchingKBArticle(groupId, ancestorKBFolder, preferredKBFolderUrlTitle, kbFolderUrlTitle, urlTitle);
    }
    return kbArticle;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle)

Example 37 with KBFolder

use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.

the class FindKBArticleAction method isParentFolder.

protected boolean isParentFolder(long resourcePrimKey, long kbFolderId) throws PortalException, SystemException {
    while (kbFolderId != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        if (resourcePrimKey == kbFolderId) {
            return true;
        }
        KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbFolderId);
        kbFolderId = kbFolder.getParentKBFolderId();
    }
    return false;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 38 with KBFolder

use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.

the class FindKBArticleAction method getKBArticleURL.

protected PortletURL getKBArticleURL(long plid, String portletId, KBArticle kbArticle, HttpServletRequest request) throws Exception {
    long resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
    String mvcPath = null;
    String rootPortletId = PortletConstants.getRootPortletId(portletId);
    if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_ARTICLE)) {
        mvcPath = "/article/view_article.jsp";
    } else if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
        mvcPath = "/section/view_article.jsp";
    }
    PortletURL portletURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
    if (mvcPath != null) {
        portletURL.setParameter("mvcPath", mvcPath);
    }
    if ((kbArticle == null) || Validator.isNull(kbArticle.getUrlTitle())) {
        portletURL.setParameter("resourcePrimKey", String.valueOf(resourcePrimKey));
    } else {
        portletURL.setParameter("urlTitle", kbArticle.getUrlTitle());
        if (kbArticle.getKbFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
            KBFolder kbFolder = KBFolderLocalServiceUtil.getKBFolder(kbArticle.getKbFolderId());
            portletURL.setParameter("kbFolderUrlTitle", String.valueOf(kbFolder.getUrlTitle()));
        }
    }
    portletURL.setPortletMode(PortletMode.VIEW);
    portletURL.setWindowState(LiferayWindowState.NORMAL);
    if (rootPortletId.equals(PortletKeys.KNOWLEDGE_BASE_SECTION)) {
        portletURL.setWindowState(LiferayWindowState.MAXIMIZED);
    }
    return portletURL;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) PortletURL(javax.portlet.PortletURL)

Example 39 with KBFolder

use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.

the class KBFolderStagedModelDataHandler method doExportStagedModel.

@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, KBFolder kbFolder) throws Exception {
    if (kbFolder.getParentKBFolderId() != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        KBFolder parentKBFolder = KBFolderLocalServiceUtil.getKBFolder(kbFolder.getParentKBFolderId());
        StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, kbFolder, parentKBFolder, PortletDataContext.REFERENCE_TYPE_PARENT);
    }
    Element kbFolderElement = portletDataContext.getExportDataElement(kbFolder);
    portletDataContext.addClassedModel(kbFolderElement, ExportImportPathUtil.getModelPath(kbFolder), kbFolder);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) Element(com.liferay.portal.kernel.xml.Element)

Example 40 with KBFolder

use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.

the class KBFolderExportActionableDynamicQuery method performAction.

@Override
@SuppressWarnings("unused")
protected void performAction(Object object) throws PortalException, SystemException {
    KBFolder stagedModel = (KBFolder) object;
    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext, stagedModel);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Aggregations

KBFolder (com.liferay.knowledgebase.model.KBFolder)59 NoSuchFolderException (com.liferay.knowledgebase.NoSuchFolderException)24 StringBundler (com.liferay.portal.kernel.util.StringBundler)21 Session (com.liferay.portal.kernel.dao.orm.Session)14 SystemException (com.liferay.portal.kernel.exception.SystemException)14 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)12 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)11 Query (com.liferay.portal.kernel.dao.orm.Query)10 ArrayList (java.util.ArrayList)9 List (java.util.List)9 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)8 KBArticle (com.liferay.knowledgebase.model.KBArticle)7 KBFolderImpl (com.liferay.knowledgebase.model.impl.KBFolderImpl)7 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 PortletURL (javax.portlet.PortletURL)4 Element (com.liferay.portal.kernel.xml.Element)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2 PortalPreferences (com.liferay.portlet.PortalPreferences)2 Date (java.util.Date)2 Map (java.util.Map)2