# Business Logic — JKKCmpMalwareBlockingApiCC.editErrorInfoCom() [63 LOC]

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

## 1. Role

### JKKCmpMalwareBlockingApiCC.editErrorInfoCom()

This method is a **shared error-information consolidation utility** used by the malware-blocking API component to standardize how service component (SC) return status codes and error messages are propagated back through the request parameter object. It operates as a post-SC-call bridge: after a downstream service component invocation (via the enclosing `callSC` method), `editErrorInfoCom` receives the SC response template along with the original return code, normalizes the status code through a lookup-table mechanism (the `RETURN_MESSAGE_*` constant map), and ensures that only a higher-priority status code is written into the control map data — preventing lower-priority errors from overwriting more critical ones. It also iterates over caller-supplied error field mappings (contents entries whose names end with `_err`) and copies any non-blank error codes from the SC template into the user-data map, effectively bridging SC-level error codes back to the screen-level data model. As a private delegation method, it implements the **template-based message resolution pattern** and the **priority-comparison update pattern**, serving all SC-call sites within `JKKCmpMalwareBlockingApiCC` and, by code-sharing convention, similar utility classes.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfoCom(params)"])
    START --> GET_TEMPLATE["Extract templates[0] as template"]
    GET_TEMPLATE --> GET_STATUS["Get templateStatus = template.getInt(STATUS_INT_KEY)"]
    GET_STATUS --> CHECK_RETURN{"returnCode != 0?"}
    CHECK_RETURN -->|true| SET_STATUS["Set templateStatus = 9000"]
    CHECK_RETURN -->|false| CHECK_CONST["Check JCMAPLConstMgr for RETURN_MESSAGE_{templateStatus}"]
    SET_STATUS --> CHECK_CONST
    CHECK_CONST --> CONST_NULL{"ConstMgr returns null?"}
    CONST_NULL -->|true| RESET_STATUS["Set templateStatus = 0"]
    CONST_NULL -->|false| GET_BP_STATUS
    RESET_STATUS --> GET_BP_STATUS["Get bpStatus = param.getControlMapData(RETURN_CODE)"]
    GET_BP_STATUS --> BP_NULL{"obj == null?"}
    BP_NULL -->|true| SET_BP_NEG1["Set bpStatus = -1"]
    BP_NULL -->|false| PARSE_BP["Parse bpStatus = Integer.parseInt(obj)"]
    SET_BP_NEG1 --> COMPARE{"templateStatus > bpStatus?"}
    PARSE_BP --> COMPARE
    COMPARE -->|true| FORMAT["Format templateStatus as 4-digit string"]
    FORMAT --> FETCH_MSG["Fetch message = JCMAPLConstMgr.getString(RETURN_MESSAGE_{formatStatus})"]
    FETCH_MSG --> SET_CTRL_CODE["param.setControlMapData(RETURN_CODE, formatStatus)"]
    SET_CTRL_CODE --> SET_CTRL_MSG["param.setControlMapData(RETURN_MESSAGE, message)"]
    SET_CTRL_MSG --> GET_DATA
    COMPARE -->|false| GET_DATA["Get inMap = param.getData(dataMapKey)"]
    GET_DATA --> LOOP_CHECK{"i < contents.length AND contents != null?"}
    LOOP_CHECK -->|true| GET_ITEM["Extract itemNm = contents[i][0]"]
    GET_ITEM --> SUFFIX_CHECK{"itemNm endsWith('_err')?"}
    SUFFIX_CHECK -->|true| GET_ERR["errCd = template.getString(itemNm)"]
    GET_ERR --> ERR_BLANK{"errCd is null/blank?"}
    ERR_BLANK -->|false| PUT_ERR["inMap.put(itemNm, errCd)"]
    ERR_BLANK -->|true| INC_I["i++"]
    PUT_ERR --> INC_I
    SUFFIX_CHECK -->|false| INC_I
    INC_I --> LOOP_CHECK
    LOOP_CHECK -->|false| END_RETURN["Return param"]
    END_RETURN --> END(["editErrorInfoCom end"])
