# Business Logic — JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfoCom() [66 LOC]

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

## 1. Role

### JKKMalwareBlockingNonFlgChengeOverCC.editErrorInfoCom()

This method is a private utility used in the **Malware Blocking Data Migration** common component. Its business purpose is to assemble and inject error information into the request parameter object (`IRequestParameterReadWrite`) so that calling screens or CBS handlers can display or process error messages after a service component execution.

The method performs three core business operations: (1) it resolves the appropriate status code by comparing the template's service component status against the business process's current baseline status — promoting the higher of the two, and potentially overriding it to `9000` if a non-zero return code was passed; (2) it looks up the corresponding localized error message via the `JCMAPLConstMgr` resource manager, keyed by `RETURN_MESSAGE_` followed by the zero-padded 4-digit status code; (3) it iterates over the `contents` array, identifies fields marked as error items (suffix `_err`), and populates them into the user data map (`inMap`) with their resolved error codes from the template.

This method follows the **delegation pattern**: it does not implement service component logic itself but instead routes error data from templates and service responses into a structured parameter object consumed by the caller (`callSC()`). Its role in the larger system is to serve as a shared error-handling bridge between service component executions and the requesting screen/batch entry point, ensuring consistent error status resolution and message formatting across the malware blocking data migration feature.

The method implements a **promote-the-worst-status** design: if the service component (`returnCode`) signals an error (non-zero), the template status is forced to `9000`. Then, if the template's own status exceeds the baseline business process status (`bpStatus`), the method promotes the template's status and message into the control map, ensuring the most severe status always wins.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfoCom start"])

    t1["t1: Get template = templates[0]"]
    t2["t2: templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)"]

    c1{"returnCode != 0?"}
    set1["set1: templateStatus = 9000"]

    c2{"Return message exists for RETURN_MESSAGE_ + format(templateStatus)?"}
    set2["set2: templateStatus = 0"]

    set3["set3: bpStatus = 0"]
    c3{"obj == null?"}
    set4["set4: bpStatus = -1"]
    set5["set5: bpStatus = Integer.parseInt(obj)"]

    c4{"templateStatus > bpStatus?"}
    set6["set6: formatStatus = String.format(RETURN_MESSAGE_FORMAT, templateStatus)"]
    set7["set7: message = JCMAPLConstMgr.getString(RETURN_MESSAGE_STRING + formatStatus)"]
    set8["set8: param.setControlMapData(RETURN_CODE, formatStatus)"]
    set9["set9: param.setControlMapData(RETURN_MESSAGE, message)"]

    set10["set10: inMap = null"]
    set11["set11: inMap = param.getData(dataMapKey) cast to HashMap"]
    set12["set12: i = 0"]
    c5{"contents != null && i < contents.length?"}
    set13["set13: itemNm = contents[i][0]"]
    c6{"itemNm endsWith '_err'?"}
    set14["set14: errCd = template.getString(itemNm)"]
    c7{"errCd is not null/blank?"}
    set15["set15: inMap.put(itemNm, errCd)"]
    inc1["inc1: i++"]

    END_NODE(["Return param"])

    START --> t1 --> t2 --> c1
    c1 -- true --> set1 --> c2
    c1 -- false --> c2
    c2 -- false --> set2 --> set3
    c2 -- true --> set3
    set1 --> c2
    set3 --> c3
    c3 -- true --> set4 --> set5
    c3 -- false --> set5
    set4 --> c4
    set5 --> c4
    c4 -- true --> set6 --> set7 --> set8 --> set9 --> set10
    c4 -- false --> set10
    set9 --> set10 --> set11 --> set12 --> c5
    c5 -- true --> set13 --> c6
    c5 -- false --> END_NODE
    c6 -- true --> set14 --> c7
    c6 -- false --> inc1
    c7 -- true --> set15 --> inc1
    c7 -- false --> inc1
    set14 --> c7
    set15 --> inc1
    inc1 --> c5
