# Business Logic — JKKCmpMalwareBlockingApiCC.getErrOfSvcKei() [37 LOC]

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

## 1. Role

### JKKCmpMalwareBlockingApiCC.getErrOfSvcKei()

The `getErrOfSvcKei` method serves as a **business rule validation gate** within the eo Customer Core System's Malware Blocking information synchronization and update pipeline. Its core purpose is to check whether a given service contract record (specifically for eo Hikari Net / eo Light Net fiber broadband services) is eligible to be processed, and if not, register an appropriate business-level error. This method implements a **guard clause / early-failure pattern**: rather than transforming data, it inspects the contract's price group and current status, then rejects records that fall outside the allowed processing scope.

The method handles two distinct service domains. First, it validates the **price group code** (`prcGrpCd`) of the service contract — the method only accepts three price groups: "02" (eo Hikari Net Home Type), "03" (eo Hikari Net Meshon Type), and "04" (eo Hikari Net Manshon Type). Any other price group code is rejected because malware blocking is not applicable to those service categories. Second, and only when the processing type is an update ("2"), it validates the **service contract status** (`svcKeiStat`) — it rejects contracts that are already in "010" (Received), "910" (Disconnected), or "920" (Cancelled) status, because malware blocking updates cannot be applied to contracts in these states. The method delegates error-map construction to `getExistErrInfMap`, which returns a standard error structure using error code `RETURN_CD_2001` (business error — input validation failure). This method is called directly by `malwareBlockingMain`, which is the main entry point for the malware blocking API CC, and is the second validation step after `getErrOfUnitParam` (unit-level parameter check).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["getErrOfSvcKei"])
    INIT["Create empty errList"]
    START --> INIT
    INIT --> COND_NULL{Is ekk0081a010 null?}
    COND_NULL -->|Yes| ERR_NULL["Add error: getExistErrInfMap with SVC_KEI_NO"]
    COND_NULL -->|No| COND_PRG["Get prcGrpCd from ekk0081a010.getString"]
    COND_PRG --> COND_PRG_CHK{Is prcGrpCd valid?}
    COND_PRG_CHK -->|02 or 03 or 04| COND_UPD
    COND_PRG_CHK -->|Other value| ERR_PRG["Add error: getExistErrInfMap with SVC_KEI_NO"]
    COND_UPD --> COND_UPD_CHK{Is processingType == 2?}
    COND_UPD_CHK -->|Yes| GET_STAT["Get svcKeiStat from ekk0081a010.getString"]
    COND_UPD_CHK -->|No| RETURN_ERR
    GET_STAT --> COND_STAT{Is svcKeiStat invalid?}
    COND_STAT -->|010 or 910 or 920| ERR_STAT["Add error: getExistErrInfMap with SVC_KEI_NO"]
    COND_STAT -->|Other| RETURN_ERR
    ERR_NULL --> RETURN_ERR
    ERR_PRG --> RETURN_ERR
    ERR_STAT --> RETURN_ERR
    RETURN_ERR(["Return errList"])
