use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBFolderPersistenceImpl method findByG_P_N.
/**
* Returns the k b folder where groupId = ? and parentKBFolderId = ? and name = ? or throws a {@link com.liferay.knowledgebase.NoSuchFolderException} if it could not be found.
*
* @param groupId the group ID
* @param parentKBFolderId the parent k b folder ID
* @param name the name
* @return the matching k b folder
* @throws com.liferay.knowledgebase.NoSuchFolderException if a matching k b folder could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public KBFolder findByG_P_N(long groupId, long parentKBFolderId, String name) throws NoSuchFolderException, SystemException {
KBFolder kbFolder = fetchByG_P_N(groupId, parentKBFolderId, name);
if (kbFolder == null) {
StringBundler msg = new StringBundler(8);
msg.append(_NO_SUCH_ENTITY_WITH_KEY);
msg.append("groupId=");
msg.append(groupId);
msg.append(", parentKBFolderId=");
msg.append(parentKBFolderId);
msg.append(", name=");
msg.append(name);
msg.append(StringPool.CLOSE_CURLY_BRACE);
if (_log.isWarnEnabled()) {
_log.warn(msg.toString());
}
throw new NoSuchFolderException(msg.toString());
}
return kbFolder;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KBNavigationDisplayContext method hasMultipleDescendantKBArticles.
protected boolean hasMultipleDescendantKBArticles() throws PortalException, SystemException {
long scopeGroupId = PortalUtil.getScopeGroupId(_portletRequest);
long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
if (getResourceClassNameId() == kbFolderClassNameId) {
List<KBFolder> kbFolders = KnowledgeBaseUtil.getAlternateRootKBFolders(scopeGroupId, getResourcePrimKey());
if (kbFolders.size() > 1) {
int maxKBArticlesCount = 0;
for (KBFolder kbFolder : kbFolders) {
int kbArticlesCount = KBArticleLocalServiceUtil.getKBFolderKBArticlesCount(scopeGroupId, kbFolder.getKbFolderId(), WorkflowConstants.STATUS_APPROVED);
if (kbArticlesCount > maxKBArticlesCount) {
maxKBArticlesCount = kbArticlesCount;
}
}
if (maxKBArticlesCount > 1) {
return true;
}
return false;
}
}
boolean showNavigation = true;
long rootResourcePrimKey = getRootResourcePrimKey();
int kbArticlesCount = KBArticleLocalServiceUtil.getKBArticlesCount(scopeGroupId, rootResourcePrimKey, WorkflowConstants.STATUS_APPROVED);
if (kbArticlesCount == 0) {
showNavigation = false;
} else if (kbArticlesCount == 1) {
List<KBArticle> kbArticles = KBArticleLocalServiceUtil.getKBArticles(scopeGroupId, rootResourcePrimKey, WorkflowConstants.STATUS_APPROVED, 0, 1, null);
KBArticle navigationKBArticle = kbArticles.get(0);
int navigationKBArticleChildCount = KBArticleLocalServiceUtil.getKBArticlesCount(scopeGroupId, navigationKBArticle.getResourcePrimKey(), WorkflowConstants.STATUS_APPROVED);
if (navigationKBArticleChildCount == 0) {
showNavigation = false;
}
}
return showNavigation;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KnowledgeBaseUtil method getCurrentRootKBFolder.
private static long getCurrentRootKBFolder(PortletRequest portletRequest, long groupId, long kbFolderId) throws PortalException, SystemException {
PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);
PortletPreferences portletPreferences = portletRequest.getPreferences();
String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
String kbFolderURLTitle = getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
long childKbFolderId = KBFolderConstants.DEFAULT_PARENT_FOLDER_ID;
if (kbFolderURLTitle == null) {
List<KBFolder> kbFolders = getAlternateRootKBFolders(groupId, kbFolderId);
if (!kbFolders.isEmpty()) {
KBFolder kbFolder = kbFolders.get(0);
childKbFolderId = kbFolder.getKbFolderId();
}
} else {
KBFolder kbFolder = KBFolderServiceUtil.fetchKBFolderByUrlTitle(groupId, kbFolderId, kbFolderURLTitle);
if (kbFolder != null) {
childKbFolderId = kbFolder.getKbFolderId();
}
}
return childKbFolderId;
}
use of com.liferay.knowledgebase.model.KBFolder in project liferay-ide by liferay.
the class KnowledgeBaseUtil method addPortletBreadcrumbEntries.
protected static void addPortletBreadcrumbEntries(Map<String, Object> parameters, HttpServletRequest request, RenderResponse renderResponse) throws PortalException, SystemException {
PortletURL portletURL = renderResponse.createRenderURL();
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
portletURL.setParameter(entry.getKey(), value.toString());
}
long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName());
long parentResourceClassNameId = (Long) parameters.get("parentResourceClassNameId");
long parentResourcePrimKey = (Long) parameters.get("parentResourcePrimKey");
String mvcPath = (String) parameters.get("mvcPath");
if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString());
} else if (parentResourceClassNameId == kbFolderClassNameId) {
KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(parentResourcePrimKey);
addPortletBreadcrumbEntries(kbFolder.getClassNameId(), kbFolder.getParentKBFolderId(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbFolder.getName(), portletURL.toString());
} else {
KBArticle kbArticle = KBArticleServiceUtil.getLatestKBArticle(parentResourcePrimKey, WorkflowConstants.STATUS_ANY);
addPortletBreadcrumbEntries(kbArticle.getParentResourceClassNameId(), kbArticle.getParentResourcePrimKey(), mvcPath, request, renderResponse);
PortalUtil.addPortletBreadcrumbEntry(request, kbArticle.getTitle(), portletURL.toString());
}
}
Aggregations