# Business Logic — FUIFE194.execute() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `local.gyomu.api.FUIFE194` |
| Layer | Controller (JAX-RS REST API endpoint, extends `ApiServerLocalBase`) |
| Module | `api` (Package: `local.gyomu.api`) |

## 1. Role

### FUIFE194.execute()

FUIFE194 is a public REST API endpoint that handles customer-requested service contract operations within K-Opticom's telecom service billing platform (Fiber-to-the-Home and related broadband services). The method serves as the sole entry point for POST requests directed at the `/FUIFE194` path, acting as an API routing/dispatch controller that delegates processing to the base framework's execution pipeline.

Upon invocation, the method delegates to `super.exec(APIID, pRequest, pContext)`, which triggers the framework's `mainExec` chain: `mainExec` -> `run` -> `logicExecute`. The core business logic lives in `logicExecute`, which reads a `func_code` from the request body to dispatch to one of four backend BP (Business Platform) services. When `func_code` is `"3"` (application completion flow), it sequentially invokes two additional downstream services — the application completion mail notification service and the WEB application content deletion service — beyond the initial primary service call.

The method implements a layered delegation pattern: the REST endpoint layer (`execute`) is thin, passing responsibility to the framework pipeline, which in turn calls the domain-specific `logicExecute` method that orchestrates cross-service invocations, error handling, and response assembly. Its role in the larger system is that of an API gateway handler for customer service contract lifecycle management, specifically handling both initial service registration/changes and post-completion cleanup/notifications.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["execute(pRequest, pContext)"])
    START --> CALL["exec(APIID, pRequest, pContext)"]
    CALL --> RUN["run(reqPartsBean)"]
    RUN --> LOGIC["logicExecute(reqPartsBean)"]
    LOGIC --> GETBODY["Get func_code from body map"]
    GETBODY --> COND1{funcCode equals 3}
    COND1 -- "No" --> SID1["serviceId = SERVICE_ID_1"]
    COND1 -- "Yes" --> SID2["serviceId = SERVICE_ID_2"]
    SID1 --> CALLSV1["callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID)"]
    SID2 --> CALLSV1
    CALLSV1 --> TRY{Execution success}
    TRY -- "ApiServerExceptionGyomuErr" --> ERR_PROC1["Collect error info, add errCode 3001"]
    TRY -- "Other Exception" --> ERR_PROC2["Add errCode 3001, set error list on bean"]
    TRY -- "Success" --> GETRESULT["Get resultMap from outputMap"]
    GETRESULT --> CHECKERR{Has error info}
    CHECKERR -- "Yes" --> REMOVEERR["Remove ERROR_INFO, set errList, throw"]
    CHECKERR -- "No" --> FUNCCOND{funcCode equals 3}
    FUNCCOND -- "Yes" --> MAILSEND["serviceId = SERVICE_ID_3, callBpService"]
    MAILSEND --> REMWEB["serviceId = SERVICE_ID_4, callBpService"]
    REMWEB --> RESPONSE1["Create response bean, set body, return"]
    FUNCCOND -- "No" --> RESPONSE1
    ERR_PROC1 --> THROW1["throw ApiServerExceptionGyomuErr"]
    ERR_PROC2 --> THROW2["throw ApiServerExceptionGyomuErr"]
    REMOVEERR --> THROW3["throw ApiServerExceptionGyomuErr"]
    THROW1 --> END(["Return Response"])
    THROW2 --> END
    THROW3 --> END
