# Business Logic — JKKCmpMalwareBlockingApiCC.callSC() [39 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKCmpMalwareBlockingApiCC` |
| Layer | CC/Common Component (Private utility helper within a shared common component class) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKCmpMalwareBlockingApiCC.callSC()

This method is the central **Service Component (SC) invocation gateway** for the malware blocking API domain. It provides a standardized, single entry point for executing any remote service component through the `ServiceComponentRequestInvoker` (SCCall) infrastructure, then performing a uniform post-call processing pipeline. The business operation it performs is: **execute a downstream SC service, validate the response, manage error state, and propagate errors or return the success message.** It handles all response normalization uniformly regardless of which specific SC is invoked — the method is agnostic to the specific service code or business domain of the underlying SC, as it receives the SC invoker, parameter map, and response handling callbacks as generic arguments. It implements the **delegation pattern** (delegating actual execution to `scCall.run()`) and the **template processing pattern** (extracting and inspecting `CAANMsg` templates from the response). Its role in the larger system is that of a **shared utility wrapper** called internally by the four public API methods of `JKKCmpMalwareBlockingApiCC` (`getEKK0081A010`, `getEKK0091A010`, `insertMskm`, `updateMalwareBlockingInfo`), ensuring consistent error handling, response parsing, and control map management across all malware blocking operations. The method enforces a binary outcome contract: either the SC returns a "0" return code with status 0 (success), in which case the parsed `CAANMsg` is returned; or any deviation triggers an `SCCallException` with detailed return code and status information for the caller to handle.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callSC handle, scCall, param, dataMapKey, mappingData, contents"])
    START --> STEP1["STEP1: Edit Input Message"]
    STEP1 --> STEP1_EXEC["editInMsg(param, mappingData)"]
    STEP1_EXEC --> STEP1_SET["paramMap = HashMap<String, Object>"]

    STEP1_SET --> STEP2["STEP2: Execute SC Call"]
    STEP2 --> STEP2_EXEC["scCall.run(paramMap, handle)"]
    STEP2_EXEC --> STEP2_SET["result = Map<?, ?>"]

    STEP2_SET --> STEP3["STEP3: Extract Templates"]
    STEP3 --> STEP3_GET["result.get(JCMConstants.TEMPLATE_LIST_KEY)"]
    STEP3_GET --> STEP3_CAST["templates = CAANMsg[]"]
    STEP3_CAST --> STEP3_FIRST["msg = templates[0]"]

    STEP3_FIRST --> STEP4["STEP4: Get Return Code"]
    STEP4 --> STEP4_GET["result.get(JCMConstants.RET_CD_INT_KEY)"]
    STEP4_GET --> STEP4_SET["return_code = Object"]

    STEP4_SET --> STEP5["STEP5: Edit Error Info"]
    STEP5 --> STEP5_CALL["editErrorInfoCom(param, templates, return_code, dataMapKey, mappingData, contents)"]

    STEP5_CALL --> STEP6["STEP6: Initialize Error List"]
    STEP6 --> STEP6_GET["param.getControlMapData(SCControlMapKeys.ERROR_INFO)"]
    STEP6_GET --> STEP6_ERR_LIST["errList = ArrayList<Object>"]
    STEP6_ERR_LIST --> STEP6_NULL_CHECK{errList is null?}
    STEP6_NULL_CHECK -->|true| STEP6_NEW["errList = new ArrayList<Object>()"]
    STEP6_NULL_CHECK -->|false| STEP6_STATUS["status = msg.getInt(JCMConstants.STATUS_INT_KEY)"]
    STEP6_NEW --> STEP6_STATUS

    STEP6_STATUS --> STEP6_SET_CTRL["param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(result, errList))"]

    STEP6_SET_CTRL --> STEP7["STEP7: Validate Result"]
    STEP7 --> STEP7_CHECK{SC call successful?}
    STEP7_CHECK -->|return_code != '0' or status != 0| STEP7_THROW["throw SCCallException('return value invalid', return_code, status)"]
    STEP7_CHECK -->|return_code = '0' and status = 0| STEP8["STEP8: Return msg"]

    STEP7_THROW --> END(["throw SCCallException"])
    STEP8 --> END2(["return msg"])
