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(MibClient2MediaiBox.Core.Audit, MibServerApiMediaiBox.Cms.Api.Audit, MibMicroServicesEditHistory, MibServer3 history V2 controllers); the cited surfaces are byte-identical onreleases/6.0.
Related docs. Edit history / audit — automatic change tracking — the capture-and-view feature angle (what's recorded, the
ALLOW_AUDIT_VIEWpage 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):
- MibObject (
MediaiBox.Core.Objects, the persistence lib shipped in MibClient2) — every create/update/delete of content flows through it. It carriesAuditInformationand computes the field-level change set as aMibObjectChangesdocument (MediaiBox.Core.Audit/MibAuditObjectChanges.cs:15):RegisterId,MediaType,User/Date,Operation∈Added/Changed/Removed/AddedRelation/RemovedRelation(:60),ChangeDetails[]. - MibApi (
Cms.Api) — on save it firesIRepositoryNotificationListener; the concrete listener is loaded by reflection fromMibObjectNotificationConfig.NotificationClassFullName(MediaiBox.Cms.Api.Audit/AuditListenerBase.cs:10). In a stock deploy that value isMediaiBox.Cms.MicroServices.EditHistory.Listener.MibEditHistoryListener. 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}(orsave/batch, viaMibEditHistoryListenerBatch).- Edit History microservice — persists to MongoDB (one collection per media type; there is no SQL audit table).
Read path (view):
- MibServer3 (BFF) reads via three
api/v2history controllers —edition-history(the per-entity "view history" drawer),page-history/{pageKey}, anduser-history(+export) — each gated byUseEditHistoryMicroService(MibCmsFrontEndServerBaseConfig.cs:93), the per-pageALLOW_AUDIT_VIEWflag (DisplayConfiguration.cs:17), and SOURCE read scope (EditHistoryDashboardRepository.cs:162). - 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
- Docker
- MibConfig via ENVVAR
- 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 exposesPOST edithistory/v1/count/{mediatype}/{registerId}(history-entry count for a record) and a separate dashboard controller atapi/v1/edithistorydashboard/…(user,page,mediatype/{mediaType}/{historyId},collections,recentusers) that backs the cross-page history dashboard. The BFF'sapi/v2history controllers (see How it works) are the client for these. The service generates Swagger/OpenAPI viaAddSwaggerGen(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 }
- relationType is an enum described in MediaiBox.Cms.MicroServices.EditHistory.Model.RelationshipType, which may be:
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:
MibMongoDBConfigon the MicroService and the MongoDB environment- GET methods on the MicroService
- ❌ No → Check:
UseEditHistoryMicroServiceon theCms.FrontEndmust be set totrueinMibCmsFrontEndServerBaseConfigMibEditHistoryMicroServiceClientConfigon theCms.FrontEndmust point to a working environment
- ✅ Yes → Check:
- Are the MicroService endpoints being called?
Note on user-facing errors: when
UseEditHistoryMicroServiceistrueand the MicroService cannot be read - an unreachable host, anApiUrlthat points to another service, or the configuredTimeoutreached - theCms.FrontEndanswers 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 entryerror/historynotobtainable), followed by the Request Id. The original exception is logged in theCms.FrontEndunder that Request Id for diagnosis. An empty or relativeApiUrlis not reported this way, since theCms.FrontEnddoes not start with it (the health check registration fails to build the/healthURL). Up to 7.0.7 the drawer of a record (GET /api/v2/user-historywith anid) answered this same case with a 500ArgumentNullExceptioninEditHistoryDashboardWorkflow.GetHistoryListByIteminstead of the 503; the[EditHistoryMicroService] Message: …line in theCms.FrontEndlog names the real failure (MEDIAIBOX-12431).
- ❌ If it is NOT present:
- The issue may be in saving the information
- Check the configuration in
Cms.ApiandCms.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.ApiorCore.MibObjects
- Configuration in
- ✅ Yes → Issue is likely in the MicroService logic,
- Are the MicroService endpoints being called?