Search in sources :

Example 31 with KBFolder

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

the class KBFolderKBArticleSelector method findByResourcePrimKey.

@Override
public KBArticle findByResourcePrimKey(long groupId, String preferredKBFolderUrlTitle, long ancestorResourcePrimKey, long resourcePrimKey) throws PortalException, SystemException {
    KBFolder ancestorKBFolder = _rootKBFolder;
    if (ancestorResourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        ancestorKBFolder = KBFolderLocalServiceUtil.fetchKBFolder(ancestorResourcePrimKey);
        if (ancestorKBFolder == null) {
            return null;
        }
    }
    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(resourcePrimKey, WorkflowConstants.STATUS_APPROVED);
    if ((kbArticle == null) || !isDescendant(kbArticle, ancestorKBFolder)) {
        return findClosestMatchingKBArticle(groupId, ancestorKBFolder, preferredKBFolderUrlTitle);
    }
    return kbArticle;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle)

Example 32 with KBFolder

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

the class KBFolderLocalServiceImpl method updateKBFolder.

@Override
public KBFolder updateKBFolder(long parentResourceClassNameId, long parentResourcePrimKey, long kbFolderId, String name, String description) throws PortalException, SystemException {
    validateParent(parentResourceClassNameId, parentResourcePrimKey);
    KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId);
    kbFolder.setModifiedDate(new Date());
    kbFolder.setParentKBFolderId(parentResourcePrimKey);
    kbFolder.setName(name);
    kbFolder.setDescription(description);
    return kbFolderPersistence.update(kbFolder);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) Date(java.util.Date)

Example 33 with KBFolder

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

the class KBFolderLocalServiceImpl method addKBFolder.

@Override
public KBFolder addKBFolder(long userId, long groupId, long parentResourceClassNameId, long parentResourcePrimKey, String name, String description, ServiceContext serviceContext) throws PortalException, SystemException {
    // KB folder
    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();
    validateName(groupId, parentResourcePrimKey, name);
    validateParent(parentResourceClassNameId, parentResourcePrimKey);
    long kbFolderId = counterLocalService.increment();
    KBFolder kbFolder = kbFolderPersistence.create(kbFolderId);
    kbFolder.setUuid(serviceContext.getUuid());
    kbFolder.setGroupId(groupId);
    kbFolder.setCompanyId(user.getCompanyId());
    kbFolder.setUserId(userId);
    kbFolder.setUserName(user.getFullName());
    kbFolder.setCreateDate(now);
    kbFolder.setModifiedDate(now);
    kbFolder.setParentKBFolderId(parentResourcePrimKey);
    kbFolder.setName(name);
    kbFolder.setUrlTitle(getUniqueUrlTitle(groupId, parentResourcePrimKey, kbFolderId, name));
    kbFolder.setDescription(description);
    kbFolderPersistence.update(kbFolder);
    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
        addKBFolderResources(kbFolder, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
    } else {
        addKBFolderResources(kbFolder, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }
    return kbFolder;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) User(com.liferay.portal.model.User) Date(java.util.Date)

Example 34 with KBFolder

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

the class KBFolderServiceImpl method getKBFolderByUrlTitle.

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

Example 35 with KBFolder

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

the class KBFolderKBArticleSelector method findClosestMatchingKBArticle.

protected KBArticle findClosestMatchingKBArticle(long groupId, KBFolder ancestorKBFolder, String preferredKBFolderUrlTitle, String kbFolderUrlTitle, String urlTitle) throws PortalException, SystemException {
    KBFolder kbFolder = getCandidateKBFolder(groupId, preferredKBFolderUrlTitle, ancestorKBFolder, kbFolderUrlTitle);
    KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(groupId, kbFolder.getKbFolderId(), urlTitle);
    if (kbArticle != null) {
        return kbArticle;
    }
    return KBArticleLocalServiceUtil.fetchFirstChildKBArticle(groupId, kbFolder.getKbFolderId());
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) KBArticle(com.liferay.knowledgebase.model.KBArticle)

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