```

**Processing Flow Summary:**

1. **STEP1 — Input Message Preparation:** Transforms the raw request parameter object (`param`) and mapping data into a structured `HashMap<String, Object>` parameter map via `editInMsg()`. This prepares the data in the format expected by the SC layer.

2. **STEP2 — SC Invocation:** Delegates execution to the `ServiceComponentRequestInvoker.run()` method, passing the prepared parameter map and session handle. The SC executes its business logic (which may involve database reads/writes, external system calls, etc.) and returns a result map containing the return code, status, and response templates.

3. **STEP3 — Response Template Extraction:** Extracts the list of `CAANMsg` templates from the result map using the `JCMConstants.TEMPLATE_LIST_KEY` constant, casts it to `CAANMsg[]`, and takes the first template (`templates[0]`) as the primary response message object. This template will be returned to the caller on success.

4. **STEP4 — Return Code Retrieval:** Extracts the return code from the result map using `JCMConstants.RET_CD_INT_KEY` and stores it as an `Object`. This code indicates whether the SC completed successfully ("0" = success) or encountered an error (non-zero = failure).

5. **STEP5 — Error Info Pre-processing:** Calls `editErrorInfoCom()` to perform preliminary error info processing before the final error info assignment. This step populates error state into the parameter and templates based on the return code and mapping data.

6. **STEP6 — Error List Initialization and Final Error Assignment:** Retrieves any existing error info from the parameter's control map. If null, creates a new empty `ArrayList`. Then, uses `TemplateErrorUtil.getErrorInfo()` to extract error details from the SC result map and sets the final error list into the control map via `SCControlMapKeys.ERROR_INFO`. Also retrieves the message status code using `JCMConstants.STATUS_INT_KEY`.

7. **STEP7 — Result Validation:** Validates that both the return code equals "0" (success) AND the status is 0 (healthy). If either check fails, throws an `SCCallException` with the Japanese literal message "戻値不正" ("return value invalid"), the return code, and the status. This propagates SC-level failures to the caller with full context.

8. **STEP8 — Success Path:** When validation passes, returns the first `CAANMsg` template (`msg`) to the caller, which the caller will then send back as the HTTP/API response.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | The current session context, carrying user authentication, tenant context, and request-scoped metadata used by the SC infrastructure to maintain session consistency across the service component call. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | The service component invoker that performs the actual remote SC execution. This is a reusable invoker instance configured for a specific SC code (e.g., `EKK0081A010SC`, `EKK0091A010SC`). It acts as the bridge between this API layer and the downstream service component logic. |
| 3 | `param` | `IRequestParameterReadWrite` | The request parameter object that carries business input data and serves as the output container for error information (via its control map). It is modified in-place by `editInMsg()` for input preparation and by `editErrorInfoCom()` / `setControlMapData()` for error propagation. |
| 4 | `dataMapKey` | `String` | A key string used by `editErrorInfoCom()` to identify and associate error information with a specific data map entry. Used for error categorization and traceability in the response. |
| 5 | `mappingData` | `Object[][]` | A 2D mapping table that maps field names or keys between the request parameter format and the SC input format. Contains pairs of [request key, SC key] mappings used during input transformation. |
| 6 | `contents` | `Object[][]` | A 2D array containing response content data (message templates, content items) that may be used by error handling and response assembly logic. Passed through to `editErrorInfoCom()` for reference during error processing. |

**External State / Constants Referenced:**

| Source | Constant / Field | Value (as referenced) | Business Meaning |
|--------|-----------------|----------------------|------------------|
| `JCMConstants.TEMPLATE_LIST_KEY` | TEMPLATE_LIST_KEY | (String key — value defined in external JCM library) | Map key to retrieve the `CAANMsg` template list from the SC result. |
| `JCMConstants.RET_CD_INT_KEY` | RET_CD_INT_KEY | (String key — value defined in external JCM library) | Map key to retrieve the return code (integer) from the SC result. |
| `JCMConstants.STATUS_INT_KEY` | STATUS_INT_KEY | (String key — value defined in external JCM library) | Message key to retrieve the status indicator from the `CAANMsg` response. |
| `SCControlMapKeys.ERROR_INFO` | ERROR_INFO | (String key — value defined in external SC library) | Control map key used to store and retrieve error information list in the request parameter. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKCmpMalwareBlockingApiCC.editInMsg` | (internal) | - | Transforms request parameters into a HashMap for SC invocation. Input preparation utility method. |
| - | `ServiceComponentRequestInvoker.run` | (varies — caller-dependent) | (varies — SC-dependent) | Executes the underlying SC with the prepared parameter map. SC code depends on which public API called this method (e.g., `EKK0081A010SC`, `EKK0091A010SC`). |
| - | `JKKCmpMalwareBlockingApiCC.editErrorInfoCom` | (internal) | - | Processes error information based on return code and templates. Populates error state into the parameter object. |
| R | `IRequestParameterReadWrite.getControlMapData` | (internal) | - | Retrieves existing error info from the parameter's control map. |
| U | `IRequestParameterReadWrite.setControlMapData` | (internal) | - | Stores the final error info list (computed by `TemplateErrorUtil.getErrorInfo()`) into the control map. |
| R | `TemplateErrorUtil.getErrorInfo` | (internal) | - | Extracts structured error information from the SC result map, given the current error list. |
| - | `SCControlMapKeys.ERROR_INFO` | (constant) | - | Control map key for error info — used as key for get/set operations. |
| - | `SCCallException` constructor | (internal) | - | Creates an exception when SC validation fails. Thrown as error path. |

**Notes on SC Code and Entity/DB:**

This method is itself a **dispatcher** — it does not contain hardcoded SC codes or direct entity references. The specific SC executed depends on which caller invokes it:

- `getEKK0081A010()` passes an invoker configured for SC code `EKK0081A010SC`
- `getEKK0091A010()` passes an invoker configured for SC code `EKK0091A010SC`
- `insertMskm()` passes an invoker for the malware blocking registration SC
- `updateMalwareBlockingInfo()` passes an invoker for the malware blocking update SC

The actual database entities and tables are determined by the underlying SC implementations (which are in separate SC project modules).

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 4 methods.
Terminal operations from this method: `getErrorInfo` [R], `getErrorInfo` [R], `getErrorInfo` [R], `editErrorInfoCom` [U], `run` [-], `run` [-], `run` [-], `run` [-], `run` [-], `editInMsg` [U]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CBS: `JKKCmpMalwareBlockingApiCC.getEKK0081A010` | `getEKK0081A010()` -> `callSC()` | `scCall.run[EKK0081A010SC]`, `editErrorInfoCom[U]`, `getErrorInfo[R]` |
| 2 | CBS: `JKKCmpMalwareBlockingApiCC.getEKK0091A010` | `getEKK0091A010()` -> `callSC()` | `scCall.run[EKK0091A010SC]`, `editErrorInfoCom[U]`, `getErrorInfo[R]` |
| 3 | CBS: `JKKCmpMalwareBlockingApiCC.insertMskm` | `insertMskm()` -> `callSC()` | `scCall.run[insert SC]`, `editErrorInfoCom[U]`, `getErrorInfo[R]` |
| 4 | CBS: `JKKCmpMalwareBlockingApiCC.updateMalwareBlockingInfo` | `updateMalwareBlockingInfo()` -> `callSC()` | `scCall.run[update SC]`, `editErrorInfoCom[U]`, `getErrorInfo[R]` |

**Call Chain Details:**