```

**Conditional branch summary:**

| Condition | Value(s) | Business Meaning | Action |
|-----------|----------|------------------|--------|
| `ekk0081a010 == null` | `null` | No service contract data provided | Add error, return list |
| `prcGrpCd == "02"` | `CD00133_02` | eo Hikari Net Home Type | Proceed to next check |
| `prcGrpCd == "03"` | `CD00133_03` | eo Hikari Net Meshon Type | Proceed to next check |
| `prcGrpCd == "04"` | `CD00133_04` | eo Hikari Net Manshon Type | Proceed to next check |
| `prcGrpCd != "02/03/04"` | any other | Service not in eligible price group | Add error, return list |
| `processingType == "2"` | `PROCESSING_TYPE_UPDATE` | This is an update operation | Check service contract status |
| `svcKeiStat == "010"` | `CD00037_UK_ZM` | Service contract in Received status | Add error, return list |
| `svcKeiStat == "910"` | `CD00037_DSL_ZM` | Service contract Disconnected | Add error, return list |
| `svcKeiStat == "920"` | `CD00037_CANCEL_ZM` | Service contract Cancelled | Add error, return list |
| Default (all checks passed) | — | Contract is valid for processing | Return empty list |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `ekk0081a010` | `CAANMsg` | The service contract record for eo Hikari Net (eo Light Net). This message object carries fields such as `PRC_GRP_CD` (price group code) and `SVC_KEI_STAT` (service contract status) extracted from the EKK0081A010 CBS response. It represents a specific service contract line item in the customer core system. If `null`, it indicates the contract could not be retrieved (e.g., the contract number does not exist). |
| 2 | `processingType` | `String` | The processing type discriminator. Controls which validation path is taken. `"1"` means Reference (read-only check), and `"2"` means Update (data modification). For malware blocking, only update mode triggers the additional status check on the service contract. |

**Referenced constants (resolved):**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `SVC_KEI_NO` | `"svc_kei_no"` | CC Parameter key — service contract number. Used as the item name in error messages. |
| `PROCESSING_TYPE_UPDATE` | `"2"` | Processing Type — Update. Only mode that triggers service contract status validation. |
| `CD00133_02` | `"02"` | Price Group Code — eo Hikari Net Home Type. A residential fiber broadband plan. |
| `CD00133_03` | `"03"` | Price Group Code — eo Hikari Net Meshon Type. A meshon-type fiber broadband plan. |
| `CD00133_04` | `"04"` | Price Group Code — eo Hikari Net Manshon Type. A mansion-type fiber broadband plan. |
| `CD00037_UK_ZM` | `"010"` | Service Contract Status — Received (Uke-tsuzuke Completed). The contract has been received but not yet provided. |
| `CD00037_DSL_ZM` | `"910"` | Service Contract Status — Disconnected (Sho-ryaku Completed). The service contract has been fully disconnected. |
| `CD00037_CANCEL_ZM` | `"920"` | Service Contract Status — Cancelled (Kyansel Completed). The service contract has been cancelled. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatFUCaseFileRnkData.getString` | JBSbatFUCaseFileRnkData | - | Calls `getString` in `JBSbatFUCaseFileRnkData` (called via `nullToStr` internally) |
| R | `JBSbatFUMoveNaviData.getString` | JBSbatFUMoveNaviData | - | Calls `getString` in `JBSbatFUMoveNaviData` (called via `nullToStr` internally) |
| R | `JBSbatZMAdDataSet.getString` | JBSbatZMAdDataSet | - | Calls `getString` in `JBSbatZMAdDataSet` (called via `nullToStr` internally) |
| R | `JKKCmpMalwareBlockingApiCC.getExistErrInfMap` | - | - | Calls `getExistErrInfMap` in the same class — creates an error map with error code `RETURN_CD_2001` for the specified item name. |
| - | `JKKCmpMalwareBlockingApiCC.nullToStr` | - | - | Static utility method that wraps `JKKStringUtil.isNullBlank` — converts null/blank to empty string. Used for safe string extraction from CAANMsg. |
| R | `JESC0101B010TPMA.getString` | JESC0101B010TPMA | - | Calls `getString` in `JESC0101B010TPMA` (called via `nullToStr` internally) |
| R | `JESC0101B020TPMA.getString` | JESC0101B020TPMA | - | Calls `getString` in `JESC0101B020TPMA` (called via `nullToStr` internally) |

**Detailed call analysis for `getErrOfSvcKei`:**

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `CAANMsg.getString(String key)` | EKK0081A010SC | Service contract record | Retrieves `prcGrpCd` from the EKK0081A010 CBS message (price group code). Called via `ekk0081a010.getString(EKK0081A010CBSMsg1List.PRC_GRP_CD)`. |
| R | `CAANMsg.getString(String key)` | EKK0081A010SC | Service contract record | Retrieves `svcKeiStat` from the EKK0081A010 CBS message (service contract status). Called via `ekk0081a010.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT)`. |
| R | `nullToStr(String val)` | - | - | Static utility — wraps `JKKStringUtil.isNullBlank`, returns `""` for null/blank inputs. Ensures safe string comparison without NPE. |
| R | `JKKCmpMalwareBlockingApiCC.getExistErrInfMap(String itemName)` | - | - | Returns a `Map<String, String>` containing error code `RETURN_CD_2001` and an empty message. Used to build the error list when validation fails. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `getExistErrInfMap` [R], `nullToStr` [-], `getString` [R], `getString` [R], `getExistErrInfMap` [R], `nullToStr` [-], `getString` [R], `getExistErrInfMap` [R]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | `JKKCmpMalwareBlockingApiCC.malwareBlockingMain()` | `malwareBlockingMain(handle, param, fixedText)` → `getEKK0081A010(handle, param, fixedText)` (gets CAANMsg) → `getErrOfSvcKei(ekk0081a010, processingType)` | `getExistErrInfMap [R] (error code RETURN_CD_2001)`<br>`getString [R] EKK0081A010CBSMsg1List.PRC_GRP_CD`<br>`getString [R] EKK0081A010CBSMsg1List.SVC_KEI_STAT` |

