<commit_before>package org.dcsc.admin.users;

import org.dcsc.core.user.DcscUser;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class UserFormBinder {
    public void bindToUser(DcscUser user, Map<String, Object> userForm) throws Exception {
        for (Map.Entry<String, Object> entry : userForm.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();

            if (isProfileDescription(key)) {
                user.getUserProfile().setDescription((String) value);
            } else if (isFormPassword(key) && passwordMatches((String) value, (String) userForm.get("user_form_confirm_password"))) {
                user.setPassword(new BCryptPasswordEncoder().encode((String) value));
            } else if (isFormEmail(key)) {
                user.getUserProfile().setEmail((String) value);
            }
        }
    }

    private boolean isProfileDescription(String key) {
        return "user_form_description".equals(key);
    }

    private boolean isFormPassword(String key) {
        return "user_form_password".equals(key);
    }

    private boolean passwordMatches(String password, String confirmPassword) {
        return password.matches(confirmPassword);
    }

    private boolean isFormEmail(String key) {
        return "user_form_email".equals(key);
    }
}<commit_msg>Promote integration to preview<commit_after>package org.dcsc.admin.users;

import org.dcsc.core.user.DcscUser;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Optional;

@Component
public class UserFormBinder {
    public void bindToUser(DcscUser user, Map<String, Object> userForm) throws Exception {
        Optional.ofNullable((String) userForm.get("user_form_description"))
                .ifPresent(description -> user.getUserProfile().setDescription(description));

        Optional.ofNullable((String) userForm.get("user_form_password"))
                .filter(password -> !password.isEmpty())
                .filter(password -> password.equals(userForm.get("user_form_confirm_password")))
                .ifPresent(password -> user.setPassword(new <PASSWORD>().encode(password)));

        Optional.ofNullable((String) userForm.get("user_form_email"))
                .ifPresent(email -> user.getUserProfile().setEmail(email));
    }
}
{'fraction_non_alphanumeric': 0.11481922924116011, 'fraction_numerical': 0.0, 'mean_word_length': 3.456637168141593, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1562366', 'n_tokens_mistral': 693, 'n_tokens_neox': 677, 'n_words': 124}