List of usage examples for com.liferay.portal.kernel.util WebKeys VM_VARIABLES
String VM_VARIABLES
To view the source code for com.liferay.portal.kernel.util WebKeys VM_VARIABLES.
Click Source Link
From source file:com.liferay.nested.portlets.web.internal.portlet.NestedPortletsPortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); String layoutTemplateId = StringPool.BLANK; try {/*from ww w.ja va2s . c o m*/ NestedPortletsDisplayContext nestedPortletsDisplayContext = new NestedPortletsDisplayContext( _portal.getHttpServletRequest(renderRequest)); layoutTemplateId = nestedPortletsDisplayContext.getLayoutTemplateId(); } catch (ConfigurationException ce) { if (_log.isWarnEnabled()) { _log.warn(ce, ce); } } String templateId = StringPool.BLANK; String templateContent = StringPool.BLANK; Map<String, String> columnIds = new HashMap<>(); if (Validator.isNotNull(layoutTemplateId)) { Theme theme = themeDisplay.getTheme(); LayoutTemplate layoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(layoutTemplateId, false, theme.getThemeId()); String content = layoutTemplate.getContent(); Matcher processColumnMatcher = _processColumnPattern.matcher(content); while (processColumnMatcher.find()) { String columnId = processColumnMatcher.group(2); if (Validator.isNotNull(columnId)) { columnIds.put(columnId, renderResponse.getNamespace() + StringPool.UNDERLINE + columnId); } } processColumnMatcher.reset(); StringBundler sb = new StringBundler(4); sb.append(theme.getThemeId()); sb.append(LayoutTemplateConstants.CUSTOM_SEPARATOR); sb.append(renderResponse.getNamespace()); sb.append(layoutTemplateId); templateId = sb.toString(); content = processColumnMatcher.replaceAll("$1\\${$2}$3"); Matcher columnIdMatcher = _columnIdPattern.matcher(content); templateContent = columnIdMatcher.replaceAll("$1" + renderResponse.getNamespace() + "$2$3"); } checkLayout(themeDisplay.getLayout(), columnIds.values()); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); renderRequest.setAttribute(NestedPortletsWebKeys.TEMPLATE_ID + portletDisplay.getId(), templateId); renderRequest.setAttribute(NestedPortletsWebKeys.TEMPLATE_CONTENT + portletDisplay.getId(), templateContent); Map<String, Object> vmVariables = (Map<String, Object>) renderRequest .getAttribute(WebKeys.VM_VARIABLES + portletDisplay.getId()); if (vmVariables != null) { vmVariables.putAll(columnIds); } else { renderRequest.setAttribute(WebKeys.VM_VARIABLES + portletDisplay.getId(), columnIds); } super.include(viewTemplate, renderRequest, renderResponse); }
From source file:org.eclipse.sw360.portal.hooks.BuildInfoForVelocityProviderHook.java
License:Open Source License
@Override public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException { request.setAttribute(WebKeys.VM_VARIABLES, getBuildInfo()); }
From source file:org.xcolab.hooks.climatecolab.EXTServicePreAction.java
License:Open Source License
public void run(HttpServletRequest req, HttpServletResponse res) throws ActionException { ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY); Map<String, Object> vmVariables = (Map<String, Object>) req.getAttribute(WebKeys.VM_VARIABLES); if (vmVariables == null) { vmVariables = new HashMap<String, Object>(); }//from ww w .j a va2 s.c o m List<Theme> themes = ThemeLocalServiceUtil.getThemes(themeDisplay.getCompanyId()); String themeTimestamp = ""; for (Theme theme : themes) { if (theme.getName().equals(COLLABORATORIUM_THEME_NAME)) { themeTimestamp = String.valueOf(theme.getTimestamp()); } } String contestIdStr = req.getParameter("_collab_paramcontestId"); if (contestIdStr != null) { try { Contest contest = ContestLocalServiceUtil.getContest(Long.parseLong(contestIdStr)); vmVariables.put("collab_contest", contest); } catch (NumberFormatException e) { _log.error("An exception has been thrown when trying to parse contest id " + contestIdStr, e); } catch (PortalException e) { _log.error("An exception has been thrown when loading contest with id " + contestIdStr, e); } catch (SystemException e) { _log.error("An exception has been thrown when loading contest with id " + contestIdStr, e); } } String planIdStr = req.getParameter("_collab_paramplanId"); if (planIdStr != null) { try { PlanItem plan = PlanItemLocalServiceUtil.getPlan(Long.parseLong(planIdStr)); vmVariables.put("collab_plan", plan); } catch (NumberFormatException e) { _log.error("An exception has been thrown when trying to parse contest id " + contestIdStr, e); } catch (PortalException e) { _log.error("An exception has been thrown when loading contest with id " + contestIdStr, e); } catch (SystemException e) { _log.error("An exception has been thrown when loading contest with id " + contestIdStr, e); } } vmVariables.put("themeTimestamp", themeTimestamp); req.setAttribute(WebKeys.VM_VARIABLES, vmVariables); req.setAttribute(THEME_TIMESTAMP_ATTRIBUTE, themeTimestamp); }