- logger.entering(Core.class.getName(), "loadConfiguration()");
-
- /* parse local Sones. */
- logger.log(Level.INFO, "Loading Sones…");
- int soneId = 0;
- do {
- String sonePrefix = "Sone/Sone." + soneId++;
- String id = configuration.getStringValue(sonePrefix + "/ID").getValue(null);
- if (id == null) {
- break;
- }
- String name = configuration.getStringValue(sonePrefix + "/Name").getValue(null);
- String insertUri = configuration.getStringValue(sonePrefix + "/InsertURI").getValue(null);
- String requestUri = configuration.getStringValue(sonePrefix + "/RequestURI").getValue(null);
- long modificationCounter = configuration.getLongValue(sonePrefix + "/ModificationCounter").getValue((long) 0);
- String firstName = configuration.getStringValue(sonePrefix + "/Profile/FirstName").getValue(null);
- String middleName = configuration.getStringValue(sonePrefix + "/Profile/MiddleName").getValue(null);
- String lastName = configuration.getStringValue(sonePrefix + "/Profile/LastName").getValue(null);
- try {
- Profile profile = new Profile();
- profile.setFirstName(firstName);
- profile.setMiddleName(middleName);
- profile.setLastName(lastName);
- Sone sone = getSone(id).setName(name).setRequestUri(new FreenetURI(requestUri)).setInsertUri(new FreenetURI(insertUri));
- sone.setProfile(profile);
- int postId = 0;
- do {
- String postPrefix = sonePrefix + "/Post." + postId++;
- id = configuration.getStringValue(postPrefix + "/ID").getValue(null);
- if (id == null) {
- break;
- }
- long time = configuration.getLongValue(postPrefix + "/Time").getValue(null);
- String text = configuration.getStringValue(postPrefix + "/Text").getValue(null);
- Post post = getPost(id).setSone(sone).setTime(time).setText(text);
- sone.addPost(post);
- } while (true);
- int replyCounter = 0;
- do {
- String replyPrefix = sonePrefix + "/Reply." + replyCounter++;
- String replyId = configuration.getStringValue(replyPrefix + "/ID").getValue(null);
- if (replyId == null) {
- break;
- }
- Post replyPost = getPost(configuration.getStringValue(replyPrefix + "/Post").getValue(null));
- long replyTime = configuration.getLongValue(replyPrefix + "/Time").getValue(null);
- String replyText = configuration.getStringValue(replyPrefix + "/Text").getValue(null);
- Reply reply = getReply(replyId).setSone(sone).setPost(replyPost).setTime(replyTime).setText(replyText);
- sone.addReply(reply);
- } while (true);
-
- /* load friends. */
- int friendCounter = 0;
- while (true) {
- String friendPrefix = sonePrefix + "/Friend." + friendCounter++;
- String friendId = configuration.getStringValue(friendPrefix + "/ID").getValue(null);
- if (friendId == null) {
- break;
- }
- Sone friendSone = getSone(friendId);
- String friendKey = configuration.getStringValue(friendPrefix + "/Key").getValue(null);
- String friendName = configuration.getStringValue(friendPrefix + "/Name").getValue(null);
- friendSone.setRequestUri(new FreenetURI(friendKey)).setName(friendName);
- soneDownloader.addSone(friendSone);
- sone.addFriend(friendSone);
- }