```

**Processing flow summary:**

1. **Extract SC template** — Take the first element from the `templates` array (the primary response message) and read its status code using `JCMConstants.STATUS_INT_KEY`.
2. **Override on explicit return code** — If the caller passed a non-zero `returnCode`, force the template status to `9000` (a generic failure indicator). This ensures the caller's error diagnosis takes precedence.
3. **Validate status against lookup table** — Attempt to look up a message for the current status code in the constant manager. If no message exists (`null`), reset `templateStatus` to `0` (success/no error).
4. **Read current BP status** — Get the existing business-process return code from the control map data. If it is absent (`null`), treat the current BP status as `-1` (meaning any template status will win).
5. **Priority comparison** — Only update the control map if the template's status is strictly greater than the existing BP status. This implements a "highest-wins" policy: once a critical error is recorded, less severe errors are ignored.
6. **Map error fields** — Iterate over the `contents` array; for each entry whose name ends with `_err`, extract the corresponding error code from the SC template and copy it into the user-data map. This bridges SC-level field-level error codes back into the request's data payload.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The live request parameter object that carries control map data (return code, return message, error info list) and user-level data (the `dataMapKey` payload). It is both read and mutated — error status and messages are written back into it. |
| 2 | `templates` | `CAANMsg[]` | An array of Service Component response messages. The first element (`templates[0]`) is the primary response template containing field-level error codes (retrieved via `getString(key)`) and a top-level status code (`STATUS_INT_KEY`). This is the raw output from a downstream SC invocation. |
| 3 | `returnCode` | `int` | The integer return code from the SC call. If non-zero, it signals that the SC reported an error, causing the method to override the template's status to `9000` (generic failure). A value of `0` means the SC returned success and the original template status is preserved. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the user-data `Map<String, String>` from `param.getData()`. This map holds the business data that flows between the screen and the SC. Error codes are written into this map keyed by the `_err` field names. |
| 5 | `mappingData` | `Object[][]` | A mapping table passed through from the caller (typically field-name-to-field-name mappings between screen data and SC input data). This method reads the parameter but does not directly access `mappingData` in the body — it is accepted for API compatibility with overloaded variants. |
| 6 | `contents` | `Object[][]` | A 2D array where each row is `[fieldName, ...]`. Entries whose first column (index 0) ends with `_err` designate error fields. The method iterates these, extracts the error code from the SC template for each matching field, and copies it into the user-data map. If `contents` is `null`, the iteration is skipped. |

**External state / instance fields:** None. The method is fully stateless — it operates only on its parameters and delegates to static constant managers and external utility classes.

## 4. CRUD Operations / Called Services

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

This method performs **no direct database or entity operations**. All calls are utility / data-accessor methods on the parameter object, the CAANMsg template, and constant/message lookups.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `template.getInt(JCMConstants.STATUS_INT_KEY)` | — | — | Reads the top-level status code from the SC response template |
| R | `JCMAPLConstMgr.getString(key)` | — | — | Looks up a human-readable message from the constant manager for a given status code key |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | — | — | Reads the current business-process return code from control map data |
| R | `param.getData(dataMapKey)` | — | — | Retrieves the user-data map (business-level data container) from the request parameter |
| — | `JKKStringUtil.isNullBlank(str)` | — | — | Validates whether a string is null or blank (utility check, not data access) |
| U | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, value)` | — | — | Writes the selected status code back into control map data |
| U | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, value)` | — | — | Writes the resolved human-readable message back into control map data |
| U | `inMap.put(itemNm, errCd)` | — | — | Copies an SC-level error code into the user-data map for the calling screen |

**Call chain context:** This method is called from `JKKCmpMalwareBlockingApiCC.callSC()`, which in turn is invoked by SC-specific methods (e.g., `ekk0081a010SC`, `ekk0091a010SC`, `ekk0091c040SC`, `ekk1091d010SC`, `ekk0011d020SC`, `ekk0021c060SC`) that perform the actual Create/Read/Update database operations against entities such as `KK_T_KMKYO`, `KK_T_KMKYO_KET`, `KK_T_EKK0081A010MA`, `KK_T_EKK0091A010MA`, `KK_T_EKK0091C040MA`, `KK_T_EKK1091D010MA`, `KK_T_EKK0011D020MA`, and `KK_T_EKK0021C060MA`.

## 5. Dependency Trace

This method is a **private utility** within `JKKCmpMalwareBlockingApiCC`. It has **no public callers** outside its class. The pre-computed call graph indicates 83 methods with `editErrorInfoCom` in their name across the codebase, but these are independent overloaded variants in different classes (each class defines its own `editErrorInfoCom` signature).

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCmpMalwareBlockingApiCC.callSC()` | `ekk0081a010SC()` / `ekk0091a010SC()` / ... -> `callSC()` -> `editErrorInfoCom()` | `template.getInt [R]`, `ConstMgr.getString [R]`, `param.setControlMapData [U]`, `inMap.put [U]` |