**Call flow description:**

1. `malwareBlockingMain()` (public entry point, EJB Module layer) is the sole direct caller.
2. It first performs unit-level parameter validation via `getErrOfUnitParam()`.
3. If unit-level checks pass, it retrieves the service contract by calling `getEKK0081A010()`, which invokes the EKK0081A010 Service Component to fetch the contract data as a `CAANMsg` object.
4. It then passes the retrieved contract to `getErrOfSvcKei()` to validate whether the contract is eligible for malware blocking processing.
5. If `getErrOfSvcKei()` returns a non-empty error list, `malwareBlockingMain()` sets the return code to `RETURN_CD_5000` (business error) and returns early.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `errList` initialization (L314)

> Creates a new empty ArrayList to accumulate validation errors.

| # | Type | Code |
|---|------|------|
| 1 | SET | `errList = new ArrayList<Map<String, String>>();` // Initialize empty error list |

**Block 2** — [IF] `ekk0081a010 == null` (L317)

> If the service contract message is null, the contract could not be retrieved (e.g., the contract number does not exist in the system). This is treated as a business error, and an error entry is registered.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0081a010 == null` // Service contract is null [-> null check] |
| 2 | CALL | `getExistErrInfMap(SVC_KEI_NO)` // Creates error map with code RETURN_CD_2001 for "svc_kei_no" [-> ERROR_INFO, RETURN_CD_2001] |
| 3 | EXEC | `errList.add(...)` // Add the error map to the error list |

**Block 3** — [ELSE] `ekk0081a010 != null` (L324)

> The service contract record exists. Proceed to validate the price group code.

**Block 3.1** — [SET] Price group code extraction (L327)

> Extracts the price group code from the service contract message. The `nullToStr` utility is applied to handle null values safely, converting them to an empty string.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prcGrpCd = nullToStr(ekk0081a010.getString(EKK0081A010CBSMsg1List.PRC_GRP_CD))` // Price group code from service contract [-> nullToStr applied] |

**Block 3.2** — [IF] Price group code validation (L328–333)

> Checks if the price group code is one of the three eligible types for malware blocking: "02" (eo Hikari Net Home Type), "03" (eo Hikari Net Meshon Type), or "04" (eo Hikari Net Manshon Type). If the code is none of these, the service contract is not eligible for malware blocking, and an error is registered.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prcGrpCd != "02"` [CD00133_02] // Price group not Home Type |
| 2 | SET | `prcGrpCd != "03"` [CD00133_03] // Price group not Meshon Type |
| 3 | SET | `prcGrpCd != "04"` [CD00133_04] // Price group not Manshon Type |
| 4 | COND | `!JKKStrConst.CD00133_02.equals(prcGrpCd) && !JKKStrConst.CD00133_03.equals(prcGrpCd) && !JKKStrConst.CD00133_04.equalsIgnoreCase(prcGrpCd)` // Not one of the three eligible price groups |
| 5 | CALL | `getExistErrInfMap(SVC_KEI_NO)` // Creates error map for ineligible price group [-> ERROR_INFO, RETURN_CD_2001] |
| 6 | EXEC | `errList.add(...)` // Add the error map to the error list |

**Block 3.3** — [ELSE-IF] Update-mode status check (L335–342)

> Only when the processing type is "2" (Update), this additional check validates the service contract status. Malware blocking updates cannot be applied to contracts that are in "010" (Received), "910" (Disconnected), or "920" (Cancelled) status.

| # | Type | Code |
|---|------|------|
| 1 | SET | `processingType == "2"` [PROCESSING_TYPE_UPDATE = "2"] // Update processing mode |
| 2 | COND | `StringUtils.equals(PROCESSING_TYPE_UPDATE, processingType)` // Only runs for update operations |

**Block 3.3.1** — [SET] Service contract status extraction (L336)

> Extracts the service contract status from the message. The `nullToStr` utility ensures safe comparison.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiStat = nullToStr(ekk0081a010.getString(EKK0081A010CBSMsg1List.SVC_KEI_STAT))` // Service contract status from message [-> nullToStr applied] |

**Block 3.3.2** — [IF] Service contract status validation (L337–342)

