public class PortletFacesContext.PortletExternalContext extends BaseFacesContext.BaseExternalContext
Modifier and Type | Class and Description |
---|---|
protected class |
PortletFacesContext.PortletExternalContext.ApplicationAttributeMap |
protected class |
PortletFacesContext.PortletExternalContext.PortletInitParameterMap |
protected class |
PortletFacesContext.PortletExternalContext.RequestAttributeMap |
protected class |
PortletFacesContext.PortletExternalContext.RequestHeaderMap |
protected class |
PortletFacesContext.PortletExternalContext.RequestHeaderValuesMap |
protected class |
PortletFacesContext.PortletExternalContext.RequestParameterMap |
protected class |
PortletFacesContext.PortletExternalContext.RequestParameterValuesMap |
protected class |
PortletFacesContext.PortletExternalContext.SessionAttributeMap |
protected class |
PortletFacesContext.PortletExternalContext.WebAppInitParameterMap |
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
m_applicationAttributeMap |
protected Map<String,Object> |
m_cookieMap |
protected Map<String,String> |
m_initParameterMap |
protected Map<String,Object> |
m_requestAttributeMap |
protected Map<String,String> |
m_requestHeaderMap |
protected Map<String,String[]> |
m_requestHeaderValuesMap |
protected List<Locale> |
m_requestLocales |
protected Map<String,String> |
m_requestParameterMap |
protected List<String> |
m_requestParameterNames |
protected Map<String,String[]> |
m_requestParameterValuesMap |
protected Map<String,Object> |
m_sessionAttributeMap |
m_wrapped
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
Constructor and Description |
---|
PortletExternalContext()
Default constructor.
|
PortletExternalContext(ExternalContext wrapped)
Create a
PortletExternalContext with a wrapped
ExternalContext . |
Modifier and Type | Method and Description |
---|---|
void |
dispatch(String path)
Dispatch a request to the specified resource to create output for
this response.
|
String |
encodeActionURL(String url)
Return the input URL, after performing any rewriting needed to ensure
that it will correctly identify an addressable action in the current
application.
|
String |
encodeNamespace(String ns)
Return the specified name, after prefixing it with a namespace
that ensures that it will be unique within the context of a
particular page.
|
String |
encodeResourceURL(String url)
Return the input URL, after performing any rewriting needed to ensure
that it will correctly identify an addressable resource in the
current application.
|
Map<String,Object> |
getApplicationMap()
Return a mutable
Map representing the application scope
attributes for the current application. |
String |
getAuthType()
Return the name of the authentication scheme used to authenticate the
current user, if any; otherwise, return null.
|
Object |
getContext()
Return the application environment object instance for the current application.
|
String |
getInitParameter(String name)
Return the value of the specified application initialization
parameter (if any).
|
Map<String,String> |
getInitParameterMap()
Return an immutable
Map whose keys are the set of
application initialization parameter names configured for this
application, and whose values are the corresponding parameter values. |
String |
getRemoteUser()
Return the login name of the user making the current request if any;
otherwise, return null.
|
Object |
getRequest()
Return the environment-specific object instance for the current
request.
|
String |
getRequestContextPath()
Return the portion of the request URI that identifies the web
application context for this request.
|
Map<String,Object> |
getRequestCookieMap()
Return an immutable
Map whose keys are the set of cookie
names included in the current request, and whose values (of type
Cookie ) are the first (or only) cookie for
each cookie name returned by the underlying request. |
Map<String,String> |
getRequestHeaderMap()
Return an immutable
Map whose keys are the set of
request header names included in the current request, and whose
values (of type String) are the first (or only) value for each header
name returned by the underlying request. |
Map<String,String[]> |
getRequestHeaderValuesMap()
Return an immutable
Map whose keys are the set of
request header names included in the current request, and whose
values (of type String[] ) are all of the value for each header name
returned by the underlying request. |
Locale |
getRequestLocale()
Return the preferred
Locale in which the client will
accept content. |
Iterator<Locale> |
getRequestLocales()
Return an
Iterator over the preferred
Locale s specified in the request, in decreasing order of
preference. |
Map<String,Object> |
getRequestMap()
Return a mutable
Map representing the request scope attributes for
the current application. |
Map<String,String> |
getRequestParameterMap()
Return an immutable
Map whose keys are the set of
request parameters names included in the current request, and whose
values (of type String ) are the first (or only) value
for each parameter name returned by the underlying request. |
Iterator<String> |
getRequestParameterNames()
Return an
Iterator over the names of all request
parameters included in the current request. |
Map<String,String[]> |
getRequestParameterValuesMap()
Return an immutable
Map whose keys are the set of
request parameters names included in the current request, and whose
values (of type String[] ) are all of the values for each
parameter name returned by the underlying request. |
String |
getRequestPathInfo()
Not used with the portlets.
|
String |
getRequestServletPath()
Return the current portlet viewId
|
URL |
getResource(String path)
Return a
URL for the application resource mapped to the specified
path, if it exists; otherwise, return null . |
InputStream |
getResourceAsStream(String path)
Return an
InputStream for an application resource mapped
to the specified path, if it exists; otherwise, return
null . |
Set<String> |
getResourcePaths(String path)
Return the
Set of resource paths for all application
resources whose resource path starts with the specified argument. |
Object |
getResponse()
Return the environment-specific object instance for the current
response.
|
Object |
getSession(boolean create)
If the create parameter is
true , create (if necessary) and return a
session instance associated with the current request. |
Map<String,Object> |
getSessionMap()
Return a mutable
Map representing the session scope
attributes for the current application. |
Principal |
getUserPrincipal()
Return the
Principal object containing the name of the
current authenticated user, if any; otherwise, return
null . |
boolean |
isUserInRole(String role)
Return
true if the currently authenticated user is
included in the specified role. |
void |
log(String message)
Log the specified message to the application object.
|
void |
log(String message,
Throwable exception)
Log the specified message to the application object.
|
void |
redirect(String url)
Redirect a request to the specified URL, and calls the
responseComplete() method on the
PortletFacesContext instance for the current request. |
protected void |
release()
Release all the resources held by
PortletFacesContext instance for the current request. |
encodeBookmarkableURL, encodeRedirectURL, getResponseOutputWriter, setResponseOutputWriter
getWrapped, setWrapped
addResponseCookie, addResponseHeader, encodePartialActionURL, getApplicationContextPath, getClientWindow, getContextName, getFlash, getMimeType, getRealPath, getRequestCharacterEncoding, getRequestContentLength, getRequestContentType, getRequestScheme, getRequestServerName, getRequestServerPort, getResponseBufferSize, getResponseCharacterEncoding, getResponseContentType, getResponseOutputStream, getSessionId, getSessionMaxInactiveInterval, invalidateSession, isResponseCommitted, isSecure, responseFlushBuffer, responseReset, responseSendError, setClientWindow, setRequest, setRequestCharacterEncoding, setResponse, setResponseBufferSize, setResponseCharacterEncoding, setResponseContentLength, setResponseContentType, setResponseHeader, setResponseStatus, setSessionMaxInactiveInterval
public PortletExternalContext()
public PortletExternalContext(ExternalContext wrapped)
PortletExternalContext
with a wrapped
ExternalContext
.wrapped
- ExternalContext
public void dispatch(String path) throws IOException
This must be accomplished by calling the PortletContext
method getRequestDispatcher()
, and calling the
include()
method on the resulting object.
dispatch
in class ExternalContextWrapper
path
- Context relative path to the specified resource, which
must start with a slash ("/") characterIOException
- if an input/output error occurspublic String encodeActionURL(String url)
This must be the value returned by the
PortletResponse.encodeURL(String)
method.
encodeActionURL
in class ExternalContextWrapper
url
- The input URL to be encodedpublic String encodeNamespace(String ns)
Return the specified name, after prefixing it with a namespace that ensures that it will be unique within the context of a particular page.
Servlet: The input value must be returned unchanged.
Portlet: The returned value must be the input value
prefixed by the value returned by the
javax.portlet.RenderResponse
method
getNamespace()
.
encodeNamespace
in class ExternalContextWrapper
name
- Name to be encodedIllegalStateException
- if this method is called in a portlet
environment, and the current response is an ActionResponse
instead of a RenderResponse
NullPointerException
- if name
is null
public String encodeResourceURL(String url)
This must be the value returned by the
PortletResponse.encodeURL(String)
method.
encodeResourceURL
in class ExternalContextWrapper
url
- the input URL to be encodedpublic Map<String,Object> getApplicationMap()
Map
representing the application scope
attributes for the current application.
This must be the set of attributes available via the
PortletContext
methods getAttribute(),
getAttributeNames(), removeAttribute(),
and setAttribute()
.
getApplicationMap
in class ExternalContextWrapper
Map
public String getAuthType()
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH,
or
FORM_AUTH
.
This must be the value returned by the
PortletRequest.getAuthType()
.
getAuthType
in class ExternalContextWrapper
public Object getContext()
getContext
in class ExternalContextWrapper
PortletConfig
or PortletContext
public String getInitParameter(String name)
PortletConfig.getInitParameter(String)
or
PortletContext.getInitParameter(String)
.getInitParameter
in class ExternalContextWrapper
name
- Name of the requested initialization parameterpublic Map<String,String> getInitParameterMap()
Map
whose keys are the set of
application initialization parameter names configured for this
application, and whose values are the corresponding parameter values.
This result is as if it were synthesized by calling the
PortletContext.getInitParameterNames()
method , and putting
each configured parameter name/value pair into the result.
getInitParameterMap
in class ExternalContextWrapper
Map
public String getRemoteUser()
This is the value returned by the
PortletRequest.getRemoteUser()
method.
getRemoteUser
in class ExternalContextWrapper
public Object getRequest()
getRequest
in class ExternalContextWrapper
PortletRequest
public String getRequestContextPath()
getRequestContextPath
in class ExternalContextWrapper
String
public Map<String,Object> getRequestCookieMap()
Map
whose keys are the set of cookie
names included in the current request, and whose values (of type
Cookie
) are the first (or only) cookie for
each cookie name returned by the underlying request.getRequestCookieMap
in class ExternalContextWrapper
Map
public Map<String,String> getRequestHeaderMap()
Map
whose keys are the set of
request header names included in the current request, and whose
values (of type String) are the first (or only) value for each header
name returned by the underlying request.getRequestHeaderMap
in class ExternalContextWrapper
Map
public Map<String,String[]> getRequestHeaderValuesMap()
Map
whose keys are the set of
request header names included in the current request, and whose
values (of type String[]
) are all of the value for each header name
returned by the underlying request.getRequestHeaderValuesMap
in class ExternalContextWrapper
Map
public Locale getRequestLocale()
Locale
in which the client will
accept content.getRequestLocale
in class ExternalContextWrapper
Locale
public Iterator<Locale> getRequestLocales()
Iterator
over the preferred
Locale
s specified in the request, in decreasing order of
preference.getRequestLocales
in class ExternalContextWrapper
Iterator
public Map<String,Object> getRequestMap()
Map
representing the request scope attributes for
the current application.getRequestMap
in class ExternalContextWrapper
Map
public Map<String,String> getRequestParameterMap()
Map
whose keys are the set of
request parameters names included in the current request, and whose
values (of type String
) are the first (or only) value
for each parameter name returned by the underlying request.getRequestParameterMap
in class ExternalContextWrapper
Map
public Iterator<String> getRequestParameterNames()
Iterator
over the names of all request
parameters included in the current request.getRequestParameterNames
in class ExternalContextWrapper
Iterator
public Map<String,String[]> getRequestParameterValuesMap()
Map
whose keys are the set of
request parameters names included in the current request, and whose
values (of type String[]
) are all of the values for each
parameter name returned by the underlying request.getRequestParameterValuesMap
in class ExternalContextWrapper
Map
public String getRequestPathInfo()
getRequestPathInfo
in class ExternalContextWrapper
null
public String getRequestServletPath()
getRequestServletPath
in class ExternalContextWrapper
public URL getResource(String path) throws MalformedURLException
URL
for the application resource mapped to the specified
path, if it exists; otherwise, return null
.getResource
in class ExternalContextWrapper
path
- String
pathURL
MalformedURLException
- if the specified path is not in the correct formNullPointerException
- if path is nullpublic InputStream getResourceAsStream(String path)
InputStream
for an application resource mapped
to the specified path, if it exists; otherwise, return
null
.getResourceAsStream
in class ExternalContextWrapper
path
- String
pathInputStream
public Set<String> getResourcePaths(String path)
Set
of resource paths for all application
resources whose resource path starts with the specified argument.getResourcePaths
in class ExternalContextWrapper
path
- String
pathSet
public Object getResponse()
getResponse
in class ExternalContextWrapper
PortletResponse
public Object getSession(boolean create)
true
, create (if necessary) and return a
session instance associated with the current request. If the create
parameter is false
return any existing session instance associated
with the current request, or return null
if there is no such session.getSession
in class ExternalContextWrapper
create
- Flag indicating whether or not a new session should be
created if there is no session associated with the current
requestPortletSession
or null
public Map<String,Object> getSessionMap()
Map
representing the session scope
attributes for the current application. Accessing attributes via this
Map
creates a session associated with the current
request, if such a session does not already exist.getSessionMap
in class ExternalContextWrapper
Map
public Principal getUserPrincipal()
Principal
object containing the name of the
current authenticated user, if any; otherwise, return
null
.getUserPrincipal
in class ExternalContextWrapper
Principal
public boolean isUserInRole(String role)
true
if the currently authenticated user is
included in the specified role. Otherwise, return false
.isUserInRole
in class ExternalContextWrapper
role
- Logical role name to be checkedpublic void log(String message, Throwable exception)
log
in class ExternalContextWrapper
message
- Message to be loggedexception
- Exception to be loggedNullPointerException
- if message or exception is nullpublic void log(String message)
log
in class ExternalContextWrapper
message
- Message to be loggedNullPointerException
- if message is nullpublic void redirect(String url) throws IOException
responseComplete()
method on the
PortletFacesContext
instance for the current request.redirect
in class ExternalContextWrapper
url
- Absolute URL to which the client should be redirectedIOException
- if an input/output error occursIllegalArgumentException
- if the specified url is relativeIllegalStateException
- if, in a portlet environment, the current response object
is a RenderResponse instead of an ActionResponseIllegalStateException
- if, in a servlet environment, the current response has
already been committedprotected void release()
PortletFacesContext
instance for the current request.release
in class BaseFacesContext.BaseExternalContext