/** * @param name * @param scope * @return The value of the attribute for a given scope. */ private static Object getContextAttribute( final String name, final int scope) { return getContextAttributes().getAttribute(name, scope); }
/** * Remove the scoped attribute of the given name for a given scope, if it exists. * @param name * @param scope */ private static void removeContextAttribute( final String name, final int scope) { getContextAttributes().removeAttribute(name, scope); }
/** * Set an attribute for a given scope. * @param name * @param value * @param scope */ private static void setContextAttribute( final String name, final Object value, final int scope) { getContextAttributes().setAttribute(name, value, scope); }
/** * @return The current HttpServletRequest. */ public static HttpServletRequest getHttpServletRequest() { if (ContextUtils.isServlet()) { return ((ServletRequestAttributes) ContextUtils.getContextAttributes()).getRequest(); } PortletRequest portletRequest = ((PortletRequestAttributes) ContextUtils.getContextAttributes()).getRequest(); return ContextUtils.getHttpServletRequestFromPortletRequest(portletRequest); }
/** * @return The current PortletRequest. */ private static PortletRequest getPortletRequest() { RequestAttributes requestAttributes = ContextUtils.getContextAttributes(); if (!ContextUtils.isPortlet()) { throw new UnsupportedOperationException( "call HttpUtils.getPortletRequest() in portlet mode only!"); } return ((PortletRequestAttributes) requestAttributes).getRequest(); }
/** * @return The global session attributes, as a set of strings. */ public static Set<String> getGlobalSessionAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { HttpServletRequest servletRequest = ((ServletRequestAttributes) getContextAttributes()).getRequest(); return getAttributesStrings(getGlobalSessionAttributes(servletRequest)); } PortletRequest portletRequest = ((PortletRequestAttributes) getContextAttributes()).getRequest(); return getAttributesStrings(getGlobalSessionAttributes(portletRequest)); }
/** * @return The request attributes, as a set of strings. */ public static Set<String> getRequestAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { return getAttributesStrings(getRequestAttributes( ((ServletRequestAttributes) getContextAttributes()).getRequest())); } return getAttributesStrings(getRequestAttributes( ((PortletRequestAttributes) getContextAttributes()).getRequest())); }
/** * @return The session attributes, as a set of strings. */ public static Set<String> getSessionAttributesStrings() { if (!isWeb()) { return new TreeSet<String>(); } if (isServlet()) { return getAttributesStrings(getSessionAttributes( ((ServletRequestAttributes) getContextAttributes()).getRequest())); } return getAttributesStrings(getSessionAttributes( ((PortletRequestAttributes) getContextAttributes()).getRequest())); }