- `getEKK0081A010` — Public API method for **retrieving malware blocking information** (likely screen `KKSV` series). Invokes `callSC()` with a read-oriented SC invoker.
- `getEKK0091A010` — Public API method for **retrieving malware blocking list/detail** (secondary retrieval endpoint). Invokes `callSC()` with a read-oriented SC invoker.
- `insertMskm` — Public API method for **inserting (registering) malware blocking entries**. Invokes `callSC()` with a create SC invoker.
- `updateMalwareBlockingInfo` — Public API method for **updating existing malware blocking information**. Invokes `callSC()` with an update SC invoker.

**Terminal Operations Propagated from callSC:**

| Terminal | Type | Description |
|----------|------|-------------|
| `scCall.run()` | - | Delegates to the underlying SC — SC-specific CRUD and entity operations are determined by the caller's configured invoker. |
| `editInMsg()` | U | Updates/transforms input parameter data. |
| `editErrorInfoCom()` | U | Updates error info in templates and parameter. |
| `IRequestParameterReadWrite.setControlMapData()` | U | Updates control map with final error info. |
| `TemplateErrorUtil.getErrorInfo()` | R | Reads error details from SC result map. |
| `IRequestParameterReadWrite.getControlMapData()` | R | Reads existing error info from control map. |

## 6. Per-Branch Detail Blocks

**Block 1** — [SET/EXEC] `editInMsg` call — Input Message Preparation (L699-L700)

> Transforms the raw request parameter into a HashMap for the SC layer.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `editInMsg(param, mappingData)` |
| 2 | SET | `paramMap = HashMap<String, Object>` // Stores the transformed parameter map returned by editInMsg() |

**Block 2** — [EXEC] `scCall.run` — Service Component Execution (L702)

> Delegates to the underlying SC. The actual SC code is determined by which caller invokes this method.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `scCall.run(paramMap, handle)` // Invokes the SC with the prepared parameter map and session handle |
| 2 | SET | `result = Map<?, ?>` // Stores the SC response: contains return code, status, template list, and other result data |

**Block 3** — [GET/CAST/FIRST-ACCESS] Template Extraction (L704-L707)

> Extracts the CAANMsg template list from the result map and takes the first template as the response message.

| # | Type | Code |
|---|------|------|
| 1 | GET | `result.get(JCMConstants.TEMPLATE_LIST_KEY)` // Retrieves template list from result map using the template list key constant |
| 2 | SET | `templates = (CAANMsg[])` // Casts the retrieved object to CAANMsg array |
| 3 | SET | `msg = templates[0]` // Takes the first CAANMsg as the primary response message |

**Block 4** — [GET] Return Code Retrieval (L710-L711)

> Extracts the return code from the SC result for success/failure validation.

| # | Type | Code |
|---|------|------|
| 1 | GET | `result.get(JCMConstants.RET_CD_INT_KEY)` // Retrieves return code from result map using the return code key constant |
| 2 | SET | `return_code = Object` // Stores the return code as Object (later used as String via toString()) |

**Block 5** — [EXEC] `editErrorInfoCom` — Error Info Pre-processing (L713)

> Performs preliminary error info processing before final error assignment. Called unconditionally regardless of success/failure.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `editErrorInfoCom(param, templates, (Integer)return_code, dataMapKey, mappingData, contents)` // Pre-processes error info using return code and templates |

**Block 6** — [GET/SET] Error List Initialization and Assignment (L716-L723)

> Retrieves existing error info, initializes if null, then sets the final error info computed by TemplateErrorUtil. This block has a conditional sub-branch for null handling.

| # | Type | Code |
|---|------|------|
| 1 | GET | `param.getControlMapData(SCControlMapKeys.ERROR_INFO)` // Retrieves existing error info from the parameter's control map |
| 2 | SET | `errList = ArrayList<Object>` // Casts retrieved object to ArrayList |
| 3 | SET | `status = msg.getInt(JCMConstants.STATUS_INT_KEY)` // Retrieves message status code (always executed) |

