# Business Logic — FUIFE194.run() [10 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.FUIFE194` |
| Layer | Controller (REST API entry point, package: `local.gyomu.api`) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### FUIFE194.run()

FUIFE194 is the business logic dispatch method for the **WEB Application Content Deletion** API. This API handles the complete deletion workflow for a customer's WEB application registration submitted through the web front end. Depending on the `func_code` value carried in the request, the method routes to different backend service paths: when `func_code` is `"3"`, it triggers a **confirmation-mode** deletion that sends a completion email and then removes the WEB application content; for any other `func_code` value (including `null` or missing), it performs a standard service operation using the primary registration service.

The method implements a **routing/dispatch pattern**, branching based on the `func_code` parameter to determine which Business Process (BP) services to invoke. It delegates all heavy lifting to `logicExecute()`, which coordinates the BP service layer via `callBpService()`. The method extracts function codes from the request body, resolves the appropriate service ID, and handles three distinct error paths: business-level exceptions from the BP layer, system-level exceptions, and business-level errors returned within the response payload. Its role in the larger system is as a **REST API entry point** for the deletion of WEB application content — specifically consumed by the deletion confirmation CC (`JFUWebMskmNyoDeleteCC`), which maps `FUNC_CODE_CONF` (value `"3"`) to this API ID (`FUIFE194`) for syslog classification.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["run(reqPartsBean)"])

    START --> L85["Generate response data"]
    L85 --> L86["logicExecute(reqPartsBean)"]

    L86 --> L103["Extract body from reqPartsBean"]
    L103 --> L104["Extract funcCode from body"]
    L104 --> COND1{"funcCode == 3"}

    COND1 -- Yes --> L109["serviceId = FUSV0356"]
    COND1 -- No --> L111["serviceId = FUSV0355"]

    L109 --> L114["Create outMap HashMap"]
    L111 --> L114

    L114 --> L116["callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)"]

    L116 --> CATCH1{ApiServerExceptionGyomuErr}
    CATCH1 -- Yes --> L120["Get existing errList from reqPartsBean"]
    L120 --> L121{"errList null or empty"}
    L121 -- Yes --> L123["Create errMap with errCode 3001"]
    L123 --> L126["throw ApiServerExceptionGyomuErr"]
    L121 -- No --> L126

    CATCH1 -- No --> CATCH2{General Exception}
    CATCH2 -- Yes --> L132["Create errList with errCode 3001"]
    L132 --> L133["Set errList on reqPartsBean"]
    L133 --> L134["throw ApiServerExceptionGyomuErr"]

    CATCH2 -- No --> L140["Extract resultMap from outMap"]
    L140 --> L143["Get errInfo from resultMap"]
    L143 --> COND2{"errInfo != null and is List"}

    COND2 -- Yes --> L146["Set errList from errInfo"]
    L146 --> L149["Set errList on reqPartsBean"]
    L149 --> L152["Remove ERROR_INFO from resultMap"]
    L152 --> L155["Set body to resultMap on reqPartsBean"]
    L155 --> L156["throw ApiServerExceptionGyomuErr"]

    COND2 -- No --> COND3{"funcCode == 3"}

    COND3 -- Yes --> L160["Set body to resultMap on reqPartsBean"]
    L160 --> L161["serviceId = FUSV0360"]
    L161 --> L162["callBpService(FUSV0360) - Send completion email"]
    L162 --> L165["Set body to resultMap on reqPartsBean"]
    L165 --> L166["serviceId = FUSV0369"]
    L166 --> L167["callBpService(FUSV0369) - Delete web application content"]

    COND3 -- No --> L171["Create resPartsBean"]
    L167 --> L171
    L171 --> L172["Set body to resultMap on resPartsBean"]
    L172 --> END(["Return resPartsBean"])

    L126 --> END
    L134 --> END
    L156 --> END
