From: David ‘Bombe’ Roden Date: Mon, 11 Jul 2016 17:55:51 +0000 (+0200) Subject: Merge branch 'release-0.9.5' X-Git-Tag: 0.9.5^0 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=c4ae226ec5052116cefc542ae2017036a7bc6332;hp=76ed638264e531a26e35647d13702db865a52321 Merge branch 'release-0.9.5' --- diff --git a/pom.xml b/pom.xml index 2ca12c0..1799801 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.pterodactylus sone - 0.9.4 + 0.9.5 net.pterodactylus @@ -118,6 +118,7 @@ maven-assembly-plugin 2.2-beta-5 + sone jar-with-dependencies @@ -154,7 +155,7 @@ org.jacoco jacoco-maven-plugin - 0.7.1.201405082137 + 0.7.6.201602180812 default-prepare-agent @@ -193,6 +194,19 @@ + + org.pitest + pitest-maven + 1.1.10 + + + net.pterodactylus.sone.* + + + net.pterodactylus.sone.* + + + diff --git a/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java b/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java index a29856b..37e0ed5 100644 --- a/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java @@ -201,8 +201,6 @@ public class ConfigurationSoneParser { String albumDescription = getString(albumPrefix + "/Description", null); String albumParentId = getString(albumPrefix + "/Parent", null); - String albumImageId = - getString(albumPrefix + "/AlbumImage", null); if ((albumTitle == null) || (albumDescription == null)) { throw new InvalidAlbumFound(); } @@ -213,7 +211,6 @@ public class ConfigurationSoneParser { .modify() .setTitle(albumTitle) .setDescription(albumDescription) - .setAlbumImage(albumImageId) .update(); if (albumParentId != null) { Album parentAlbum = albums.get(albumParentId); diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 99a5654..3b958f1 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1,5 +1,5 @@ /* - * Sone - Core.java - Copyright © 2010–2015 David Roden + * Sone - Core.java - Copyright © 2010–2016 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 @@ -204,14 +204,14 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, * The database */ @Inject - public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database) { + public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database) { super("Sone Core"); this.configuration = configuration; this.freenetInterface = freenetInterface; this.identityManager = identityManager; this.soneDownloader = new SoneDownloaderImpl(this, freenetInterface); this.imageInserter = new ImageInserter(freenetInterface, freenetInterface.new InsertTokenSupplier()); - this.updateChecker = new UpdateChecker(eventBus, freenetInterface); + this.updateChecker = updateChecker; this.webOfTrustUpdater = webOfTrustUpdater; this.eventBus = eventBus; this.database = database; @@ -1518,7 +1518,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, configuration.getStringValue(albumPrefix + "/Title").setValue(album.getTitle()); configuration.getStringValue(albumPrefix + "/Description").setValue(album.getDescription()); configuration.getStringValue(albumPrefix + "/Parent").setValue(album.getParent().equals(sone.getRootAlbum()) ? null : album.getParent().getId()); - configuration.getStringValue(albumPrefix + "/AlbumImage").setValue(album.getAlbumImage() == null ? null : album.getAlbumImage().getId()); } configuration.getStringValue(sonePrefix + "/Albums/" + albumCounter + "/ID").setValue(null); @@ -1730,8 +1729,14 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, /* TODO - we don’t have the Sone anymore. should this happen? */ return; } - database.removeSone(sone.get()); + for (PostReply postReply : sone.get().getReplies()) { + eventBus.post(new PostReplyRemovedEvent(postReply)); + } + for (Post post : sone.get().getPosts()) { + eventBus.post(new PostRemovedEvent(post)); + } eventBus.post(new SoneRemovedEvent(sone.get())); + database.removeSone(sone.get()); } /** diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index 219377d..a06b5b0 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -1,5 +1,5 @@ /* - * Sone - FreenetInterface.java - Copyright © 2010–2015 David Roden + * Sone - FreenetInterface.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/ImageInserter.java b/src/main/java/net/pterodactylus/sone/core/ImageInserter.java index d338161..f47b713 100644 --- a/src/main/java/net/pterodactylus/sone/core/ImageInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/ImageInserter.java @@ -1,5 +1,5 @@ /* - * Sone - ImageInserter.java - Copyright © 2011–2015 David Roden + * Sone - ImageInserter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/Options.java b/src/main/java/net/pterodactylus/sone/core/Options.java index 9a53202..39b7b37 100644 --- a/src/main/java/net/pterodactylus/sone/core/Options.java +++ b/src/main/java/net/pterodactylus/sone/core/Options.java @@ -1,5 +1,5 @@ /* - * Sone - Options.java - Copyright © 2010–2015 David Roden + * Sone - Options.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/Preferences.java b/src/main/java/net/pterodactylus/sone/core/Preferences.java index 8123764..456e7f2 100644 --- a/src/main/java/net/pterodactylus/sone/core/Preferences.java +++ b/src/main/java/net/pterodactylus/sone/core/Preferences.java @@ -1,5 +1,5 @@ /* - * Sone - Preferences.java - Copyright © 2013–2015 David Roden + * Sone - Preferences.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index 6317abe..db08046 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -1,5 +1,5 @@ /* - * Sone - SoneDownloaderImpl.java - Copyright © 2010–2015 David Roden + * Sone - SoneDownloaderImpl.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneException.java b/src/main/java/net/pterodactylus/sone/core/SoneException.java index 246025d..e651646 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneException.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneException.java @@ -1,5 +1,5 @@ /* - * Sone - SoneException.java - Copyright © 2010–2015 David Roden + * Sone - SoneException.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInsertException.java b/src/main/java/net/pterodactylus/sone/core/SoneInsertException.java index ffda655..879767e 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInsertException.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInsertException.java @@ -1,5 +1,5 @@ /* - * Sone - SoneInsertException.java - Copyright © 2011–2015 David Roden + * Sone - SoneInsertException.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index e34f19d..46558ab 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -1,5 +1,5 @@ /* - * Sone - SoneInserter.java - Copyright © 2010–2015 David Roden + * Sone - SoneInserter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneParser.java b/src/main/java/net/pterodactylus/sone/core/SoneParser.java index ae1e2a5..fdbd9ae 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneParser.java @@ -261,7 +261,6 @@ public class SoneParser { String parentId = albumXml.getValue("parent", null); String title = albumXml.getValue("title", null); String description = albumXml.getValue("description", ""); - String albumImageId = albumXml.getValue("album-image", null); if ((id == null) || (title == null)) { logger.log(Level.WARNING, String.format("Downloaded Sone %s contains invalid album!", sone)); return null; @@ -315,7 +314,6 @@ public class SoneParser { allImages.put(imageId, image); } } - album.modify().setAlbumImage(albumImageId).update(); } } diff --git a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java index 2ca4b4a..0731b1a 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneRescuer.java @@ -1,5 +1,5 @@ /* - * Sone - SoneRescuer.java - Copyright © 2011–2015 David Roden + * Sone - SoneRescuer.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneUri.java b/src/main/java/net/pterodactylus/sone/core/SoneUri.java index f62b4ec..1fbadbc 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneUri.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneUri.java @@ -1,5 +1,5 @@ /* - * Sone - SoneUri.java - Copyright © 2013–2015 David Roden + * Sone - SoneUri.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java index 146383a..e739a44 100644 --- a/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java +++ b/src/main/java/net/pterodactylus/sone/core/UpdateChecker.java @@ -1,5 +1,5 @@ /* - * Sone - UpdateChecker.java - Copyright © 2011–2015 David Roden + * Sone - UpdateChecker.java - Copyright © 2011–2016 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 @@ -28,6 +28,8 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import javax.inject.Singleton; + import net.pterodactylus.sone.core.FreenetInterface.Fetched; import net.pterodactylus.sone.core.event.UpdateFoundEvent; import net.pterodactylus.sone.main.SonePlugin; @@ -45,6 +47,7 @@ import freenet.support.api.Bucket; * * @author David ‘Bombe’ Roden */ +@Singleton public class UpdateChecker { /** The logger. */ @@ -60,10 +63,11 @@ public class UpdateChecker { private FreenetURI currentUri; /** The latest known edition. */ - private long latestEdition; + private long latestEdition = SonePlugin.getLatestEdition(); /** The current latest known version. */ - private Version currentLatestVersion = SonePlugin.VERSION; + private Version currentLatestVersion; + private final Version currentRunningVersion; /** The release date of the latest version. */ private long latestVersionDate; @@ -77,9 +81,11 @@ public class UpdateChecker { * The freenet interface to use */ @Inject - public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface) { + public UpdateChecker(EventBus eventBus, FreenetInterface freenetInterface, Version currentVersion) { this.eventBus = eventBus; this.freenetInterface = freenetInterface; + this.currentRunningVersion = currentVersion; + this.currentLatestVersion = currentVersion; } // @@ -93,7 +99,7 @@ public class UpdateChecker { * @return {@code true} if a new version was found */ public boolean hasLatestVersion() { - return currentLatestVersion.compareTo(SonePlugin.VERSION) > 0; + return currentLatestVersion.compareTo(currentRunningVersion) > 0; } /** @@ -218,9 +224,22 @@ public class UpdateChecker { if (version.compareTo(currentLatestVersion) > 0) { currentLatestVersion = version; latestVersionDate = releaseTime; - logger.log(Level.INFO, String.format("Found new version: %s (%tc)", version, new Date(releaseTime))); - eventBus.post(new UpdateFoundEvent(version, releaseTime, edition)); + boolean disruptive = disruptiveVersionBetweenCurrentAndFound(properties); + logger.log(Level.INFO, String.format("Found new version: %s (%tc%s)", version, new Date(releaseTime), disruptive ? ", disruptive" : "")); + eventBus.post(new UpdateFoundEvent(version, releaseTime, edition, disruptive)); + } + } + + private boolean disruptiveVersionBetweenCurrentAndFound(Properties properties) { + for (String key : properties.stringPropertyNames()) { + if (key.startsWith("DisruptiveVersion/")) { + Version disruptiveVersion = Version.parse(key.substring("DisruptiveVersion/".length())); + if (disruptiveVersion.compareTo(currentRunningVersion) > 0) { + return true; + } + } } + return false; } } diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java index 82b14ef..05d940f 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java @@ -1,5 +1,5 @@ /* - * Sone - WebOfTrustUpdaterImpl.java - Copyright © 2013–2015 David Roden + * Sone - WebOfTrustUpdaterImpl.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/ImageEvent.java b/src/main/java/net/pterodactylus/sone/core/event/ImageEvent.java index c9646ed..a8a0c6f 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/ImageEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/ImageEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ImageEvent.java - Copyright © 2013–2015 David Roden + * Sone - ImageEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertAbortedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertAbortedEvent.java index 2316217..63a561b 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertAbortedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertAbortedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ImageInsertAbortedEvent.java - Copyright © 2013–2015 David Roden + * Sone - ImageInsertAbortedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFailedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFailedEvent.java index b09cd45..eaa3996 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFailedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFailedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ImageInsertFailedEvent.java - Copyright © 2013–2015 David Roden + * Sone - ImageInsertFailedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFinishedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFinishedEvent.java index 06a506d..41d7ecc 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFinishedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertFinishedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ImageInsertFinishedEvent.java - Copyright © 2013–2015 David Roden + * Sone - ImageInsertFinishedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertStartedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertStartedEvent.java index b0f0c68..876f2db 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/ImageInsertStartedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/ImageInsertStartedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ImageInsertStartedEvent.java - Copyright © 2013–2015 David Roden + * Sone - ImageInsertStartedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/MarkPostKnownEvent.java b/src/main/java/net/pterodactylus/sone/core/event/MarkPostKnownEvent.java index 112361a..72c7baf 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/MarkPostKnownEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/MarkPostKnownEvent.java @@ -1,5 +1,5 @@ /* - * Sone - MarkPostKnownEvent.java - Copyright © 2013–2015 David Roden + * Sone - MarkPostKnownEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/MarkPostReplyKnownEvent.java b/src/main/java/net/pterodactylus/sone/core/event/MarkPostReplyKnownEvent.java index d50a046..224bb31 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/MarkPostReplyKnownEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/MarkPostReplyKnownEvent.java @@ -1,5 +1,5 @@ /* - * Sone - MarkPostReplyKnownEvent.java - Copyright © 2013–2015 David Roden + * Sone - MarkPostReplyKnownEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java b/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java index eb1ea3f..ca6cd70 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/MarkSoneKnownEvent.java @@ -1,5 +1,5 @@ /* - * Sone - MarkSoneKnownEvent.java - Copyright © 2013–2015 David Roden + * Sone - MarkSoneKnownEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/NewPostFoundEvent.java b/src/main/java/net/pterodactylus/sone/core/event/NewPostFoundEvent.java index f77c462..ff81357 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/NewPostFoundEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/NewPostFoundEvent.java @@ -1,5 +1,5 @@ /* - * Sone - NewPostFoundEvent.java - Copyright © 2013–2015 David Roden + * Sone - NewPostFoundEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/NewPostReplyFoundEvent.java b/src/main/java/net/pterodactylus/sone/core/event/NewPostReplyFoundEvent.java index 68c2d20..bda02b6 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/NewPostReplyFoundEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/NewPostReplyFoundEvent.java @@ -1,5 +1,5 @@ /* - * Sone - NewPostReplyFoundEvent.java - Copyright © 2013–2015 David Roden + * Sone - NewPostReplyFoundEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java b/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java index 623cf12..c110483 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/NewSoneFoundEvent.java @@ -1,5 +1,5 @@ /* - * Sone - NewSoneFoundEvent.java - Copyright © 2013–2015 David Roden + * Sone - NewSoneFoundEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/PostEvent.java b/src/main/java/net/pterodactylus/sone/core/event/PostEvent.java index 1b5cb68..78555b5 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/PostEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/PostEvent.java @@ -1,5 +1,5 @@ /* - * Sone - PostEvent.java - Copyright © 2013–2015 David Roden + * Sone - PostEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/PostRemovedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/PostRemovedEvent.java index 850f712..8240176 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/PostRemovedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/PostRemovedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - PostRemovedEvent.java - Copyright © 2013–2015 David Roden + * Sone - PostRemovedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/PostReplyEvent.java b/src/main/java/net/pterodactylus/sone/core/event/PostReplyEvent.java index f312fcc..6ae51bc 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/PostReplyEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/PostReplyEvent.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyEvent.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/PostReplyRemovedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/PostReplyRemovedEvent.java index e900de5..4f7cc8b 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/PostReplyRemovedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/PostReplyRemovedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyRemovedEvent.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyRemovedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java index 324b230..848c1b8 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java index fa68c26..a20e15a 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertAbortedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneInsertAbortedEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneInsertAbortedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java index 6c276b7..8b3f79e 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneInsertedEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneInsertedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java index 4653317..4e2f155 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneInsertingEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneInsertingEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneInsertingEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java index 251759d..2703f16 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneLockedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneLockedEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneLockedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java index 30bd317..ecba776 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneRemovedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneRemovedEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneRemovedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java b/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java index 17f8027..de2d875 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/SoneUnlockedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - SoneUnlockedEvent.java - Copyright © 2013–2015 David Roden + * Sone - SoneUnlockedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/core/event/UpdateFoundEvent.java b/src/main/java/net/pterodactylus/sone/core/event/UpdateFoundEvent.java index e8cb8e5..10adda5 100644 --- a/src/main/java/net/pterodactylus/sone/core/event/UpdateFoundEvent.java +++ b/src/main/java/net/pterodactylus/sone/core/event/UpdateFoundEvent.java @@ -1,5 +1,5 @@ /* - * Sone - UpdateFoundEvent.java - Copyright © 2013–2015 David Roden + * Sone - UpdateFoundEvent.java - Copyright © 2013–2016 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 @@ -26,61 +26,32 @@ import net.pterodactylus.util.version.Version; */ public class UpdateFoundEvent { - /** The version that was found. */ private final Version version; - - /** The time the update was released. */ private final long releaseTime; - - /** The latest edition of the update page. */ private final long latestEdition; + private final boolean disruptive; - /** - * Creates a new “update found” event. - * - * @param version - * The version of the update - * @param releaseTime - * The release time of the update - * @param latestEdition - * The latest edition of the update page - */ - public UpdateFoundEvent(Version version, long releaseTime, long latestEdition) { + public UpdateFoundEvent(Version version, long releaseTime, long latestEdition, boolean disruptive) { this.version = version; this.releaseTime = releaseTime; this.latestEdition = latestEdition; + this.disruptive = disruptive; } - // - // ACCESSORS - // - - /** - * Returns the version of the update. - * - * @return The version of the update - */ public Version version() { return version; } - /** - * Returns the release time of the update. - * - * @return The releae time of the update (in milliseconds since Jan 1, 1970 - * UTC) - */ public long releaseTime() { return releaseTime; } - /** - * Returns the latest edition of the update page. - * - * @return The latest edition of the update page - */ public long latestEdition() { return latestEdition; } + public boolean disruptive() { + return disruptive; + } + } diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 698206d..5a02f19 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -1,5 +1,5 @@ /* - * Sone - Album.java - Copyright © 2011–2015 David Roden + * Sone - Album.java - Copyright © 2011–2016 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 @@ -206,14 +206,6 @@ public interface Album extends Identified, Fingerprintable { Image moveImageDown(Image image); /** - * Returns the album image of this album, or {@code null} if no album image has - * been set. - * - * @return The image to show when this album is listed - */ - Image getAlbumImage(); - - /** * Returns whether this album contains any other albums or images. * * @return {@code true} if this album is empty, {@code false} otherwise @@ -288,8 +280,6 @@ public interface Album extends Identified, Fingerprintable { Modifier setDescription(String description); - Modifier setAlbumImage(String imageId); - Album update() throws IllegalStateException; class AlbumTitleMustNotBeEmpty extends IllegalStateException { } diff --git a/src/main/java/net/pterodactylus/sone/data/Client.java b/src/main/java/net/pterodactylus/sone/data/Client.java index e8f5082..650ef16 100644 --- a/src/main/java/net/pterodactylus/sone/data/Client.java +++ b/src/main/java/net/pterodactylus/sone/data/Client.java @@ -1,5 +1,5 @@ /* - * Sone - Client.java - Copyright © 2010–2015 David Roden + * Sone - Client.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java b/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java index df4e2d7..407aa8a 100644 --- a/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java +++ b/src/main/java/net/pterodactylus/sone/data/Fingerprintable.java @@ -1,5 +1,5 @@ /* - * Sone - Fingerprintable.java - Copyright © 2011–2015 David Roden + * Sone - Fingerprintable.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Identified.java b/src/main/java/net/pterodactylus/sone/data/Identified.java index e748c7e..659a56f 100644 --- a/src/main/java/net/pterodactylus/sone/data/Identified.java +++ b/src/main/java/net/pterodactylus/sone/data/Identified.java @@ -1,5 +1,5 @@ /* - * Sone - Identified.java - Copyright © 2013–2015 David Roden + * Sone - Identified.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Image.java b/src/main/java/net/pterodactylus/sone/data/Image.java index 6413481..55b0094 100644 --- a/src/main/java/net/pterodactylus/sone/data/Image.java +++ b/src/main/java/net/pterodactylus/sone/data/Image.java @@ -1,5 +1,5 @@ /* - * Sone - Image.java - Copyright © 2011–2015 David Roden + * Sone - Image.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Post.java b/src/main/java/net/pterodactylus/sone/data/Post.java index d666eb7..990e20d 100644 --- a/src/main/java/net/pterodactylus/sone/data/Post.java +++ b/src/main/java/net/pterodactylus/sone/data/Post.java @@ -1,5 +1,5 @@ /* - * Sone - Post.java - Copyright © 2010–2015 David Roden + * Sone - Post.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/PostReply.java b/src/main/java/net/pterodactylus/sone/data/PostReply.java index 585b430..6821b7b 100644 --- a/src/main/java/net/pterodactylus/sone/data/PostReply.java +++ b/src/main/java/net/pterodactylus/sone/data/PostReply.java @@ -1,5 +1,5 @@ /* - * Sone - PostReply.java - Copyright © 2010–2015 David Roden + * Sone - PostReply.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index 55faf18..0f9b8ff 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -1,5 +1,5 @@ /* - * Sone - Profile.java - Copyright © 2010–2015 David Roden + * Sone - Profile.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Reply.java b/src/main/java/net/pterodactylus/sone/data/Reply.java index c92bacb..d3068c4 100644 --- a/src/main/java/net/pterodactylus/sone/data/Reply.java +++ b/src/main/java/net/pterodactylus/sone/data/Reply.java @@ -1,5 +1,5 @@ /* - * Sone - Reply.java - Copyright © 2010–2015 David Roden + * Sone - Reply.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 072f2c7..68c8114 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -1,5 +1,5 @@ /* - * Sone - Sone.java - Copyright © 2010–2015 David Roden + * Sone - Sone.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/TemporaryImage.java b/src/main/java/net/pterodactylus/sone/data/TemporaryImage.java index 9383133..ee6c35c 100644 --- a/src/main/java/net/pterodactylus/sone/data/TemporaryImage.java +++ b/src/main/java/net/pterodactylus/sone/data/TemporaryImage.java @@ -1,5 +1,5 @@ /* - * Sone - TemporaryImage.java - Copyright © 2011–2015 David Roden + * Sone - TemporaryImage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java index 9be43b6..66a758a 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractAlbumBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AbstractAlbumBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java index ad6d15f..2282c11 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractImageBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractImageBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AbstractImageBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostBuilder.java index 3c6e547..f33a446 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractPostBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AbstractPostBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostReplyBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostReplyBuilder.java index be05424..10bdf76 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostReplyBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractPostReplyBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractPostReplyBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AbstractPostReplyBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java index 71e1e53..c66debf 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractReplyBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractReplyBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AbstractReplyBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AlbumBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/AlbumBuilderImpl.java index 72ae5a5..3ec6b42 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AlbumBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AlbumBuilderImpl.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumBuilderImpl.java - Copyright © 2013–2015 David Roden + * Sone - AlbumBuilderImpl.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java index 41668ab..991459a 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumImpl.java - Copyright © 2011–2015 David Roden + * Sone - AlbumImpl.java - Copyright © 2011–2016 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 @@ -70,9 +70,6 @@ public class AlbumImpl implements Album { /** The description of this album. */ private String description; - /** The ID of the album picture. */ - private String albumImage; - /** Creates a new album with a random ID. */ public AlbumImpl(Sone sone) { this(sone, UUID.randomUUID().toString()); @@ -176,9 +173,6 @@ public class AlbumImpl implements Album { image.getAlbum().removeImage(image); } image.setAlbum(this); - if (imageIds.isEmpty() && (albumImage == null)) { - albumImage = image.getId(); - } if (!imageIds.contains(image.getId())) { imageIds.add(image.getId()); images.put(image.getId(), image); @@ -192,13 +186,6 @@ public class AlbumImpl implements Album { checkArgument(image.getSone().equals(sone), "image must belong to the same Sone as this album"); imageIds.remove(image.getId()); images.remove(image.getId()); - if (image.getId().equals(albumImage)) { - if (images.isEmpty()) { - albumImage = null; - } else { - albumImage = images.values().iterator().next().getId(); - } - } } @Override @@ -232,14 +219,6 @@ public class AlbumImpl implements Album { } @Override - public Image getAlbumImage() { - if (albumImage == null) { - return null; - } - return Optional.fromNullable(images.get(albumImage)).or(images.values().iterator().next()); - } - - @Override public boolean isEmpty() { return albums.isEmpty() && images.isEmpty(); } @@ -284,8 +263,6 @@ public class AlbumImpl implements Album { private Optional description = absent(); - private Optional albumImage = absent(); - @Override public Modifier setTitle(String title) { this.title = fromNullable(title); @@ -299,12 +276,6 @@ public class AlbumImpl implements Album { } @Override - public Modifier setAlbumImage(String imageId) { - this.albumImage = fromNullable(imageId); - return this; - } - - @Override public Album update() throws IllegalStateException { if (title.isPresent() && title.get().trim().isEmpty()) { throw new AlbumTitleMustNotBeEmpty(); @@ -315,9 +286,6 @@ public class AlbumImpl implements Album { if (description.isPresent()) { AlbumImpl.this.description = description.get(); } - if (albumImage.isPresent()) { - AlbumImpl.this.albumImage = albumImage.get(); - } return AlbumImpl.this; } }; @@ -334,9 +302,6 @@ public class AlbumImpl implements Album { hash.putString("ID(").putString(id).putString(")"); hash.putString("Title(").putString(title).putString(")"); hash.putString("Description(").putString(description).putString(")"); - if (albumImage != null) { - hash.putString("AlbumImage(").putString(albumImage).putString(")"); - } /* add nested albums. */ hash.putString("Albums("); diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java index a0617b3..65b266d 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultPostBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - DefaultPostBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java index 1944ff9..bad7745 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultPostReplyBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - DefaultPostReplyBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java index 04ac778..4f4f26b 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ImageBuilderImpl.java @@ -1,5 +1,5 @@ /* - * Sone - ImageBuilderImpl.java - Copyright © 2013–2015 David Roden + * Sone - ImageBuilderImpl.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ImageImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ImageImpl.java index ddf01c8..9f0fbbf 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ImageImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ImageImpl.java @@ -1,5 +1,5 @@ /* - * Sone - ImageImpl.java - Copyright © 2011–2015 David Roden + * Sone - ImageImpl.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java index e6c1b66..9fed167 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java @@ -1,5 +1,5 @@ /* - * Sone - PostBuilderImpl.java - Copyright © 2013–2015 David Roden + * Sone - PostBuilderImpl.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java index 365d28f..86f4098 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java @@ -1,5 +1,5 @@ /* - * Sone - PostImpl.java - Copyright © 2010–2015 David Roden + * Sone - PostImpl.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java index a7abb66..30f32fc 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyBuilderImpl.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyBuilderImpl.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java index 136d6a0..5084c1c 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyImpl.java - Copyright © 2010–2015 David Roden + * Sone - PostReplyImpl.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java index 3416241..4105749 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java @@ -1,5 +1,5 @@ /* - * Sone - ReplyImpl.java - Copyright © 2011–2015 David Roden + * Sone - ReplyImpl.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java index 5024be2..8a6dd80 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java @@ -1,5 +1,5 @@ /* - * Sone - SoneImpl.java - Copyright © 2010–2015 David Roden + * Sone - SoneImpl.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java b/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java index f0b19cb..2460306 100644 --- a/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumBuilder.java - Copyright © 2013–2015 David Roden + * Sone - AlbumBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java index ff5ab6d..07d7ae0 100644 --- a/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - AlbumBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java b/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java index 7b37751..8e6fa45 100644 --- a/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumDatabase.java - Copyright © 2013–2015 David Roden + * Sone - AlbumDatabase.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java b/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java index 83ce6dc..746f014 100644 --- a/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java +++ b/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumProvider.java - Copyright © 2013–2015 David Roden + * Sone - AlbumProvider.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumStore.java b/src/main/java/net/pterodactylus/sone/database/AlbumStore.java index 8c3c97b..2a9bfd0 100644 --- a/src/main/java/net/pterodactylus/sone/database/AlbumStore.java +++ b/src/main/java/net/pterodactylus/sone/database/AlbumStore.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumStore.java - Copyright © 2013–2015 David Roden + * Sone - AlbumStore.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/Database.java b/src/main/java/net/pterodactylus/sone/database/Database.java index c08162c..db63ba3 100644 --- a/src/main/java/net/pterodactylus/sone/database/Database.java +++ b/src/main/java/net/pterodactylus/sone/database/Database.java @@ -1,5 +1,5 @@ /* - * Sone - Database.java - Copyright © 2013–2015 David Roden + * Sone - Database.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/DatabaseException.java b/src/main/java/net/pterodactylus/sone/database/DatabaseException.java index abd1080..bb98fec 100644 --- a/src/main/java/net/pterodactylus/sone/database/DatabaseException.java +++ b/src/main/java/net/pterodactylus/sone/database/DatabaseException.java @@ -1,5 +1,5 @@ /* - * Sone - DatabaseException.java - Copyright © 2013–2015 David Roden + * Sone - DatabaseException.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java b/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java index 08b9897..7b5c9e0 100644 --- a/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - ImageBuilder.java - Copyright © 2013–2015 David Roden + * Sone - ImageBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java index 6c40a22..900c989 100644 --- a/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - ImageBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - ImageBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java b/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java index 97e81cc..090aa3b 100644 --- a/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java @@ -1,5 +1,5 @@ /* - * Sone - ImageDatabase.java - Copyright © 2013–2015 David Roden + * Sone - ImageDatabase.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ImageProvider.java b/src/main/java/net/pterodactylus/sone/database/ImageProvider.java index ecb1bd6..8ee3e5f 100644 --- a/src/main/java/net/pterodactylus/sone/database/ImageProvider.java +++ b/src/main/java/net/pterodactylus/sone/database/ImageProvider.java @@ -1,5 +1,5 @@ /* - * Sone - ImageProvider.java - Copyright © 2013–2015 David Roden + * Sone - ImageProvider.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ImageStore.java b/src/main/java/net/pterodactylus/sone/database/ImageStore.java index 9c32542..97a7240 100644 --- a/src/main/java/net/pterodactylus/sone/database/ImageStore.java +++ b/src/main/java/net/pterodactylus/sone/database/ImageStore.java @@ -1,5 +1,5 @@ /* - * Sone - ImageStore.java - Copyright © 2013–2015 David Roden + * Sone - ImageStore.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostBuilder.java b/src/main/java/net/pterodactylus/sone/database/PostBuilder.java index 3c1927f..45cc062 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/PostBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - PostBuilder.java - Copyright © 2013–2015 David Roden + * Sone - PostBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java index 98513de..e5cee38 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/database/PostBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - PostBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - PostBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostDatabase.java b/src/main/java/net/pterodactylus/sone/database/PostDatabase.java index 164224a..648c77e 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/PostDatabase.java @@ -1,5 +1,5 @@ /* - * Sone - PostDatabase.java - Copyright © 2013–2015 David Roden + * Sone - PostDatabase.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostProvider.java b/src/main/java/net/pterodactylus/sone/database/PostProvider.java index 353a524..bea59b9 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostProvider.java +++ b/src/main/java/net/pterodactylus/sone/database/PostProvider.java @@ -1,5 +1,5 @@ /* - * Sone - PostProvider.java - Copyright © 2011–2015 David Roden + * Sone - PostProvider.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyBuilder.java b/src/main/java/net/pterodactylus/sone/database/PostReplyBuilder.java index 82b0c0b..16569d9 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyBuilder.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/PostReplyBuilderFactory.java index 8f4dfe8..f85b18b 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyBuilderFactory.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyBuilderFactory.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyBuilderFactory.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java b/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java index c68b40c..f226d73 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyDatabase.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyDatabase.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java b/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java index dc89826..e982599 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyProvider.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyProvider.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyStore.java b/src/main/java/net/pterodactylus/sone/database/PostReplyStore.java index 939c100..7956a92 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyStore.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyStore.java @@ -1,5 +1,5 @@ /* - * Sone - PostReplyStore.java - Copyright © 2013–2015 David Roden + * Sone - PostReplyStore.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/PostStore.java b/src/main/java/net/pterodactylus/sone/database/PostStore.java index b4340b9..7c3e07f 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostStore.java +++ b/src/main/java/net/pterodactylus/sone/database/PostStore.java @@ -1,5 +1,5 @@ /* - * Sone - PostStore.java - Copyright © 2013–2015 David Roden + * Sone - PostStore.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/ReplyBuilder.java b/src/main/java/net/pterodactylus/sone/database/ReplyBuilder.java index 93cf6b3..21ba89c 100644 --- a/src/main/java/net/pterodactylus/sone/database/ReplyBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/ReplyBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - ReplyBuilder.java - Copyright © 2013–2015 David Roden + * Sone - ReplyBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/SoneProvider.java b/src/main/java/net/pterodactylus/sone/database/SoneProvider.java index 1c685ab..a39ceff 100644 --- a/src/main/java/net/pterodactylus/sone/database/SoneProvider.java +++ b/src/main/java/net/pterodactylus/sone/database/SoneProvider.java @@ -1,5 +1,5 @@ /* - * Sone - SoneProvider.java - Copyright © 2011–2015 David Roden + * Sone - SoneProvider.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java index fa608e4..aa4a2a8 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryDatabase.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryDatabase.java - Copyright © 2013–2015 David Roden + * Sone - MemoryDatabase.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPost.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPost.java index d368fba..acf2374 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPost.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPost.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryPost.java - Copyright © 2010–2015 David Roden + * Sone - MemoryPost.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostBuilder.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostBuilder.java index d76f277..7125167 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryPostBuilder.java - Copyright © 2013–2015 David Roden + * Sone - MemoryPostBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReply.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReply.java index a48b017..714b84e 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReply.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReply.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryPostReply.java - Copyright © 2013–2015 David Roden + * Sone - MemoryPostReply.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReplyBuilder.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReplyBuilder.java index 2871b27..59e098c 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReplyBuilder.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryPostReplyBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryPostReplyBuilder.java - Copyright © 2013–2015 David Roden + * Sone - MemoryPostReplyBuilder.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java index 312bb9e..b2264a5 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/AbstractSoneCommand.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractSoneCommand.java - Copyright © 2011–2015 David Roden + * Sone - AbstractSoneCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java index cd596ce..6f1e82c 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/CreatePostCommand.java @@ -1,5 +1,5 @@ /* - * Sone - CreatePostCommand.java - Copyright © 2011–2015 David Roden + * Sone - CreatePostCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/CreateReplyCommand.java b/src/main/java/net/pterodactylus/sone/fcp/CreateReplyCommand.java index 65b0ac2..9369529 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/CreateReplyCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/CreateReplyCommand.java @@ -1,5 +1,5 @@ /* - * Sone - CreateReplyCommand.java - Copyright © 2011–2015 David Roden + * Sone - CreateReplyCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/DeletePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/DeletePostCommand.java index d411233..e68cbb5 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/DeletePostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/DeletePostCommand.java @@ -1,5 +1,5 @@ /* - * Sone - DeletePostCommand.java - Copyright © 2011–2015 David Roden + * Sone - DeletePostCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/DeleteReplyCommand.java b/src/main/java/net/pterodactylus/sone/fcp/DeleteReplyCommand.java index 8b2f5b7..00a5b97 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/DeleteReplyCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/DeleteReplyCommand.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteReplyCommand.java - Copyright © 2011–2015 David Roden + * Sone - DeleteReplyCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index 25cf4ae..440cb4c 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -1,5 +1,5 @@ /* - * Sone - FcpInterface.java - Copyright © 2011–2015 David Roden + * Sone - FcpInterface.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java index fdef446..8ac80cc 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetLocalSonesCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetLocalSonesCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetLocalSonesCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java index 2211677..1e02dae 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetPostCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java index 0851616..bbff5ed 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostFeedCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetPostFeedCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java index baa7147..4059bf5 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostsCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostsCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetPostsCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetSoneCommand.java index 2ad514f..f23be19 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetSoneCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetSoneCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetSoneCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java index 770cb22..97c8842 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java @@ -1,5 +1,5 @@ /* - * Sone - GetSonesCommand.java - Copyright © 2011–2015 David Roden + * Sone - GetSonesCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java b/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java index d8d6604..583b8e4 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/LikePostCommand.java @@ -1,5 +1,5 @@ /* - * Sone - LikePostCommand.java - Copyright © 2011–2015 David Roden + * Sone - LikePostCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java b/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java index edfa742..63d8893 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/LikeReplyCommand.java @@ -1,5 +1,5 @@ /* - * Sone - LikeReplyCommand.java - Copyright © 2011–2015 David Roden + * Sone - LikeReplyCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/LockSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/LockSoneCommand.java index 287ec91..e05ac93 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/LockSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/LockSoneCommand.java @@ -1,5 +1,5 @@ /* - * Sone - LockSoneCommand.java - Copyright © 2013–2015 David Roden + * Sone - LockSoneCommand.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/UnlockSoneCommand.java b/src/main/java/net/pterodactylus/sone/fcp/UnlockSoneCommand.java index 4870168..311a7ca 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/UnlockSoneCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/UnlockSoneCommand.java @@ -1,5 +1,5 @@ /* - * Sone - UnlockSoneCommand.java - Copyright © 2013–2015 David Roden + * Sone - UnlockSoneCommand.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java b/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java index 9533aca..b887926 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/VersionCommand.java @@ -1,5 +1,5 @@ /* - * Sone - VersionCommand.java - Copyright © 2011–2015 David Roden + * Sone - VersionCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java index b547a53..3b4af2a 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java +++ b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java @@ -1,5 +1,5 @@ /* - * Sone - L10nFilter.java - Copyright © 2010–2015 David Roden + * Sone - L10nFilter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java index dfc30f9..55e4024 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java +++ b/src/main/java/net/pterodactylus/sone/freenet/PluginStoreConfigurationBackend.java @@ -1,5 +1,5 @@ /* - * Sone - PluginStoreConfigurationBackend.java - Copyright © 2010–2015 David Roden + * Sone - PluginStoreConfigurationBackend.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/SimpleFieldSetBuilder.java b/src/main/java/net/pterodactylus/sone/freenet/SimpleFieldSetBuilder.java index 2c68f07..25088fc 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/SimpleFieldSetBuilder.java +++ b/src/main/java/net/pterodactylus/sone/freenet/SimpleFieldSetBuilder.java @@ -1,5 +1,5 @@ /* - * Sone - SimpleFieldSetBuilder.java - Copyright © 2011–2015 David Roden + * Sone - SimpleFieldSetBuilder.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java index c516f0f..b39d905 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/AbstractCommand.java @@ -1,5 +1,5 @@ /* - * Sone - AbstractCommand.java - Copyright © 2011–2015 David Roden + * Sone - AbstractCommand.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java index d0f812a..bafa764 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/Command.java @@ -1,5 +1,5 @@ /* - * Sone - Command.java - Copyright © 2011–2015 David Roden + * Sone - Command.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpException.java b/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpException.java index 34920f4..c28eef7 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpException.java +++ b/src/main/java/net/pterodactylus/sone/freenet/fcp/FcpException.java @@ -1,5 +1,5 @@ /* - * Sone - FcpException.java - Copyright © 2011–2015 David Roden + * Sone - FcpException.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java index 46343a3..0090aa8 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginConnector.java @@ -1,5 +1,5 @@ /* - * Sone - PluginConnector.java - Copyright © 2010–2015 David Roden + * Sone - PluginConnector.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginException.java b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginException.java index 78e73cd..09b186e 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginException.java +++ b/src/main/java/net/pterodactylus/sone/freenet/plugin/PluginException.java @@ -1,5 +1,5 @@ /* - * Sone - PluginException.java - Copyright © 2010–2015 David Roden + * Sone - PluginException.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/plugin/event/ReceivedReplyEvent.java b/src/main/java/net/pterodactylus/sone/freenet/plugin/event/ReceivedReplyEvent.java index feeb1ea..56a1d46 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/plugin/event/ReceivedReplyEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/plugin/event/ReceivedReplyEvent.java @@ -1,5 +1,5 @@ /* - * Sone - ReceivedReplyEvent.java - Copyright © 2013–2015 David Roden + * Sone - ReceivedReplyEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java index 4d5a3a8..13f9793 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Context.java @@ -1,5 +1,5 @@ /* - * Sone - Context.java - Copyright © 2014–2015 David Roden + * Sone - Context.java - Copyright © 2014–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java index 6313a1a..433516f 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultIdentity.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultIdentity.java - Copyright © 2010–2015 David Roden + * Sone - DefaultIdentity.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java index 68e6f41..2f78943 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentity.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultOwnIdentity.java - Copyright © 2010–2015 David Roden + * Sone - DefaultOwnIdentity.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java index c6875e9..25ddf9c 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -1,5 +1,5 @@ /* - * Sone - Identity.java - Copyright © 2010–2015 David Roden + * Sone - Identity.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java index 9703891..cfce632 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityChangeDetector.java - Copyright © 2013–2015 David Roden + * Sone - IdentityChangeDetector.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java index d17efae..b3c3c05 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityChangeEventSender.java - Copyright © 2013–2015 David Roden + * Sone - IdentityChangeEventSender.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java index a3b4f6c..1a8cc49 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityLoader.java - Copyright © 2013–2015 David Roden + * Sone - IdentityLoader.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java index 33b1ef6..02e91ce 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityManagerImpl.java - Copyright © 2010–2015 David Roden + * Sone - IdentityManagerImpl.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java index 2f0ade9..8be0571 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/OwnIdentity.java @@ -1,5 +1,5 @@ /* - * Sone - OwnIdentity.java - Copyright © 2010–2015 David Roden + * Sone - OwnIdentity.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java index 65c6dba..7b18888 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Trust.java @@ -1,5 +1,5 @@ /* - * Sone - Trust.java - Copyright © 2010–2015 David Roden + * Sone - Trust.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index ca3a38c..5f7b8b7 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -1,5 +1,5 @@ /* - * Sone - WebOfTrustConnector.java - Copyright © 2010–2015 David Roden + * Sone - WebOfTrustConnector.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustException.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustException.java index ae41613..c622b3c 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustException.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustException.java @@ -1,5 +1,5 @@ /* - * Sone - WebOfTrustException.java - Copyright © 2010–2015 David Roden + * Sone - WebOfTrustException.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java index 897c04b..323a9cf 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityAddedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityAddedEvent.java - Copyright © 2013–2015 David Roden + * Sone - IdentityAddedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java index 60abcb6..6289c8a 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityEvent.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityEvent.java - Copyright © 2013–2015 David Roden + * Sone - IdentityEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java index bdf2ff0..a586de0 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityRemovedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityRemovedEvent.java - Copyright © 2013–2015 David Roden + * Sone - IdentityRemovedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java index 0521f7e..3e9a0f7 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/IdentityUpdatedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityUpdatedEvent.java - Copyright © 2013–2015 David Roden + * Sone - IdentityUpdatedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java index f4bc97a..cdb787a 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityAddedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - OwnIdentityAddedEvent.java - Copyright © 2013–2015 David Roden + * Sone - OwnIdentityAddedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java index 56a7156..91ad281 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityEvent.java @@ -1,5 +1,5 @@ /* - * Sone - OwnIdentityEvent.java - Copyright © 2013–2015 David Roden + * Sone - OwnIdentityEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java index 0f8b201..5b6bd95 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/event/OwnIdentityRemovedEvent.java @@ -1,5 +1,5 @@ /* - * Sone - OwnIdentityRemovedEvent.java - Copyright © 2013–2015 David Roden + * Sone - OwnIdentityRemovedEvent.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 828d1af..bff0a49 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -1,5 +1,5 @@ /* - * Sone - SonePlugin.java - Copyright © 2010–2015 David Roden + * Sone - SonePlugin.java - Copyright © 2010–2016 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 @@ -116,12 +116,12 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr } /** The version. */ - public static final Version VERSION = new Version(0, 9, 4); + public static final Version VERSION = new Version(0, 9, 5); /** The current year at time of release. */ - private static final int YEAR = 2015; + private static final int YEAR = 2016; private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/"; - private static final int LATEST_EDITION = 71; + private static final int LATEST_EDITION = 72; /** The logger. */ private static final Logger logger = getLogger(SonePlugin.class.getName()); @@ -183,6 +183,10 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr return SONE_HOMEPAGE + LATEST_EDITION; } + public static long getLatestEdition() { + return LATEST_EDITION; + } + // // FREDPLUGIN METHODS // @@ -250,6 +254,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr bind(Context.class).toInstance(context); bind(getOptionalContextTypeLiteral()).toInstance(of(context)); bind(SonePlugin.class).toInstance(SonePlugin.this); + bind(Version.class).toInstance(VERSION); if (startConfiguration.getBooleanValue("Developer.LoadFromFilesystem").getValue(false)) { String path = startConfiguration.getStringValue("Developer.FilesystemPath").getValue(null); if (path != null) { diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java index 101b1fb..8ab8e4c 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java @@ -1,5 +1,5 @@ /* - * Sone - ListNotification.java - Copyright © 2010–2015 David Roden + * Sone - ListNotification.java - Copyright © 2010–2016 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 @@ -194,15 +194,7 @@ public class ListNotification extends TemplateNotification { if (!key.equals(listNotification.key)) { return false; } - if (elements.size() != listNotification.elements.size()) { - return false; - } - for (int index = 0; index < elements.size(); ++index) { - if (!elements.get(index).equals(listNotification.elements.get(index))) { - return false; - } - } - return true; + return elements.equals(listNotification.elements); } } diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java new file mode 100644 index 0000000..4672e72 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java @@ -0,0 +1,166 @@ +/* + * Sone - ListNotificationFilter.java - Copyright © 2010–2016 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.notify; + +import static com.google.common.collect.FluentIterable.from; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.inject.Singleton; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.util.notify.Notification; + +import com.google.common.base.Optional; + +/** + * Filter for {@link ListNotification}s. + * + * @author David ‘Bombe’ Roden + */ +@Singleton +public class ListNotificationFilter { + + private final PostVisibilityFilter postVisibilityFilter; + private final ReplyVisibilityFilter replyVisibilityFilter; + + @Inject + public ListNotificationFilter(@Nonnull PostVisibilityFilter postVisibilityFilter, @Nonnull ReplyVisibilityFilter replyVisibilityFilter) { + this.postVisibilityFilter = postVisibilityFilter; + this.replyVisibilityFilter = replyVisibilityFilter; + } + + /** + * Filters new-post and new-reply notifications in the given list of + * notifications. If {@code currentSone} is null, new-post and + * new-reply notifications are removed completely. If {@code currentSone} is + * not {@code null}, only posts that are posted by a friend Sone or the Sone + * itself, and replies that are replies to posts of friend Sones or the Sone + * itself will be retained in the notifications. + * + * @param notifications + * The notifications to filter + * @param currentSone + * The current Sone, or {@code null} if not logged in + * @return The filtered notifications + */ + @SuppressWarnings("unchecked") + public List filterNotifications(Collection notifications, Sone currentSone) { + List filteredNotifications = new ArrayList(); + for (Notification notification : notifications) { + if (notification.getId().equals("new-sone-notification")) { + if ((currentSone != null) && !currentSone.getOptions().isShowNewSoneNotifications()) { + continue; + } + filteredNotifications.add(notification); + } else if (notification.getId().equals("new-post-notification")) { + if (currentSone == null) { + continue; + } + if (!currentSone.getOptions().isShowNewPostNotifications()) { + continue; + } + Optional> filteredNotification = filterPostNotification((ListNotification) notification, currentSone); + if (filteredNotification.isPresent()) { + filteredNotifications.add(filteredNotification.get()); + } + } else if (notification.getId().equals("new-reply-notification")) { + if (currentSone == null) { + continue; + } + if (!currentSone.getOptions().isShowNewReplyNotifications()) { + continue; + } + Optional> filteredNotification = + filterNewReplyNotification((ListNotification) notification, currentSone); + if (filteredNotification.isPresent()) { + filteredNotifications.add(filteredNotification.get()); + } + } else if (notification.getId().equals("mention-notification")) { + Optional> filteredNotification = filterPostNotification((ListNotification) notification, null); + if (filteredNotification.isPresent()) { + filteredNotifications.add(filteredNotification.get()); + } + } else { + filteredNotifications.add(notification); + } + } + return filteredNotifications; + } + + /** + * Filters the posts of the given notification. + * + * @param postNotification + * The post notification + * @param currentSone + * The current Sone, or {@code null} if not logged in + * @return The filtered post notification, or {@link Optional#absent()} if the notification should be removed + */ + @Nonnull + private Optional> filterPostNotification(@Nonnull ListNotification postNotification, + @Nullable Sone currentSone) { + List newPosts = from(postNotification.getElements()).filter(postVisibilityFilter.isVisible(currentSone)).toList(); + if (newPosts.isEmpty()) { + return Optional.absent(); + } + if (newPosts.size() == postNotification.getElements().size()) { + return Optional.of(postNotification); + } + ListNotification filteredNotification = new ListNotification(postNotification); + filteredNotification.setElements(newPosts); + filteredNotification.setLastUpdateTime(postNotification.getLastUpdatedTime()); + return Optional.of(filteredNotification); + } + + /** + * Filters the new replies of the given notification. If {@code currentSone} + * is {@code null}, {@code null} is returned and the notification is + * subsequently removed. Otherwise only replies that are replies to posts + * that are posted by friend Sones of the given Sone are retained; all other + * replies are removed. + * + * @param newReplyNotification + * The new-reply notification + * @param currentSone + * The current Sone, or {@code null} if not logged in + * @return The filtered new-reply notification, or {@code null} if the + * notification should be removed + */ + private Optional> filterNewReplyNotification(ListNotification newReplyNotification, + @Nonnull Sone currentSone) { + List newReplies = from(newReplyNotification.getElements()).filter(replyVisibilityFilter.isVisible(currentSone)).toList(); + if (newReplies.isEmpty()) { + return Optional.absent(); + } + if (newReplies.size() == newReplyNotification.getElements().size()) { + return Optional.of(newReplyNotification); + } + ListNotification filteredNotification = new ListNotification(newReplyNotification); + filteredNotification.setElements(newReplies); + filteredNotification.setLastUpdateTime(newReplyNotification.getLastUpdatedTime()); + return Optional.of(filteredNotification); + } + +} diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java deleted file mode 100644 index 1d4aa68..0000000 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilters.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Sone - ListNotificationFilters.java - Copyright © 2010–2015 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.notify; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.PostReply; -import net.pterodactylus.sone.data.Reply; -import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.freenet.wot.OwnIdentity; -import net.pterodactylus.sone.freenet.wot.Trust; -import net.pterodactylus.util.notify.Notification; - -import com.google.common.base.Optional; - -/** - * Filter for {@link ListNotification}s. - * - * @author David ‘Bombe’ Roden - */ -public class ListNotificationFilters { - - /** - * Filters new-post and new-reply notifications in the given list of - * notifications. If {@code currentSone} is null, new-post and - * new-reply notifications are removed completely. If {@code currentSone} is - * not {@code null}, only posts that are posted by a friend Sone or the Sone - * itself, and replies that are replies to posts of friend Sones or the Sone - * itself will be retained in the notifications. - * - * @param notifications - * The notifications to filter - * @param currentSone - * The current Sone, or {@code null} if not logged in - * @return The filtered notifications - */ - @SuppressWarnings("unchecked") - public static List filterNotifications(Collection notifications, Sone currentSone) { - List filteredNotifications = new ArrayList(); - for (Notification notification : notifications) { - if (notification.getId().equals("new-sone-notification")) { - if ((currentSone != null) && !currentSone.getOptions().isShowNewSoneNotifications()) { - continue; - } - filteredNotifications.add(notification); - } else if (notification.getId().equals("new-post-notification")) { - if ((currentSone != null) && !currentSone.getOptions().isShowNewPostNotifications()) { - continue; - } - ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, currentSone, true); - if (filteredNotification != null) { - filteredNotifications.add(filteredNotification); - } - } else if (notification.getId().equals("new-reply-notification")) { - if ((currentSone != null) && !currentSone.getOptions().isShowNewReplyNotifications()) { - continue; - } - ListNotification filteredNotification = filterNewReplyNotification((ListNotification) notification, currentSone); - if (filteredNotification != null) { - filteredNotifications.add(filteredNotification); - } - } else if (notification.getId().equals("mention-notification")) { - ListNotification filteredNotification = filterNewPostNotification((ListNotification) notification, null, false); - if (filteredNotification != null) { - filteredNotifications.add(filteredNotification); - } - } else { - filteredNotifications.add(notification); - } - } - return filteredNotifications; - } - - /** - * Filters the new posts of the given notification. If {@code currentSone} - * is {@code null} and {@code soneRequired} is {@code true}, {@code null} is - * returned and the notification is subsequently removed. Otherwise only - * posts that are posted by friend Sones of the given Sone are retained; all - * other posts are removed. - * - * @param newPostNotification - * The new-post notification - * @param currentSone - * The current Sone, or {@code null} if not logged in - * @param soneRequired - * Whether a non-{@code null} Sone in {@code currentSone} is - * required - * @return The filtered new-post notification, or {@code null} if the - * notification should be removed - */ - public static ListNotification filterNewPostNotification(ListNotification newPostNotification, Sone currentSone, boolean soneRequired) { - if (soneRequired && (currentSone == null)) { - return null; - } - List newPosts = new ArrayList(); - for (Post post : newPostNotification.getElements()) { - if (isPostVisible(currentSone, post)) { - newPosts.add(post); - } - } - if (newPosts.isEmpty()) { - return null; - } - if (newPosts.size() == newPostNotification.getElements().size()) { - return newPostNotification; - } - ListNotification filteredNotification = new ListNotification(newPostNotification); - filteredNotification.setElements(newPosts); - filteredNotification.setLastUpdateTime(newPostNotification.getLastUpdatedTime()); - return filteredNotification; - } - - /** - * Filters the new replies of the given notification. If {@code currentSone} - * is {@code null}, {@code null} is returned and the notification is - * subsequently removed. Otherwise only replies that are replies to posts - * that are posted by friend Sones of the given Sone are retained; all other - * replies are removed. - * - * @param newReplyNotification - * The new-reply notification - * @param currentSone - * The current Sone, or {@code null} if not logged in - * @return The filtered new-reply notification, or {@code null} if the - * notification should be removed - */ - public static ListNotification filterNewReplyNotification(ListNotification newReplyNotification, Sone currentSone) { - if (currentSone == null) { - return null; - } - List newReplies = new ArrayList(); - for (PostReply reply : newReplyNotification.getElements()) { - if (isReplyVisible(currentSone, reply)) { - newReplies.add(reply); - } - } - if (newReplies.isEmpty()) { - return null; - } - if (newReplies.size() == newReplyNotification.getElements().size()) { - return newReplyNotification; - } - ListNotification filteredNotification = new ListNotification(newReplyNotification); - filteredNotification.setElements(newReplies); - filteredNotification.setLastUpdateTime(newReplyNotification.getLastUpdatedTime()); - return filteredNotification; - } - - /** - * Filters the given posts, using {@link #isPostVisible(Sone, Post)} to - * decide whether a post should be contained in the returned list. If - * {@code currentSone} is not {@code null} it is used to filter out posts - * that are from Sones that are not followed or not trusted by the given - * Sone. - * - * @param posts - * The posts to filter - * @param currentSone - * The current Sone (may be {@code null}) - * @return The filtered posts - */ - public static List filterPosts(Collection posts, Sone currentSone) { - List filteredPosts = new ArrayList(); - for (Post post : posts) { - if (isPostVisible(currentSone, post)) { - filteredPosts.add(post); - } - } - return filteredPosts; - } - - /** - * Checks whether a post is visible to the given Sone. A post is not - * considered visible if one of the following statements is true: - *
    - *
  • The post does not have a Sone.
  • - *
  • The post’s {@link Post#getTime() time} is in the future.
  • - *
- *

- * If {@code post} is not {@code null} more checks are performed, and the - * post will be invisible if: - *

- *
    - *
  • The Sone of the post is not the given Sone, the given Sone does not - * follow the post’s Sone, and the given Sone is not the recipient of the - * post.
  • - *
  • The trust relationship between the two Sones can not be retrieved.
  • - *
  • The given Sone has explicitely assigned negative trust to the post’s - * Sone.
  • - *
  • The given Sone has not explicitely assigned negative trust to the - * post’s Sone but the implicit trust is negative.
  • - *
- * If none of these statements is true the post is considered visible. - * - * @param sone - * The Sone that checks for a post’s visibility (may be - * {@code null} to skip Sone-specific checks, such as trust) - * @param post - * The post to check for visibility - * @return {@code true} if the post is considered visible, {@code false} - * otherwise - */ - public static boolean isPostVisible(Sone sone, Post post) { - checkNotNull(post, "post must not be null"); - if (!post.isLoaded()) { - return false; - } - Sone postSone = post.getSone(); - if (sone != null) { - Trust trust = postSone.getIdentity().getTrust((OwnIdentity) sone.getIdentity()); - if (trust != null) { - if ((trust.getExplicit() != null) && (trust.getExplicit() < 0)) { - return false; - } - if ((trust.getExplicit() == null) && (trust.getImplicit() != null) && (trust.getImplicit() < 0)) { - return false; - } - } else { - /* - * a null trust means that the trust updater has not yet - * received a trust value for this relation. if we return false, - * the post feed will stay empty until the trust updater has - * received trust values. to prevent this we simply assume that - * posts are visible if there is no trust. - */ - } - if ((!postSone.equals(sone)) && !sone.hasFriend(postSone.getId()) && !sone.getId().equals(post.getRecipientId().orNull())) { - return false; - } - } - if (post.getTime() > System.currentTimeMillis()) { - return false; - } - return true; - } - - /** - * Checks whether a reply is visible to the given Sone. A reply is not - * considered visible if one of the following statements is true: - *
    - *
  • The reply does not have a post.
  • - *
  • The reply’s post does not have a Sone.
  • - *
  • The Sone of the reply’s post is not the given Sone, the given Sone - * does not follow the reply’s post’s Sone, and the given Sone is not the - * recipient of the reply’s post.
  • - *
  • The trust relationship between the two Sones can not be retrieved.
  • - *
  • The given Sone has explicitely assigned negative trust to the post’s - * Sone.
  • - *
  • The given Sone has not explicitely assigned negative trust to the - * reply’s post’s Sone but the implicit trust is negative.
  • - *
  • The reply’s post’s {@link Post#getTime() time} is in the future.
  • - *
  • The reply’s {@link Reply#getTime() time} is in the future.
  • - *
- * If none of these statements is true the reply is considered visible. - * - * @param sone - * The Sone that checks for a post’s visibility (may be - * {@code null} to skip Sone-specific checks, such as trust) - * @param reply - * The reply to check for visibility - * @return {@code true} if the reply is considered visible, {@code false} - * otherwise - */ - public static boolean isReplyVisible(Sone sone, PostReply reply) { - checkNotNull(reply, "reply must not be null"); - Optional post = reply.getPost(); - if (!post.isPresent()) { - return false; - } - if (!isPostVisible(sone, post.get())) { - return false; - } - if (reply.getTime() > System.currentTimeMillis()) { - return false; - } - return true; - } - -} diff --git a/src/main/java/net/pterodactylus/sone/notify/PostVisibilityFilter.java b/src/main/java/net/pterodactylus/sone/notify/PostVisibilityFilter.java new file mode 100644 index 0000000..3582e3d --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/notify/PostVisibilityFilter.java @@ -0,0 +1,97 @@ +package net.pterodactylus.sone.notify; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.inject.Singleton; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; +import net.pterodactylus.sone.freenet.wot.Trust; +import net.pterodactylus.util.notify.Notification; + +import com.google.common.base.Predicate; + +/** + * Filters {@link Notification}s involving {@link Post}s. + * + * @author David ‘Bombe’ Roden + */ +@Singleton +public class PostVisibilityFilter { + + /** + * Checks whether a post is visible to the given Sone. A post is not + * considered visible if one of the following statements is true: + *
    + *
  • The post does not have a Sone.
  • + *
  • The post’s {@link Post#getTime() time} is in the future.
  • + *
+ *

+ * If {@code post} is not {@code null} more checks are performed, and the + * post will be invisible if: + *

+ *
    + *
  • The Sone of the post is not the given Sone, the given Sone does not + * follow the post’s Sone, and the given Sone is not the recipient of the + * post.
  • + *
  • The trust relationship between the two Sones can not be retrieved.
  • + *
  • The given Sone has explicitely assigned negative trust to the post’s + * Sone.
  • + *
  • The given Sone has not explicitely assigned negative trust to the + * post’s Sone but the implicit trust is negative.
  • + *
+ * If none of these statements is true the post is considered visible. + * + * @param sone + * The Sone that checks for a post’s visibility (may be + * {@code null} to skip Sone-specific checks, such as trust) + * @param post + * The post to check for visibility + * @return {@code true} if the post is considered visible, {@code false} + * otherwise + */ + boolean isPostVisible(@Nullable Sone sone, @Nonnull Post post) { + checkNotNull(post, "post must not be null"); + if (!post.isLoaded()) { + return false; + } + Sone postSone = post.getSone(); + if (sone != null) { + Trust trust = postSone.getIdentity().getTrust((OwnIdentity) sone.getIdentity()); + if (trust != null) { + if ((trust.getExplicit() != null) && (trust.getExplicit() < 0)) { + return false; + } + if ((trust.getExplicit() == null) && (trust.getImplicit() != null) && (trust.getImplicit() < 0)) { + return false; + } + } else { + /* + * a null trust means that the trust updater has not yet + * received a trust value for this relation. if we return false, + * the post feed will stay empty until the trust updater has + * received trust values. to prevent this we simply assume that + * posts are visible if there is no trust. + */ + } + if ((!postSone.equals(sone)) && !sone.hasFriend(postSone.getId()) && !sone.getId().equals(post.getRecipientId().orNull())) { + return false; + } + } + return post.getTime() <= System.currentTimeMillis(); + } + + @Nonnull + public Predicate isVisible(@Nullable final Sone currentSone) { + return new Predicate() { + @Override + public boolean apply(@Nullable Post post) { + return (post != null) && isPostVisible(currentSone, post); + } + }; + } + +} diff --git a/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java b/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java new file mode 100644 index 0000000..fd13779 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/notify/ReplyVisibilityFilter.java @@ -0,0 +1,72 @@ +package net.pterodactylus.sone.notify; + +import static com.google.common.base.Preconditions.checkNotNull; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.inject.Inject; +import javax.inject.Singleton; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; + +import com.google.common.base.Optional; +import com.google.common.base.Predicate; + +/** + * Filter that checks a {@link PostReply} for visibility. + * + * @author David ‘Bombe’ Roden + */ +@Singleton +public class ReplyVisibilityFilter { + + private final PostVisibilityFilter postVisibilityFilter; + + @Inject + public ReplyVisibilityFilter(@Nonnull PostVisibilityFilter postVisibilityFilter) { + this.postVisibilityFilter = postVisibilityFilter; + } + + /** + * Checks whether a reply is visible to the given Sone. A reply is not + * considered visible if one of the following statements is true: + *
    + *
  • The reply does not have a post.
  • + *
  • The reply’s post {@link PostVisibilityFilter#isPostVisible(Sone, Post) is not visible}.
  • + *
  • The reply’s {@link PostReply#getTime() time} is in the future.
  • + *
+ * If none of these statements is true the reply is considered visible. + * + * @param sone + * The Sone that checks for a post’s visibility (may be + * {@code null} to skip Sone-specific checks, such as trust) + * @param reply + * The reply to check for visibility + * @return {@code true} if the reply is considered visible, {@code false} + * otherwise + */ + boolean isReplyVisible(@Nullable Sone sone, @Nonnull PostReply reply) { + checkNotNull(reply, "reply must not be null"); + Optional post = reply.getPost(); + if (!post.isPresent()) { + return false; + } + if (!postVisibilityFilter.isPostVisible(sone, post.get())) { + return false; + } + return reply.getTime() <= System.currentTimeMillis(); + } + + @Nonnull + public Predicate isVisible(@Nullable final Sone currentSone) { + return new Predicate() { + @Override + public boolean apply(@Nullable PostReply postReply) { + return (postReply != null) && isReplyVisible(currentSone, postReply); + } + }; + } + +} diff --git a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java index e19a89a..7d0ab90 100644 --- a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - AlbumAccessor.java - Copyright © 2011–2015 David Roden + * Sone - AlbumAccessor.java - Copyright © 2011–2016 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 @@ -19,8 +19,10 @@ package net.pterodactylus.sone.template; import java.util.ArrayList; import java.util.List; +import java.util.Random; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.Image; import net.pterodactylus.util.template.Accessor; import net.pterodactylus.util.template.ReflectionAccessor; import net.pterodactylus.util.template.TemplateContext; @@ -34,6 +36,8 @@ import net.pterodactylus.util.template.TemplateContext; */ public class AlbumAccessor extends ReflectionAccessor { + private final Random random = new Random(); + /** * {@inheritDoc} */ @@ -49,6 +53,9 @@ public class AlbumAccessor extends ReflectionAccessor { } backlinks.add(0, new Link("imageBrowser.html?sone=" + album.getSone().getId(), SoneAccessor.getNiceName(album.getSone()))); return backlinks; + } else if ("albumImage".equals(member)) { + List images = album.getImages(); + return images.isEmpty() ? null : images.get(random.nextInt(images.size())); } return super.get(templateContext, object, member); } diff --git a/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java b/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java index 5449fa5..0771abd 100644 --- a/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - CollectionAccessor.java - Copyright © 2010–2015 David Roden + * Sone - CollectionAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/CssClassNameFilter.java b/src/main/java/net/pterodactylus/sone/template/CssClassNameFilter.java index 2b1f73c..5776b07 100644 --- a/src/main/java/net/pterodactylus/sone/template/CssClassNameFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/CssClassNameFilter.java @@ -1,5 +1,5 @@ /* - * Sone - CssClassNameFilter.java - Copyright © 2010–2015 David Roden + * Sone - CssClassNameFilter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/GetPagePlugin.java b/src/main/java/net/pterodactylus/sone/template/GetPagePlugin.java index ae53e58..4c8f3d5 100644 --- a/src/main/java/net/pterodactylus/sone/template/GetPagePlugin.java +++ b/src/main/java/net/pterodactylus/sone/template/GetPagePlugin.java @@ -1,5 +1,5 @@ /* - * Sone - GetPagePlugin.java - Copyright © 2010–2015 David Roden + * Sone - GetPagePlugin.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/HttpRequestAccessor.java b/src/main/java/net/pterodactylus/sone/template/HttpRequestAccessor.java index 3383a3b..3e7a261 100644 --- a/src/main/java/net/pterodactylus/sone/template/HttpRequestAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/HttpRequestAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - HttpRequestAccessor.java - Copyright © 2011–2015 David Roden + * Sone - HttpRequestAccessor.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java b/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java index 3a49aed..74c1a77 100644 --- a/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityAccessor.java - Copyright © 2010–2015 David Roden + * Sone - IdentityAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ImageAccessor.java b/src/main/java/net/pterodactylus/sone/template/ImageAccessor.java index 2c27933..903e26c 100644 --- a/src/main/java/net/pterodactylus/sone/template/ImageAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ImageAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - ImageAccessor.java - Copyright © 2011–2015 David Roden + * Sone - ImageAccessor.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java index f560731..2f1526f 100644 --- a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java @@ -1,5 +1,5 @@ /* - * Sone - ImageLinkFilter.java - Copyright © 2011–2015 David Roden + * Sone - ImageLinkFilter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/JavascriptFilter.java b/src/main/java/net/pterodactylus/sone/template/JavascriptFilter.java index 809c53a..595f40e 100644 --- a/src/main/java/net/pterodactylus/sone/template/JavascriptFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/JavascriptFilter.java @@ -1,5 +1,5 @@ /* - * Sone - JavascriptFilter.java - Copyright © 2011–2015 David Roden + * Sone - JavascriptFilter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ParserFilter.java b/src/main/java/net/pterodactylus/sone/template/ParserFilter.java index 109222e..479b3b2 100644 --- a/src/main/java/net/pterodactylus/sone/template/ParserFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ParserFilter.java @@ -1,5 +1,5 @@ /* - * Sone - ParserFilter.java - Copyright © 2011–2015 David Roden + * Sone - ParserFilter.java - Copyright © 2011–2016 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 @@ -20,7 +20,6 @@ package net.pterodactylus.sone.template; import static java.lang.String.valueOf; import static net.pterodactylus.sone.utils.NumberParsers.parseInt; -import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; @@ -101,41 +100,37 @@ public class ParserFilter implements Filter { FreenetRequest request = (FreenetRequest) templateContext.get("request"); SoneTextParserContext context = new SoneTextParserContext(request, (Sone) sone); StringWriter parsedTextWriter = new StringWriter(); - try { - Iterable parts = soneTextParser.parse(context, new StringReader(text)); - if (length > -1) { - int allPartsLength = 0; - List shortenedParts = new ArrayList(); - for (Part part : parts) { - if (part instanceof PlainTextPart) { - String longText = ((PlainTextPart) part).getText(); - if (allPartsLength < cutOffLength) { - if ((allPartsLength + longText.length()) > cutOffLength) { - shortenedParts.add(new PlainTextPart(longText.substring(0, cutOffLength - allPartsLength) + "…")); - } else { - shortenedParts.add(part); - } - } - allPartsLength += longText.length(); - } else if (part instanceof LinkPart) { - if (allPartsLength < cutOffLength) { - shortenedParts.add(part); - } - allPartsLength += ((LinkPart) part).getText().length(); - } else { - if (allPartsLength < cutOffLength) { + Iterable parts = soneTextParser.parse(text, context); + if (length > -1) { + int allPartsLength = 0; + List shortenedParts = new ArrayList(); + for (Part part : parts) { + if (part instanceof PlainTextPart) { + String longText = part.getText(); + if (allPartsLength < cutOffLength) { + if ((allPartsLength + longText.length()) > cutOffLength) { + shortenedParts.add(new PlainTextPart(longText.substring(0, cutOffLength - allPartsLength) + "…")); + } else { shortenedParts.add(part); } } + allPartsLength += longText.length(); + } else if (part instanceof LinkPart) { + if (allPartsLength < cutOffLength) { + shortenedParts.add(part); + } + allPartsLength += part.getText().length(); + } else { + if (allPartsLength < cutOffLength) { + shortenedParts.add(part); + } } - if (allPartsLength >= length) { - parts = shortenedParts; - } } - render(parsedTextWriter, parts); - } catch (IOException ioe1) { - /* no exceptions in a StringReader or StringWriter, ignore. */ + if (allPartsLength >= length) { + parts = shortenedParts; + } } + render(parsedTextWriter, parts); return parsedTextWriter.toString(); } @@ -252,26 +247,22 @@ public class ParserFilter implements Filter { private void render(Writer writer, PostPart postPart) { SoneTextParser parser = new SoneTextParser(core, core); SoneTextParserContext parserContext = new SoneTextParserContext(null, postPart.getPost().getSone()); - try { - Iterable parts = parser.parse(parserContext, new StringReader(postPart.getPost().getText())); - StringBuilder excerpt = new StringBuilder(); - for (Part part : parts) { - excerpt.append(part.getText()); - if (excerpt.length() > 20) { - int lastSpace = excerpt.lastIndexOf(" ", 20); - if (lastSpace > -1) { - excerpt.setLength(lastSpace); - } else { - excerpt.setLength(20); - } - excerpt.append("…"); - break; + Iterable parts = parser.parse(postPart.getPost().getText(), parserContext); + StringBuilder excerpt = new StringBuilder(); + for (Part part : parts) { + excerpt.append(part.getText()); + if (excerpt.length() > 20) { + int lastSpace = excerpt.lastIndexOf(" ", 20); + if (lastSpace > -1) { + excerpt.setLength(lastSpace); + } else { + excerpt.setLength(20); } + excerpt.append("…"); + break; } - renderLink(writer, "viewPost.html?post=" + postPart.getPost().getId(), excerpt.toString(), SoneAccessor.getNiceName(postPart.getPost().getSone()), "in-sone"); - } catch (IOException ioe1) { - /* StringReader shouldn’t throw. */ } + renderLink(writer, "viewPost.html?post=" + postPart.getPost().getId(), excerpt.toString(), SoneAccessor.getNiceName(postPart.getPost().getSone()), "in-sone"); } /** diff --git a/src/main/java/net/pterodactylus/sone/template/PostAccessor.java b/src/main/java/net/pterodactylus/sone/template/PostAccessor.java index f04ea83..11cafea 100644 --- a/src/main/java/net/pterodactylus/sone/template/PostAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/PostAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - PostAccessor.java - Copyright © 2010–2015 David Roden + * Sone - PostAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java index 93bfc59..980d960 100644 --- a/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ProfileAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - ProfileAccessor.java - Copyright © 2011–2015 David Roden + * Sone - ProfileAccessor.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java b/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java index dc5ded0..a3253b0 100644 --- a/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - ReplyAccessor.java - Copyright © 2010–2015 David Roden + * Sone - ReplyAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java b/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java index 709ffbc..9bb5b81 100644 --- a/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ReplyGroupFilter.java @@ -1,5 +1,5 @@ /* - * Sone - ReplyGroupFilter.java - Copyright © 2010–2015 David Roden + * Sone - ReplyGroupFilter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java index 211c4b4..2d6167a 100644 --- a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java @@ -1,5 +1,5 @@ /* - * Sone - RequestChangeFilter.java - Copyright © 2010–2015 David Roden + * Sone - RequestChangeFilter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java index 4bb78af..50fa272 100644 --- a/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/SoneAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - SoneAccessor.java - Copyright © 2010–2015 David Roden + * Sone - SoneAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/SubstringFilter.java b/src/main/java/net/pterodactylus/sone/template/SubstringFilter.java index 101cbb0..2104888 100644 --- a/src/main/java/net/pterodactylus/sone/template/SubstringFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/SubstringFilter.java @@ -1,5 +1,5 @@ /* - * Sone - SubstringFilter.java - Copyright © 2010–2015 David Roden + * Sone - SubstringFilter.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/TrustAccessor.java b/src/main/java/net/pterodactylus/sone/template/TrustAccessor.java index f3dd827..fee047d 100644 --- a/src/main/java/net/pterodactylus/sone/template/TrustAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/TrustAccessor.java @@ -1,5 +1,5 @@ /* - * Sone - TrustAccessor.java - Copyright © 2010–2015 David Roden + * Sone - TrustAccessor.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java b/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java index 005094e..2ca695b 100644 --- a/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java @@ -1,5 +1,5 @@ /* - * Sone - UniqueElementFilter.java - Copyright © 2011–2015 David Roden + * Sone - UniqueElementFilter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java b/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java index 7981d55..2c5a004 100644 --- a/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/UnknownDateFilter.java @@ -1,5 +1,5 @@ /* - * Sone - UnknownDateFilter.java - Copyright © 2011–2015 David Roden + * Sone - UnknownDateFilter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/FreenetLinkPart.java b/src/main/java/net/pterodactylus/sone/text/FreenetLinkPart.java index b8fd240..829bf0f 100644 --- a/src/main/java/net/pterodactylus/sone/text/FreenetLinkPart.java +++ b/src/main/java/net/pterodactylus/sone/text/FreenetLinkPart.java @@ -1,5 +1,5 @@ /* - * Sone - FreenetLinkPart.java - Copyright © 2011–2015 David Roden + * Sone - FreenetLinkPart.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/LinkPart.java b/src/main/java/net/pterodactylus/sone/text/LinkPart.java index 2e7d331..6764328 100644 --- a/src/main/java/net/pterodactylus/sone/text/LinkPart.java +++ b/src/main/java/net/pterodactylus/sone/text/LinkPart.java @@ -1,5 +1,5 @@ /* - * Sone - LinkPart.java - Copyright © 2011–2015 David Roden + * Sone - LinkPart.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/Parser.java b/src/main/java/net/pterodactylus/sone/text/Parser.java index f5f8f1b..f87b852 100644 --- a/src/main/java/net/pterodactylus/sone/text/Parser.java +++ b/src/main/java/net/pterodactylus/sone/text/Parser.java @@ -1,5 +1,5 @@ /* - * Sone - Parser.java - Copyright © 2010–2015 David Roden + * Sone - Parser.java - Copyright © 2010–2016 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 @@ -17,8 +17,9 @@ package net.pterodactylus.sone.text; -import java.io.IOException; import java.io.Reader; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Interface for parsers that can create {@link Part}s from a text source @@ -33,14 +34,13 @@ public interface Parser { /** * Create one or more {@link Part}s from the given text source. * - * @param context - * The parser context (may be {@code null}) * @param source * The text source + * @param context + * The parser context (may be {@code null}) * @return The parsed parts - * @throws IOException - * if an I/O error occurs */ - public Iterable parse(C context, Reader source) throws IOException; + @Nonnull + Iterable parse(@Nonnull String source, @Nullable C context); } diff --git a/src/main/java/net/pterodactylus/sone/text/ParserContext.java b/src/main/java/net/pterodactylus/sone/text/ParserContext.java index 9782008..7387967 100644 --- a/src/main/java/net/pterodactylus/sone/text/ParserContext.java +++ b/src/main/java/net/pterodactylus/sone/text/ParserContext.java @@ -1,5 +1,5 @@ /* - * Sone - ParserContext.java - Copyright © 2010–2015 David Roden + * Sone - ParserContext.java - Copyright © 2010–2016 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 @@ -20,7 +20,7 @@ package net.pterodactylus.sone.text; /** * Context for the {@link Parser}. This interface needs to be implemented by * {@link Parser}s that need to provide more information than just the text to - * parse to {@link Parser#parse(ParserContext, java.io.Reader)}. + * parse to {@link Parser#parse(String, ParserContext)}. * * @author David ‘Bombe’ Roden */ diff --git a/src/main/java/net/pterodactylus/sone/text/Part.java b/src/main/java/net/pterodactylus/sone/text/Part.java index 8dee69b..e516f0a 100644 --- a/src/main/java/net/pterodactylus/sone/text/Part.java +++ b/src/main/java/net/pterodactylus/sone/text/Part.java @@ -1,5 +1,5 @@ /* - * Sone - Part.java - Copyright © 2010–2015 David Roden + * Sone - Part.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/PartContainer.java b/src/main/java/net/pterodactylus/sone/text/PartContainer.java index 75714f7..d1c89b3 100644 --- a/src/main/java/net/pterodactylus/sone/text/PartContainer.java +++ b/src/main/java/net/pterodactylus/sone/text/PartContainer.java @@ -1,5 +1,5 @@ /* - * Sone - PartContainer.java - Copyright © 2010–2015 David Roden + * Sone - PartContainer.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java b/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java index 9090eb3..4f15a73 100644 --- a/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java +++ b/src/main/java/net/pterodactylus/sone/text/PlainTextPart.java @@ -1,5 +1,5 @@ /* - * Sone - PlainTextPart.java - Copyright © 2011–2015 David Roden + * Sone - PlainTextPart.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/PostPart.java b/src/main/java/net/pterodactylus/sone/text/PostPart.java index 6aae37c..68075a5 100644 --- a/src/main/java/net/pterodactylus/sone/text/PostPart.java +++ b/src/main/java/net/pterodactylus/sone/text/PostPart.java @@ -1,5 +1,5 @@ /* - * Sone - PostPart.java - Copyright © 2011–2015 David Roden + * Sone - PostPart.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/SonePart.java b/src/main/java/net/pterodactylus/sone/text/SonePart.java index 3d3e666..cbafc61 100644 --- a/src/main/java/net/pterodactylus/sone/text/SonePart.java +++ b/src/main/java/net/pterodactylus/sone/text/SonePart.java @@ -1,5 +1,5 @@ /* - * Sone - SonePart.java - Copyright © 2011–2015 David Roden + * Sone - SonePart.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index f338286..fb4e7cd 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTextParser.java - Copyright © 2010–2015 David Roden + * Sone - SoneTextParser.java - Copyright © 2010–2016 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 @@ -21,13 +21,16 @@ import static java.util.logging.Logger.getLogger; import java.io.BufferedReader; import java.io.IOException; -import java.io.Reader; +import java.io.StringReader; import java.net.MalformedURLException; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.impl.IdOnlySone; @@ -117,10 +120,11 @@ public class SoneTextParser implements Parser { /** * {@inheritDoc} */ + @Nonnull @Override - public Iterable parse(SoneTextParserContext context, Reader source) throws IOException { + public Iterable parse(@Nonnull String source, @Nullable SoneTextParserContext context) { PartContainer parts = new PartContainer(); - BufferedReader bufferedReader = (source instanceof BufferedReader) ? (BufferedReader) source : new BufferedReader(source); + BufferedReader bufferedReader = new BufferedReader(new StringReader(source)); try { String line; boolean lastLineEmpty = true; @@ -271,10 +275,11 @@ public class SoneTextParser implements Parser { } lastLineEmpty = false; } + } catch (IOException ioe1) { + // a buffered reader around a string reader should never throw. + throw new RuntimeException(ioe1); } finally { - if (bufferedReader != source) { - Closer.close(bufferedReader); - } + Closer.close(bufferedReader); } for (int partIndex = parts.size() - 1; partIndex >= 0; --partIndex) { Part part = parts.getPart(partIndex); diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParserContext.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParserContext.java index 3e7dc3f..8918e40 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParserContext.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParserContext.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTextParserContext.java - Copyright © 2011–2015 David Roden + * Sone - SoneTextParserContext.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/text/TextFilter.java b/src/main/java/net/pterodactylus/sone/text/TextFilter.java index 5782a23..fa57f9c 100644 --- a/src/main/java/net/pterodactylus/sone/text/TextFilter.java +++ b/src/main/java/net/pterodactylus/sone/text/TextFilter.java @@ -1,5 +1,5 @@ /* - * Sone - TextFilter.java - Copyright © 2011–2015 David Roden + * Sone - TextFilter.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/utils/IntegerRangePredicate.java b/src/main/java/net/pterodactylus/sone/utils/IntegerRangePredicate.java index a0470c1..aac9594 100644 --- a/src/main/java/net/pterodactylus/sone/utils/IntegerRangePredicate.java +++ b/src/main/java/net/pterodactylus/sone/utils/IntegerRangePredicate.java @@ -1,5 +1,5 @@ /* - * Sone - IntegerRangePredicate.java - Copyright © 2013–2015 David Roden + * Sone - IntegerRangePredicate.java - Copyright © 2013–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/AboutPage.java b/src/main/java/net/pterodactylus/sone/web/AboutPage.java index 581df3e..76a475f 100644 --- a/src/main/java/net/pterodactylus/sone/web/AboutPage.java +++ b/src/main/java/net/pterodactylus/sone/web/AboutPage.java @@ -1,5 +1,5 @@ /* - * Sone - AboutPage.java - Copyright © 2010–2015 David Roden + * Sone - AboutPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java b/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java index afb6a29..be5fc67 100644 --- a/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java +++ b/src/main/java/net/pterodactylus/sone/web/BookmarkPage.java @@ -1,5 +1,5 @@ /* - * Sone - BookmarkPage.java - Copyright © 2011–2015 David Roden + * Sone - BookmarkPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java b/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java index a86e044..404abb1 100644 --- a/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java +++ b/src/main/java/net/pterodactylus/sone/web/BookmarksPage.java @@ -1,5 +1,5 @@ /* - * Sone - BookmarksPage.java - Copyright © 2011–2015 David Roden + * Sone - BookmarksPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java index 539fa6b..6ba14f0 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java @@ -1,5 +1,5 @@ /* - * Sone - CreateAlbumPage.java - Copyright © 2011–2015 David Roden + * Sone - CreateAlbumPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java index 46631ce..f486379 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreatePostPage.java @@ -1,5 +1,5 @@ /* - * Sone - CreatePostPage.java - Copyright © 2010–2015 David Roden + * Sone - CreatePostPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index 5098f2d..2383218 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java @@ -1,5 +1,5 @@ /* - * Sone - CreateReplyPage.java - Copyright © 2010–2015 David Roden + * Sone - CreateReplyPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java index 5ea2c1a..7ea74fe 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - CreateSonePage.java - Copyright © 2010–2015 David Roden + * Sone - CreateSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java index b3a7a06..7d2fa59 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteAlbumPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteAlbumPage.java - Copyright © 2011–2015 David Roden + * Sone - DeleteAlbumPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java b/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java index 6934beb..eeb9e3c 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteImagePage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteImagePage.java - Copyright © 2011–2015 David Roden + * Sone - DeleteImagePage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java index 03a6933..517a07e 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeletePostPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeletePostPage.java - Copyright © 2010–2015 David Roden + * Sone - DeletePostPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java index 0184a2c..f036489 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteProfileFieldPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteProfileFieldPage.java - Copyright © 2011–2015 David Roden + * Sone - DeleteProfileFieldPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java index 37b9fea..0cd6b4f 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteReplyPage.java - Copyright © 2010–2015 David Roden + * Sone - DeleteReplyPage.java - Copyright © 2010–2016 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 @@ -58,7 +58,7 @@ public class DeleteReplyPage extends SoneTemplatePage { Optional reply = webInterface.getCore().getPostReply(replyId); String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); if (request.getMethod() == Method.POST) { - if (!reply.get().getSone().isLocal()) { + if (!reply.isPresent() || !reply.get().getSone().isLocal()) { throw new RedirectException("noPermission.html"); } if (request.getHttpRequest().isPartSet("confirmDelete")) { diff --git a/src/main/java/net/pterodactylus/sone/web/DeleteSonePage.java b/src/main/java/net/pterodactylus/sone/web/DeleteSonePage.java index 90cc6cc..ce01771 100644 --- a/src/main/java/net/pterodactylus/sone/web/DeleteSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/DeleteSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteSonePage.java - Copyright © 2010–2015 David Roden + * Sone - DeleteSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/DismissNotificationPage.java b/src/main/java/net/pterodactylus/sone/web/DismissNotificationPage.java index d5bb6ea..80da869 100644 --- a/src/main/java/net/pterodactylus/sone/web/DismissNotificationPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DismissNotificationPage.java @@ -1,5 +1,5 @@ /* - * Sone - DismissNotificationPage.java - Copyright © 2010–2015 David Roden + * Sone - DismissNotificationPage.java - Copyright © 2010–2016 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 @@ -22,6 +22,8 @@ import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; +import com.google.common.base.Optional; + /** * Page that lets the user dismiss a notification. * @@ -52,9 +54,9 @@ public class DismissNotificationPage extends SoneTemplatePage { protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { super.processTemplate(request, templateContext); String notificationId = request.getHttpRequest().getPartAsStringFailsafe("notification", 36); - Notification notification = webInterface.getNotifications().getNotification(notificationId); - if ((notification != null) && notification.isDismissable()) { - notification.dismiss(); + Optional notification = webInterface.getNotification(notificationId); + if (notification.isPresent() && notification.get().isDismissable()) { + notification.get().dismiss(); } String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256); throw new RedirectException(returnPage); diff --git a/src/main/java/net/pterodactylus/sone/web/DistrustPage.java b/src/main/java/net/pterodactylus/sone/web/DistrustPage.java index 14411f9..c09608a 100644 --- a/src/main/java/net/pterodactylus/sone/web/DistrustPage.java +++ b/src/main/java/net/pterodactylus/sone/web/DistrustPage.java @@ -1,5 +1,5 @@ /* - * Sone - DistrustPage.java - Copyright © 2011–2015 David Roden + * Sone - DistrustPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java index 5244bc5..6a08c3c 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditAlbumPage.java - Copyright © 2011–2015 David Roden + * Sone - EditAlbumPage.java - Copyright © 2011–2016 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 @@ -68,11 +68,6 @@ public class EditAlbumPage extends SoneTemplatePage { webInterface.getCore().touchConfiguration(); throw new RedirectException("imageBrowser.html?album=" + album.getParent().getId()); } - String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36); - if (webInterface.getCore().getImage(albumImageId, false) == null) { - albumImageId = null; - } - album.modify().setAlbumImage(albumImageId).update(); String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim(); String description = request.getHttpRequest().getPartAsStringFailsafe("description", 1000).trim(); try { diff --git a/src/main/java/net/pterodactylus/sone/web/EditImagePage.java b/src/main/java/net/pterodactylus/sone/web/EditImagePage.java index 9ae7ed6..b169161 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditImagePage.java @@ -1,5 +1,5 @@ /* - * Sone - EditImagePage.java - Copyright © 2010–2015 David Roden + * Sone - EditImagePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java b/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java index 8f5e4ba..8cf18f2 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditProfileFieldPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditProfileFieldPage.java - Copyright © 2011–2015 David Roden + * Sone - EditProfileFieldPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java index 5145358..bf76c26 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditProfilePage.java @@ -1,5 +1,5 @@ /* - * Sone - EditProfilePage.java - Copyright © 2010–2015 David Roden + * Sone - EditProfilePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java index a83c46a..eef94df 100644 --- a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - FollowSonePage.java - Copyright © 2010–2015 David Roden + * Sone - FollowSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/GetImagePage.java b/src/main/java/net/pterodactylus/sone/web/GetImagePage.java index 87e4fa2..ec38d0a 100644 --- a/src/main/java/net/pterodactylus/sone/web/GetImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/GetImagePage.java @@ -1,5 +1,5 @@ /* - * Sone - GetImagePage.java - Copyright © 2011–2015 David Roden + * Sone - GetImagePage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java index 442cdc0..5da6e53 100644 --- a/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ImageBrowserPage.java @@ -1,5 +1,5 @@ /* - * Sone - ImageBrowserPage.java - Copyright © 2011–2015 David Roden + * Sone - ImageBrowserPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/IndexPage.java b/src/main/java/net/pterodactylus/sone/web/IndexPage.java index c5e80c4..e5d5b7d 100644 --- a/src/main/java/net/pterodactylus/sone/web/IndexPage.java +++ b/src/main/java/net/pterodactylus/sone/web/IndexPage.java @@ -1,5 +1,5 @@ /* - * Sone - IndexPage.java - Copyright © 2010–2015 David Roden + * Sone - IndexPage.java - Copyright © 2010–2016 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 @@ -26,14 +26,13 @@ import java.util.List; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.notify.ListNotificationFilters; +import net.pterodactylus.sone.notify.PostVisibilityFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.collection.Pagination; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import com.google.common.base.Optional; -import com.google.common.base.Predicate; import com.google.common.collect.Collections2; /** @@ -44,14 +43,11 @@ import com.google.common.collect.Collections2; */ public class IndexPage extends SoneTemplatePage { - /** - * @param template - * The template to render - * @param webInterface - * The Sone web interface - */ - public IndexPage(Template template, WebInterface webInterface) { + private final PostVisibilityFilter postVisibilityFilter; + + public IndexPage(Template template, WebInterface webInterface, PostVisibilityFilter postVisibilityFilter) { super("index.html", template, "Page.Index.Title", webInterface, true); + this.postVisibilityFilter = postVisibilityFilter; } // @@ -81,14 +77,7 @@ public class IndexPage extends SoneTemplatePage { } } } - allPosts = Collections2.filter(allPosts, new Predicate() { - - @Override - public boolean apply(Post post) { - return ListNotificationFilters.isPostVisible(currentSone, post); - } - }); - allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER); + allPosts = Collections2.filter(allPosts, postVisibilityFilter.isVisible(currentSone)); List sortedPosts = new ArrayList(allPosts); Collections.sort(sortedPosts, Post.TIME_COMPARATOR); Pagination pagination = new Pagination(sortedPosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(parseInt(request.getHttpRequest().getParam("page"), 0)); diff --git a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java index edb9980..d5fb9e2 100644 --- a/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java +++ b/src/main/java/net/pterodactylus/sone/web/KnownSonesPage.java @@ -1,5 +1,5 @@ /* - * Sone - KnownSonesPage.java - Copyright © 2010–2015 David Roden + * Sone - KnownSonesPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/LikePage.java b/src/main/java/net/pterodactylus/sone/web/LikePage.java index 43d46a6..171a7be 100644 --- a/src/main/java/net/pterodactylus/sone/web/LikePage.java +++ b/src/main/java/net/pterodactylus/sone/web/LikePage.java @@ -1,5 +1,5 @@ /* - * Sone - LikePage.java - Copyright © 2010–2015 David Roden + * Sone - LikePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/LockSonePage.java b/src/main/java/net/pterodactylus/sone/web/LockSonePage.java index dc35b70..7881e9e 100644 --- a/src/main/java/net/pterodactylus/sone/web/LockSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/LockSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - LockSonePage.java - Copyright © 2010–2015 David Roden + * Sone - LockSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/LoginPage.java b/src/main/java/net/pterodactylus/sone/web/LoginPage.java index 4b38a07..608f120 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -1,5 +1,5 @@ /* - * Sone - LoginPage.java - Copyright © 2010–2015 David Roden + * Sone - LoginPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java index aa8f401..d47044c 100644 --- a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java @@ -1,5 +1,5 @@ /* - * Sone - LogoutPage.java - Copyright © 2010–2015 David Roden + * Sone - LogoutPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java index 215ce93..39c5a43 100644 --- a/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java +++ b/src/main/java/net/pterodactylus/sone/web/MarkAsKnownPage.java @@ -1,5 +1,5 @@ /* - * Sone - MarkAsKnownPage.java - Copyright © 2011–2015 David Roden + * Sone - MarkAsKnownPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/NewPage.java b/src/main/java/net/pterodactylus/sone/web/NewPage.java index 1757952..2b99adb 100644 --- a/src/main/java/net/pterodactylus/sone/web/NewPage.java +++ b/src/main/java/net/pterodactylus/sone/web/NewPage.java @@ -1,5 +1,5 @@ /* - * Sone - NewPage.java - Copyright © 2013–2015 David Roden + * Sone - NewPage.java - Copyright © 2013–2016 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 @@ -25,11 +25,10 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import com.google.common.collect.Collections2; - import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; -import net.pterodactylus.sone.notify.ListNotificationFilters; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.notify.PostVisibilityFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.collection.Pagination; import net.pterodactylus.util.template.Template; @@ -37,8 +36,7 @@ import net.pterodactylus.util.template.TemplateContext; /** * Page that displays all new posts and replies. The posts are filtered using - * {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)} - * and sorted by time. + * {@link PostVisibilityFilter#isPostVisible(Sone, Post)} and sorted by time. * * @author David ‘Bombe’ Roden */ @@ -68,13 +66,13 @@ public class NewPage extends SoneTemplatePage { super.processTemplate(request, templateContext); /* collect new elements from notifications. */ - Set posts = new HashSet(webInterface.getNewPosts()); - for (PostReply reply : Collections2.filter(webInterface.getNewReplies(), PostReply.HAS_POST_FILTER)) { + Set posts = new HashSet(webInterface.getNewPosts(getCurrentSone(request.getToadletContext(), false))); + for (PostReply reply : webInterface.getNewReplies(getCurrentSone(request.getToadletContext(), false))) { posts.add(reply.getPost().get()); } /* filter and sort them. */ - List sortedPosts = ListNotificationFilters.filterPosts(new ArrayList(posts), webInterface.getCurrentSone(request.getToadletContext(), false)); + List sortedPosts = new ArrayList(posts); Collections.sort(sortedPosts, Post.TIME_COMPARATOR); /* paginate them. */ diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index dff7ecf..0bc44d5 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -1,5 +1,5 @@ /* - * Sone - OptionsPage.java - Copyright © 2010–2015 David Roden + * Sone - OptionsPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ReloadingPage.java b/src/main/java/net/pterodactylus/sone/web/ReloadingPage.java index 0c8f516..f89bbed 100644 --- a/src/main/java/net/pterodactylus/sone/web/ReloadingPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ReloadingPage.java @@ -1,5 +1,5 @@ /* - * Sone - ReloadingPage.java - Copyright © 2010–2015 David Roden + * Sone - ReloadingPage.java - Copyright © 2010–2016 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 @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -72,8 +73,10 @@ public class ReloadingPage implements Page { String path = request.getUri().getPath(); int lastSlash = path.lastIndexOf('/'); String filename = path.substring(lastSlash + 1); - InputStream fileInputStream = new FileInputStream(new File(filesystemPath, filename)); - if (fileInputStream == null) { + InputStream fileInputStream; + try { + fileInputStream = new FileInputStream(new File(filesystemPath, filename)); + } catch (FileNotFoundException fnfe1) { return response.setStatusCode(404).setStatusText("Not found."); } OutputStream contentOutputStream = response.getContent(); diff --git a/src/main/java/net/pterodactylus/sone/web/RescuePage.java b/src/main/java/net/pterodactylus/sone/web/RescuePage.java index 8599a31..2383e0d 100644 --- a/src/main/java/net/pterodactylus/sone/web/RescuePage.java +++ b/src/main/java/net/pterodactylus/sone/web/RescuePage.java @@ -1,5 +1,5 @@ /* - * Sone - RescuePage.java - Copyright © 2011–2015 David Roden + * Sone - RescuePage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 7ec7f9f..5b657d5 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -1,5 +1,5 @@ /* - * Sone - SearchPage.java - Copyright © 2010–2015 David Roden + * Sone - SearchPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 15810ca..b3e7a6a 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTemplatePage.java - Copyright © 2010–2015 David Roden + * Sone - SoneTemplatePage.java - Copyright © 2010–2016 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 @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -27,20 +28,19 @@ import java.util.Map; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.main.SonePlugin; -import net.pterodactylus.sone.notify.ListNotificationFilters; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.sone.web.page.FreenetTemplatePage; import net.pterodactylus.util.notify.Notification; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import freenet.clients.http.SessionManager.Session; import freenet.clients.http.ToadletContext; import freenet.support.api.HTTPRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + /** * Base page for the Sone web interface. * @@ -65,21 +65,6 @@ public class SoneTemplatePage extends FreenetTemplatePage { * The path of the page * @param template * The template to render - * @param webInterface - * The Sone web interface - */ - public SoneTemplatePage(String path, Template template, WebInterface webInterface) { - this(path, template, null, webInterface, false); - } - - /** - * Creates a new template page for Sone that does not require the user to be - * logged in. - * - * @param path - * The path of the page - * @param template - * The template to render * @param pageTitleKey * The l10n key of the page title * @param webInterface @@ -263,7 +248,7 @@ public class SoneTemplatePage extends FreenetTemplatePage { templateContext.set("latestEdition", webInterface.getCore().getUpdateChecker().getLatestEdition()); templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion()); templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate()); - List notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone); + List notifications = new ArrayList(webInterface.getNotifications(currentSone)); Collections.sort(notifications, Notification.CREATED_TIME_SORTER); templateContext.set("notifications", notifications); templateContext.set("notificationHash", notifications.hashCode()); diff --git a/src/main/java/net/pterodactylus/sone/web/TrustPage.java b/src/main/java/net/pterodactylus/sone/web/TrustPage.java index cf67052..637bb26 100644 --- a/src/main/java/net/pterodactylus/sone/web/TrustPage.java +++ b/src/main/java/net/pterodactylus/sone/web/TrustPage.java @@ -1,5 +1,5 @@ /* - * Sone - TrustPage.java - Copyright © 2011–2015 David Roden + * Sone - TrustPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java index 80b3ce6..51da550 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnbookmarkPage.java - Copyright © 2011–2015 David Roden + * Sone - UnbookmarkPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java b/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java index 1ec2d6f..d8ff899 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnfollowSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - UnfollowSonePage.java - Copyright © 2010–2015 David Roden + * Sone - UnfollowSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UnlikePage.java b/src/main/java/net/pterodactylus/sone/web/UnlikePage.java index 057f7b3..ade8b89 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnlikePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnlikePage.java @@ -1,5 +1,5 @@ /* - * Sone - UnlikePage.java - Copyright © 2010–2015 David Roden + * Sone - UnlikePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java b/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java index 0d4432f..f641361 100644 --- a/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UnlockSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - UnlockSonePage.java - Copyright © 2010–2015 David Roden + * Sone - UnlockSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UntrustPage.java b/src/main/java/net/pterodactylus/sone/web/UntrustPage.java index a5b314f..9d51276 100644 --- a/src/main/java/net/pterodactylus/sone/web/UntrustPage.java +++ b/src/main/java/net/pterodactylus/sone/web/UntrustPage.java @@ -1,5 +1,5 @@ /* - * Sone - UntrustPage.java - Copyright © 2011–2015 David Roden + * Sone - UntrustPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java index 7621a6d..21c4272 100644 --- a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java @@ -1,5 +1,5 @@ /* - * Sone - UploadImagePage.java - Copyright © 2011–2015 David Roden + * Sone - UploadImagePage.java - Copyright © 2011–2016 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 @@ -91,7 +91,10 @@ public class UploadImagePage extends SoneTemplatePage { if (!currentSone.equals(parent.getSone())) { throw new RedirectException("noPermission.html"); } - String name = request.getHttpRequest().getPartAsStringFailsafe("title", 200); + String name = request.getHttpRequest().getPartAsStringFailsafe("title", 200).trim(); + if (name.length() == 0) { + throw new RedirectException("emptyImageTitle.html"); + } String description = request.getHttpRequest().getPartAsStringFailsafe("description", 4000); HTTPUploadedFile uploadedFile = request.getHttpRequest().getUploadedFile("image"); Bucket fileBucket = uploadedFile.getData(); diff --git a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java index 9ab6612..dca59e2 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewPostPage.java @@ -1,5 +1,5 @@ /* - * Sone - ViewPostPage.java - Copyright © 2010–2015 David Roden + * Sone - ViewPostPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java index 9b346c3..fe1e7db 100644 --- a/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/ViewSonePage.java @@ -1,5 +1,5 @@ /* - * Sone - ViewSonePage.java - Copyright © 2010–2015 David Roden + * Sone - ViewSonePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 4da2177..271111e 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -1,5 +1,5 @@ /* - * Sone - WebInterface.java - Copyright © 2010–2015 David Roden + * Sone - WebInterface.java - Copyright © 2010–2016 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 @@ -17,10 +17,10 @@ package net.pterodactylus.sone.web; +import static com.google.common.collect.FluentIterable.from; import static java.util.logging.Logger.getLogger; import static net.pterodactylus.util.template.TemplateParser.parse; -import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; @@ -35,8 +35,9 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; -import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent; @@ -72,6 +73,9 @@ import net.pterodactylus.sone.main.Loaders; import net.pterodactylus.sone.main.ReparseFilter; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.notify.ListNotification; +import net.pterodactylus.sone.notify.ListNotificationFilter; +import net.pterodactylus.sone.notify.PostVisibilityFilter; +import net.pterodactylus.sone.notify.ReplyVisibilityFilter; import net.pterodactylus.sone.template.AlbumAccessor; import net.pterodactylus.sone.template.CollectionAccessor; import net.pterodactylus.sone.template.CssClassNameFilter; @@ -147,11 +151,6 @@ import net.pterodactylus.util.template.XmlFilter; import net.pterodactylus.util.web.RedirectPage; import net.pterodactylus.util.web.TemplatePage; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableSet; -import com.google.common.eventbus.Subscribe; -import com.google.inject.Inject; - import freenet.clients.http.SessionManager; import freenet.clients.http.SessionManager.Session; import freenet.clients.http.ToadletContainer; @@ -159,6 +158,12 @@ import freenet.clients.http.ToadletContext; import freenet.l10n.BaseL10n; import freenet.support.api.HTTPRequest; +import com.google.common.base.Optional; +import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableSet; +import com.google.common.eventbus.Subscribe; +import com.google.inject.Inject; + /** * Bundles functionality that a web interface of a Freenet plugin needs, e.g. * references to l10n helpers. @@ -194,6 +199,10 @@ public class WebInterface { /** The parser filter. */ private final ParserFilter parserFilter; + private final ListNotificationFilter listNotificationFilter; + private final PostVisibilityFilter postVisibilityFilter; + private final ReplyVisibilityFilter replyVisibilityFilter; + /** The “new Sone” notification. */ private final ListNotification newSoneNotification; @@ -243,9 +252,12 @@ public class WebInterface { * The Sone plugin */ @Inject - public WebInterface(SonePlugin sonePlugin, Loaders loaders) { + public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) { this.sonePlugin = sonePlugin; this.loaders = loaders; + this.listNotificationFilter = listNotificationFilter; + this.postVisibilityFilter = postVisibilityFilter; + this.replyVisibilityFilter = replyVisibilityFilter; formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword(); soneTextParser = new SoneTextParser(getCore(), getCore()); @@ -454,6 +466,16 @@ public class WebInterface { return notificationManager; } + @Nonnull + public Optional getNotification(@Nonnull String notificationId) { + return Optional.fromNullable(notificationManager.getNotification(notificationId)); + } + + @Nonnull + public Collection getNotifications(@Nullable Sone currentSone) { + return listNotificationFilter.filterNotifications(notificationManager.getNotifications(), currentSone); + } + /** * Returns the l10n helper of the node. * @@ -491,6 +513,15 @@ public class WebInterface { return ImmutableSet. builder().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).build(); } + @Nonnull + public Collection getNewPosts(@Nullable Sone currentSone) { + Set allNewPosts = ImmutableSet. builder() + .addAll(newPostNotification.getElements()) + .addAll(localPostNotification.getElements()) + .build(); + return from(allNewPosts).filter(postVisibilityFilter.isVisible(currentSone)).toSet(); + } + /** * Returns the replies that have been announced as new in the * {@link #newReplyNotification}. @@ -501,6 +532,15 @@ public class WebInterface { return ImmutableSet. builder().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).build(); } + @Nonnull + public Collection getNewReplies(@Nullable Sone currentSone) { + Set allNewReplies = ImmutableSet.builder() + .addAll(newReplyNotification.getElements()) + .addAll(localReplyNotification.getElements()) + .build(); + return from(allNewReplies).filter(replyVisibilityFilter.isVisible(currentSone)).toSet(); + } + /** * Sets whether the current start of the plugin is the first start. It is * considered a first start if the configuration file does not exist. @@ -638,7 +678,7 @@ public class WebInterface { PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/"); pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage("", "index.html"))); - pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index")); + pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this, postVisibilityFilter), "Index")); pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New")); pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone")); pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones")); @@ -753,14 +793,10 @@ public class WebInterface { private Collection getMentionedSones(String text) { /* we need no context to find mentioned Sones. */ Set mentionedSones = new HashSet(); - try { - for (Part part : soneTextParser.parse(null, new StringReader(text))) { - if (part instanceof SonePart) { - mentionedSones.add(((SonePart) part).getSone()); - } + for (Part part : soneTextParser.parse(text, null)) { + if (part instanceof SonePart) { + mentionedSones.add(((SonePart) part).getSone()); } - } catch (IOException ioe1) { - logger.log(Level.WARNING, String.format("Could not parse post text: %s", text), ioe1); } return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER); } @@ -897,12 +933,6 @@ public class WebInterface { @Subscribe public void soneRemoved(SoneRemovedEvent soneRemovedEvent) { newSoneNotification.remove(soneRemovedEvent.sone()); - for (Post post : soneRemovedEvent.sone().getPosts()) { - removePost(post); - } - for (PostReply postReply : soneRemovedEvent.sone().getReplies()) { - removeReply(postReply); - } } @Subscribe @@ -1019,9 +1049,10 @@ public class WebInterface { */ @Subscribe public void updateFound(UpdateFoundEvent updateFoundEvent) { - newVersionNotification.getTemplateContext().set("latestVersion", updateFoundEvent.version()); - newVersionNotification.getTemplateContext().set("latestEdition", updateFoundEvent.latestEdition()); - newVersionNotification.getTemplateContext().set("releaseTime", updateFoundEvent.releaseTime()); + newVersionNotification.set("latestVersion", updateFoundEvent.version()); + newVersionNotification.set("latestEdition", updateFoundEvent.latestEdition()); + newVersionNotification.set("releaseTime", updateFoundEvent.releaseTime()); + newVersionNotification.set("disruptive", updateFoundEvent.disruptive()); notificationManager.addNotification(newVersionNotification); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.java index dea9c3e..ce5276b 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/BookmarkAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - BookmarkAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - BookmarkAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java index 8af6d47..bf82328 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - CreatePostAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - CreatePostAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java index b63c852..fe2ae85 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - CreateReplyAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - CreateReplyAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java index 6ed222b..cfc1415 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeletePostAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - DeletePostAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java index 2ad3b29..7d937b5 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteProfileFieldAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteProfileFieldAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - DeleteProfileFieldAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java index e4905f5..7b2c3c9 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DeleteReplyAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - DeleteReplyAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java index 4e731e8..4661851 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DismissNotificationAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - DismissNotificationAjaxPage.java - Copyright © 2010–2016 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 @@ -21,6 +21,8 @@ import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.notify.Notification; +import com.google.common.base.Optional; + /** * AJAX page that lets the user dismiss a notification. * @@ -44,14 +46,14 @@ public class DismissNotificationAjaxPage extends JsonPage { @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { String notificationId = request.getHttpRequest().getParam("notification"); - Notification notification = webInterface.getNotifications().getNotification(notificationId); - if (notification == null) { + Optional notification = webInterface.getNotification(notificationId); + if (!notification.isPresent()) { return createErrorJsonObject("invalid-notification-id"); } - if (!notification.isDismissable()) { + if (!notification.get().isDismissable()) { return createErrorJsonObject("not-dismissable"); } - notification.dismiss(); + notification.get().dismiss(); return createSuccessJsonObject(); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java index c99c1a5..26a1207 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DistrustAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - DistrustAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - DistrustAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java index 96f3d01..9817fd8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditAlbumAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - EditAlbumAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java index e11a2b2..6f67ccb 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditImageAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - EditImageAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.java index 2a931c9..b81cf60 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditProfileFieldAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - EditProfileFieldAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - EditProfileFieldAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java index 115b27b..6a2d8ce 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - FollowSoneAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - FollowSoneAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java index 3f6c0d4..7bb75e6 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetLikesAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - GetLikesAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java index ee4683f..d0cba79 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetNotificationsAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetNotificationsAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - GetNotificationsAjaxPage.java - Copyright © 2011–2016 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 @@ -21,13 +21,12 @@ import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance; import java.io.IOException; import java.io.StringWriter; -import java.util.Collection; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.main.SonePlugin; -import net.pterodactylus.sone.notify.ListNotificationFilters; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.notify.Notification; @@ -81,14 +80,13 @@ public class GetNotificationsAjaxPage extends JsonPage { @Override protected JsonReturnObject createJsonObject(FreenetRequest request) { Sone currentSone = getCurrentSone(request.getToadletContext(), false); - Collection notifications = webInterface.getNotifications().getNotifications(); - List filteredNotifications = ListNotificationFilters.filterNotifications(notifications, currentSone); - Collections.sort(filteredNotifications, Notification.CREATED_TIME_SORTER); + List notifications = new ArrayList(webInterface.getNotifications(currentSone)); + Collections.sort(notifications, Notification.CREATED_TIME_SORTER); ArrayNode jsonNotifications = new ArrayNode(instance); - for (Notification notification : filteredNotifications) { + for (Notification notification : notifications) { jsonNotifications.add(createJsonNotification(request, notification)); } - return createSuccessJsonObject().put("notificationHash", filteredNotifications.hashCode()).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone)); + return createSuccessJsonObject().put("notificationHash", notifications.hashCode()).put("notifications", jsonNotifications).put("options", createJsonOptions(currentSone)); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java index 78176cb..60e94ce 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetPostAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - GetPostAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java index 1445e98..c66f47a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetReplyAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - GetReplyAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java index 6c5c0de..2ca7c23 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetStatusAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - GetStatusAjaxPage.java - Copyright © 2010–2016 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 @@ -21,6 +21,7 @@ import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -31,7 +32,8 @@ import java.util.Set; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.notify.ListNotificationFilters; +import net.pterodactylus.sone.notify.PostVisibilityFilter; +import net.pterodactylus.sone.notify.ReplyVisibilityFilter; import net.pterodactylus.sone.template.SoneAccessor; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; @@ -40,8 +42,6 @@ import net.pterodactylus.util.notify.Notification; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; /** * The “get status” AJAX handler returns all information that is necessary to @@ -88,20 +88,11 @@ public class GetStatusAjaxPage extends JsonPage { jsonSones.add(createJsonSone(sone)); } /* load notifications. */ - List notifications = ListNotificationFilters.filterNotifications(webInterface.getNotifications().getNotifications(), currentSone); + List notifications = new ArrayList(webInterface.getNotifications(currentSone)); Collections.sort(notifications, Notification.CREATED_TIME_SORTER); /* load new posts. */ - Collection newPosts = webInterface.getNewPosts(); - if (currentSone != null) { - newPosts = Collections2.filter(newPosts, new Predicate() { - - @Override - public boolean apply(Post post) { - return ListNotificationFilters.isPostVisible(currentSone, post); - } + Collection newPosts = webInterface.getNewPosts(getCurrentSone(request.getToadletContext(), false)); - }); - } ArrayNode jsonPosts = new ArrayNode(instance); for (Post post : newPosts) { ObjectNode jsonPost = new ObjectNode(instance); @@ -112,19 +103,8 @@ public class GetStatusAjaxPage extends JsonPage { jsonPosts.add(jsonPost); } /* load new replies. */ - Collection newReplies = webInterface.getNewReplies(); - if (currentSone != null) { - newReplies = Collections2.filter(newReplies, new Predicate() { - - @Override - public boolean apply(PostReply reply) { - return ListNotificationFilters.isReplyVisible(currentSone, reply); - } + Collection newReplies = webInterface.getNewReplies(getCurrentSone(request.getToadletContext(), false)); - }); - } - /* remove replies to unknown posts. */ - newReplies = Collections2.filter(newReplies, PostReply.HAS_POST_FILTER); ArrayNode jsonReplies = new ArrayNode(instance); for (PostReply reply : newReplies) { ObjectNode jsonReply = new ObjectNode(instance); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java index 97706a9..02fd0c1 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetTimesAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - GetTimesAjaxPage.java - Copyright © 2010–2016 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 the Free Software @@ -150,10 +150,10 @@ public class GetTimesAjaxPage extends JsonPage { String text; long refresh; if (age < 0) { - text = webInterface.getL10n().getDefaultString("View.Time.InTheFuture"); + text = webInterface.getL10n().getString("View.Time.InTheFuture"); refresh = TimeUnit.MINUTES.toMillis(5); } else if (age < TimeUnit.SECONDS.toMillis(20)) { - text = webInterface.getL10n().getDefaultString("View.Time.AFewSecondsAgo"); + text = webInterface.getL10n().getString("View.Time.AFewSecondsAgo"); refresh = TimeUnit.SECONDS.toMillis(10); } else if (age < TimeUnit.SECONDS.toMillis(45)) { text = webInterface.getL10n().getString("View.Time.HalfAMinuteAgo"); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java index 2823177..53e3e67 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java @@ -1,5 +1,5 @@ /* - * Sone - GetTranslationPage.java - Copyright © 2010–2015 David Roden + * Sone - GetTranslationPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java index a262742..289b5a4 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java @@ -1,5 +1,5 @@ /* - * Sone - JsonPage.java - Copyright © 2010–2015 David Roden + * Sone - JsonPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java index cf57c8e..f088acb 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - LikeAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - LikeAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java index 3a9ea7e..7298bae 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - LockSoneAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - LockSoneAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java index 4727686..fff1975 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkAsKnownAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - MarkAsKnownAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - MarkAsKnownAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.java index 4283f72..e8377f9 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MoveProfileFieldAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - MoveProfileFieldAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - MoveProfileFieldAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java index 1c0689f..a186d46 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/TrustAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - TrustAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - TrustAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java index 769ebcb..94dd268 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnbookmarkAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnbookmarkAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - UnbookmarkAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java index 803464c..58af936 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnfollowSoneAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - UnfollowSoneAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java index 6afe39b..2eaaa68 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnlikeAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - UnlikeAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java index 513ca97..bf88371 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UnlockSoneAjaxPage.java - Copyright © 2010–2015 David Roden + * Sone - UnlockSoneAjaxPage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java index cf8f1a7..644dfd6 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UntrustAjaxPage.java @@ -1,5 +1,5 @@ /* - * Sone - UntrustAjaxPage.java - Copyright © 2011–2015 David Roden + * Sone - UntrustAjaxPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java index 590ac48..813703c 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/FreenetPage.java @@ -1,5 +1,5 @@ /* - * Sone - FreenetPage.java - Copyright © 2011–2015 David Roden + * Sone - FreenetPage.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java index 4a0b788..ecbc0bb 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java +++ b/src/main/java/net/pterodactylus/sone/web/page/FreenetRequest.java @@ -1,5 +1,5 @@ /* - * Sone - FreenetRequest.java - Copyright © 2011–2015 David Roden + * Sone - FreenetRequest.java - Copyright © 2011–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java index 7338149..4c20e1f 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/FreenetTemplatePage.java @@ -1,5 +1,5 @@ /* - * Sone - FreenetTemplatePage.java - Copyright © 2010–2015 David Roden + * Sone - FreenetTemplatePage.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java b/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java index c64f2d7..222aa72 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java +++ b/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java @@ -1,5 +1,5 @@ /* - * Sone - PageToadlet.java - Copyright © 2010–2015 David Roden + * Sone - PageToadlet.java - Copyright © 2010–2016 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 diff --git a/src/main/java/net/pterodactylus/sone/web/page/PageToadletFactory.java b/src/main/java/net/pterodactylus/sone/web/page/PageToadletFactory.java index 0816e89..da5fcde 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/PageToadletFactory.java +++ b/src/main/java/net/pterodactylus/sone/web/page/PageToadletFactory.java @@ -1,5 +1,5 @@ /* - * Sone - PageToadletFactory.java - Copyright © 2010–2015 David Roden + * Sone - PageToadletFactory.java - Copyright © 2010–2016 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 diff --git a/src/main/resources/i18n/sone.de.properties b/src/main/resources/i18n/sone.de.properties index 6e871f9..62e9807 100644 --- a/src/main/resources/i18n/sone.de.properties +++ b/src/main/resources/i18n/sone.de.properties @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=Diese Sones wurden gerettet: Notification.SoneRescued.Text.RememberToUnlock=Bitte denken Sie daran, die Nachrichten und Antworten dieser Sone(s) zu kontrollieren und sie danach zu entsperren! Notification.LockedSones.Text=Diese Sones sind seit mehr als 5 Minuten gesperrt. Bitte überprüfen Sie, ob diese Sones wirklich gesperrt bleiben sollen: Notification.NewVersion.Text=Die Version {version} vom Sone-Plugin wurde gefunden. Sie können diese Version von USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​ herunter laden. +Notification.NewVersion.Disruptive.Text=Es wird {em}dringend empfohlen{/em}, dass Sie auf diese neue Version updaten, denn es ist möglich, dass Ihnen mit Ihrer aktuellen Version ein Haufen Inhalte entgehen! Notification.InsertingImages.Text=Diese Bilder werden gerade nach Freenet hoch geladen: Notification.InsertedImages.Text=Diese Bilder wurden nach Freenet hoch geladen: Notification.ImageInsertFailed.Text=Diese Bilder konnten nicht nach Freenet hoch geladen werden: diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties index 40a12b1..ae57376 100644 --- a/src/main/resources/i18n/sone.en.properties +++ b/src/main/resources/i18n/sone.en.properties @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=The following Sones have been rescued: Notification.SoneRescued.Text.RememberToUnlock=Please remember to control the posts and replies you have given and don’t forget to unlock your Sones! Notification.LockedSones.Text=The following Sones have been locked for more than 5 minutes. Please check if you really want to keep these Sones locked: Notification.NewVersion.Text=Version {version} of the Sone plugin was found. Download it from USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​! +Notification.NewVersion.Disruptive.Text=It is {em}highly recommended{/em} that you update to this version as it may be possible that you are missing a lot of content with your current version! Notification.InsertingImages.Text=The following images are being inserted: Notification.InsertedImages.Text=The following images have been inserted: Notification.ImageInsertFailed.Text=The following images could not be inserted: diff --git a/src/main/resources/i18n/sone.es.properties b/src/main/resources/i18n/sone.es.properties index 368903f..ab992e4 100644 --- a/src/main/resources/i18n/sone.es.properties +++ b/src/main/resources/i18n/sone.es.properties @@ -326,7 +326,7 @@ Page.Invalid.Text=Se ha realizado una acción inválida, o la acción era válid View.Search.Button.Search=Buscar -View.CreateSone.Text.WotIdentityRequired=Para crear un Sone necesitas una identidad del {link} plugin Web of Trust{/link}. +View.CreateSone.Text.WotIdentityRequired=Para crear un Sone necesitas una identidad del {link}plugin Web of Trust{/link}. View.CreateSone.Select.Default=Selecciona una identidad View.CreateSone.Text.NoIdentities=No tienes ninguna identidad de Web of Trust. Por favor, ve al {link}plugin Web of Trust{/link} y crea una identidad. View.CreateSone.Text.NoNonSoneIdentities=No tienes ninguna identidad de Web of Trust que no tenga ya un Sone. Usa alguna de las identidades restantes para crear un nuevo Sone o ve al {link}plugin Web of Trust{/link} para crear una nueva identidad. @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=Los siguientes Sone han sido rescatados: Notification.SoneRescued.Text.RememberToUnlock=Por favor, recuerda controlar las publicaciones y respuestas que has dado y no olvides desbloquear tus Sones! Notification.LockedSones.Text=Los siguientes Sone han estado bloqueados durante más de 5 minutos. Por favor, comprueva si realmente quieres mantenerlos bloqueados: Notification.NewVersion.Text=La versión {version} del plugin Sone fue encontrada. Descargala de USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​! +Notification.NewVersion.Disruptive.Text=Es {em}muy recomendable{/em} que se actualice a la nueva version tan pronto como sea posible ya que pueden haber nuevas herramientas incompatibles con la actual! Notification.InsertingImages.Text=Las siguientes imágenes están siendo insertadas: Notification.InsertedImages.Text=Las siguientes imágenes han sido insertadas: Notification.ImageInsertFailed.Text=Las siguientes imágenes no han podido ser insertadas: diff --git a/src/main/resources/i18n/sone.fr.properties b/src/main/resources/i18n/sone.fr.properties index df6f1ed..e068e49 100644 --- a/src/main/resources/i18n/sone.fr.properties +++ b/src/main/resources/i18n/sone.fr.properties @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=Les Sones suivants ont été sauvés: Notification.SoneRescued.Text.RememberToUnlock=Veuillez vous souvenir de contrôler les messages et réponses que vous avez donnés et n'oubliez pas de déverrouiller vos Sones! Notification.LockedSones.Text=Les Sones suivants ont été verrouillés pour une durée de plus de 5 minutes. Veuillez vérifier si vous voulez vraiment garder ces Sones bloqués: Notification.NewVersion.Text=La version ${version} du plugin Sone a été trouvée. Téléchargez la depuis USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​! +Notification.NewVersion.Disruptive.Text=Il est {en}fortement recommandé{/en} que vous mettiez à jour vers cette version, car il est possible que vous manquiez beaucoup de contenu avec la version actuelle! Notification.InsertingImages.Text=Les images suivantes sont en cours d'insertion: Notification.InsertedImages.Text=Les images suivantes ont été insérées: Notification.ImageInsertFailed.Text=Les images suivantes ne peuvent être insérées: diff --git a/src/main/resources/i18n/sone.ja.properties b/src/main/resources/i18n/sone.ja.properties index af7a295..d193e6f 100644 --- a/src/main/resources/i18n/sone.ja.properties +++ b/src/main/resources/i18n/sone.ja.properties @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=次のSoneが復帰しました: Notification.SoneRescued.Text.RememberToUnlock=投稿や返信を確認の上、ロックを解除するのを忘れないようにしてください。 Notification.LockedSones.Text=次のSoneは5分以上ロック状態になっています。故意にロック中であるかを確認してください: Notification.NewVersion.Text=Soneの新しいバージョン{version}があります。USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​よりダウンロードしてください。 +Notification.NewVersion.Disruptive.Text=It is {em}highly recommended{/em} that you update to this version as it may be possible that you are missing a lot of content with your current version! Notification.InsertingImages.Text=次の画像がインサート中です: Notification.InsertedImages.Text=次の画像のインサートされました: Notification.ImageInsertFailed.Text=次の画像のインサートに失敗しました: @@ -463,4 +464,4 @@ Notification.Mention.Text=次の投稿でメンションされています: Notification.SoneIsInserting.Text=あなたのSone sone://{0}は現在インサート中です。 Notification.SoneIsInserted.Text=あなたのSone sone://{0}は{1,number}{1,choice,0#秒|1#秒|1<秒}でインサートされました。 Notification.SoneInsertAborted.Text=あなたのSone sone://{0}のインサートに失敗しました。 -# 60, 100 +# 60, 100, 458 diff --git a/src/main/resources/i18n/sone.no.properties b/src/main/resources/i18n/sone.no.properties index 27a5a2e..99a950f 100644 --- a/src/main/resources/i18n/sone.no.properties +++ b/src/main/resources/i18n/sone.no.properties @@ -455,6 +455,7 @@ Notification.SoneRescued.Text=De følgende Sonene har blitt reddet: Notification.SoneRescued.Text.RememberToUnlock=Husk å kontroller innlegg og svar du har publisert og ikke glem å lås opp dine Soner! Notification.LockedSones.Text=De følgende Sonene har vært låst i mer enn 5 minutter. Vennligst sjekk om du virkelig ønsker å beholde disse Sonene låst: Notification.NewVersion.Text=Utgave {version} av sone-tillegget ble funnet. Last det ned fra USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/{edition}​! +Notification.NewVersion.Disruptive.Text=It is {em}highly recommended{/em} that you update to this version as it may be possible that you are missing a lot of content with your current version! Notification.InsertingImages.Text=De følgende bildene blir lastet opp: Notification.InsertedImages.Text=De følgende bildene har blitt lastet opp: Notification.ImageInsertFailed.Text=De følgende bildene kunne ikke bli innsatt: @@ -463,4 +464,4 @@ Notification.Mention.Text=Du har blitt nevnt i følgende innlegg: Notification.SoneIsInserting.Text=Your Sone sone://{0} is now being inserted. Notification.SoneIsInserted.Text=Your Sone sone://{0} has been inserted in {1,number} {1,choice,0#seconds|1#second|1 - + diff --git a/src/main/resources/templates/deleteReply.html b/src/main/resources/templates/deleteReply.html index 1c0cf4e..23daf1c 100644 --- a/src/main/resources/templates/deleteReply.html +++ b/src/main/resources/templates/deleteReply.html @@ -7,7 +7,7 @@
- +
diff --git a/src/main/resources/templates/imageBrowser.html b/src/main/resources/templates/imageBrowser.html index 7dd4c29..644848a 100644 --- a/src/main/resources/templates/imageBrowser.html +++ b/src/main/resources/templates/imageBrowser.html @@ -353,17 +353,6 @@ - <%if ! album.images.empty> -
- - -
- <%/if>
diff --git a/src/main/resources/templates/insert/include/album.xml b/src/main/resources/templates/insert/include/album.xml deleted file mode 100644 index cd845da..0000000 --- a/src/main/resources/templates/insert/include/album.xml +++ /dev/null @@ -1,23 +0,0 @@ - - <% album.id|xml> - <% album.name|xml> - <% album.description|xml> - - <%foreach album.albums album> - <%include insert/include/album.xml> - <%/foreach> - - - <%foreach album.images image> - - <% image.id|xml> - <% image.creationTime|xml> - <% image.key|xml> - <% image.width|xml> - <% image.height|xml> - <% image.title|xml> - <% image.description|xml> - - <%/foreach> - - diff --git a/src/main/resources/templates/notify/newVersionNotification.html b/src/main/resources/templates/notify/newVersionNotification.html index 599a7e6..f35ecaf 100644 --- a/src/main/resources/templates/notify/newVersionNotification.html +++ b/src/main/resources/templates/notify/newVersionNotification.html @@ -1 +1,4 @@
<%= Notification.NewVersion.Text|l10n|replace needle=="{version}" replacement=latestVersion|replace needle=="{edition}" replacement=latestEdition|parse sone=="nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI">
+<%if disruptive> +
<%= Notification.NewVersion.Disruptive.Text|l10n|html|replace needle=="{em}" replacement==""|replace needle=="{/em}" replacement=="">
+<%/if> diff --git a/src/test/java/net/pterodactylus/sone/Matchers.java b/src/test/java/net/pterodactylus/sone/Matchers.java index faf2633..823cdf9 100644 --- a/src/test/java/net/pterodactylus/sone/Matchers.java +++ b/src/test/java/net/pterodactylus/sone/Matchers.java @@ -1,5 +1,5 @@ /* - * Sone - Matchers.java - Copyright © 2013–2015 David Roden + * Sone - Matchers.java - Copyright © 2013–2016 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 @@ -109,8 +109,7 @@ public class Matchers { public static Matcher isAlbum(final String albumId, final String parentAlbumId, - final String title, final String albumDescription, - final String imageId) { + final String title, final String albumDescription) { return new TypeSafeDiagnosingMatcher() { @Override protected boolean matchesSafely(Album album, @@ -146,22 +145,6 @@ public class Matchers { .appendValue(album.getDescription()); return false; } - if (imageId == null) { - if (album.getAlbumImage() != null) { - mismatchDescription.appendText("has album image"); - return false; - } - } else { - if (album.getAlbumImage() == null) { - mismatchDescription.appendText("has no album image"); - return false; - } - if (!album.getAlbumImage().getId().equals(imageId)) { - mismatchDescription.appendText("has album image ") - .appendValue(album.getAlbumImage().getId()); - return false; - } - } return true; } @@ -177,12 +160,6 @@ public class Matchers { description.appendText(", has title ").appendValue(title); description.appendText(", has description ") .appendValue(albumDescription); - if (imageId == null) { - description.appendText(", has no album image"); - } else { - description.appendText(", has album image ") - .appendValue(imageId); - } } }; } diff --git a/src/test/java/net/pterodactylus/sone/TestAlbumBuilder.java b/src/test/java/net/pterodactylus/sone/TestAlbumBuilder.java index 9890a70..a499019 100644 --- a/src/test/java/net/pterodactylus/sone/TestAlbumBuilder.java +++ b/src/test/java/net/pterodactylus/sone/TestAlbumBuilder.java @@ -46,17 +46,6 @@ public class TestAlbumBuilder implements AlbumBuilder { return description; } }); - when(album.getAlbumImage()).thenAnswer(new Answer() { - @Override - public Image answer(InvocationOnMock invocation) { - if (imageId == null) { - return null; - } - Image image = mock(Image.class); - when(image.getId()).thenReturn(imageId); - return image; - } - }); when(album.getAlbums()).thenReturn(albums); when(album.getImages()).thenReturn(images); doAnswer(new Answer() { @@ -101,12 +90,6 @@ public class TestAlbumBuilder implements AlbumBuilder { } @Override - public Modifier setAlbumImage(String imageId) { - TestAlbumBuilder.this.imageId = imageId; - return this; - } - - @Override public Album update() throws IllegalStateException { return album; } diff --git a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java index 7bbfae8..ec42a8c 100644 --- a/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/ConfigurationSoneParserTest.java @@ -333,15 +333,15 @@ public class ConfigurationSoneParserTest { albumBuilderFactory); assertThat(topLevelAlbums, hasSize(2)); Album firstAlbum = topLevelAlbums.get(0); - assertThat(firstAlbum, isAlbum("A1", null, "T1", "D1", "I1")); + assertThat(firstAlbum, isAlbum("A1", null, "T1", "D1")); assertThat(firstAlbum.getAlbums(), emptyIterable()); assertThat(firstAlbum.getImages(), emptyIterable()); Album secondAlbum = topLevelAlbums.get(1); - assertThat(secondAlbum, isAlbum("A2", null, "T2", "D2", null)); + assertThat(secondAlbum, isAlbum("A2", null, "T2", "D2")); assertThat(secondAlbum.getAlbums(), hasSize(1)); assertThat(secondAlbum.getImages(), emptyIterable()); Album thirdAlbum = secondAlbum.getAlbums().get(0); - assertThat(thirdAlbum, isAlbum("A3", "A2", "T3", "D3", "I3")); + assertThat(thirdAlbum, isAlbum("A3", "A2", "T3", "D3")); assertThat(thirdAlbum.getAlbums(), emptyIterable()); assertThat(thirdAlbum.getImages(), emptyIterable()); } diff --git a/src/test/java/net/pterodactylus/sone/core/CoreTest.java b/src/test/java/net/pterodactylus/sone/core/CoreTest.java index 263c2d0..8e83e21 100644 --- a/src/test/java/net/pterodactylus/sone/core/CoreTest.java +++ b/src/test/java/net/pterodactylus/sone/core/CoreTest.java @@ -1,15 +1,36 @@ package net.pterodactylus.sone.core; +import static org.mockito.Matchers.argThat; import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import net.pterodactylus.sone.core.Core.MarkPostKnown; import net.pterodactylus.sone.core.Core.MarkReplyKnown; +import net.pterodactylus.sone.core.event.PostRemovedEvent; +import net.pterodactylus.sone.core.event.PostReplyRemovedEvent; +import net.pterodactylus.sone.core.event.SoneRemovedEvent; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.Database; +import net.pterodactylus.sone.freenet.wot.Identity; +import net.pterodactylus.sone.freenet.wot.IdentityManager; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; +import net.pterodactylus.sone.freenet.wot.event.IdentityRemovedEvent; +import net.pterodactylus.util.config.Configuration; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.eventbus.EventBus; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; import org.junit.Test; +import org.mockito.InOrder; /** * Unit test for {@link Core} and its subclasses. @@ -36,4 +57,108 @@ public class CoreTest { verify(core).markReplyKnown(eq(postReply)); } + @Test + public void removingAnIdentitySendsRemovalEventsForAllSoneElements() { + // given + Configuration configuration = mock(Configuration.class); + FreenetInterface freenetInterface = mock(FreenetInterface.class); + IdentityManager identityManager = mock(IdentityManager.class); + SoneDownloader soneDownloader = mock(SoneDownloader.class); + ImageInserter imageInserter = mock(ImageInserter.class); + UpdateChecker updateChecker = mock(UpdateChecker.class); + WebOfTrustUpdater webOfTrustUpdater = mock(WebOfTrustUpdater.class); + EventBus eventBus = mock(EventBus.class); + Database database = mock(Database.class); + Core core = new Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database); + OwnIdentity ownIdentity = mock(OwnIdentity.class); + Identity identity = mock(Identity.class); + when(identity.getId()).thenReturn("sone-id"); + Sone sone = mock(Sone.class); + when(database.getSone("sone-id")).thenReturn(Optional.of(sone)); + PostReply postReply1 = mock(PostReply.class); + PostReply postReply2 = mock(PostReply.class); + when(sone.getReplies()).thenReturn(ImmutableSet.of(postReply1, postReply2)); + Post post1 = mock(Post.class); + Post post2 = mock(Post.class); + when(sone.getPosts()).thenReturn(ImmutableList.of(post1, post2)); + + // when + core.identityRemoved(new IdentityRemovedEvent(ownIdentity, identity)); + + // then + InOrder inOrder = inOrder(eventBus, database); + inOrder.verify(eventBus).post(argThat(isPostReplyRemoved(postReply1))); + inOrder.verify(eventBus).post(argThat(isPostReplyRemoved(postReply2))); + inOrder.verify(eventBus).post(argThat(isPostRemoved(post1))); + inOrder.verify(eventBus).post(argThat(isPostRemoved(post2))); + inOrder.verify(eventBus).post(argThat(isSoneRemoved(sone))); + inOrder.verify(database).removeSone(sone); + } + + private Matcher isPostRemoved(final Post post) { + return new TypeSafeDiagnosingMatcher() { + @Override + protected boolean matchesSafely(Object item, Description mismatchDescription) { + if (!(item instanceof PostRemovedEvent)) { + mismatchDescription.appendText("is not PostRemovedEvent"); + return false; + } + if (((PostRemovedEvent) item).post() != post) { + mismatchDescription.appendText("post is ").appendValue(((PostRemovedEvent) item).post()); + return false; + } + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("is PostRemovedEvent and post is ").appendValue(post); + } + }; + } + + private Matcher isPostReplyRemoved(final PostReply postReply) { + return new TypeSafeDiagnosingMatcher() { + @Override + protected boolean matchesSafely(Object item, Description mismatchDescription) { + if (!(item instanceof PostReplyRemovedEvent)) { + mismatchDescription.appendText("is not PostReplyRemovedEvent"); + return false; + } + if (((PostReplyRemovedEvent) item).postReply() != postReply) { + mismatchDescription.appendText("post reply is ").appendValue(((PostReplyRemovedEvent) item).postReply()); + return false; + } + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("is PostReplyRemovedEvent and post is ").appendValue(postReply); + } + }; + } + + private Matcher isSoneRemoved(final Sone sone) { + return new TypeSafeDiagnosingMatcher() { + @Override + protected boolean matchesSafely(Object item, Description mismatchDescription) { + if (!(item instanceof SoneRemovedEvent)) { + mismatchDescription.appendText("is not SoneRemovedEvent"); + return false; + } + if (((SoneRemovedEvent) item).sone() != sone) { + mismatchDescription.appendText("sone is ").appendValue(((SoneRemovedEvent) item).sone()); + return false; + } + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("is SoneRemovedEvent and sone is ").appendValue(sone); + } + }; + } + } diff --git a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java index dc19195..2d8a5a0 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java @@ -243,7 +243,6 @@ public class SoneParserTest { @Before public void setupAlbum() { final Album album = SoneParserTest.this.album; - when(album.getAlbumImage()).thenReturn(mock(Image.class)); doAnswer(new Answer() { @Override public Void answer(InvocationOnMock invocation) { @@ -273,7 +272,6 @@ public class SoneParserTest { final Modifier albumModifier = new Modifier() { private String title = album.getTitle(); private String description = album.getDescription(); - private String imageId = album.getAlbumImage().getId(); @Override public Modifier setTitle(String title) { @@ -288,18 +286,9 @@ public class SoneParserTest { } @Override - public Modifier setAlbumImage(String imageId) { - this.imageId = imageId; - return this; - } - - @Override public Album update() throws IllegalStateException { when(album.getTitle()).thenReturn(title); when(album.getDescription()).thenReturn(description); - Image image = mock(Image.class); - when(image.getId()).thenReturn(imageId); - when(album.getAlbumImage()).thenReturn(image); return album; } }; diff --git a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java index a5e3b2a..44819ee 100644 --- a/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java +++ b/src/test/java/net/pterodactylus/sone/core/UpdateCheckerTest.java @@ -1,7 +1,6 @@ package net.pterodactylus.sone.core; import static java.lang.Long.MAX_VALUE; -import static net.pterodactylus.sone.main.SonePlugin.VERSION; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.is; @@ -44,7 +43,8 @@ public class UpdateCheckerTest { private final EventBus eventBus = mock(EventBus.class); private final FreenetInterface freenetInterface = mock(FreenetInterface.class); - private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface); + private final Version currentVersion = new Version(1, 0, 0); + private final UpdateChecker updateChecker = new UpdateChecker(eventBus, freenetInterface, currentVersion); @Before public void startUpdateChecker() { @@ -54,7 +54,7 @@ public class UpdateCheckerTest { @Test public void newUpdateCheckerDoesNotHaveALatestVersion() { assertThat(updateChecker.hasLatestVersion(), is(false)); - assertThat(updateChecker.getLatestVersion(), is(VERSION)); + assertThat(updateChecker.getLatestVersion(), is(currentVersion)); } @Test @@ -87,23 +87,33 @@ public class UpdateCheckerTest { setupFetchResult(createFutureFetchResult()); setupCallbackWithEdition(MAX_VALUE, true, false); verifyAFreenetUriIsFetched(); - ArgumentCaptor updateFoundEvent = forClass(UpdateFoundEvent.class); - verify(eventBus, times(1)).post(updateFoundEvent.capture()); - assertThat(updateFoundEvent.getValue().version(), is(new Version(99, 0, 0))); - assertThat(updateFoundEvent.getValue().releaseTime(), is(11865368297000L)); - assertThat(updateChecker.getLatestVersion(), is(new Version(99, 0, 0))); - assertThat(updateChecker.getLatestVersionDate(), is(11865368297000L)); - assertThat(updateChecker.hasLatestVersion(), is(true)); + verifyEventIsFired(new Version(99, 0, 0), 11865368297000L, false); + verifyThatUpdateCheckerKnowsLatestVersion(new Version(99, 0, 0), 11865368297000L); } private FetchResult createFutureFetchResult() { ClientMetadata clientMetadata = new ClientMetadata("application/xml"); Bucket fetched = new ArrayBucket(("# MapConfigurationBackendVersion=1\n" + "CurrentVersion/Version: 99.0.0\n" + - "CurrentVersion/ReleaseTime: 11865368297000").getBytes()); + "CurrentVersion/ReleaseTime: 11865368297000\n" + + "DisruptiveVersion/0.1.2: true").getBytes()); return new FetchResult(clientMetadata, fetched); } + private void verifyEventIsFired(Version version, long releaseTime, boolean disruptive) { + ArgumentCaptor updateFoundEvent = forClass(UpdateFoundEvent.class); + verify(eventBus, times(1)).post(updateFoundEvent.capture()); + assertThat(updateFoundEvent.getValue().version(), is(version)); + assertThat(updateFoundEvent.getValue().releaseTime(), is(releaseTime)); + assertThat(updateFoundEvent.getValue().disruptive(), is(disruptive)); + } + + private void verifyThatUpdateCheckerKnowsLatestVersion(Version version, long releaseTime) { + assertThat(updateChecker.getLatestVersion(), is(version)); + assertThat(updateChecker.getLatestVersionDate(), is(releaseTime)); + assertThat(updateChecker.hasLatestVersion(), is(true)); + } + @Test public void callbackDoesNotStartIfNoNewEditionIsFound() { setupFetchResult(createPastFetchResult()); @@ -230,4 +240,22 @@ public class UpdateCheckerTest { return new FetchResult(clientMetadata, fetched); } + @Test + public void disruptiveVersionGetsNotification() { + setupFetchResult(createDisruptiveVersionFetchResult()); + setupCallbackWithEdition(MAX_VALUE, true, false); + verifyAFreenetUriIsFetched(); + verifyEventIsFired(new Version(1, 2, 3), 1289417883000L, true); + verifyThatUpdateCheckerKnowsLatestVersion(new Version(1, 2, 3), 1289417883000L); + } + + private FetchResult createDisruptiveVersionFetchResult() { + ClientMetadata clientMetadata = new ClientMetadata("application/xml"); + Bucket fetched = new ArrayBucket(("# MapConfigurationBackendVersion=1\n" + + "CurrentVersion/Version: 1.2.3\n" + + "CurrentVersion/ReleaseTime: 1289417883000\n" + + "DisruptiveVersion/1.2.3: true").getBytes()); + return new FetchResult(clientMetadata, fetched); + } + } diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index 5ee498c..a207132 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -1,5 +1,5 @@ /* - * Sone - MemoryDatabaseTest.java - Copyright © 2013–2015 David Roden + * Sone - MemoryDatabaseTest.java - Copyright © 2013–2016 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 @@ -131,7 +131,7 @@ public class MemoryDatabaseTest { .update(); Album secondAlbum = new TestAlbumBuilder().withId("album2").by( sone).build().modify().setTitle("album2").setDescription( - "album-description2").setAlbumImage("image1").update(); + "album-description2").update(); Album thirdAlbum = new TestAlbumBuilder().withId("album3").by( sone).build().modify().setTitle("album3").setDescription( "album-description3").update(); @@ -192,14 +192,11 @@ public class MemoryDatabaseTest { assertThat(memoryDatabase.getPostReply("reply4").isPresent(), is(false)); assertThat(memoryDatabase.getAlbum("album1").get(), - isAlbum("album1", null, "album1", "album-description1", - null)); + isAlbum("album1", null, "album1", "album-description1")); assertThat(memoryDatabase.getAlbum("album2").get(), - isAlbum("album2", null, "album2", "album-description2", - "image1")); + isAlbum("album2", null, "album2", "album-description2")); assertThat(memoryDatabase.getAlbum("album3").get(), - isAlbum("album3", "album1", "album3", "album-description3", - null)); + isAlbum("album3", "album1", "album3", "album-description3")); assertThat(memoryDatabase.getAlbum("album4").isPresent(), is(false)); assertThat(memoryDatabase.getImage("image1").get(), isImage("image1", 1000L, "KSK@image1", "image1", diff --git a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java index b6c9cd7..d583661 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/LockSoneCommandTest.java @@ -1,5 +1,5 @@ /* - * Sone - LockSoneCommandTest.java - Copyright © 2013–2015 David Roden + * Sone - LockSoneCommandTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java index 4cabfd1..bd292dd 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/UnlockSoneCommandTest.java @@ -1,5 +1,5 @@ /* - * Sone - UnlockSoneCommandTest.java - Copyright © 2013–2015 David Roden + * Sone - UnlockSoneCommandTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultIdentityTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultIdentityTest.java index b0e88ad..f11c7e3 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultIdentityTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultIdentityTest.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultIdentityTest.java - Copyright © 2013–2015 David Roden + * Sone - DefaultIdentityTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentityTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentityTest.java index 29c371e..c5dc840 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentityTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/DefaultOwnIdentityTest.java @@ -1,5 +1,5 @@ /* - * Sone - DefaultOwnIdentityTest.java - Copyright © 2013–2015 David Roden + * Sone - DefaultOwnIdentityTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/Identities.java b/src/test/java/net/pterodactylus/sone/freenet/wot/Identities.java index 479bee6..9f92308 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/Identities.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/Identities.java @@ -1,5 +1,5 @@ /* - * Sone - Identities.java - Copyright © 2013–2015 David Roden + * Sone - Identities.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetectorTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetectorTest.java index 6a4e3d2..3773cbe 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetectorTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetectorTest.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityChangeDetectorTest.java - Copyright © 2013–2015 David Roden + * Sone - IdentityChangeDetectorTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java index c88147c..f58c239 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityChangeEventSenderTest.java - Copyright © 2013–2015 David Roden + * Sone - IdentityChangeEventSenderTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java index 692400a..a07af28 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityLoaderTest.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityLoaderTest.java - Copyright © 2013–2015 David Roden + * Sone - IdentityLoaderTest.java - Copyright © 2013–2016 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 diff --git a/src/test/java/net/pterodactylus/sone/notify/ListNotificationFilterTest.java b/src/test/java/net/pterodactylus/sone/notify/ListNotificationFilterTest.java new file mode 100644 index 0000000..b29b2c1 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/notify/ListNotificationFilterTest.java @@ -0,0 +1,281 @@ +package net.pterodactylus.sone.notify; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.emptyIterable; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Nullable; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.data.SoneOptions; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; +import net.pterodactylus.util.notify.Notification; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.hamcrest.Matchers; +import org.junit.Test; + +/** + * Unit test for {@link ListNotificationFilterTest}. + * + * @author David ‘Bombe’ Roden + */ +public class ListNotificationFilterTest { + + private static final String LOCAL_ID = "local-id"; + + private final PostVisibilityFilter postVisibilityFilter = mock(PostVisibilityFilter.class); + private final ReplyVisibilityFilter replyVisibilityFilter = mock(ReplyVisibilityFilter.class); + private final ListNotificationFilter listNotificationFilter = new ListNotificationFilter(postVisibilityFilter, replyVisibilityFilter); + + private final Sone localSone = mock(Sone.class); + private final SoneOptions soneOptions = mock(SoneOptions.class); + private final OwnIdentity localIdentity = mock(OwnIdentity.class); + private final List> newPostNotifications = Arrays.asList(createNewPostNotification()); + private final List> newReplyNotifications = Arrays.asList(createNewReplyNotification()); + private final List> mentionNotifications = Arrays.asList(createMentionNotification()); + + public ListNotificationFilterTest() { + when(localSone.getId()).thenReturn(LOCAL_ID); + when(localSone.isLocal()).thenReturn(true); + when(localSone.getIdentity()).thenReturn(localIdentity); + when(localIdentity.getId()).thenReturn(LOCAL_ID); + when(localSone.getOptions()).thenReturn(soneOptions); + } + + @Test + public void filterIsOnlyCreatedOnce() { + Injector injector = Guice.createInjector(); + ListNotificationFilter firstFilter = injector.getInstance(ListNotificationFilter.class); + ListNotificationFilter secondFilter = injector.getInstance(ListNotificationFilter.class); + assertThat(firstFilter, sameInstance(secondFilter)); + } + + @Test + public void newSoneNotificationsAreNotRemovedIfNotLoggedIn() { + List notifications = Arrays.asList(createNewSoneNotification()); + List filteredNotifications = listNotificationFilter.filterNotifications(notifications, null); + assertThat(filteredNotifications, contains(notifications.get(0))); + } + + private Notification createNewSoneNotification() { + ListNotification newSoneNotification = mock(ListNotification.class); + when(newSoneNotification.getId()).thenReturn("new-sone-notification"); + return newSoneNotification; + } + + @Test + public void newSoneNotificationsAreRemovedIfLoggedInAndNewSonesShouldNotBeShown() { + List notifications = Arrays.asList(createNewSoneNotification()); + List filteredNotifications = listNotificationFilter.filterNotifications(notifications, localSone); + assertThat(filteredNotifications, emptyIterable()); + } + + @Test + public void newSoneNotificationsAreNotRemovedIfLoggedInAndNewSonesShouldBeShown() { + List notifications = Arrays.asList(createNewSoneNotification()); + when(soneOptions.isShowNewSoneNotifications()).thenReturn(true); + List filteredNotifications = listNotificationFilter.filterNotifications(notifications, localSone); + assertThat(filteredNotifications, contains(notifications.get(0))); + } + + private ListNotification createNewPostNotification() { + ListNotification newSoneNotification = mock(ListNotification.class); + when(newSoneNotification.getElements()).thenReturn(new ArrayList()); + when(newSoneNotification.getId()).thenReturn("new-post-notification"); + return newSoneNotification; + } + + @Test + public void newPostNotificationIsNotShownIfOptionsSetAccordingly() { + List> notifications = Arrays.asList(createNewPostNotification()); + List filteredNotifications = listNotificationFilter.filterNotifications(notifications, localSone); + assertThat(filteredNotifications, hasSize(0)); + } + + private void activateNewPostNotifications() { + when(soneOptions.isShowNewPostNotifications()).thenReturn(true); + } + + private boolean addPostToPostNotification(List> notifications) { + return notifications.get(0).getElements().add(mock(Post.class)); + } + + private void setPostVisibilityPredicate(Predicate value) { + when(postVisibilityFilter.isVisible(any(Sone.class))).thenReturn(value); + } + + @Test + public void newPostNotificationIsNotShownIfNoNewPostsAreVisible() { + activateNewPostNotifications(); + addPostToPostNotification(newPostNotifications); + setPostVisibilityPredicate(Predicates.alwaysFalse()); + List filteredNotifications = listNotificationFilter.filterNotifications(newPostNotifications, localSone); + assertThat(filteredNotifications, hasSize(0)); + } + + @Test + public void newPostNotificationIsShownIfNewPostsAreVisible() { + activateNewPostNotifications(); + addPostToPostNotification(newPostNotifications); + setPostVisibilityPredicate(Predicates.alwaysTrue()); + List filteredNotifications = listNotificationFilter.filterNotifications(newPostNotifications, localSone); + assertThat(filteredNotifications, contains((Notification) newPostNotifications.get(0))); + } + + @Test + public void newPostNotificationIsNotShownIfNewPostsAreVisibleButLocalSoneIsNull() { + activateNewPostNotifications(); + addPostToPostNotification(newPostNotifications); + setPostVisibilityPredicate(Predicates.alwaysTrue()); + List filteredNotifications = listNotificationFilter.filterNotifications(newPostNotifications, null); + assertThat(filteredNotifications, Matchers.emptyIterable()); + } + + @Test + public void newPostNotificationContainsOnlyVisiblePosts() { + activateNewPostNotifications(); + addPostToPostNotification(newPostNotifications); + addPostToPostNotification(newPostNotifications); + setPostVisibilityPredicate(new Predicate() { + @Override + public boolean apply(@Nullable Post post) { + return post.equals(newPostNotifications.get(0).getElements().get(1)); + } + }); + List filteredNotifications = listNotificationFilter.filterNotifications(newPostNotifications, localSone); + assertThat(filteredNotifications, hasSize(1)); + assertThat(((ListNotification) filteredNotifications.get(0)).getElements().get(0), is(newPostNotifications.get(0).getElements().get(1))); + } + + private ListNotification createNewReplyNotification() { + ListNotification newReplyNotifications = mock(ListNotification.class); + when(newReplyNotifications.getElements()).thenReturn(new ArrayList()); + when(newReplyNotifications.getId()).thenReturn("new-reply-notification"); + return newReplyNotifications; + } + + private void activateNewReplyNotifications() { + when(soneOptions.isShowNewReplyNotifications()).thenReturn(true); + } + + private void addReplyToNewReplyNotification(List> notifications) { + notifications.get(0).getElements().add(mock(PostReply.class)); + } + + private void setReplyVisibilityPredicate(Predicate value) { + when(replyVisibilityFilter.isVisible(any(Sone.class))).thenReturn(value); + } + + @Test + public void newReplyNotificationContainsOnlyVisibleReplies() { + activateNewReplyNotifications(); + addReplyToNewReplyNotification(newReplyNotifications); + addReplyToNewReplyNotification(newReplyNotifications); + setReplyVisibilityPredicate(new Predicate() { + @Override + public boolean apply(@Nullable PostReply postReply) { + return postReply.equals(newReplyNotifications.get(0).getElements().get(1)); + } + }); + List filteredNotifications = listNotificationFilter.filterNotifications(newReplyNotifications, localSone); + assertThat(filteredNotifications, hasSize(1)); + assertThat(((ListNotification) filteredNotifications.get(0)).getElements().get(0), is(newReplyNotifications.get(0).getElements().get(1))); + } + + @Test + public void newReplyNotificationIsNotModifiedIfAllRepliesAreVisible() { + activateNewReplyNotifications(); + addReplyToNewReplyNotification(newReplyNotifications); + addReplyToNewReplyNotification(newReplyNotifications); + setReplyVisibilityPredicate(Predicates.alwaysTrue()); + List filteredNotifications = listNotificationFilter.filterNotifications(newReplyNotifications, localSone); + assertThat(filteredNotifications, hasSize(1)); + assertThat(filteredNotifications.get(0), is((Notification) newReplyNotifications.get(0))); + assertThat(((ListNotification) filteredNotifications.get(0)).getElements(), hasSize(2)); + } + + @Test + public void newReplyNotificationIsNotShownIfNoRepliesAreVisible() { + activateNewReplyNotifications(); + addReplyToNewReplyNotification(newReplyNotifications); + addReplyToNewReplyNotification(newReplyNotifications); + setReplyVisibilityPredicate(Predicates.alwaysFalse()); + List filteredNotifications = listNotificationFilter.filterNotifications(newReplyNotifications, localSone); + assertThat(filteredNotifications, hasSize(0)); + } + + @Test + public void newReplyNotificationIsNotShownIfDeactivatedInOptions() { + addReplyToNewReplyNotification(newReplyNotifications); + addReplyToNewReplyNotification(newReplyNotifications); + setReplyVisibilityPredicate(Predicates.alwaysTrue()); + List filteredNotifications = listNotificationFilter.filterNotifications(newReplyNotifications, localSone); + assertThat(filteredNotifications, hasSize(0)); + } + + @Test + public void newReplyNotificationIsNotShownIfCurrentSoneIsNull() { + addReplyToNewReplyNotification(newReplyNotifications); + addReplyToNewReplyNotification(newReplyNotifications); + setReplyVisibilityPredicate(Predicates.alwaysTrue()); + List filteredNotifications = listNotificationFilter.filterNotifications(newReplyNotifications, null); + assertThat(filteredNotifications, hasSize(0)); + } + + private ListNotification createMentionNotification() { + ListNotification newSoneNotification = mock(ListNotification.class); + when(newSoneNotification.getElements()).thenReturn(new ArrayList()); + when(newSoneNotification.getId()).thenReturn("mention-notification"); + return newSoneNotification; + } + + @Test + public void mentionNotificationContainsOnlyVisiblePosts() { + addPostToPostNotification(mentionNotifications); + addPostToPostNotification(mentionNotifications); + setPostVisibilityPredicate(new Predicate() { + @Override + public boolean apply(@Nullable Post post) { + return post.equals(mentionNotifications.get(0).getElements().get(1)); + } + }); + List filteredNotifications = listNotificationFilter.filterNotifications(mentionNotifications, localSone); + assertThat(filteredNotifications, hasSize(1)); + assertThat(((ListNotification) filteredNotifications.get(0)).getElements().get(0), is(mentionNotifications.get(0).getElements().get(1))); + } + + @Test + public void mentionNotificationIsNotShownIfNoPostsAreVisible() { + addPostToPostNotification(mentionNotifications); + addPostToPostNotification(mentionNotifications); + setPostVisibilityPredicate(Predicates.alwaysFalse()); + List filteredNotifications = listNotificationFilter.filterNotifications(mentionNotifications, localSone); + assertThat(filteredNotifications, hasSize(0)); + } + + @Test + public void unfilterableNotificationIsNotFiltered() { + Notification notification = mock(Notification.class); + when(notification.getId()).thenReturn("random-notification"); + List notifications = Arrays.asList(notification); + List filteredNotifications = listNotificationFilter.filterNotifications(notifications, null); + assertThat(filteredNotifications, contains(notification)); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java b/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java new file mode 100644 index 0000000..c354afa --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java @@ -0,0 +1,121 @@ +package net.pterodactylus.sone.notify; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.emptyIterable; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.mockito.Matchers.argThat; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; + +import net.pterodactylus.util.notify.NotificationListener; +import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; + +import org.hamcrest.Matchers; +import org.junit.Test; + +/** + * Unit test for {@link ListNotification}. + * + * @author David ‘Bombe’ Roden + */ +public class ListNotificationTest { + + private static final String ID = "notification-id"; + private static final String KEY = "element-key"; + private static final String OTHER_KEY = "other-key"; + + private final Template template = mock(Template.class); + private final TemplateContext templateInitialContext = mock(TemplateContext.class); + private ListNotification listNotification; + + public ListNotificationTest() { + when(template.getInitialContext()).thenReturn(templateInitialContext); + listNotification = new ListNotification(ID, KEY, template); + } + + @Test + public void creatingAListNotificationSetsEmptyIterableOnElementKeyInTemplateContext() { + verify(templateInitialContext).set(eq(KEY), argThat(emptyIterable())); + } + + @Test + public void newListNotificationHasNoElement() { + assertThat(listNotification.getElements(), emptyIterable()); + } + + @Test + public void newListNotificationIsEmpty() { + assertThat(listNotification.isEmpty(), is(true)); + } + + @Test + public void listNotificationRetainsSetElements() { + listNotification.setElements(Arrays.asList("a", "b", "c")); + assertThat(listNotification.getElements(), Matchers.contains("a", "b", "c")); + } + + @Test + public void listNotificationRetainsAddedElements() { + listNotification.add("a"); + listNotification.add("b"); + listNotification.add("c"); + assertThat(listNotification.getElements(), Matchers.contains("a", "b", "c")); + } + + @Test + public void listNotificationRemovesCorrectElement() { + listNotification.setElements(Arrays.asList("a", "b", "c")); + listNotification.remove("b"); + assertThat(listNotification.getElements(), Matchers.contains("a", "c")); + } + + @Test + public void removingTheLastElementDismissesTheNotification() { + NotificationListener notificationListener = mock(NotificationListener.class); + listNotification.addNotificationListener(notificationListener); + listNotification.add("a"); + listNotification.remove("a"); + verify(notificationListener).notificationDismissed(listNotification); + } + + @Test + public void dismissingTheListNotificationRemovesAllElements() { + listNotification.setElements(Arrays.asList("a", "b", "c")); + listNotification.dismiss(); + assertThat(listNotification.getElements(), emptyIterable()); + } + + @Test + public void listNotificationWithDifferentElementsIsNotEqual() { + ListNotification secondNotification = new ListNotification(ID, KEY, template); + listNotification.add("a"); + secondNotification.add("b"); + assertThat(listNotification, not(is(secondNotification))); + } + + @Test + public void listNotificationWithDifferentKeyIsNotEqual() { + ListNotification secondNotification = new ListNotification(ID, OTHER_KEY, template); + assertThat(listNotification, not(is(secondNotification))); + } + + @Test + public void copiedNotificationsHaveTheSameHashCode() { + ListNotification secondNotification = new ListNotification(listNotification); + listNotification.add("a"); + secondNotification.add("a"); + assertThat(listNotification.hashCode(), is(secondNotification.hashCode())); + } + + @Test + public void listNotificationIsNotEqualToOtherObjects() { + assertThat(listNotification, not(is(new Object()))); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/notify/PostVisibilityFilterTest.java b/src/test/java/net/pterodactylus/sone/notify/PostVisibilityFilterTest.java new file mode 100644 index 0000000..d49e59b --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/notify/PostVisibilityFilterTest.java @@ -0,0 +1,203 @@ +package net.pterodactylus.sone.notify; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.Identity; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; +import net.pterodactylus.sone.freenet.wot.Trust; + +import com.google.common.base.Optional; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.junit.Test; + +/** + * Unit test for {@link PostVisibilityFilterTest}. + * + * @author David ‘Bombe’ Roden + */ +public class PostVisibilityFilterTest { + + private static final String LOCAL_ID = "local-id"; + private static final String REMOTE_ID = "remote-id"; + + private final PostVisibilityFilter postVisibilityFilter = new PostVisibilityFilter(); + + private final Sone localSone = mock(Sone.class); + private final OwnIdentity localIdentity = mock(OwnIdentity.class); + private final Post post = mock(Post.class); + private final Sone remoteSone = mock(Sone.class); + private final Identity remoteIdentity = mock(Identity.class); + + public PostVisibilityFilterTest() { + when(localSone.getId()).thenReturn(LOCAL_ID); + when(localSone.isLocal()).thenReturn(true); + when(localSone.getIdentity()).thenReturn(localIdentity); + when(localIdentity.getId()).thenReturn(LOCAL_ID); + when(remoteSone.getId()).thenReturn(REMOTE_ID); + when(remoteSone.getIdentity()).thenReturn(remoteIdentity); + when(remoteIdentity.getId()).thenReturn(REMOTE_ID); + when(post.getRecipientId()).thenReturn(Optional.absent()); + } + + @Test + public void postVisibilityFilterIsOnlyCreatedOnce() { + Injector injector = Guice.createInjector(); + PostVisibilityFilter firstFilter = injector.getInstance(PostVisibilityFilter.class); + PostVisibilityFilter secondFilter = injector.getInstance(PostVisibilityFilter.class); + assertThat(firstFilter, sameInstance(secondFilter)); + } + + @Test + public void postIsNotVisibleIfItIsNotLoaded() { + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(false)); + } + + private static void makePostLoaded(Post post) { + when(post.isLoaded()).thenReturn(true); + } + + @Test + public void loadedPostIsVisibleWithoutSone() { + makePostLoaded(post); + assertThat(postVisibilityFilter.isPostVisible(null, post), is(true)); + } + + private void makePostComeFromTheFuture() { + when(post.getTime()).thenReturn(System.currentTimeMillis() + 1000); + } + + @Test + public void loadedPostFromTheFutureIsNotVisible() { + makePostLoaded(post); + makePostComeFromTheFuture(); + assertThat(postVisibilityFilter.isPostVisible(null, post), is(false)); + } + + private void makePostFromRemoteSone() { + when(post.getSone()).thenReturn(remoteSone); + } + + private void giveRemoteIdentityNegativeExplicitTrust() { + when(remoteIdentity.getTrust(localIdentity)).thenReturn(new Trust(-1, null, null)); + } + + @Test + public void loadedPostFromExplicitelyNotTrustedSoneIsNotVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + giveRemoteIdentityNegativeExplicitTrust(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(false)); + } + + private void giveRemoteIdentityNegativeImplicitTrust() { + when(remoteIdentity.getTrust(localIdentity)).thenReturn(new Trust(null, -1, null)); + } + + @Test + public void loadedPostFromImplicitelyUntrustedSoneIsNotVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + giveRemoteIdentityNegativeImplicitTrust(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(false)); + } + + private void makeLocalSoneFollowRemoteSone() { + when(localSone.hasFriend(REMOTE_ID)).thenReturn(true); + } + + private void giveRemoteIdentityPositiveExplicitTrustButNegativeImplicitTrust() { + when(remoteIdentity.getTrust(localIdentity)).thenReturn(new Trust(1, -1, null)); + } + + @Test + public void loadedPostFromExplicitelyTrustedButImplicitelyUntrustedSoneIsVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + makeLocalSoneFollowRemoteSone(); + giveRemoteIdentityPositiveExplicitTrustButNegativeImplicitTrust(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + private void giveTheRemoteIdentityPositiveImplicitTrust() { + when(remoteIdentity.getTrust(localIdentity)).thenReturn(new Trust(null, 1, null)); + } + + @Test + public void loadedPostFromImplicitelyTrustedSoneIsVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + makeLocalSoneFollowRemoteSone(); + giveTheRemoteIdentityPositiveImplicitTrust(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + private void giveTheRemoteIdentityUnknownTrust() { + when(remoteIdentity.getTrust(localIdentity)).thenReturn(new Trust(null, null, null)); + } + + @Test + public void loadedPostFromSoneWithUnknownTrustIsVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + makeLocalSoneFollowRemoteSone(); + giveTheRemoteIdentityUnknownTrust(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + @Test + public void loadedPostFromUnfollowedRemoteSoneThatIsNotDirectedAtLocalSoneIsNotVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(false)); + } + + private void makePostFromLocalSone() { + makePostLoaded(post); + when(post.getSone()).thenReturn(localSone); + } + + @Test + public void loadedPostFromLocalSoneIsVisible() { + makePostFromLocalSone(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + @Test + public void loadedPostFromFollowedRemoteSoneThatIsNotDirectedAtLocalSoneIsVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + makeLocalSoneFollowRemoteSone(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + private void makePostDirectedAtLocalId() { + when(post.getRecipientId()).thenReturn(Optional.of(LOCAL_ID)); + } + + @Test + public void loadedPostFromRemoteSoneThatIsDirectedAtLocalSoneIsVisible() { + makePostLoaded(post); + makePostFromRemoteSone(); + makePostDirectedAtLocalId(); + assertThat(postVisibilityFilter.isPostVisible(localSone, post), is(true)); + } + + @Test + public void predicateWillCorrectlyRecognizeVisiblePost() { + makePostFromLocalSone(); + assertThat(postVisibilityFilter.isVisible(null).apply(post), is(true)); + } + + @Test + public void predicateWillCorrectlyRecognizeNotVisiblePost() { + assertThat(postVisibilityFilter.isVisible(null).apply(post), is(false)); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.java b/src/test/java/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.java new file mode 100644 index 0000000..7187847 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/notify/ReplyVisibilityFilterTest.java @@ -0,0 +1,106 @@ +package net.pterodactylus.sone.notify; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; + +import com.google.common.base.Optional; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.junit.Test; + +/** + * Unit test for {@link ReplyVisibilityFilterTest}. + * + * @author David ‘Bombe’ Roden + */ +public class ReplyVisibilityFilterTest { + + private static final String LOCAL_ID = "local-id"; + + private final PostVisibilityFilter postVisibilityFilter = mock(PostVisibilityFilter.class); + private final ReplyVisibilityFilter replyVisibilityFilter = new ReplyVisibilityFilter(postVisibilityFilter); + + private final Sone localSone = mock(Sone.class); + private final OwnIdentity localIdentity = mock(OwnIdentity.class); + private final Post post = mock(Post.class); + private final PostReply postReply = mock(PostReply.class); + + public ReplyVisibilityFilterTest() { + when(localSone.getId()).thenReturn(LOCAL_ID); + when(localSone.isLocal()).thenReturn(true); + when(localSone.getIdentity()).thenReturn(localIdentity); + when(post.getRecipientId()).thenReturn(Optional.absent()); + } + + @Test + public void replyVisibilityFilterIsOnlyCreatedOnce() { + Injector injector = Guice.createInjector(); + ReplyVisibilityFilter firstFilter = injector.getInstance(ReplyVisibilityFilter.class); + ReplyVisibilityFilter secondFilter = injector.getInstance(ReplyVisibilityFilter.class); + assertThat(firstFilter, sameInstance(secondFilter)); + } + + private void makePostPresent() { + when(postReply.getPost()).thenReturn(Optional.of(post)); + } + + @Test + public void replyIsNotVisibleIfPostIsNotVisible() { + makePostPresent(); + assertThat(replyVisibilityFilter.isReplyVisible(localSone, postReply), is(false)); + } + + private void makePostAbsent() { + when(postReply.getPost()).thenReturn(Optional.absent()); + } + + @Test + public void replyIsNotVisibleIfPostIsNotPresent() { + makePostAbsent(); + assertThat(replyVisibilityFilter.isReplyVisible(localSone, postReply), is(false)); + } + + private void makePostPresentAndVisible() { + makePostPresent(); + when(postVisibilityFilter.isPostVisible(localSone, post)).thenReturn(true); + } + + private void makeReplyComeFromFuture() { + when(postReply.getTime()).thenReturn(System.currentTimeMillis() + 1000); + } + + @Test + public void replyIsNotVisibleIfItIsFromTheFuture() { + makePostPresentAndVisible(); + makeReplyComeFromFuture(); + assertThat(replyVisibilityFilter.isReplyVisible(localSone, postReply), is(false)); + } + + @Test + public void replyIsVisibleIfItIsNotFromTheFuture() { + makePostPresentAndVisible(); + assertThat(replyVisibilityFilter.isReplyVisible(localSone, postReply), is(true)); + } + + @Test + public void predicateCorrectlyRecognizesVisibleReply() { + makePostPresentAndVisible(); + assertThat(replyVisibilityFilter.isVisible(localSone).apply(postReply), is(true)); + } + + @Test + public void predicateCorrectlyRecognizesNotVisibleReply() { + makePostPresentAndVisible(); + makeReplyComeFromFuture(); + assertThat(replyVisibilityFilter.isVisible(localSone).apply(postReply), is(false)); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/template/AlbumAccessorTest.java b/src/test/java/net/pterodactylus/sone/template/AlbumAccessorTest.java index afc2a54..aace929 100644 --- a/src/test/java/net/pterodactylus/sone/template/AlbumAccessorTest.java +++ b/src/test/java/net/pterodactylus/sone/template/AlbumAccessorTest.java @@ -1,15 +1,22 @@ package net.pterodactylus.sone.template; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.hamcrest.Matchers.nullValue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import net.pterodactylus.sone.TestUtil; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.Image; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Sone; @@ -90,4 +97,25 @@ public class AlbumAccessorTest { }; } + @Test + public void albumImageIsGeneratedRandomly() { + Image image = mock(Image.class); + List albumImages = Arrays.asList(mock(Image.class), image); + when(album.getImages()).thenReturn(albumImages); + int matchedImage = 0; + for (int i = 0; i < 1000; i++) { + Image randomImage = (Image) albumAccessor.get(null, album, "albumImage"); + if (randomImage == image) { + matchedImage++; + } + } + assertThat(matchedImage, allOf(greaterThanOrEqualTo(250), lessThanOrEqualTo(750))); + } + + @Test + public void albumImageIsNullIfThereAreNoImagesInAnAlbum() { + when(album.getImages()).thenReturn(Collections.emptyList()); + assertThat(albumAccessor.get(null, album, "albumImage"), nullValue()); + } + } diff --git a/src/test/java/net/pterodactylus/sone/template/JavascriptFilterTest.java b/src/test/java/net/pterodactylus/sone/template/JavascriptFilterTest.java new file mode 100644 index 0000000..6718c5a --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/template/JavascriptFilterTest.java @@ -0,0 +1,56 @@ +package net.pterodactylus.sone.template; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import net.pterodactylus.util.number.Hex; + +import org.junit.Test; + +/** + * Unit test for {@link JavascriptFilter}. + * + * @author David ‘Bombe’ Roden + */ +public class JavascriptFilterTest { + + private final JavascriptFilter filter = new JavascriptFilter(); + + @Test + public void filterEscapesAllCharactersBelowSpace() { + String source = buildStringWithAllCharactersToEscape(); + String target = buildStringWithEscapedCharacters(); + assertThat((String) filter.format(null, source, null), is("\"" + target + "\"")); + } + + private String buildStringWithAllCharactersToEscape() { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < 32; i++) { + stringBuilder.append((char) i); + } + stringBuilder.append('"').append("\\").append("!"); + return stringBuilder.toString(); + } + + private String buildStringWithEscapedCharacters() { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < 32; i++) { + switch (i) { + case 9: + stringBuilder.append("\\t"); + break; + case 10: + stringBuilder.append("\\n"); + break; + case 13: + stringBuilder.append("\\r"); + break; + default: + stringBuilder.append("\\x").append(Hex.toHex(i, 2)); + } + } + stringBuilder.append("\\\"").append("\\\\").append("!"); + return stringBuilder.toString(); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index 051c235..7a06dcf 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -1,5 +1,5 @@ /* - * Sone - SoneTextParserTest.java - Copyright © 2011–2015 David Roden + * Sone - SoneTextParserTest.java - Copyright © 2011–2016 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 @@ -18,7 +18,6 @@ package net.pterodactylus.sone.text; import java.io.IOException; -import java.io.StringReader; import java.util.Arrays; import java.util.Collection; @@ -53,17 +52,17 @@ public class SoneTextParserTest extends TestCase { Iterable parts; /* check basic operation. */ - parts = soneTextParser.parse(null, new StringReader("Test.")); + parts = soneTextParser.parse("Test.", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Test.", convertText(parts, PlainTextPart.class)); /* check empty lines at start and end. */ - parts = soneTextParser.parse(null, new StringReader("\nTest.\n\n")); + parts = soneTextParser.parse("\nTest.\n\n", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Test.", convertText(parts, PlainTextPart.class)); /* check duplicate empty lines in the text. */ - parts = soneTextParser.parse(null, new StringReader("\nTest.\n\n\nTest.")); + parts = soneTextParser.parse("\nTest.\n\n\nTest.", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Test.\n\nTest.", convertText(parts, PlainTextPart.class)); } @@ -80,17 +79,17 @@ public class SoneTextParserTest extends TestCase { Iterable parts; /* check basic links. */ - parts = soneTextParser.parse(null, new StringReader("KSK@gpl.txt")); + parts = soneTextParser.parse("KSK@gpl.txt", null); assertNotNull("Parts", parts); assertEquals("Part Text", "[KSK@gpl.txt|gpl.txt|gpl.txt]", convertText(parts, FreenetLinkPart.class)); /* check embedded links. */ - parts = soneTextParser.parse(null, new StringReader("Link is KSK@gpl.txt\u200b.")); + parts = soneTextParser.parse("Link is KSK@gpl.txt\u200b.", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\u200b.", convertText(parts, PlainTextPart.class, FreenetLinkPart.class)); /* check embedded links and line breaks. */ - parts = soneTextParser.parse(null, new StringReader("Link is KSK@gpl.txt\nKSK@test.dat\n")); + parts = soneTextParser.parse("Link is KSK@gpl.txt\nKSK@test.dat\n", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\n[KSK@test.dat|test.dat|test.dat]", convertText(parts, PlainTextPart.class, FreenetLinkPart.class)); } @@ -107,7 +106,7 @@ public class SoneTextParserTest extends TestCase { Iterable parts; /* check basic links. */ - parts = soneTextParser.parse(null, new StringReader("Some text.\n\nLink to sone://DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU and stuff.")); + parts = soneTextParser.parse("Some text.\n\nLink to sone://DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU and stuff.", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Some text.\n\nLink to [Sone|DAxKQzS48mtaQc7sUVHIgx3fnWZPQBz0EueBreUVWrU] and stuff.", convertText(parts, PlainTextPart.class, SonePart.class)); } @@ -125,7 +124,7 @@ public class SoneTextParserTest extends TestCase { Iterable parts; /* check empty http links. */ - parts = soneTextParser.parse(null, new StringReader("Some text. Empty link: http:// – nice!")); + parts = soneTextParser.parse("Some text. Empty link: http:// – nice!", null); assertNotNull("Parts", parts); assertEquals("Part Text", "Some text. Empty link: http:// – nice!", convertText(parts, PlainTextPart.class)); } diff --git a/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java b/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java new file mode 100644 index 0000000..80c8a2f --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/DeleteReplyPageTest.java @@ -0,0 +1,65 @@ +package net.pterodactylus.sone.web; + +import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Collections; + +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.web.page.FreenetRequest; +import net.pterodactylus.util.notify.Notification; +import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; + +import freenet.support.api.HTTPRequest; + +import com.google.common.base.Optional; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Matchers; + +/** + * Unit test for {@link DeleteReplyPage}. + * + * @author David ‘Bombe’ Roden + */ +public class DeleteReplyPageTest { + + @Rule + public final ExpectedException expectedException = ExpectedException.none(); + + private final Template template = new Template(); + private final WebInterface webInterface = mock(WebInterface.class, RETURNS_DEEP_STUBS); + private final DeleteReplyPage page = new DeleteReplyPage(template, webInterface); + private final TemplateContext templateContext = new TemplateContext(); + private final FreenetRequest freenetRequest = mock(FreenetRequest.class); + private final HTTPRequest httpRequest = mock(HTTPRequest.class); + + @Before + public void setupWebInterface() { + when(webInterface.getNotifications(Matchers.any(Sone.class))).thenReturn(Collections.emptyList()); + } + + @Before + public void setupHttpRequest() { + when(freenetRequest.getHttpRequest()).thenReturn(httpRequest); + } + + @Test + public void tryingToDeleteAReplyWithAnInvalidIdResultsInNoPermissionPage() throws Exception { + when(freenetRequest.getMethod()).thenReturn(Method.POST); + when(httpRequest.getPartAsStringFailsafe(eq("reply"), anyInt())).thenReturn("id"); + when(webInterface.getCore().getPostReply("id")).thenReturn(Optional.absent()); + expectedException.expect(redirectsTo("noPermission.html")); + page.processTemplate(freenetRequest, templateContext); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/web/NewPageTest.java b/src/test/java/net/pterodactylus/sone/web/NewPageTest.java new file mode 100644 index 0000000..b527e58 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/NewPageTest.java @@ -0,0 +1,74 @@ +package net.pterodactylus.sone.web; + +import static java.util.Arrays.asList; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.Collections; +import java.util.List; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.web.page.FreenetRequest; +import net.pterodactylus.util.notify.Notification; +import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; + +import freenet.clients.http.ToadletContext; + +import com.google.common.base.Optional; +import org.junit.Before; +import org.junit.Test; + +/** + * Unit test for {@link NewPage}. + * + * @author David ‘Bombe’ Roden + */ +public class NewPageTest { + + private final Template template = mock(Template.class); + private final WebInterface webInterface = mock(WebInterface.class, RETURNS_DEEP_STUBS); + private final NewPage newPage = new NewPage(template, webInterface); + private final Sone currentSone = mock(Sone.class); + private final TemplateContext templateContext = new TemplateContext(); + private final FreenetRequest freenetRequest = mock(FreenetRequest.class, RETURNS_DEEP_STUBS); + + @Before + public void setupFreenetRequest() { + when(freenetRequest.getToadletContext()).thenReturn(mock(ToadletContext.class)); + } + + @Before + public void setupWebInterface() { + when(webInterface.getCore().getPreferences().getPostsPerPage()).thenReturn(5); + when(webInterface.getCurrentSone(any(ToadletContext.class), anyBoolean())).thenReturn(currentSone); + when(webInterface.getNotifications(any(Sone.class))).thenReturn(Collections.emptyList()); + } + + @Test + public void postsAreNotDuplicatedWhenTheyComeFromBothNewPostsAndNewRepliesNotifications() throws Exception { + // given + Post extraPost = mock(Post.class); + List posts = asList(mock(Post.class), mock(Post.class)); + List postReplies = asList(mock(PostReply.class), mock(PostReply.class)); + when(postReplies.get(0).getPost()).thenReturn(Optional.of(posts.get(0))); + when(postReplies.get(1).getPost()).thenReturn(Optional.of(extraPost)); + when(webInterface.getNewPosts(currentSone)).thenReturn(posts); + when(webInterface.getNewReplies(currentSone)).thenReturn(postReplies); + + // when + newPage.processTemplate(freenetRequest, templateContext); + + // then + List renderedPosts = templateContext.get("posts", List.class); + assertThat(renderedPosts, containsInAnyOrder(posts.get(0), posts.get(1), extraPost)); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/web/UploadImagePageTest.java b/src/test/java/net/pterodactylus/sone/web/UploadImagePageTest.java new file mode 100644 index 0000000..e74efbd --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/UploadImagePageTest.java @@ -0,0 +1,73 @@ +package net.pterodactylus.sone.web; + +import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyInt; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.net.URI; + +import net.pterodactylus.sone.core.Core; +import net.pterodactylus.sone.core.UpdateChecker; +import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.web.page.FreenetRequest; +import net.pterodactylus.util.template.Template; +import net.pterodactylus.util.template.TemplateContext; +import net.pterodactylus.util.web.Method; + +import freenet.clients.http.ToadletContext; +import freenet.support.api.HTTPRequest; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +/** + * Unit test for {@link UploadImagePageTest}. + * + * @author David ‘Bombe’ Roden + */ +public class UploadImagePageTest { + + @Rule + public final ExpectedException expectedException = ExpectedException.none(); + + private final Template template = new Template(); + private final WebInterface webInterface = mock(WebInterface.class); + private final UploadImagePage uploadImagePage = new UploadImagePage(template, webInterface); + + private final TemplateContext templateContext = new TemplateContext(); + private final HTTPRequest httpRequest = mock(HTTPRequest.class); + private final ToadletContext toadletContext = mock(ToadletContext.class); + private final Core core = mock(Core.class); + private final Sone currentSone = mock(Sone.class); + private final Album parentAlbum = mock(Album.class); + + @Before + public void setupWebInterface() { + UpdateChecker updateChecker = mock(UpdateChecker.class); + when(core.getUpdateChecker()).thenReturn(updateChecker); + when(webInterface.getCore()).thenReturn(core); + when(webInterface.getCurrentSone(any(ToadletContext.class))).thenReturn(currentSone); + } + + @Before + public void setupParentAlbum() { + when(core.getAlbum("parent-id")).thenReturn(parentAlbum); + when(parentAlbum.getSone()).thenReturn(currentSone); + } + + @Test + public void uploadingAnImageWithoutTitleRedirectsToEmptyImageTitlePage() throws Exception { + FreenetRequest request = new FreenetRequest(new URI(""), Method.POST, httpRequest, toadletContext); + when(httpRequest.getPartAsStringFailsafe(eq("parent"), anyInt())).thenReturn("parent-id"); + when(httpRequest.getPartAsStringFailsafe(eq("title"), anyInt())).thenReturn(" "); + expectedException.expect(redirectsTo("emptyImageTitle.html")); + uploadImagePage.processTemplate(request, templateContext); + } + +} diff --git a/src/test/java/net/pterodactylus/sone/web/WebTestUtils.java b/src/test/java/net/pterodactylus/sone/web/WebTestUtils.java new file mode 100644 index 0000000..d4e7596 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/WebTestUtils.java @@ -0,0 +1,37 @@ +package net.pterodactylus.sone.web; + +import javax.annotation.Nonnull; + +import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeDiagnosingMatcher; + +/** + * Utilities for testing the web package. + * + * @author David ‘Bombe’ Roden + */ +public class WebTestUtils { + + @Nonnull + public static Matcher redirectsTo(@Nonnull final String page) { + return new TypeSafeDiagnosingMatcher() { + @Override + protected boolean matchesSafely(RedirectException exception, Description mismatchDescription) { + if (!exception.getTarget().equals(page)) { + mismatchDescription.appendText("target is ").appendValue(exception.getTarget()); + return false; + } + return true; + } + + @Override + public void describeTo(Description description) { + description.appendText("target is ").appendValue(page); + } + }; + } + +} diff --git a/src/test/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPageTest.java b/src/test/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPageTest.java new file mode 100644 index 0000000..e1ab857 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPageTest.java @@ -0,0 +1,39 @@ +package net.pterodactylus.sone.web.ajax; + +import static java.lang.System.currentTimeMillis; +import static net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.getTime; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.when; + +import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage.Time; + +import org.junit.Test; +import org.mockito.Mockito; + +/** + * Unit test for {@link GetTimesAjaxPage}. + * + * @author David ‘Bombe’ Roden + */ +public class GetTimesAjaxPageTest { + + private final WebInterface webInterface = Mockito.mock(WebInterface.class, RETURNS_DEEP_STUBS); + + @Test + public void timestampInTheFutureIsTranslatedCorrectly() { + when(webInterface.getL10n().getString("View.Time.InTheFuture")).thenReturn("in the future"); + Time time = getTime(webInterface, currentTimeMillis() + 100); + assertThat(time.getText(), is("in the future")); + } + + @Test + public void timestampAFewSecondsAgoIsTranslatedCorrectly() { + when(webInterface.getL10n().getString("View.Time.AFewSecondsAgo")).thenReturn("a few seconds ago"); + Time time = getTime(webInterface, currentTimeMillis() - 1000); + assertThat(time.getText(), is("a few seconds ago")); + } + +}