# Business Logic — JKKCmpMalwareBlockingApiCC.malwareBlockingMain() [80 LOC]

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

## 1. Role

### JKKCmpMalwareBlockingApiCC.malwareBlockingMain()

This method is the central entry point for querying and updating malware blocking (communication interception) settings on a service contract within the K-Opticom eo customer core system. It acts as a Coordination Component (CC) that orchestrates validation, data retrieval, business rule enforcement, and state changes for the malware blocking feature. The method implements a **routing/dispatch pattern** — based on the `processing_type` parameter, it branches into either a read-only inquiry mode (returns the current blocking status) or an update mode (modifies the blocking flag, emits an SOD, and registers a progress event). The design follows a strict **validation-first, then delegate** approach: all individual item checks run before any service component calls, enabling the system to return a comprehensive list of validation errors in a single response rather than failing on the first issue. Its role in the larger system is as a shared API component consumed by BPM operations (specifically KKSV094501CC), making it the single responsibility point for all malware blocking inquiry and update logic across screens and workflows.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["malwareBlockingMain"])
    START --> GET_CC_MSG["Get ccMsg from param.getData"]
    GET_CC_MSG --> GET_PROC_TYPE["Get processingType from ccMsg"]

    GET_PROC_TYPE --> UNIT_CHECK["getErrOfUnitParam: individual item validation"]
    UNIT_CHECK --> ERR_LIST_CHECK{"errList.size > 0?"}

    ERR_LIST_CHECK -- Yes --> SET_ERR_INFO["ccMsg.put(ERROR_INFO, errList)"]
    SET_ERR_INFO --> SET_RETURN_5000["param.setControlMapData(RETURN_CODE, 5000)"]
    SET_RETURN_5000 --> RETURN_PARAM_1(["Return param with errors"])

    ERR_LIST_CHECK -- No --> GET_EKK0081["getEKK0081A010: retrieve service contract"]
    GET_EKK0081 --> SVC_CHECK["getErrOfSvcKei: service contract validity check"]
    SVC_CHECK --> SVC_ERR_CHECK{"errList.size > 0?"}

    SVC_ERR_CHECK -- Yes --> SET_SVC_ERR["ccMsg.put(ERROR_INFO, errList)"]
    SET_SVC_ERR --> SET_RETURN_5000B["param.setControlMapData(RETURN_CODE, 5000)"]
    SET_RETURN_5000B --> RETURN_PARAM_2(["Return param with errors"])

    SVC_ERR_CHECK -- No --> GET_EKK0091["getEKK0091A010: retrieve eo light-net service contract"]
    GET_EKK0091 --> EKK0091_NULL{"ekk0091a010 == null?"}

    EKK0091_NULL -- Yes --> ADD_SVC_ERR["errList.add(getReqErrInfMap(svc_kei_no))"]
    ADD_SVC_ERR --> SET_SVC_ERR_2["ccMsg.put(ERROR_INFO, errList)"]
    SET_SVC_ERR_2 --> SET_RETURN_5000C["param.setControlMapData(RETURN_CODE, 5000)"]
    SET_RETURN_5000C --> RETURN_PARAM_3(["Return param with errors"])

    EKK0091_NULL -- No --> PROC_TYPE_CHECK{"processingType == 1?"}

    PROC_TYPE_CHECK -- Yes: Reference --> CHECK_BLOCKING_FLG{"MALWARE_BLOCKING_NON_FLG == 1?"}
    CHECK_BLOCKING_FLG -- Yes: Non-blocking --> SET_NON_BLOCK["currentBlocking = 2 (Non-blocking)"]
    CHECK_BLOCKING_FLG -- No: Default Blocking --> SET_BLOCK["currentBlocking = 1 (Blocking)"]
    SET_NON_BLOCK --> BUILD_RES_MAP
    SET_BLOCK --> BUILD_RES_MAP

    PROC_TYPE_CHECK -- No: Update --> CALL_UPDATE["updateMalwareBlockingInfo: update blocking flag"]
    CALL_UPDATE --> GET_REVISED["currentBlocking = ccMsg.get(revised_blocking)"]
    GET_REVISED --> BUILD_RES_MAP

    BUILD_RES_MAP["resMap.put(result=0, blocking=currentBlocking)"]
    BUILD_RES_MAP --> SET_DATA["param.setData(fixedText, resMap)"]
    SET_DATA --> RETURN_RES(["Return param with result"])

    RETURN_RES --> TRY_BLOCK_END(["End try block"])
    TRY_BLOCK_END --> CATCH_SC{"SCCallException?"}
    CATCH_SC -- Yes --> SET_SYS_ERR["setControlMapData(RETURN_CODE=9000, RETURN_MESSAGE=system error)"]
    SET_SYS_ERR --> THROW_CC["throw CCException"]
    THROW_CC --> RETURN_PARAM_4(["Return param"])
    CATCH_SC -- No --> RETURN_PARAM_5(["Return param"])
