Search in sources :

Example 26 with KBFolder

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

the class KBFolderServiceImpl method fetchKBFolderByUrlTitle.

public KBFolder fetchKBFolderByUrlTitle(long groupId, long parentKbFolderId, String urlTitle) throws PortalException, SystemException {
    KBFolder kbFolder = kbFolderLocalService.fetchKBFolderByUrlTitle(groupId, parentKbFolderId, urlTitle);
    if (kbFolder == null) {
        return null;
    }
    KBFolderPermission.check(getPermissionChecker(), kbFolder, ActionKeys.VIEW);
    return kbFolder;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 27 with KBFolder

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

the class KBArticleLocalServiceImpl method getUniqueUrlTitle.

protected String getUniqueUrlTitle(long groupId, long kbFolderId, long kbArticleId, String title) throws PortalException, SystemException {
    String urlTitle = KnowledgeBaseUtil.getUrlTitle(kbArticleId, title);
    String uniqueUrlTitle = urlTitle;
    if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        int kbArticlesCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES);
        for (int i = 1; kbArticlesCount > 0; i++) {
            uniqueUrlTitle = urlTitle + StringPool.DASH + i;
            kbArticlesCount = kbArticlePersistence.countByG_KBFI_UT_ST(groupId, kbFolderId, uniqueUrlTitle, _STATUSES);
        }
        return uniqueUrlTitle;
    }
    KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId);
    int kbArticlesCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES);
    for (int i = 1; kbArticlesCount > 0; i++) {
        uniqueUrlTitle = urlTitle + StringPool.DASH + i;
        kbArticlesCount = kbArticleFinder.countByUrlTitle(groupId, kbFolder.getUrlTitle(), uniqueUrlTitle, _STATUSES);
    }
    return uniqueUrlTitle;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 28 with KBFolder

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

the class DisplayPortlet method updateRootKBFolderId.

public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException, SystemException {
    long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId");
    if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        return;
    }
    KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId);
    PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(PortalUtil.getLiferayPortletRequest(actionRequest));
    PortletPreferences portletPreferences = actionRequest.getPreferences();
    String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
    String previousPreferredKBFolderURLTitle = KnowledgeBaseUtil.getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
    KnowledgeBaseUtil.setPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix, kbFolder.getUrlTitle());
    String urlTitle = ParamUtil.getString(actionRequest, "urlTitle");
    if (Validator.isNull(urlTitle)) {
        return;
    }
    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle);
    if (kbArticle == null) {
        if (Validator.isNull(previousPreferredKBFolderURLTitle)) {
            return;
        }
        kbArticle = findClosestMatchingKBArticle(kbFolder.getGroupId(), previousPreferredKBFolderURLTitle, kbFolder.getKbFolderId(), urlTitle);
        if (kbArticle == null) {
            return;
        }
    }
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    if (!KBArticlePermission.contains(themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) {
        return;
    }
    PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_DISPLAY, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
    redirectURL.setParameter("kbFolderUrlTitle", kbFolder.getUrlTitle());
    redirectURL.setParameter("urlTitle", kbArticle.getUrlTitle());
    actionResponse.sendRedirect(redirectURL.toString());
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle) PortalPreferences(com.liferay.portlet.PortalPreferences) PortletPreferences(javax.portlet.PortletPreferences) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 29 with KBFolder

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

the class KBFolderModelImpl method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof KBFolder)) {
        return false;
    }
    KBFolder kbFolder = (KBFolder) obj;
    long primaryKey = kbFolder.getPrimaryKey();
    if (getPrimaryKey() == primaryKey) {
        return true;
    } else {
        return false;
    }
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 30 with KBFolder

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

the class KBFolderModelImpl method toModel.

/**
 * Converts the soap model instance into a normal model instance.
 *
 * @param soapModel the soap model instance to convert
 * @return the normal model instance
 */
public static KBFolder toModel(KBFolderSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    KBFolder model = new KBFolderImpl();
    model.setUuid(soapModel.getUuid());
    model.setKbFolderId(soapModel.getKbFolderId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setParentKBFolderId(soapModel.getParentKBFolderId());
    model.setName(soapModel.getName());
    model.setUrlTitle(soapModel.getUrlTitle());
    model.setDescription(soapModel.getDescription());
    return model;
}
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