Table of Contents

MicroServices - Edit History

Introduction

The Edit History microservice is used to log data related to changes made by operators in the CMS. The logged data is added when an item of a mediatype is created, updated or deleted, also when a relationship is created or deleted with the referred item. The stored data may also be read by operators using this microservice.

Both of these functions are available through an API, which will be detailed later.

Grounded against origin/releases/7.0 (MibClient2 MediaiBox.Core.Audit, MibServerApi MediaiBox.Cms.Api.Audit, MibMicroServices EditHistory, MibServer3 history V2 controllers); the cited surfaces are byte-identical on releases/6.0.

Related docs. Edit history / audit — automatic change tracking — the capture-and-view feature angle (what's recorded, the ALLOW_AUDIT_VIEW page flag, the dashboard, gotchas). Audit trail — the in-toolbar view.

How it works — the cross-component audit flow

Edit History is not a service you call directly during authoring; it is the sink of an automatic pipeline that spans four components. Capture is global (every media type, minus configured ignore-lists) — you don't opt a media type in; a page only controls whether the trail is viewable.

Write path (capture → store):

  1. MibObject (MediaiBox.Core.Objects, the persistence lib shipped in MibClient2) — every create/update/delete of content flows through it. It carries AuditInformation and computes the field-level change set as a MibObjectChanges document (MediaiBox.Core.Audit/MibAuditObjectChanges.cs:15): RegisterId, MediaType, User/Date, Operation ∈ Added/Changed/Removed/AddedRelation/RemovedRelation (:60), ChangeDetails[].
  2. MibApi (Cms.Api) — on save it fires IRepositoryNotificationListener; the concrete listener is loaded by reflection from MibObjectNotificationConfig.NotificationClassFullName (MediaiBox.Cms.Api.Audit/AuditListenerBase.cs:10). In a stock deploy that value is MediaiBox.Cms.MicroServices.EditHistory.Listener.MibEditHistoryListener.
  3. MibEditHistoryListener (MibMicroServices/EditHistory/…Listener, : IRepositoryNotificationListener) — this assembly is dropped into the Cms.Api bin; it receives each change and calls the microservice client → POST edithistory/v1/save/{mediatype}/{registerId} (or save/batch, via MibEditHistoryListenerBatch).
  4. Edit History microservice — persists to MongoDB (one collection per media type; there is no SQL audit table).

Read path (view):

  1. MibServer3 (BFF) reads via three api/v2 history controllers — edition-history (the per-entity "view history" drawer), page-history/{pageKey}, and user-history (+ export) — each gated by UseEditHistoryMicroService (MibCmsFrontEndServerBaseConfig.cs:93), the per-page ALLOW_AUDIT_VIEW flag (DisplayConfiguration.cs:17), and SOURCE read scope (EditHistoryDashboardRepository.cs:162).
  2. MibFrontEnd renders the drawer / dashboard.

So Cms.Api and Cms.FrontEnd both hold the client config, but for opposite directions: the API writes (through the listener), the BFF reads. The capture internals, enable flag, and gotchas live in the feature doc.

Prerequisites

  1. Docker
  2. MibConfig via ENVVAR
  3. MongoDB

Required Configuration Files

Some configurations are required by the microservice and for the service that consumes it service and provides the data to be logged.

MibEditHistoryMicroServiceClientConfig

  • ApiUrl, string: path where the microservice is served.
  • MaxCallErrors, int: maximum number of times that the microservice is called in case of unsuccesful response.
  • Timeout, int: maximum response time tolerated from the microservice in seconds.

MibEditHistoryMicroServiceServerConfig

  • IsLogEnabled, bool: includes all the data information to be added in the EditHistory DB in the log produced by the microservice operations.
  • EnsureIndex, bool: creates indexes in the Edit History BD.

MibObjectNotificationConfig

  • NotificationAssemblyName, string: "MediaiBox.Cms.MicroServices.EditHistory.Listener".
  • NotificationClassFullName, string: "MediaiBox.Cms.MicroServices.EditHistory.Listener.MibEditHistoryListener".

MibLogConfig

MibMongoDBConfig see more

MibCmsFrontEndServerBaseConfig

  • UseEditHistoryMicroService, bool: enables the use of the edit history microservice (must be True).

Required configuration file at Cms.FrontEnd:

  • MibEditHistoryMicroServiceClientConfig
  • MibCmsFrontEndServerBaseConfig

Required configuration file at Cms.Api:

  • MibEditHistoryMicroServiceClientConfig
  • MibObjectNotificationConfig

Required configuration file at Cms.MicroService:

  • MibEditHistoryMicroServiceServerConfig
  • MibLogConfig
  • MibMongoDBConfig

Using with DocumentDB AWS

To use DocumentDB with the MongoDB driver, it is necessary to pay attention to the points below:

  • Will need to apply the UseTls setting in MibMongoDBConfig to establish a secure connection.
  • Will need to apply the ClientCertificate setting in MibMongoDBConfig to validate the connection. If not informed, a FileNotFoundException will be released.
  • It is possible to define whether the service should validate revoked certificates. To apply validation, set CheckCertificateRevocation setting in MibMongoDBConfig to true.

If CheckCertificateRevocation is true, the connection process will call the ClientCertificateSelectionCallback. ClientCertificateSelectionCallback can be used to apply validations as needed. By default, Mib only checks if there are any errors logged in this callback. If it exists, an InvalidOperationException will be released.

There are two ways to set your callback logic:

  • In all constructors of MibMongoDb it is possible to pass a RemoteCertificateValidationCallback.
  • In the MibMongoDb class there is a SetServerCertificateValidationCallback method to inform the callback.

For more information about the process follow documentation links:

API Routes

Base route edithistory/v1/. Beyond the three detailed below, the service also exposes POST edithistory/v1/count/{mediatype}/{registerId} (history-entry count for a record) and a separate dashboard controller at api/v1/edithistorydashboard/… (user, page, mediatype/{mediaType}/{historyId}, collections, recentusers) that backs the cross-page history dashboard. The BFF's api/v2 history controllers (see How it works) are the client for these. The service generates Swagger/OpenAPI via AddSwaggerGen (vanilla, not /help).

Save

POST: edithistory/v1/save/{mediatype}/{registerId}
Parameters:

  • mediatype: mediatype name of the register which changes would be logged
  • registerid: id of the register which changes would be logged
  • SaveInformation, body:
{
    "userid": "int",
    "repositoryObject":{
        "modifiedFields":[
        {
            "name": "string",
            "newvalue": "string",
            "originalvalue": "string"
        }],
        "addedRelations":[
        {
            "mediatype": "string",
            "id": "int"
        }],
        "removedRelations":[
        {
            "mediatype": "string",
            "id": "int"
        }]    
    },
    "operationtype": "int"     
}
  • userId: id of the user who made that change
  • repositoryObject: holds the description in lists for changes in fields (name of the field, old and new value) and for changes in relations (mediatype and id of the item). Each list may be null if there is no change in their subject.
  • operationType: enum value described in MediaiBox.Core.Audit.MibAuditObjectChanges.ChangeOperationType, which may be:
    {
        Added,
        Changed,
        Removed,
        AddedRelation,
        RemovedRelation
    }
    

SaveBatch

POST: edithistory/v1/save/batch

  • SaveInformation, body:
[
  {
    "id": 0,
    "mediaType": "string",
    "userId": 0,
    "repositoryObject": {
      "modifiedFields": [
        {
          "name": "string",
          "originalValue": "string",
          "newValue": "string"
        }
      ],
      "addedRelations": [
        {
          "mediaType": "string",
          "id": 0
        }
      ],
      "removedRelations": [
        {
          "mediaType": "string",
          "id": 0
        }
      ],
      "auditInformation": {
        "instanceId": 0,
        "requestId": "string",
        "pageKey": "string",
        "source": 0,
        "tags": [
          "string"
        ],
        "hiddenFields": [
          "string"
        ]
      }
    },
    "operationType": 1
  }
]
  • id: id of the register which changes would be logged
  • mediatype: mediatype name of the register which changes would be logged
  • userId: id of the user who made that change
  • repositoryObject: holds the description in lists for changes in fields (name of the field, old and new value) and for changes in relations (mediatype and id of the item). Each list may be null if there is no change in their subject.
  • operationType: enum value described in MediaiBox.Core.Audit.MibAuditObjectChanges.ChangeOperationType, which may be:
    {
        Added,
        Changed,
        Removed,
        AddedRelation,
        RemovedRelation
    }
    

Read

POST: edithistory/v1/read/{mediatype}/{registerId}?page={page}&limit={limit}
Parameters:

  • mediatype: mediatype name of the register which logged changes would be read
  • registerid: id of the register which logged changes would be read
  • page: pagination value
  • limit: maximum number of items per request (if not informed or the value is less than or equal to zero, a default limit of 10 will be applied)
  • ReadInformation, body:
{
    "relateds":[
    {
        "name":"string",
        "relationType":"int",
        "relationColumn":"string"
    }],
    "readPermissions":[
        "string",
        "string",
        "string"
    ]
}
  • readPermissions: list of mediatype names that the user has the permission to read.
  • relateds: list of mediatypes related to the main mediatype, with their name, type of relation and relationship column.
    • relationType is an enum described in MediaiBox.Cms.MicroServices.EditHistory.Model.RelationshipType, which may be:
      {
          Direct,
          DirectInverse,
          LinkObjects,
          RelationshipTable
      }
      

Troubleshooting

If the register changes are note being shown in the drawer or dashboard correctly, checking if the record is present in the MongoDB may be a good lead:

  • ✅ If it is present:
    • The issue may be in retrieving the information
    • Check the configuration in Cms.FrontEnd:
      • Are the MicroService endpoints being called?
        • ✅ Yes → Check:
          • MibMongoDBConfig on the MicroService and the MongoDB environment
          • GET methods on the MicroService
        • ❌ No → Check:
          • UseEditHistoryMicroService on the Cms.FrontEnd must be set to true in MibCmsFrontEndServerBaseConfig
          • MibEditHistoryMicroServiceClientConfig on the Cms.FrontEnd must point to a working environment

Note on user-facing errors: when UseEditHistoryMicroService is true and the MicroService cannot be read - an unreachable host, an ApiUrl that points to another service, or the configured Timeout reached - the Cms.FrontEnd answers the Edit History drawer, Page History and User History with a 503 and the message "Not possible to access history. Please refer to the logs for more info." (dictionary entry error/historynotobtainable), followed by the Request Id. The original exception is logged in the Cms.FrontEnd under that Request Id for diagnosis. An empty or relative ApiUrl is not reported this way, since the Cms.FrontEnd does not start with it (the health check registration fails to build the /health URL). Up to 7.0.7 the drawer of a record (GET /api/v2/user-history with an id) answered this same case with a 500 ArgumentNullException in EditHistoryDashboardWorkflow.GetHistoryListByItem instead of the 503; the [EditHistoryMicroService] Message: … line in the Cms.FrontEnd log names the real failure (MEDIAIBOX-12431).

  • ❌ If it is NOT present:
    • The issue may be in saving the information
    • Check the configuration in Cms.Api and Cms.MicroService
      • Are the MicroService endpoints being called?
        • ✅ Yes → Issue is likely in the MicroService logic, MibMongoDBConfig, or the MongoDB environment
        • ❌ No → Check:
          • Configuration in Cms.Api
          • Assembly set in MibObjectNotificationConfig
          • Save process in Cms.Api or Core.MibObjects