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 theTaskRequestContextinterface by managing a reference to aContainerServices, aRequestKeysand aWebIServerSessionobject.- Since:
- MicroStrategy Web 8.1.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringBLK_MESSAGE_RESULTstatic java.lang.StringBLP_MESSAGE_RESULT_MESSAGE_IDstatic java.lang.StringBLP_MESSAGE_RESULT_MESSAGE_STATE_IDstatic java.lang.StringBLP_MESSAGE_RESULT_MESSAGE_STATUSstatic java.lang.StringBLP_MESSAGE_RESULT_PARTIAL_MANIPULATIONSprotected WebPrivilegesExpressionmPrivileges
-
Constructor Summary
Constructors Constructor Description BaseTaskRequestContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckPrivileges()protected voidcheckSessionAliveness(WebIServerSession wiss)Checks whether the supplied WebIServerSession instance is alive or not.BlockcreateMessageResultBlock(WebResultSetInstance wrsi)This method creates a Block of type "MessageResult" and populates it with the properties of the suppliedWebResultSetInstanceobject.BeanContextgetBeanContext()BlockgetBlock(java.lang.String blockName)Gets a Block from the Block Library.BlockgetBlock(java.lang.String blockName, int blockMode)Deprecated.Please usegetBlock(String)insteadjava.lang.StringgetBlockAssignmentMode()Returns the default block assignment mode used for all Block creation.protected BlockContextgetBlockContext(MarkupOutput markupOutput)Returns the BlockContext object associated with this MarkupOutput.ContainerServicesgetContainerServices()Returns the ContainerServices object associated with this request.java.lang.StringgetContentType()Gets the desired Content Type specified by the caller for this Task invocation.booleangetIsPolling()Returns the isPolling flagjava.lang.StringgetMimeType()Gets the desired MIME Type specified by the caller for this Task invocation.RequestKeysgetRequestKeys()Returns the RequestKeys object associated with this request.BlockgetRootBlock(java.lang.String blockName, int blockMode)Deprecated.Please usegetRootBlock(String, MarkupOutput)insteadBlockgetRootBlock(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 WebIServerSessiongetWebIServerSession()Returns the held WebIServerSession instance.WebIServerSessiongetWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName)Returns the WebIServerSession object associated with this request.WebIServerSessiongetWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName, boolean checkSessionAliveness)booleanisParameterEmpty(TaskParameterMetadata tpm)This method checks if the the Task Parameter (identified by the TaskParameterMetadata) in a request is empty or not.protected WebIServerSessionrestoreSessionFromStateOrId(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName)voidsetBlockAssignmentMode(java.lang.String blockMode)Sets the default block assignment mode used for all Block creation.voidsetContainerServices(ContainerServices cntrSvcs)Sets the ContainerServices object associated with this request.voidsetContentType(java.lang.String contentType)Sets the desired Content Type specified by the caller for this Task invocation.voidsetIsPolling(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 accordinglyvoidsetMimeType(java.lang.String mimeType)Sets the desired MIME Type specified by the caller for this Task invocation.voidsetPrivileges(WebPrivilegesExpression privileges)Stores the task privileges to check them when we get a sessionvoidsetRequestKeys(RequestKeys requestKeys)Sets the RequestKeys object associated with this request.voidsetRootBlock(Block rootBlock, MarkupOutput markupOutput)This method sets the root Block of the markupOutput to the supplied Block.voidsetWebIServerSession(WebIServerSession wiss)Sets the WebIServerSession object associated with this request.BlocktransformBlock(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:TaskRequestContextReturns the ContainerServices object associated with this request.- Specified by:
getContainerServicesin interfaceTaskRequestContext- Returns:
- The
ContainerServicesobject associated with this request.
-
setContainerServices
public void setContainerServices(ContainerServices cntrSvcs)
Description copied from interface:TaskRequestContextSets the ContainerServices object associated with this request.- Specified by:
setContainerServicesin interfaceTaskRequestContext- Parameters:
cntrSvcs- TheContainerServicesobject associated with this request.
-
getRequestKeys
public RequestKeys getRequestKeys()
Description copied from interface:TaskRequestContextReturns the RequestKeys object associated with this request.- Specified by:
getRequestKeysin interfaceTaskRequestContext- Returns:
- The
RequestKeysobject associated with this request.
-
setRequestKeys
public void setRequestKeys(RequestKeys requestKeys)
Description copied from interface:TaskRequestContextSets the RequestKeys object associated with this request.- Specified by:
setRequestKeysin interfaceTaskRequestContext- Parameters:
requestKeys- TheRequestKeysobject associated with this request.
-
getWebIServerSession
public WebIServerSession getWebIServerSession(java.lang.String sessionStateParamName, java.lang.String sessionIDParamName) throws TaskException
Description copied from interface:TaskRequestContextReturns 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:
getWebIServerSessionin 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
WebIServerSessionobject 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:TaskRequestContextSets the WebIServerSession object associated with this request.- Specified by:
setWebIServerSessionin interfaceTaskRequestContext- Parameters:
wiss- TheWebIServerSessionobject to associate with this request.
-
getRootBlock
public Block getRootBlock(java.lang.String blockName, MarkupOutput markupOutput) throws TaskException
Description copied from interface:TaskRequestContextIf 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, theBlockContextis constructed and associated with theMarkupOutputobject. 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:
getRootBlockin interfaceTaskRequestContext- Parameters:
blockName- The name of the Block to create. If null or an empty string, then an "anonymous" block is created.markupOutput- TheMarkupOutputthat should contain the root block.- Returns:
- A
Blockwhich 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:TaskRequestContextThis method sets the root Block of the markupOutput to the supplied Block. TheBlockContextis constructed and associated with theMarkupOutputobject. This enables the constructed Block tree to automatically serialized according the specified content type.- Specified by:
setRootBlockin interfaceTaskRequestContext- Parameters:
rootBlock- theBlockobject.markupOutput- TheMarkupOutputthat 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:TaskRequestContextThis method creates a Block of type "MessageResult" and populates it with the properties of the suppliedWebResultSetInstanceobject.- Specified by:
createMessageResultBlockin 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:TaskRequestContextThis method checks if the the Task Parameter (identified by the TaskParameterMetadata) in a request is empty or not.- Specified by:
isParameterEmptyin interfaceTaskRequestContext- Parameters:
tpm- theTaskParameterMetadataobject.- 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:TaskRequestContextReturns the default block assignment mode used for all Block creation.- Specified by:
getBlockAssignmentModein 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:TaskRequestContextSets the default block assignment mode used for all Block creation.- Specified by:
setBlockAssignmentModein 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:TaskRequestContextGets 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:
getBlockin interfaceTaskRequestContext- Parameters:
blockName- The name of the Block. If null or an empty string, then an "anonymous" block is created.- Returns:
- A
Blockto 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:TaskRequestContextGets the desired Content Type specified by the caller for this Task invocation.- Specified by:
getContentTypein interfaceTaskRequestContext- Returns:
- The desired content type.
- Since:
- MicroStrategy Web 9.0.0
-
setContentType
public void setContentType(java.lang.String contentType)
Description copied from interface:TaskRequestContextSets 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:
setContentTypein interfaceTaskRequestContext- Parameters:
contentType- The desired content type.- Since:
- MicroStrategy Web 9.0.0
-
getMimeType
public java.lang.String getMimeType()
Description copied from interface:TaskRequestContextGets the desired MIME Type specified by the caller for this Task invocation.- Specified by:
getMimeTypein interfaceTaskRequestContext- Returns:
- The desired MIME type.
- See Also:
TaskRequestContext.setContentType(String)
-
setMimeType
public void setMimeType(java.lang.String mimeType)
Description copied from interface:TaskRequestContextSets 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:
setMimeTypein interfaceTaskRequestContext- Parameters:
mimeType- The desired MIME type.
-
getRootBlock
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
Blockto be used by this task. - Throws:
TaskConfigurationException- If the Block cannot be created.
-
getBlock
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
Blockto 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:TaskRequestContextTransform a Block into another form using a Block Transform "script".- Specified by:
transformBlockin 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- TheMarkupOutputobject that hosts theBlockContext.- Returns:
- The
BlockContextobject 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- TheWebIServerSessioninstance 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:
setPrivilegesin interfaceTaskRequestContext- Parameters:
privileges- The privilege expression
-
setIsPolling
public void setIsPolling(boolean value)
Description copied from interface:TaskRequestContextSets 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:
setIsPollingin interfaceTaskRequestContext
-
getIsPolling
public boolean getIsPolling()
Description copied from interface:TaskRequestContextReturns the isPolling flag- Specified by:
getIsPollingin interfaceTaskRequestContext- Returns:
-
-