Refine search
/** * Default resource serving. * <p> * The default implementation of this method does nothing. * <p> * However, if the reserved portlet initialization parameter * {@link #AUTOMATIC_RESOURCE_DISPATCH} * (= "javax.portlet.automaticResourceDispatching") * is set to <code>true</code>, the default * implementation will perform a * <code>PortletRequestDispatcher.forward</code> to the location designated by * the ResourceID of the ResourceRequest. * If no ResourceID is set on the resource URL the default implementation * does nothing. * * @since 2.0 */ public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { String autofwd = getInitParameter(AUTOMATIC_RESOURCE_DISPATCH); if (autofwd != null && autofwd.equalsIgnoreCase("true")) { if (request.getResourceID() != null) { PortletRequestDispatcher rd = getPortletConfig().getPortletContext().getRequestDispatcher( request.getResourceID()); if (rd != null) rd.forward(request, response); } } }
@Override public Object getAttribute(String name) { return wrapped.getAttribute(name); }
@Override public void setAttribute(String name, Object object) { wrapped.setAttribute(name, object); }
protected void include( String path, PortletRequest portletRequest, PortletResponse portletResponse, String lifecycle) throws IOException, PortletException { HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(portletRequest); PortletContext portletContext = (PortletContext)httpServletRequest.getAttribute( MVCRenderConstants. PORTLET_CONTEXT_OVERRIDE_REQUEST_ATTIBUTE_NAME_PREFIX + path); if (portletContext == null) { portletContext = getPortletContext(); } PortletRequestDispatcher portletRequestDispatcher = portletContext.getRequestDispatcher(path); if (portletRequestDispatcher == null) { _log.error(path + " is not a valid include"); } else { checkPath(path); portletRequestDispatcher.include(portletRequest, portletResponse); } if (clearRequestParameters) { if (lifecycle.equals(PortletRequest.RENDER_PHASE)) { portletResponse.setProperty( "clear-request-parameters", Boolean.TRUE.toString()); } } }
protected PortletRequestDispatcher getPortletRequestDispatcher( ResourceRequest resourceRequest, String path) { PortletConfig portletConfig = getPortletConfig(resourceRequest); PortletContext portletContext = portletConfig.getPortletContext(); return portletContext.getRequestDispatcher(path); }
@Override public BridgeConfig getBridgeConfig(PortletConfig portletConfig) { PortletContext portletContext = portletConfig.getPortletContext(); BridgeConfig bridgeConfig = (BridgeConfig) portletContext.getAttribute(BRIDGE_CONFIG); if (bridgeConfig == null) { bridgeConfig = new BridgeConfigImpl(portletConfig); portletContext.setAttribute(BRIDGE_CONFIG, bridgeConfig); } return bridgeConfig; }
final PortletContext context = config.getPortletContext(); for (final Enumeration<String> e = context.getInitParameterNames(); e .hasMoreElements();) { final String name = e.nextElement(); initParameters.setProperty(name, context.getInitParameter(name)); for (final Enumeration<String> e = config.getInitParameterNames(); e .hasMoreElements();) { final String name = e.nextElement(); initParameters.setProperty(name, config.getInitParameter(name));
@Override public ServletConfig getServletConfig( PortletConfig portletConfig, PortletRequest portletRequest) { PortletContext portletContext = portletConfig.getPortletContext(); Object servletConfig = portletContext.getAttribute( _PORTLET_CONTAINER_SERVLET_CONFIG); if (servletConfig == null) { servletConfig = portletRequest.getAttribute( PortletServlet.PORTLET_SERVLET_CONFIG); } return (ServletConfig)servletConfig; }
/** {@inheritDoc} */ public Collection<Object> values() { List<Object> list = new ArrayList<Object>(); Enumeration<String> keys = context.getAttributeNames(); while (keys.hasMoreElements()) { list.add(context.getAttribute(keys.nextElement())); } return (list); }
@Override public Object get(String name, ObjectFactory<?> objectFactory) { Object scopedObject = this.portletContext.getAttribute(name); if (scopedObject == null) { scopedObject = objectFactory.getObject(); this.portletContext.setAttribute(name, scopedObject); } return scopedObject; }
@Override public Object remove(String name) { Object scopedObject = this.portletContext.getAttribute(name); if (scopedObject != null) { this.portletContext.removeAttribute(name); this.destructionCallbacks.remove(name); return scopedObject; } else { return null; } }
protected void include( ResourceRequest resourceRequest, ResourceResponse resourceResponse, String jspPath) throws IOException, PortletException { PortletConfig portletConfig = getPortletConfig(resourceRequest); PortletContext portletContext = portletConfig.getPortletContext(); PortletRequestDispatcher portletRequestDispatcher = portletContext.getRequestDispatcher(jspPath); portletRequestDispatcher.include(resourceRequest, resourceResponse); }
@Override public String getInitParameter(String name) { String initParameter = portletConfig.getInitParameter(name); if (initParameter == null) { initParameter = portletContext.getInitParameter(name); } return initParameter; }
/** {@inheritDoc} */ public Collection<String> values() { List<String> list = new ArrayList<String>(); Enumeration<String> keys = context.getInitParameterNames(); while (keys.hasMoreElements()) { list.add(context.getInitParameter(keys.nextElement())); } return (list); }
@Override public File getBaseDirectory() { PortletContext context = getPortletContext(); String resultPath = context.getRealPath("/"); if (resultPath != null) { return new File(resultPath); } else { try { final URL url = context.getResource("/"); return new File(url.getFile()); } catch (final Exception e) { // FIXME: Handle exception getLogger().log(Level.INFO, "Cannot access base directory, possible security issue " + "with Application Server or Servlet Container", e); } } return null; }
@Override public InputStream getResourceAsStream(String path) { return wrapped.getResourceAsStream(path); }
@Override public URL getResource(String path) throws MalformedURLException { return wrapped.getResource(path); }
@Override public PortletRequestDispatcher getRequestDispatcher(String path) { return wrapped.getRequestDispatcher(path); }
@Override public String getRealPath(String path) { return wrapped.getRealPath(path); }
public static void dumpContextProperties(final StringBuffer sb, final PortletContext context, final String lf, final String indent) { sb.append(indent); sb.append("ContextRealPath=").append(context.getRealPath("/")); sb.append(lf).append(indent); sb.append("SERVER_SOFTWARE=").append(context.getServerInfo()); sb.append(", PortletContextName=").append( context.getPortletContextName()); sb.append(", MajorVersion=").append(context.getMajorVersion()); sb.append(", MinorVersion=").append(context.getMinorVersion()); }