TDAODataSchemaDispatcher

Overview

The ODATA Schema Dispatcher is a class that exposes a Data Abstract service as an OData provider. OData is an open specification with standardized ways of accessing, updating, inserting and deleting data and exposing metadata. It has clients on multiple platforms including javascript, PHP, Java, Ruby and .NET. OData is ideal when you need to expose your Data Abstract service to external clients that are unable to use Data Abstract themselves.

Location


 

constructor Create  override

Standard component constructor

constructor Create(AOwner: TComponent)

Parameters:

  • AOwner: Owner

Activate  virtual    (declared in TROExtendedHttpDispatcher)

procedure Activate

Assign  override    (declared in TROComponent)

Copies the contents of another, similar object.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

CanHandlePath    (declared in TROExtendedHttpDispatcher)

Return true if the given path can be handled by the dispatcher. The function compares the Path property content with the given path and chacks if the given path starts with the Path subpath.

function CanHandlePath(aPath: string): Boolean

Parameters:

  • aPath: The request path to check.

Deactivate  virtual    (declared in TROExtendedHttpDispatcher)

procedure Deactivate

FixName

Thsi function replaces '[', ']', '.' and ' ' with '_'.

class function FixName(s: UnicodeString): UnicodeString

Parameters:

  • s: input string

HttpAuthLoginServiceName

Name of the service to use for authentication. This can be unassigned in which case no authentication is required. When it's set, the name used should be the name of a SimpleLoginService descendant with a Login method implementation. The Login method is called and cached someone logs through plain HTTP authentication.

property HttpAuthLoginServiceName: string read write

HttpAuthRealm

The realm to use during authentication. This is the string the user sees as the domain to which to login.

property HttpAuthRealm: string read write

MaxRecords

Maximum number of records to send in a package. This can be 0 which means unlimited.

property MaxRecords: Integer read write

Namespace

The namespace to use for OData. This could be any url that unique identifies this service.

property Namespace: string read write

Notification  protected override

Forwards notification messages to all owned components.

procedure Notification(AComponent: TComponent; Operation: TOperation)

Parameters:

  • AComponent: component
  • Operation: operation

NotifyDispose    (declared in TROExtendedHttpDispatcher)

This procedure is called when the server HTTP channel is about to be freed.

procedure NotifyDispose

OnGetSchemaDataTable

Called when the client requests the schema for a particular data table.

property OnGetSchemaDataTable: TDAODataOnGetSchemaDataTableEvent read write
delegate: procedure OnGetSchemaDataTable(aSender: TObject; const Service: IDataAbstractLocalServiceAccess; const DataTableName: UnicodeString; var SchemaDataTable: TDADataset)

OnGetServiceSchema

Called when the client requests the service schema.

property OnGetServiceSchema: TDAODataOnGetServiceSchemaEvent read write
delegate: procedure OnGetServiceSchema(aSender: TObject; const ServiceInstance: IDataAbstractLocalServiceAccess; const TargetUrl: UnicodeString; const ClientId: TGUID; var RootUrl: UnicodeString; const Schema: TDASchema)

OnLoginNeeded

Called when authentication of client is needed.

property OnLoginNeeded: TDAODataOnLoginNeededEvent read write
delegate: procedure OnLoginNeeded(aSender: TObject; const Request: IROHTTPRequest; const ClientId: TGUID; const TargetUrl: UnicodeString; const Username: UnicodeString; const Password: UnicodeString; var LoginSuccessful: Boolean)

OnProcessTargetUrl

Fires during processing of target url.

property OnProcessTargetUrl: TDAODataOnProcessTargetUrlEvent read write
delegate: procedure OnProcessTargetUrl(aSender: TObject; const ClientId: TGUID; const TargetUrl: UnicodeString; var TableName: UnicodeString; FilterValues: TStrings)

OnUnknownRequest

Called when a request that is not supported by the OData provider occurs.

property OnUnknownRequest: TDAODataOnUnknownRequestEvent read write
delegate: procedure OnUnknownRequest(asender: TObject; const Request: IROHTTPRequest; const Response: IROHTTPResponse; const RequestData: TStream; const ResponseData: TStream; const Path: UnicodeString)

Path    (declared in TROExtendedHttpDispatcher)

The request path the dispatcher will be activated for. For example, if this property contains /js then the dispatcher will be activated by the server channel to process such requests as http://example.org:8099/js/* (the asterisk means zero or more characters to continue the request path).

property Path: string read write

Process  override

The main method to perform the request processing ant to form the response. Called every time to process incoming requests if the dispatcher is suitable to process it (determined by CanHandlePath result).

procedure Process(aTransport: IROHTTPTransport; aRequest: IROHTTPRequest; aResponse: IROHTTPResponse; aRequestData: TStream; aResponseData: TStream)

