Digizuite DAM integration service provides an API where integration endpoints can register for notifications regarding asset and metadata changes. We have made it easy to setup the connection between Episerver and Digizuite. All you have to do is to add some configuration in the web.config - and your Episerver instance will receive notifications from Digizuite whenever an asset changes.
In Episerver we have created a new ApiController, which is located at the following route [siteUrl]/digizuite/integration. This is the endpoint that receives notifications from Digizuite. An important thing to note here is, that the endpoint should be reachable by the Digizuite server. Otherwise, the notifications won't be able to sent. This is usually the case for developers on local environments.
let’s talk about what the controller does when it receives a notification. The data coming from Digizuite will be serialized in to an object of this type:
public class UpdateNotification { public int ChangeType { get; set; } public ChangeData Data { get; set; } } public class ChangeData { public int ItemId { get; set; } public int BaseId { get; set; } }
The property ChangeType indicates whether it's an AssetChanged, MetafieldChanged, ComboValueChanged or a TreeValueChanged. If it's an AssetChanged we do the following:
Delete blobs for the relevant asset, based on the asset ID.
Delete database entries for the relevant asset, based on the asset ID.
The last thing we do, is to raise an Episerver event with the UpdateNotification object.
_eventRegistry.Get(GlobalConstants.ContentEventRegistry.DigizuiteAssetChangeEventId).RaiseAsync( GlobalConstants.ContentEventRegistry.DigizuiteAssetChangeRaiserId, updateNotification, EventRaiseOption.RaiseBroadcast);
We're also listening for the event. For AssetChanged we clear the in-memory cache and if the RaiserId is coming from another instance (broadcast) and the configuration “DeleteBlob” is true, then we delete the blobs and database entries for the relevant asset, based on the asset ID.
var digizuiteIntegrationEvent = _eventRegistry.Get(GlobalConstants.ContentEventRegistry.DigizuiteAssetChangeEventId); digizuiteIntegrationEvent.Raised += DigizuiteIntegrationEvent_Raised;
As a developer, you can also build your own logic around notifications from Digizuite. You can listen for the event by subscribing to the event, just like we do above.
1. Setup the endpoint
Open the Episerver’s web.config and locate the Digizuite node. Beneath this node, there’s a node called “digizuiteIntegration”. This is the one we need to update. Here you see an example where it has been configured:
<digizuiteIntegration siteUrl="http://my.episerverSite.dk" guid="e01553bd-f66a-4fba-8b6b-884133d8ae80" subscriptions="1" deleteBlob="false"/>
The siteUrl is the URL to your Episerver’s site. The guid is used as an identifier, when creating a new endpoint in Digizuite. The default value is empty so you have to generate a new one. The parameter subscriptions indicates which “change type” you want to listen for. The possible values can be found here DFE 2.1.0 - 3 Setting up Episerver. The default value is 1 - that being the ID of the “AssetChanged” event. The last parameter deleteBlob indicates whether we should delete blobs of the asset. In a load balanced environment, where you have multiple instances in which each of the instances contains its own local blob storage, this should be set to true. If the blob storage is shared between instances, leave it as false.
Once the change has been made, reload the site. You will now see the following log statement in the file Digizuite.log:
2020-05-14 08:22:33,529 [1] INFO DigizuiteProviderInit::Initialize: DigizuiteIntegration has been setup and configured
2. Verify connection
If you have access to the Digizuite server. Open a browser from that server and access your Episerver site. If you cannot access the site, Digizuite won't be able to send notifications to it.
If the server can access your site, the next test is to change an asset in the Digizuite DAM Center and verify that the notification has been sent to Episerver.
Change the log level for the logger “Digizuite.Episerver.Helpers.Internal.Logger” to Debug or All.
Reload the site.
Go to the DAM Center and find an asset that is published to the Episerver channel.
Change some of the metadata, e.g. the title. The Digizuite DAM will notify all registered integration endpoints with the update.
You should see the following log statement in the log file Digizuite.log. This indicates that Digizuite DAM has delivered the notification to the api controller inside Episerver.
2020-05-15 11:20:45,828 [20] DEBUG DigizuiteIntegrationController::Update: DigizuiteIntegration Event, Type:1 ItemId:395810 AssetId:3247
Lastly, verify that the changed metadata is the same as in Episerver.