**Note:** The `callSC()` method is the sole caller within `JKKCmpMalwareBlockingApiCC`. `callSC()` itself is called by the six SC wrapper methods (`ekk0081a010SC`, `ekk0091a010SC`, `ekk0091c040SC`, `ekk1091d010SC`, `ekk0011d020SC`, `ekk0021c060SC`), each of which corresponds to a specific service component call for malware-blocking operations. The SC wrapper methods are in turn called by screen CBS classes (e.g., `JKKSBT...` screens).

**Terminal operations reached from this method:**

| Terminal Call | Type | Business Effect |
|--------------|------|-----------------|
| `template.getInt(STATUS_INT_KEY)` | R | Reads SC response status |
| `JCMAPLConstMgr.getString(...)` | R | Resolves status message text |
| `param.getControlMapData(RETURN_CODE)` | R | Reads current BP return code |
| `param.getData(dataMapKey)` | R | Reads user data map |
| `JKKStringUtil.isNullBlank(...)` | — | Null/blank validation |
| `param.setControlMapData(RETURN_CODE, ...)` | U | Writes selected status code to control map |
| `param.setControlMapData(RETURN_MESSAGE, ...)` | U | Writes resolved message to control map |
| `inMap.put(itemNm, errCd)` | U | Copies field-level error code to user data |

## 6. Per-Branch Detail Blocks

### Block 1 — Extract template and initial status (L849)

> Retrieves the primary response template from the SC and reads its status code. This establishes the baseline status before any overrides.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg template = templates[0]` // Extract the primary SC response message |
| 2 | SET | `int templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Read the status code from the SC template |

**Constants referenced:** `JCMConstants.STATUS_INT_KEY` — Key to retrieve the integer status code from a CAANMsg template (exact value: external Fujitsu library constant, used to read the SC response status field).

---

### Block 2 — Return code override (L852–854)

> If the SC returned a non-zero return code (indicating an error at the SC-call level), override the template status to `9000`. This is a generic "failure" code that ensures the caller's explicit error diagnosis takes priority over the template's own status.

| # | Type | Code |
|---|------|------|
| 1 | IF | `0 != returnCode` [Condition: SC call reported an error] (L852) |
|   | SET | `templateStatus = 9000` // Override template status to 9000 (generic failure) [-> 9000] (L853) |

---

### Block 3 — Status code validation against message lookup table (L856–858)

> Before using the template status, verify that a corresponding human-readable message exists in the constant manager. If no message is defined for this status code, reset `templateStatus` to `0` (success). This prevents the system from reporting a status code that has no associated message, which would indicate a misconfiguration.

| # | Type | Code |
|---|------|------|
| 1 | IF | `null == JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus))` [Condition: No message exists for this status] (L856) |
|   | SET | `templateStatus = 0` // Reset to success status since no message exists [-> 0] (L857) |

**Constants referenced:** `"RETURN_MESSAGE_{status_code}"` — A dynamically constructed key (e.g., `RETURN_MESSAGE_0000`, `RETURN_MESSAGE_9000`) used to look up human-readable messages in the constant manager. The status code is zero-padded to 4 digits using `String.format("%1$04d", templateStatus)`.

**Constants referenced:** `JCMAPLConstMgr` — External Fujitsu constant manager class. Provides `getString(String key)` for message lookup.

---

