Package com.microstrategy.web.tasks
Class BaseTaskRequestContext
- java.lang.Object
-
- com.microstrategy.web.tasks.BaseTaskRequestContext
-
- All Implemented Interfaces:
TaskRequestContext
- Direct Known Subclasses:
AppTaskRequestContext
public class BaseTaskRequestContext extends java.lang.Object implements TaskRequestContext
This class implements theTaskRequestContext
interface by managing a reference to aContainerServices
, aRequestKeys
and aWebIServerSession
object.- Since:
- MicroStrategy Web 8.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BLK_MESSAGE_RESULT
static java.lang.String
BLP_MESSAGE_RESULT_MESSAGE_ID
static java.lang.String
BLP_MESSAGE_RESULT_MESSAGE_STATE_ID
static java.lang.String
BLP_MESSAGE_RESULT_MESSAGE_STATUS
static java.lang.String
BLP_MESSAGE_RESULT_PARTIAL_MANIPULATIONS
protected WebPrivilegesExpression
mPrivileges
-
Constructor Summary
Constructors Constructor Description BaseTaskRequestContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
checkPrivileges()
protected void
checkSessionAliveness(WebIServerSession wiss)
Checks whether the supplied WebIServerSession instance is alive or not.Block
createMessageResultBlock(WebResultSetInstance wrsi)
This method creates a Block of type "MessageResult" and populates it with the properties of the suppliedWebResultSetInstance
object.BeanContext
getBeanContext()
Block
getBlock(java.lang.String blockName)
Gets a Block from the Block Library.Block
getBlock(java.lang.String blockName, int blockMode)
Deprecated.Please usegetBlock(String)
insteadjava.lang.String
getBlockAssignmentMode()
Returns the default block assignment mode used for all Block creation.protected BlockContext
getBlockContext(MarkupOutput markupOutput)
Returns the BlockContext object associated with this MarkupOutput.ContainerServices
getContainerServices()
Returns the ContainerServices object associated with this request.java.lang.String
getContentType()
Gets the desired Content Type specified by the caller for this Task invocation.boolean
getIsPolling()
Returns the isPolling flagjava.lang.String
getMimeType()
Gets the desired MIME Type specified by the caller for this Task invocation.RequestKeys
getRequestKeys()
Returns the RequestKeys object associated with this request.Block
getRootBlock(java.lang.String blockName, int blockMode)
Deprecated.Please usegetRootBlock(String, MarkupOutput)
insteadBlock
getRootBlock(java.lang.String blockName, MarkupOutput markupOutput)
If a Task uses a Block to construct output content, then this method gets the "root" Block associated with a MarkupOutput object.protected WebIServerSession
getWebIServerSession()
Returns the held WebIServerSession instance.WebIServerSession
getWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName)
Returns the WebIServerSession object associated with this request.WebIServerSession
getWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName, boolean checkSessionAliveness)
boolean
isParameterEmpty(TaskParameterMetadata tpm)
This method checks if the the Task Parameter (identified by the TaskParameterMetadata) in a request is empty or not.protected WebIServerSession
restoreSessionFromStateOrId(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName)
void
setBlockAssignmentMode(java.lang.String blockMode)
Sets the default block assignment mode used for all Block creation.void
setContainerServices(ContainerServices cntrSvcs)
Sets the ContainerServices object associated with this request.void
setContentType(java.lang.String contentType)
Sets the desired Content Type specified by the caller for this Task invocation.void
setIsPolling(boolean value)
Sets the isPolling flag indicating whether this task is in polling state (waiting for server response while polling with the client) Useful to set the response to client accordinglyvoid
setMimeType(java.lang.String mimeType)
Sets the desired MIME Type specified by the caller for this Task invocation.void
setPrivileges(WebPrivilegesExpression privileges)
Stores the task privileges to check them when we get a sessionvoid
setRequestKeys(RequestKeys requestKeys)
Sets the RequestKeys object associated with this request.void
setRootBlock(Block rootBlock, MarkupOutput markupOutput)
This method sets the root Block of the markupOutput to the supplied Block.void
setWebIServerSession(WebIServerSession wiss)
Sets the WebIServerSession object associated with this request.Block
transformBlock(Block rootBlock, java.lang.String blockScript)
Transform a Block into another form using a Block Transform "script".
-
-
-
Field Detail
-
BLK_MESSAGE_RESULT
public static final java.lang.String BLK_MESSAGE_RESULT
- See Also:
- Constant Field Values
-
BLP_MESSAGE_RESULT_MESSAGE_STATUS
public static final java.lang.String BLP_MESSAGE_RESULT_MESSAGE_STATUS
- See Also:
- Constant Field Values
-
BLP_MESSAGE_RESULT_MESSAGE_ID
public static final java.lang.String BLP_MESSAGE_RESULT_MESSAGE_ID
- See Also:
- Constant Field Values
-
BLP_MESSAGE_RESULT_MESSAGE_STATE_ID
public static final java.lang.String BLP_MESSAGE_RESULT_MESSAGE_STATE_ID
- See Also:
- Constant Field Values
-
BLP_MESSAGE_RESULT_PARTIAL_MANIPULATIONS
public static final java.lang.String BLP_MESSAGE_RESULT_PARTIAL_MANIPULATIONS
- See Also:
- Constant Field Values
-
mPrivileges
protected WebPrivilegesExpression mPrivileges
-
-
Method Detail
-
getContainerServices
public ContainerServices getContainerServices()
Description copied from interface:TaskRequestContext
Returns the ContainerServices object associated with this request.- Specified by:
getContainerServices
in interfaceTaskRequestContext
- Returns:
- The
ContainerServices
object associated with this request.
-
setContainerServices
public void setContainerServices(ContainerServices cntrSvcs)
Description copied from interface:TaskRequestContext
Sets the ContainerServices object associated with this request.- Specified by:
setContainerServices
in interfaceTaskRequestContext
- Parameters:
cntrSvcs
- TheContainerServices
object associated with this request.
-
getRequestKeys
public RequestKeys getRequestKeys()
Description copied from interface:TaskRequestContext
Returns the RequestKeys object associated with this request.- Specified by:
getRequestKeys
in interfaceTaskRequestContext
- Returns:
- The
RequestKeys
object associated with this request.
-
setRequestKeys
public void setRequestKeys(RequestKeys requestKeys)
Description copied from interface:TaskRequestContext
Sets the RequestKeys object associated with this request.- Specified by:
setRequestKeys
in interfaceTaskRequestContext
- Parameters:
requestKeys
- TheRequestKeys
object associated with this request.
-
getWebIServerSession
public WebIServerSession getWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName) throws TaskException
Description copied from interface:TaskRequestContext
Returns the WebIServerSession object associated with this request. Session information may be serialized in many forms. It may be in the form of a "session state" or it may be as just the "session ID". This method can inspect the incoming request for either of these forms (based on how the caller wants to identify the names of these parameters) and if present, constructs a WebIServerSession object. It is held in this context object for later retrieval in this request. Here is the order in which a WebIServerSession object is provided:- If there is already a non-null WebIServerSession object, it is returned.
- If there is a non-empty key which denotes the session state, it is evaluated and a WebIServerSession is returned.
- If there is a non-empty key which denotes the session ID, it is assigned to a newly created WebIServerSession and returned.
- Specified by:
getWebIServerSession
in interfaceTaskRequestContext
- Parameters:
sessionStateParamName
- The name of the incoming request key ("parameter name") that contains a session state.sessionIDParamName
- The name of the incoming request key ("parameter name") that contains a session ID.- Returns:
- The
WebIServerSession
object associated with this request. - Throws:
TaskException
- if either the session state or session ID are invalid (TaskRequestMalformedException) or the session has timed out (TaskInternalException).
-
getWebIServerSession
public WebIServerSession getWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName, boolean checkSessionAliveness) throws TaskException
- Throws:
TaskException
-
restoreSessionFromStateOrId
protected WebIServerSession restoreSessionFromStateOrId(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName) throws TaskRequestMalformedException
- Throws:
TaskRequestMalformedException
-
checkPrivileges
protected void checkPrivileges() throws TaskException
- Throws:
TaskException
-
setWebIServerSession
public void setWebIServerSession(WebIServerSession wiss)
Description copied from interface:TaskRequestContext
Sets the WebIServerSession object associated with this request.- Specified by:
setWebIServerSession
in interfaceTaskRequestContext
- Parameters:
wiss
- TheWebIServerSession
object to associate with this request.
-
getRootBlock
public Block getRootBlock(java.lang.String blockName, MarkupOutput markupOutput) throws TaskException
Description copied from interface:TaskRequestContext
If a Task uses a Block to construct output content, then this method gets the "root" Block associated with a MarkupOutput object. If the root Block has already been constructed, it is returned. Otherwise, the Block is instantiated using the information supplied. In addition to creating the root block, theBlockContext
is constructed and associated with theMarkupOutput
object. This enables the constructed Block tree to automatically serialized according the specified content type. The default block assignment mode is consulted when creating this Block.- Specified by:
getRootBlock
in interfaceTaskRequestContext
- Parameters:
blockName
- The name of the Block to create. If null or an empty string, then an "anonymous" block is created.markupOutput
- TheMarkupOutput
that should contain the root block.- Returns:
- A
Block
which can then by further populated by the Task. - Throws:
TaskException
- If the Block cannot be created (e.g. it does not exist) or if there is no BlockRenderer associated with the specified content type.- Since:
- MicroStrategy Web 9.0.0
- See Also:
TaskRequestContext.getBlockAssignmentMode()
-
setRootBlock
public void setRootBlock(Block rootBlock, MarkupOutput markupOutput)
Description copied from interface:TaskRequestContext
This method sets the root Block of the markupOutput to the supplied Block. TheBlockContext
is constructed and associated with theMarkupOutput
object. This enables the constructed Block tree to automatically serialized according the specified content type.- Specified by:
setRootBlock
in interfaceTaskRequestContext
- Parameters:
rootBlock
- theBlock
object.markupOutput
- TheMarkupOutput
that should contain the root block.- Since:
- MicroStrategy Web 9.0.0
- See Also:
TaskRequestContext.getRootBlock(String, MarkupOutput)
-
createMessageResultBlock
public Block createMessageResultBlock(WebResultSetInstance wrsi) throws TaskException
Description copied from interface:TaskRequestContext
This method creates a Block of type "MessageResult" and populates it with the properties of the suppliedWebResultSetInstance
object.- Specified by:
createMessageResultBlock
in interfaceTaskRequestContext
- Parameters:
wrsi
- The WebResultSetInstance object- Returns:
- A MessageResult block
- Throws:
TaskException
- if we are unable to create the Block or populate its contents.
-
isParameterEmpty
public boolean isParameterEmpty(TaskParameterMetadata tpm)
Description copied from interface:TaskRequestContext
This method checks if the the Task Parameter (identified by the TaskParameterMetadata) in a request is empty or not.- Specified by:
isParameterEmpty
in interfaceTaskRequestContext
- Parameters:
tpm
- theTaskParameterMetadata
object.- Returns:
- A boolean value that tells if the Parameter in the request is empty or not.
- Since:
- MicroStrategy Web 9.0.0
-
getBlockAssignmentMode
public java.lang.String getBlockAssignmentMode()
Description copied from interface:TaskRequestContext
Returns the default block assignment mode used for all Block creation.- Specified by:
getBlockAssignmentMode
in interfaceTaskRequestContext
- Returns:
- The default block assignment mode used for all Block creation.
- Since:
- MicroStrategy Web 9.0.0
-
setBlockAssignmentMode
public void setBlockAssignmentMode(java.lang.String blockMode)
Description copied from interface:TaskRequestContext
Sets the default block assignment mode used for all Block creation.- Specified by:
setBlockAssignmentMode
in interfaceTaskRequestContext
- Parameters:
blockMode
- The block assignment mode to use for all Block creation.- Since:
- MicroStrategy Web 9.0.0
-
getBlock
public Block getBlock(java.lang.String blockName) throws TaskException
Description copied from interface:TaskRequestContext
Gets a Block from the Block Library. This is merely a helper function that throws an exception if a block is not present in the library. The default block assignment mode is consulted when creating this Block.- Specified by:
getBlock
in interfaceTaskRequestContext
- Parameters:
blockName
- The name of the Block. If null or an empty string, then an "anonymous" block is created.- Returns:
- A
Block
to be used by this task. - Throws:
TaskException
- If the Block cannot be created.- Since:
- MicroStrategy Web 9.0.0
- See Also:
TaskRequestContext.getBlockAssignmentMode()
-
getContentType
public java.lang.String getContentType()
Description copied from interface:TaskRequestContext
Gets the desired Content Type specified by the caller for this Task invocation.- Specified by:
getContentType
in interfaceTaskRequestContext
- Returns:
- The desired content type.
- Since:
- MicroStrategy Web 9.0.0
-
setContentType
public void setContentType(java.lang.String contentType)
Description copied from interface:TaskRequestContext
Sets the desired Content Type specified by the caller for this Task invocation. The value should correspond to an entry in the ContentTypes properties file (e.g., "JSON" or "XML"). This method also overrides the MIME type if the supplied content type corresponds to an entry in the ContentTypes property file. The ConentTypes property file defines a MIME type for each entry.- Specified by:
setContentType
in interfaceTaskRequestContext
- Parameters:
contentType
- The desired content type.- Since:
- MicroStrategy Web 9.0.0
-
getMimeType
public java.lang.String getMimeType()
Description copied from interface:TaskRequestContext
Gets the desired MIME Type specified by the caller for this Task invocation.- Specified by:
getMimeType
in interfaceTaskRequestContext
- Returns:
- The desired MIME type.
- See Also:
TaskRequestContext.setContentType(String)
-
setMimeType
public void setMimeType(java.lang.String mimeType)
Description copied from interface:TaskRequestContext
Sets the desired MIME Type specified by the caller for this Task invocation. The value should be a standard MIME type (e.g., "application/json" or "text/xml").- Specified by:
setMimeType
in interfaceTaskRequestContext
- Parameters:
mimeType
- The desired MIME type.
-
getRootBlock
@Deprecated public Block getRootBlock(java.lang.String blockName, int blockMode) throws TaskConfigurationException
Deprecated.Please usegetRootBlock(String, MarkupOutput)
insteadGets the Root Block associated with this Task. If the root Block has already been requested, it is returned. Otherwise, the Block is instantiated using the information supplied.- Parameters:
blockName
- The name of the Block.blockMode
- The mode used to instantiate the Block.- Returns:
- A
Block
to be used by this task. - Throws:
TaskConfigurationException
- If the Block cannot be created.
-
getBlock
@Deprecated public Block getBlock(java.lang.String blockName, int blockMode) throws TaskConfigurationException
Deprecated.Please usegetBlock(String)
insteadGets a Block from the Block Library.- Parameters:
blockName
- The name of the Block.blockMode
- The mode used to instantiate the Block.- Returns:
- A
Block
to be used by this task. - Throws:
TaskConfigurationException
- If the Block cannot be created.
-
transformBlock
public Block transformBlock(Block rootBlock, java.lang.String blockScript) throws BlockTransformScriptInvalid, BlockTransformExecutionFailure
Description copied from interface:TaskRequestContext
Transform a Block into another form using a Block Transform "script".- Specified by:
transformBlock
in interfaceTaskRequestContext
- Parameters:
rootBlock
- The root Block to perform the transformation on.blockScript
- The script to perform on the root Block.- Returns:
- The root Block after the transformation.
- Throws:
BlockTransformScriptInvalid
- If the supplied Block script is syntactically invalid.BlockTransformExecutionFailure
- If the Block script fails during execution.
-
getWebIServerSession
protected WebIServerSession getWebIServerSession()
Returns the held WebIServerSession instance.- Returns:
- The WebIServerSession instance.
- Since:
- MicroStrategy Web 9.0.1
-
getBlockContext
protected BlockContext getBlockContext(MarkupOutput markupOutput)
Returns the BlockContext object associated with this MarkupOutput. If none exists, then one is created. It is automatically populated with the following fields:- Content Type
- Container Services
- Request Keys
- Parameters:
markupOutput
- TheMarkupOutput
object that hosts theBlockContext
.- Returns:
- The
BlockContext
object associated with this MarkupOutput. - Since:
- MicroStrategy Web 9.0.0
-
checkSessionAliveness
protected void checkSessionAliveness(WebIServerSession wiss) throws TaskException
Checks whether the supplied WebIServerSession instance is alive or not.- Parameters:
wiss
- TheWebIServerSession
instance to check for.- Throws:
TaskException
- If the WebIServerSession instance is not alive (that is, there is no longer a "live" session on the Intelligence Server open).- Since:
- MicroStrategy Web 9.0.0
-
getBeanContext
public BeanContext getBeanContext()
-
setPrivileges
public void setPrivileges(WebPrivilegesExpression privileges)
Stores the task privileges to check them when we get a session- Specified by:
setPrivileges
in interfaceTaskRequestContext
- Parameters:
privileges
- The privilege expression
-
setIsPolling
public void setIsPolling(boolean value)
Description copied from interface:TaskRequestContext
Sets the isPolling flag indicating whether this task is in polling state (waiting for server response while polling with the client) Useful to set the response to client accordingly- Specified by:
setIsPolling
in interfaceTaskRequestContext
-
getIsPolling
public boolean getIsPolling()
Description copied from interface:TaskRequestContext
Returns the isPolling flag- Specified by:
getIsPolling
in interfaceTaskRequestContext
- Returns:
-
-