|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IContext
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:
com.webmethods.portal.framework.presentation.PresentationData
for more information.Map
.
com.webmethods.portal.framework.presentation.PresentationData
Field Summary | |
---|---|
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
|
Method Summary | |
---|---|
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 |
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 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 |
Methods inherited from interface com.webmethods.portal.bizPolicy.IPrincipalData |
---|
getDN, getDomain, getPassword, getUri, getUserDirectoryURI, getUserID, getUserName, isAdminSession, isAnonymous, isAuthenticated, isLoginSession, isPrivilegedInfo, setAuthentication, setDN, setDomain, setInfo, setIsAdminSession, setIsAnonymous, setIsLoginSession, setIsPrivilegedInfo, setUri, setUserID, setUserName |
Methods inherited from interface com.webmethods.portal.system.IURI |
---|
clone, getSegment, getSegments, getSegments, getServiceName, getSize, initialize, toString |
Methods inherited from interface com.webmethods.portal.bizPolicy.ILocaleInfo |
---|
evaluateLocale, getiContext, getLocale, setLocale, setLocale |
Field Detail |
---|
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);
IContext.setAttribute(java.lang.Object, java.lang.Object, int)
,
IContext.getAttribute(java.lang.Object, int)
,
Constant Field Valuesstatic 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);
IContext.setAttribute(java.lang.Object, java.lang.Object, int)
,
IContext.getAttribute(java.lang.Object, int)
,
Constant Field Valuesstatic final int SCOPE_APPLICATION
Method Detail |
---|
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.IContext.getTraits()
void setAttribute(Object key, Object value, int scope)
key
- the identifier of the datavalue
- the datascope
- the scope of the dataIContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
void setAttributes(Map properties, int scope)
properties
- A Map of attributes to storescope
- the scope of the dataIContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
Object getAttribute(Object key, int scope)
key
- the identifier of the datascope
- the scope of the data
IContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
void removeAttribute(Object key, int scope)
key
- the identifier of the datascope
- the scope of the dataIContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
void clearAttributes(int scope)
scope
- the scope of the dataIContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
Map getAttributes(int scope)
scope
- the scope of the data
IContext.SCOPE_REQUEST
,
IContext.SCOPE_SESSION
Object getCommandResult()
IContext.setCommandResult(java.lang.Object)
void setCommandResult(Object obj)
obj
- the command result value to set.IContext.getCommandResult()
IURI getCurrentResource()
IURI
of the current resourcevoid setCurrentResource(IURI uri)
uri
- the IURI
of the current resourceIContext.getCurrentResource()
String getCurrentResourceType()
void setCurrentResourceType(String type)
IContext.getCurrentResourceType()
void startTracking()
void stopTracking()
IContextState getTrackedState()
IContextState
of the current context.boolean isSystemContext()
IContext.setSystemContext(boolean)
void setSystemContext(boolean isSystemContext)
isSystemContext
- True if this is a system context, False otherwise.IContext.isSystemContext()
boolean canImpersonate(IThingID userID)
userID
- the user to impersonate
void 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()
IContext.hasRenderedPageStart()
void setInformationalMessage(int severity, String message)
severity
- message
- already localized messageIInformationalMessage
IInformationalMessage getMessage()
IInformationalMessage
void clearMessage()
IInformationalMessage
boolean hasMessage()
IInformationalMessage
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |