Search in sources :

Example 21 with KBFolder

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

the class KBFolderLocalServiceImpl method moveKBFolder.

@Override
public void moveKBFolder(long kbFolderId, long parentKBFolderId) throws PortalException, SystemException {
    KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId);
    if (parentKBFolderId != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        KBFolder parentKBFolder = kbFolderPersistence.findByPrimaryKey(parentKBFolderId);
        validateParent(kbFolder, parentKBFolder);
        parentKBFolderId = parentKBFolder.getKbFolderId();
    }
    kbFolder.setParentKBFolderId(parentKBFolderId);
    kbFolderPersistence.update(kbFolder);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 22 with KBFolder

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

the class KBFolderLocalServiceImpl method deleteKBFolder.

@Override
public KBFolder deleteKBFolder(long kbFolderId) throws PortalException, SystemException {
    KBFolder kbFolder = kbFolderPersistence.findByPrimaryKey(kbFolderId);
    kbArticleLocalService.deleteKBArticles(kbFolder.getGroupId(), kbFolder.getKbFolderId());
    List<KBFolder> childKBFolders = kbFolderPersistence.findByG_P(kbFolder.getGroupId(), kbFolder.getKbFolderId());
    for (KBFolder childKBFolder : childKBFolders) {
        deleteKBFolder(childKBFolder.getKbFolderId());
    }
    return kbFolderPersistence.remove(kbFolder);
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 23 with KBFolder

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

the class KBFolderLocalServiceImpl method validateParent.

protected void validateParent(long parentResourceClassNameId, long parentResourcePrimKey) throws PortalException, SystemException {
    long kbFolderClassNameId = classNameLocalService.getClassNameId(KBFolderConstants.getClassName());
    KBFolder parentKBFolder = null;
    if (parentResourceClassNameId == kbFolderClassNameId) {
        if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
            return;
        }
        parentKBFolder = kbFolderPersistence.fetchByPrimaryKey(parentResourcePrimKey);
    }
    if (parentKBFolder == null) {
        throw new NoSuchFolderException(String.format("No KB folder found with KB folder ID %", parentResourcePrimKey));
    }
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder) NoSuchFolderException(com.liferay.knowledgebase.NoSuchFolderException)

Example 24 with KBFolder

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

the class KBFolderLocalServiceImpl method getUniqueUrlTitle.

protected String getUniqueUrlTitle(long groupId, long parentKbFolderId, long kbFolderId, String name) throws SystemException {
    String urlTitle = KnowledgeBaseUtil.getUrlTitle(kbFolderId, name);
    String uniqueUrlTitle = urlTitle;
    KBFolder kbFolder = null;
    for (int i = 1; kbFolder != null; i++) {
        uniqueUrlTitle = urlTitle + StringPool.DASH + i;
        kbFolder = kbFolderPersistence.fetchByG_P_UT(groupId, parentKbFolderId, uniqueUrlTitle);
    }
    return uniqueUrlTitle;
}
Also used : KBFolder(com.liferay.knowledgebase.model.KBFolder)

Example 25 with KBFolder

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

the class KBFolderLocalServiceImpl method getSubfolderIds.

protected void getSubfolderIds(KBFolder parentKBFolder, Collection<Long> kbFolderIds) throws SystemException {
    Collection<KBFolder> kbFolders = kbFolderPersistence.findByG_P(parentKBFolder.getGroupId(), parentKBFolder.getKbFolderId());
    for (KBFolder kbFolder : kbFolders) {
        getSubfolderIds(kbFolder, kbFolderIds);
    }
    kbFolderIds.add(parentKBFolder.getKbFolderId());
}
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