# Business Logic — FUW02301SFLogic.checkException() [75 LOC]

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

## 1. Role

### FUW02301SFLogic.checkException()

This method is the centralized exception interpretation engine for the **Mail Address Change Application** screen (FUW02301SF) within K-Opticom's customer base system. When a web service call fails with a `JCCWebServiceException`, this method inspects the structured error payload — including status codes, template identifiers, item identifiers, and error flags — to determine the correct user-facing message. It implements a **conditional routing (dispatch) pattern**, branching along two primary dimensions: the **operation mode** (`cfm` = confirmation button vs. `mskm` = submission button) and the **error category** (`EB` = check-time error requiring web-layer handling, or `EA` = system-level error requiring business-layer handling). For confirmation-mode checks, it re-throws the original service exception so the web layer can render contextual validation messages. For submission-mode checks, it transforms errors into business exceptions (`JCCBusinessException`) with specific error codes (0102 for contract-state errors, 0204 for immutability-period errors), and for any unrecognized status it defaults to a generic system error (code 0002). This dual-path design ensures the same underlying service error produces context-appropriate user feedback depending on whether the user is reviewing changes or committing them.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["checkException(se, callMethod)"])
    STEP1["Extract error info from JCCWebServiceException"]
    STEP2["msgResult = se.getMessageList()"]
    STEP3["moreInfo = msgResult.getMessageMoreInfoList()"]
    STEP4["info = moreInfo[0]"]
    STEP5["Extract: status, templateid, itemid, errFlg"]
    COND1{"1100" relation error check}
    STEP6["cfm method check"]
    COND2{"EKK0361C050 and EB and kibo_ml_account_1"}
    STEP7["throw se"]
    COND3{"EKK0361C050 and EB and mlad"}
    STEP8["throw se"]
    STEP9["Submission path EMS error check"]
    COND4{"EKK0361C050 and EB and kibo_ml_account_1"}
    STEP10["throw JCCBusinessException 0102 contract state error"]
    COND5{"EKK0361C050 and EB and mlad"}
    STEP11["throw JCCBusinessException 0102 contract state error"]
    STEP12["System error changelog period check"]
    COND6{"EKK0361C050 and EA and kibo_ml_account_1"}
    STEP13["throw JCCBusinessException 0102 contract state error"]
    STEP14["Timestamp check"]
    COND7{"EKK0361C050 and EA and upd_dtm_bf"}
    STEP15["throw JCCBusinessException 0204 update not possible error"]
    STEP16["Default throw JCCBusinessException 0002 system error"]
    END_NODE(["Method ends"])

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
    STEP5 --> COND1
    COND1 --> STEP6
    COND1 --> STEP16
    STEP6 --> COND2
    COND2 --> STEP7
    COND2 --> COND3
    COND3 --> STEP8
    COND3 --> STEP9
    STEP9 --> COND4
    COND4 --> STEP10
    COND4 --> COND5
    COND5 --> STEP12
    STEP12 --> COND6
    COND6 --> STEP13
    COND6 --> STEP14
    STEP14 --> COND7
    COND7 --> STEP15
    COND7 --> STEP16
    STEP7 --> END_NODE
    STEP8 --> END_NODE
    STEP10 --> END_NODE
    STEP11 --> END_NODE
    STEP13 --> END_NODE
    STEP15 --> END_NODE
    STEP16 --> END_NODE
