From: David ‘Bombe’ Roden Date: Sat, 12 Jan 2013 16:41:27 +0000 (+0100) Subject: Merge branch 'next' into new-database-38 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=refs%2Fheads%2Fnew-database-38;p=Sone.git Merge branch 'next' into new-database-38 Conflicts: src/main/java/net/pterodactylus/sone/core/Core.java src/main/java/net/pterodactylus/sone/web/SearchPage.java --- 771e8efcd92c7325423441d57c5a6ed90a835e6f diff --cc src/main/java/net/pterodactylus/sone/core/Core.java index 0b1379a,5843b30..1bb638a --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@@ -1429,7 -1580,8 +1442,8 @@@ public class Core extends AbstractServi * @return The created post */ public Post createPost(Sone sone, Sone recipient, long time, String text) { + Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.length(), 0).check(); - if (!isLocalSone(sone)) { + if (!sone.isLocal()) { logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone)); return null; } @@@ -1569,7 -1721,8 +1583,8 @@@ * @return The created reply */ public PostReply createReply(Sone sone, Post post, long time, String text) { + Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.trim().length(), 0).check(); - if (!isLocalSone(sone)) { + if (!sone.isLocal()) { logger.log(Level.FINE, String.format("Tried to create reply for non-local Sone: %s", sone)); return null; } diff --cc src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 42e2fe1,5b28b85..1bc8b5a --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@@ -188,12 -186,8 +188,11 @@@ public class SonePlugin implements Fred /* create web of trust connector. */ PluginConnector pluginConnector = new PluginConnector(pluginRespirator); webOfTrustConnector = new WebOfTrustConnector(pluginConnector); - identityManager = new IdentityManager(webOfTrustConnector); - identityManager.setContext("Sone"); + identityManager = new IdentityManager(webOfTrustConnector, "Sone"); + /* create Sone database. */ + Database soneDatabase = new MemoryDatabase(); + /* create trust updater. */ WebOfTrustUpdater trustUpdater = new WebOfTrustUpdater(webOfTrustConnector); trustUpdater.init(); diff --cc src/main/java/net/pterodactylus/sone/web/SearchPage.java index 691453d,0f12abf..524e501 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@@ -111,7 -111,27 +111,27 @@@ public class SearchPage extends SoneTem throw new RedirectException("index.html"); } + /* check for a couple of shortcuts. */ + if (phrases.size() == 1) { + String phrase = phrases.get(0).getPhrase(); + + /* is it a Sone ID? */ + redirectIfNotNull(getSoneId(phrase), "viewSone.html?sone="); + + /* is it a post ID? */ + redirectIfNotNull(getPostId(phrase), "viewPost.html?post="); + + /* is it a reply ID? show the post. */ + redirectIfNotNull(getReplyPostId(phrase), "viewPost.html?post="); + + /* is it an album ID? */ + redirectIfNotNull(getAlbumId(phrase), "imageBrowser.html?album="); + + /* is it an image ID? */ + redirectIfNotNull(getImageId(phrase), "imageBrowser.html?image="); + } + - Set sones = webInterface.getCore().getSones(); + Collection sones = webInterface.getCore().getSones(); Set> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR); Set> postHits;