X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=ec59c92f3eef4098c74d317775116de6f4506bdc;hp=5564c37f22510157db5f22cf57cb3ed01c865058;hb=791ae7c17d02857541e10a5dd97af65f6f532056;hpb=045fc6957de36dc6c35af39fe79c559b6cec62d1 diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 5564c37..ec59c92 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1108,24 +1108,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, String lastInsertFingerprint = configuration.getStringValue(sonePrefix + "/LastInsertFingerprint").getValue(""); /* load profile. */ - Profile profile = new Profile(sone); - profile.setFirstName(configuration.getStringValue(sonePrefix + "/Profile/FirstName").getValue(null)); - profile.setMiddleName(configuration.getStringValue(sonePrefix + "/Profile/MiddleName").getValue(null)); - profile.setLastName(configuration.getStringValue(sonePrefix + "/Profile/LastName").getValue(null)); - profile.setBirthDay(configuration.getIntValue(sonePrefix + "/Profile/BirthDay").getValue(null)); - profile.setBirthMonth(configuration.getIntValue(sonePrefix + "/Profile/BirthMonth").getValue(null)); - profile.setBirthYear(configuration.getIntValue(sonePrefix + "/Profile/BirthYear").getValue(null)); - - /* load profile fields. */ - while (true) { - String fieldPrefix = sonePrefix + "/Profile/Fields/" + profile.getFields().size(); - String fieldName = configuration.getStringValue(fieldPrefix + "/Name").getValue(null); - if (fieldName == null) { - break; - } - String fieldValue = configuration.getStringValue(fieldPrefix + "/Value").getValue(""); - profile.addField(fieldName).setValue(fieldValue); - } + Profile profile = parseProfileFromConfiguration(configuration, sone, sonePrefix); /* load posts. */ Set posts = new HashSet(); @@ -1308,6 +1291,29 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, logger.info(String.format("Sone loaded successfully: %s", sone)); } + private static Profile parseProfileFromConfiguration(Configuration configuration, Sone sone, String sonePrefix) { + Profile profile = new Profile(sone); + profile.setFirstName(configuration.getStringValue(sonePrefix + "/Profile/FirstName").getValue(null)); + profile.setMiddleName(configuration.getStringValue(sonePrefix + "/Profile/MiddleName").getValue(null)); + profile.setLastName(configuration.getStringValue(sonePrefix + "/Profile/LastName").getValue(null)); + profile.setBirthDay(configuration.getIntValue(sonePrefix + "/Profile/BirthDay").getValue(null)); + profile.setBirthMonth(configuration.getIntValue(sonePrefix + "/Profile/BirthMonth").getValue(null)); + profile.setBirthYear(configuration.getIntValue(sonePrefix + "/Profile/BirthYear").getValue(null)); + + /* load profile fields. */ + while (true) { + String fieldPrefix = sonePrefix + "/Profile/Fields/" + profile.getFields().size(); + String fieldName = configuration.getStringValue(fieldPrefix + "/Name").getValue(null); + if (fieldName == null) { + break; + } + String fieldValue = configuration.getStringValue(fieldPrefix + "/Value").getValue(""); + profile.addField(fieldName).setValue(fieldValue); + } + + return profile; + } + /** * Creates a new post. *