# Business Logic — JKKNsidPwdChgOrsjgsCC.callSC() [42 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.callSC()

The `callSC` method is a **shared utility dispatcher** that invokes a Service Component (SC) on behalf of the authentication ID / password change processing class for downstream business partners (`eo.kyaku.kiko` — e-Customer Base System). It acts as the **single entry point** for all service interface calls within the `JKKNsidPwdChgOrsjgsCC` class, implementing a **delegation pattern** where it prepares the request payload, executes the service, and standardizes the response handling.

The method performs three distinct business responsibilities in sequence: (1) it builds a `paramMap` by extracting session, user, and operational context from the request parameter object and mapping data — including the transaction ID, use case ID, operator ID, client hostname/IP, and view ID; (2) it delegates the actual service invocation to the injected `scCall` invoker; and (3) it processes the result by extracting the template message, return code, and status, then writing error information via `editErrorInfo`, and finally throwing a `CCException` if the service returned a non-success code. This uniform handling ensures that every caller — `addMskmNyoSnn`, `addPrg`, `chgISPNsidPwd`, and `chkKnrn` — benefits from consistent error handling and response formatting regardless of which specific SC Code it targets.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callSC params"])
    S1["editInMsg
Extracts request parameters
into paramMap HashMap"]
    S2["scCall.run
Invokes service interface
with paramMap and handle"]
    S3["Extract templates[] from result"]
    S4["msg = templates[0]"]
    S5["Extract returnCode
from result"]
    S6["Extract status
from msg"]
    S7["editErrorInfo
Set error info and user data"]
    S8["Get errList from
ControlMap ERROR_INFO"]
    S9{"errList == null?"}
    S10["errList =
new ArrayList<>"]
    S11["Set ERROR_INFO in ControlMap
TemplateErrorUtil.getErrorInfo result,errList"]
    S12{"returnCode != '0'
or status != 0?"}
    S13["throw CCException
Service component error"]
    S14["return msg"]

    START --> S1
    S1 --> S2
    S2 --> S3
    S3 --> S4
    S4 --> S5
    S5 --> S6
    S6 --> S7
    S7 --> S8
    S8 --> S9
    S9 -->|true| S10
    S10 --> S11
    S9 -->|false| S11
    S11 --> S12
    S12 -->|true| S13
    S12 -->|false| S14
    S13 --> END(["End / Exception"])
    S14 --> END
```

**Processing summary:**

1. **Request preparation** — `editInMsg` is called to build a `HashMap<String, Object>` containing the transaction context (telegram ID, use case ID, operation ID, call type), the user/arena context (client hostname, IP address, view ID, operator ID), and the template populated from mapping data.

2. **Service invocation** — `scCall.run(paramMap, handle)` is called to execute the target service interface. The actual SC code being invoked is determined by the `mappingData[0][1]` value passed in (e.g., `EKK0361A010`, `EKK0361A020`).

3. **Result extraction** — The result map yields the `CAANMsg[]` templates array (keyed by `JCMConstants.TEMPLATE_LIST_KEY`) and the return code (`JCMConstants.RET_CD_INT_KEY`). The first template message is used to extract the status (`JCMConstants.STATUS_INT_KEY`).

4. **Error info setup** — `editErrorInfo` sets the template status and writes user data (err fields) into the response. It also compares BP-level return status against template status, promoting the higher (worse) status.

5. **Error list consolidation** — The current `ERROR_INFO` list is retrieved from the control map, replaced if null, then overwritten with the merged error info from `TemplateErrorUtil.getErrorInfo`.

6. **Error check** — If the return code is not `"0"` OR the status is not `0`, a `CCException` with message `"サービスコンポーネントエラー"` (Service Component Error) is thrown.

7. **Return** — On success, the `CAANMsg` is returned to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The active session context for the request — carries the authentication and session state for the current transaction (e.g., the customer performing the password change). |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | The service component invocation delegate — a reusable invoker that dispatches the prepared request map to the target CBS/SC. This is injected by the caller to allow different SC codes to be targeted. |
| 3 | `param` | `IRequestParameterReadWrite` | The request parameter container — holds all incoming request data including transaction IDs, use case IDs, operator context, and control map data (hostname, IP, view ID, operator ID, return code, operation date/time). |
| 4 | `mappingData` | `Object[][]` | The SC mapping configuration — a 2D array where each row defines a mapping entry. Row 0, column 1 (`mappingData[0][1]`) contains the SC code (e.g., `"EKK0361A010"`), which determines the target CBS message template class name. Subsequent rows map field names to either `CAANMsg[]` arrays or primitive/`String` values. |
| 5 | `fixedText` | `String` | The user-defined string key used to access user data fields (`param.getData(fixedText)`) — typically a control map key identifying the user data HashMap. Used in `editErrorInfo` to populate error code fields. |
| 6 | `contents` | `Object[][]` | The user data content configuration — a 2D array where each row contains a field name (at index 0) and its value (at index 1). Fields ending with `"_err"` have their error codes extracted from the template and written into the user data map. |

**Internal fields / external state read:**
- No instance fields of `JKKNsidPwdChgOrsjgsCC` are read directly. All state is obtained through method parameters.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `ServiceComponentRequestInvoker.run` | (Determined by mappingData[0][1]) | — | Delegates to the target service component (SC) via the invoker. The specific SC code is provided in mappingData, e.g., `EKK0361A010` for FTTH auth registration, `EKK0361A020` for FTTH auth password change, `EKK0361A030` for Mail auth change. |
| U | `JKKNsidPwdChgOrsjgsCC.editErrorInfo` | — | — | Writes error status and user data into the `param` container's control map and data fields. Compares BP-level vs. template-level status and promotes the worse one. |
| U | `JKKNsidPwdChgOrsjgsCC.editInMsg` | — | — | Builds the request parameter map for the SC invocation, extracting session, operator, and template data from the incoming request. |
| - | `TemplateErrorUtil.getErrorInfo` | — | — | Consolidates error information from the service result map into the error list for the response. |

**How SC Code is determined:** The `mappingData` parameter is a 2D array. `mappingData[0][1]` contains the SC code string (e.g., `"EKK0361A010"`). This code is used to construct the CBS message template class name: `eo.ejb.cbs.cbsmsg.{SCCode}CBSMsg` (via `editInMsg`).

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS:JKKNsidPwdChgOrsjgsCC.addMskmNyoSnn | `addMskmNyoSnn` -> `callSC` | `scCall.run [R] (SC determined by mappingData)` |
| 2 | CBS:JKKNsidPwdChgOrsjgsCC.addPrg | `addPrg` -> `callSC` | `scCall.run [R] (SC determined by mappingData)` |
| 3 | CBS:JKKNsidPwdChgOrsjgsCC.chgISPNsidPwd | `chgISPNsidPwd` -> `callSC` | `scCall.run [R] (SC determined by mappingData)` |
| 4 | CBS:JKKNsidPwdChgOrsjgsCC.chkKnrn | `chkKnrn` -> `callSC` | `scCall.run [R] (SC determined by mappingData)` |

**Terminal operations reached from this method:**

| Terminal | CRUD | Description |
|----------|------|-------------|
| `getErrorInfo` (from `JBSbatACECBuyIfTrkm`) | R | Error info query on service result |
| `getErrorInfo` (from `JBSbatACKojiChrgInfoTrkm`) | R | Error info query on service result |
| `getErrorInfo` (from `ApiBpInterface`) | R | Error info query on service result |
| `editErrorInfo` (local) | U | Error info write to control map |
| `run` (target SC via `scCall`) | R | Service component invocation — specific entity/DB depends on SC code |
| `editInMsg` (local) | U | Request parameter map construction |

## 6. Per-Branch Detail Blocks

**Block 1** — [EXEC] `editInMsg` call (L784)

> Prepares the request parameter map by extracting session, operator, and template data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> paramMap = editInMsg(param, mappingData);` // Builds paramMap from request data and mapping configuration |

**Block 1.1** — Internal logic of `editInMsg` (L830–L891)

> Creates a new HashMap, populates it with transaction context, arena (user) context, and template data, then adds the template list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> paramMap = new HashMap<String, Object>();` |
| 2 | EXEC | `paramMap.put(JCMConstants.TRANZACTION_ID_KEY, param.getTelegramID());` // Set transaction ID [-> TRANSACTION ID] |
| 3 | EXEC | `paramMap.put(JCMConstants.USECASE_ID_KEY, param.getUsecaseID());` // Set use case ID [-> USE CASE ID] |
| 4 | EXEC | `paramMap.put(JCMConstants.OPERATION_ID_KEY, param.getOperationID());` // Set operation ID [-> OPERATION ID] |
| 5 | EXEC | `paramMap.put(JCMConstants.CALL_TYPE_KEY, param.getCallType());` // Set service call type [-> CALL TYPE] |
| 6 | EXEC | `paramMap.put(JCMConstants.CLIENT_HOST_NAME_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTNAME));` // Set client hostname [-> REQ_HOSTNAME] |
| 7 | EXEC | `paramMap.put(JCMConstants.CLIENT_IP_ADDRESS_KEY, param.getControlMapData(SCControlMapKeys.REQ_HOSTIP));` // Set client IP address [-> REQ_HOSTIP] |
| 8 | EXEC | `paramMap.put(JCMConstants.INVOKE_GAMEN_ID_KEY, param.getControlMapData(SCControlMapKeys.REQ_VIEWID));` // Set invoked view ID [-> REQ_VIEWID] |
| 9 | EXEC | `paramMap.put(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID));` // Set operator ID [-> OPERATOR_ID] |
| 10 | SET | `String svcIf = (String)mappingData[0][1];` // Extract SC code from mappingData |
| 11 | SET | `CAANMsg template = new CAANMsg(String.format("eo.ejb.cbs.cbsmsg.%sCBSMsg", svcIf));` // Create template with CBS message class name |
| 12 | EXEC | `template.set(JCMConstants.OPERATOR_ID_KEY, param.getControlMapData(SCControlMapKeys.OPERATOR_ID));` |
| 13 | EXEC | `template.set(JCMConstants.OPERATE_DATE_KEY, param.getControlMapData(SCControlMapKeys.OPE_DATE));` |
| 14 | EXEC | `template.set(JCMConstants.OPERATE_DATETIME_KEY, param.getControlMapData(SCControlMapKeys.OPE_TIME));` |
| 15 | EXEC | `for (int i = 0; i < mappingData.length; i++)` // Loop over all mapping entries |
| 16 | EXEC | `if (mappingData[i][1] instanceof CAANMsg[])` // Check if value is a CAANMsg array |
| 16.1 | EXEC | `template.set((String)mappingData[i][0], (CAANMsg[])mappingData[i][1]);` // Set CAANMsg[] as nested template |
| 16.2 | ELSE | `if ("".equals(mappingData[i][1]))` // Check if value is empty string |
| 16.2.1 | EXEC | `template.setNull((String)mappingData[i][0]);` // Set null value |
| 16.2.2 | ELSE | `template.set((String)mappingData[i][0], mappingData[i][1]);` // Set value directly |
| 17 | SET | `CAANMsg[] templates = new CAANMsg[1];` // Allocate templates array |
| 18 | SET | `templates[0] = template;` |
| 19 | EXEC | `paramMap.put(JCMConstants.TEMPLATE_LIST_KEY, templates);` // [-> TEMPLATE LIST KEY] |
| 20 | RETURN | `return paramMap;` |

**Block 2** — [EXEC] Service invocation (L789)

> Executes the service component via the injected invoker.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `Map<?, ?> result = scCall.run(paramMap, handle);` // Invoke target SC; the specific SC code is determined by mappingData[0][1] |

**Block 3** — [SET] Extract return values (L792–L796)

> Extracts the template message array, the template message, the return code, and the status from the result map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg[] templates = (CAANMsg[])result.get(JCMConstants.TEMPLATE_LIST_KEY);` // [-> TEMPLATE LIST KEY] |
| 2 | SET | `CAANMsg msg = templates[0];` // First template is the response message |
| 3 | SET | `Object returnCode = result.get(JCMConstants.RET_CD_INT_KEY);` // [-> RET CD INT KEY] |
| 4 | SET | `int status = msg.getInt(JCMConstants.STATUS_INT_KEY);` // [-> STATUS INT KEY] |

**Block 4** — [EXEC] Error info setup (L799)

> Writes error status and user data into the parameter container. This method compares the BP-level return status with the template status and promotes the worse one, then writes user-defined error fields.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editErrorInfo(param, templates, (Integer)returnCode, fixedText, contents);` // Sets error info and user data |

**Block 4.1** — Internal logic of `editErrorInfo` (L711–L765)

> Adjusts the template status based on return code, looks up the corresponding message, compares BP status vs. template status, and writes user data error fields.

| # | Type | Code |
|---|------|------|
| 1 | SET | `CAANMsg template = templates[0];` |
| 2 | SET | `int templateStatus = template.getInt(JCMConstants.STATUS_INT_KEY);` // [-> STATUS INT KEY] |
| 3 | IF | `if (returnCode != 0)` [L716] |
| 3.1 | SET | `templateStatus = 9000;` // Override status to 9000 on non-zero return code |
| 4 | IF | `if (JCMAPLConstMgr.getString("RETURN_MESSAGE_" + String.format("%1$04d", templateStatus)) == null)` [L720] |
| 4.1 | SET | `templateStatus = 0;` // Reset status to 0 if no message exists for this status |
| 5 | SET | `int bpStatus = 0;` |
| 6 | SET | `Object obj = param.getControlMapData(SCControlMapKeys.RETURN_CODE);` // [-> RETURN_CODE] |
| 7 | IF | `if (obj == null)` [L726] |
| 7.1 | SET | `bpStatus = -1;` |
| 7.2 | ELSE | `bpStatus = Integer.parseInt((String)param.getControlMapData(SCControlMapKeys.RETURN_CODE));` |
| 8 | IF | `if (bpStatus < templateStatus)` [L733] // BP status is better (lower) than template status |
| 8.1 | SET | `String formatStatus = String.format("%1$04d", templateStatus);` // [-> FORMAT STATUS] |
| 8.2 | SET | `String message = JCMAPLConstMgr.getString("RETURN_MESSAGE_" + formatStatus);` // Look up status message from constants |
| 8.3 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, formatStatus);` // Promote template status to BP |
| 8.4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, message);` |
| 9 | SET | `HashMap<String, String> inMap = (HashMap<String, String>)param.getData(fixedText);` // Get user data HashMap |
| 10 | EXEC | `for (int i = 0; null != contents && i < contents.length; i++)` // Loop over user data content |
| 10.1 | SET | `String itemNm = (String)contents[i][0];` |
| 10.2 | IF | `if (itemNm.endsWith("_err"))` [L747] // Only process error fields |
| 10.2.1 | SET | `String errCd = (String)template.getString(itemNm);` // Get error code from template |
| 10.2.2 | IF | `if (!JKKStringUtil.isNullBlank(errCd))` [L749] |
| 10.2.2.1 | EXEC | `inMap.put(itemNm, errCd);` // Write error code to user data |

**Block 5** — [EXEC] Error list retrieval (L802)

> Retrieves the current error info list from the control map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ArrayList<Object> errList = (ArrayList<Object>)param.getControlMapData(SCControlMapKeys.ERROR_INFO);` // [-> ERROR_INFO] |

**Block 6** — [IF] Null check on error list (L804–L807)

> If the error list is null, initialize it.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (errList == null)` [L804] |
| 1.1 | SET | `errList = new ArrayList<Object>();` |

**Block 7** — [EXEC] Set consolidated error info (L811)

> Overwrites the ERROR_INFO control map entry with the merged error info.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(result, errList));` // [-> ERROR_INFO] Consolidates service result errors with the existing list |

**Block 8** — [IF] Error check and exception throw (L814–L817)

> If the return code is not "0" or the status is not 0, throw a service component error exception.

| # | Type | Code |
|---|------|------|
| 1 | IF | `if (!("0".equals(returnCode.toString()) && 0 == status))` [L814] // Condition: returnCode is NOT "0" OR status is NOT 0 |
| 1.1 | THROW | `throw new CCException("サービスコンポーネントエラー", new Exception());` // 英語: "Service component error" |

**Block 9** — [RETURN] Return success (L819)

> On successful processing, return the CAANMsg to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return msg;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `callSC` | Method | Service Component call — the shared utility method that dispatches service interface invocations |
| `SC` | Acronym | Service Component — the backend service layer that handles business logic |
| `CBS` | Acronym | Core Business System — the back-end enterprise system providing business functions |
| `CAANMsg` | Class | CAAN Message — a message container used to pass data between the BP (Business Platform) layer and the SC/CBS layer |
| `SessionHandle` | Class | Session handle — carries the authentication and session context for the current transaction |
| `ServiceComponentRequestInvoker` | Interface | Service component request invoker — the delegate used to dispatch requests to SC/CBS services |
| `IRequestParameterReadWrite` | Interface | Request parameter read/write — the container for all incoming request data |
| `mappingData` | Field | Mapping data — the 2D array defining SC code and field-to-template mappings |
| `fixedText` | Field | Fixed text — a user-defined string key used as the control map key for user data |
| `contents` | Field | Contents — the user data content configuration array defining which fields to extract as error codes |
| `TRANZACTION_ID_KEY` | Constant | Transaction ID key — the key in the parameter map for the transaction ID (note: misspelled as "TRANZACTION" in source) |
| `USECASE_ID_KEY` | Constant | Use case ID key — the key for the business use case identifier |
| `OPERATION_ID_KEY` | Constant | Operation ID key — the key for the operation identifier |
| `CALL_TYPE_KEY` | Constant | Call type key — the key for the service call type classification |
| `TEMPLATE_LIST_KEY` | Constant | Template list key — the key in the result map for the CAANMsg[] templates array |
| `RET_CD_INT_KEY` | Constant | Return code integer key — the key for the integer return code in the result map |
| `STATUS_INT_KEY` | Constant | Status integer key — the key for the status integer in the CAANMsg |
| `ERROR_INFO` | Constant | Error info — the control map key for the error information list |
| `RETURN_CODE` | Constant | Return code — the control map key for the return code string |
| `RETURN_MESSAGE` | Constant | Return message — the control map key for the status message string |
| `REQ_HOSTNAME` | Constant | Request hostname — the control map key for the client hostname |
| `REQ_HOSTIP` | Constant | Request host IP — the control map key for the client IP address |
| `REQ_VIEWID` | Constant | Request view ID — the control map key for the invoked view/screen ID |
| `OPERATOR_ID` | Constant | Operator ID — the control map key for the operator identifier |
| `OPE_DATE` | Constant | Operation date — the control map key for the operation date |
| `OPE_TIME` | Constant | Operation time — the control map key for the operation time |
| `editInMsg` | Method | Edit in message — builds the request parameter map for SC invocation |
| `editErrorInfo` | Method | Edit error info — sets error status and user data in the response |
| `CCException` | Class | Common Component Exception — the standard exception thrown for service component errors |
| `JCMAPLConstMgr` | Class | JCM Application Constant Manager — utility for looking up message constants by key (e.g., `"RETURN_MESSAGE_0000"`, `"RETURN_MESSAGE_9000"`) |
| `JKKStringUtil` | Class | JKK String Utility — utility for null/blank checking strings (`isNullBlank`) |
| `TemplateErrorUtil` | Class | Template error utility — consolidates error information from service results |
| `eo.kyaku.kiko` | Domain | e-Customer Base System — the system for customer base processing; `JKKNsidPwdChgOrsjgsCC` is the common component for authentication ID and password change for downstream business partners |
| `sid` | Domain | Service ID / Authentication ID — the customer's login identifier |
| `Pwd` | Domain | Password — the customer's authentication password |
| `Chg` | Domain | Change — the action of modifying credentials |
| `Orsjgs` | Domain | Downstream business partner — refers to third-party/external business partners using the service |
| `CC` | Domain | Common Component — shared utility class in the e-Customer base system |
