CodamAIDocs
Topicdone

What remains after a delete

The history stays readable, there is no recycle bin (soft delete), and a rollback does not bring deleted objects back.

Variants
history readableno soft deleteno revival through rollbacknon-audited model → nothing remainscreate again from the history

What this is about

CDMS deletes hard. The row disappears from the database, and the object is gone for every request: reading returns 404, a search does not find it, references to it are empty. There is no “deleted” field, no recycle bin and no endpoint to restore it. This is called: no soft delete.

What remains is the history, provided the model is audited. Audited means: for every change, CDMS writes a revision, a stored state with a timestamp and an author. See What is audited.

The timeline of an object

flowchart LR
    A["ADD<br/>created"] --> M1["MOD<br/>changed"] --> M2["MOD<br/>changed"] --> D["DEL<br/>deleted"]
    D -.-> X["Read: 404<br/>Rollback: 404<br/>History: readable"]

Every revision has a type: ADD for creating, MOD for every change, DEL for deleting. The DEL revision tells you who deleted the object and when. Its fields are empty, except for the id. You find the last content before the delete in the revision before it.

The history after the delete

You read the history as for an existing object, with its id:

History of a deleted order
Request
POST /api/rest/order/7e1…/history
{ "response": ["id", "orderNr", "price"] }
Response
{ "data": [
    { "revision": { "id": "7e1…", "orderNr": null, "price": null },
      "revisionMeta": { "ref": 57, "username": "ben", … },
      "revisionType": "DEL" },
    { "revision": { "id": "7e1…", "orderNr": "A-1000", "price": 120.5 },
      "revisionMeta": { "ref": 42, "username": "anna", … },
      "revisionType": "MOD" },
    { "revision": { "id": "7e1…", "orderNr": "A-1000", "price": 90.8 },
      "revisionMeta": { "ref": 17, "username": "anna", … },
      "revisionType": "ADD" }
  ],
  "meta": { … } }

For this you need the read role and the history role of the model, and the model must have the history endpoint. See Reading the history.

What remains, what is gone

After the delete
Audited model
with history
  • the object is gone
  • the history remains: all revisions up to the deletion
  • who deleted it and when
  • dependent children: each with its own history, if their model is audited
  • file content and versions are gone
Non-audited model
without history
  • the object is gone
  • nothing of it remains in CDMS
  • file content is gone

For files see Deleting file models.

No rollback for deleted objects

A rollback sets an existing object back to the state of an older revision. For a deleted object this does not work:

  1. 1
    Client→CDMS
    sends POST /order/7e1…/rollback/42
  2. 2
    CDMS
    looks for the object with the read filters
  3. 3
    CDMS→Client
    no longer exists → 404 not-found|<Dto>|<id>
    Result: Nothing is created. The history stays unchanged.

An object keeps its id forever, and a deleted id is not given out again. That is why CDMS cannot bring a deleted object back under its old id. See Rolling back to an old state.

Creating an old state again

If you need a deleted object again, create it anew:

  1. 1
    Client→CDMS
    reads the history and takes the revision before the DEL revision
  2. 2
    Client→CDMS
    sends its fields without id to POST /order/create
  3. 3
    CDMS→Database
    creates a new object
    Result: The new object has a new id, a new _createdOn and a new history of its own. The old history stays under the old id. You have to create dependent children and file contents anew as well.

Pitfalls

What comes next

Sources in the code and the knowledge base
  • CDMS/cdms-persistence-database – AbstractDatabasePersistence.deleteObject (em.remove), AuditHistoryReader.queryHistory (forRevisionsOfEntity including deleted), historyRollback (history-entity-deleted)
  • CDMS/cdms-system-layer – AbstractLayer.queryHistory, AbstractSystemLayer.historyRollback (assertVisibleForWrite)
  • CDMS/cdms-integrationtest – AbstractAuditTrailTest.createPatchDeleteAreEachRecorded
  • documentation/50-auditierung/01-auditing-und-historie.md
Search