List of usage examples for com.liferay.portal.kernel.util PortalUtil getHttpServletRequest
public static HttpServletRequest getHttpServletRequest(PortletRequest portletRequest)
From source file:com.liferay.exportimport.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static RenderRequest getWrappedRenderRequest(RenderRequest renderRequest, PortletPreferences portletPreferences) throws PortalException { HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest); portletPreferences = getPortletPreferences(request, renderRequest.getPreferences(), portletPreferences); renderRequest = new ConfigurationRenderRequest(renderRequest, portletPreferences); request.setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, renderRequest); return renderRequest; }
From source file:com.liferay.exportimport.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static ResourceRequest getWrappedResourceRequest(ResourceRequest resourceRequest, PortletPreferences portletPreferences) throws PortalException { HttpServletRequest request = PortalUtil.getHttpServletRequest(resourceRequest); portletPreferences = getPortletPreferences(request, resourceRequest.getPreferences(), portletPreferences); return new ConfigurationResourceRequest(resourceRequest, portletPreferences); }
From source file:com.liferay.faces.bridge.ext.client.internal.BrowserSnifferFactoryLiferayImpl.java
License:Open Source License
@Override public BrowserSniffer getBrowserSniffer(ExternalContext externalContext) { PortletRequest portletRequest = (PortletRequest) externalContext.getRequest(); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); // Calling ExternalContext.setRequest(httpServletRequest) adds extra overhead because all of the // underlying maps have to get re-created. Instead, create a simple ExternalContextWrapper. ExternalContext externalContextBrowserSnifferImpl = new ExternalContextBrowserSnifferImpl(externalContext, httpServletRequest);/*from www .j ava 2 s .co m*/ BrowserSnifferFactory firstNonBridgeBrowserSnifferFactory = getFirstNonBridgeBrowserSnifferFactory(); return firstNonBridgeBrowserSnifferFactory.getBrowserSniffer(externalContextBrowserSnifferImpl); }
From source file:com.liferay.faces.bridge.ext.context.internal.HeadResponseWriterLiferayImpl.java
License:Open Source License
@Override protected void addResourceToHeadSection(Element element, String nodeName) throws IOException { // Get the underlying HttpServletRequest and HttpServletResponse FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); PortletRequest portletRequest = (PortletRequest) externalContext.getRequest(); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); PortletResponse portletResponse = (PortletResponse) externalContext.getResponse(); HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(portletResponse); // Invoke the Liferay HtmlTopTag class directly (rather than using liferay-util:html-top from a JSP). HtmlTopTag htmlTopTag = new HtmlTopTag(); JspFactory jspFactory = JspFactory.getDefaultFactory(); ServletContext servletContext = getServletContext(httpServletRequest); JSPSupportServlet jspSupportServlet = new JSPSupportServlet(servletContext); PageContext pageContext = jspFactory.getPageContext(jspSupportServlet, httpServletRequest, httpServletResponse, null, false, 0, false); htmlTopTag.setPageContext(pageContext); htmlTopTag.doStartTag();//from w w w . jav a 2 s.c o m String elementAsString = element.toString(); BodyContent bodyContent = pageContext.pushBody(); bodyContent.print(elementAsString); htmlTopTag.setBodyContent(bodyContent); try { htmlTopTag.doEndTag(); } catch (Exception e) { throw new IOException(e.getMessage()); } jspFactory.releasePageContext(pageContext); logger.debug(ADDED_RESOURCE_TO_HEAD, "Liferay", nodeName); }
From source file:com.liferay.faces.bridge.ext.event.internal.LiferayPageTopPhaseListenerCompat.java
License:Open Source License
protected void setPageTop(PortletRequest portletRequest, StringBundler pageTop) { OutputData outputData = (OutputData) portletRequest.getAttribute(WebKeys.OUTPUT_DATA); if (outputData != null) { outputData.setData(null, WebKeys.PAGE_TOP, pageTop); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); httpServletRequest.setAttribute(WebKeys.PAGE_TOP, pageTop); }// w w w . j a va 2s .c o m }
From source file:com.liferay.faces.portal.resource.internal.CaptchaResource.java
License:Open Source License
@Override public InputStream getInputStream() { ByteArrayInputStream byteArrayInputStream = null; try {//from w w w . j a va2 s .c om FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); PortletRequest portletRequest = (PortletRequest) externalContext.getRequest(); PortletResponse portletResponse = (PortletResponse) externalContext.getResponse(); PortletSession portletSession = (PortletSession) externalContext.getSession(true); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(portletResponse); CaptchaHttpServletResponse captchaHttpServletResponse = new CaptchaHttpServletResponse( httpServletResponse); CaptchaUtil.serveImage(httpServletRequest, captchaHttpServletResponse); String captchaText = (String) httpServletRequest.getSession().getAttribute(CAPTCHA_TEXT); portletSession.setAttribute(CAPTCHA_TEXT, captchaText); CaptchaServletOutputStream captchaServletOutputStream = (CaptchaServletOutputStream) captchaHttpServletResponse .getOutputStream(); byteArrayInputStream = new ByteArrayInputStream(captchaServletOutputStream.toByteArray()); } catch (Exception e) { e.printStackTrace(); } return byteArrayInputStream; }
From source file:com.liferay.ip.geocoder.sample.web.internal.portlet.IPGeocoderSamplePortlet.java
License:Open Source License
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest); ServiceReference<IPGeocoder> serviceReference = _bundleContext.getServiceReference(IPGeocoder.class); if (serviceReference != null) { IPGeocoder ipGeocoder = _bundleContext.getService(serviceReference); if (ipGeocoder != null) { IPInfo ipInfo = ipGeocoder.getIPInfo(request.getRemoteAddr()); renderRequest.setAttribute(IPInfo.class.getName(), ipInfo); }/*w w w . j ava 2 s.co m*/ } super.doView(renderRequest, renderResponse); }
From source file:com.liferay.journal.web.internal.display.context.JournalMoveEntriesDisplayContext.java
License:Open Source License
public JournalMoveEntriesDisplayContext(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, String currentURL) throws PortalException { _liferayPortletRequest = liferayPortletRequest; _liferayPortletResponse = liferayPortletResponse; _currentURL = currentURL;// w w w .java 2 s . c o m _servletRequest = PortalUtil.getHttpServletRequest(_liferayPortletRequest); processFolders(getMoveFolders()); processArticles(getMoveArticles()); setViewAttributes(); }
From source file:com.liferay.journal.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static JournalArticle getArticle(PortletRequest portletRequest) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); JournalArticle article = getArticle(request); JournalUtil.addRecentArticle(portletRequest, article); return article; }
From source file:com.liferay.journal.web.internal.portlet.action.ActionUtil.java
License:Open Source License
public static JournalFeed getFeed(PortletRequest portletRequest) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); return getFeed(request); }