Skip to content

Commit

Permalink
fix uuid for user
Browse files Browse the repository at this point in the history
  • Loading branch information
ojwanganto committed Jul 4, 2024
1 parent b1ef630 commit a46d9c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private Map createUserMap(User u) {
Person p = u.getPerson();
Map map = new HashMap();
map.put("name", p.getPersonName().getFullName());
map.put("uuid", p.getUuid());
map.put("uuid", u.getUuid());
return map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public List<DataFilterDefaultResponse> searchEntityBasisMap(@Valid @RequestBody
&& basisDomain.equalsIgnoreCase("org.openmrs.Location")) {
basis = Context.getLocationService().getLocationByUuid(basisIdentifier);
}

if (entity != null && basis == null) {
entityBasisMaps = dataFilterService.getEntityBasisMaps(entity, basisDomain);
} else if (basis != null && entity == null) {
Expand All @@ -124,7 +124,7 @@ public List<DataFilterDefaultResponse> searchEntityBasisMap(@Valid @RequestBody
}
return dataFilterMapper.constructResponse(entityBasisMaps.stream().collect(Collectors.toList()));
}

@RequestMapping(method = RequestMethod.POST, value = "revoke")
@ResponseBody
public ResponseEntity<Object> revokeAccess(@Valid @RequestBody EntityBasisMap entityBasisMapRequest) {
Expand All @@ -135,29 +135,29 @@ public ResponseEntity<Object> revokeAccess(@Valid @RequestBody EntityBasisMap en
String entityIdentifier = entityBasisMapRequest.getEntityIdentifier();
String basisDomain = entityBasisMapRequest.getBasisType();
String basisIdentifier = entityBasisMapRequest.getBasisIdentifier();

if (StringUtils.isNotBlank(entityDomain) && StringUtils.isNotBlank(entityIdentifier)
&& entityDomain.equalsIgnoreCase("org.openmrs.User")) {
&& entityDomain.equalsIgnoreCase("org.openmrs.User")) {
entity = Context.getUserService().getUserByUuid(entityIdentifier);
} else if (StringUtils.isNotBlank(entityDomain) && StringUtils.isNotBlank(entityIdentifier)
&& entityDomain.equalsIgnoreCase("org.openmrs.Patient")) {
&& entityDomain.equalsIgnoreCase("org.openmrs.Patient")) {
entity = Context.getPatientService().getPatientByUuid(entityIdentifier);
}

if (StringUtils.isNotBlank(basisDomain) && StringUtils.isNotBlank(basisIdentifier)
&& basisDomain.equalsIgnoreCase("org.openmrs.Location")) {
&& basisDomain.equalsIgnoreCase("org.openmrs.Location")) {
basis = Context.getLocationService().getLocationByUuid(basisIdentifier);
}
if (entity == null) {
return new ResponseEntity<>("Data filter Entity is required!", HttpStatus.BAD_REQUEST);
}

if (basis == null) {
return new ResponseEntity<>("Data filter Basis is required!", HttpStatus.BAD_REQUEST);
}
dataFilterService.revokeAccess(entity, basis);
return new ResponseEntity<>("Access has been revoked successfully", HttpStatus.OK);

}
catch (Exception e) {
log.error("Runtime error while trying to revoke data filter access", e);
Expand Down

0 comments on commit a46d9c2

Please sign in to comment.