# Business Logic — JKKCmpMalwareBlockingApiCC.insertMskm() [50 LOC]

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

## 1. Role

### JKKCmpMalwareBlockingApiCC.insertMskm()

This method registers a new malware blocking application (MSKM = Malware Blocking Application) for a customer and returns the generated application detail number. In K-Opticom's customer base system, "malware blocking" is a value-added security service that provides antivirus protection; customers subscribe to this service which is tracked via an application record. The method follows a **two-stage registration pattern**: first, it invokes CBS EKK0011D020 to create the malware blocking application header and receive the system-assigned detail number; then, if creation succeeds, it invokes CBS EKK0021C060 to delegate follow-up ID migration work (linking the new application to the customer's identity records). The method implements the **delegation pattern** by wrapping the low-level SC calls (`callSC`, `createCAANMsgList`) that handle the actual communication with backend CBS (Common Business Service) components. This is a private, non-public API shared by the `updateMalwareBlockingInfo` method within the same class, which itself is called from the `malwareBlockingMain` screen handler (KKSV0945). The method always registers a malware blocking application with type code `00027` (a fixed subscription type) and consumption business application status code `04`.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["insertMskm Starts"])
    
    START --> INIT_SC["Initialize ServiceComponentRequestInvoker"]
    
    INIT_SC --> BUILD_LIST["Build ekk0011d020CBSMsg1ListIn Object array
(7 fields initialized to empty string)"]
    
    BUILD_LIST --> CREATE_MSG["Call createCAANMsgList for detail list
-> CAANMsg[]"]
    
    CREATE_MSG --> BUILD_INPUT["Build ekk0011D020In input
TEMPLATE_ID_EKK0011D020, FUNC_CD_1, sysid,
MSKM_SBT_CD=\"00027\", date/time, CONSMBSN_MSKM_STAT_SKBT_CD=\"04\"
Detail list CAANMsg[]"]
    
    BUILD_INPUT --> CALL_SC1["Call SC EKK0011D020CBS
Register malware blocking application
-> CAANMsg response"]
    
    CALL_SC1 --> EXTRACT_LIST["Extract CAANMsgList from response
-> ekk0011d020cbsmsg1List[]"]
    
    EXTRACT_LIST --> CHECK_LIST{"Detail list is
null or empty?"}
    
    CHECK_LIST -->|Yes| RETURN_NULL["Return null"]
    
    CHECK_LIST -->|No| BUILD_FOLLOWUP["Build ekk0021C060In input
MSKM_DTL_NO from list[0],
UPD_DTM_BF from response,
IDO_DIV=\"00033\", operation date"]
    
    BUILD_FOLLOWUP --> CALL_SC2["Call SC EKK0021C060CBS
Delegate follow-up ID migration work
-> CAANMsg response"]
    
    CALL_SC2 --> RETURN_DETAIL["Return MSKM_DTL_NO from list[0]"]
    
    RETURN_NULL --> END(["End"])
    RETURN_DETAIL --> END
```

**Processing Summary:**

1. **Service Component Request Invoker Initialization:** Creates a `ServiceComponentRequestInvoker` instance for SC communication. The invoker is used to pass the class name for logging purposes.

2. **Detail List Building (7 fields):** Constructs an input array (`ekk0011d020CBSMsg1ListIn`) with 7 fields for the malware blocking application detail. All fields are initialized to empty strings:
   - `MSKM_UK_SBT_CD` — Subscription content approval registration detail / Subscription acceptance type code
   - `MSKMSHO_TRAT_IF_TNTSHA_NM` — Subscription acceptance handling information: handler name
   - `MSKMSHO_TRAT_IF_TELNO` — Subscription acceptance handling information: phone number
   - `KEI_HUKA_CD` — Contract addition code
   - `HNIN_CFM_ATICLE_NM` — Identity verification document name
   - `MSKMSHO_NO` — Application number
   - `MSKMSHO_DTL_NO` — Application detail number

3. **CAAN Message List Creation:** Calls `createCAANMsgList()` to convert the input array into a `CAANMsg[]` detail list.

4. **Main Input Building for EKK0011D020CBS:** Constructs the primary input with:
   - Template ID: `EKK0011D020`
   - Function Code: `1` (Check & Register)
   - SYSID: passed as parameter
   - MSKM_SBT_CD: `"00027"` (fixed malware blocking application type code)
   - MSKM_UK_DTM: system date-time stamp (from `JCCBPCommon.getSysDateTimeStamp()`)
   - MSKM_YMD: operation date (from `JCCBPCommon.getOpeDate(null)`)
   - CONSMBSN_MSKM_STAT_SKBT_CD: `"04"` (Consumption business application status identification code)
   - Detail list: the CAANMsg[] created above

5. **SC Call - EKK0011D020CBS Registration:** Calls `callSC()` to execute CBS EKK0011D020, which registers the malware blocking application. The response (`ekk0011d020Msg`) contains the created record data including the assigned detail number.

6. **Response Detail List Extraction:** Extracts the detail list from the SC response using `getCAANMsgList(EKK0011D020CBSMSG1LIST)`.

7. **Null Check & Conditional Follow-up:** If the detail list is null or empty, returns `null`. Otherwise, proceeds to step 8.

8. **Follow-up Input Building for EKK0021C060CBS:** Constructs the follow-up input with:
   - Template ID: `EKK0021C060`
   - Function Code: `1` (Check & Register)
   - MSKM_DTL_NO: the detail number from the first element of the registration response
   - UPD_DTM_BF: the update date-time before update (from the SC response)
   - IDO_DIV: `"00033"` (ID migration division code)
   - KZKWRK_REQYMD: follow-up work request date (operation date)

9. **SC Call - EKK0021C060CBS Delegation:** Calls `callSC()` to execute CBS EKK0021C060, which delegates the follow-up ID migration work.

10. **Return Detail Number:** Returns the MSKM_DTL_NO (application detail number) from the first element of the registration response detail list.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database/session handle for the current transaction context. Carries the database connection and session state used to interact with CBS components. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object that provides read/write access to request data (form fields, message data). Used to pass request context and extract data during SC invocations. |
| 3 | `fixedText` | `String` | Parameter key string used to retrieve data from the request parameter object. Acts as the namespace/identifier for accessing structured data within `param.getData(fixedText)`. |
| 4 | `sysid` | `String` | System ID that identifies the source system making this request. Passed to the CBS to associate the registration with the originating system. |

**Instance Fields Read by the Method:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `TEMPLATE_ID_EKK0011D020` | `String` | Template ID constant `"EKK0011D020"` for the malware blocking application registration CBS |
| `TEMPLATE_ID_EKK0021C060` | `String` | Template ID constant `"EKK0021C060"` for the follow-up work delegation CBS |
| `UPDATE_IDO_DIV` | `String` | ID migration division code `"00033"` used when delegating follow-up work |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| CALL | `createCAANMsgList` | - | - | Creates CAANMsg list from input array for malware blocking detail fields (local utility, no DB interaction) |
| C | `EKK0011D020CBS` (via `callSC`) | EKK0011D020 | Malware blocking application table | Registers a new malware blocking application with type code 00027, receives assigned detail number |
| R | `EKK0011D020CBS` (via `callSC`) | EKK0011D020 | Malware blocking application table | Extracts created record data including MSKM_DTL_NO from SC response |
| C | `EKK0021C060CBS` (via `callSC`) | EKK0021C060 | Follow-up work / ID migration table | Delegates follow-up ID migration work using the assigned detail number |

### Additional Service Calls Used as Infrastructure:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JCCBPCommon.getSysDateTimeStamp` | JCCBPCommon | - | Retrieves current system date-time stamp for subscription acceptance date-time field |
| R | `JCCBPCommon.getOpeDate` | JCCBPCommon | - | Retrieves current operation date for application date and follow-up work request date fields |

**CRUD Classification Rationale:**

- **EKK0011D020CBS (C/R):** Named pattern `D020` indicates a detail registration CBS. `FUNC_CODE = "1"` specifies "Check & Register" mode. The CBS creates a new malware blocking application record and returns the assigned system-generated detail number. The response contains the created record data.

- **EKK0021C060CBS (C):** Named pattern `C060` indicates a CBS for work delegation. Uses the same `FUNC_CODE = "1"` (Check & Register). Delegates follow-up ID migration work by creating a work request record linked to the malware blocking application detail.

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0945 | `KKSV0945OPOperation` -> `malwareBlockingMain` -> `updateMalwareBlockingInfo` -> `insertMskm` | `EKK0011D020CBS [C] Malware blocking application`, `EKK0021C060CBS [C] Follow-up work/ID migration` |

**Caller Analysis:**

- **KKSV0945OPOperation** (Line 189): The KKSV0945 screen operation class calls `updateMalwareBlockingInfo()` when the processing type is `UPDATE` (processing type = "update"). The screen handles malware blocking information management and update operations for the K-Opticom customer portal.

- **updateMalwareBlockingInfo** (Line ~444): This private method within `JKKCmpMalwareBlockingApiCC` is the direct caller of `insertMskm`. It extracts the SYSID from the `EKK0081A010CBSMsg1List` message and passes it to `insertMskm` to register the malware blocking application as part of the malware blocking info update flow.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (L577)

> Initializes the ServiceComponentRequestInvoker for SC calls. When the parameter passed is a class name, it outputs to log. When set to empty string, no log output.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `ServiceComponentRequestInvoker scCall = new ServiceComponentRequestInvoker()` | Create SC request invoker instance for service component communication |

**Block 2** — SET (L580-587)

> Builds the detail list input array with 7 fields, all initialized to empty strings. These represent the malware blocking application detail fields to be registered.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `Object[][] ekk0011d020CBSMsg1ListIn = {...}` | Initialize detail list input array |
| 1.1 | SET | `{MSKM_UK_SBT_CD, ""}` | Subscription acceptance type code [-> empty string] |
| 1.2 | SET | `{MSKMSHO_TRAT_IF_TNTSHA_NM, ""}` | Subscription acceptance handling information: handler name [-> empty string] |
| 1.3 | SET | `{MSKMSHO_TRAT_IF_TELNO, ""}` | Subscription acceptance handling information: phone number [-> empty string] |
| 1.4 | SET | `{KEI_HUKA_CD, ""}` | Contract addition code [-> empty string] |
| 1.5 | SET | `{HNIN_CFM_ATICLE_NM, ""}` | Identity verification document name [-> empty string] |
| 1.6 | SET | `{MSKMSHO_NO, ""}` | Application number [-> empty string] |
| 1.7 | SET | `{MSKMSHO_DTL_NO, ""}` | Application detail number [-> empty string] |

**Block 3** — CALL (L588)

> Converts the detail list input array into a CAAN message array for SC transmission.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `createCAANMsgList(EKK0011D020CBSMsg1List.class.getName(), ekk0011d020CBSMsg1ListIn)` | Create CAANMsg[] detail list from input array |
| 2 | SET | `CAANMsg[] ekk0011d020cbsmsg1list = ...` | Store the created message list |

**Block 4** — SET (L589-600)

> Builds the primary input for CBS EKK0011D020 registration. Contains all required fields for the malware blocking application registration including system date/time and fixed type codes.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `Object[][] ekk0011D020In = {...}` | Initialize primary registration input array |
| 1.1 | SET | `{TEMPLATEID, TEMPLATE_ID_EKK0011D020}` | Template ID: "EKK0011D020" [-> "EKK0011D020"] |
| 1.2 | SET | `{FUNC_CODE, JPCModelConstant.FUNC_CD_1}` | Function code: 1 (Check & Register) [-> FUNC_CD_1] |
| 1.3 | SET | `{SYSID, sysid}` | SYSID from method parameter |
| 1.4 | SET | `{MSKM_SBT_CD, "00027"}` | Application type code [-> "00027" (Malware Blocking Application Type)] |
| 1.5 | SET | `{MSKM_UK_DTM, JCCBPCommon.getSysDateTimeStamp()}` | Subscription acceptance date-time [-> current system date-time] |
| 1.6 | SET | `{MSKM_YMD, JCCBPCommon.getOpeDate(null)}` | Application date [-> current operation date] |
| 1.7 | SET | `{CONSMBSN_MSKM_STAT_SKBT_CD, "04"}` | Consumption business application status [-> "04"] |
| 1.8 | SET | `{EKK0011D020CBSMSG1LIST, ekk0011d020cbsmsg1list}` | Detail list CAANMsg[] |

**Block 5** — CALL (L603)

> Invokes CBS EKK0011D020 to register the malware blocking application. This is the core creation operation.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0011D020In, EKK0011D020CBSMsg.getContents())` | Execute CBS EKK0011D020 - Register malware blocking application |
| 2 | SET | `CAANMsg ekk0011d020Msg = ...` | Store the SC response containing the registered record |

**Block 6** — SET (L604)

> Extracts the detail list from the SC response. The response contains the system-assigned application detail number.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `ekk0011d020Msg.getCAANMsgList(EKK0011D020CBSMSG1LIST)` | Extract detail list from registration response |
| 2 | SET | `CAANMsg[] ekk0011d020cbsmsg1List = ...` | Store extracted detail list |

**Block 7** — IF (condition: `ekk0011d020cbsmsg1List != null && ekk0011d020cbsmsg1List.length > 0`) (L606)

> Checks whether the registration response contains a valid detail list. If the list exists and has at least one element, proceeds with follow-up work delegation and returns the detail number. Otherwise, falls through to return null.

**Block 7.1** — SET (L609-615)

> Builds the follow-up input array for CBS EKK0021C060. Uses the detail number from the registration response to link the follow-up work to the newly created application.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | SET | `Object[][] ekk0021C060In = {...}` | Initialize follow-up work delegation input |
| 1.1 | SET | `{TEMPLATEID, TEMPLATE_ID_EKK0021C060}` | Template ID: "EKK0021C060" [-> "EKK0021C060"] |
| 1.2 | SET | `{FUNC_CODE, JPCModelConstant.FUNC_CD_1}` | Function code: 1 (Check & Register) [-> FUNC_CD_1] |
| 1.3 | SET | `{MSKM_DTL_NO, ekk0011d020cbsmsg1List[0].getString(MSKM_DTL_NO)}` | Application detail number from registration response [-> extracted from list[0]] |
| 1.4 | SET | `{UPD_DTM_BF, ekk0011d020Msg.getString(UPD_DTM)}` | Update date-time before update [-> extracted from SC response] |
| 1.5 | SET | `{IDO_DIV, UPDATE_IDO_DIV}` | ID migration division code [-> "00033"] |
| 1.6 | SET | `{KZKWRK_REQYMD, JCCBPCommon.getOpeDate(null)}` | Follow-up work request date [-> current operation date] |

**Block 7.2** — CALL (L616)

> Invokes CBS EKK0021C060 to delegate the follow-up ID migration work. This links the newly registered malware blocking application to the customer's ID records.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0021C060In, EKK0021C060CBSMsg.getContents())` | Execute CBS EKK0021C060 - Delegate follow-up ID migration work |
| 2 | SET | `CAANMsg ekk0021c060Msg = ...` | Store the follow-up SC response (not further processed) |

**Block 7.3** — RETURN (L618)

> Returns the application detail number assigned by the CBS during registration.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `ekk0011d020cbsmsg1List[0].getString(MSKM_DTL_NO)` | Return the system-assigned application detail number |

**Block 8** — ELSE (implicit: list is null or empty) (L620)

> When the registration response contains no detail list, the method returns null to indicate the registration did not produce a valid result.

| # | Type | Code | Business Description |
|---|------|------|---------------------|
| 1 | RETURN | `return null` | Return null when no detail list in response |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `MSKM` | Acronym | Malware Blocking — K-Opticom's antivirus/security software service for customer devices |
| `MSKM_SBT_CD` | Field | Malware blocking subscription type code — classifies the type of malware blocking subscription (e.g., "00027" for new application) |
| `MSKM_DTL_NO` | Field | Malware blocking application detail number — system-assigned unique identifier for each malware blocking application record |
| `MSKM_UK_DTM` | Field | Malware blocking subscription acceptance date-time — timestamp when the subscription was accepted/registered |
| `MSKM_YMD` | Field | Malware blocking application date — the date of the application registration |
| `MSKM_UK_SBT_CD` | Field | Malware blocking subscription content acceptance registration detail / subscription acceptance type code — classifies the type of subscription acceptance |
| `MSKMSHO_NO` | Field | Malware blocking application number — the application identifier |
| `MSKMSHO_DTL_NO` | Field | Malware blocking application detail number — same as MSKM_DTL_NO, the detail-level application tracking number |
| `MSKMSHO_TRAT_IF_TNTSHA_NM` | Field | Malware blocking application handling information: handler name — name of the staff/person handling the application |
| `MSKMSHO_TRAT_IF_TELNO` | Field | Malware blocking application handling information: phone number — contact phone for the handling staff |
| `KEI_HUKA_CD` | Field | Service detail addition code — code for contract additions/add-ons associated with the service |
| `HNIN_CFM_ATICLE_NM` | Field | Identity verification document name — name of the document used for customer identity verification |
| `CONSMBSN_MSKM_STAT_SKBT_CD` | Field | Consumption business application status identification code — indicates the status of the application in consumption-based business processing ("04" = active/registered) |
| `IDO_DIV` | Field | ID migration division code — indicates the type of ID migration operation ("00033" for update-related migration) |
| `KZKWRK_REQYMD` | Field | Co-work request date — the date for requesting follow-up collaborative work |
| `UPD_DTM_BF` | Field | Update date-time before — the timestamp of the record before the update operation |
| `FUNC_CD_1` | Constant | Function code 1 — "Check & Register" mode, meaning the CBS validates data and inserts/registers it |
| `SC` | Acronym | Service Component — a component that handles business logic and communicates with CBS |
| `CBS` | Acronym | Common Business Service — the backend service layer that performs CRUD operations on database tables |
| `CAANMsg` | Class | CAAN Message — a message object used for structured data exchange between SCs and CBS components |
| `ServiceComponentRequestInvoker` | Class | A utility class for invoking service components, used to pass logging context |
| `EKK0011D020CBS` | CBS | Malware blocking application registration CBS — registers new malware blocking applications and assigns detail numbers |
| `EKK0021C060CBS` | CBS | Follow-up work delegation CBS — handles ID migration work delegation for newly registered applications |
| `JCCBPCommon` | Class | Common business processing utility class — provides shared methods like `getSysDateTimeStamp()` and `getOpeDate()` |
| `JPCModelConstant.FUNC_CD_1` | Constant | Function code constant for "Check & Register" operation mode |
| `MALWARE_BLOCKING_NON_FLG_ON` | Constant | "1" — indicates malware blocking unblocking flag is ON |
| `UPDATE_IDO_DIV` | Constant | "00033" — ID migration division code for update operations |
| `TEMPLATE_ID_EKK0011D020` | Constant | "EKK0011D020" — template ID for the malware blocking application registration CBS |
| `TEMPLATE_ID_EKK0021C060` | Constant | "EKK0021C060" — template ID for the follow-up work delegation CBS |
| KKSV0945 | Screen | Malware blocking information management/update screen — the customer portal screen for managing malware blocking services |
| `malwareBlockingMain` | Method | Main processing method for malware blocking information management and update operations |
| `updateMalwareBlockingInfo` | Method | Updates malware blocking information, including registration of new applications via `insertMskm` |
| SYSID | Field | System ID — identifies the source system initiating the request |
| K-Opticom | Business term | Japanese telecommunications provider — the business domain of this customer base system |