```

**CRITICAL — Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|-----------------|
| `RETURN_MESSAGE_FORMAT` | `"%1$04d"` | Zero-padded 4-digit integer format string (e.g., status `9000` becomes `"9000"`, status `1` becomes `"0001"`) |
| `ERRITEM_SUFFIX` | `"_err"` | Suffix appended to item names to designate error fields in the `contents` array |
| `RETURN_MESSAGE_STRING` | `"RETURN_MESSAGE_"` | Prefix used to construct resource bundle keys for error message lookup (e.g., `"RETURN_MESSAGE_9000"`) |
| `JCMConstants.STATUS_INT_KEY` | `String` key | Constant key used to retrieve the status code integer from the `CAANMsg` template |
| `SCControlMapKeys.RETURN_CODE` | `String` key | Key used to store the formatted return status code in the parameter's control map |
| `SCControlMapKeys.RETURN_MESSAGE` | `String` key | Key used to store the human-readable error message in the parameter's control map |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries the entire request context — control map data (return code, message) and user data maps. It is both read from and written to throughout the method, serving as the primary data carrier between the service component and the caller. |
| 2 | `templates` | `CAANMsg[]` | An array of `CAANMsg` objects containing message templates and error codes. Element `[0]` is the primary template used to retrieve the status code (`JCMConstants.STATUS_INT_KEY`) and error item values. Each CAANMsg entry maps field names to error code strings (e.g., `field_err` -> `"E001"`). |
| 3 | `returnCode` | `int` | The return code from the executed service component. A value of `0` indicates success; any non-zero value triggers a status override to `9000`, signaling that the service component encountered an error condition. This code drives the "promote-the-worst-status" logic. |
| 4 | `dataMapKey` | `String` | The key used to retrieve the user data `HashMap` from the `param` object via `param.getData(dataMapKey)`. This map holds the business data that error codes will be injected into. |
| 5 | `mappingData` | `Object[][]` | Mapping data passed into the method but not used within `editErrorInfoCom` itself. Likely retained for API compatibility with similar methods in the component hierarchy. |
| 6 | `contents` | `Object[][]` | An array of object arrays where each row represents a field definition. `contents[i][0]` holds the item name (String) — fields whose names end with the `"_err"` suffix are treated as error items, and their corresponding error codes are extracted from the template and placed into the user data map. |

**Instance fields / external state read:**

| Source | Description |
|--------|-------------|
| `JCMAPLConstMgr.getString()` | Static resource manager — reads from the application's resource bundle to resolve message keys like `"RETURN_MESSAGE_9000"` into human-readable Japanese error messages. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JCMConstants` (static field access) | - | - | Reads `STATUS_INT_KEY` constant from the JCM framework's constants class |
| R | `CAANMsg.getInt(String key)` | - | - | Reads the status integer from the template CAANMsg object using the status key |
| R | `JCMAPLConstMgr.getString(String key)` | - | - | Reads the localized error message from the resource bundle by constructing the key `"RETURN_MESSAGE_" + formattedStatus`. Called twice: once for validation, once for actual retrieval. |
| R | `IRequestParameterReadWrite.getControlMapData(String key)` | - | - | Reads the return code value from the parameter's control map to determine the baseline business process status |
| R | `IRequestParameterReadWrite.getData(String key)` | - | - | Retrieves the user data HashMap associated with `dataMapKey` from the parameter object |
| R | `CAANMsg.getString(String itemNm)` | - | - | Reads the error code string for a specific error item field from the template CAANMsg |
| - | `IRequestParameterReadWrite.setControlMapData(String key, String value)` | - | - | Writes the formatted status code and error message into the parameter's control map for the caller to consume |
| - | `HashMap.put(String key, String value)` | - | - | Writes error code key-value pairs into the user data map for fields flagged as error items (`_err` suffix) |
| - | `JKKStringUtil.isNullBlank(String value)` | - | - | Utility call that checks if a string is null or blank. Used to filter out empty error codes before writing them into the data map. |

## 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: `getInt` [-], `getString` [R], `getString` [R], `getControlMapData` [-], `getData` [-], `setControlMapData` [-], `setControlMapData` [-], `put` [-], `isNullBlank` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKMalwareBlockingNonFlgChengeOverCC.callSC() | `callSC()` -> `editErrorInfoCom(param, templates, returnCode, dataMapKey, mappingData, contents)` | `getInt` [-], `getString` [resource bundle lookup], `getControlMapData` [-], `getData` [-], `setControlMapData` [-], `setControlMapData` [-], `put` [-], `isNullBlank` [-] |

## 6. Per-Branch Detail Blocks

**Block 1** — [ASSIGNMENT] (L487)

> Retrieves the primary template and extracts its status code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = templates[0]` // Extract first CAANMsg template from the array |
| 2 | SET | `templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Retrieve service component status from template |

**Block 2** — [IF] `(0 != returnCode)` (L490)

