List of usage examples for com.liferay.portal.kernel.util WebKeys PORTLET_ID
String PORTLET_ID
To view the source code for com.liferay.portal.kernel.util WebKeys PORTLET_ID.
Click Source Link
From source file:com.hannikkala.thymeleaf.liferay.LiferayURLUtil.java
License:Open Source License
private static String getPortletName(String portletName, HttpServletRequest request) { if (portletName != null) { return portletName; }/*from w ww. j a v a2s. co m*/ return (String) request.getAttribute(WebKeys.PORTLET_ID); }
From source file:com.liferay.ci.portlet.JenkinsIntegrationPortlet.java
License:Open Source License
protected void buildSeries(RenderRequest request) { PortletPreferences portletPreferences = request.getPreferences(); String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); String jobName = portletPreferences.getValue("jobname", StringPool.BLANK); _log.debug("Getting builds for " + jobName); String buildsNumber = portletPreferences.getValue("buildsnumber", StringPool.BLANK); try {/* ww w . j a v a2 s . c o m*/ int maxBuildNumber = 0; if (Validator.isNotNull(buildsNumber)) { maxBuildNumber = Integer.parseInt(buildsNumber); _log.debug("Max BuildNumber for build: " + maxBuildNumber); } String jobCacheKey = jobName + StringPool.POUND + buildsNumber; if (!_cache.containsKey(portletId, jobCacheKey)) { JSONArray testResults = JenkinsConnectUtil.getBuilds(getConnectionParams(portletPreferences), jobName, maxBuildNumber); _cache.put(portletId, jobCacheKey, testResults); } request.setAttribute("TEST_RESULTS", _cache.get(portletId, jobCacheKey)); } catch (IOException ioe) { SessionErrors.add(request, ioe.getClass()); _log.error("The job was not available", ioe); } catch (JSONException e) { _log.error("The job is not well-formed", e); } }
From source file:com.liferay.comment.taglib.internal.struts.GetCommentsStrutsAction.java
License:Open Source License
@Override public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception { String namespace = ParamUtil.getString(request, "namespace"); HttpServletRequest namespacedRequest = new NamespaceServletRequest(request, StringPool.BLANK, namespace); namespacedRequest.setAttribute("aui:form:portletNamespace", namespace); String className = ParamUtil.getString(namespacedRequest, "className"); namespacedRequest.setAttribute("liferay-comment:discussion:className", className); long classPK = ParamUtil.getLong(namespacedRequest, "classPK"); namespacedRequest.setAttribute("liferay-comment:discussion:classPK", String.valueOf(classPK)); boolean hideControls = ParamUtil.getBoolean(namespacedRequest, "hideControls"); namespacedRequest.setAttribute("liferay-comment:discussion:hideControls", String.valueOf(hideControls)); int index = ParamUtil.getInteger(namespacedRequest, "index"); namespacedRequest.setAttribute("liferay-comment:discussion:index", String.valueOf(index)); String portletId = ParamUtil.getString(namespacedRequest, "portletId"); namespacedRequest.setAttribute(WebKeys.PORTLET_ID, portletId); String randomNamespace = ParamUtil.getString(namespacedRequest, "randomNamespace"); namespacedRequest.setAttribute("liferay-comment:discussion:randomNamespace", randomNamespace); boolean ratingsEnabled = ParamUtil.getBoolean(namespacedRequest, "ratingsEnabled"); namespacedRequest.setAttribute("liferay-comment:discussion:ratingsEnabled", String.valueOf(ratingsEnabled)); int rootIndexPage = ParamUtil.getInteger(namespacedRequest, "rootIndexPage"); namespacedRequest.setAttribute("liferay-comment:discussion:rootIndexPage", String.valueOf(rootIndexPage)); long userId = ParamUtil.getLong(namespacedRequest, "userId"); namespacedRequest.setAttribute("liferay-comment:discussion:userId", String.valueOf(userId)); RequestDispatcher requestDispatcher = namespacedRequest .getRequestDispatcher("/discussion/page_resources.jsp"); requestDispatcher.include(namespacedRequest, response); return null;/*from w ww . j a va 2 s . c om*/ }
From source file:com.liferay.faces.bridge.container.liferay.internal.LiferayURLGeneratorBaseImpl.java
License:Open Source License
public String generateURL(Map<String, String[]> additionalParameterMap, PortletMode portletMode, String resourceId, WindowState windowState) { String toStringValue = null;//from w ww . j a va2 s. co m if (baseURL.contains(Portal.FRIENDLY_URL_SEPARATOR)) { toStringValue = baseURL; } else { StringBuilder url = new StringBuilder(); // Build up a new URL string based on the one returned by Liferay, but discard everything after the // question mark because it's filled with all kinds of unnecessary stuff. url.append(prefix); // Possibly add the p_auth parameter. boolean firstParameter = true; String portalAuthToken = parameterMap.get(LiferayConstants.P_AUTH); if (portalAuthToken != null) { appendParameterToURL(firstParameter, LiferayConstants.P_AUTH, portalAuthToken, url); firstParameter = false; } // Possibly add the p_l_id parameter. String plid = parameterMap.get(LiferayConstants.P_L_ID); if (plid != null) { appendParameterToURL(firstParameter, LiferayConstants.P_L_ID, plid, url); firstParameter = false; } // Possibly add the p_p_auth parameter. String portletAuthToken = parameterMap.get(LiferayConstants.P_P_AUTH); if (portletAuthToken != null) { boolean addPortletAuthToken = true; if ((LIFERAY_BUILD_NUMBER < 6102) || ((LIFERAY_BUILD_NUMBER > 6102) && (LIFERAY_BUILD_NUMBER < 6130))) { // Versions of Liferay Portal prior to 6.1.2-CE/6.1.30-EE suffered from LPS-36481 which caused // PortletURLImpl.addPortletAuthToken(StringBundle, Key) method to add the p_p_auth parameter to // URLs for portlets when add-default-resource=false. It is therefore necessary to check that // add-default-resource=true before adding the p_p_auth parameter to the URL. FacesContext facesContext = FacesContext.getCurrentInstance(); PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest(); String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try { Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); addPortletAuthToken = portlet.isAddDefaultResource(); } catch (SystemException e) { logger.error(e); } } if (addPortletAuthToken) { appendParameterToURL(firstParameter, LiferayConstants.P_P_AUTH, portletAuthToken, url); firstParameter = false; } } // Always add the p_p_id parameter String parameterValue = responseNamespace; if (parameterValue.startsWith(StringPool.UNDERLINE)) { parameterValue = parameterValue.substring(1); } if (parameterValue.endsWith(StringPool.UNDERLINE)) { parameterValue = parameterValue.substring(0, parameterValue.length() - 1); } appendParameterToURL(firstParameter, LiferayConstants.P_P_ID, parameterValue, url); firstParameter = false; // Always add the p_p_lifecycle parameter. String portletLifecycleId = getPortletLifecycleId(); appendParameterToURL(LiferayConstants.P_P_LIFECYCLE, portletLifecycleId, url); // Add the p_p_state parameter. FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap(); WindowState urlWindowState = initialWindowState; if (windowState != null) { urlWindowState = windowState; } if (urlWindowState == null) { parameterValue = (String) applicationMap.get(responseNamespace + LiferayConstants.P_P_STATE); } else { parameterValue = urlWindowState.toString(); } appendParameterToURL(LiferayConstants.P_P_STATE, parameterValue, url); // Possibly add the p_p_state_rcv parameter. String stateRestoreCurrentView = parameterMap.get(LiferayConstants.P_P_STATE_RCV); if (stateRestoreCurrentView != null) { appendParameterToURL(LiferayConstants.P_P_STATE_RCV, stateRestoreCurrentView, url); } // Add the p_p_mode parameter. PortletMode urlPortletMode = initialPortletMode; if (portletMode != null) { urlPortletMode = portletMode; } if (urlPortletMode == null) { parameterValue = (String) applicationMap.get(responseNamespace + LiferayConstants.P_P_MODE); } else { parameterValue = urlPortletMode.toString(); } appendParameterToURL(LiferayConstants.P_P_MODE, parameterValue, url); // Possibly add the p_p_cacheability parameter if (LiferayConstants.LIFECYCLE_RESOURCE_PHASE_ID.equals(portletLifecycleId)) { String cacheability = parameterMap.get(LiferayConstants.P_P_CACHEABILITY); if (cacheability != null) { appendParameterToURL(LiferayConstants.P_P_CACHEABILITY, cacheability, url); } } // Always add the p_p_col_id parameter parameterValue = (String) applicationMap.get(responseNamespace + LiferayConstants.P_P_COL_ID); appendParameterToURL(LiferayConstants.P_P_COL_ID, parameterValue, url); // Possibly add the p_p_col_count parameter. parameterValue = (String) applicationMap.get(responseNamespace + LiferayConstants.P_P_COL_COUNT); appendParameterToURL(LiferayConstants.P_P_COL_COUNT, parameterValue, url); // Add the p_p_col_pos parameter if it is greater than zero (same logic as Liferay's // PortletURLImpl.toString()) parameterValue = (String) applicationMap.get(responseNamespace + LiferayConstants.P_P_COL_POS); if ((parameterValue != null) && (parameterValue.length() > 0)) { try { int colPos = Integer.parseInt(parameterValue); if (colPos > 0) { appendParameterToURL(LiferayConstants.P_P_COL_POS, parameterValue, url); } } catch (NumberFormatException e) { // ignore } } // Possibly add the p_o_p_id parameter. String outerPortletId = parameterMap.get(LiferayConstants.P_O_P_ID); if (outerPortletId != null) { appendParameterToURL(LiferayConstants.P_O_P_ID, outerPortletId, url); } // Possibly add the doAsUserId parameter. String doAsUserId = parameterMap.get(LiferayConstants.DO_AS_USER_ID); if (doAsUserId != null) { appendParameterToURL(LiferayConstants.DO_AS_USER_ID, doAsUserId, url); } // Possibly add the doAsUserLanguageId parameter. String doAsUserLanguageId = parameterMap.get(LiferayConstants.DO_AS_USER_LANGUAGE_ID); if (doAsUserLanguageId != null) { appendParameterToURL(LiferayConstants.DO_AS_USER_LANGUAGE_ID, doAsUserLanguageId, url); } // Possibly add the doAsGroupId parameter. String doAsGroupId = parameterMap.get(LiferayConstants.DO_AS_GROUP_ID); if (doAsGroupId != null) { appendParameterToURL(LiferayConstants.DO_AS_GROUP_ID, doAsGroupId, url); } // Possibly add the refererGroupId parameter. String refererGroupId = parameterMap.get(LiferayConstants.REFERER_GROUP_ID); if (refererGroupId != null) { appendParameterToURL(LiferayConstants.REFERER_GROUP_ID, refererGroupId, url); } // Possibly add the refererPlid parameter. String refererPlid = parameterMap.get(LiferayConstants.REFERER_PLID); if (refererPlid != null) { appendParameterToURL(LiferayConstants.REFERER_PLID, refererPlid, url); } // Possibly add the controlPanelCategory parameter. String controlPanelCategory = parameterMap.get(LiferayConstants.CONTROL_PANEL_CATEGORY); if (controlPanelCategory != null) { appendParameterToURL(LiferayConstants.CONTROL_PANEL_CATEGORY, controlPanelCategory, url); } // Add request parameters from the request parameter map. boolean namespaced = !responseNamespace.startsWith(BridgeConstants.WSRP); Set<Map.Entry<String, String[]>> mapEntries = additionalParameterMap.entrySet(); if (mapEntries != null) { for (Map.Entry<String, String[]> mapEntry : mapEntries) { String[] parameterValues = mapEntry.getValue(); if (parameterValues != null) { String parameterName = mapEntry.getKey(); for (String curParameterValue : parameterValues) { if (curParameterValue != null) { String encodedParameterValue = encode(curParameterValue); appendParameterToURL(firstParameter, namespaced, parameterName, encodedParameterValue, url); } } } } } // Add WSRP URL parameters for (URLParameter wsrpParameter : wsrpParameters) { appendParameterToURL(wsrpParameter.getName(), wsrpParameter.getValue(), url); } // Possibly add the p_p_resource_id parameter. String urlResourceId = parameterMap.get(LiferayConstants.P_O_P_ID); if (resourceId != null) { urlResourceId = resourceId; } if (urlResourceId == null) { if (prefix.startsWith(BridgeConstants.WSRP)) { appendParameterToURL(LiferayConstants.P_P_RESOURCE_ID, BridgeConstants.WSRP, url); } } else { appendParameterToURL(LiferayConstants.P_P_RESOURCE_ID, urlResourceId, url); } // Possibly add a Portlet URL Anchor if (portletURLAnchor != null) { url.append(portletURLAnchor); } toStringValue = url.toString(); } return toStringValue; }
From source file:com.liferay.faces.bridge.container.liferay.PortletContainerLiferayCompatImpl.java
License:Open Source License
protected boolean isPortletRequiresNamespacedParameters(PortletRequest portletRequest, ThemeDisplay themeDisplay) {/* w ww . j a va2 s . c o m*/ boolean portletRequiresNamespacedParameters = false; String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); try { Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); portletRequiresNamespacedParameters = portlet.isRequiresNamespacedParameters(); } catch (SystemException e) { logger.error(e); } return portletRequiresNamespacedParameters; }
From source file:com.liferay.faces.bridge.context.internal.BridgePortalContextLiferayCompatImpl.java
License:Open Source License
protected boolean isLiferayNamingspacingParameters(PortletRequest portletRequest) { boolean liferayNamespacingParameters = false; String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); try {// ww w. jav a 2 s.com ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); liferayNamespacingParameters = portlet.isRequiresNamespacedParameters(); } catch (SystemException e) { logger.error(e); } return liferayNamespacingParameters; }
From source file:com.liferay.faces.bridge.ext.context.internal.PortalContextBridgeLiferayImpl.java
License:Open Source License
private boolean isLiferayNamespacingParameters(PortletRequest portletRequest) { boolean liferayNamespacingParameters = false; String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); try {/* www . ja v a2s . c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); liferayNamespacingParameters = portlet.isRequiresNamespacedParameters(); } catch (SystemException e) { logger.error(e); } return liferayNamespacingParameters; }
From source file:com.liferay.faces.bridge.ext.filter.internal.LiferayURLGeneratorBaseImpl.java
License:Open Source License
public String generateURL(Map<String, String[]> additionalParameterMap, String cacheability, PortletMode portletMode, String resourceId, WindowState windowState) { String toStringValue;// w w w .ja v a2 s . c o m if (baseURL.contains(Portal.FRIENDLY_URL_SEPARATOR)) { toStringValue = baseURL; } else { StringBuilder url = new StringBuilder(); // Build up a new URL string based on the one returned by Liferay, but discard everything after the // question mark because it's filled with all kinds of unnecessary stuff. url.append(prefix); // Possibly add the p_auth parameter. boolean firstParameter = true; String portalAuthToken = StringHelper.toString(additionalParameterMap.get(P_AUTH), parameterMap.get(P_AUTH)); if (portalAuthToken != null) { appendParameterToURL(firstParameter, P_AUTH, portalAuthToken, url); firstParameter = false; } // Possibly add the p_l_id parameter. String plid = StringHelper.toString(additionalParameterMap.get(P_L_ID), parameterMap.get(P_L_ID)); if (plid != null) { appendParameterToURL(firstParameter, P_L_ID, plid, url); firstParameter = false; } // Possibly add the p_p_auth parameter. String portletAuthToken = StringHelper.toString(additionalParameterMap.get(P_P_AUTH), parameterMap.get(P_P_AUTH)); if (portletAuthToken != null) { boolean addPortletAuthToken = true; if ((LIFERAY_BUILD_NUMBER < 6102) || ((LIFERAY_BUILD_NUMBER > 6102) && (LIFERAY_BUILD_NUMBER < 6130))) { // Versions of Liferay Portal prior to 6.1.2-CE/6.1.30-EE suffered from LPS-36481 which caused // PortletURLImpl.addPortletAuthToken(StringBundle, Key) method to add the p_p_auth parameter to // URLs for portlets when add-default-resource=false. It is therefore necessary to check that // add-default-resource=true before adding the p_p_auth parameter to the URL. FacesContext facesContext = FacesContext.getCurrentInstance(); PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest(); String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try { Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); addPortletAuthToken = portlet.isAddDefaultResource(); } catch (SystemException e) { logger.error(e); } } if (addPortletAuthToken) { appendParameterToURL(firstParameter, P_P_AUTH, portletAuthToken, url); firstParameter = false; } } // Always add the p_p_id parameter String parameterValue = StringHelper.toString(additionalParameterMap.get(P_P_ID), responseNamespace); if (parameterValue.startsWith("_")) { parameterValue = parameterValue.substring(1); } if (parameterValue.endsWith("_")) { parameterValue = parameterValue.substring(0, parameterValue.length() - 1); } appendParameterToURL(firstParameter, P_P_ID, parameterValue, url); firstParameter = false; // Always add the p_p_lifecycle parameter. String portletLifecycleId = getPortletLifecycleId(); appendParameterToURL(P_P_LIFECYCLE, portletLifecycleId, url); // Add the p_p_state parameter. FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap(); WindowState urlWindowState = initialWindowState; if (additionalParameterMap.get(P_P_STATE) != null) { urlWindowState = new WindowState(additionalParameterMap.get(P_P_STATE)[0]); } if (windowState != null) { urlWindowState = windowState; } if (urlWindowState == null) { parameterValue = (String) applicationMap.get(responseNamespace + P_P_STATE); } else { parameterValue = urlWindowState.toString(); } appendParameterToURL(P_P_STATE, parameterValue, url); // Possibly add the p_p_state_rcv parameter. String stateRestoreCurrentView = StringHelper.toString(additionalParameterMap.get(P_P_STATE_RCV), parameterMap.get(P_P_STATE_RCV)); if (stateRestoreCurrentView != null) { appendParameterToURL(P_P_STATE_RCV, stateRestoreCurrentView, url); } // Add the p_p_mode parameter. PortletMode urlPortletMode = initialPortletMode; if (additionalParameterMap.get(P_P_MODE) != null) { urlPortletMode = new PortletMode(additionalParameterMap.get(P_P_MODE)[0]); } if (portletMode != null) { urlPortletMode = portletMode; } if (urlPortletMode == null) { parameterValue = (String) applicationMap.get(responseNamespace + P_P_MODE); } else { parameterValue = urlPortletMode.toString(); } appendParameterToURL(P_P_MODE, parameterValue, url); // Possibly add the p_p_cacheability parameter if (LIFECYCLE_RESOURCE_PHASE_ID.equals(portletLifecycleId)) { String urlCacheability = null; if (cacheability != null) { urlCacheability = cacheability; } if (urlCacheability == null) { urlCacheability = StringHelper.toString(additionalParameterMap.get(P_P_CACHEABILITY), parameterMap.get(P_P_CACHEABILITY)); } if (urlCacheability != null) { appendParameterToURL(P_P_CACHEABILITY, urlCacheability, url); } } // Always add the p_p_col_id parameter parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_ID); appendParameterToURL(P_P_COL_ID, parameterValue, url); // Possibly add the p_p_col_count parameter. parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_COUNT); appendParameterToURL(P_P_COL_COUNT, parameterValue, url); // Add the p_p_col_pos parameter if it is greater than zero (same logic as Liferay's // PortletURLImpl.toString()) parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_POS); if ((parameterValue != null) && (parameterValue.length() > 0)) { try { int colPos = Integer.parseInt(parameterValue); if (colPos > 0) { appendParameterToURL(P_P_COL_POS, parameterValue, url); } } catch (NumberFormatException e) { // ignore } } // Possibly add the p_o_p_id parameter. String outerPortletId = StringHelper.toString(additionalParameterMap.get(P_O_P_ID), parameterMap.get(P_O_P_ID)); if (outerPortletId != null) { appendParameterToURL(P_O_P_ID, outerPortletId, url); } // Possibly add the doAsUserId parameter. String doAsUserId = StringHelper.toString(additionalParameterMap.get(DO_AS_USER_ID), parameterMap.get(DO_AS_USER_ID)); if (doAsUserId != null) { appendParameterToURL(DO_AS_USER_ID, doAsUserId, url); } // Possibly add the doAsUserLanguageId parameter. String doAsUserLanguageId = StringHelper.toString(additionalParameterMap.get(DO_AS_USER_LANGUAGE_ID), parameterMap.get(DO_AS_USER_LANGUAGE_ID)); if (doAsUserLanguageId != null) { appendParameterToURL(DO_AS_USER_LANGUAGE_ID, doAsUserLanguageId, url); } // Possibly add the doAsGroupId parameter. String doAsGroupId = StringHelper.toString(additionalParameterMap.get(DO_AS_GROUP_ID), parameterMap.get(DO_AS_GROUP_ID)); if (doAsGroupId != null) { appendParameterToURL(DO_AS_GROUP_ID, doAsGroupId, url); } // Possibly add the refererGroupId parameter. String refererGroupId = StringHelper.toString(additionalParameterMap.get(REFERER_GROUP_ID), parameterMap.get(REFERER_GROUP_ID)); if (refererGroupId != null) { appendParameterToURL(REFERER_GROUP_ID, refererGroupId, url); } // Possibly add the refererPlid parameter. String refererPlid = StringHelper.toString(additionalParameterMap.get(REFERER_PLID), parameterMap.get(REFERER_PLID)); if (refererPlid != null) { appendParameterToURL(REFERER_PLID, refererPlid, url); } // Possibly add the controlPanelCategory parameter. String controlPanelCategory = StringHelper.toString(additionalParameterMap.get(CONTROL_PANEL_CATEGORY), parameterMap.get(CONTROL_PANEL_CATEGORY)); if (controlPanelCategory != null) { appendParameterToURL(CONTROL_PANEL_CATEGORY, controlPanelCategory, url); } // Add request parameters from the request parameter map. boolean namespaced = !responseNamespace.startsWith("wsrp"); Set<Map.Entry<String, String[]>> mapEntries = additionalParameterMap.entrySet(); if (mapEntries != null) { for (Map.Entry<String, String[]> mapEntry : mapEntries) { String[] parameterValues = mapEntry.getValue(); if (parameterValues != null) { String parameterName = mapEntry.getKey(); if (!LIFERAY_NON_NAMESPACED_PARAMS.contains(parameterName)) { for (String curParameterValue : parameterValues) { if (curParameterValue != null) { String encodedParameterValue = encode(curParameterValue); appendParameterToURL(firstParameter, namespaced, parameterName, encodedParameterValue, url); } } } } } } // Add WSRP URL parameters for (LiferayURLParameter wsrpParameter : wsrpParameters) { appendParameterToURL(wsrpParameter.getName(), wsrpParameter.getValue(), url); } // Possibly add the p_p_resource_id parameter. String urlResourceId = parameterMap.get(P_O_P_ID); if (resourceId != null) { urlResourceId = resourceId; } if (urlResourceId == null) { if (prefix.startsWith("wsrp")) { appendParameterToURL(P_P_RESOURCE_ID, "wsrp", url); } } else { appendParameterToURL(P_P_RESOURCE_ID, urlResourceId, url); } // Possibly add a Portlet URL Anchor if (portletURLAnchor != null) { url.append(portletURLAnchor); } toStringValue = url.toString(); } return toStringValue; }
From source file:com.liferay.faces.bridge.filter.liferay.internal.LiferayURLGeneratorBaseImpl.java
License:Open Source License
public String generateURL(Map<String, String[]> additionalParameterMap, String cacheability, PortletMode portletMode, String resourceId, WindowState windowState) { String toStringValue;//from ww w.j ava 2 s . co m if (baseURL.contains(Portal.FRIENDLY_URL_SEPARATOR)) { toStringValue = baseURL; } else { StringBuilder url = new StringBuilder(); // Build up a new URL string based on the one returned by Liferay, but discard everything after the // question mark because it's filled with all kinds of unnecessary stuff. url.append(prefix); // Possibly add the p_auth parameter. boolean firstParameter = true; String portalAuthToken = StringHelper.toString(additionalParameterMap.get(P_AUTH), parameterMap.get(P_AUTH)); if (portalAuthToken != null) { appendParameterToURL(firstParameter, P_AUTH, portalAuthToken, url); firstParameter = false; } // Possibly add the p_l_id parameter. String plid = StringHelper.toString(additionalParameterMap.get(P_L_ID), parameterMap.get(P_L_ID)); if (plid != null) { appendParameterToURL(firstParameter, P_L_ID, plid, url); firstParameter = false; } // Possibly add the p_p_auth parameter. String portletAuthToken = StringHelper.toString(additionalParameterMap.get(P_P_AUTH), parameterMap.get(P_P_AUTH)); if (portletAuthToken != null) { boolean addPortletAuthToken = true; if ((LIFERAY_BUILD_NUMBER < 6102) || ((LIFERAY_BUILD_NUMBER > 6102) && (LIFERAY_BUILD_NUMBER < 6130))) { // Versions of Liferay Portal prior to 6.1.2-CE/6.1.30-EE suffered from LPS-36481 which caused // PortletURLImpl.addPortletAuthToken(StringBundle, Key) method to add the p_p_auth parameter to // URLs for portlets when add-default-resource=false. It is therefore necessary to check that // add-default-resource=true before adding the p_p_auth parameter to the URL. FacesContext facesContext = FacesContext.getCurrentInstance(); PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest(); String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); try { Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId); addPortletAuthToken = portlet.isAddDefaultResource(); } catch (SystemException e) { logger.error(e); } } if (addPortletAuthToken) { appendParameterToURL(firstParameter, P_P_AUTH, portletAuthToken, url); firstParameter = false; } } // Always add the p_p_id parameter String parameterValue = StringHelper.toString(additionalParameterMap.get(P_P_ID), responseNamespace); if (parameterValue.startsWith("_")) { parameterValue = parameterValue.substring(1); } if (parameterValue.endsWith("_")) { parameterValue = parameterValue.substring(0, parameterValue.length() - 1); } appendParameterToURL(firstParameter, P_P_ID, parameterValue, url); firstParameter = false; // Always add the p_p_lifecycle parameter. String portletLifecycleId = getPortletLifecycleId(); appendParameterToURL(P_P_LIFECYCLE, portletLifecycleId, url); // Add the p_p_state parameter. FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, Object> applicationMap = facesContext.getExternalContext().getApplicationMap(); WindowState urlWindowState = initialWindowState; if (additionalParameterMap.get(P_P_STATE) != null) { urlWindowState = new WindowState(additionalParameterMap.get(P_P_STATE)[0]); } if (windowState != null) { urlWindowState = windowState; } if (urlWindowState == null) { parameterValue = (String) applicationMap.get(responseNamespace + P_P_STATE); } else { parameterValue = urlWindowState.toString(); } appendParameterToURL(P_P_STATE, parameterValue, url); // Possibly add the p_p_state_rcv parameter. String stateRestoreCurrentView = StringHelper.toString(additionalParameterMap.get(P_P_STATE_RCV), parameterMap.get(P_P_STATE_RCV)); if (stateRestoreCurrentView != null) { appendParameterToURL(P_P_STATE_RCV, stateRestoreCurrentView, url); } // Add the p_p_mode parameter. PortletMode urlPortletMode = initialPortletMode; if (additionalParameterMap.get(P_P_MODE) != null) { urlPortletMode = new PortletMode(additionalParameterMap.get(P_P_MODE)[0]); } if (portletMode != null) { urlPortletMode = portletMode; } if (urlPortletMode == null) { parameterValue = (String) applicationMap.get(responseNamespace + P_P_MODE); } else { parameterValue = urlPortletMode.toString(); } appendParameterToURL(P_P_MODE, parameterValue, url); // Possibly add the p_p_cacheability parameter if (LIFECYCLE_RESOURCE_PHASE_ID.equals(portletLifecycleId)) { String urlCacheability = null; if (cacheability != null) { urlCacheability = cacheability; } if (urlCacheability == null) { urlCacheability = StringHelper.toString(additionalParameterMap.get(P_P_CACHEABILITY), parameterMap.get(P_P_CACHEABILITY)); } if (urlCacheability != null) { appendParameterToURL(P_P_CACHEABILITY, urlCacheability, url); } } // Always add the p_p_col_id parameter parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_ID); appendParameterToURL(P_P_COL_ID, parameterValue, url); // Possibly add the p_p_col_count parameter. parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_COUNT); appendParameterToURL(P_P_COL_COUNT, parameterValue, url); // Add the p_p_col_pos parameter if it is greater than zero (same logic as Liferay's // PortletURLImpl.toString()) parameterValue = (String) applicationMap.get(responseNamespace + P_P_COL_POS); if ((parameterValue != null) && (parameterValue.length() > 0)) { try { int colPos = Integer.parseInt(parameterValue); if (colPos > 0) { appendParameterToURL(P_P_COL_POS, parameterValue, url); } } catch (NumberFormatException e) { // ignore } } // Possibly add the p_o_p_id parameter. String outerPortletId = StringHelper.toString(additionalParameterMap.get(P_O_P_ID), parameterMap.get(P_O_P_ID)); if (outerPortletId != null) { appendParameterToURL(P_O_P_ID, outerPortletId, url); } // Possibly add the doAsUserId parameter. String doAsUserId = StringHelper.toString(additionalParameterMap.get(DO_AS_USER_ID), parameterMap.get(DO_AS_USER_ID)); if (doAsUserId != null) { appendParameterToURL(DO_AS_USER_ID, doAsUserId, url); } // Possibly add the doAsUserLanguageId parameter. String doAsUserLanguageId = StringHelper.toString(additionalParameterMap.get(DO_AS_USER_LANGUAGE_ID), parameterMap.get(DO_AS_USER_LANGUAGE_ID)); if (doAsUserLanguageId != null) { appendParameterToURL(DO_AS_USER_LANGUAGE_ID, doAsUserLanguageId, url); } // Possibly add the doAsGroupId parameter. String doAsGroupId = StringHelper.toString(additionalParameterMap.get(DO_AS_GROUP_ID), parameterMap.get(DO_AS_GROUP_ID)); if (doAsGroupId != null) { appendParameterToURL(DO_AS_GROUP_ID, doAsGroupId, url); } // Possibly add the refererGroupId parameter. String refererGroupId = StringHelper.toString(additionalParameterMap.get(REFERER_GROUP_ID), parameterMap.get(REFERER_GROUP_ID)); if (refererGroupId != null) { appendParameterToURL(REFERER_GROUP_ID, refererGroupId, url); } // Possibly add the refererPlid parameter. String refererPlid = StringHelper.toString(additionalParameterMap.get(REFERER_PLID), parameterMap.get(REFERER_PLID)); if (refererPlid != null) { appendParameterToURL(REFERER_PLID, refererPlid, url); } // Possibly add the controlPanelCategory parameter. String controlPanelCategory = StringHelper.toString(additionalParameterMap.get(CONTROL_PANEL_CATEGORY), parameterMap.get(CONTROL_PANEL_CATEGORY)); if (controlPanelCategory != null) { appendParameterToURL(CONTROL_PANEL_CATEGORY, controlPanelCategory, url); } // Add request parameters from the request parameter map. boolean namespaced = !responseNamespace.startsWith("wsrp"); Set<Map.Entry<String, String[]>> mapEntries = additionalParameterMap.entrySet(); if (mapEntries != null) { for (Map.Entry<String, String[]> mapEntry : mapEntries) { String[] parameterValues = mapEntry.getValue(); if (parameterValues != null) { String parameterName = mapEntry.getKey(); if (!LIFERAY_NON_NAMESPACED_PARAMS.contains(parameterName)) { for (String curParameterValue : parameterValues) { if (curParameterValue != null) { String encodedParameterValue = encode(curParameterValue); appendParameterToURL(firstParameter, namespaced, parameterName, encodedParameterValue, url); } } } } } } // Add WSRP URL parameters for (URLParameter wsrpParameter : wsrpParameters) { appendParameterToURL(wsrpParameter.getName(), wsrpParameter.getValue(), url); } // Possibly add the p_p_resource_id parameter. String urlResourceId = parameterMap.get(P_O_P_ID); if (resourceId != null) { urlResourceId = resourceId; } if (urlResourceId == null) { if (prefix.startsWith("wsrp")) { appendParameterToURL(P_P_RESOURCE_ID, "wsrp", url); } } else { appendParameterToURL(P_P_RESOURCE_ID, urlResourceId, url); } // Possibly add a Portlet URL Anchor if (portletURLAnchor != null) { url.append(portletURLAnchor); } toStringValue = url.toString(); } return toStringValue; }
From source file:com.liferay.httpservice.internal.servlet.WebExtenderServlet.java
License:Open Source License
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { printHeaders(request);//from w w w . j a va 2 s.com String portletId = (String) request.getAttribute(WebKeys.PORTLET_ID); String requestURI = request.getRequestURI(); ServletContext servletContext = getServletContext(portletId, requestURI); service(request, response, servletContext, portletId, requestURI); }