```

**CRITICAL — Constant Resolution:**
- Branch on `funcCode == "3"` resolves to `JFUMkmInfoAddFrontiaConstCC.FUNC_CODE_CONF = "3"` (Confirmation function code — triggers deletion post-confirmation flow: send completion email, then delete WEB application content).
- `SERVICE_ID_1 = "FUSV0355"` — Primary service for WEB application content registration/operation.
- `SERVICE_ID_2 = "FUSV0356"` — Service used when `funcCode` is `"3"` (confirmation-mode primary operation).
- `SERVICE_ID_3 = "FUSV0360"` — Completion email dispatch service (invoked only when `funcCode` is `"3"`).
- `SERVICE_ID_4 = "FUSV0369"` — WEB application content deletion service (invoked only when `funcCode` is `"3"`).
- `SYSTEM_ID = "FTR1"` — Preceding system ID (Frontia).
- `JOB_ID = "FUIFE194"` — Job identifier for BP service invocation.
- `_01CC = "01CC"` — Suffix used to key the CC (Component Container) response map within the output.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `reqPartsBean` | `ApiServerPartsBean` | The request payload carrying WEB application deletion data. Contains a `body` map with at least a `func_code` key. `func_code` value `"3"` indicates the deletion is being performed after confirmation (confirmation-mode deletion flow). Other values or null indicate a standard operation. Also carries error lists (`errList`) and may contain business data fields relevant to the WEB application content registration/deletion domain. |

**Instance fields / external state read by this method:**
| Field | Type | Business Description |
|-------|------|---------------------|
| `SERVICE_ID_1` | `String` (constant: `"FUSV0355"`) | Default service ID for standard WEB application operations |
| `SERVICE_ID_2` | `String` (constant: `"FUSV0356"`) | Confirmation-mode service ID for WEB application operations |
| `SERVICE_ID_3` | `String` (constant: `"FUSV0360"`) | Completion email dispatch service ID |
| `SERVICE_ID_4` | `String` (constant: `"FUSV0369"`) | WEB application content deletion service ID |
| `SYSTEM_ID` | `String` (constant: `"FTR1"`) | Preceding system identifier (Frontia platform) |
| `JOB_ID` | `String` (constant: `"FUIFE194"`) | Job identifier for BP service routing |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `FUIFE194.logicExecute` | FUIFE194 | - | Main business logic delegate — resolves service ID, invokes BP services, processes results and errors |

The `run()` method itself delegates entirely to `logicExecute()`, which in turn calls `callBpService()` (defined in `ApiServerLocalBase`) to invoke BP layer services. The actual CRUD operations are performed by the downstream BP services, not directly visible in this 10-LOC method. The services invoked are:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| (delegated) | `callBpService(SERVICE_ID_1=...)` | FUSV0355 | - | Primary WEB application content operation service (standard mode) |
| (delegated) | `callBpService(SERVICE_ID_2=...)` | FUSV0356 | - | Primary WEB application content operation service (confirmation mode) |
| (delegated) | `callBpService(SERVICE_ID_3=...)` | FUSV0360 | - | Send completion email to customer |
| (delegated) | `callBpService(SERVICE_ID_4=...)` | FUSV0369 | - | Delete WEB application content from the system |
| (delegated) | `JFUWebMskmNyoDeleteCC` | CC | - | Common component for deleting WEB application content records (invoked by FUSV0369) |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | REST API: FUIFE194 | `execute(HttpServletRequest, ServletContext)` -> `super.exec(APIID, ...)` -> `mainExec(reqPartsBean)` -> `run(reqPartsBean)` | `callBpService(FUSV0355/FUSV0356)`, `callBpService(FUSV0360)`, `callBpService(FUSV0369)` |
| 2 | CC: JFUWebMskmNyoDeleteCC | References `FUIFE194` as process ID for syslog (funcCode=CONF branch) | Logs deletion activity via `JCCSyslogFormat.logger("FUIFE194", ...)` |

**Call chain detail:**
- The `execute()` method (annotated with `@POST` at `@Path("FUIFE194")`) is the REST entry point. It calls `super.exec("FUIFE194", pRequest, pContext)` which invokes the framework's request processing, eventually calling `mainExec(reqPartsBean)` in `ApiServerLocalBase`, which delegates to `run(reqPartsBean)`.

## 6. Per-Branch Detail Blocks

### Block 1 — METHOD (run entry) (L83)

> The run method entry point. Generates response data by delegating to logicExecute and returns it.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `logicExecute(reqPartsBean)` // business logic delegate [-> ApiServerPartsBean] |
| 2 | RETURN | `return resPartsBean` // returns the processed response |

### Block 2 — NESTED: logicExecute(funcCode resolution) (L103)

> Extracts the function code from the request body and resolves the service ID based on the confirmation flag.

| # | Type | Code |
|---|------|------|
| 1 | SET | `body = reqPartsBean.getBody()` // extracts the request body map |
| 2 | SET | `funcCode = (String)body.get("func_code")` // gets the function code key [-> "func_code"] |
| 3 | SET | `serviceId = null` // initialization |
| 4 | IF | [funcCode == "3" (FUNC_CODE_CONF)] (L106) |
| 5 | ELSE | [funcCode != "3" or null] (L110) |

**Block 2.1** — IF `[funcCode == "3"]` `[JFUMkmInfoAddFrontiaConstCC.FUNC_CODE_CONF="3"]` (L106)

> When funcCode is "3" (confirmation mode), uses SERVICE_ID_2 (FUSV0356) for the primary service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `serviceId = SERVICE_ID_2` // = "FUSV0356" [CONFIRMATION_MODE_SERVICE] |

**Block 2.2** — ELSE `[funcCode != "3" or null]` (L110)

> When funcCode is not "3" (standard mode), uses SERVICE_ID_1 (FUSV0355) for the primary service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `serviceId = SERVICE_ID_1` // = "FUSV0355" [STANDARD_SERVICE] |

### Block 3 — PROCESSING (L114)

> Creates the output map and invokes the BP service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `outMap = new HashMap<String, Object>()` // initializes output container |
| 2 | TRY | `try { outMap = callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID) }` // invokes BP service [-> FUSV0355 or FUSV0356] |

### Block 4 — CATCH: Business Exception (L119)

> Handles `ApiServerExceptionGyomuErr` — a business-level error thrown by the BP service.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Object>()` // creates new error list |
| 2 | SET | `errList = reqPartsBean.getErrList()` // retrieves existing error list from request |
| 3 | IF | [errList == null || errList.size() == 0] (L121) |

