Skip to content

Commit

Permalink
Merge branch 'release/1.3.3.rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Slawomir Wieczorek committed Dec 13, 2024
2 parents 38debc0 + 9a40951 commit fa002e5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class SupersetDashboardsForUserUpdate {
List<DashboardForUserDto> dashboards;
private int supersetUserId;
private String supersetUserName;
private String supersetUserEmail;
private String supersetFirstName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,15 @@ public void validateUserHasAccessToContext(String contextKey, String reason) {

public List<AdUserDto> searchUser(String email) {
if (email == null || email.length() < 3) {
return new ArrayList<>();
return Collections.emptyList();
}
return userLookupProviderManager.searchUserByEmail(email)
.stream()
.collect(Collectors.toCollection(LinkedHashSet::new))
.stream()

List<AdUserDto> users = userLookupProviderManager.searchUserByEmail(email);
Set<String> uniqueEmails = new HashSet<>();

return users.stream()
.filter(Objects::nonNull)
.filter(user -> uniqueEmails.add(user.getEmail()))
.collect(Collectors.toList());
}

Expand Down Expand Up @@ -593,27 +596,21 @@ private void updateDashboardRoleForUser(UUID userId, List<DashboardForUserDto> d
try {
SupersetDashboardsForUserUpdate supersetDashboardsForUserUpdate = new SupersetDashboardsForUserUpdate();
UserEntity userEntity = getUserEntity(userId);
SubsystemUser userInInstance = metaInfoResourceService.findUserInInstance(userEntity.getEmail(), supersetInstanceName);
if (userInInstance != null) {
supersetDashboardsForUserUpdate.setSupersetUserId(userInInstance.getId());
supersetDashboardsForUserUpdate.setSupersetUserName(userInInstance.getUsername());
supersetDashboardsForUserUpdate.setSupersetUserEmail(userInInstance.getEmail());
supersetDashboardsForUserUpdate.setDashboards(dashboardForUserDtoList);
supersetDashboardsForUserUpdate.setSupersetFirstName(userInInstance.getFirstName());
supersetDashboardsForUserUpdate.setSupersetLastName(userInInstance.getLastName());
supersetDashboardsForUserUpdate.setActive(userInInstance.isActive());
String subject = SlugifyUtil.slugify(supersetInstanceName + RequestReplySubject.UPDATE_DASHBOARD_ROLES_FOR_USER.getSubject());
log.info("[updateDashboardRoleForUser] Sending request to subject: {}", subject);
Message reply =
connection.request(subject, objectMapper.writeValueAsString(supersetDashboardsForUserUpdate).getBytes(StandardCharsets.UTF_8), Duration.ofSeconds(10));
if (reply == null) {
log.warn("Reply is null, please verify superset sidecar or nats connection");
} else {
reply.ack();
log.info("[updateDashboardRoleForUser] Response received: " + new String(reply.getData()));
}
supersetDashboardsForUserUpdate.setSupersetUserName(userEntity.getUsername());
supersetDashboardsForUserUpdate.setSupersetUserEmail(userEntity.getEmail());
supersetDashboardsForUserUpdate.setDashboards(dashboardForUserDtoList);
supersetDashboardsForUserUpdate.setSupersetFirstName(userEntity.getFirstName());
supersetDashboardsForUserUpdate.setSupersetLastName(userEntity.getLastName());
supersetDashboardsForUserUpdate.setActive(userEntity.isEnabled());
String subject = SlugifyUtil.slugify(supersetInstanceName + RequestReplySubject.UPDATE_DASHBOARD_ROLES_FOR_USER.getSubject());
log.info("[updateDashboardRoleForUser] Sending request to subject: {}", subject);
Message reply =
connection.request(subject, objectMapper.writeValueAsString(supersetDashboardsForUserUpdate).getBytes(StandardCharsets.UTF_8), Duration.ofSeconds(10));
if (reply == null) {
log.warn("Reply is null, please verify superset sidecar or nats connection");
} else {
log.error("User {} not found in superset instance {}!", userEntity.getEmail(), supersetInstanceName);
reply.ack();
log.info("[updateDashboardRoleForUser] Response received: " + new String(reply.getData()));
}
} catch (Exception e) {
log.error("Error updating dashboard role for user", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void listenForRequests() {

RoleUtil.leaveOnlyBiViewerRoleIfNoneAttached(allRoles, supersetUserRolesUpdate);

log.debug("Roles that user should now have: {}", supersetUserRolesUpdate.getRoles());
log.debug("Roles that user {} should now have: {}", user.getEmail(), supersetUserRolesUpdate.getRoles());
SupersetUserUpdateResponse updatedUser = supersetClient.updateUserRoles(supersetUserRolesUpdate, user.getId());
log.debug("\t-=-=-=-= received message from the superset: {}", new String(msg.getData()));
natsConnection.publish(msg.getReplyTo(), objectMapper.writeValueAsBytes(updatedUser));
Expand Down

0 comments on commit fa002e5

Please sign in to comment.