# Business Logic — JKKMalwareBlockingNonFlgChengeOverCC.editResultRP() [55 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKMalwareBlockingNonFlgChengeOverCC` |
| Layer | CC / Common Component (Custom business logic common component) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKMalwareBlockingNonFlgChengeOverCC.editResultRP()

This method serves as a **service component result mapping and error-handling utility** that transforms raw service component (SC) return values into the framework's standard response representation (`IRequestParameterReadWrite`). After a downstream service component executes its business operation (in this case, a malware-blocking non-flag change-over process), `editResultRP` extracts the execution result — including status messages, return codes, and error information — and populates the request parameter object with the appropriate mappings for consumption by the calling screen or CBS.

The method implements a **result-normalization pattern**: regardless of which specific service component produced the result, this utility provides a unified mechanism to read the return status, map error details into a standardized control map, and either surface the result for the calling layer or throw an `SCCallException` to signal processing failure. It acts as a shared bridge between the service component execution layer and the screen/BPM layer, ensuring consistent error handling across the Fujitsu Futurity platform's business logic tier.

The method handles two logical branches: a **success path** where return code equals "0" and status equals 0 (normal completion, data is returned to the caller), and a **failure path** where either condition is violated (an `SCCallException` is thrown with the literal error message "Return value invalid" / "戻り値不正" in Japanese).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editResultRP(msgList, param, mapName)"])
    
    START --> S1["Extract CAANMsg[] templates from msgList TEMPLATE_LIST_KEY"]
    START --> S2["Extract return_code from msgList RET_CD_INT_KEY"]
    
    S1 --> W1["Get workMap from param.getMappingWorkArea()"]
    S2 --> W1
    
    W1 --> W2{workMap == null?}
    
    W2 -->|true| W3["workMap = new HashMap()"]
    W3 --> W4["param.setMappingWorkArea(workMap)"]
    W4 --> D1
    
    W2 -->|false| D1["Get dataMap from param.getData(mapName)"]
    
    D1 --> D2{dataMap == null?}
    
    D2 -->|true| D3["dataMap = new HashMap()"]
    D3 --> D4["param.setData(mapName, dataMap)"]
    D4 --> E1
    
    D2 -->|false| E1["CAANMsg msg = templates[0]"]
    
    E1 --> E2["int status = msg.getInt(STATUS_INT_KEY)"]
    
    E2 --> E3["param = editErrorInfo(param, templates, return_code, mapName)"]
    
    E3 --> E4["Get errList from param.getControlMapData(ERROR_INFO)"]
    
    E4 --> E5{errList == null?}
    
    E5 -->|true| E6["errList = new ArrayList<Object>()"]
    E6 --> E7
    
    E5 -->|false| E7["param.setControlMapData(ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList))"]
    
    E7 --> CHK{return_code equals 0 and status equals 0?}
    
    CHK -->|false| EXC["throw SCCallException Return value invalid, return_code, status"]
    
    CHK -->|true| RET["Return param"]
    
    EXC --> END(["terminate"])
    
    RET --> END
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `JCMConstants.TEMPLATE_LIST_KEY` | `"TEMPLATE_LIST"` (framework key) | Key to retrieve the CAANMsg array containing service component response messages |
| `JCMConstants.RET_CD_INT_KEY` | `"RET_CD_INT"` (framework key) | Key to retrieve the integer return code from the service component |
| `JCMConstants.STATUS_INT_KEY` | `"STATUS"` (framework key) | Key to retrieve the status integer from the CAANMsg template |
| `SCControlMapKeys.ERROR_INFO` | `"ERROR_INFO"` (framework key) | Key in the control map where error information list is stored/retrieved |

**Condition branch label:** `return_code == "0" && status == 0` — The SC returned normal completion (code "0") and the message status is 0 (no warnings or errors in the message body).

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `msgList` | `Map<?, ?>` | The raw result map returned from a service component (SC) call. Contains the CAANMsg template array (at `TEMPLATE_LIST_KEY`), the integer return code (at `RET_CD_INT_KEY`), and other framework-level metadata such as status messages and error details. This map is the bridge between the SC execution layer and this result-mapping utility. |
| 2 | `param` | `IRequestParameterReadWrite` | The request/response parameter object that flows through the entire BPM/screen invocation chain. This method reads and writes to the parameter's work area, data map, and control map to propagate results, error information, and metadata back to the caller. |
| 3 | `mapName` | `String` | The business data key used to identify the specific data map within the `param` object. It serves as the storage/retrieval key for the result HashMap that holds the service operation's business data. For example, it could be an operation name like `"result"` or an entity identifier specific to the calling screen. |