**Block 4.1** — IF `[errList is null or empty]` (L121)

> If no existing errors, create a default error entry with code 3001.

| # | Type | Code |
|---|------|------|
| 1 | SET | `returnMap = new HashMap<String, String>()` |
| 2 | EXEC | `returnMap.put("errCode", "3001")` // default business error code |
| 3 | EXEC | `returnMap.put("errMessage", "")` // empty message field |
| 4 | EXEC | `errList.add(returnMap)` // adds the default error to the list |

> No matter the branch, re-throw the business exception.

| # | Type | Code |
|---|------|------|
| 5 | THROW | `throw new ApiServerExceptionGyomuErr(reqPartsBean)` |

### Block 5 — CATCH: System Exception (L130)

> Handles general `Exception` — a system-level error from the BP service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Object>()` |
| 2 | SET | `returnMap = new HashMap<String, String>()` |
| 3 | EXEC | `returnMap.put("errCode", "3001")` // default error code for system error |
| 4 | EXEC | `returnMap.put("errMessage", "")` |
| 5 | EXEC | `errList.add(returnMap)` |
| 6 | SET | `reqPartsBean.setErrList(errList)` // sets error list on request bean |
| 7 | THROW | `throw new ApiServerExceptionGyomuErr(reqPartsBean)` |

### Block 6 — PROCESSING (L140)

> After successful BP service call, extracts the result map and checks for business errors embedded in the response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `resultMap = (Map<String, Object>)outMap.get(serviceId + _01CC)` // extracts result by serviceId + "01CC" [-> "01CC"] |
| 2 | SET | `errInfo = resultMap.get(ApiBpInterface.ERROR_INFO)` // gets error info from result [-> ApiBpInterface.ERROR_INFO] |
| 3 | IF | [errInfo != null && errInfo instanceof List] (L144) |

**Block 6.1** — IF `[errInfo is non-null List]` (L144)

> When the BP service returned errors embedded in the response payload (not via exception).

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = (List<Object>)errInfo` // casts error info to error list |
| 2 | SET | `reqPartsBean.setErrList(errList)` // sets errors back to request bean |
| 3 | EXEC | `resultMap.remove(ApiBpInterface.ERROR_INFO)` // removes error info from result map |
| 4 | SET | `reqPartsBean.setBody(resultMap)` // updates request body with cleaned result |
| 5 | THROW | `throw new ApiServerExceptionGyomuErr(reqPartsBean)` // throws business exception with error details |

