private void validateUserCreator(UserCreator creator) throws CreationException { if (creator == null) { throw new CreationException("Can not create a null user."); } final Map<UserCreator.UserField, Serializable> fields = creator.getFields(); final String userName = (String) fields.get(UserCreator.UserField.NAME); if (userName == null || userName.trim().isEmpty()) { throw new CreationException("The user name cannot be null or empty."); } final String password = (String) fields.get(UserCreator.UserField.PASSWORD); if (password == null || password.trim().isEmpty()) { throw new CreationException("The password cannot be null or empty."); } try { getUserByUserName(userName); throw new AlreadyExistsException("A user with name \"" + userName + "\" already exists"); } catch (final UserNotFoundException ignored) { } }
private void validateUserCreator(UserCreator creator) throws CreationException { if (creator == null) { throw new CreationException("Can not create a null user."); } final Map<UserCreator.UserField, Serializable> fields = creator.getFields(); final String userName = (String) fields.get(UserCreator.UserField.NAME); if (userName == null || userName.trim().isEmpty()) { throw new CreationException("The user name cannot be null or empty."); } final String password = (String) fields.get(UserCreator.UserField.PASSWORD); if (password == null || password.trim().isEmpty()) { throw new CreationException("The password cannot be null or empty."); } try { getUserByUserName(userName); throw new AlreadyExistsException("A user with name \"" + userName + "\" already exists"); } catch (final UserNotFoundException ignored) { } }