**Block 6.1** — [IF] Null Check on errList (L718-L720)

> If no existing error list is found in the control map, creates a new empty ArrayList.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Object>()` // Creates fresh error list when no prior errors exist |

**Block 6.2** — [SET] Final Error Info Assignment (L723)

> Sets the computed error info into the control map regardless of whether the list was pre-existing or newly created.

| # | Type | Code |
|---|------|------|
| 1 | SET | `param.setControlMapData(SCControlMapKeys.ERROR_INFO, TemplateErrorUtil.getErrorInfo(result, errList))` // Stores final error info list; TemplateErrorUtil merges existing and newly extracted errors |

**Block 7** — [IF] Result Validation — Success/Failure Gate (L726-L730)

> Validates the SC response. Both the return code must equal "0" AND the status must equal 0 for success. This is the method's primary error-handling branch point.

| # | Type | Code |
|---|------|------|
| 1 | COND | `"0".equals(return_code.toString() && 0 == status)` // [JCMConstants: return_code = "0" means success; status = 0 means healthy] |

**Block 7.1** — [ELSE-IF] Failure Path — Throw SCCallException (L728-L729)

> Triggered when either the return code is non-zero (SC reported an error) or the status is non-zero (message-level error). The Japanese literal "戻値不正" means "return value invalid" or "invalid return value."

| # | Type | Code |
|---|------|------|
| 1 | THROW | `throw new SCCallException("戻値不正" ("return value invalid"), return_code.toString(), status)` // Propagates SC failure with return code and status for caller diagnosis |

**Block 7.2** — [THEN] Success Path — Return Message (L732)

> Triggered only when both return code is "0" and status is 0. The primary CAANMsg template is returned to the caller.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return msg` // Returns the first CAANMsg template to the caller as the successful SC response |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| SC | Acronym | Service Component — a remote service module in the Fujitsu Futurity framework that implements business logic and data access. |
| SCCall | Acronym | Service Component Call — the invocation mechanism (`ServiceComponentRequestInvoker`) used to execute an SC from the API layer. |
| CAANMsg | Type | CAAN Message — the standard message envelope class used for request/response data transfer in the Futurity framework. Contains status, return codes, headers, and body content. |
| SessionHandle | Type | Session context object carrying authentication, tenant, and request-scoped metadata for a client session. |
| IRequestParameterReadWrite | Type | Interface for reading and writing request parameters, including a control map for auxiliary data like error info. |
| JCMConstants | Type | External constant class (from JCM library) defining map keys for SC result data (template list, return code, status). |
| SCControlMapKeys | Type | External constant class (from SC library) defining keys for control map data (e.g., `ERROR_INFO`). |
| TemplateErrorUtil | Type | Utility class that extracts structured error information from SC result maps and existing error lists. |
| SCCallException | Type | Custom exception class thrown when an SC call returns an error condition (non-zero return code or status). |
| ERROR_INFO | Constant | Control map key (`SCControlMapKeys.ERROR_INFO`) used to store and retrieve lists of error objects. |
| TEMPLATE_LIST_KEY | Constant | JCM constant key to retrieve the `CAANMsg[]` template list from SC result maps. |
| RET_CD_INT_KEY | Constant | JCM constant key to retrieve the return code integer from SC result maps. |
| STATUS_INT_KEY | Constant | JCM constant key to retrieve the message status integer from `CAANMsg`. |
| 戻値不正 | Japanese term | "Return value invalid" — the Japanese error message string used in `SCCallException` when SC validation fails. |
| param | Field | Request parameter object — carries business input data and serves as output container for error state. |
| mappingData | Field | 2D array mapping request keys to SC input keys for parameter transformation. |
| contents | Field | 2D array of response content data passed to error processing for context. |
| dataMapKey | Field | String key identifying the data map entry for error categorization and traceability. |
