text: const { addDraftDataFromExistingDraft } = require('../utils/handlerUtils')
  const { isDraftActivateAction } = require('../utils/draftUtils')
  
  /**
   * Generic Handler for before UPDATE requests.
   */
  const _handler = async function (req) {
    if (isDraftActivateAction(req)) return
  
    const result = await addDraftDataFromExistingDraft(req, this)
  
    // means that draft not exists
    if (result.length === 0) req.reject(404)
  }
  
  const { ODATA, COMMON } = require('../../../common/constants/annotation')
  const _relevant = e => e[ODATA.DRAFT] || e[COMMON.DRAFT_NODE.PREP_ACTION]
  
  module.exports = function () {
    _handler._initial = true
  
    for (const entity of Object.values(this.entities).filter(_relevant)) {
      this.before(['PATCH', 'UPDATE'], entity, _handler)
    }
  }
  