---

# Business Logic — FUW02501SFLogic.checkException() [34 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02501SF.FUW02501SFLogic` |
| Layer | Service (Web Logic / Business Logic Layer) |
| Module | `FUW02501SF` (Package: `eo.web.webview.FUW02501SF`) |

## 1. Role

### FUW02501SFLogic.checkException()

The `checkException` method is the centralized exception-handling dispatcher for the **Homepage Access Analysis Order** (HP Access Koushi Ukeuke) business domain within the FUW02501SF screen logic. It receives a `JCCWebServiceException` thrown during upstream web service calls and performs **related-field relational checks** — interpreting structured error metadata extracted from the exception to classify and re-throw domain-specific business errors.

Specifically, the method examines three dimensions of error metadata — the template ID, item check error flag, and item ID — and maps specific combinations to precise business rules: if the error relates to an already-contracted service contract number, it throws an "already contracted" error (0103); if the error relates to a pre-update timestamp conflict (indicating the record was modified by another user), it throws an "update impossible" error (0204). Any relational error that does not match these specific combinations, or any non-relational error, falls through to a generic system error (0002).

The design pattern implemented is a **conditional error classification and dispatch** — a form of the interpreter pattern where structured exception data is matched against business rule conditions. As a private method called exclusively from `execute()`, it serves as the error-interception layer between the service component calls and the user-facing error reporting, ensuring that technical exceptions from downstream services are translated into meaningful, user-actionable business error messages.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["checkException(JCCWebServiceException se)"])
    START --> GET_MSG["Get message list from exception"]
    GET_MSG --> EXTRACT["Extract fields: templateid, itemid, status, errFlg"]
    EXTRACT --> RELATION_CHECK{"status == RELATION_ERR = 1100?"}
    RELATION_CHECK -->|true| TEMPLATE_CHECK{"templateid == EKK0411D010 AND errFlg == EG AND itemid == op_svc_kei_no?"}
    RELATION_CHECK -->|false| SYSTEM_ERROR["Throw system error (0002)"]
    TEMPLATE_CHECK -->|true| ALREADY_CONTRACTED["Throw already contracted error (0103)"]
    TEMPLATE_CHECK -->|false| TIMESTAM_CHECK{"templateid == EKK0411D010 AND errFlg == EA AND itemid == upd_dtm_bf?"}
    TIMESTAM_CHECK -->|true| UPDATE_IMPOSSIBLE["Throw update impossible error (0204)"]
    TIMESTAM_CHECK -->|false| SYSTEM_ERROR
    ALREADY_CONTRACTED --> END_NODE(["End - exception propagated"])
    UPDATE_IMPOSSIBLE --> END_NODE
    SYSTEM_ERROR --> END_NODE
```

**Processing Flow:**

1. **Exception Message Extraction**: Extract the message list from the incoming `JCCWebServiceException`, retrieve the first message's more-info metadata array, and extract four fields: `templateid`, `itemid`, `status`, and `errFlg`.
2. **Relational Error Gate**: Check if the `status` equals `RELATION_ERR` (1100). If not, skip directly to the system error (Block 3).
3. **Branch A — Already Contracted Error**: If template ID is `EKK0411D010`, error flag is `EG`, and item ID is `op_svc_kei_no`, the error indicates that the customer already has an existing service contract for this operation service — throw error code `0103`.
4. **Branch B — Update Impossible (Optimistic Lock) Error**: If template ID is `EKK0411D010`, error flag is `EA`, and item ID is `upd_dtm_bf`, the error indicates a timestamp conflict (the record's pre-update timestamp doesn't match — another user modified it) — throw error code `0204`.
5. **Fallback — System Error**: If none of the specific relational error conditions match (either the status is not `RELATION_ERR`, or a relational error occurred but doesn't match Branch A or B), throw the generic system error `0002`.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `se` | `JCCWebServiceException` | The exception thrown by an upstream web service component call during the Homepage Access Analysis Order submission flow. Contains a structured list of error messages with metadata (template ID, item ID, status, error flag) that encodes the specific business rule that was violated. |

**Instance fields read by this method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `EKK0411D010` | `String` | Template ID constant — identifies the operation service contract processing template (`"EKK0411D010"`) |
| `OP_SVC_KEI_NO` | `String` | Item ID constant — identifies the operation service contract number field (`"op_svc_kei_no"`) |
| `UPD_DTM_BF` | `String` | Item ID constant — identifies the pre-update timestamp field (`"upd_dtm_bf"`) |

## 4. CRUD Operations / Called Services

This method is a **pure error classification method** — it reads metadata from an exception object and throws business exceptions. It does **not** invoke any service components, data access methods, or database operations. No CRUD operations are performed.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCWebServiceException.getMessageList` | - | - | Reads structured error message metadata from the exception |
| R | `X31CMessageResult.getMessageMoreInfoList` | - | - | Reads the array of error more-info objects |
| R | `X31CMessageMoreInfo.getTemplateId` | - | - | Reads the error template ID |
| R | `X31CMessageMoreInfo.getItemId` | - | - | Reads the error item identifier |
| R | `X31CMessageMoreInfo.getStatus` | - | - | Reads the error status code |
| R | `X31CMessageMoreInfo.getItemCheckErr` | - | - | Reads the item check error flag |

