import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.ReplyShell;
+import net.pterodactylus.sone.data.Shell;
import net.pterodactylus.sone.data.ShellCache;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.data.SoneShell;
return Collections.unmodifiableSet(localSones);
}
+ /**
+ * Returns a Sone or a {@link Shell} around one for the given ID.
+ *
+ * @param soneId
+ * The ID of the Sone
+ * @return The Sone, or a {@link Shell} around one
+ */
+ public Sone getSone(String soneId) {
+ Sone sone = soneCache.get(soneId);
+ if (sone instanceof SoneShell) {
+ soneCache.put(soneId, sone = ((SoneShell) sone).getShelled());
+ }
+ return sone;
+ }
+
//
// ACTIONS
//
*/
public void addSone(Sone sone) {
if (localSones.add(sone)) {
+ soneCache.put(sone.getId(), sone);
SoneInserter soneInserter = new SoneInserter(freenetInterface, sone);
soneInserter.start();
soneInserters.put(sone, soneInserter);
Sone sone;
try {
logger.log(Level.FINEST, "Creating new Sone ā%sā at %s (%s)ā¦", new Object[] { name, finalRequestUri, finalInsertUri });
- sone = new Sone(UUID.randomUUID(), name, new FreenetURI(finalRequestUri), new FreenetURI(finalInsertUri));
+ sone = new Sone(UUID.randomUUID(), name, new FreenetURI(finalRequestUri).setKeyType("USK"), new FreenetURI(finalInsertUri).setKeyType("USK"));
sone.setProfile(new Profile());
/* set modification counter to 1 so it is inserted immediately. */
sone.setModificationCounter(1);
} catch (MalformedURLException mue1) {
throw new SoneException(Type.INVALID_URI);
}
- localSones.add(sone);
return sone;
}