added UserStore.hasUsers for efficient check whether there are none

Change-Id: Ifacc9c84bda961399b866e860757e8ebe0d78b71
This commit is contained in:
Axel Uhl committed 2017-11-29 14:09:35 +01:00
1 parent a505e4c69e
commit 680f3a0441
3 files changed
+8 -1

No files matched your search

@@ -318,6 +318,11 @@ public class UserStoreImpl implements UserStore {
return new ArrayList<User>(users.values());
}
@Override
public boolean hasUsers() {
return !users.isEmpty();
}
@Override
public User getUserByName(String name) {
final User result;
@@ -10,6 +10,8 @@ import com.sap.sse.security.shared.UserManagementException;
public interface UserStore extends Named {
Iterable<User> getUsers();
boolean hasUsers();
/**
* The user with that {@link User#getName() name} or {@code null} if no such user exists
@@ -191,7 +191,7 @@ public class SecurityServiceImpl implements ReplicableSecurityService, ClearStat
* is empty.
*/
private void initEmptyStore() {
if (Util.isEmpty(store.getUsers())) {
if (!store.hasUsers()) {
try {
logger.info("No users found, creating default user \"admin\" with password \"admin\"");
createSimpleUser("admin", "nobody@sapsailing.com", "admin",