protected String getArticleId(PortletRequest portletRequest) throws PortalException { long assetEntryId = GetterUtil.getLong(getParameter(portletRequest, "assetEntryId")); AssetEntry assetEntry = _assetEntryLocalService.fetchEntry(assetEntryId); if (assetEntry == null) { return StringPool.BLANK; } JournalArticleAssetRendererFactory articleAssetRendererFactory = (JournalArticleAssetRendererFactory) AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName( JournalArticle.class.getName()); JournalArticleAssetRenderer articleAssetRenderer = (JournalArticleAssetRenderer) articleAssetRendererFactory.getAssetRenderer(assetEntry.getClassPK()); JournalArticle article = articleAssetRenderer.getArticle(); return StringUtil.toUpperCase(article.getArticleId()); }
protected void sendEditArticleRedirect( ActionRequest actionRequest, ActionResponse actionResponse, JournalArticle article, String oldUrlTitle) throws Exception { String actionName = ParamUtil.getString(actionRequest, ActionRequest.ACTION_NAME); String redirect = ParamUtil.getString(actionRequest, "redirect"); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_PUBLISH); String portletId = HttpUtil.getParameter(redirect, "p_p_id", false); String namespace = PortalUtil.getPortletNamespace(portletId); if (Validator.isNotNull(oldUrlTitle)) { String oldRedirectParam = namespace + "redirect"; String oldRedirect = HttpUtil.getParameter(redirect, oldRedirectParam, false); if (Validator.isNotNull(oldRedirect)) { String newRedirect = HttpUtil.decodeURL(oldRedirect); newRedirect = StringUtil.replace(newRedirect, oldUrlTitle, article.getUrlTitle()); newRedirect = StringUtil.replace(newRedirect, oldRedirectParam, "redirect"); redirect = StringUtil.replace(redirect, oldRedirect, newRedirect); } } if ((actionName.equals("deleteArticle") || actionName.equals("deleteArticles")) && !ActionUtil.hasArticle(actionRequest)) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletURL portletURL = PortletURLFactoryUtil.create( actionRequest, themeDisplay.getPpid(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); redirect = portletURL.toString(); } if ((article != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { redirect = getSaveAndContinueRedirect(actionRequest, article, redirect); if (actionName.equals("previewArticle")) { SessionMessages.add(actionRequest, "previewRequested"); hideDefaultSuccessMessage(actionRequest); } } else { WindowState windowState = actionRequest.getWindowState(); if (windowState.equals(LiferayWindowState.POP_UP)) { redirect = PortalUtil.escapeRedirect(redirect); if (Validator.isNotNull(redirect)) { if (actionName.equals("addArticle") && (article != null)) { redirect = HttpUtil.addParameter( redirect, namespace + "className", JournalArticle.class.getName()); redirect = HttpUtil.addParameter( redirect, namespace + "classPK", JournalArticleAssetRenderer.getClassPK(article)); } actionResponse.sendRedirect(redirect); } } } actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }