@Override
public Object construct() {
try {
setText(GT._("Retrieving MediaWiki API"));
API api = APIFactory.getAPI();
EnumWikipedia wiki = getWikipedia();
// Login
if (!reloadOnly) {
setText(GT._("Login"));
LoginResult result = api.login(wiki, username, new String(password), login);
if (login) {
if ((result == null) || (!result.isLoginSuccessful())) {
throw new APIException("Login unsuccessful: " + ((result != null) ? result.toString() : ""));
}
}
User user = api.retrieveUser(wiki, username);
username = (user != null) ? user.getName() : null;
wiki.getConnection().setUser(user);
api.retrieveTokens(wiki);
logged = true;
}
// Load configuration
setText(GT._("Loading configuration"));
api.loadConfiguration(wiki, username);
// Saving settings
Configuration configuration = Configuration.getConfiguration();
configuration.setWikipedia(wiki);
configuration.setLanguage(language);
if (login && !reloadOnly && (saveUser != ConfigurationConstants.VALUE_SAVE_USER_NO_CHANGE)) {
Properties props = configuration.getProperties(wiki, Configuration.PROPERTIES_USERS);
if (saveUser == ConfigurationConstants.VALUE_SAVE_USER_NONE) {
props.remove(username);
configuration.setString(wiki, ConfigurationValueString.LAST_USER, (String) null);
} else {
props.setProperty(
username,
(saveUser == ConfigurationConstants.VALUE_SAVE_USER_BOTH) ? new String(password) : "");
configuration.setString(wiki, ConfigurationValueString.LAST_USER, username);
}
configuration.setProperties(wiki, Configuration.PROPERTIES_USERS, props);
configuration.setInt(
null,
ConfigurationValueInteger.SAVE_USER,
saveUser);
}
Configuration.getConfiguration().save();
// Retrieving disambiguation templates
setText(GT._("Retrieving disambiguation templates"));
wiki.initDisambiguationTemplates(api);
// Retrieving suggestions for text replacements
setText(GT._("Retrieving suggestions for text replacements"));
wiki.getConfiguration().initSuggestions(api, reloadOnly);
// Retrieving Check Wiki configuration
setText(GT._("Retrieving Check Wiki configuration"));
APIFactory.getCheckWiki().retrieveConfiguration(wiki, this);
} catch (APIException e) {