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

This method performs **ISP Authentication ID and Password Change** for downstream business partner (卸先事業者) scenarios within the e-Glass (eo Hikari) telecommunications service platform. It orchestrates a two-phase service interface (SC) interaction to securely update a customer's ISP credentials while maintaining data consistency through versioned updates.

The method follows a **routed delegation pattern**: it first calls service component `EKK0171B002` (Auth ISP Password Authentication List Matching / 認証IDパスワード認証一覧照会) to resolve the service contract line item number (`svcKeiUcwkNo`) and retrieve the current `lastUpdDtm` (last update datetime) by matching against the stored authentication ID and password. This establishes the authoritative contract context.

It then calls service component `EKK0171C012` (ISP Auth ID Password Change / ISP認証IDパスワード変更) to actually perform the password change operation, passing the resolved `svcKeiUcwkNo`, the new `authenticationIdPassword`, and the `lastUpdDtm` for optimistic concurrency control (the `UPD_DTM_BF` field captures the previous update timestamp for validation).

This is a **shared utility method** (private access) called by `chgNsidPwd()` within the same class, serving as the core credential update engine for ISP authentication ID/password changes in downstream business partner contexts. It implements a **read-before-write** pattern using the last update timestamp as a version guard.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chgISPNsidPwd(params)"])
    BUILD_IN_MAP["Build ekk0171b002In input map with template, function code, sysid, ninshoId, ninshoIdPwd"]
    CALL_EKK0171B002["callSC: EKK0171B002 - Auth ISP Password Authentication List Matching"]
    GET_MSG_LIST["Extract EKK0171B002CBSMSG1LIST from response"]
    CHECK_MSG_LIST["Message list empty?"]
    GET_LAST_MSG["Get last message from list"]
    EXTRACT_FIELDS["Extract svcKeiUcwkNo, geneAddDtm, lastUpdDtm from last message"]
    BUILD_CHANGE_IN["Build ekk0171c012In input map with template, function code, svcKeiUcwkNo, authenticationIdPassword, lastUpdDtm"]
    CALL_EKK0171C012["callSC: EKK0171C012 - ISP Auth ID Password Change"]
    CHECK_GENE_DTM["Contains KK0161_GENE_ADD_DTM key?"]
    EXTRACT_GENE_DTM["Extract kk0161GeneAddDtm from response"]
    END_NODE(["Return void"])

    START --> BUILD_IN_MAP --> CALL_EKK0171B002 --> GET_MSG_LIST --> CHECK_MSG_LIST
    CHECK_MSG_LIST -- "Yes (non-null AND length > 0)" --> GET_LAST_MSG --> EXTRACT_FIELDS
    CHECK_MSG_LIST -- "No" --> BUILD_CHANGE_IN
    EXTRACT_FIELDS --> BUILD_CHANGE_IN --> CALL_EKK0171C012 --> CHECK_GENE_DTM
    CHECK_GENE_DTM -- "Yes" --> EXTRACT_GENE_DTM
    CHECK_GENE_DTM -- "No" --> END_NODE
    EXTRACT_GENE_DTM --> END_NODE
```

**Processing Flow Summary:**

1. **Phase 1 — Authentication Resolution**: Builds an input map for the `EKK0171B002` service call, passing the stored `sysid`, `ninshoId`, and `ninshoIdPwd` along with template ID and function code `FUNC_CD_1` ("1"). Invokes `callSC()` to query the authentication password list.

2. **Phase 1 Result Extraction**: Extracts the response message list from `EKK0171B002CBSMSG1LIST`. If the list is non-null and non-empty, reads the **last entry** (index `length - 1`) to extract `svcKeiUcwkNo` (service contract line item number), `geneAddDtm` (generation registration datetime), and `lastUpdDtm` (last update datetime).

3. **Phase 2 — Password Change**: Builds an input map for `EKK0171C012`, passing the resolved `svcKeiUcwkNo`, the new `authenticationIdPassword`, and the `lastUpdDtm` (as `UPD_DTM_BF` for optimistic concurrency). Invokes `callSC()` to execute the actual password change.

4. **Phase 2 Result Handling**: If the response contains the `KK0161_GENE_ADD_DTM` key, extracts `kk0161GeneAddDtm` (generation registration datetime for service contract) for downstream use. Returns void.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle for the current transaction context. Carries the active database connection and transaction state for service component invocations. |
| 2 | `scCall` | `ServiceComponentRequestInvoker` | Service Component invocation router that dispatches SC calls to the appropriate backend service. Enables indirect dispatch through the platform's service component framework. |
| 3 | `param` | `IRequestParameterReadWrite` | Request parameter I/O object for passing data between SC calls. Used as a shared parameter container across the two-phase SC interaction. |
| 4 | `fixedText` | `String` | User-defined fixed string, typically used as a trace or audit identifier embedded in SC call requests for logging and monitoring purposes. |
| 5 | `authenticationIdPassword` | `String` | The **new** ISP authentication ID and password to be set after the change. This is the updated credential value that will replace the existing one on the service contract line item. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `sysid` | `String` | System ID — identifies the target system context for authentication matching |
| `ninshoId` | `String` | Authentication ID (認定ID) — the current ISP credential to match against |
| `ninshoIdPwd` | `String` | Authentication ID Password (認定IDパスワード) — the current password to match against |
| `svcKeiUcwkNo` | `String` | Service Contract Line Item Number (サービス契約内容番号) — resolved from Phase 1, identifies the specific service contract line item |
| `geneAddDtm` | `String` | Generation Registration Datetime (世代登録年月日時分秒) — registration timestamp for the credential record |
| `kk0161GeneAddDtm` | `String` | Generation Registration Datetime for Service Contract (サービス契約) — extracted from Phase 2 response for downstream use |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` | EKK0171B002 | EKK0171B002CBSMsg1List | Calls `callSC` to execute Auth ISP Password Authentication List Matching — queries service contract line items matching the stored authentication ID and password. Resolves `svcKeiUcwkNo`, `geneAddDtm`, `lastUpdDtm` from the response. |
| R | `callSC` | EKK0171C012 | EKK0171C012CBSMsg | Calls `callSC` to execute ISP Auth ID Password Change — updates the credential for the resolved service contract line item. Returns `kk0161GeneAddDtm` if present. |

**CRUD Classification:**
- Both calls are **Read (R)** operations from the method's perspective — `EKK0171B002` reads to find matching credentials, and `EKK0171C012` performs the update (but from this method's perspective, it delegates the write through the SC framework).

## 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: `callSC` [R], `callSC` [R]  # NOSONAR

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Class: `JKKNsidPwdChgOrsjgsCC` | `chgNsidPwd()` -> `chgISPNsidPwd()` | `callSC (EKK0171B002) [R]`, `callSC (EKK0171C012) [R]` |

**Notes:**
- `chgNsidPwd()` is the direct caller within the same class (`JKKNsidPwdChgOrsjgsCC`).
- No direct screen entry points (KKSV*) or batch entry points were found within 8 hops of the call graph.
- The method serves as an internal utility method (private access) for credential change operations, likely invoked as part of a broader service contract modification flow.

## 6. Per-Branch Detail Blocks

**Block 1** — SET (L630-637)

