/*
- * Sone - Core.java - Copyright © 2010–2016 David Roden
+ * Sone - Core.java - Copyright © 2010–2019 David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
import net.pterodactylus.util.thread.NamedThreadFactory;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
/** The start time. */
private final long startupTime = System.currentTimeMillis();
+ private final DebugInformation debugInformation = new DebugInformation();
+
/** The preferences. */
private final Preferences preferences;
return startupTime;
}
+ @Nonnull
+ public DebugInformation getDebugInformation() {
+ return debugInformation;
+ }
+
/**
* Returns the options used by the core.
*
* The text of the post
* @return The created post
*/
- public Post createPost(Sone sone, Optional<Sone> recipient, String text) {
+ public Post createPost(Sone sone, @Nullable Sone recipient, String text) {
checkNotNull(text, "text must not be null");
checkArgument(text.trim().length() > 0, "text must not be empty");
if (!sone.isLocal()) {
}
PostBuilder postBuilder = database.newPostBuilder();
postBuilder.from(sone.getId()).randomId().currentTime().withText(text.trim());
- if (recipient.isPresent()) {
- postBuilder.to(recipient.get().getId());
+ if (recipient != null) {
+ postBuilder.to(recipient.getId());
}
final Post post = postBuilder.build();
database.storePost(post);
identityManager.start();
webOfTrustUpdater.init();
webOfTrustUpdater.start();
- database.start();
+ database.startAsync();
}
/**
}
}
saveConfiguration();
- database.stop();
+ database.stopAsync();
webOfTrustUpdater.stop();
updateChecker.stop();
soneDownloader.stop();
*/
@Subscribe
public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
- logger.log(Level.WARNING, String.format("Image insert finished for %s: %s", imageInsertFinishedEvent.image(), imageInsertFinishedEvent.resultingUri()));
- imageInsertFinishedEvent.image().modify().setKey(imageInsertFinishedEvent.resultingUri().toString()).update();
- deleteTemporaryImage(imageInsertFinishedEvent.image().getId());
+ logger.log(Level.WARNING, String.format("Image insert finished for %s: %s", imageInsertFinishedEvent.getImage(), imageInsertFinishedEvent.getResultingUri()));
+ imageInsertFinishedEvent.getImage().modify().setKey(imageInsertFinishedEvent.getResultingUri().toString()).update();
+ deleteTemporaryImage(imageInsertFinishedEvent.getImage().getId());
touchConfiguration();
}