@Override protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { if (SessionErrors.contains(renderRequest, NoSuchArticleException.class.getName()) || SessionErrors.contains(renderRequest, NoSuchCommentException.class.getName()) || SessionErrors.contains(renderRequest, NoSuchSubscriptionException.class.getName()) || SessionErrors.contains(renderRequest, PrincipalException.class.getName())) { include(templatePath + "error.jsp", renderRequest, renderResponse); } else { super.doDispatch(renderRequest, renderResponse); } }
@Override protected void addSuccessMessage(ActionRequest actionRequest, ActionResponse actionResponse) { String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); if (actionName.equals("deleteKBArticle") || actionName.equals("updateKBComment") || actionName.equals("updateRootKBFolderId")) { return; } super.addSuccessMessage(actionRequest, actionResponse); }
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); int status = getStatus(renderRequest); renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_STATUS, status); KBArticle kbArticle = null; Tuple resourceTuple = getResourceTuple(renderRequest); long resourcePrimKey = (Long) resourceTuple.getObject(1); if (resourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { long resourceClassNameId = (Long) resourceTuple.getObject(0); long kbFolderClassNameId = PortalUtil.getClassNameId(KBFolderConstants.getClassName()); if (resourceClassNameId == kbFolderClassNameId) { PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(renderRequest); String preferredKBFolderURLTitle = portalPreferences.getValue( PortletKeys.KNOWLEDGE_BASE_DISPLAY, "preferredKBFolderURLTitle"); kbArticle = getKBFolderKBArticle( themeDisplay.getScopeGroupId(), resourcePrimKey, preferredKBFolderURLTitle); } else { kbArticle = KBArticleServiceUtil.fetchLatestKBArticle(resourcePrimKey, status); } } else { long parentResourcePrimKey = ParamUtil.getLong( renderRequest, "parentResourcePrimKey", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID); if (parentResourcePrimKey == KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) { List<KBArticle> kbArticles = KBArticleLocalServiceUtil.getGroupKBArticles( themeDisplay.getScopeGroupId(), status, 0, 1, new KBArticlePriorityComparator(true)); if (!kbArticles.isEmpty()) { kbArticle = kbArticles.get(0); } } } renderRequest.setAttribute(WebKeys.KNOWLEDGE_BASE_KB_ARTICLE, kbArticle); } catch (Exception e) { if (e instanceof NoSuchArticleException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); SessionMessages.add( renderRequest, PortalUtil.getPortletId(renderRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); } else { throw new PortletException(e); } } super.render(renderRequest, renderResponse); }