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