```

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing transaction and connection context for all SC (Service Component) calls made within this method. |
| 2 | `param` | `IRequestParameterReadWrite` | Request/response parameter object carrying the input data map (`ccMsg` under `fixedText` key) and supporting control map data (error lists, return codes, return messages). Modified in place for both input and output. |
| 3 | `fixedText` | `String` | The key used to access and store the data map within `param` via `getData()` and `setData()`. Also used to derive a sub-key (`fixedText + "01"`) when passing data to the SOD issuance component. |

**Instance fields / external state read:**

None directly. All constants are static `private final` fields defined within this class. The method delegates stateful work to called methods and helper components.

## 4. CRUD Operations / Called Services

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `getEKK0081A010` | EKK0081A010 | KK_T_SVC_KEI (Service Contract) | Retrieves service contract record by service contract number (`svc_kei_no`) and operation date to validate the contract exists and obtain its attributes. |
| R | `getEKK0091A010` | EKK0091A010 | KK_T_SVC_KEI_EO_NET (eo Light-Net Service Contract) | Retrieves the eo light-net service contract detail to obtain the current malware blocking flag and related configuration fields. |
| U | `updateMalwareBlockingInfo` | EKK0091C040 | KK_T_SVC_KEI_EO_NET (eo Light-Net Service Contract) | Updates the malware blocking flag field (`MALWARE_BLOCKING_NON_FLG`) on the eo light-net service contract record with the new setting. Also passes a comprehensive set of contract attributes from the original service contract record for synchronization. |
| C | `insertMskm` (via updateMalwareBlockingInfo) | EKK0011D020 | KK_T_MSKM (Application/Detailed Number) | Registers a new application record (`mskm`) with empty detail fields and service contract SYSID, returning the newly created application detail number. |
| C | `insertMskm` (via updateMalwareBlockingInfo) | EKK0021C060 | KK_T_MSWM (Follow-up Work) | Registers a follow-up work request dependent on the newly created application record for subsequent processing. |
| C | `updateMalwareBlockingInfo` (via updateMalwareBlockingInfo) | EKK1091D010 | KK_T_PRG_JOKYU (Progress Status) | Registers a progress status record documenting the malware blocking change (with memo indicating the before/after blocking state). |
| C | `updateMalwareBlockingInfo` (via updateMalwareBlockingInfo) | JKKHakkoSODCC.hakkoSOD | SOD Table (Service Order Data) | Issues an FTTH authentication SOD with malware blocking detail information for downstream fulfillment processing. |
| R | `getErrOfUnitParam` | - | - | Validates individual input parameters (service contract number, processing type, revised blocking setting) for required fields, format, length, and valid value ranges. |
| R | `getErrOfSvcKei` | - | - | Validates the retrieved service contract — checks record existence, pricing group code validity (02/03/04 only), and for update operations, service contract status is not in canceled/draft state. |

### How SC Codes are classified:

- **EKK0081A010** — Service Contract Inquiry (A010 = standard select/inquiry pattern)
- **EKK0091A010** — eo Light-Net Service Contract Inquiry (A010 = standard select/inquiry)
- **EKK0091C040** — eo Light-Net Service Contract Update (C040 = update/registration pattern)
- **EKK0011D020** — Application Registration (D020 = registration pattern)
- **EKK0021C060** — Follow-up Work Registration (C060 = registration for follow-up tasks)
- **EKK1091D010** — Progress Status Registration (D010 = registration pattern)

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0945 (KKSV0945OPOperation) | `KKSV0945OPOperation.run` -> `CCRequestBroker.invoke` -> `JKKCmpMalwareBlockingApiCC.malwareBlockingMain` | `getEKK0081A010 [R] KK_T_SVC_KEI`, `getEKK0091A010 [R] KK_T_SVC_KEI_EO_NET`, `updateMalwareBlockingInfo [U] KK_T_SVC_KEI_EO_NET`, `insertMskm [C] KK_T_MSKM`, `insertMskm [C] KK_T_MSWM`, `updateMalwareBlockingInfo [C] KK_T_PRG_JOKYU`, `hakkoSOD [C] SOD` |

**Notes on caller analysis:**
- KKSV0945OPOperation is the BPM operation class that triggers the malware blocking inquiry/update flow.
- The CCRequestBroker (`KKSV094501CC`) is configured with the target class and method name in the BPM definition, serving as the invocation bridge.

## 6. Per-Branch Detail Blocks

### Block 1 — try block entry (L129)

> The main processing logic is wrapped in a try-catch block. All business operations execute within the try block; any SCCallException triggers system error handling.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (Map<String, Object>) param.getData(fixedText)` // Get the CC data map from param [L132] |
| 2 | SET | `processingType = (String) ccMsg.get(PROCESSING_TYPE)` // Read processing type discriminator [L133] |
| 3 | EXEC | `errList = getErrOfUnitParam(handle, param, fixedText, ccMsg, processingType)` // Call individual item validation [L136] |

