Skip to content

Commit

Permalink
HELLODATA-1895 - fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Slawomir Wieczorek committed Dec 2, 2024
1 parent df8a45a commit c6dab1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 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 @@ -593,27 +593,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

0 comments on commit c6dab1c

Please sign in to comment.