Parameters:

  • aTransport: Http transport.
  • aRequest: Contains object implementing IROHTTPRequest interface that describes the request.
  • aResponse: Contains initialized object implementing IROHTTPResponse interface that should describe the response.
  • aRequestData: The data stream (TStream) that contains the raw HTTP request data except the header part.
  • aResponseData: Contais initialized and empty data stream (TStream) that shpuld be filled with the raw reponse data except the header part.

ROFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure ROFreeNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

RootUrl

Full url to where this service is or will be hosted. OData requires absolute urls to be placed in the xml and json results, so this is a required property.

property RootUrl: string read write

RORemoveFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure RORemoveFreeNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

SendRemoveNotification  protected    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure SendRemoveNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

Server    (declared in TROExtendedHttpDispatcher)

Points to the HTTP server channel which the dispatcher works with.

property Server: IROHTTPServer read write

ServiceName

Data Abstract DataAbstractService descendant to use to access the data. This will be your main Data Abstract service that has the schema and business logic you want to expose through this OData schema dispatcher class.

property ServiceName: string read write

SessionManager

Session Manager that is used for authentication purposes

property SessionManager: TROCustomSessionManager read write

WriteDataTableNotFound  protected

Send a data table not found error to the client.

procedure WriteDataTableNotFound(aTable: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aTable: table name to fail on
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteEmptyOk  protected

Set the required headers for a valid response.

procedure WriteEmptyOk(aResponse: IROHTTPResponse; aResponseData: TStream)

Parameters:

  • aResponse: response info
  • aResponseData: response data

WriteError  protected

Send an exception back to the client.

procedure WriteError(aError: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aError: exception message
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteNotAcceptable  protected

Write a not acceptable header to denote the requested Accept: header was not supported.

procedure WriteNotAcceptable(aResponse: IROHTTPResponse; aResponseData: TStream)

Parameters:

  • aResponse: response info
  • aResponseData: response data

WriteNotAuthorized  protected

Write a not-authorized response to request user authentication.

procedure WriteNotAuthorized(aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteParametersNotSupported  protected

Write a "parameter not supported" error. This is an OData error that declares that an unknown request was passed.

procedure WriteParametersNotSupported(aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteRecordNotFound  protected

Sends a 404 error for records that could not be found.

procedure WriteRecordNotFound(aPath: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aPath: full path for this request
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format

 

HttpAuthLoginServiceName

Name of the service to use for authentication. This can be unassigned in which case no authentication is required. When it's set, the name used should be the name of a SimpleLoginService descendant with a Login method implementation. The Login method is called and cached someone logs through plain HTTP authentication.

property HttpAuthLoginServiceName: string read write

HttpAuthRealm

The realm to use during authentication. This is the string the user sees as the domain to which to login.

property HttpAuthRealm: string read write

MaxRecords

Maximum number of records to send in a package. This can be 0 which means unlimited.

property MaxRecords: Integer read write

Namespace

The namespace to use for OData. This could be any url that unique identifies this service.

property Namespace: string read write

Path    (declared in TROExtendedHttpDispatcher)

The request path the dispatcher will be activated for. For example, if this property contains /js then the dispatcher will be activated by the server channel to process such requests as http://example.org:8099/js/* (the asterisk means zero or more characters to continue the request path).

property Path: string read write

RootUrl

Full url to where this service is or will be hosted. OData requires absolute urls to be placed in the xml and json results, so this is a required property.

property RootUrl: string read write

Server    (declared in TROExtendedHttpDispatcher)

Points to the HTTP server channel which the dispatcher works with.

property Server: IROHTTPServer read write

ServiceName

Data Abstract DataAbstractService descendant to use to access the data. This will be your main Data Abstract service that has the schema and business logic you want to expose through this OData schema dispatcher class.

property ServiceName: string read write

SessionManager

Session Manager that is used for authentication purposes

property SessionManager: TROCustomSessionManager read write

 

FixName

Thsi function replaces '[', ']', '.' and ' ' with '_'.

class function FixName(s: UnicodeString): UnicodeString

Parameters:

  • s: input string

 

constructor Create  override

Standard component constructor

constructor Create(AOwner: TComponent)

Parameters:

  • AOwner: Owner

Activate  virtual    (declared in TROExtendedHttpDispatcher)

procedure Activate

Assign  override    (declared in TROComponent)

Copies the contents of another, similar object.

procedure Assign(Source: TPersistent)

Parameters:

  • Source: Instance whose properties will be copied

CanHandlePath    (declared in TROExtendedHttpDispatcher)

Return true if the given path can be handled by the dispatcher. The function compares the Path property content with the given path and chacks if the given path starts with the Path subpath.

function CanHandlePath(aPath: string): Boolean

Parameters:

  • aPath: The request path to check.

Deactivate  virtual    (declared in TROExtendedHttpDispatcher)

procedure Deactivate

Notification  protected override

Forwards notification messages to all owned components.

procedure Notification(AComponent: TComponent; Operation: TOperation)

Parameters:

  • AComponent: component
  • Operation: operation

NotifyDispose    (declared in TROExtendedHttpDispatcher)

This procedure is called when the server HTTP channel is about to be freed.

procedure NotifyDispose

Process  override

The main method to perform the request processing ant to form the response. Called every time to process incoming requests if the dispatcher is suitable to process it (determined by CanHandlePath result).

procedure Process(aTransport: IROHTTPTransport; aRequest: IROHTTPRequest; aResponse: IROHTTPResponse; aRequestData: TStream; aResponseData: TStream)

Parameters:

  • aTransport: Http transport.
  • aRequest: Contains object implementing IROHTTPRequest interface that describes the request.
  • aResponse: Contains initialized object implementing IROHTTPResponse interface that should describe the response.
  • aRequestData: The data stream (TStream) that contains the raw HTTP request data except the header part.
  • aResponseData: Contais initialized and empty data stream (TStream) that shpuld be filled with the raw reponse data except the header part.

ROFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure ROFreeNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

RORemoveFreeNotification    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure RORemoveFreeNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

SendRemoveNotification  protected    (declared in TROComponent)

Forwards notification messages to all owned components.

procedure SendRemoveNotification(aComponent: TComponent)

Parameters:

  • aComponent: component

WriteDataTableNotFound  protected

Send a data table not found error to the client.

procedure WriteDataTableNotFound(aTable: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aTable: table name to fail on
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteEmptyOk  protected

Set the required headers for a valid response.

procedure WriteEmptyOk(aResponse: IROHTTPResponse; aResponseData: TStream)

Parameters:

  • aResponse: response info
  • aResponseData: response data

WriteError  protected

Send an exception back to the client.

procedure WriteError(aError: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aError: exception message
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteNotAcceptable  protected

Write a not acceptable header to denote the requested Accept: header was not supported.

procedure WriteNotAcceptable(aResponse: IROHTTPResponse; aResponseData: TStream)

Parameters:

  • aResponse: response info
  • aResponseData: response data

WriteNotAuthorized  protected

Write a not-authorized response to request user authentication.

procedure WriteNotAuthorized(aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteParametersNotSupported  protected

Write a "parameter not supported" error. This is an OData error that declares that an unknown request was passed.

procedure WriteParametersNotSupported(aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aResponse: response info
  • aResponseData: response data
  • aFormat: format.

WriteRecordNotFound  protected

Sends a 404 error for records that could not be found.

procedure WriteRecordNotFound(aPath: UnicodeString; aResponse: IROHTTPResponse; aResponseData: TStream; aFormat: TDAODataFormat)

Parameters:

  • aPath: full path for this request
  • aResponse: response info
  • aResponseData: response data
  • aFormat: format

 

OnGetSchemaDataTable

Called when the client requests the schema for a particular data table.

property OnGetSchemaDataTable: TDAODataOnGetSchemaDataTableEvent read write
delegate: procedure OnGetSchemaDataTable(aSender: TObject; const Service: IDataAbstractLocalServiceAccess; const DataTableName: UnicodeString; var SchemaDataTable: TDADataset)

OnGetServiceSchema

Called when the client requests the service schema.

property OnGetServiceSchema: TDAODataOnGetServiceSchemaEvent read write
delegate: procedure OnGetServiceSchema(aSender: TObject; const ServiceInstance: IDataAbstractLocalServiceAccess; const TargetUrl: UnicodeString; const ClientId: TGUID; var RootUrl: UnicodeString; const Schema: TDASchema)

OnLoginNeeded

Called when authentication of client is needed.

property OnLoginNeeded: TDAODataOnLoginNeededEvent read write
delegate: procedure OnLoginNeeded(aSender: TObject; const Request: IROHTTPRequest; const ClientId: TGUID; const TargetUrl: UnicodeString; const Username: UnicodeString; const Password: UnicodeString; var LoginSuccessful: Boolean)

OnProcessTargetUrl

Fires during processing of target url.

property OnProcessTargetUrl: TDAODataOnProcessTargetUrlEvent read write
delegate: procedure OnProcessTargetUrl(aSender: TObject; const ClientId: TGUID; const TargetUrl: UnicodeString; var TableName: UnicodeString; FilterValues: TStrings)

OnUnknownRequest

Called when a request that is not supported by the OData provider occurs.

property OnUnknownRequest: TDAODataOnUnknownRequestEvent read write
delegate: procedure OnUnknownRequest(asender: TObject; const Request: IROHTTPRequest; const Response: IROHTTPResponse; const RequestData: TStream; const ResponseData: TStream; const Path: UnicodeString)

 

  • OData Publishing