```

**Constant Resolution Reference:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `JPCModelConstant.RELATION_ERR` | `1100` | Related check error status code |
| `EKK0361C050` | `"EKK0361C050"` | Error template: Option Service Contract (ISP) Information Change |
| `KIBO_ML_ACCOUNT_1` | `"kibo_ml_account_1"` | Desired Mail Account 1 (field identifier) |
| `MLAD` | `"mlad"` | Mail Address (field identifier) |
| `UPD_DTM_BF` | `"upd_dtm_bf"` | Update DateTime Before (field identifier) |
| `CALL_METHOD_CFM` | `"cfm"` | Confirmation button press mode |
| `CALL_METHOD_MSKM` | `"mskm"` | Submission button press mode |
| `JFUStrConst.RELATION_CHECK_ERR_EB` | `"EB"` | Related check error flag — check-time error |
| `JFUStrConst.RELATION_CHECK_ERR_EA` | `"EA"` | Related check error flag — system error |
| `JFUStrConst.ERROR_CODE_0002` | `"0002"` | System error (generic fallback) |
| `JFUStrConst.ERROR_CODE_0102` | `"0102"` | Contract state error |
| `JFUStrConst.ERROR_CODE_0204` | `"0204"` | Update not possible error (immutability period) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `se` | `JCCWebServiceException` | The service-level exception thrown by an upstream web service call (e.g., `invokeService()`). Carries structured error metadata: a message list containing item-level status codes, template IDs, field identifiers, and error flags. This exception is either re-thrown directly (confirmation mode) or wrapped in a business exception (submission mode). |
| 2 | `callMethod` | `String` | Identifies which button triggered the flow: `"cfm"` (confirmation button — user is reviewing changes on a preview screen) or `"mskm"` (submission button — user is committing changes). This controls whether errors are passed through to the web layer for display or transformed into business exceptions with specific error codes. |

**Instance/External State Read:**
- No instance fields are read within this method.
- No external services or database calls are made — this method performs pure exception inspection and dispatch logic.

## 4. CRUD Operations / Called Services

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

This method performs **no CRUD operations**. It exclusively inspects exception data structures and throws exceptions. All method calls are local utility calls on the exception parameter:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `se.getMessageList()` | — | — | Reads the `X31CMessageResult` from the web service exception to extract structured error metadata (no DB access). |
| R | `msgResult.getMessageMoreInfoList()` | — | — | Retrieves the array of `X31CMessageMoreInfo` objects containing per-field error details. |
| R | `info.getStatus()` | — | — | Extracts the error status code (e.g., `"1100"` for relation check errors). |
| R | `info.getTemplateId()` | — | — | Extracts the error template ID (e.g., `"EKK0361C050"` for ISP service contract changes). |
| R | `info.getItemId()` | — | — | Extracts the item/field identifier (e.g., `"kibo_ml_account_1"`, `"mlad"`, `"upd_dtm_bf"`). |
| R | `info.getItemCheckErr()` | — | — | Extracts the error flag (e.g., `"EB"` for check-time errors, `"EA"` for system errors). |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 2 methods.
Terminal operations from this method: `throw` [business exception dispatch] (7 distinct error paths)

Trace who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `FUW02301SFLogic.cfm()` | `invokeService()` -> `catch JCCWebServiceException` -> `checkException(se, CALL_METHOD_CFM)` | `throw se` (re-throw web service exception to caller) |
| 2 | Class: `FUW02301SFLogic.mskm()` | `catch JCCWebServiceException` -> `checkException(se, CALL_METHOD_MSKM)` | `throw JCCBusinessException(0102)` or `throw JCCBusinessException(0204)` |

**Caller Details:**

1. **`cfm()`** — Confirmation button handler. Invokes the web service inside a try-catch block. When a `JCCWebServiceException` is caught, it calls `checkException(se, "cfm")`. Since this is the confirmation flow, errors are evaluated for web-layer display (NG Word Check, Engineering Check). The original exception `se` is re-thrown, preserving the full error message for the presentation layer.

2. **`mskm()`** — Submission button handler. Called from the submission confirmation screen. Invokes the web service inside a try-catch block. When a `JCCWebServiceException` is caught, it calls `checkException(se, "mskm")`. Since this is the submission flow, errors are transformed into business exceptions with specific codes — contract state errors (0102) for check-time errors and update-not-possible errors (0204) for immutability-period violations.

## 6. Per-Branch Detail Blocks

**Block 1** — TRY / INIT `(error info extraction)` (L996)

Extract structured error data from the `JCCWebServiceException` parameter. The method retrieves the first (and only) message from the error list — because related check errors always produce exactly one message entry.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `se.getMessageList()` // Get the message result from the web service exception |
| 2 | CALL | `msgResult.getMessageMoreInfoList()` // Get array of detailed error info objects |
| 3 | SET | `info = moreInfo[0]` // Take first element — related check always has exactly one error entry (関連チェック系は必ずエラーが1つのため0番目から取得する) |
| 4 | CALL | `info.getStatus()` // Extract the error status code |
| 5 | CALL | `info.getTemplateId()` // Extract the error template ID |
| 6 | CALL | `info.getItemId()` // Extract the field/element identifier |
| 7 | CALL | `info.getItemCheckErr()` // Extract the error flag (EB, EA, etc.) |

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

Determine if the error is a **related check error** (関連情報). If not, skip directly to the default system error (Block 6). If yes, proceed to Block 3 to branch on the calling mode.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `String.valueOf(JPCModelConstant.RELATION_ERR).equals(status)` // Check if status is "1100" (related check error) |

**Block 2.1** — IF `(callMethod == "cfm")` `[CALL_METHOD_CFM = "cfm"]` (L1009)

**Confirmation button path** — The user is on the review/confirmation screen. Errors in this path are re-thrown as the original `JCCWebServiceException` so the web layer can render detailed validation messages with field-level context.

> Block 2.1.1 — IF `(templateid == "EKK0361C050" && errFlg == "EB" && itemid == "kibo_ml_account_1")` (L1016)

**NG Word Check** (NGワードチェック) — Validates the desired mail account (KIBO_ML_ACCOUNT_1) for prohibited words. If the error template matches, the flag is EB (check-time), and the field is the desired mail account, the original exception is re-thrown.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 (Option Service Contract ISP Info Change) |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg)` // Error flag is "EB" (check-time error) |
| 3 | EXEC | `KIBO_ML_ACCOUNT_1.equals(itemid)` // Field is "kibo_ml_account_1" (Desired Mail Account 1) |
| 4 | RETURN | `throw se` // Re-throw the original web service exception (業務例外をthrow) |

