Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/environment/1097_ci.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ elasticsearch.index.beneficiary=@env.ELASTICSEARCH_INDEX_BENEFICIARY@
# Enable/Disable ES (for gradual rollout)
elasticsearch.enabled=@env.ELASTICSEARCH_ENABLED@

# Van/local-laptop deployments only. The 1097 service is not a van deployment, so this
# stays false β€” but must still be set explicitly, since IdentityService.java (shared with
# the common_* build) now requires this property with no inline default.
stoptb.enforce.vanid=false

5 changes: 5 additions & 0 deletions src/main/environment/1097_docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ elasticsearch.index.beneficiary=${ELASTICSEARCH_INDEX_BENEFICIARY}
# Enable/Disable ES (for gradual rollout)
elasticsearch.enabled=${ELASTICSEARCH_ENABLED}

# Van/local-laptop deployments only. The 1097 service is not a van deployment, so this
# stays false β€” but must still be set explicitly, since IdentityService.java (shared with
# the common_* build) now requires this property with no inline default.
stoptb.enforce.vanid=false

5 changes: 5 additions & 0 deletions src/main/environment/1097_example.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ elasticsearch.index.beneficiary=beneficiary_index
# Enable/Disable ES (for gradual rollout)
elasticsearch.enabled=true

# Van/local-laptop deployments only. The 1097 service is not a van deployment, so this
# stays false β€” but must still be set explicitly, since IdentityService.java (shared with
# the common_* build) now requires this property with no inline default.
stoptb.enforce.vanid=false

Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ private JdbcTemplate getJdbcTemplate() {
@Value("${elasticsearch.enabled}")
private boolean esEnabled;

// Van/local-laptop deployments only β€” see RmnchDataSyncServiceImpl and FLW-API's
// CampConfigService for the same flag. createIdentity() previously had no enforcement
// check at all, so a missing vanID here would silently save VanID=NULL instead of failing.
// No inline default: every properties file must set this explicitly, so a forgotten
// config fails loudly at startup instead of silently running fail-open.
@Value("${stoptb.enforce.vanid}")
private boolean enforceVanID;

public void getBenAdress() {
logger.debug("Address count: " + addressRepo.count());
logger.debug(
Expand Down Expand Up @@ -1385,6 +1393,11 @@ private MBeneficiarydetail convertIdentityEditDTOToMBeneficiarydetail(IdentityEd
public BeneficiaryCreateResp createIdentity(IdentityDTO identity) {
logger.info("IdentityService.createIdentity - start");

if (identity.getVanID() == null && enforceVanID) {
throw new IllegalStateException(
"Camp not configured: vanID missing. Please select van/service point in MMU before registering beneficiary.");
}

// Atomically claim the next available ID using SELECT … FOR UPDATE SKIP LOCKED.
// This is safe across multiple app servers sharing the same database β€” each server
// locks and reserves a distinct row, so duplicate BenRegId inserts cannot occur.
Expand Down Expand Up @@ -1764,8 +1777,8 @@ private MBeneficiaryImage identityDTOToMBeneficiaryImage(IdentityDTO identity) {
beneficiaryImage.setCreatedDate(identity.getCreatedDate());
if (identity.getVanID() != null) {
beneficiaryImage.setVanID(identity.getVanID());
}
if (identity.getBenFamilyDTOs() != null) {
} else if (identity.getBenFamilyDTOs() != null && !identity.getBenFamilyDTOs().isEmpty()
&& identity.getBenFamilyDTOs().get(0).getVanID() != null) {
beneficiaryImage.setVanID(identity.getBenFamilyDTOs().get(0).getVanID());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ public class RmnchDataSyncServiceImpl implements RmnchDataSyncService {
private String fhirUrl;

// When true, sync fails loudly if camp is not configured instead of silently
// skipping vanID stamping
@Value("${stoptb.enforce.vanid:false}")
// skipping vanID stamping. No inline default β€” every properties file must set this
// explicitly, so a forgotten config fails loudly at startup instead of running fail-open.
@Value("${stoptb.enforce.vanid}")
private boolean enforceVanID;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@Override
Expand Down Expand Up @@ -401,6 +402,10 @@ public String syncDataToAmrit(String requestOBJ, String authorization) throws Ex
if (hhTimestampMap.containsKey(obj.getHouseoldId()))
obj.setGpsTimestamp(new Timestamp(hhTimestampMap.get(obj.getHouseoldId())));
}
// Set VanID/ParkingPlaceID for both NEW and existing households β€” this must
// stay OUTSIDE the "household already exists" block above (it's regressed
// back inside there twice already via merges), otherwise a brand-new
// household never gets VanID stamped, breaking van-scoped sync.
if (obj.getVanID() == null && vanID != null) {
obj.setVanID(vanID);
obj.setParkingPlaceID(parkingPlaceID);
Expand Down
Loading