# Business Logic — JKKNsidPwdChgOrsjgsCC.editErrorInfo() [56 LOC]

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

## 1. Role

### JKKNsidPwdChgOrsjgsCC.editErrorInfo()

This method aggregates and normalizes error information returned from a service component call, then populates the request parameter's control map and data map with status codes and localized error messages for the UI layer. It serves as a centralized error-handling utility within the NIS/Password Change and Operation System service (`JKKNsidPwdChgOrsjgs`), which processes telecom order fulfillment workflows for ISP and password-related operations. The method implements a **min-wins error severity** pattern: it compares the business-process (BP) status already stored in the request against the service component's returned status, and only overwrites the stored status if the service component reported a more severe error (i.e., a higher numeric status). It retrieves the localized error message from the global constant manager keyed by a zero-padded status code and writes both the status code and message into the request's control map. Finally, it iterates over the caller-provided error content array and populates an error-code map with any field names ending in `_err`, extracting their values from the CAANMsg template.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["editErrorInfo(params)"])

    START --> GetTemplate["Get template = templates[0]"]

    GetTemplate --> GetTemplateStatus["Get templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)"]

    GetTemplateStatus --> CheckReturnCode{"returnCode != 0?"}

    CheckReturnCode -->|true| SetStatus9000["Set templateStatus = 9000"]
    CheckReturnCode -->|false| GetReturnMessage["Check JCMAPLConstMgr.getString(RETURN_MESSAGE_ + formatStatus)"]

    SetStatus9000 --> GetReturnMessage

    GetReturnMessage --> MessageIsNull{"RETURN_MESSAGE result == null?"}

    MessageIsNull -->|true| SetStatus0["Set templateStatus = 0"]
    MessageIsNull -->|false| GetControlMap["Get obj = param.getControlMapData(RETURN_CODE)"]

    SetStatus0 --> GetControlMap

    GetControlMap --> ObjIsNull{"obj == null?"}

    ObjIsNull -->|true| SetBpStatusNeg1["Set bpStatus = -1"]
    ObjIsNull -->|false| ParseBpStatus["Set bpStatus = Integer.parseInt(param.getControlMapData(RETURN_CODE))"]

    SetBpStatusNeg1 --> CheckBpVsTemplate{"bpStatus < templateStatus?"}
    ParseBpStatus --> CheckBpVsTemplate

    CheckBpVsTemplate -->|false| GetInMap["Get inMap = param.getData(fixedText)"]

    CheckBpVsTemplate -->|true| SetBpStatus["Format status, get message, write RETURN_CODE and RETURN_MESSAGE into control map"]

    SetBpStatus --> GetInMap

    GetInMap --> InitLoop{"contents != null and i < contents.length?"}

    InitLoop -->|true| LoopStart["Loop: i++"]
    InitLoop -->|false| ReturnParam["Return param"]

    LoopStart --> GetItemNm["Get itemNm = contents[i][0]"]

    GetItemNm --> CheckItemNm{"itemNm ends with '_err'?"}

    CheckItemNm -->|false| LoopCheck2{"i++"}
    CheckItemNm -->|true| GetErrCd["Get errCd = template.getString(itemNm)"]

    GetErrCd --> CheckErrCd{"errCd is null or blank?"}

    CheckErrCd -->|true| LoopCheck2
    CheckErrCd -->|false| PutErrCd["inMap.put(itemNm, errCd)"]

    PutErrCd --> LoopCheck2

    LoopCheck2 -->|true| LoopStart
    LoopCheck2 -->|false| ReturnParam

    ReturnParam --> END(["End"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `param` | `IRequestParameterReadWrite` | The request parameter object carrying control map data (status codes, messages) and business data maps between screens, service components, and the business logic layer. It acts as the primary data carrier for the NIS/Password Change workflow. |
| 2 | `templates` | `CAANMsg[]` | An array of message templates populated by the called service component. `templates[0]` contains the service return status code (via `JCMConstants.STATUS_INT_KEY`) and per-field error codes keyed by field name. |
| 3 | `returnCode` | `int` | The raw return code from the called service component (SC). A non-zero value signals that the SC call failed, causing the method to override `templateStatus` to `9000` (a generic error status). Zero indicates success. |
| 4 | `fixedText` | `String` | The map key used to retrieve or create the HashMap of user-defined error data from the request parameter. This map accumulates field-level error codes (keys ending in `_err`). |
| 5 | `contents` | `Object[][]` | A 2D array of error content pairs where `contents[i][0]` is the field name and `contents[i][1]` is its associated value. Used to identify which fields have error conditions based on the `_err` suffix convention. |

**External state / instance fields read:** None. This method is purely stateless — all input comes through parameters and it reads nothing from `this`.

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `template.getInt(JCMConstants.STATUS_INT_KEY)` | - | - | Reads the status integer from the first CAANMsg template |
| R | `JCMAPLConstMgr.getString` | - | - | Looks up a localized message string by key (`RETURN_MESSAGE_XXXX`) |
| R | `param.getControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Reads the existing BP-level return code from the control map |
| SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE)` | - | - | Writes the (formatted) status code back into the control map |
| SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE)` | - | - | Writes the localized error message back into the control map |
| R | `param.getData(fixedText)` | - | - | Retrieves the user-defined error data HashMap |
| SET | `inMap.put(itemNm, errCd)` | - | - | Stores the extracted error code into the error data map |

**Analysis:** This method performs **no database or service component CRUD operations**. It is a pure data-transformation utility that reads status codes from templates, looks up localized messages from constants, and populates the request parameter's control map and data map with error information. All operations are in-memory reads/writes to parameter objects.

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

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `JKKNsidPwdChgOrsjgsCC` | `callSC` → `editErrorInfo` | `getInt`, `getString` [R], `setControlMapData` [SET], `put` [SET] |

**Notes:** This method is called exclusively from `callSC()` within the same class (`JKKNsidPwdChgOrsjgsCC`). It is a private helper, not an entry point. The `callSC()` method is the service-component invocation wrapper that calls business logic and routes results through `editErrorInfo()` to normalize error information for the response. No screen (KKSV*) or batch entry points were found calling this method directly.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (Extract template and initial status) (L713)

> Retrieves the first message template from the array and extracts the service component's status code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `template = templates[0]` |
| 2 | SET | `templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY)` // Reads SC return status |

**Block 2** — IF (override status on non-zero return) (L717)

> If the raw return code is non-zero (indicating failure), override the template status to `9000` — a generic error indicator.

| # | Type | Code |
|---|------|------|
| 1 | IF | `returnCode != 0` [RETURN_CODE_NONZERO="non-zero indicates failure"] |
| 2 | SET | `templateStatus = 9000` [STATUS_9000="Generic error status"] |

**Block 3** — IF (validate return message key existence) (L721)

> Validates that a localized message exists for the current `templateStatus`. If no message key is found in `JCMAPLConstMgr`, the status is reset to `0` (success/no-error), effectively suppressing an invalid status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-padded 4-digit |
| 2 | IF | `JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus) == null` [MSG_KEY_NULL="No localized message for this status"] |
| 3 | SET | `templateStatus = 0` [STATUS_0="No-error / success status"] |

**Block 4** — IF/ELSE (read existing BP status from control map) (L728)

> Reads the current business-process-level return code from the request's control map. If the key is absent, defaults to `-1` (lower than any valid status). Otherwise parses the string value as an integer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE)` |
| 2 | IF | `obj == null` |
| 3 | SET | `bpStatus = -1` [BP_STATUS_MISSING="No prior BP status set"] |
| 4 | ELSE | |
| 5 | SET | `bpStatus = Integer.parseInt((String) param.getControlMapData(SCControlMapKeys.RETURN_CODE))` |

**Block 5** — IF (min-wins error severity comparison) (L735)

> Only overwrites the BP-level status and message if the service component's status is more severe (higher numeric value) than what the BP already holds. This implements a "worst wins" / "min-wins" pattern: lower numeric values take priority, so a newly reported higher status overrides the existing one.

| # | Type | Code |
|---|------|------|
| 1 | IF | `bpStatus < templateStatus` [SEVERITY_CHECK="Only update if SC status is worse"] |
| 2 | SET | `formatStatus = String.format("%1$04d", templateStatus)` // Zero-padded status code |
| 3 | SET | `message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus)` // Localized message |
| 4 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus)` [-> Key: "RETURN_CODE"] |
| 5 | SET | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message)` [-> Key: "RETURN_MESSAGE"] |

**Block 6** — SET (retrieve error data map) (L748)

> Gets the user-defined error data HashMap from the request parameter. This map accumulates field-level error codes for display on the UI.

| # | Type | Code |
|---|------|------|
| 1 | SET | `inMap = (HashMap<String, String>) param.getData(fixedText)` |

**Block 7** — FOR (iterate error contents and populate error map) (L750)

> Iterates through the `contents` array. For each entry whose field name ends with `_err`, it extracts the corresponding error code from the template and stores it in the error data map. Blank error codes are skipped.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `i = 0; contents != null && i < contents.length; i++` |
| 2 | SET | `itemNm = (String) contents[i][0]` |
| 3 | IF | `itemNm.endsWith("_err")` [ERR_SUFFIX="_err suffix indicates error field"] |
| 4 | SET | `errCd = (String) template.getString(itemNm)` |
| 5 | IF | `JKKStringUtil.isNullBlank(errCd)` [IS_NULLBLANK="Skip blank/null error codes"] |
| 6 | EXEC | (skip — errCd is blank) |
| 7 | ELSE | |
| 8 | SET | `inMap.put(itemNm, errCd)` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `RETURN_CODE` | Constant | Control map key for the business-process-level return code. Carries a zero-padded 4-digit status code (e.g., "0000", "9000") indicating the result of service component execution. |
| `RETURN_MESSAGE` | Constant | Control map key for the localized error message text corresponding to the return code. Used by the UI layer to display user-facing error messages. |
| `STATUS_INT_KEY` | Constant | Key used to retrieve the status integer from a `CAANMsg` template. Represents the service component's raw status code. |
| `SCControlMapKeys` | Class | Constant class defining keys for the request parameter's control map (e.g., `RETURN_CODE`, `RETURN_MESSAGE`). |
| `JCMConstants` | Class | Centralized constants class for Java Communication Message (JCM) framework keys, including `STATUS_INT_KEY`. |
| `JCMAPLConstMgr` | Class | Application-level constant manager that provides localized string lookups by key. Used to resolve `RETURN_MESSAGE_XXXX` keys to human-readable messages. |
| `CAANMsg` | Class | Message container class used to carry structured message data (status codes, field-level error codes) between service components and UI layers. |
| `IRequestParameterReadWrite` | Interface | Request parameter interface providing `getControlMapData`, `setControlMapData`, and `getData` methods for bidirectional data exchange across the request lifecycle. |
| `templateStatus` | Variable | The normalized service component return status. Starts from the template's status field, may be overridden to `9000` on non-zero return code, or reset to `0` if no message key exists. |
| `bpStatus` | Variable | The existing business-process-level status stored in the request's control map. Represents the worst status encountered so far in the processing chain. |
| `_err` | Naming convention | Suffix appended to field names in the `contents` array to mark fields that carry error codes. Only entries with this suffix are processed into the error map. |
| `9000` | Status code | Generic error status code. Set when `returnCode` is non-zero, indicating the service component call failed. |
| `0000` / `0` | Status code | Success / no-error status. Reset when no localized message exists for the current template status, effectively suppressing invalid statuses. |
| `fixedText` | Parameter | Map key used to retrieve/create the HashMap holding user-defined error data. Each field-level error code is stored as a key-value pair in this map. |
