Skip to content

Commit

Permalink
Return the root domain name for instances without data domain support…
Browse files Browse the repository at this point in the history
… to let the combo box show it.
  • Loading branch information
piotrczarnas committed Sep 25, 2024
1 parent 2e9e97a commit 52434f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public Collection<LocalDataDomainSpec> getAllLocalDataDomains() {
ArrayList<LocalDataDomainSpec> allDomains = new ArrayList<>();
allDomains.add(new LocalDataDomainSpec() {{
setDataDomainName(UserDomainIdentity.ROOT_DOMAIN_ALTERNATE_NAME);
setDisplayName("Root data domain");
setDisplayName(UserDomainIdentity.ROOT_DOMAIN_DISPLAY_NAME);
}});

allDomains.addAll(nestedDataDomains);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public class UserDomainIdentity {
*/
public static final String ROOT_DOMAIN_ALTERNATE_NAME = "(default)";

/**
* The display name shown for the root data domain.
*/
public static final String ROOT_DOMAIN_DISPLAY_NAME = "Root data domain";

/**
* The default identity of the local instance, a user who manages the root data domain on this DQOps instance.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.dqops.rest.controllers;

import com.dqops.core.configuration.DqoInstanceConfigurationProperties;
import com.dqops.core.configuration.DqoUserConfigurationProperties;
import com.dqops.core.domains.DataDomainsService;
import com.dqops.core.domains.DqoDataDomainException;
import com.dqops.core.domains.LocalDataDomainModel;
Expand Down Expand Up @@ -49,6 +50,7 @@
import reactor.core.publisher.Mono;

import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
Expand All @@ -66,6 +68,7 @@ public class DataDomainsController {
private final UserHomeContextFactory userHomeContextFactory;
private final LocalDataDomainRegistry localDataDomainRegistry;
private final DqoInstanceConfigurationProperties dqoInstanceConfigurationProperties;
private final DqoUserConfigurationProperties dqoUserConfigurationProperties;
private final InstanceCloudLoginService instanceCloudLoginService;


Expand All @@ -76,18 +79,21 @@ public class DataDomainsController {
* @param userHomeContextFactory User home context factory.
* @param localDataDomainRegistry Local data domain registry.
* @param dqoInstanceConfigurationProperties DQOps instance configuration - the cookie expiration time.
* @param dqoUserConfigurationProperties DQO User Home configuration - to identify the default data domain.
* @param instanceCloudLoginService Cloud login controller.
*/
@Autowired
public DataDomainsController(DataDomainsService dataDomainsService,
UserHomeContextFactory userHomeContextFactory,
LocalDataDomainRegistry localDataDomainRegistry,
DqoInstanceConfigurationProperties dqoInstanceConfigurationProperties,
DqoUserConfigurationProperties dqoUserConfigurationProperties,
InstanceCloudLoginService instanceCloudLoginService) {
this.dataDomainsService = dataDomainsService;
this.userHomeContextFactory = userHomeContextFactory;
this.localDataDomainRegistry = localDataDomainRegistry;
this.dqoInstanceConfigurationProperties = dqoInstanceConfigurationProperties;
this.dqoUserConfigurationProperties = dqoUserConfigurationProperties;
this.instanceCloudLoginService = instanceCloudLoginService;
}

Expand All @@ -113,7 +119,13 @@ public Mono<ResponseEntity<Flux<LocalDataDomainModel>>> getLocalDataDomains(
List<LocalDataDomainModel> allDataDomains = this.dataDomainsService.getAllDataDomains();
LinkedHashMap<String, DqoUserRole> domainRoles = principal.getDomainRoles();
if (domainRoles == null) {
return new ResponseEntity<>(Flux.empty(), HttpStatus.OK);
ArrayList<LocalDataDomainModel> rootDomainList = new ArrayList<>();
boolean isRootDomain = Objects.equals(dqoUserConfigurationProperties.getDefaultDataDomain(), UserDomainIdentity.ROOT_DATA_DOMAIN);
rootDomainList.add(new LocalDataDomainModel() {{
setDomainName(isRootDomain ? UserDomainIdentity.ROOT_DOMAIN_ALTERNATE_NAME : dqoUserConfigurationProperties.getDefaultDataDomain());
setDisplayName(isRootDomain ? UserDomainIdentity.ROOT_DOMAIN_DISPLAY_NAME : dqoUserConfigurationProperties.getDefaultDataDomain());
}});
return new ResponseEntity<>(Flux.fromStream(rootDomainList.stream()), HttpStatus.OK);
}

if (principal.getAccountRole() == DqoUserRole.NONE) {
Expand Down

0 comments on commit 52434f1

Please sign in to comment.