> Build the input map for Phase 1: Auth ISP Password Authentication List Matching (認証IDパスワード認証一覧照会)

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object[][] ekk0171b002In = { ... }` // Input map for EKK0171B002 SC call |
| 2 | SET | `EKK0171B002CBSMsg.TEMPLATEID -> TEMPLATE_ID_EKK0171B002` // [-> "EKK0171B002"] Template ID |
| 3 | SET | `EKK0171B002CBSMsg.FUNC_CODE -> JPCModelConstant.FUNC_CD_1` // [-> "1"] Function code 1 |
| 4 | SET | `EKK0171B002CBSMsg.KEY_SYSID -> sysid` // Instance field: System ID |
| 5 | SET | `EKK0171B002CBSMsg.KEY_ISP_NINSHO_ID -> ninshoId` // Instance field: Current authentication ID |
| 6 | SET | `EKK0171B002CBSMsg.KEY_ISP_NINSHO_ID_PWD -> ninshoIdPwd` // Instance field: Current authentication password |

**Block 2** — CALL (L639-641)

> Execute Phase 1 SC call: retrieve authentication password list matching the current credentials

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, ekk0171b002In, fixedText, new EKK0171B002CBSMsg().getContents())` |
| 2 | EXEC | `.getCAANMsgList(EKK0171B002CBSMsg.EKK0171B002CBSMSG1LIST)` // Extract message list from response |
| 3 | SET | `CAANMsg[] ekk0171b002Msg1List` // Response: array of authentication messages |

**Block 3** — SET (L642-643)

> Initialize local variables for Phase 1 result extraction

| # | Type | Code |
|---|------|------|
| 1 | SET | `String lastUpdDtm = ""` // Initialize last update datetime (empty default) |

**Block 4** — IF (condition: `null != ekk0171b002Msg1List && 0 < ekk0171b002Msg1List.length`) (L645-652)

> Extract the last message from the authentication list response to resolve service contract details. The comment says "Assuming single row" (単一行である想定).

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwkNo = ekk0171b002Msg1List[length - 1].getString(EKK0171B002CBSMsg1List.SVC_KEI_UCWK_NO)` // [-> Service contract line item number] Resolves the contract context |
| 2 | SET | `geneAddDtm = ekk0171b002Msg1List[length - 1].getString(EKK0171B002CBSMsg1List.GENE_ADD_DTM)` // [-> Generation registration datetime] Timestamp for the credential record |
| 3 | SET | `lastUpdDtm = ekk0171b002Msg1List[length - 1].getString(EKK0171B002CBSMsg1List.LAST_UPD_DTM)` // [-> Last update datetime] For optimistic concurrency control in Phase 2 |

**Block 4.1** — ELSE (implicit: empty or null list) (L645)

> If no authentication messages are returned, `svcKeiUcwkNo`, `geneAddDtm`, and `lastUpdDtm` retain their default values (`""` for `lastUpdDtm`). The method proceeds to Phase 2 with these empty values, which may cause the downstream SC to return an error or no-change response.

**Block 5** — SET (L654-660)

> Build the input map for Phase 2: ISP Auth ID Password Change (ISP認証IDパスワード変更)

| # | Type | Code |
|---|------|------|
| 1 | SET | `Object[][] ekk0171c012In = { ... }` // Input map for EKK0171C012 SC call |
| 2 | SET | `EKK0171C012CBSMsg.TEMPLATEID -> TEMPLATE_ID_EKK0171C012` // [-> "EKK0171C012"] Template ID |
| 3 | SET | `EKK0171C012CBSMsg.FUNC_CODE -> JPCModelConstant.FUNC_CD_1` // [-> "1"] Function code 1 |
| 4 | SET | `EKK0171C012CBSMsg.SVC_KEI_UCWK_NO -> svcKeiUcwkNo` // [-> resolved from Phase 1] Service contract line item to update |
| 5 | SET | `EKK0171C012CBSMsg.ISP_NINSHO_ID_PWD -> authenticationIdPassword` // [-> new credential] The new password to set |
| 6 | SET | `EKK0171C012CBSMsg.UPD_DTM_BF -> lastUpdDtm` // [-> from Phase 1] Previous update timestamp for optimistic concurrency |

**Block 6** — CALL (L663-664)

> Execute Phase 2 SC call: actually change the ISP authentication password

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, ekk0171c012In, fixedText, new EKK0171C012CBSMsg().getContents())` |
| 2 | SET | `CAANMsg ekk0171c012Msg1List` // Response: single message from password change SC |

**Block 7** — IF (condition: `ekk0171c012Msg1List.containsKeyOfMsgData(EKK0171C012CBSMsg.KK0161_GENE_ADD_DTM)`) (L666-669)

