Provide Forms support for multiple MAI connector

Fixed in

EPiServer.Forms 4.18.0

Created

Jun 29 2018

Updated

Oct 12 2018

State

Closed, Acceptance tests pass


Description

Provide Forms support for multiple MAI connector.

1. Developers can create an instance of IExternalSystem and register it with the Forms.

var efmService = ServiceLocator.Current.GetInstance<ExternalSystemService>();
var custom1 = new CustomExternalSystem("Custom_1");
custom1.Datasources = GetSomeDatasources(custom1);
var custom2 = new CustomExternalSystem("Custom_2");
custom2.Datasources = GetSomeDatasources(custom2);
efmService.RegisterExternalSystem(custom1);
efmService.RegisterExternalSystem(custom2);

2. Forms also automatically activate ExternalSystem with the default constructor and register with Forms. Developers can override to change this default behavior.

3. Allow the display name of the ExternalSystem by ID. Will get DisplayName localization resource from xml path:

/episerver/forms/externalsystems/{system.Id}/displayname

If that resource does not exist, fallback to the default one (like previous version):

/episerver/forms/externalsystems/{system.GetType().FullName}/displayname

IMPLEMENT: API changes

1. Introduce a new service, ExternalSystemService, for working with external systems:

  • WorkingExternalSystem: property to get all current, activated external systems.
  • HasExternalSystems(): Determine if there is any an implementation of an IExternalSystem.
  • ActivateFromTypes(): Automatically try to create instances of IExternalSystem by scanning assembly. This requires the default constructor of ExternalSystem. If you don’t want to automatically activate your ExternalSystem, override this method and do nothing or don’t provide the default constructor for the ExternalSystem.
  • RegisterExternalSystem: Explicitly register an ExternalSystem. Each ExternalSystem must have a unique ID. The ID should NOT contain space or special characters.
  • UnregisterExternalSystem: Remove an ExternalSystem.
  • GetExternalSystem: Return instance of ExternalSystem by ID.
  • GetAllExternalSystems: Return all instances of ExternalSystem (activated, registered).

2. Obsolete the property IPostSubmissionActor.ActiveExternalFieldMappingTable, since the Actors should NOT know about the mappings. If you want to have a mapping table in Actors, use IExternalFieldMappingService.GetActiveFieldMappingTables to retrieve them.