public class ToolProvider
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ID_SCOPE_CONTEXT
Prefix the ID with the consumer key and context ID.
|
static int |
ID_SCOPE_GLOBAL
Prefix an ID with the consumer key.
|
static int |
ID_SCOPE_ID_ONLY
Use ID value only.
|
static int |
ID_SCOPE_RESOURCE
Prefix the ID with the consumer key and resource link ID.
|
static char |
ID_SCOPE_SEPARATOR
Character used to separate each element of an ID.
|
static java.lang.String |
LTI_VERSION
LTI version for messages.
|
Constructor and Description |
---|
ToolProvider(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Callback callbackHandler,
DataConnector dataConnector)
Constructs a ToolProvider object for handling an LTI launch request.
|
ToolProvider(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.Map<java.lang.String,Callback> callbackHandlers,
DataConnector dataConnector)
Constructs a ToolProvider object for handling an LTI launch request.
|
Modifier and Type | Method and Description |
---|---|
boolean |
execute()
Process a launch request
|
ToolConsumer |
getConsumer()
Returns the tool consumer object relating to the source of the launch request.
|
java.util.List<ToolConsumer> |
getConsumers()
Get a list of tool consumers defined in this tool provider.
|
java.lang.String |
getDefaultEmail()
Returns the default email domain to be used when auto-generating email addresses.
|
int |
getIdScope()
Returns the default scope to use when generating user IDs.
|
java.lang.String |
getMessage()
Returns a default message returned from an invalid launch.
|
java.lang.String |
getReason()
Returns an explanation for the error identified in the launch.
|
java.lang.String |
getRedirectUrl()
Returns the URL to which the user should be redirected on successful completion
of processing the request.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Returns the HTTP request object relating to the current launch request.
|
ResourceLink |
getResourceLink()
Returns the ResourceLink object relating to the source of the launch request.
|
java.lang.String |
getReturnUrl()
Returns the URL provided on launch to use when returning a user to the tool consumer.
|
User |
getUser()
Returns the User object relating to the user performing launch request.
|
boolean |
isAllowSharing()
Returns
true if the sharing facility is to be permitted. |
boolean |
isOk()
Returns
true if no errors have been encountered. |
void |
setAllowSharing(boolean allowSharing)
Set whether the sharing facility is permitted for launch requests.
|
void |
setDefaultEmail(java.lang.String defaultEmail)
Set the the default email domain to be used when auto-generating email addresses.
|
void |
setIdScope(int idScope)
Set the default scope to use when generating user IDs.
|
void |
setMessage(java.lang.String message)
Set the default message to return on an invalid launch.
|
void |
setParameterConstraint(java.lang.String name,
boolean required,
java.lang.Integer maxLength)
Add a parameter constraint to be validated on launch.
|
void |
setReason(java.lang.String reason)
Set the explanation for an error identified in the launch.
|
void |
setRedirectUrl(java.lang.String redirectUrl)
Set the URL to which users should be redirected on successful completion of a
launch request.
|
public static final java.lang.String LTI_VERSION
public static final int ID_SCOPE_ID_ONLY
public static final int ID_SCOPE_GLOBAL
public static final int ID_SCOPE_CONTEXT
public static final int ID_SCOPE_RESOURCE
public static final char ID_SCOPE_SEPARATOR
public ToolProvider(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Callback callbackHandler, DataConnector dataConnector)
request
- User's HTTP request objectresponse
- User's HTTP response objectcallbackHandler
- Callback function for a connect requestdataConnector
- DataConnector object representing the database connection to use for accessing the tables used by the packagepublic ToolProvider(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,Callback> callbackHandlers, DataConnector dataConnector)
request
- User's HTTP request objectresponse
- User's HTTP response objectcallbackHandlers
- Map containing callback functions for each request type (e.g. connect, error)dataConnector
- DataConnector object representing the database connection to use for accessing the tables used by the packagepublic boolean execute()
true
if the launch request was successfulpublic boolean isOk()
true
if no errors have been encountered.true
if there have not been any errorspublic ToolConsumer getConsumer()
public User getUser()
public javax.servlet.http.HttpServletRequest getRequest()
public ResourceLink getResourceLink()
public java.lang.String getReturnUrl()
public java.lang.String getRedirectUrl()
public void setRedirectUrl(java.lang.String redirectUrl)
redirectUrl
- redirect URL, may be nullpublic java.lang.String getDefaultEmail()
When the domain starts with @
the user's ID will be added as a prefix when
generating an email address.
public void setDefaultEmail(java.lang.String defaultEmail)
When the domain starts with @
the user's ID will be added as a prefix when
generating an email address.
defaultEmail
- default email domainpublic int getIdScope()
The value is one of the pre-defined constants: ID_SCOPE_ID_ONLY
,
ID_SCOPE_GLOBAL
, ID_SCOPE_CONTEXT
,
ID_SCOPE_RESOURCE
.
public void setIdScope(int idScope)
The value should be one of the pre-defined constants: ID_SCOPE_ID_ONLY
,
ID_SCOPE_GLOBAL
, ID_SCOPE_CONTEXT
,
ID_SCOPE_RESOURCE
.
idScope
- default scopepublic boolean isAllowSharing()
true
if the sharing facility is to be permitted.
Sharing allows launches from different resource link IDs to all be directed to the same one.
true
if sharing is permittedpublic void setAllowSharing(boolean allowSharing)
Sharing allows launches from different resource link IDs to all be directed to the same one.
allowSharing
- true
if sharing is permittedpublic void setParameterConstraint(java.lang.String name, boolean required, java.lang.Integer maxLength)
A parameter may be validated based on its presence (required) and/or a specified maximum length.
name
- Name of parameter to be validatedrequired
- True if parameter is requiredmaxLength
- Maximum permitted length of parameter value (optional, default is NULL)public java.lang.String getMessage()
public void setMessage(java.lang.String message)
message
- message stringpublic java.lang.String getReason()
public void setReason(java.lang.String reason)
reason
- error description, may be nullpublic java.util.List<ToolConsumer> getConsumers()