Merge branch 'next' into new-database-38 new-database-38
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Jan 2013 16:41:27 +0000 (17:41 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 14 Jan 2013 05:32:50 +0000 (06:32 +0100)
Conflicts:
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/web/SearchPage.java

1  2 
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/text/SoneTextParser.java
src/main/java/net/pterodactylus/sone/web/SearchPage.java
src/main/java/net/pterodactylus/sone/web/WebInterface.java
src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.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) {
 -              if (!isLocalSone(sone)) {
+               Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.length(), 0).check();
 +              if (!sone.isLocal()) {
                        logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone));
                        return null;
                }
         * @return The created reply
         */
        public PostReply createReply(Sone sone, Post post, long time, String text) {
 -              if (!isLocalSone(sone)) {
+               Validation.begin().isNotNull("Text", text).check().isGreater("Text Length", text.trim().length(), 0).check();
 +              if (!sone.isLocal()) {
                        logger.log(Level.FINE, String.format("Tried to create reply for non-local Sone: %s", sone));
                        return null;
                }
@@@ -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();
@@@ -111,7 -111,27 +111,27 @@@ public class SearchPage extends SoneTem
                        throw new RedirectException("index.html");
                }
  
 -              Set<Sone> sones = webInterface.getCore().getSones();
+               /* 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=");
+               }
 +              Collection<Sone> sones = webInterface.getCore().getSones();
                Set<Hit<Sone>> soneHits = getHits(sones, phrases, SoneStringGenerator.COMPLETE_GENERATOR);
  
                Set<Hit<Post>> postHits;