> Block 2.1.2 — IF `(templateid == "EKK0361C050" && errFlg == "EB" && itemid == "mlad")` (L1022)

**Engineering Check** (エンジニアチェック) — Validates the mail address field (MLAD). Same error propagation as NG Word Check: re-throw the original exception for web-layer rendering.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg)` // Error flag is "EB" (check-time error) |
| 3 | EXEC | `MLAD.equals(itemid)` // Field is "mlad" (Mail Address) |
| 4 | RETURN | `throw se` // Re-throw the original web service exception (業務例外をthrow) |

**Block 2.2** — ELSE `(callMethod != "cfm" => submission mode)` (L1030)

**Submission button path** — The user is committing changes. Errors are converted to business exceptions (`JCCBusinessException`) with specific error codes. This separates system errors from business-level validation errors.

> Block 2.2.1 — IF `(templateid == "EKK0361C050" && errFlg == "EB" && itemid == "kibo_ml_account_1")` (L1036)

**NG Word Check (submission mode)** — Same NG Word validation as the confirmation path, but instead of re-throwing the original exception, it throws a `JCCBusinessException` with error code 0102 (contract state error). This prevents submission when the desired mail account contains prohibited words.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg)` // Error flag is "EB" (check-time error) |
| 3 | EXEC | `KIBO_ML_ACCOUNT_1.equals(itemid)` // Field is "kibo_ml_account_1" |
| 4 | RETURN | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102)` // System error — contract state error (システムエラーをthrow（契約状態エラー）) |

> Block 2.2.2 — IF `(templateid == "EKK0361C050" && errFlg == "EB" && itemid == "mlad")` (L1042)

**Engineering Check (submission mode)** — Same Engineering validation as the confirmation path, but throws `JCCBusinessException` with error code 0102 instead of re-throwing.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EB.equals(errFlg)` // Error flag is "EB" (check-time error) |
| 3 | EXEC | `MLAD.equals(itemid)` // Field is "mlad" (Mail Address) |
| 4 | RETURN | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102)` // System error — contract state error (システムエラーをthrow（契約状態エラー）) |

**Block 2.3** — IF `(templateid == "EKK0361C050" && errFlg == "EA" && itemid == "kibo_ml_account_1")` (L1050)

**Changelog period check** (変更不可期間チェック) — Detects when the desired mail account is being modified during a protected/immutability period. This is a system-level error (flag EA), so it throws `JCCBusinessException` with code 0102 (contract state error) regardless of the calling mode.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EA.equals(errFlg)` // Error flag is "EA" (system error) |
| 3 | EXEC | `KIBO_ML_ACCOUNT_1.equals(itemid)` // Field is "kibo_ml_account_1" |
| 4 | RETURN | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0102)` // System error — contract state error (システムエラーをthrow（契約状態エラー）) |

**Block 2.4** — IF `(templateid == "EKK0361C050" && errFlg == "EA" && itemid == "upd_dtm_bf")` (L1056)

**Timestamp check** (タイムスタンプチェック) — Detects when the mail address change conflicts with another concurrent modification (detected via optimistic locking via `upd_dtm_bf` — the "update datetime before" field). Throws `JCCBusinessException` with code 0204 (update not possible error).

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `EKK0361C050.equals(templateid)` // Error template is EKK0361C050 |
| 2 | EXEC | `JFUStrConst.RELATION_CHECK_ERR_EA.equals(errFlg)` // Error flag is "EA" (system error) |
| 3 | EXEC | `UPD_DTM_BF.equals(itemid)` // Field is "upd_dtm_bf" (Update DateTime Before) |
| 4 | RETURN | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0204)` // System error — update not possible error (システムエラーをthrow（更新不可エラー）) |