---

### Block 2 — IF (errList.size() > 0) individual item validation failure (L137)

> If any individual parameter validation fails (required, format, length, or valid value), the method registers the error list and returns immediately with error code 5000.

**Block 2.1** — IF (`errList.size() > 0`) — individual item validation returned errors (L137)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg.put(ERROR_INFO, errList)` // Register the error list in ccMsg [L138] |
| 2 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, JKKStrConst.RETURN_CD_5000)` // Set error return code 5000 [L139] |
| 3 | RETURN | `return param` // Return with errors, skip all further processing [L140] |

---

### Block 3 — Service Contract Retrieval (L143)

> After validation passes, the method retrieves the service contract record to verify existence and obtain its attributes.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0081a010 = getEKK0081A010(handle, param, fixedText)` // SC call: service contract inquiry [L143] |

---

### Block 4 — IF (errList.size() > 0) service contract validity check (L146)

> The retrieved service contract is checked for validity — null record, wrong pricing group code, or invalid status for update operations.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `errList = getErrOfSvcKei(ekk0081a010, processingType)` // Validate service contract record [L147] |

**Block 4.1** — IF (`errList.size() > 0`) — service contract validation returned errors (L148)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg.put(ERROR_INFO, errList)` // Register service contract check errors [L151] |
| 2 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, JKKStrConst.RETURN_CD_5000)` // Set error code 5000 [L152] |
| 3 | RETURN | `return param` // Return with errors [L153] |

---

### Block 5 — eo Light-Net Service Contract Retrieval (L156)

> Retrieves the detailed eo light-net service contract to obtain the current malware blocking flag.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `ekk0091a010 = getEKK0091A010(handle, param, fixedText)` // SC call: eo light-net service contract inquiry [L156] |

---

### Block 6 — IF (ekk0091a010 == null) eo Light-Net record not found (L157)

> If the eo light-net service contract record cannot be retrieved, this indicates a service contract number error.

**Block 6.1** — IF (`ekk0091a010 == null`) — eo light-net record missing (L157)

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Map<String, String>>()` // Create new error list [L162] |
| 2 | EXEC | `errList.add(getReqErrInfMap(SVC_KEI_NO))` // Add required field error for service contract number [L163] |
| 3 | SET | `ccMsg.put(ERROR_INFO, errList)` // Register error in ccMsg [L164] |
| 4 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, JKKStrConst.RETURN_CD_5000)` // Set error code 5000 [L165] |
| 5 | RETURN | `return param` // Return with errors [L166] |

---

### Block 7 — Processing Type Branch: Reference (L172)

> When `processing_type = "1"`, the method reads the current blocking status and returns it as a result.

**Block 7.1** — IF (`PROCESSING_TYPE_REFERENCE` = "1" equals `processingType`) — Reference mode (L172)

| # | Type | Code |
|---|------|------|
| 1 | SET | `currentBlocking = null` // Initialize blocking status variable [L170] |

**Block 7.1.1** — IF (`MALWARE_BLOCKING_NON_FLG_ON` = "1" equals `ekk0091a010.getString(EKK0091A010CBSMsg1List.MALWARE_BLOCKING_NON_FLG)`) — Malware blocking non-flag is ON (L173)

> The current blocking status is determined by checking the malware blocking non-flag field from the eo light-net contract record.

| # | Type | Code |
|---|------|------|
| 1 | SET | `currentBlocking = NON_BLOCKING` ("2") // Blocking OFF — malware blocking is not active [L174, comment: ブロッキング無] |

**Block 7.1.2** — ELSE — Malware blocking non-flag is NOT ON (L176)

> Default to blocking if the flag value is anything other than "1".

| # | Type | Code |
|---|------|------|
| 1 | SET | `currentBlocking = BLOCKING` ("1") // Default to blocking — "1"以外は全てデフォルトと判断 [L177, comment: "1"以外、全てデフォルトと判断] |

---

### Block 8 — ELSE IF (PROCESSING_TYPE_UPDATE = "2" equals `processingType`) — Update mode (L179)

> When `processing_type = "2"`, the method updates the malware blocking flag and then reads back the revised value.

**Block 8.1** — ELSE IF (`PROCESSING_TYPE_UPDATE` = "2" equals `processingType`) — Update mode (L179)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `updateMalwareBlockingInfo(handle, param, fixedText, ekk0081a010, ekk0091a010)` // Update blocking flag, issue SOD, register progress [L182] |
| 2 | SET | `currentBlocking = (String) ccMsg.get(REVISED_BLOCKING)` // Read back the updated blocking setting [L183] |

> **updateMalwareBlockingInfo** internally performs the following sequence:
> 1. Calls `insertMskm()` to register an application record (SC: EKK0011D020), deriving `mskm_dtl_no` from the result (or existing record if creation fails).
> 2. Determines `malwareBlockingNashiF`: if `revised_blocking` equals `NON_BLOCKING` ("2"), sets it to `MALWARE_BLOCKING_NON_FLG_ON` ("1"); otherwise null.
> 3. Calls SC EKK0091C040 to update the eo light-net service contract with the malware blocking flag and a comprehensive set of contract attributes.
> 4. Issues an FTTH authentication SOD via `JKKHakkoSODCC.hakkoSOD()` with malware blocking detail info.
> 5. Registers a progress status record (SC: EKK1091D010) with memo indicating the change (e.g., "マルウェア通信遮断(変更前)有" or "マルウェア通信遮断(変更前)無").

---

### Block 9 — Result Map Construction (L186)

> After either branch completes, the result map is built and set into the parameter object.

| # | Type | Code |
|---|------|------|
| 1 | SET | `resMap = new HashMap<String, Object>()` // Create result map [L186] |
| 2 | SET | `resMap.put(RESULT_KEY, NORMAL_END)` // Set result = "0" (NORMAL_END, 正常終了) [L187] |
| 3 | SET | `resMap.put(BLOCKING_VALUE_KEY, currentBlocking)` // Set blocking status in result [L188] |
| 4 | EXEC | `param.setData(fixedText, resMap)` // Replace data map with result — no excess data passed to return [L189, comment: 戻り値に余分なデータを渡さない] |

---

### Block 10 — catch (SCCallException) — Service Interface error (L192)

> If any service component call fails during processing, the method sets a system error code and re-throws as a CCException.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_CODE, JKKStrConst.RETURN_CD_9000)` // System error code 9000 [L194] |
| 2 | EXEC | `param.setControlMapData(SCControlMapKeys.RETURN_MESSAGE, JKKStrConst.RETURN_MESSAGE_SYSTEM_ERROR)` // System error message [L195] |
| 3 | RETURN | `throw new CCException("", scCallEx)` // Wrap and re-throw as CCException [L196] |

---

### Block 11 — return param (L197)

> After the try-catch block (and if no exception was thrown), return the modified parameter object.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return parameter with result map or error information [L197] |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service contract number — the unique identifier for a service contract line item (eo light-net contract). |
| `processing_type` | Field | Processing type discriminator — "1" for inquiry (reference) mode, "2" for update mode. |
| `revised_blocking` | Field | Revised blocking setting — the desired blocking state after update ("1" = blocking, "2" = non-blocking). |
| `MALWARE_BLOCKING_NON_FLG` | Field | Malware blocking non-flag — stored in the eo light-net service contract table. "1" means blocking is OFF (non-blocking); any other value means blocking is ON. |
| `BLOCKING` | Constant | Blocking ON — value "1", meaning malware communication interception is active. |
| `NON_BLOCKING` | Constant | Blocking OFF — value "2", meaning malware communication interception is inactive. |
| `PROCESSING_TYPE_REFERENCE` | Constant | Reference/inquiry mode — value "1". |
| `PROCESSING_TYPE_UPDATE` | Constant | Update mode — value "2". |
| `MALWARE_BLOCKING_NON_FLG_ON` | Constant | Malware blocking non-flag ON — value "1", meaning blocking is disabled. |
| `RETURN_CD_5000` | Constant | Business error return code — returned when input validation or business rule checks fail. |
| `RETURN_CD_9000` | Constant | System error return code — returned when a service component call throws an exception. |
| `RETURN_CD_1001` | Constant | Required field error code — used when a required parameter is missing. |
| `RETURN_CD_1002` | Constant | Format error code — used when a parameter has an invalid format. |
| `RETURN_CD_1003` | Constant | Length error code — used when a parameter exceeds its maximum allowed length. |
| `RETURN_CD_2001` | Constant | Existence error code — used when a record is expected but not found. |
| `NORMAL_END` | Constant | Normal termination indicator — value "0". |
| EKK0081A010 | SC Code | Service Contract Inquiry — retrieves service contract header data by service contract number. |
| EKK0091A010 | SC Code | eo Light-Net Service Contract Inquiry — retrieves eo light-net specific service contract details including malware blocking flag. |
| EKK0091C040 | SC Code | eo Light-Net Service Contract Update — updates eo light-net service contract record fields. |
| EKK0011D020 | SC Code | Application Registration — registers a new application/detailed order record (mskm). |
| EKK0021C060 | SC Code | Follow-up Work Registration — registers a follow-up task for the application. |
| EKK1091D010 | SC Code | Progress Status Registration — registers a progress/event log entry with memo. |
| JKKHakkoSODCC | CC Class | SOD Issuance Component — issues Service Order Data for FTTH authentication processing. |
| SOD | Acronym | Service Order Data — order fulfillment entity passed to downstream FTTH provisioning systems. |
| Mskm (申請明细番号) | Field | Application detail number — internal tracking ID for service applications (申请 = application). |
| MSKM_DTL_NO | Field | Application detail number — primary key for the application table. |
| UPDATE_IDO_DIV | Constant | Change type discriminator — value "00033", identifies the type of update/change event. |
| UPDATE_PRG_STATE | Constant | Progress state code — value "1001", indicates processing status. |
| FTTH | Business term | Fiber To The Home — fiber-optic broadband internet service. |
| eo light-net | Business term | eo Light-Net — K-Opticom's fiber-optic service brand (eo光ネット). |
| CC (Common Component) | Technical term | Coordination Component — a reusable business logic layer that coordinates service component calls, performs validation, and orchestrates workflows. |
| SC (Service Component) | Technical term | Service Component — a low-level data access/processing component that interacts directly with the database. |
| BPM | Acronym | Business Process Management — workflow engine that orchestrates CC and CBS invocations. |
| KKSV0945 | Screen | Malware blocking inquiry/update screen — the customer service screen that triggers this CC. |