### Block 4 — Current BP return code retrieval (L860–870)

> Retrieve the business process's current return code from the control map data. The control map carries metadata about the request lifecycle (return code, return message, error info list). If no return code is stored (first time through or cleared), default `bpStatus` to `-1`, which guarantees that any positive `templateStatus` will win the comparison in the next block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int bpStatus = 0` // Initialize BP status to 0 (success) [-> 0] (L860) |
| 2 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read current BP return code (L862) |
| 3 | IF | `null == obj` [Condition: No BP return code is stored] (L863) |
|   | SET | `bpStatus = -1` // Default to -1 so any template status wins (L864) |
| 4 | ELSE | (else-branch) (L865) |
|   | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse existing return code (L867) |

**Constants referenced:** `SCControlMapKeys.RETURN_CODE` — Key used to store and retrieve the business-process return code in the control map data (exact value: external Fujitsu library constant).

---

### Block 5 — Priority comparison and error info update (L872–882)

> The core business rule: only update the control map if the SC's template status is **strictly higher** than the current BP status. This implements a "highest-wins" error propagation policy — once a critical error is recorded, less severe errors from subsequent SC calls are silently ignored. If the condition is met, format the status as a 4-digit string, look up its message, and write both into the control map.

| # | Type | Code |
|---|------|------|
| 1 | IF | `templateStatus > bpStatus` [Condition: SC status is higher priority than current BP status] (L872) |
|   | SET | `String formatStatus = String.format("%1$04d", templateStatus)` // Zero-pad to 4 digits (L874) |
|   | SET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Look up human-readable message (L876) |
|   | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Write selected status code (L878) |
|   | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Write human-readable message (L879) |

**Constants referenced:** `SCControlMapKeys.RETURN_CODE` — Key to store the return code in control map data.

**Constants referenced:** `SCControlMapKeys.RETURN_MESSAGE` — Key to store the return message text in control map data.

---

### Block 6 — User data map retrieval (L884–885)

> Retrieve the user-data map from the request parameter using the `dataMapKey`. This map holds business-level data (not control metadata) and is where field-level error codes will be written in the next block.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Map<String, String> inMap = null` // Declare user data map variable (L884) |
| 2 | SET | `inMap = (Map<String, String>)param.getData(dataMapKey)` // Get user data map [-> dataMapKey is caller-defined key] (L886) |

---

### Block 7 — Error field iteration loop (L888–898)

> Iterate over the `contents` array to find fields marked as error fields (names ending with `_err`). For each error field, extract the error code from the SC template and, if non-blank, write it into the user-data map. This bridges SC-level field errors back into the screen-level data model.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (int i = 0; null != contents && i < contents.length; i++)` [Loop over contents array, guarded against null] (L888) |
|   | SET | `String itemNm = (String)contents[i][0]` // Extract field name from contents[row][0] (L889) |
| 2 | IF | `itemNm.endsWith("_err")` [Condition: Field is an error field] (L890) |
|   | SET | `String errCd = (String)template.getString(itemNm)` // Extract error code from SC template for this field (L891) |
| 3 | IF | `!JKKStringUtil.isNullBlank(errCd)` [Condition: Error code is present and non-blank] (L892) |
|   | EXEC | `inMap.put(itemNm, errCd)` // Copy error code into user data map (L893) |

**Constants referenced:** `"_err"` — Suffix convention indicating that a field name represents an error field (e.g., `name_err`, `address_err`). This is a naming convention used across the codebase to designate fields whose values contain error codes rather than business data.

**Constants referenced:** `JKKStringUtil.isNullBlank(str)` — Utility method to check if a string is `null` or blank (empty/whitespace-only). Returns `true` if the string is null or blank, `false` if it contains actual content.

---

### Block 8 — Return (L899)

