@Override public String getURLViewInContext( long classPK, LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String noSuchEntryRedirect) { try { AssetRenderer<?> assetRenderer = getAssetRenderer(classPK); if (assetRenderer != null) { return assetRenderer.getURLViewInContext( liferayPortletRequest, liferayPortletResponse, noSuchEntryRedirect); } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e, e); } } return null; }
public static String getSearchResultViewURL( RenderRequest renderRequest, RenderResponse renderResponse, String className, long classPK, boolean viewInContext, String currentURL) throws Exception { try { PortletURL viewContentURL = renderResponse.createRenderURL(); viewContentURL.setParameter("mvcPath", "/view_content.jsp"); viewContentURL.setParameter("redirect", currentURL); viewContentURL.setPortletMode(PortletMode.VIEW); viewContentURL.setWindowState(WindowState.MAXIMIZED); if (Validator.isNull(className) || (classPK <= 0)) { return viewContentURL.toString(); } AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className); if (assetRendererFactory == null) { return viewContentURL.toString(); } viewContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); viewContentURL.setParameter("type", assetRendererFactory.getType()); if (viewInContext) { String viewFullContentURLString = viewContentURL.toString(); viewFullContentURLString = HttpUtil.setParameter(viewFullContentURLString, "redirect", currentURL); AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(classPK); String viewURL = assetRenderer.getURLViewInContext( (LiferayPortletRequest) renderRequest, (LiferayPortletResponse) renderResponse, viewFullContentURLString); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); return AssetUtil.checkViewURL(assetEntry, viewInContext, viewURL, currentURL, themeDisplay); } return viewContentURL.toString(); } catch (Exception e) { _log.error( "Unable to get search result view URL for class " + className + " with primary key " + classPK, e); return ""; } }