Skip to content

Commit

Permalink
Return user UUID in LookupUser call (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanisSaldabols authored Oct 8, 2024
1 parent 49d6736 commit 92faa91
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions src/main/java/org/folio/ncip/services/FolioLookupUserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.folio.ncip.Constants;
import org.folio.ncip.FolioNcipException;
import org.folio.ncip.FolioRemoteServiceManager;

import java.util.List;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -114,36 +116,41 @@ public LookupUserResponseData performService(LookupUserInitiationData initData,
return responseData;
}

private LookupUserResponseData constructResponse(LookupUserInitiationData initData,JsonObject userDetails,String requesterAgencyId) throws Exception {

LookupUserResponseData responseData = new LookupUserResponseData();
try {

if (responseData.getUserOptionalFields()==null)
responseData.setUserOptionalFields(new UserOptionalFields());

if (initData.getNameInformationDesired()) {
responseData.getUserOptionalFields().setNameInformation(this.retrieveName(userDetails));
}

if (initData.getUserIdDesired())
responseData.setUserId(this.retrieveBarcode(userDetails,requesterAgencyId));

if (initData.getUserAddressInformationDesired())
responseData.getUserOptionalFields().setUserAddressInformations(this.retrieveAddress(userDetails,requesterAgencyId));

if (initData.getUserPrivilegeDesired()) {
responseData.getUserOptionalFields().setUserPrivileges(this.retrievePrivileges(userDetails,requesterAgencyId));
responseData.getUserOptionalFields().getUserPrivileges().add(this.retrieveBorrowingPrvilege(userDetails,requesterAgencyId));
}
}
catch(Exception e) {
logger.error("error during constructing lookup user construct response:");
logger.error(e.toString());
throw e;
}
return responseData;
}
private LookupUserResponseData constructResponse(LookupUserInitiationData initData,JsonObject userDetails,String requesterAgencyId) throws Exception {

LookupUserResponseData responseData = new LookupUserResponseData();
try {

if (responseData.getUserOptionalFields()==null)
responseData.setUserOptionalFields(new UserOptionalFields());

if (initData.getNameInformationDesired()) {
responseData.getUserOptionalFields().setNameInformation(this.retrieveName(userDetails));
}

if (initData.getUserIdDesired()) {
responseData.setUserId(this.retrieveBarcode(userDetails, requesterAgencyId));
UserId userUuid = new UserId();
userUuid.setUserIdentifierType(new UserIdentifierType("uuid"));
userUuid.setUserIdentifierValue(userDetails.getString("id"));
responseData.getUserOptionalFields().setUserIds(List.of(userUuid));
}

if (initData.getUserAddressInformationDesired())
responseData.getUserOptionalFields().setUserAddressInformations(this.retrieveAddress(userDetails,requesterAgencyId));

if (initData.getUserPrivilegeDesired()) {
responseData.getUserOptionalFields().setUserPrivileges(this.retrievePrivileges(userDetails,requesterAgencyId));
responseData.getUserOptionalFields().getUserPrivileges().add(this.retrieveBorrowingPrvilege(userDetails,requesterAgencyId));
}
}
catch(Exception e) {
logger.error("error during constructing lookup user construct response:");
logger.error(e.toString());
throw e;
}
return responseData;
}

private UserId retrieveBarcode(JsonObject jsonObject,String agencyId) throws Exception {
UserId userId = new UserId();
Expand Down

0 comments on commit 92faa91

Please sign in to comment.