```

**Service ID Resolution (Constants):**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `SERVICE_ID_1` | `"FUSV0355"` | Primary service registration/change processing |
| `SERVICE_ID_2` | `"FUSV0356"` | Alternative primary service processing (used when func_code is "3") |
| `SERVICE_ID_3` | `"FUSV0360"` | Application completion mail notification service |
| `SERVICE_ID_4` | `"FUSV0369"` | WEB application content deletion service |
| `SYSTEM_ID` | `"FTR1"` | Source system ID (Fiber-to-the-Home frontend) |
| `JOB_ID` | `"FUIFE194"` | Job identifier for BP traceability |
| `APIID` | `"FUIFE194"` | API endpoint identifier |

**Requirements:**
- The method branches on `func_code` from the request body: value `"3"` routes to `SERVICE_ID_2` (FUSV0356), while any other value routes to `SERVICE_ID_1` (FUSV0355).
- After the primary service call, error conditions are handled at three layers: BP-level business errors (`ApiServerExceptionGyomuErr`), generic system exceptions, and business-level error info embedded in the result map.
- When `func_code` is `"3"`, two additional service calls are made in sequence: the completion notification (FUSV0360) followed by content deletion (FUSV0369).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `pRequest` | `@Context final HttpServletRequest` | The HTTP request object carrying the API invocation context. Contains the request body (as `ApiServerPartsBean`) which includes the `func_code` field — a business discriminator that determines which service type is invoked and whether post-completion notification/cleanup steps are triggered. |
| 2 | `pContext` | `@Context final ServletContext` | The servlet context providing server-level runtime information (application scope, deployment metadata) passed through to the framework's execution pipeline for session and configuration resolution. |

**External state / instance fields referenced:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `APIID` | `static final String` | API identifier `"FUIFE194"` — used as the invocation key throughout the execution pipeline |
| `SERVICE_ID_1` | `static final String` | Primary service ID `"FUSV0355"` — default service for func_code values other than "3" |
| `SERVICE_ID_2` | `static final String` | Alternative service ID `"FUSV0356"` — used when func_code equals "3" |
| `SERVICE_ID_3` | `static final String` | Completion notification service ID `"FUSV0360"` — triggered only when func_code is "3" |
| `SERVICE_ID_4` | `static final String` | WEB content deletion service ID `"FUSV0369"` — triggered only when func_code is "3" |
| `SYSTEM_ID` | `static final String` | Source system identifier `"FTR1"` — identifies the calling system as Fiber-to-the-Home frontend |
| `JOB_ID` | `static final String` | Job identifier `"FUIFE194"` — used for audit trail and job tracking in the BP layer |

## 4. CRUD Operations / Called Services

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

The `execute()` method delegates to `super.exec(APIID, pRequest, pContext)`, which triggers the `logicExecute()` method. All actual CRUD/service invocations occur within `logicExecute()` via `callBpService()`.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callBpService(SERVICE_ID_1)` | FUSV0355 | Service contract processing entity | Calls primary service for service registration/change — invoked when func_code is not "3" |
| R | `callBpService(SERVICE_ID_2)` | FUSV0356 | Service contract processing entity | Calls alternative primary service — invoked when func_code equals "3" |
| R | `callBpService(SERVICE_ID_3)` | FUSV0360 | Mail notification entity | Sends application completion notification mail — invoked only when func_code equals "3" |
| R | `callBpService(SERVICE_ID_4)` | FUSV0369 | WEB application content entity | Deletes WEB application registration content — invoked only when func_code equals "3" |

**Classification notes:**
- All four services are invoked via `callBpService()` which internally calls `ApiBpInterface.invokeService()` to route requests through the BP (Business Platform) EJB layer.
- These are service-level invocations (R) — they query/process existing service data through the BP layer. The actual CRUD operations (create/read/update/delete) on database tables are encapsulated within each BP service component and are not directly visible from this API endpoint.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | REST Client (HTTP) | HTTP POST `/FUIFE194` -> JAX-RS Dispatcher -> `FUIFE194.execute` | `FUSV0355` / `FUSV0356` / `FUSV0360` / `FUSV0369` (BP service calls) |

**Notes on caller analysis:**
- `FUIFE194` is annotated with `@Path("FUIFE194")` and `@POST`, meaning it is a REST endpoint invoked directly by HTTP POST requests from external clients (likely the general web service frontend, as indicated by the change log: "general web service application function reconstruction API creation").
- No internal Java callers were found — this is a top-level API entry point, not called by other Java classes.
- The upstream processing chain within the class: `execute()` -> `super.exec()` -> `mainExec()` -> `run()` -> `logicExecute()` -> `callBpService()`.

## 6. Per-Branch Detail Blocks

**Block 1** — [Method Entry] (L70)

> The public REST endpoint method. Accepts the HTTP request and servlet context.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `super.exec(APIID, pRequest, pContext)` // Invokes base framework execution pipeline [-> APIID="FUIFE194"] |
| 2 | RETURN | `return response;` // Returns the HTTP Response from the framework pipeline |

**Block 2** — [Private Method: logicExecute] (L100)