**Block 3** — ELSE-FALLTHROUGH `(status != "1100" or unrecognized error)` (L1064)

For any error that does not match the known related-check pattern (RELATION_ERR = "1100"), or for any unrecognized error status, throw the generic system error. This is the catch-all default that ensures every exception path results in an exception being thrown.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new JCCBusinessException(JFUStrConst.ERROR_CODE_0002)` // System error — generic fallback for all other cases (上記以外の場合システムエラーをスロー) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `RELATION_ERR` | Constant | Related check error status code = 1100. Indicates the error originated from a cross-reference/related-data validation check. |
| `RELATION_CHECK_ERR_EA` | Constant | Related check error flag "EA" — system-level error (requires business exception transformation). |
| `RELATION_CHECK_ERR_EB` | Constant | Related check error flag "EB" — check-time error (requires web-layer display, e.g., NG word validation). |
| `EKK0361C050` | Constant | Error template ID for Option Service Contract (ISP) Information Change — the service operation whose errors are being inspected. |
| `KIBO_ML_ACCOUNT_1` | Constant | Field identifier "kibo_ml_account_1" — Desired Mail Account 1. The customer's preferred alternate email address for notifications. |
| `MLAD` | Constant | Field identifier "mlad" — Mail Address. The primary customer email address being changed. |
| `UPD_DTM_BF` | Constant | Field identifier "upd_dtm_bf" — Update DateTime Before. The timestamp of the last successful update, used for optimistic concurrency control. |
| `CALL_METHOD_CFM` | Constant | Mode identifier "cfm" — Confirmation button press. The user is reviewing changes before committing. |
| `CALL_METHOD_MSKM` | Constant | Mode identifier "mskm" — Submission button press. The user is committing changes to the database. |
| ERROR_CODE_0002 | Constant | System error code — generic fallback for unrecognized errors. |
| ERROR_CODE_0102 | Constant | Contract state error code — thrown when a contract-state violation is detected (e.g., prohibited word in mail account, changelog period conflict). |
| ERROR_CODE_0204 | Constant | Update not possible error code — thrown when a timestamp conflict prevents the update (optimistic locking violation). |
| FUW02301SF | Module | Mail Address Change Application — the web screen module for submitting mail address change requests. |
| NG Word Check | Business term | NGワードチェック — Validation that checks field values against a list of prohibited words (e.g., offensive terms, restricted patterns). |
| Engineering Check | Business term | エンジニアチェック — Validation that verifies data from a technical/engineering perspective (e.g., mail address format, deliverability). |
| JCCWebServiceException | Class | Web service exception — thrown by upstream service calls carrying structured error metadata (status, template, item, error flag). |
| JCCBusinessException | Class | Business exception — domain-specific exception with a numeric error code, used for business-level error handling. |
| X31CMessageResult | Class | Message result container — holds the list of error messages returned from a web service call. |
| X31CMessageMoreInfo | Class | Message detail info — holds per-field error metadata including status, template ID, item ID, and error flag. |