> Return the parameter object (which has been mutated with the selected status code, message, and error field mappings) to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return the enriched parameter object (L899) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `param` | Parameter | Request parameter object — carries both control map metadata (return code, message, error info) and user-level data (business data map keyed by `dataMapKey`). Used throughout the framework to pass request/response data. |
| `templates` | Parameter | SC response message array — produced by the Service Component invocation (`callSC`). Contains field-level values retrievable via `CAANMsg.getString(key)` and a top-level status code. |
| `returnCode` | Parameter | SC return code — integer status returned from the service component. `0` means success; non-zero indicates an error. |
| `dataMapKey` | Parameter | User data map key — the key used to identify the business data container within the request parameter. Different calls may use different keys (e.g., `fixedText`, dynamic keys). |
| `bpStatus` | Internal | Business process status — the current status code stored in the control map, representing the highest-priority status recorded so far for this request. |
| `templateStatus` | Internal | Template status — the status code extracted from the SC response template, or `9000` if the caller's return code indicated an error. |
| `formatStatus` | Internal | Zero-padded status string — the template status formatted as a 4-digit zero-padded string (e.g., `0900`), used as a key into the constant manager's message lookup table. |
| `itemNm` | Internal | Item name — the field name from the `contents` array, used to identify error fields by their `_err` suffix. |
| `errCd` | Internal | Error code — the error code string extracted from the SC template for a specific error field. |
| `JCMConstants.STATUS_INT_KEY` | Constant | Template status key — the key used to read the integer status code from a CAANMsg template. Exact value: external Fujitsu library constant. |
| `SCControlMapKeys.RETURN_CODE` | Constant | Control map return code key — the key used to store and retrieve the return code in the request parameter's control map. Exact value: external Fujitsu library constant. |
| `SCControlMapKeys.RETURN_MESSAGE` | Constant | Control map return message key — the key used to store the human-readable return message in the control map. Exact value: external Fujitsu library constant. |
| `SCControlMapKeys.ERROR_INFO` | Constant | Control map error info key — used to store the aggregated error info list (referenced in the calling `callSC` method, not in this method directly). Exact value: external Fujitsu library constant. |
| `JCMConstants.TEMPLATE_LIST_KEY` | Constant | Template list key — key used in `callSC` to retrieve the `CAANMsg[]` templates array from the SC result. Exact value: external Fujitsu library constant. |
| `JCMConstants.RET_CD_INT_KEY` | Constant | Return code integer key — key used in `callSC` to retrieve the integer return code from the SC result. Exact value: external Fujitsu library constant. |
| `JCMAPLConstMgr` | Constant class | Constant manager utility — a shared static class that provides message lookups via `getString(String key)`. Used to resolve status codes to human-readable messages. Exact implementation: external Fujitsu library. |
| `JKKStringUtil.isNullBlank()` | Utility | Null/blank check — validates whether a string is null or contains only whitespace. Used to skip writing empty error codes into the user data map. |
| `_err` suffix | Naming convention | Error field naming pattern — any field name ending with `_err` denotes a field whose value contains an error code rather than business data. Used to identify which SC template fields should be mapped into the user data. |
| `9000` | Status code | Generic failure status — forced template status when the SC call returns a non-zero return code. Indicates a non-specific error. |
| `0` | Status code | Success status — template status when no error is indicated (either the SC returned 0, or the status code has no corresponding message in the lookup table). |
| `-1` | Status code | Sentinel value — used as the default `bpStatus` when no return code is stored in the control map, ensuring any positive template status will win the comparison. |
| `CAANMsg` | Framework class | Fujitsu CAAN framework message class — provides `getString(key)` and `getInt(key)` methods to access message field values. Used as the SC response container. |
| `IRequestParameterReadWrite` | Framework interface | Fujitsu CAAN framework interface for request parameters — provides `getData()`, `getControlMapData()`, and `setControlMapData()` methods for bidirectional data access. |
| SC (Service Component) | Architecture concept | A Service Component is a backend module in the Fujitsu CAAN architecture that encapsulates a specific business operation (database CRUD, external API call, etc.) and communicates via message objects (`CAANMsg`). |
| CC (Common Component) | Architecture concept | A Common Component is a utility/support class in the CAAN architecture that provides shared functionality (error handling, data transformation, validation) across screens and business components. |
| `callSC()` | Wrapper method | Private method in `JKKCmpMalwareBlockingApiCC` that invokes a service component, calls `editErrorInfoCom` to process the response, and handles error aggregation. |
