© 2014, Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and or/its affiliates and/or their licensors.
Generated by JsDoc Toolkit 2.3.2

Class Presto .Connection

A connection to the Presto Mashup Server. Multiple requests can be sent through this connection. The Connection can be anonymous or authenticated. Authentication can be handled with SSO, x.509 certificates or by passing user credentials in the configuration object for the constructor.

Class Summary
Constructor AttributesConstructor Name and Description
 
Method Summary
Method AttributesMethod Name and Description
 

Determines if this connection is authenticated or anonymous or possibly timed out.

 
request(requestObject, callback)

Invokes a mashable or mashup in Presto for this connection.

Class Detail
Presto.Connection(config)
Parameters:
{Object} config
A configuration object with these properties:
{String} config.prestoUrl
The required URL to connect to the Mashup Server. For local connections this can be a relative URL, such as /presto. Mashup Server URLs are in the form: http://server:port/presto.
{String} config.username
An optional username to use to log into the Mashup Server. This is used for authenticated connections not handled by SSO or x.509 certificate authentication.
{String} config.password
An optional password to use to log into the Mashup Server. This is used for authenticated connections not handled by SSO or x.509 certificate authentication.
Method Detail
isAuthenticated(fn)

Determines if this connection is authenticated or anonymous or possibly timed out. This updates the username property for the connection and calls the specified callback function for both success and error responses.

Parameters:
{Function} fn
The callback function to invoke, with signature fn(scope, user). The user parameter is only present for successful invocations. For authenticated connections this contains the user name, but is null if the connection is anonymous or the authenticated session has timed out.
request(requestObject, callback)

Invokes a mashable or mashup in Presto for this connection. This function builds the REST request based on the request configuration passed and registers the callback functions to handle the asynchronous response.

Parameters:
{Object or String} requestObject
The REST URL to invoke a mashable or mashup via HTTP GET or a configuration object used to build this request. This object can contain the following properties:
{String} requestObject.url
The required base REST URL to invoke this mashable or mashup including any input parameters or Presto headers (as parameters). See the Technical Specs tab in the artifact page in Presto Hub for this mashable or mashup to get this URL. For more information on valid Presto headers/parameters, see Presto Headers/Parameters.
{String} requestObject.contentType
An optional string with the content type for this request. This defaults to application/x-www-form-urlencoded if this property is omitted.
{String} requestObject.type
Either GET or POST, indicating the HTTP action for this request.
{Object} requestObject.data
Query parameters to add to the URL for GET requests or the body for a POST request. For POST, this must match the content that is expected and allowed by the Presto mashable or mashup invoked in this request.
{Object} callback
A required object containing the callback functions and scope to handle the response to this request. Call objects contains these properties:
{Function} callback.onSuccess
A function to handle successful responses, in the form onSucess(data, responseHeaders)
{Function} callback.onFailure
A function to handle error or exception responses in the form onFailure(error)
{Function} callback.onComplete
A function to call after either successful or error responses are handled in the form: onComplete(data, reponseHeaders) for success or onComplete(error) for failure