> If the service component returned a non-zero return code, override the template status to 9000 to force an error state. This implements the "promote-the-worst-status" rule.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 9000` // [CONSTANT: Forced error status when returnCode != 0] |

**Block 3** — [IF] `(null == JCMAPLConstMgr.getString(RETURN_MESSAGE_STRING + String.format(RETURN_MESSAGE_FORMAT, templateStatus)))` (L493)

> Validates that a message key exists for the current templateStatus. If no message exists in the resource bundle for the key `"RETURN_MESSAGE_" + formattedStatus` (e.g., `"RETURN_MESSAGE_9000"`), reset the status to 0 to prevent displaying an undefined message. This is a guard against stale or missing resource entries.

| # | Type | Code |
|---|------|------|
| 1 | SET | `templateStatus = 0` // [CONSTANT: Reset to OK if no message template exists] |

**Block 4** — [ASSIGNMENT] (L498)

> Initialize the baseline business process status variable.

| # | Type | Code |
|---|------|------|
| 1 | SET | `bpStatus = 0` // Initial business process status set to success (0) |

**Block 5** — [ASSIGNMENT + IF] (L500-L507)

> Determine the baseline business process status from the parameter's control map. If the `RETURN_CODE` control map entry is null, the baseline is -1 (meaning any positive status wins). Otherwise, parse it as an integer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` // Read baseline status from control map |
| 2 | IF | `(null == obj)` (L502) |
| 2.1 | SET | `bpStatus = -1` // [CONSTANT: No prior baseline — any positive templateStatus wins] |
| 2.2 | SET | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE))` // Parse the string value to integer |

**Block 6** — [IF] `(templateStatus > bpStatus)` (L509)

> Core status promotion logic. If the resolved template status is higher than the baseline business process status, promote it. This ensures the most severe status (service component or business process) always wins. The formatted status and the localized error message are written back into the parameter's control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format(RETURN_MESSAGE_FORMAT, templateStatus)` // [CONSTANT: Returns zero-padded 4-digit string, e.g. `"9000"`] |
| 2 | SET | `message = JCMAPLConstMgr.getString(RETURN_MESSAGE_STRING + formatStatus)` // [CONSTANT: Looks up `"RETURN_MESSAGE_" + formatStatus` from resource bundle, e.g. `"RETURN_MESSAGE_9000"`] |
| 3 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` // Store the formatted status code back into the parameter control map |
| 4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` // Store the localized error message into the parameter control map |

**Block 7** — [ASSIGNMENT] (L516-L517)

> Prepare the user data map for error code injection. Initialize as null, then populate from the parameter's data store using `dataMapKey`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = null` // Initialize HashMap reference |
| 2 | SET | `inMap = (HashMap<String, String>)param.getData(dataMapKey)` // Cast user data to HashMap — this is the target map where error codes will be stored |

**Block 8** — [FOR LOOP] `(null != contents && i < contents.length)` (L519)

> Iterate over the `contents` array to find error item fields. The loop processes each row in `contents`, where each row is an `Object[]`. The first element `contents[i][0]` is the item name. Only items whose names end with the `_err` suffix are treated as error items and processed.

| # | Type | Code |
|---|------|------|
| 1 | SET | `itemNm = (String)contents[i][0]` // Extract the field name from contents row |
| 2 | IF | `itemNm.endsWith(ERRITEM_SUFFIX)` (L521) — [CONSTANT: `ERRITEM_SUFFIX = "_err"`] |
| 2.1 | SET | `errCd = template.getString(itemNm)` // Read the error code for this error item from the template CAANMsg |
| 2.2 | IF | `!JKKStringUtil.isNullBlank(errCd)` (L523) |
| 2.2.1 | SET | `inMap.put(itemNm, errCd)` // Write the error code into the user data map, keyed by the item name |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `editErrorInfoCom` | Method | Error information assembly utility — central method for merging service component error data into the request parameter object during malware blocking data migration |
| `IRequestParameterReadWrite` | Interface | Request parameter interface — the primary data carrier object that holds both control map data (return codes, messages) and user data maps (business data) |
| `CAANMsg` | Class | Message object — a Fujitsu-specific messaging class used for template-based error code and message retrieval |
| `JCMConstants` | Class | JCM Framework Constants — shared constants class from the Futurity JCM framework providing standard keys like `STATUS_INT_KEY` |
| `JCMAPLConstMgr` | Class | JCM Application Constants Manager — static resource bundle manager used to resolve message keys (e.g., `"RETURN_MESSAGE_9000"`) into localized Japanese error messages |
| `SCControlMapKeys` | Class | Service Component Control Map Keys — constants class for control map entry keys including `RETURN_CODE` and `RETURN_MESSAGE` |
| `RETURN_MESSAGE_FORMAT` | Constant | `"%1$04d"` — zero-padded 4-digit integer format, used to convert status codes to message keys |
| `ERRITEM_SUFFIX` | Constant | `"_err"` — suffix convention for error item field names in the `contents` array |
| `RETURN_MESSAGE_STRING` | Constant | `"RETURN_MESSAGE_"` — prefix for constructing resource bundle message lookup keys |
| `templateStatus` | Variable | Service component status code extracted from the template CAANMsg — represents the error/success state of the executed service component |
| `bpStatus` | Variable | Business Process status code — the baseline status retrieved from the parameter's control map, used as a comparison threshold for status promotion |
| `returnCode` | Parameter | Service component return code — `0` indicates success; any non-zero value triggers forced error status `9000` |
| `dataMapKey` | Parameter | Key used to retrieve the user data HashMap from the parameter object — identifies which data map the error codes should be injected into |
| `contents` | Parameter | Field definition array — each row defines a field, with error items designated by the `"_err"` suffix |
| `inMap` | Variable | User data HashMap — the mutable map where error codes are written for error items identified in the `contents` array |
| `isNullBlank` | Method | Null/blank utility — checks if a string value is null or empty, used to filter out empty error codes before writing them |
| Malware Blocking Data Migration | Feature | Business feature — migration of malware blocking data, handled by this common component class |
| `callSC()` | Method | Service Component caller — the direct caller of `editErrorInfoCom()` within the same class, executes the service component and delegates error handling to this method |
