Problem/Motivation

As a developer, I want a DamExceptionHandler shared service and AssetMediaSyncService in the parent acquia_dam module. This makes DAM exception translation reusable by any API client and shares media sync logic between the cron queue worker and the webhook controller without duplication.

Context

DamExceptionHandler and AssetMediaSyncService live in the parent acquia_dam module. They cost nothing when the webhook submodule is disabled.

This story extracts existing exception handling into a standalone service and creates a new shared sync service.

Acceptance criteria

DamExceptionHandler

  • DamExceptionHandler::handle(\Exception $exception): never
    • Extracted from AcquiaDamClient::throwDamException()
    • Maps GuzzleHttp\Exception\ClientException → DamClientException
    • Maps ConnectException → DamConnectException
    • Maps all others → DamServerException
    • Logs via injected LoggerInterface
    • never return type
  • DamExceptionHandler registered as acquia_dam.exception_handler with @logger.channel.acquia_dam
  • AcquiaDamClient
    • Injects DamExceptionHandler as constructor param 7, before optional $domain
    • All internal catch blocks delegate to $this->exceptionHandler->handle($e)
    • throwDamException() method removed
  • AcquiaDamClientFactory
    • Injects @acquia_dam.exception_handler
    • Forwards it to new AcquiaDamClient(...)
  • acquia_dam_update_9025()
    • Calls \Drupal::service('kernel')->invalidateContainer()
    • Needed for container rebuild for new service and updated factory wiring

AssetMediaSyncService

  • AssetMediaSyncService::syncAsset(string $asset_id, int|string $media_id, int $user_id = 0): bool
    • Extracts the full media update logic from MediaItemUpdater::processItem()
    • Includes cache bust
    • Includes DAM API fetch
    • Includes field updates
    • Includes file download, if configured
    • Includes version resolution
    • Includes revision save
    • Includes NewAssetVersionEvent dispatch
  • AssetMediaSyncService registered as acquia_dam.asset_media_sync in acquia_dam.services.yml
  • MediaItemUpdater::processItem()
    • Delegates entirely to AssetMediaSyncService::syncAsset()
    • No duplicated logic

Issue fork acquia_dam-3611282

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajeshreeputra created an issue. See original summary.

rajeshreeputra’s picture

Status: Active » Needs review

Requesting review.

  • rajeshreeputra committed 9c7253fc on 1.1.x
    Resolve #3611282 "Create DamExceptionHandler and AssetMediaSyncService...
rajeshreeputra’s picture

Status: Needs review » Fixed

MR merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • rajeshreeputra committed 9c7253fc on 1.1.x-webhook
    Resolve #3611282 "Create DamExceptionHandler and AssetMediaSyncService...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.