> Core business logic that dispatches to the correct BP service based on func_code, handles errors, and processes completion flows.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<String, Object> body = reqPartsBean.getBody();` // Extracts request body map |
| 2 | SET | `String funcCode = (String)body.get("func_code");` // Reads func_code discriminator from body |
| 3 | SET | `String serviceId = null;` // Declares service ID variable |

**Block 2.1** — [IF/ELSE-IF] `(funcCode equals "3")` [ODR_NAIYO_CD_101="3"] (L104)

> Determines which primary service to invoke based on the function code discriminator.

| # | Type | Code |
|---|------|------|
| 1 | SET | `serviceId = SERVICE_ID_2;` // "3" -> use alternative primary service [-> "FUSV0356"] |
| 2 | SET | `serviceId = SERVICE_ID_1;` // else -> use default primary service [-> "FUSV0355"] |

**Block 2.2** — [Processing] (L108)

> Prepares output map for the BP service response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<String, Object> outMap = new HashMap<String, Object>();` // Creates output map |

**Block 2.3** — [TRY-CATCH] (L109)

> Invokes the BP service and handles errors at three levels: business errors, system errors, and business-level error info in results.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `outMap = callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID);` // Invokes BP service [-> JOB_ID="FUIFE194", SYSTEM_ID="FTR1"] |

**Block 2.3.1** — [CATCH: ApiServerExceptionGyomuErr] (L111)

> Handles BP-level business exceptions. Collects existing error list or creates a new one with error code 3001.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<Object> errList = new ArrayList<Object>();` // Creates new error list |
| 2 | EXEC | `errList = reqPartsBean.getErrList();` // Retrieves existing error list from request bean |
| 3 | IF | `if (errList == null || errList.size() == 0)` // Checks if error list is empty |
| 4 | SET | `Map<String, String> returnMap = new HashMap<String, String>();` // Creates error map |
| 5 | SET | `returnMap.put("errCode", "3001");` // Sets business error code |
| 6 | SET | `returnMap.put("errMessage", "");` // Sets empty error message |
| 7 | EXEC | `errList.add(returnMap);` // Adds error entry to list |
| 8 | RETURN | `throw new ApiServerExceptionGyomuErr(reqPartsBean);` // Re-throws with error context |

**Block 2.3.2** — [CATCH: Exception] (L124)

> Handles general system exceptions. Always adds error code 3001 to the error list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<Object> errList = new ArrayList<Object>();` // Creates new error list |
| 2 | SET | `Map<String, String> returnMap = new HashMap<String, String>();` // Creates error map |
| 3 | SET | `returnMap.put("errCode", "3001");` // Sets error code for system error |
| 4 | SET | `returnMap.put("errMessage", "");` // Sets empty error message |
| 5 | EXEC | `errList.add(returnMap);` // Adds error to list |
| 6 | EXEC | `reqPartsBean.setErrList(errList);` // Sets error list on request bean |
| 7 | RETURN | `throw new ApiServerExceptionGyomuErr(reqPartsBean);` // Re-throws |

**Block 2.4** — [Processing] (L135)

> Extracts the result map from the BP service output.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<String, Object> resultMap = (Map<String, Object>)outMap.get(serviceId + _01CC);` // Gets result under key "FUSVxxxx01CC" [-> _01CC="01CC"] |

**Block 2.5** — [Processing] (L138)

> Retrieves error information from the result map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object errInfo = resultMap.get(ApiBpInterface.ERROR_INFO);` // Gets error info [-> ERROR_INFO="ERROR_INFO"] |

**Block 2.6** — [IF] `(errInfo != null && errInfo instanceof List<?>)` (L140)

> Checks if the BP service returned business-level error information embedded in the result map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `List<Object> errList = (List<Object>)errInfo;` // Casts error info to list |
| 2 | EXEC | `reqPartsBean.setErrList(errList);` // Sets error list on request bean |
| 3 | EXEC | `resultMap.remove(ApiBpInterface.ERROR_INFO);` // Removes error info from result map |
| 4 | EXEC | `reqPartsBean.setBody(resultMap);` // Sets body on request bean |
| 5 | RETURN | `throw new ApiServerExceptionGyomuErr(reqPartsBean);` // Throws business exception |

