package ru.yandex.wmtools.common.servantlet;

import ru.yandex.wmtools.common.error.UserException;
import ru.yandex.wmtools.common.service.SettingsService;

/**
 * @author baton
 */
@Deprecated
public class UserTextOptions {
    private static final String TRUE_STRING_VALUE = "true";
    private static final String SHOW_ERROR_NAME_IF_NO_USER_TEXT = "show.error.name.if.no.user.text";

    public String createUserText(UserException e, SettingsService settingsService) {
        String userText = settingsService.getSettings().getProperty(e.getProblem().toString());

        // try to use default language
        if (userText == null) {
            userText = settingsService.getSettings().getProperty(e.getProblem().toString());
        }

        // using error name as user text
        if (userText == null) {
            if (TRUE_STRING_VALUE.equals(settingsService.getSettings().getProperty(SHOW_ERROR_NAME_IF_NO_USER_TEXT))) {
                userText = e.getProblem().toString();
            }
        }
        return userText;
    }
}
