public interface IContext extends IPrincipalData, IURI, ILocaleInfo
IContext is the java bean that represents the current user's portal session. It provides a protocol independent way of accessing request and session information. It is guaranteed to always be available for any business logic or presentation logic. If an IContext is accessed from outside of the scope of a current session then it will act as the system user.
IContext can be accessed from anywhere with the following code examples:
IContext context = com.webmethods.portal.bizPolicy.impl.ContextFactory.acquireContext(true);
Or if you have access to the HttpServletRequest, //request = HttpServletRequest
IContext context = com.webmethods.portal.bizPolicy.impl.ContextFactory.acquireContext(request);
IContext holds the following types of information:
PresentationData
for more information.Map
.PresentationData
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CLASS
The default implementation of this interface: com.webmethods.portal.bizPolicy.impl.Context
|
static String |
ID |
static int |
SCOPE_APPLICATION
Deprecated.
|
static int |
SCOPE_REQUEST
All attributes are stored with a scope.
|
static int |
SCOPE_SESSION
All attributes are stored with a scope.
|
static String |
SERVICE_NAME |
Modifier and Type | Method and Description |
---|---|
boolean |
canImpersonate(IThingID userID)
Checks if the current user can impersonate other users
|
void |
clearAttributes(int scope)
Clears all the attributes on the IContext that stored stateful user information for a given scope.
|
void |
clearMessage()
Clears any information message
|
Object |
getAttribute(Object key,
int scope)
Gets an attribute on the IContext that was used to store stateful user information.
|
Map<Object,Object> |
getAttributes(int scope)
Retrieves all the attributes on the IContext that store stateful user information for the given scope.
|
Object |
getCommandResult()
Retrieves the result of the last command.
|
IContextProvider |
getContextProvider()
Returns instance of ContextProvider which created this context instance
|
IURI |
getCurrentResource()
Retrieves the current resource.
|
String |
getCurrentResourceType()
(Probably) Only valid in the webApplication context
The type might be for instance: folder, content, wm_xt_rssfeed, etc...
|
IPrincipalData |
getInternalPrincipalData()
Get the internal storage for the
IPrincipalData . |
IInformationalMessage |
getMessage()
Retrieves a message if available
|
IContextState |
getTrackedState()
Deprecated.
for use only with the PostRenderCache
|
ITraits |
getTraits()
Get the
ITraits object for the current context. |
boolean |
hasMessage()
Whether the current context has a message
|
boolean |
hasRenderedPageStart()
This is a clue to the presentation system that
this context's request has already rendered the start of a page
In case of error, don't rerender all the header info
|
void |
impersonate(IThingID userID,
boolean isAdmin)
Have this context impersonate a user.
|
void |
initialize(IPrincipalData info)
Initialize this context using the given principal data object.
|
boolean |
isSystemContext()
Returns true if this is a system context.
|
boolean |
isValid()
Describes whether this is context is in a valid state.
|
void |
removeAttribute(Object key,
int scope)
Removes an attribute on the IContext that stored stateful user information.
|
void |
setAttribute(Object key,
Object value,
int scope)
Sets an attribute on the IContext in order to store stateful user information.
|
void |
setAttributes(Map<? extends Object,? extends Object> properties,
int scope)
Sets attributes on the IContext in order to store stateful user information.
|
void |
setCommandResult(Object obj)
Sets the command result on the context with SCOPE_REQUEST scope.
|
void |
setCurrentResource(IURI uri)
Set the current resource.
|
void |
setCurrentResourceType(String type) |
void |
setInformationalMessage(int severity,
String message)
This sets a message that can later be retrieved (stored on the session)
|
void |
setRenderedPageStart() |
void |
setSystemContext(boolean isSystemContext)
Set whether this is a system context.
|
void |
setTraits(ITraits traits)
Set the
ITraits object for the current context. |
void |
startTracking()
Deprecated.
for use only with the PostRenderCache
|
void |
stopTracking()
Deprecated.
for use only with the PostRenderCache
|
getDN, getDomain, getDomainUserName, getPassword, getUri, getUserDirectoryURI, getUserID, getUserName, isAdminSession, isAnonymous, isAuthenticated, isLoginSession, isPrivilegedInfo, setAuthentication, setDN, setDomain, setInfo, setIsAdminSession, setIsAnonymous, setIsLoginSession, setIsPrivilegedInfo, setUri, setUserID, setUserName
clone, getSegment, getSegments, getSegments, getServiceName, getSize, initialize, toString
evaluateLocale, getiContext, getLocale, setLocale, setLocale
static final String SERVICE_NAME
static final String ID
static final String DEFAULT_CLASS
static final int SCOPE_REQUEST
context.setAttribute("myAttrKey", myObjectVal, IContext.SCOPE_REQEUST);
Then to retrieve the attribute later during the same request use the follwoing:
Object myObjectVal = context.getAttribute("myAttrKey", IContext.SCOPE_REQEUST);
static final int SCOPE_SESSION
context.setAttribute("myAttrKey", myObjectVal, IContext.SCOPE_SESSION);
Then to retrieve the attribute later during the same request use the follwoing:
Object myObjectVal = context.getAttribute("myAttrKey", IContext.SCOPE_SESSION);
@Deprecated static final int SCOPE_APPLICATION
boolean isValid()
IContextProvider getContextProvider()
void initialize(IPrincipalData info)
info
- IPrincipalData
objectITraits getTraits()
ITraits
object for the current context.
This allows you to inspect the current registered traits that control the runtime
execution of user's interaction with Portal Verbs.ITraits
objectvoid setTraits(ITraits traits)
ITraits
object for the current context.
This allows you to set the registered traits that control the runtime
execution of user's interaction with Portal Verbs.traits
- the ITraits
object.getTraits()
void setAttribute(Object key, Object value, int scope)
key
- the identifier of the datavalue
- the datascope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
void setAttributes(Map<? extends Object,? extends Object> properties, int scope)
properties
- A Map of attributes to storescope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
Object getAttribute(Object key, int scope)
key
- the identifier of the datascope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
void removeAttribute(Object key, int scope)
key
- the identifier of the datascope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
void clearAttributes(int scope)
scope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
Map<Object,Object> getAttributes(int scope)
scope
- the scope of the dataSCOPE_REQUEST
,
SCOPE_SESSION
Object getCommandResult()
setCommandResult(java.lang.Object)
void setCommandResult(Object obj)
obj
- the command result value to set.getCommandResult()
IURI getCurrentResource()
IURI
of the current resourcevoid setCurrentResource(IURI uri)
uri
- the IURI
of the current resourcegetCurrentResource()
String getCurrentResourceType()
void setCurrentResourceType(String type)
getCurrentResourceType()
@Deprecated void startTracking()
@Deprecated void stopTracking()
@Deprecated IContextState getTrackedState()
IContextState
of the current context.boolean isSystemContext()
setSystemContext(boolean)
void setSystemContext(boolean isSystemContext)
isSystemContext
- True if this is a system context, False otherwise.isSystemContext()
boolean canImpersonate(IThingID userID)
userID
- the user to impersonatevoid impersonate(IThingID userID, boolean isAdmin) throws PortalException
userID
- The IThingID
of the user to impersonate.isAdmin
- True if this is an administrator.PortalException
- if userID is invalidIPrincipalData getInternalPrincipalData()
IPrincipalData
.IPrincipalData
object for the current context.boolean hasRenderedPageStart()
void setRenderedPageStart()
hasRenderedPageStart()
void setInformationalMessage(int severity, String message)
severity
- message
- already localized messageIInformationalMessage
IInformationalMessage getMessage()
IInformationalMessage
void clearMessage()
IInformationalMessage
boolean hasMessage()
IInformationalMessage