Kentico CMS 6.0 Integration Guide

Implementation of inbound direction

Implementation of inbound direction

Previous topic Next topic Mail us feedback on this topic!  

Implementation of inbound direction

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

At this point you should be decided:

 

which objects and documents you want to synchronize

which data type you want to use

 

Based on this information you will be able to decide which methods you need to implement. You should also have operational skeleton of connector prepared as described in the Creating a connector class topic.

 

Implementation basics

 

To log object or document tasks to the queue, please use the following method located in the IntegrationHelper class:

 

void ProcessExternalTask(string connectorName, object obj, IntegrationProcessTypeEnum result, TaskTypeEnum taskType, TaskDataTypeEnum dataType, string siteName)

 

This method just logs the tasks to the queue and the system takes care of them and processes them later. It has the following parameters:

 

connectorName – use code name of the connector for that you want the tasks to be logged.

obj – this will typically be the external object. If you have somehow managed to prepare ICMSObject earlier, you can pass it as well.

result – this value says how the system should behave when fetching the tasks from the database and how it should react if an error occurs.

taskType – by providing this value, you say whether the provided object or document should be created, updated, deleted, etc.

dataType – says whether the provided object contains also child objects, etc. The value also indicates whether the methods for collecting translation information will be called.

siteName – if the processed object belongs to a site, you should provide a code name of this site.

 

Detailed description of particular enumerations used in the parameters can be found in Important types -> Enumerations.

 

The following diagram illustrates the sequence of method calls for each inbound synchronization. The purpose and details of individual methods are described further below.

 

integrationguide_clip0027

 

Methods to be implemented

 

The following methods need to be implemented to ensure synchronization in the inbound direction:

 

PrepareInternalObject - ensures processing of an object or a document.

GetInteralObjectParams - prepares translation information for an object or a document that has a foreign key to an object (BaseInfo).

GetInternalDocumentParams - prepares translation information for an object or a document that has a foreign key to a document (TreeNode).

 

PrepareInternalObject method

 

The method has the following signature:

 

ICMSObject PrepareInternalObject(object obj, TaskTypeEnum taskType, TaskDataTypeEnum dataType, string siteName)

 

The method serves as a centralized point for transformation of objects and documents from the external system to the corresponding ones in Kentico CMS. Your task is to return a valid TreeNode or object inheriting from BaseInfo. The following figure illustrates when the method is called:

 

integrationguide_clip0028

 

GetInernalObjectParams method

 

The method has the following signature:

 

void GetInternalObjectParams(int id, string objectType, out string codeName, out string siteName, ref int parentId, ref int groupId)

 

The method needs to be implemented when you are planning to synchronize objects or documents that have foreign keys referencing objects (in Kentico CMS). Based on the given parameters (id and objectType), you should be able to find corresponding object in the external system and supply at least its code name through the corresponding out parameter. It is possible to specify the object  more precisely by providing also siteName, parentId and groupId.

 

GetInternalDocumentParams method

 

The method has the following signature:

 

void GetInternalDocumentParams(int id, string className, out Guid nodeGuid, out string cultureCode, out string siteName)

 

The method needs to be implemented when you are planning to synchronize objects or documents that have foreign keys referencing documents (in Kentico CMS). Based on the given parameters (id and className), you should be able to find the corresponding document in the external system and supply its nodeGuid, cultureCode and siteName through the out parameters. All of the parameters are mandatory.

 

How to request processing of logged tasks

 

BaseIntegrationConnector offers you two overloads of the RequestTasksProcessing method:

 

HttpStatusCode RequestTasksProcessing(string serverUrl)

HttpStatusCode RequestTasksProcessing(string serverUrl, string connectorName)

 

By calling these methods, the application makes a HTTP request to the ~/CMSPages/IntegrationNotify.aspx page, which causes that processing is executed. Each connector will be processed in its own thread. The method requires you to specify a URL leading to the root of the Kentico CMS application (e.g. http://www.example.com/KenticoCMS). The second overload allows you to specify the connector whose tasks will be processed. If the parameter is not supplied, all connectors will be processed.