> Extract the generation registration datetime for service contract if present in the response. This field is optional (checked via `containsKeyOfMsgData`).

| # | Type | Code |
|---|------|------|
| 1 | SET | `kk0161GeneAddDtm = ekk0171c012Msg1List.getString(EKK0171C012CBSMsg.KK0161_GENE_ADD_DTM)` // [-> Generation registration datetime for service contract] Extracted for downstream use |

**Block 7.1** — ELSE (implicit: key not present) (L666)

> If `KK0161_GENE_ADD_DTM` is not present in the response, `kk0161GeneAddDtm` retains its default value (`""`). The method continues without this value.

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `ninshoId` | Field | Authentication ID (認定ID) — the ISP credential identifier (username) for the customer |
| `ninshoIdPwd` | Field | Authentication ID Password (認定IDパスワード) — the current ISP credential password |
| `svcKeiUcwkNo` | Field | Service Contract Line Item Number (サービス契約内容番号) — internal tracking ID for a specific line item within a service contract |
| `geneAddDtm` | Field | Generation Registration Datetime (世代登録年月日時分秒) — timestamp when the credential record was created |
| `lastUpdDtm` | Field | Last Update Datetime (最終更新年月日時分秒) — most recent modification timestamp for optimistic concurrency control |
| `kk0161GeneAddDtm` | Field | Generation Registration Datetime for Service Contract (サービス契約) — extracted from EKK0171C012 response |
| `sysid` | Field | System ID — identifies the target system in the authentication matching process |
| `fixedText` | Parameter | User-defined fixed string — audit trace identifier passed through SC calls |
| `authenticationIdPassword` | Parameter | New ISP Authentication ID Password (変更後認証IDパスワード) — the updated credential to set |
| `FUNC_CD_1` | Constant | Function code "1" — standard function type for SC operations (from JPCModelConstant) |
| `TEMPLATE_ID_EKK0171B002` | Constant | "EKK0171B002" — template ID for Auth ISP Password Authentication List Matching (認証IDパスワード認証一覧照会) |
| `TEMPLATE_ID_EKK0171C012` | Constant | "EKK0171C012" — template ID for ISP Auth ID Password Change (ISP認証IDパスワード変更) |
| EKK0171B002 | SC Code | Auth ISP Password Authentication List Matching — queries credential records matching the authentication ID and password |
| EKK0171C012 | SC Code | ISP Auth ID Password Change — performs the actual credential update on a service contract line item |
| ISP | Business term | Internet Service Provider — in this context, refers to the ISP authentication credentials for e-Glass (eo Hikari) customers |
| SC | Acronym | Service Component — platform service call that handles business logic and data access |
| CC | Acronym | Common Component — reusable shared business logic class extending `AbstractCommonComponent` |
| CAANMsg | Class | CAAN Message — platform message container for passing data between SC calls |
| `ID_PWD_SHKKA_CC_MAP` | Constant | "IdPwdShkkaSaifurHakkoCC" — key for ISP password reset/rel issuance common component map |
| `HAKKO_SOD_CC_MAP` | Constant | "HakkoSODCC" — key for order issuance SOD common component map |
| `CATEGORY_OF_CHANGE_CHG` | Constant | "1" — change (変更) category indicator |
| `CATEGORY_OF_CHANGE_SHKKA` | Constant | "2" — initialization (初期化) category indicator |
| ISP | Business term | Internet Service Provider — refers to the ISP authentication credentials (ID and password) for e-Glass (eo Hikari) broadband customers |
| 卸先事業者 | Business term | Downstream business partner — B2B channel partner that provides ISP services to end customers |
| 認証 | Business term | Authentication (認定) — the verification process for customer ISP credentials |
| サービス契約 | Business term | Service contract — the agreement between the customer and the ISP service |
| 世代登録 | Business term | Generation registration — tracking of credential record versions/timestamps |
| 最終更新 | Business term | Last update — most recent modification timestamp for versioned data |
| 単一行 | Comment | Assumed single row — the code assumes the authentication list response contains exactly one matching row |