**Block 2.7** — [IF] `(funcCode equals "3")` [ODR_NAIYO_CD_101="3"] (L151)

> When func_code is "3", performs post-completion processing: sends completion notification mail, then deletes WEB application content.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `reqPartsBean.setBody(resultMap);` // Sets body on request bean |
| 2 | SET | `serviceId = SERVICE_ID_3;` // Switches to completion notification service [-> "FUSV0360"] |
| 3 | CALL | `callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID);` // Sends completion notification mail |
| 4 | EXEC | `reqPartsBean.setBody(resultMap);` // Sets body on request bean |
| 5 | SET | `serviceId = SERVICE_ID_4;` // Switches to content deletion service [-> "FUSV0369"] |
| 6 | CALL | `callBpService(serviceId, reqPartsBean, JOB_ID, SYSTEM_ID);` // Deletes WEB application content |

**Block 2.8** — [Processing] (L162)

> Constructs and returns the response bean with the processed result data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ApiServerPartsBean resPartsBean = new ApiServerPartsBean();` // Creates response bean |
| 2 | EXEC | `resPartsBean.setBody(resultMap);` // Sets body with result data |
| 3 | RETURN | `return resPartsBean;` // Returns the processed response |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `func_code` | Field | Function code discriminator — determines which service processing branch to take. Value "3" indicates the application completion flow. |
| APIID | Field | API Identifier — the unique ID used to identify this REST endpoint within the execution framework. |
| SERVICE_ID_1 | Constant | Primary service ID "FUSV0355" — the default service invoked for standard func_code values. Handles initial service registration/change processing. |
| SERVICE_ID_2 | Constant | Alternative service ID "FUSV0356" — invoked when func_code equals "3". Handles a variant of service registration/change processing specific to the completion flow. |
| SERVICE_ID_3 | Constant | Application completion notification service ID "FUSV0360" — sends a completion notification mail to the customer after service registration is finalized. |
| SERVICE_ID_4 | Constant | WEB application content deletion service ID "FUSV0369" — removes WEB application registration content from the system after completion processing. |
| SYSTEM_ID | Constant | Source System ID "FTR1" — identifies the calling system as the Fiber-to-the-Home (FTTH) frontend application. |
| JOB_ID | Constant | Job ID "FUIFE194" — used for audit trail, logging, and job tracking throughout the BP (Business Platform) processing chain. |
| `_01CC` | Constant | CC key suffix "01CC" — used as a map key prefix to access cross-component data in the BP service output (e.g., "FUSV035501CC"). |
| ERROR_INFO | Constant | Error info map key "ERROR_INFO" — used to store and retrieve business error information embedded in the BP service result map. |
| `errCode` | Field | Error code in the error list — "3001" indicates a generic error returned when error information is missing or malformed. |
| ApiServerPartsBean | Class | Server parts bean — carries request/response data between the REST layer and the BP service layer. Contains body map and error list. |
| ApiBpInterface | Class | BP (Business Platform) interface — the common interface for invoking BP services via `invokeService()`. Provides error code and message extraction utilities. |
| ApiServerExceptionGyomuErr | Class | Business exception — thrown when a business-level error occurs (BP service error, error info in result, or system exception). |
| ApiServerLocalBase | Class | Local base class — abstract class providing the API execution framework including `exec`, `mainExec`, `run`, and `callBpService` methods. |
| BP | Acronym | Business Platform — the enterprise service layer (EJB-based) that contains the actual business logic components for service processing. |
| callBpService | Method | BP service invocation method — delegates to `ApiBpInterface.invokeService()` to call BP services. Sets up parameter maps with the service ID prefix and invokes the service. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. FTR1 (source system ID) represents the FTTH frontend system. |
| K-Opticom | Business term | Telecom service provider — the company whose service billing platform this codebase implements. |
| POST | HTTP Method | HTTP POST method used to invoke the REST endpoint. Annotated with `@POST` on the `execute` method. |
| `@Context` | JAX-RS Annotation | JAX-RS context injection annotation — provides access to HttpServletRequest and ServletContext instances. |
| `@Path("FUIFE194")` | JAX-RS Annotation | JAX-RS path annotation — maps HTTP requests to the `/FUIFE194` endpoint. |
| `@POST` | JAX-RS Annotation | JAX-RS method annotation — indicates this method handles POST requests. |
