From c27af2505db9048c18206e3eb4bb042ab9448530 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Fri, 17 Feb 2023 11:53:36 +0500 Subject: [PATCH 1/2] Add check to fail gracefully when no locations assigned --- .../web/controller/UserController.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/opensrp/web/controller/UserController.java b/src/main/java/org/opensrp/web/controller/UserController.java index dd16e057d..fbae13d14 100644 --- a/src/main/java/org/opensrp/web/controller/UserController.java +++ b/src/main/java/org/opensrp/web/controller/UserController.java @@ -51,7 +51,6 @@ import org.opensrp.service.PractitionerService; import org.opensrp.web.exceptions.MissingTeamAssignmentException; import org.opensrp.web.rest.RestUtils; -import org.slf4j.LoggerFactory; import org.smartregister.domain.Jurisdiction; import org.smartregister.domain.PhysicalLocation; import org.smartregister.domain.PlanDefinition.PlanStatus; @@ -201,14 +200,19 @@ public ResponseEntity authenticate(Authentication authentication) throws try { String userId = u.getBaseEntityId(); practionerOrganizationIds = practitionerService.getOrganizationsByUserId(userId); - - for (AssignedLocations assignedLocation : organizationService - .findAssignedLocationsAndPlans(practionerOrganizationIds.right)) { - if (StringUtils.isNotBlank(assignedLocation.getJurisdictionId())) - locationIds.add(assignedLocation.getJurisdictionId()); - if (StringUtils.isNotBlank(assignedLocation.getPlanId())) - planIdentifiers.add(assignedLocation.getPlanId()); - } + + if (practionerOrganizationIds != null && practionerOrganizationIds.right.size() > 0) { + for (AssignedLocations assignedLocation : organizationService + .findAssignedLocationsAndPlans(practionerOrganizationIds.right)) { + if (StringUtils.isNotBlank(assignedLocation.getJurisdictionId())) + locationIds.add(assignedLocation.getJurisdictionId()); + if (StringUtils.isNotBlank(assignedLocation.getPlanId())) + planIdentifiers.add(assignedLocation.getPlanId()); + } + } else { + throw new MissingTeamAssignmentException( + "User not mapped on any location. Make sure that user is assigned to an organization with valid Location(s) "); + } jurisdictions.addAll(locationService.findLocationByIdsWithChildren(false, locationIds, Integer.MAX_VALUE)); From 3a6cdb5133219d99537e6a4ffe6d68a8f5f795dc Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Fri, 17 Feb 2023 12:00:51 +0500 Subject: [PATCH 2/2] Cump up core and web versions --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bced9f9c1..3f7ca80b2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ opensrp-server-web war - 3.2.11-SNAPSHOT + 3.2.12-SNAPSHOT opensrp-server-web OpenSRP Server Web Application https://github.com/OpenSRP/opensrp-server-web @@ -25,7 +25,7 @@ 6.1.6.RELEASE always 1.5.1 - 3.2.8-SNAPSHOT + 3.2.9-ALPHA1-SNAPSHOT 2.4.1-SNAPSHOT 2.0.1-SNAPSHOT 2.0.5