ofuks commented on a change in pull request #1002:
URL: https://github.com/apache/incubator-datalab/pull/1002#discussion_r536146672
##########
File path:
services/self-service/src/main/java/com/epam/datalab/backendapi/dropwizard/listeners/MongoStartupListener.java
##########
@@ -38,50 +40,66 @@
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.stream.Collectors;
+import static java.lang.String.format;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
@Slf4j
public class MongoStartupListener implements ServerLifecycleListener {
- private static final String PATH_TO_GENERAL_ROLES =
"/mongo/general/mongo_roles.json";
+ private static final String PATH_TO_ROLES = "/mongo/%s/mongo_roles.json";
private static final ObjectMapper MAPPER = new ObjectMapper();
private final UserRoleDAO userRoleDao;
private final SelfServiceApplicationConfiguration configuration;
private final SettingsDAO settingsDAO;
+ private final EndpointDAO endpointDAO;
@Inject
public MongoStartupListener(UserRoleDAO userRoleDao,
SelfServiceApplicationConfiguration configuration,
SettingsDAO settingsDAO, EndpointDAO
endpointDAO) {
this.userRoleDao = userRoleDao;
this.configuration = configuration;
this.settingsDAO = settingsDAO;
+ this.endpointDAO = endpointDAO;
}
@Override
public void serverStarted(Server server) {
settingsDAO.setServiceBaseName(configuration.getServiceBaseName());
settingsDAO.setConfOsFamily(configuration.getOs());
settingsDAO.setSsnInstanceSize(configuration.getSsnInstanceSize());
+ List<EndpointDTO> endpointDTOs = endpointDAO.getEndpoints();
if (userRoleDao.findAll().isEmpty()) {
- log.debug("Populating DataLab roles into database");
- userRoleDao.insert(getRoles());
+ log.info("Populating DataLab default roles into database");
+ List<UserRoleDTO> populatingRoles =
getRoles(CloudProvider.GENERAL);
+ List<CloudProvider> connectedCloudProviders =
getConnectedProviders(endpointDTOs);
+ log.info("Check for connected endpoints:\n connected endpoints: {}
\n connected clouds: {}"
+ , endpointDTOs.size(), connectedCloudProviders);
+
connectedCloudProviders.forEach(provider->populatingRoles.addAll(getRoles(provider)));
Review comment:
Please format this line
##########
File path:
services/self-service/src/main/java/com/epam/datalab/backendapi/dropwizard/listeners/MongoStartupListener.java
##########
@@ -38,50 +40,66 @@
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
+import java.util.stream.Collectors;
+import static java.lang.String.format;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
@Slf4j
public class MongoStartupListener implements ServerLifecycleListener {
- private static final String PATH_TO_GENERAL_ROLES =
"/mongo/general/mongo_roles.json";
+ private static final String PATH_TO_ROLES = "/mongo/%s/mongo_roles.json";
private static final ObjectMapper MAPPER = new ObjectMapper();
private final UserRoleDAO userRoleDao;
private final SelfServiceApplicationConfiguration configuration;
private final SettingsDAO settingsDAO;
+ private final EndpointDAO endpointDAO;
@Inject
public MongoStartupListener(UserRoleDAO userRoleDao,
SelfServiceApplicationConfiguration configuration,
SettingsDAO settingsDAO, EndpointDAO
endpointDAO) {
this.userRoleDao = userRoleDao;
this.configuration = configuration;
this.settingsDAO = settingsDAO;
+ this.endpointDAO = endpointDAO;
}
@Override
public void serverStarted(Server server) {
settingsDAO.setServiceBaseName(configuration.getServiceBaseName());
settingsDAO.setConfOsFamily(configuration.getOs());
settingsDAO.setSsnInstanceSize(configuration.getSsnInstanceSize());
+ List<EndpointDTO> endpointDTOs = endpointDAO.getEndpoints();
if (userRoleDao.findAll().isEmpty()) {
- log.debug("Populating DataLab roles into database");
- userRoleDao.insert(getRoles());
+ log.info("Populating DataLab default roles into database");
+ List<UserRoleDTO> populatingRoles =
getRoles(CloudProvider.GENERAL);
Review comment:
Please rename this variable **populatingRoles** to **generalRoles** for
example.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]