### Block 7 — IF: Post-Processing (funcCode == "3") (L159)

> When funcCode is "3" (confirmation mode), performs post-processing: send completion email, then delete WEB application content.

| # | Type | Code |
|---|------|------|
| 1 | SET | `reqPartsBean.setBody(resultMap)` // prepares request body for email dispatch |
| 2 | SET | `serviceId = SERVICE_ID_3` // = "FUSV0360" [COMPLETION_EMAIL_SERVICE] |
| 3 | CALL | `callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)` // dispatch completion email |
| 4 | SET | `reqPartsBean.setBody(resultMap)` // prepares request body for deletion |
| 5 | SET | `serviceId = SERVICE_ID_4` // = "FUSV0369" [DELETE_CONTENT_SERVICE] |
| 6 | CALL | `callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)` // deletes WEB application content |

### Block 8 — RESPONSE SETUP (L171)

> Constructs and returns the response bean, regardless of which branch was taken.

| # | Type | Code |
|---|------|------|
| 1 | SET | `resPartsBean = new ApiServerPartsBean()` |
| 2 | SET | `resPartsBean.setBody(resultMap)` // sets the processed result on response |
| 3 | RETURN | `return resPartsBean` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `func_code` | Field | Function code — dispatch key that determines the processing mode. Value `"3"` (CONF) triggers the post-confirmation deletion flow; other values use the standard operation path. |
| `FUIFE194` | API ID | WEB Application Content Deletion API — handles deletion of WEB application registrations submitted via the web front end. |
| FUSV0355 | Service ID | Primary WEB application content operation service (standard mode). |
| FUSV0356 | Service ID | Primary WEB application content operation service (confirmation mode, used when funcCode is "3"). |
| FUSV0360 | Service ID | Completion email dispatch service — sends a confirmation email after deletion is finalized. |
| FUSV0369 | Service ID | WEB application content deletion service — performs the actual deletion of WEB application content records. |
| JFUWebMskmNyoDeleteCC | CC Class | Common Component for WEB application content deletion — the caller CC that references FUIFE194 for syslog classification in the confirmation flow. |
| FUNC_CODE_CONF | Constant | Confirmation function code — value `"3"`, defined in `JFUMkmInfoAddFrontiaConstCC`. When this value is set, the API enters confirmation-mode deletion flow. |
| FTR1 | System ID | Preceding system identifier — refers to the Frontia platform, the upstream system in the service chain. |
| ApiServerPartsBean | Bean | Request/response container for the business AP integration layer. Holds body data, error lists, and API metadata. |
| ApiServerExceptionGyomuErr | Exception | Business-level exception class — thrown when a service operation encounters a business error (as opposed to a system error). |
| ApiBpInterface.ERROR_INFO | Constant key | Key used to store/retrieve error information in the BP service response map. |
| _01CC | Constant | Suffix `"01CC"` appended to service ID to form the map key for the Component Container (CC) response data within the BP service output. |
| WEB Application Content | Domain term | Customer-registered content data managed through the WEB application registration system. Deletion of this content is the core business operation of this API. |
| Confirmation Mode | Business term | The post-confirmation deletion flow triggered by funcCode `"3"`. After the primary operation completes, a completion email is sent and the WEB application content record is deleted. |
