Skip to content

Commit

Permalink
Handle optional aspects/fields for CorpUser gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerem Sahin committed Mar 11, 2020
1 parent 9cd58d5 commit fba5cd8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions datahub-dao/src/main/java/com/linkedin/datahub/util/OwnerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,24 @@ private OwnerUtil() {
public static DatasetOwner toWhOwner(@Nonnull Owner owner, @Nonnull CorpUser corpUser) {
DatasetOwner dsOwner = new DatasetOwner();
dsOwner.setConfirmedBy("UI");
dsOwner.setEmail(corpUser.getInfo().getEmail());
dsOwner.setIdType("USER");
dsOwner.setIsActive(corpUser.getInfo().isActive());
dsOwner.setIsGroup(false);
dsOwner.setName(corpUser.getInfo().getFullName());
dsOwner.setNamespace("urn:li:corpuser");
dsOwner.setSource("UI");
dsOwner.setType(OWNER_CATEGORY_MAP_INV.get(owner.getType()));
dsOwner.setUserName(corpUser.getUsername());
dsOwner.setPictureLink(corpUser.getEditableInfo().getPictureLink().toString());
dsOwner.setType(OWNER_CATEGORY_MAP_INV.get(owner.getType()));

if (corpUser.hasInfo()) {
dsOwner.setEmail(corpUser.getInfo().getEmail());
dsOwner.setIsActive(corpUser.getInfo().isActive());
if (corpUser.getInfo().hasFullName()) {
dsOwner.setName(corpUser.getInfo().getFullName());
}
}

if (corpUser.hasEditableInfo() && corpUser.getEditableInfo().hasPictureLink()) {
dsOwner.setPictureLink(corpUser.getEditableInfo().getPictureLink().toString());
}

return dsOwner;
}
Expand Down

0 comments on commit fba5cd8

Please sign in to comment.