All operations are **read-only** — extracting error metadata from an exception object. No service components, CBS, or database tables are accessed.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `getMessageList` [R], `getMessageMoreInfoList` [R], `getTemplateId` [R], `getItemId` [R], `getStatus` [R], `getItemCheckErr` [R]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | FUW02501SFLogic (internal) | `FUW02501SFLogic.execute` -> `FUW02501SFLogic.checkException` | `getMessageList [R]`, `getStatus [R]`, `getTemplateId [R]` |

**Note:** This is a private method with a single direct caller: `FUW02501SFLogic.execute()`. It is the exception-handling fallback within the homepage access analysis order submission flow (FUW02501SF). It does not reach any terminal database operations — its only terminal operations are metadata reads from the `JCCWebServiceException` object.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `Extract error metadata from exception` (L603)

> Extract the structured error information from the incoming `JCCWebServiceException`. Per the Japanese comment: "Exception information to retrieve" (例外情報を取得). The related check always produces exactly one error (関連チェック系は必ずエラーが1つ), so the first element (index 0) of the more-info array is used.

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgResult = se.getMessageList()` // Get message list from exception |
| 2 | SET | `moreInfo = msgResult.getMessageMoreInfoList()` // Get error metadata array |
| 3 | SET | `info = moreInfo[0]` // First (and only) error metadata — related check always has exactly one error |
| 4 | SET | `templateid = info.getTemplateId()` // Template ID identifying the error source template |
| 5 | SET | `itemid = info.getItemId()` // Item ID identifying the specific field in error |
| 6 | SET | `status = info.getStatus()` // Status code indicating error type |
| 7 | SET | `errFlg = info.getItemCheckErr()` // Error flag (e.g., "EG", "EA") identifying the error subtype |

**Block 2** — [IF] `(status == RELATION_ERR = "1100")` `JPCModelConstant.RELATION_ERR` (L608)

> Related check block (関連チェック). If the error status indicates a relational/field-dependency error (1100), enter the relational error classification logic. Contains two nested condition branches.

| # | Type | Code |
|---|------|------|
| 1 | SET | `isRelationErr = String.valueOf(JPCModelConstant.RELATION_ERR).equals(status)` // `RELATION_ERR = "1100"` — relational error status code |

**Block 2.1** — [IF] `templateid == EKK0411D010 AND errFlg == EG AND itemid == op_svc_kei_no` (L613)

> Upper check (上限チェック). Template ID is `EKK0411D010`, error flag is `EG`, and item ID is `op_svc_kei_no`. Per the Japanese comment: "Contracted (0103) error" (契約済み(0103)エラー) — this combination means the customer already has an existing service contract for the operation service contract number, which is a duplicate registration attempt.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cond = EKK0411D010.equals(templateid)` // `EKK0411D010 = "EKK0411D010"` — template ID for operation service contract processing |
| 2 | SET | `cond = JFUStrConst.RELATION_CHECK_ERR_EG.equals(errFlg)` // `RELATION_CHECK_ERR_EG = "EG"` — related check error EG flag |
| 3 | SET | `cond = OP_SVC_KEI_NO.equals(itemid)` // `OP_SVC_KEI_NO = "op_svc_kei_no"` — operation service contract number item |
| 4 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0103)` // `ERROR_CODE_0103 = "0103"` — Already contracted error (契約済みエラー). The service contract number already exists — duplicate registration rejected. |

**Block 2.2** — [IF] `templateid == EKK0411D010 AND errFlg == EA AND itemid == upd_dtm_bf` (L619)

> Timestamp check (タイムスタンプチェック). Template ID is `EKK0411D010`, error flag is `EA`, and item ID is `upd_dtm_bf`. Per the Japanese comment: "Update impossible (0204) error" (更新不可能(0204)エラー) — this combination indicates an optimistic lock conflict: the pre-update timestamp stored in the record has changed since the user loaded the page, meaning another user modified the record concurrently.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cond = EKK0411D010.equals(templateid)` // `EKK0411D010 = "EKK0411D010"` — same template ID |
| 2 | SET | `cond = JFUStrConst.RELATION_CHECK_ERR_EA.equals(errFlg)` // `RELATION_CHECK_ERR_EA = "EA"` — related check error EA flag |
| 3 | SET | `cond = UPD_DTM_BF.equals(itemid)` // `UPD_DTM_BF = "upd_dtm_bf"` — pre-update timestamp item |
| 4 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0204)` // `ERROR_CODE_0204 = "0204"` — Update impossible error (更新不可能エラー). Record was modified by another user — concurrent modification detected. |

**Block 3** — [ELSE-IMPLICIT] Fallback — System Error (L626)

> System error (システムエラー). This is an implicit else branch — if the status is NOT a relational error (1100), OR if it IS a relational error but does not match any of the specific condition combinations in Blocks 2.1 or 2.2, the method falls through to this final line. Per the Japanese comment: "System error" (システムエラー).

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0002)` // `ERROR_CODE_0002 = "0002"` — Generic system error (共通エラー用 システムエラー). All unmatched exceptions are classified as system errors. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `templateid` | Field | Template ID — identifies the processing template that generated the error (e.g., `EKK0411D010` = operation service contract template) |
| `itemid` | Field | Item ID — identifies the specific form field or data item that caused the validation error |
| `status` | Field | Status code — classifies the type of error (e.g., `1100` = relational error, indicating a field-dependency violation) |
| `errFlg` | Field | Error flag — a short code (e.g., `EA`, `EG`) indicating the specific subtype of a relational check error |
| `op_svc_kei_no` | Field | Operation Service Contract Number — the internal tracking number for the customer's service contract line item |
| `upd_dtm_bf` | Field | Update Date/Time Before — the pre-update timestamp used for optimistic locking to detect concurrent modifications |
| `EKK0411D010` | Constant | Template ID — identifies the operation service contract processing template used in the service contract number validation flow |
| `RELATION_ERR` | Constant | Relational error status code (`1100`) — indicates a field-dependency error (e.g., a required related field failed validation) |
| `RELATION_CHECK_ERR_EG` | Constant | Related check error flag `EG` — indicates a duplicate/existing-record error (in this context, already-contracted service contract number) |
| `RELATION_CHECK_ERR_EA` | Constant | Related check error flag `EA` — indicates a timestamp/conflict error (in this context, optimistic lock failure due to concurrent modification) |
| `ERROR_CODE_0103` | Constant | "Already contracted" error code (`0103`) — thrown when a customer attempts to register an operation service contract number that already exists |
| `ERROR_CODE_0204` | Constant | "Update impossible" error code (`0204`) — thrown when a record's optimistic lock fails (record was modified by another user between load and save) |
| `ERROR_CODE_0002` | Constant | Generic system error code (`0002`) — catch-all for system-level errors not covered by specific business rules |
| `JCCWebServiceException` | Type | Web service exception — carries structured error message metadata (template ID, item ID, status, error flag) from downstream service components |
| `X31CMessageMoreInfo` | Type | Message detail metadata — holds structured error information extracted from a web service exception |
| FUW02501SF | Module | Homepage Access Analysis Order Submission — the web screen module for submitting homepage access analysis service orders |
| HP Access Koushi Ukeuke | Business term | Homepage Access Analysis Order Submission — the business domain for customers ordering web analytics/access analysis services |
| 契約済みエラー | Japanese term | "Already contracted error" — business error indicating the customer already has an existing service contract |
| 更新不可能エラー | Japanese term | "Update impossible error" — business error indicating a record could not be updated due to concurrent modification |
| 上限チェック | Japanese term | "Upper limit check" — validation that checks business upper-bound constraints (e.g., duplicate contract existence) |
| タイムスタンプチェック | Japanese term | "Timestamp check" — validation using pre-update timestamps to detect concurrent modification (optimistic locking) |
| システムエラー | Japanese term | "System error" — generic system-level error for unclassified exceptions |
| 例外情報を取得 | Japanese comment | "Retrieve exception information" — comment describing the metadata extraction step |
| 関連チェック系は必ずエラーが1つ | Japanese comment | "Related checks always produce exactly one error" — comment explaining why index `[0]` is safely used |

---
