Clean up imports.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 1109537..3ca5271 100644 (file)
@@ -17,7 +17,6 @@
 
 package net.pterodactylus.sone.core;
 
-import static com.google.common.base.Optional.absent;
 import static com.google.common.base.Optional.of;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -27,7 +26,6 @@ import static net.pterodactylus.sone.data.Identified.GET_ID;
 import static net.pterodactylus.sone.data.Sone.LOCAL_SONE_FILTER;
 import static net.pterodactylus.sone.data.Sone.TO_FREENET_URI;
 
-import java.net.MalformedURLException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -97,8 +95,7 @@ import net.pterodactylus.util.number.Numbers;
 import net.pterodactylus.util.service.AbstractService;
 import net.pterodactylus.util.thread.NamedThreadFactory;
 
-import freenet.keys.FreenetURI;
-
+import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -330,6 +327,11 @@ public class Core extends AbstractService implements SoneProvider {
        }
 
        @Override
+       public Function<String, Optional<Sone>> getSone() {
+               return database.getSone();
+       }
+
+       @Override
        public Optional<Sone> getSone(String id) {
                synchronized (sones) {
                        return Optional.fromNullable(sones.get(id));
@@ -559,9 +561,8 @@ public class Core extends AbstractService implements SoneProvider {
                logger.info(String.format("Adding Sone from OwnIdentity: %s", ownIdentity));
                synchronized (sones) {
                        final Sone sone;
-                       sone = database.newSoneBuilder().by(ownIdentity.getId()).local().build(Optional.<SoneCreated>absent());
+                       sone = database.newSoneBuilder().by(ownIdentity.getId()).local().using(new Client("Sone", SonePlugin.VERSION.toString())).build(Optional.<SoneCreated>absent());
                        sone.modify().setLatestEdition(Numbers.safeParseLong(ownIdentity.getProperty("Sone.LatestEdition"), (long) 0)).update();
-                       sone.setClient(new Client("Sone", SonePlugin.VERSION.toString()));
                        sone.setKnown(true);
                        /* TODO - load posts ’n stuff */
                        sones.put(ownIdentity.getId(), sone);
@@ -966,7 +967,7 @@ public class Core extends AbstractService implements SoneProvider {
                                break;
                        }
                        String fieldValue = configuration.getStringValue(fieldPrefix + "/Value").getValue("");
-                       profile.addField(fieldName).setValue(fieldValue);
+                       profile.setField(profile.addField(fieldName), fieldValue);
                }
 
                /* load posts. */
@@ -1095,7 +1096,7 @@ public class Core extends AbstractService implements SoneProvider {
                /* load avatar. */
                String avatarId = configuration.getStringValue(sonePrefix + "/Profile/Avatar").getValue(null);
                if (avatarId != null) {
-                       profile.setAvatar(getImage(avatarId).orNull());
+                       profile.setAvatar(getImage(avatarId).transform(GET_ID));
                }
 
                /* load options. */