> Checks if the service contract status is one of the invalid statuses for update operations: "010" (Received / Uketsuke Zumi), "910" (Disconnected / Sho-ryaku Zumi), or "920" (Cancelled / Kyansel Zumi). If any of these statuses are detected, an error is registered because malware blocking cannot be applied to contracts in these states.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiStat == "010"` [CD00037_UK_ZM] // Received status |
| 2 | SET | `svcKeiStat == "910"` [CD00037_DSL_ZM] // Disconnected status |
| 3 | SET | `svcKeiStat == "920"` [CD00037_CANCEL_ZM] // Cancelled status |
| 4 | COND | `JKKStrConst.CD00037_UK_ZM.equals(svcKeiStat) \|\| JKKStrConst.CD00037_DSL_ZM.equals(svcKeiStat) \|\| JKKStrConst.CD00037_CANCEL_ZM.equals(svcKeiStat)` // Contract in invalid status for update |
| 5 | CALL | `getExistErrInfMap(SVC_KEI_NO)` // Creates error map for invalid status [-> ERROR_INFO, RETURN_CD_2001] |
| 6 | EXEC | `errList.add(...)` // Add the error map to the error list |

**Block 4** — [RETURN] Return error list (L345)

> Returns the accumulated error list. If no errors were encountered, the list is empty (indicating the service contract is valid for malware blocking processing).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return errList;` // Returns error list (empty if valid) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `svc_kei_no` | Field | Service Contract Number — the unique identifier for a service contract line item in the customer core system. Used as the item name in error messages. |
| `prc_grp_cd` | Field | Price Group Code — classifies the type of service contract's pricing group. Determines which family of services the contract belongs to (e.g., home type, meshon type, mansion type). |
| `svc_kei_stat` | Field | Service Contract Status — indicates the current lifecycle stage of a service contract. Values include "010" (Received), "020" (Investigation Completed), "030" (Contracted), "100" (Service Provision Ongoing), "910" (Disconnected), "920" (Cancelled). |
| `processing_type` | Field | Processing Type discriminator. "1" = Reference (read-only), "2" = Update (data modification). Controls which validation paths are active. |
| MALWARE_BLOCKING | Business term | Malware Blocking information synchronization and update (マルウェアブロッキング情報照会・更新). A feature that applies malware blocking to specified service contracts for eo customers. |
| CMP | Acronym | Contract Malware Blocking Proceso (Contracts). The shared component class for malware blocking information. |
| `CD00133_02` | Constant | Price Group Code = "02" — eo Hikari Net Home Type (eo光ネットホームタイプ). Residential fiber broadband plan for single-family homes. |
| `CD00133_03` | Constant | Price Group Code = "03" — eo Hikari Net Meshon Type (eo光ネットメゾンタイプ). Fiber broadband plan for small multi-unit buildings (mansion/loft). |
| `CD00133_04` | Constant | Price Group Code = "04" — eo Hikari Net Manshon Type (eo光ネットマンションタイプ). Fiber broadband plan for large apartment buildings. |
| `CD00037_UK_ZM` | Constant | Service Contract Status = "010" — Received (受付済). The service contract has been received and registered but not yet provided. |
| `CD00037_DSL_ZM` | Constant | Service Contract Status = "910" — Disconnected (解約済). The service contract has been fully disconnected. |
| `CD00037_CANCEL_ZM` | Constant | Service Contract Status = "920" — Cancelled (キャンセル済). The service contract has been cancelled. |
| `RETURN_CD_2001` | Constant | Business error code — input validation failure. Used when a parameter fails a business rule check. |
| `RETURN_CD_5000` | Constant | Business error code — general business error. Set by the caller (`malwareBlockingMain`) when this method returns a non-empty error list. |
| `EKK0081A010` | CBS Code | Service Contract Inquiry CBS (サービス契約照会). The CBS that retrieves service contract data for eo Hikari Net. |
| `CAANMsg` | Type | Common message class used across the system for carrying CBS request/response data and field-level attributes. |
| `nullToStr` | Utility | Static helper that converts null or blank strings to empty string (""). Prevents NullPointerException during string comparisons. |
| `getExistErrInfMap` | Method | Creates a pre-populated error map with error code `RETURN_CD_2001` and an empty error message for the given item name. Used for field-level validation errors. |
| eo Hikari Net | Business term | eo光ネット (eo Light Net) — NTT East's fiber-to-the-home broadband service brand under the "eo" family. Malware blocking is applicable only to specific price groups within this service. |
| FTTH | Business term | Fiber To The Home — the underlying network technology for eo Hikari Net services. |
