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);
}
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);
}
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));
}
}
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;
}
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());
}
Aggregations