- String name = configuration.getStringValue(sonePrefix + "/Name").getValue(null);
- long time = configuration.getLongValue(sonePrefix + "/Time").getValue((long) 0);
- 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);
- Integer birthDay = configuration.getIntValue(sonePrefix + "/Profile/BirthDay").getValue(null);
- Integer birthMonth = configuration.getIntValue(sonePrefix + "/Profile/BirthMonth").getValue(null);
- Integer birthYear = configuration.getIntValue(sonePrefix + "/Profile/BirthYear").getValue(null);
- try {
- Profile profile = new Profile();
- profile.setFirstName(firstName);
- profile.setMiddleName(middleName);
- profile.setLastName(lastName);
- profile.setBirthDay(birthDay).setBirthMonth(birthMonth).setBirthYear(birthYear);
- Sone sone = getSone(id).setName(name).setTime(time).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;
- }
- time = configuration.getLongValue(postPrefix + "/Time").getValue((long) 0);
- 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);
- sone.addFriend(friendSone);
- }
-
- /* load blocked Sone IDs. */
- int blockedSoneCounter = 0;
- while (true) {
- String blockedSonePrefix = sonePrefix + "/BlockedSone." + blockedSoneCounter++;
- String blockedSoneId = configuration.getStringValue(blockedSonePrefix + "/ID").getValue(null);
- if (blockedSoneId == null) {
- break;
- }
- sone.addBlockedSoneId(blockedSoneId);
- }
-
- /* load liked post IDs. */
- int likedPostIdCounter = 0;
- while (true) {
- String likedPostIdPrefix = sonePrefix + "/LikedPostId." + likedPostIdCounter++;
- String likedPostId = configuration.getStringValue(likedPostIdPrefix + "/ID").getValue(null);
- if (likedPostId == null) {
- break;
- }
- sone.addLikedPostId(likedPostId);
- }
-
- /* load liked reply IDs. */
- int likedReplyIdCounter = 0;
- while (true) {
- String likedReplyIdPrefix = sonePrefix + "/LikedReplyId." + likedReplyIdCounter++;
- String likedReplyId = configuration.getStringValue(likedReplyIdPrefix + "/ID").getValue(null);
- if (likedReplyId == null) {
- break;
- }
- sone.addLikedReplyId(likedReplyId);
- }
-
- sone.setModificationCounter(modificationCounter);
- addLocalSone(sone);
- } catch (MalformedURLException mue1) {
- logger.log(Level.WARNING, "Could not create Sone from requestUri (“" + requestUri + "”) and insertUri (“" + insertUri + "”)!", mue1);