* @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;
}
/* 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();
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;