POST dms.request.objects.upsert.database-before (Interceptor)

As of Version2020 Winter
HTTP MethodPOST
Response FormatJSON
Predicate

The predicate is applied on all objects of the objects  list in the data part of the multipart body after enrichment. If at least one object matches, the interceptor is called.

Description

It can be triggered by

  • an object import,
  • an update of the content or
  • an update of the metadata.

The take-off point of the interceptor is after the REPOSITORY service. The initial request body is already normalized, validated and enriched with content stream properties as can be seen in the examples provided below.

The enriched multipart request body is taken by the interceptor. It always contains a data part, that contains an objects list with the metadata of the affected objects. For each object, the options section contains the action parameter that specifies the type of the call in an action code.
The predicate is applied to every single object in the list. The interceptor is triggered for the entire object list as soon as one object meets the predicate

Within the interceptor, any user-defined operation can be executed on the corresponding metadata by calling the external endpoint specified as url in the interceptor configuration. Afterwards, the modified multipart has to be routed back to continue the regular process at a suitable point.

If the interceptor should continue the regular process exactly at the take-off point, pass the multipart to http://registry/api/dms/objects.

Requirements for external endpoint The target URL must be a POST endpoint accepting a multipart request body and returning a list of objects as JSON.
Affected API Requests

POST /api/dms/objects

POST /api/dms/objects/{objectId}
PATCH /api/dms/objects/{objectId}
POST /api/dms/objects/{objectId}/contents/file

Restart Service

Repository service

HeaderAuthorization-Header

Examples

Importing Content

If an object with content is imported, the enriched multipart taken by the interceptor contains content stream properties in its data part. Depending on the document there can also be a text rendition. An import can be identified by the action with the code 100 or 101 in the options metadata section.

Data part of the original requestData part in the enriched multipart taken by the interceptor
{
  "objects" : [ {
    "properties" : {
      "system:objectTypeid" : {
        "value" : "miscellaneous"
      },
      "name" : {
        "value" : "my document"
      },
      "description" : {
        "value" : "this is a test document"
      }
    },
    "contentStreams" : [ {
      "mimeType" : "message/rfc822",
      "fileName" : "content.eml",
      "cid" : "content"
    } ]
  } ]
}
{
  "objects" : [ {
    "properties" : {
      "system:objectTypeid" : {
        "value" : "miscellaneous"
      },
      "name" : {
        "value" : "my document"
      },
      "description" : {
        "value" : "this is a test document"
      }
    },
    "contentStreams" : [ {
      "contentStreamId" : "85E76328-6651-11EB-88B6-71C8C8177575",
      "archivePath" : "default/DOCUMENT/5E/76/3/",
      "length" : 42938,
      "mimeType" : "message/rfc822",
      "fileName" : "content.eml",
      "digest" : "328B2AF519C144050A43EBBFFE21CC722C4E5A6DB40CD1DDCD5A7A54AFA6EE72",
      "repositoryId" : "repo242"
    } ],
    "renditions" : [ {
      "mimeType" : "text/plain",
      "kind" : "text",
      "contentStream" : {
        "length" : 40963,
        "mimeType" : "text/plain",
        "fileName" : "content.txt",
        "cid" : "rendition_195"
      }
    } ],
    "options" : {
      "traceid" : "a78d178f712cbd75",
      "analyzeMimeType" : true,
      "analyzeContent" : true,
      "action" : 101
    }
  } ]
}

Updating Content

A content update can be identified by the action with the code 301 in the options metadata section. Like in the import scenario, content stream properties are available in the enriched multipart, and depending on the document a text rendition can also be available.

Data part of the original requestData part in the enriched multipart taken by the interceptor

The initial request does not contain a multipart body and thus no data part can be shown here.


{
  "objects" : [ {
    "properties" : {
      "system:objectId" : {
        "value" : "50971948-019a-493f-bdf5-571e91e61236"
      },
      "system:objectTypeId" : {
        "value" : "appTest:miscellaneous"
      }
    },
    "contentStreams" : [ {
      "contentStreamId" : "9C9EDCC3-6716-11EB-B18C-A9EA85931B27",
      "archivePath" : "default/DOCUMENT/C9/ED/C/",
      "length" : 14157,
      "mimeType" : "image/jpeg",
      "fileName" : "test2.txt",
      "digest" : "998FAFD7B3045767B64463C46AB267A7DCC442E28F0FAF5D68C6A32E7DA8987F",
      "repositoryId" : "repo242"
    } ],
    "options" : {
      "currentVersion" : {
        "properties" : {
          "system:traceId" : {
            "value" : "8e57d683bdc36de5"
          },
          "system:objectTypeId" : {
            "value" : "appTest:miscellaneous"
          },
          "system:versionNumber" : {
            "value" : 3
          },
          "system:createdBy" : {
            "value" : "275c826c-6a61-4e89-9512-8d935a1631e5"
          },
          "system:creationDate" : {
            "value" : "2021-02-03T21:17:36.400Z"
          },
          "appTest:name" : {
            "value" : "my document"
          },
          "system:lastModificationDate" : {
            "value" : "2021-02-04T13:01:37.120Z"
          },
          "system:baseTypeId" : {
            "value" : "system:document"
          },
          "system:tenant" : {
            "value" : "default"
          },
          "appTest:description" : {
            "value" : "this is a new description"
          },
          "system:lastModifiedBy" : {
            "value" : "275c826c-6a61-4e89-9512-8d935a1631e5"
          },
          "system:objectId" : {
            "value" : "50971948-019a-493f-bdf5-571e91e61236"
          }
        }
      },
      "traceid" : "9a00c294eaf1e2af",
      "action" : 301
    }
  } ]
}

Updating Metadata

A metadata update can be identified by the action with the code 300 in the options metadata section of the enriched request body. Moreover, the objectId is added to the properties of the original request.

Data part of the original requestData part in the enriched multipart taken by the interceptor
{
  "objects" : [ {
    "properties" : {
      "description" : {
        "value" : "this is a new description"
      }
    }
  } ]
}
{
  "objects" : [ {
    "properties" : {
      "description" : {
        "value" : "this is a new description"
      },
      "system:objectId" : {
        "value" : "50971948-019a-493f-bdf5-571e91e61236"
      }
    },
    "options" : {
	  "action" : 300,
      "preserve_missing_properties" : true,
      "currentVersion" : {
        "properties" : {
          "system:traceId" : {
            "value" : "df4735bd88e94678"
          },
          "system:objectTypeId" : {
            "value" : "appTest:miscellaneous"
          },
          "system:versionNumber" : {
            "value" : 1
          },
          "system:createdBy" : {
            "value" : "275c826c-6a61-4e89-9512-8d935a1631e5"
          },
          "system:creationDate" : {
            "value" : "2021-02-03T21:17:36.400Z"
          },
          "appTest:name" : {
            "value" : "my document"
          },
          "system:lastModificationDate" : {
            "value" : "2021-02-03T21:17:36.400Z"
          },
          "system:baseTypeId" : {
            "value" : "system:document"
          },
          "system:tenant" : {
            "value" : "default"
          },
          "appTest:description" : {
            "value" : "this is a test document"
          },
          "system:lastModifiedBy" : {
            "value" : "275c826c-6a61-4e89-9512-8d935a1631e5"
          },
          "system:objectId" : {
            "value" : "50971948-019a-493f-bdf5-571e91e61236"
          }
        }
      }
    }
  } ]
}