**External state read:** None — this method is stateless with respect to instance fields. All state is obtained through the `param` and `msgList` parameters.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| U | `JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfo` | (local CC) | - | Updates error information in `param` by invoking `editErrorInfo` with templates, return code, and map name. This is a local utility method on the same class that enriches the parameter with SC error details. |
| R | `TemplateErrorUtil.getErrorInfo` | (framework utility) | - | Reads error information from the `msgList` and existing `errList`, returning a populated error info structure to be stored in the parameter's control map. |

**Note:** This method itself does not directly invoke any Service Component (SC) or Common Business System (CBS) data access methods (no `JBS*` or `JFU*` calls). Its sole responsibility is result mapping and error handling after the caller has already executed the downstream SC. All data access (CRUD) is performed by methods in the call chain above this one (e.g., `svcKeiHikariUpd`, which calls this method after executing an SC).

## 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: `editErrorInfo` [U], `getErrorInfo` [R]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKMalwareBlockingNonFlgChengeOverCC.svcKeiHikariUpd` | `svcKeiHikariUpd()` → `editResultRP(msgList, param, mapName)` | `editErrorInfo [U]`, `getErrorInfo [R]` |

**Notes on caller:**
- `svcKeiHikariUpd` is a Same Class (SC) update method in `JKKMalwareBlockingNonFlgChengeOverCC`. It executes a service component operation for service detail (kei) Hikari broadband update processing, and then delegates to `editResultRP` to map the SC return result back into the parameter for the calling screen layer.
- No direct screen (KKSV*) entry points are found in the 8-hop caller graph. This method is exclusively a **CBS-to-CBS bridge** used internally by the custom common component layer.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] *(Extract return values from SC)* `(L560)`

> Extracts the CAANMsg template array and the integer return code from the service component result map. These are the raw result values returned from the SC invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg[] templates = (CAANMsg[])msgList.get(JCMConstants.TEMPLATE_LIST_KEY)` // Extract CAANMsg[] from msgList [→ TEMPLATE_LIST_KEY] |
| 2 | SET | `Object return_code = msgList.get(JCMConstants.RET_CD_INT_KEY)` // Extract return code [→ RET_CD_INT_KEY] |

---

**Block 2** — [IF] *(workMap null check — initialize if needed)* `(L566)`

> Ensures the work area map exists in the parameter. The work area is a shared HashMap used for cross-operation data exchange within a single request lifecycle.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map workMap = (Map)param.getMappingWorkArea()` |
| 2 | IF | `workMap == null` |

**Block 2.1** — [nested SET] *(create workMap)* `(L568)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap = new HashMap()` |
| 2 | EXEC | `param.setMappingWorkArea(workMap)` |

---

**Block 3** — [IF] *(dataMap null check — initialize if needed)* `(L574)`

> Ensures the business data map exists for the given `mapName` key. The data map holds the business result data (e.g., updated service details, record counts) that the calling screen will read.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap dataMap = null` |
| 2 | SET | `dataMap = (HashMap)param.getData(mapName)` |
| 3 | IF | `dataMap == null` |

**Block 3.1** — [nested SET] *(create dataMap)* `(L578)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataMap = new HashMap()` |
| 2 | EXEC | `param.setData(mapName, dataMap)` |

---

**Block 4** — [SET / EXEC] *(Extract message status and process errors)* `(L583)`

> Retrieves the first CAANMsg template from the array, extracts its status integer, and calls the local `editErrorInfo` method to enrich the parameter with error information from the SC response.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg msg = templates[0]` // Get first template from SC response |
| 2 | SET | `int status = msg.getInt(JCMConstants.STATUS_INT_KEY)` // Extract status [→ STATUS_INT_KEY] |
| 3 | CALL | `param = editErrorInfo(param, templates, (Integer)return_code, mapName)` // Set error information // → editErrorInfo [U] |

---

**Block 5** — [IF] *(errList null check — initialize if needed)* `(L589)`

