Package com.microstrategy.web.app.tasks
Class WebComponentTask
- java.lang.Object
 - 
- com.microstrategy.web.tasks.AbstractBaseTask
 - 
- com.microstrategy.web.app.tasks.AbstractAppTask
 - 
- com.microstrategy.web.app.tasks.WebComponentTask
 
 
 
 
- 
- All Implemented Interfaces:
 Task
- Direct Known Subclasses:
 BeanTask,BlockLoaderTask,GetDIProjectSettingsTask,GetShortcutsList,GetVersionInfo
public class WebComponentTask extends AbstractAppTask
This class implements theTaskinterface using aWebComponentto handle data collection. The definition of the task is provided through a single XML file.- Since:
 - MicroStrategy Web 9.0.0
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFP_NAME_CONTENT_TYPEThe name of the formal parameter that defines the desired content type.protected java.lang.StringinitializationErrorMessageIf an error occurred at initialization time, then this field contains the message.- 
Fields inherited from class com.microstrategy.web.tasks.AbstractBaseTask
compressOutput, CONTENT_TYPE_BINARY, CONTENT_TYPE_HTML, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_ALL, CONTENT_TYPE_JSON_D, CONTENT_TYPE_JSON_P, CONTENT_TYPE_XML, CONTENT_TYPE_XML_ANF, DEFAULT_MAX_WAIT, DEFAULT_POLLING_FREQ, execFlagsParam, INDEFINITE_MAX_WAIT, maxWaitParam, metadata, mPrivileges, msgIDParam, objectIDParam, OTHER_CONTENT_KEY_LAYOUTS, PARAM_NAME_EXEC_FLAGS, PARAM_NAME_MAX_WAIT, PARAM_NAME_MESSAGE_ID, PARAM_NAME_OBJECT_ID, PARAM_NAME_POLLING_FREQ, PARAM_NAME_RESULT_FLAGS, PARAM_NAME_SESSION_ID, PARAM_NAME_SESSION_STATE, PARAM_NAME_STATE_ID, pollingFreqParam, PREFERENCE_DEFAULT_MAX_WAIT_IN_TASK, resultFlagsParam, sessionIDParam, sessionStateParam, stateIDParam 
 - 
 
