update_resource sequence
sequenceDiagram
autonumber
participant User as User
participant API as API
participant DB as DB
User->>API: PUT /resources/{resourceId}
alt Authorization ヘッダのBearer tokenが未指定、または署名・issuer・client・用途・期限を検証できない場合。
API-->>User: HTTP 401 Unauthorized<br/>authentication_required / invalid_token
end
alt Path/Query/Header/Body が型または制約に一致しない場合。
API-->>User: HTTP 422 Unprocessable Content<br/>invalid_input
end
Note over API,DB: DBの直列化競合・一意性競合・OCC競合は、rollback後に新しいsnapshotで処理順を最大12回・8秒まで再実行する。
alt 呼び出し元が資源を管理できる管理者でない場合。
API->>API: 資源管理権限がない場合の運用ログと error response を組み立てる。
API-->>User: HTTP 403 Forbidden<br/>forbidden
end
Note over API,DB: DB transaction範囲開始 (最初のDB操作からcommit/rollbackまで)
API->>DB: 同一資源の予約作成・取消と競合させるため、内部制御版を進めて資源を取得する。<br/>SQL 001_update_resources_control_version.sql<br/>テーブル resources
alt 編集対象の資源が存在しない場合。
API->>DB: DB transactionをrollbackして変更を破棄する。
API-->>User: HTTP 404 Not Found<br/>resource_not_found
end
alt 編集要求の公開版が資源の現在の公開版と一致しない場合。
API->>API: 資源の公開版が古い場合の運用ログと error response を組み立てる。
API->>DB: DB transactionをrollbackして変更を破棄する。
API-->>User: HTTP 409 Conflict<br/>stale_version
end
API->>DB: 無効化する資源に開始前の確定予約が残っているかを判定する。<br/>SQL 002_select_reservations.sql<br/>テーブル reservations
alt 無効化する資源に開始前の確定予約が残っている場合。
API->>API: 将来予約が残る資源を無効化しようとした場合の運用ログと error response を組み立てる。
API->>DB: DB transactionをrollbackして変更を破棄する。
API-->>User: HTTP 409 Conflict<br/>future_reservations_exist
end
API->>DB: 資源の名前・説明・種別・有効状態を更新し、公開版を進める。<br/>SQL 003_update_resources.sql<br/>テーブル resources
alt 更新時点で資源が存在しない場合。
API->>DB: DB transactionをrollbackして変更を破棄する。
API-->>User: HTTP 404 Not Found<br/>resource_not_found
end
API->>DB: DB transactionをcommitして変更を確定する。
API->>API: 編集後の資源のレスポンスを組み立てる。
API-->>User: HTTP 200 OK
alt Router で捕捉した例外を error response に変換する場合。
API->>API: Router で捕捉した例外を運用ログと HTTP error response に変換する。
API-->>User: HTTP 500 Internal Server Error<br/>internal server error
end
alt DBの競合や接続障害が再試行上限を超えた場合。
API-->>User: HTTP 503 Service Unavailable<br/>storage_temporarily_unavailable
end