use of com.hortonworks.streamline.common.exception.DuplicateEntityException in project streamline by hortonworks.
the class DefaultStreamlineAuthorizer method mayBeAddAdminUsers.
private void mayBeAddAdminUsers() {
LOG.info("Checking user entries for admin users");
adminUsers.stream().filter(name -> {
User user = catalogService.getUser(name);
if (user != null) {
LOG.info("Entry for user '{}' already exists", name);
return false;
} else {
return true;
}
}).forEach(name -> {
User user = new User();
user.setName(name);
user.setEmail(name + "@auto-generated.com");
user.setMetadata("{\"colorCode\":\"#8261be\",\"colorLabel\":\"purple\",\"icon\":\"gears\"}");
try {
User addedUser = catalogService.addUser(user);
LOG.info("Added admin user entry: {}", addedUser);
} catch (DuplicateEntityException exception) {
// In HA setup the other server may have already added the user.
LOG.info("Caught exception: " + ExceptionUtils.getStackTrace(exception));
LOG.info("Admin user entry: {} already exists.", user);
}
});
}
Aggregations