- 
Constructor Summary
Constructors Constructor Description WebComponentTask()No args constructor for a WebComponentTask. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TransformInstanceaddTransform(BeanTaskRequestContext btrContext)Adds the specified Transform to the WebBean.protected voidcollectData(BeanTaskRequestContext btrContext)This method calls the 'collectData' method on the WebBean instance.protected WebComponentcreateUntypedWebComponent(BeanTaskRequestContext btrContext)This method creates an instance of an "untyped" Web Component.protected WebComponentcreateWebBean(BeanTaskRequestContext btrContext)This method creates the WebComponent or WebBean from the specified bean type.voiddestroy()Destroy any data structures created by the 'init' method.protected booleangeneratesContent(BeanTaskRequestContext btrContext)This method determines whether the Task is going to generate any content.protected BeanInfogetBeanInfo()Returns the BeanInfo object associated with this BeanTask.protected java.lang.StringgetStyleName(BeanTaskRequestContext btrContext)protected voidhandleEvent(BeanTaskRequestContext btrContext)This method instructs the WebBean to handle the event.voidinit(ContainerServices containerSvcs)Handles the initialization of the task.protected booleanisSuccessfullyInitialized()Returns whether the BeanTask was successfully initialized or not.TaskRequestContextnewRequestContext()Returns a BeanTaskRequestContext object to use for the duration of this request.protected voidoverrideActualParameters(BeanTaskRequestContext btrContext, TransformInstance instance)Overrides any actual parameters specified in the Bean Task XML.protected voidprepareArgumentRequestKeys(RequestKeys requestKeys)This method prepares the RequestKeys by adding the necessary "event argument" parameters.protected voidprepareArgumentRequestKeys(RequestKeys requestKeys, EventInfo[] events)protected voidprepareBean(BeanTaskRequestContext btrContext)This method prepares the WebBean for execution.protected voidprepareEventOrderRequestKeys(RequestKeys requestKeys)The method sets the request keys necessary for multiple events.protected voidprepareEventOrderRequestKeys(RequestKeys requestKeys, EventInfo[] events)protected voidprepareEventRequestKeys(RequestKeys requestKeys)This method prepares the RequestKeys by adding the necessary keys for events.protected voidprepareEventRequestKeys(RequestKeys requestKeys, EventInfo[] events)protected voidprepareParameterRequestKeys(RequestKeys requestKeys)This method prepares the RequestKeys by adding any default values for parameters.protected voidprepareRequestKeys(BeanTaskRequestContext btrContext)Prepares the RequestKeys for handling the event.voidprocessRequest(TaskRequestContext context, TaskOutput taskOutput)Process the incoming request.protected voidregisterParameterMetadata(TaskParameterMetadata parameterMetadata)Registers a specific Task parameter metadata.protected voidregisterTaskMetadata(TaskMetadata sourceMetadata)This method is used to register the task metadata.protected booleanrequiresIServerSession()Returns whether this Task requires an Intelligence Server session.protected voidrestoreBeanState(BeanTaskRequestContext btrContext)Restores the state of a previously serialized WebBean.protected voidserializeResult(BeanTaskRequestContext btrContext, TaskOutput taskOutput)This method attempts to serialize the results to the supplied TaskOutput object.protected voidsetBeanContext(BeanTaskRequestContext btrContext)Set the BeanContext associated with the Bean.protected voidsetBeanInfo(BeanInfo beanInfo)Sets the BeanInfo object associated with this BeanTask.protected voidsetBeanName(BeanTaskRequestContext btrContext)Sets the Bean's name.protected voidsetBeanProperties(BeanTaskRequestContext btrContext)Set any properties on the Bean.protected voidsetBeanSession(BeanTaskRequestContext btrContext)Set the WebIServerSession object to use with the WebBean.protected voidsetSuccessfullyInitialized(boolean successfullyInitialized)Sets whether the BeanTask was successfully initialized or not.voidsetTaskID(java.lang.String taskID)Sets the Task ID.protected voidtransformBean(BeanTaskRequestContext btrContext, TaskOutput taskOutput)This method wraps a call toTransformable.transform().- 
Methods inherited from class com.microstrategy.web.app.tasks.AbstractAppTask
getDescriptor 
- 
Methods inherited from class com.microstrategy.web.tasks.AbstractBaseTask
addExecFlagsParam, addJuilLayouts, addMaxWaitParam, addMaxWaitParam, addMessageIDParam, addObjectIDParam, addParameterMetadata, addParameterMetadata, addParameterMetadata, addPollingFrequencyParam, addPollingFrequencyParam, addResultFlagsParam, addSessionIDParam, addSessionStateParam, addStateIDParam, checkForRequiredParameters, getCompressOutput, getID, getMetadata, getPrivileges, getSysDefaultPreferenceValue, processRequest, retrieveUploadedFile, setCompressOutput, setDescription, setID, setMetadata, setPrivileges, validateContentType 
 - 
 
 - 
 
- 
- 
Field Detail
- 
FP_NAME_CONTENT_TYPE
public static final java.lang.String FP_NAME_CONTENT_TYPE
The name of the formal parameter that defines the desired content type. If found, the Task infrastructure will assign the value of the Task Content Type parameter to it. This allows transforms to be written that generate Block trees and the Task caller can decide how they are rendered.- See Also:
 - Constant Field Values
 
 
- 
initializationErrorMessage
protected java.lang.String initializationErrorMessage
If an error occurred at initialization time, then this field contains the message. 
 - 
 
- 
Method Detail
- 
init
public void init(ContainerServices containerSvcs)
Handles the initialization of the task. This involves parsing the XML file and retrieving all of the contents. This method callsregisterTaskMetadata(TaskMetadata).- Specified by:
 initin interfaceTask- Overrides:
 initin classAbstractBaseTask- Parameters:
 containerSvcs- TheContainerServicesobject that can be used to find more initialization parameters.
 
- 
newRequestContext
public TaskRequestContext newRequestContext()
Returns a BeanTaskRequestContext object to use for the duration of this request.- Specified by:
 newRequestContextin interfaceTask- Overrides:
 newRequestContextin classAbstractAppTask- Returns:
 - The 
BeanTaskRequestContextobject to use for the duration of this request. 
 
