Skip to content

OP-DOWNLOAD-BY-TRACKING-ID: Download by tracking id

Looks up a tracking record by id and returns the associated output document only when the tracked status is Succeeded and an output file path is recorded.

Field Value
Operation ID OP-DOWNLOAD-BY-TRACKING-ID
Trigger Client requests GET v1/legacy/download/{trackingId}
Entry endpoint GET v1/legacy/download/{trackingId}
Owning component LegacyController.Download(long) → PdfTrackingService.DownloadByTrackingId(long)
Inputs trackingId route segment
Outputs PdfResult (Status, Message, Document)
Failure response Caught exceptions are logged and returned as Ok(new PdfResult(message)) — HTTP 200; a missing/incomplete tracking record also returns 200 with a failure PdfResult

Steps

  1. The action wraps the call in try/catch (BR-PDFAPI-017).
  2. On any exception: _logService.LogException("pdfapi", "Download", "<detail>", ex), then Ok(new PdfResult(ex.Message)) — HTTP 200.
  3. PdfTrackingService.DownloadByTrackingId reads the PDFTracking row by Id (data model).
  4. If no row is found: an explanatory failure PdfResult is returned — HTTP 200.
  5. If the row's StatusCode is Succeeded and OutputFilePath is non-null, the file is loaded from disk into a Document and returned (BR-PDFAPI-013).
  6. Otherwise: an explanatory failure PdfResult (e.g. still processing, failed, or no output path) is returned — HTTP 200.
  7. The controller returns Ok(result).

Process flow

The following diagram shows the tracking-lookup and download-decision sequence.

flowchart TD
    A["GET v1/legacy/download/trackingId"] --> B["Read PDFTracking by Id"]
    B -->|Not found| C["Failure PdfResult, 200"]
    B -->|Found| D{"Status Succeeded and<br>OutputFilePath set?"}
    D -->|Yes| E["Load document from disk,<br>return PdfResult with Document"]
    D -->|No| F["Explanatory failure PdfResult, 200"]

Transaction and side effects

Aspect Finding
Unit of work IUnitOfWorkFactory("oracle"), InstancePerRequest (read-only)
Commit point No write — read-only Query() inside Begin()/Commit()
Records written None
Downstream calls None
Repeat-call behavior Idempotent — repeated calls return the same result while the tracking record is unchanged

Logging

Surface Written content
ILogService.LogException "pdfapi", "Download", and exception detail, on any caught failure

Error handling

  • Tracking record not found, or status not Succeeded, or OutputFilePath null: not an exception — an explanatory failure PdfResult with HTTP 200 (BR-PDFAPI-013).
  • Any other exception (e.g. trackingId fails to parse as long — route does not match): produces the framework's default routing-failure response, not this operation's envelope.

Sources

  • PdfAPI\Controllers\v1\LegacyController.cs
  • PdfAPI\Services\PdfTrackingService.cs
  • PdfAPI.Core\PdfResult.cs