Skip to content

OP-012: Reserve an image id and write a document with its index sidecar

QueueImage is invoked over the Imaging route on SAIF.Services.WCF.Services.ImagingService; this page documents the process end to end, from route dispatch to the message the caller receives.

Field Value
Operation ID OP-012
Trigger Caller invokes QueueImage over the Imaging route.
Entry operation QueueImage
Owning component SAIF.Services.WCF.Services.ImagingService.QueueImage
Inputs Request message parts listed below
Outputs The reserved image id assigned to the queued document.
Failure behavior Generic SOAP fault, per Faults and error pipeline

Request and response

Direction Element Type Declared in Notes
Request file byte[] BCL (System) Document bytes to persist. (Yes)
Request fileExtension string BCL (System) Extension for the persisted document; normalized to a leading .. (Yes)
Request imageConfig ImageConfig External contracts assembly (SAIF.Services.WCF.Contracts / framework closure) ** Imaging metadata controlling folder selection and the .idx sidecar content. (Yes)
Request environment ApplicationEnvironment External contracts assembly (SAIF.Services.WCF.Contracts / framework closure) ** Caller-supplied environment value; not guarded by Enforce. (Yes)
Request taskConfig ImageTaskConfig External contracts assembly (SAIF.Services.WCF.Contracts / framework closure) ** Optional task metadata passed through to the .idx sidecar; observed C# implementation signature is ImageTaskConfig taskConfig = null (No (C# default null)). SOAP-level optionality and any wire default cannot be confirmed without the external IImagingService contract/WSDL.**
Response long long BCL (System) The reserved image id assigned to the queued document.

Steps

  1. Constructor resolves the Oracle IMG connection, evaluates ImagingHelper.IsClaimDatabase(imagingConnectionString) into the unused useClaimDatabase flag, opens the unit of work, and constructs a FileService (BR-WCF-002).
  2. Enforce.ArgumentNotNull(file), Enforce.ArgumentNotNullOrWhiteSpace(fileExtension), Enforce.ArgumentNotNull(imageConfig); note environment is not guarded (BR-WCF-023).
  3. On failure: ArgumentNullException, logged and surfaced as a generic SOAP fault.
  4. ReserveImageId() delegates to unitOfWork.GetRepository<Image>().GetNextImageId(), outside any transaction, so the id is consumed even if a later step fails (BR-WCF-024).
  5. WriteFileWithIdx generates a GUID file name (BR-WCF-025) and resolves wcf.importqueuelocation, wcf.useobimportpriorityfolders, and one of wcf.lowpriorityfolder / wcf.medpriorityfolder chosen by imageConfig.SystemGeneratedFlag (BR-WCF-026).
  6. EnsureFullPath normalizes the extension to a leading . and the directory to a trailing \ (BR-WCF-027).
  7. Delegate to FileService.WriteFile to write the document bytes (BR-WCF-004).

    Origin: This step is implemented in WriteFile and executed within this operation.

  8. Delegate to FileService.WriteFile again to write the sidecar .idx file containing imageConfig.ToIDXFileString(imageId, taskConfig) as ASCII (BR-WCF-028); a failure here leaves the document file present without its index.*

    Origin: This step is implemented in WriteFile and executed within this operation.

  9. Return imageId.
  10. On failure: logged by the installed error handler, surfaced as a generic SOAP fault; nothing is rolled back because no transaction and no compensating delete exist.

Process flow

The following diagram visualizes this process's control flow.

flowchart TD
    A["Resolve IMG connection, open unit<br>of work, construct FileService"]
    B["Validate file, fileExtension,<br>and imageConfig arguments"]
    C["Reserve next image id"]
    D["Resolve queue folder and<br>generate GUID file name"]
    E["Normalize extension and directory path"]
    F["Write document bytes to file"]
    G["Write .idx sidecar file"]
    H["Return imageId."]
    A --> B
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G
    G --> H

Transaction and side effects

Aspect Finding
Unit of work OracleUnitOfWorkFactory (IMG) for the id reservation; no transaction wraps the file writes
Commit point Not applicable — no Begin/Commit around the file-system work
Records written Image (id reservation only)
Downstream calls File system (import queue)
Shared state touched None
Repeat-call behavior Each call reserves a new id and writes new files; not idempotent

Logging

Surface Written content
ErrorLogErrorHandler → LogService Failure-path exception logging only, carrying method signature, calling user and exception detail; see Faults and error pipeline

Faults and error handling

Failure Fault type the caller receives Produced by Source
ArgumentNullException Generic SOAP fault The operation itself, via Enforce src/WCF/SAIF.Services.WCF.Host/Services/ImagingService.cs
Oracle/NHibernate exception during id reservation Generic SOAP fault The ErrorLogErrorHandler installed by [LogErrorBehavior] src/WCF/SAIF.Services.WCF.Host/Services/ImagingService.cs
Filesystem exception during the document or sidecar write Generic SOAP fault The ErrorLogErrorHandler installed by [LogErrorBehavior] src/WCF/SAIF.Services.WCF.Host/Services/FileService.cs

Authorization

Requirement Enforced by Source Applies to
None in code IIS authentication on the deployment (see Activation and hosting) src/WCF/SAIF.Services.WCF.Host/Services/ImagingService.cs This operation

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • src/WCF/SAIF.Services.WCF.Host/Services/FileService.cs
  • src/WCF/SAIF.Services.WCF.Host/Services/ImagingService.cs