- 
processRequest
public void processRequest(TaskRequestContext context, TaskOutput taskOutput) throws TaskException
Process the incoming request. This method proceeds through the following sequence:- Check for all required parameters. (calls 
AbstractBaseTask.checkForRequiredParameters(RequestKeys)) - Prepare the 
RequestKeysfor use. (callsprepareRequestKeys(BeanTaskRequestContext)) - Prepare the 
WebBeanfor use. (callsprepareBean(BeanTaskRequestContext)) - Handle the event. (calls 
handleEvent(BeanTaskRequestContext)) - Collect data for the request. (calls 
collectData(BeanTaskRequestContext)) - Serialize the results into the supplied 
TaskOutput. (callsserializeResult(BeanTaskRequestContext, TaskOutput)) 
- Specified by:
 processRequestin interfaceTask- Overrides:
 processRequestin classAbstractBaseTask- Parameters:
 context- TheTaskRequestContextobject that contains information specific to this request.taskOutput- TheTaskOutputobject to serialize the results into.- Throws:
 TaskException- If anything fails in the process of servicing the request.TaskConfigurationException- If the task is not properly configured.- See Also:
 Task.processRequest(TaskRequestContext, TaskOutput)
 - Check for all required parameters. (calls 
 
- 
destroy
public void destroy()
Destroy any data structures created by the 'init' method.- Specified by:
 destroyin interfaceTask- Overrides:
 destroyin classAbstractBaseTask
 
- 
setTaskID
public void setTaskID(java.lang.String taskID)
Sets the Task ID.- Parameters:
 taskID- The Task ID.
 
- 
registerTaskMetadata
protected void registerTaskMetadata(TaskMetadata sourceMetadata)
This method is used to register the task metadata. It is a method invoked by theinit(ContainerServices)method. This method in turn callsregisterParameterMetadata(TaskParameterMetadata)for each task parameter.- Parameters:
 sourceMetadata- TheTaskMetadataobject being registered.
 
- 
registerParameterMetadata
protected void registerParameterMetadata(TaskParameterMetadata parameterMetadata)
Registers a specific Task parameter metadata. This method is called byregisterTaskMetadata(TaskMetadata). It is helpful to override in a Task so that a specific TaskParameterMetadata may be saved for later use.- Parameters:
 parameterMetadata- The TaskParameterMetadata object being saved.
 
- 
prepareRequestKeys
protected void prepareRequestKeys(BeanTaskRequestContext btrContext)
Prepares the RequestKeys for handling the event. This method is called insideprocessRequest(TaskRequestContext, TaskOutput). This method, in turn, calls:- Parameters:
 btrContext- The BeanTaskRequestContext object.
 
- 
prepareParameterRequestKeys
protected void prepareParameterRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding any default values for parameters.- Parameters:
 requestKeys- The RequestKeys instance to add the default values to.
 
- 
prepareEventRequestKeys
protected void prepareEventRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding the necessary keys for events. If there is only one event, then theGenericWebEvent.URL_EVENT_NAMEkey is added. Otherwise, theprepareEventOrderRequestKeys(RequestKeys)method is called. Next, it calls theprepareArgumentRequestKeys(RequestKeys)method to add any keys defined for Event Arguments in the Bean Task XML.- Parameters:
 requestKeys- The RequestKeys object to add keys to.
 
- 
prepareEventRequestKeys
protected void prepareEventRequestKeys(RequestKeys requestKeys, EventInfo[] events)
 
- 
prepareEventOrderRequestKeys
protected void prepareEventOrderRequestKeys(RequestKeys requestKeys)
The method sets the request keys necessary for multiple events. This method is called in theprepareEventRequestKeys(RequestKeys)method.- Parameters:
 requestKeys- The RequestKeys instance to add keys to.
 
- 
prepareEventOrderRequestKeys
protected void prepareEventOrderRequestKeys(RequestKeys requestKeys, EventInfo[] events)
 
- 
prepareArgumentRequestKeys
protected void prepareArgumentRequestKeys(RequestKeys requestKeys)
This method prepares the RequestKeys by adding the necessary "event argument" parameters. This method is called in theprepareEventRequestKeys(RequestKeys)method.- Parameters:
 requestKeys- The RequestKeys object to add keys to.
 
- 
prepareArgumentRequestKeys
protected void prepareArgumentRequestKeys(RequestKeys requestKeys, EventInfo[] events)
 
- 
prepareBean
protected void prepareBean(BeanTaskRequestContext btrContext) throws TaskException
This method prepares the WebBean for execution. It is called by theprocessRequest(TaskRequestContext, TaskOutput)method. It performs the following actions:- Creates a new WebBean instance and adds it to the
      context. (calls 
createWebBean(BeanTaskRequestContext)) - Sets any bean properties. (calls 
setBeanProperties(BeanTaskRequestContext)) - Restores any bean state. (calls 
restoreBeanState(BeanTaskRequestContext)) 
- Parameters:
 btrContext- The BeanTaskRequestContext to use.- Throws:
 TaskException- If anything fails along the way.
 - Creates a new WebBean instance and adds it to the
      context. (calls 
 
- 
handleEvent
protected void handleEvent(BeanTaskRequestContext btrContext) throws TaskException
This method instructs the WebBean to handle the event. It is called fromprocessRequest(TaskRequestContext, TaskOutput).- Parameters:
 btrContext- The BeanTaskRequestContext that contains the WebBean instance.- Throws:
 TaskException- If something fails in the process of handling the event.TaskRequestMalformedException- If there was an exception raised while handling the event.
 
- 
collectData
protected void collectData(BeanTaskRequestContext btrContext) throws TaskException
This method calls the 'collectData' method on the WebBean instance. This method is called byprocessRequest(TaskRequestContext, TaskOutput).- Parameters:
 btrContext- The BeanTaskRequestContext object.- Throws:
 TaskException- If there is a failure while trying to collect data for the Web Bean.
 
- 
generatesContent
protected boolean generatesContent(BeanTaskRequestContext btrContext) throws TaskException
This method determines whether the Task is going to generate any content. Some tasks are "write only" in nature: they send data to the backend, but return nothing (other than a status).- Parameters:
 btrContext- The BeanTaskRequestContext object.- Returns:
 - true if we can determine that content could be generated by this Task; false, otherwise.
 - Throws:
 TaskException- if the style parameter is not correctly specified.
 
- 
serializeResult
protected void serializeResult(BeanTaskRequestContext btrContext, TaskOutput taskOutput) throws TaskException
This method attempts to serialize the results to the supplied TaskOutput object. This method is called byprocessRequest(TaskRequestContext, TaskOutput)and in turn does the following:- Add the Transform. If there is no transform
      specified, an empty MarkupOutput is returned. (calls 
addTransform(BeanTaskRequestContext)) - Override any actual parameters specified in the
      Bean Task XML. (calls 
overrideActualParameters(BeanTaskRequestContext, TransformInstance)) - Transforms the WebBean using the Transform. (calls
      
transformBean(BeanTaskRequestContext, TaskOutput)) 
- Parameters:
 btrContext- The BeanTaskRequestContext object.taskOutput- The TaskOutput object to populate.- Throws:
 TaskException- If something fails along the way.
 - Add the Transform. If there is no transform
      specified, an empty MarkupOutput is returned. (calls 
 
- 
addTransform
protected TransformInstance addTransform(BeanTaskRequestContext btrContext) throws TaskConfigurationException, TaskRequestMalformedException
Adds the specified Transform to the WebBean. This method is called byserializeResult(BeanTaskRequestContext, TaskOutput)and performs the following actions:- Retrieves the name of the style to use.
 - Adds the Transform by looking up the style.
 
- Parameters:
 btrContext- The BeanTaskRequestContext to use.- Returns:
 - The 
TransformInstancethat was created, if any. - Throws:
 TaskConfigurationException- If the static style name does not exist in the StyleCatalog.TaskRequestMalformedException- If the dynamic style name does not exist in the Style Catalog.
 
- 
getStyleName
protected java.lang.String getStyleName(BeanTaskRequestContext btrContext) throws TaskRequestMalformedException
- Throws:
 TaskRequestMalformedException
 
- 
overrideActualParameters
protected void overrideActualParameters(BeanTaskRequestContext btrContext, TransformInstance instance) throws TaskRequestMalformedException
Overrides any actual parameters specified in the Bean Task XML. This method is called by theserializeResult(BeanTaskRequestContext, TaskOutput)method.- Parameters:
 btrContext- The BeanTaskRequestContext to use.instance- The TransformInstance to operate on.- Throws:
 TaskRequestMalformedException
 
- 
transformBean
protected void transformBean(BeanTaskRequestContext btrContext, TaskOutput taskOutput) throws TaskConfigurationException
This method wraps a call toTransformable.transform(). It is called by theserializeResult(BeanTaskRequestContext, TaskOutput)method and simply calls the 'transform' method.- Parameters:
 btrContext- The BeanTaskRequestContext object.taskOutput- The TaskOutput instance to generate into.- Throws:
 TaskConfigurationException- If the Transform does not exist.
 
- 
createWebBean
protected WebComponent createWebBean(BeanTaskRequestContext btrContext) throws TaskConfigurationException
This method creates the WebComponent or WebBean from the specified bean type. If no type is specified, then an "untyped" WebComponent is created using thecreateUntypedWebComponent(BeanTaskRequestContext)method.- Parameters:
 btrContext- The BeanTaskRequestContext object.- Returns:
 - The 
WebComponentinstance created of the specified type. - Throws:
 TaskConfigurationException- If we are unable to create a WebBean or WebComponent of the specified type- See Also:
 createUntypedWebComponent(BeanTaskRequestContext)
 
- 
createUntypedWebComponent
protected WebComponent createUntypedWebComponent(BeanTaskRequestContext btrContext) throws TaskConfigurationException
This method creates an instance of an "untyped" Web Component. This component implements the Transformable interface and can be used with any Transform. It provides no specialized data access methods.- Parameters:
 btrContext- The BeanTaskRequestContext object.- Returns:
 - An instance of a 
WebComponentto use when no bean type has been specified. - Throws:
 TaskConfigurationException- If we are unable to create an instance.- See Also:
 createWebBean(BeanTaskRequestContext)
 
- 
setBeanProperties
protected void setBeanProperties(BeanTaskRequestContext btrContext) throws TaskException
Set any properties on the Bean. This method is called by theprepareBean(BeanTaskRequestContext)method and performs the following actions:- Sets the Bean Name. (calls 
setBeanName(BeanTaskRequestContext)) - Sets the Bean Session. (calls 
setBeanSession(BeanTaskRequestContext)) - Sets the Bean Context. (calls 
setBeanContext(BeanTaskRequestContext)) 
- Parameters:
 btrContext- TheBeanTaskRequestContextobject to use.- Throws:
 TaskException- If any of the subordinate methods raise an exception while setting a specific property of the Bean.
 - Sets the Bean Name. (calls 
 
- 
restoreBeanState
protected void restoreBeanState(BeanTaskRequestContext btrContext)
Restores the state of a previously serialized WebBean. This method is called byprepareBean(BeanTaskRequestContext)and calls theRequestPersistable.restoreStateFromRequest(RequestKeys)method on the WebBean.- Parameters:
 btrContext- The BeanTaskRequestContext object to use.
 
- 
setBeanName
protected void setBeanName(BeanTaskRequestContext btrContext)
Sets the Bean's name. This method is called bysetBeanProperties(BeanTaskRequestContext).- Parameters:
 btrContext- The BeanTaskRequestContext object to use.
 
- 
setBeanSession
protected void setBeanSession(BeanTaskRequestContext btrContext) throws TaskException
Set the WebIServerSession object to use with the WebBean. This method is called by thesetBeanProperties(BeanTaskRequestContext)method.- Parameters:
 btrContext- The BeanTaskRequestContext object to use.- Throws:
 TaskException- If there is not enough information to create a WebIServerSession instance.
 
- 
requiresIServerSession
protected boolean requiresIServerSession()
Returns whether this Task requires an Intelligence Server session.- Returns:
 - True if this Task requires an Intelligence Server session; otherwise, false. The base implementation simply checks whether the session state parameter is defined for this Task.
 
 
- 
setBeanContext
protected void setBeanContext(BeanTaskRequestContext btrContext)
Set the BeanContext associated with the Bean. This method is called by thesetBeanProperties(BeanTaskRequestContext)method.- Parameters:
 btrContext- The BeanTaskRequestContext object to use.
 
- 
getBeanInfo
protected BeanInfo getBeanInfo()
Returns the BeanInfo object associated with this BeanTask.- Returns:
 - The 
BeanInfoobject associated with this BeanTask. 
 
- 
setBeanInfo
protected void setBeanInfo(BeanInfo beanInfo)
Sets the BeanInfo object associated with this BeanTask.- Parameters:
 beanInfo- TheBeanInfoobject associated with this BeanTask.
 
- 
isSuccessfullyInitialized
protected boolean isSuccessfullyInitialized()
Returns whether the BeanTask was successfully initialized or not.- Returns:
 - Whether the BeanTask was successfully initialized or not.
 
 
- 
setSuccessfullyInitialized
protected void setSuccessfullyInitialized(boolean successfullyInitialized)
Sets whether the BeanTask was successfully initialized or not.- Parameters:
 successfullyInitialized- Whether the BeanTask was successfully initialized or not.
 
 - 
 
 -