/** Sone rescuers. */
/* synchronize access on this on sones. */
- private final Map<Sone, SoneRescuer> soneRescuers = new HashMap<Sone, SoneRescuer>();
+ private final Map<LocalSone, SoneRescuer> soneRescuers = new HashMap<LocalSone, SoneRescuer>();
/** All known Sones. */
private final Set<String> knownSones = new HashSet<String>();
* The local Sone to get the rescuer for
* @return The Sone rescuer for the given Sone
*/
- public SoneRescuer getSoneRescuer(Sone sone) {
+ public SoneRescuer getSoneRescuer(LocalSone sone) {
checkNotNull(sone, "sone must not be null");
- checkArgument(sone.isLocal(), "sone must be local");
synchronized (soneRescuers) {
SoneRescuer soneRescuer = soneRescuers.get(sone);
if (soneRescuer == null) {
package net.pterodactylus.sone.core;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.service.AbstractService;
import freenet.keys.FreenetURI;
private final SoneDownloader soneDownloader;
/** The Sone being rescued. */
- private final Sone sone;
+ private final LocalSone sone;
/** Whether the rescuer is currently fetching a Sone. */
private volatile boolean fetching;
* @param sone
* The Sone to rescue
*/
- public SoneRescuer(Core core, SoneDownloader soneDownloader, Sone sone) {
+ public SoneRescuer(Core core, SoneDownloader soneDownloader, LocalSone sone) {
super("Sone Rescuer for " + sone.getName());
this.core = core;
this.soneDownloader = soneDownloader;
import static net.pterodactylus.sone.utils.NumberParsers.parseLong;
import net.pterodactylus.sone.core.SoneRescuer;
-import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
- Sone currentSone = getCurrentSone(request.getToadletContext(), false).get();
+ LocalSone currentSone = getCurrentSone(request.getToadletContext(), false).get();
SoneRescuer soneRescuer = webInterface.getCore().getSoneRescuer(currentSone);
if (request.getMethod() == Method.POST) {
if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("fetch", 4))) {
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import net.pterodactylus.sone.data.LocalSone;
import net.pterodactylus.sone.data.Sone;
import freenet.keys.FreenetURI;
private static final long SOME_OTHER_EDITION = 15L;
private final Core core = mock(Core.class);
private final SoneDownloader soneDownloader = mock(SoneDownloader.class);
- private final Sone sone = mock(Sone.class);
+ private final LocalSone sone = mock(LocalSone.class);
private SoneRescuer soneRescuer;
@Before