use of com.liferay.portlet.PortalPreferences in project liferay-ide by liferay.
the class DisplayPortlet method getPreferredKBFolderUrlTitle.
protected String getPreferredKBFolderUrlTitle(RenderRequest renderRequest, PortletPreferences portletPreferences) throws PortalException, SystemException {
PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest);
String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
return KnowledgeBaseUtil.getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
}
use of com.liferay.portlet.PortalPreferences in project liferay-ide by liferay.
the class DisplayPortlet method updateRootKBFolderId.
public void updateRootKBFolderId(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortalException, SystemException {
long kbFolderId = ParamUtil.getLong(actionRequest, "rootKBFolderId");
if (kbFolderId == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
return;
}
KBFolder kbFolder = KBFolderServiceUtil.getKBFolder(kbFolderId);
PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(PortalUtil.getLiferayPortletRequest(actionRequest));
PortletPreferences portletPreferences = actionRequest.getPreferences();
String contentRootPrefix = GetterUtil.getString(portletPreferences.getValue("contentRootPrefix", null));
String previousPreferredKBFolderURLTitle = KnowledgeBaseUtil.getPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix);
KnowledgeBaseUtil.setPreferredKBFolderURLTitle(portalPreferences, contentRootPrefix, kbFolder.getUrlTitle());
String urlTitle = ParamUtil.getString(actionRequest, "urlTitle");
if (Validator.isNull(urlTitle)) {
return;
}
KBArticle kbArticle = KBArticleLocalServiceUtil.fetchKBArticleByUrlTitle(kbFolder.getGroupId(), kbFolder.getUrlTitle(), urlTitle);
if (kbArticle == null) {
if (Validator.isNull(previousPreferredKBFolderURLTitle)) {
return;
}
kbArticle = findClosestMatchingKBArticle(kbFolder.getGroupId(), previousPreferredKBFolderURLTitle, kbFolder.getKbFolderId(), urlTitle);
if (kbArticle == null) {
return;
}
}
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
if (!KBArticlePermission.contains(themeDisplay.getPermissionChecker(), kbArticle, ActionKeys.VIEW)) {
return;
}
PortletURL redirectURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_DISPLAY, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
redirectURL.setParameter("kbFolderUrlTitle", kbFolder.getUrlTitle());
redirectURL.setParameter("urlTitle", kbArticle.getUrlTitle());
actionResponse.sendRedirect(redirectURL.toString());
}
use of com.liferay.portlet.PortalPreferences 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;
}
Aggregations