> Ensures the error list exists in the control map before populating it. The error list accumulates error details from multiple SC calls within a transaction.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList<Object> errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO)` |
| 2 | IF | `errList == null` |

**Block 5.1** — [nested SET] *(create errList)* `(L591)`

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Object>()` |

---

**Block 6** — [EXEC] *(Set error info into control map)* `(L595)`

> Populates the error info control map with standardized error information extracted from the SC response via `TemplateErrorUtil.getErrorInfo()`.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(msgList, errList))` // Set error info // → getErrorInfo [R] |

---

**Block 7** — [IF] *(Exception on SC failure)* `(L598)`

> Validates the service component return status. If either the return code is not "0" or the message status is non-zero, throws an `SCCallException` to signal processing failure. This is the **failure/exception path**.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!("0".equals(return_code.toString()) && 0 == status)` [→ `"0"` for return code, `0` for status] |

**Block 7.1** — [nested RETURN] *(throw exception)* `(L600)`

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `throw new SCCallException("Return value invalid" (戻り値不正), return_code.toString(), status)` // Throw exception with return code and status |

---

**Block 8** — [RETURN] *(normal completion)* `(L603)`

> The success path. Both return code and status indicate normal SC completion. Returns the fully populated `param` object to the caller with business data, error information, and control map entries all set.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return parameter with mapped results |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `msgList` | Parameter | Service Component return value map — contains templates, return codes, and error metadata from an executed SC |
| `param` | Parameter | IRequestParameterReadWrite — the request/response parameter object that carries data through the BPM/screen invocation chain |
| `mapName` | Parameter | Data map key — identifies the specific business result data map within param |
| `workMap` | Field | Mapping work area — a shared HashMap for cross-operation data exchange within a single request lifecycle |
| `dataMap` | Field | Result data map — holds business result data (e.g., updated service detail records) for the calling screen |
| `templates` | Field | CAANMsg[] — array of CAANMsg objects containing service component response messages and status information |
| `msg` | Field | CAANMsg — the first message template from the SC response, used to extract status and messages |
| `return_code` | Field | Return code from SC — a string/numeric code indicating SC execution outcome ("0" = success) |
| `status` | Field | Message status integer from CAANMsg — 0 means normal, non-zero indicates warnings or errors |
| `errList` | Field | Error info list — an ArrayList that accumulates error details from SC calls within a transaction |
| `CAANMsg` | Framework class | Fujitsu Futurity framework message class — carries structured response data (messages, status, return codes) from service components |
| `SCCallException` | Framework class | Service Component Call Exception — thrown when an SC returns an error state (non-zero return code or status) |
| `editErrorInfo` | Local method | Local utility method on this CC class that enriches param with error information from the SC response |
| `TemplateErrorUtil.getErrorInfo` | Framework utility | Utility that extracts and formats error information from msgList and the existing error list |
| `JCMConstants` | Framework class | Futurity Common Constants — defines standard key constants for parameter data access (TEMPLATE_LIST_KEY, RET_CD_INT_KEY, STATUS_INT_KEY) |
| `SCControlMapKeys` | Framework class | Service Component Control Map Keys — defines keys for control map data (ERROR_INFO) |
| `IRequestParameterReadWrite` | Framework interface | Interface for the request/response parameter object used throughout the Futurity platform's BPM framework |
| SCCB | Abbreviation | Same Component Call / Service Component Callback — a common component method that wraps SC execution and result mapping |
| SC | Abbreviation | Service Component — a reusable business logic component that performs a specific data operation |
| CC | Abbreviation | Common Component — a shared component class containing cross-screen/business logic utilities |
| CBS | Abbreviation | Common Business System — a business system layer component, often a CBS-level method wrapping multiple SC calls |
| BPM | Abbreviation | Business Process Management — the framework that orchestrates screen-to-screen and screen-to-CBS invocation flow |
| "戻り値不正" | Japanese term | "Return value invalid" — the error message thrown when SC returns an unexpected return code or status |
| TEMPLATE_LIST_KEY | Constant | Framework key for retrieving CAANMsg[] from SC result map |
| RET_CD_INT_KEY | Constant | Framework key for retrieving the integer return code from SC result map |
| STATUS_INT_KEY | Constant | Framework key for retrieving the status integer from CAANMsg |
| ERROR_INFO | Constant | Control map key for storing/retrieving error information list |
