@Security.Authenticated(Secured.class) public static Result viewMyConversation(Long id) { Student s = Student.find.byId(request().username()); Conversation c = Conversation.find.byId(id.toString()); if (!c.getParticipants().contains(s)) { // unauthorized access! return redirect(routes.Application.viewMyConversations()); } else { // mark all read for (Message m : c.messages) { if (!m.sender.email.equals(s.email)) { m.setRead(); m.save(); } } return ok(viewConversation.render(s, c, form(MessageForm.class))); } }
public Result onLabel() { long millis = System.currentTimeMillis() % 1000; long result = millis - currentTimestamp; currentTimestamp = System.currentTimeMillis() % 1000; String label = request().getQueryString("action"); String id = request().getQueryString("id"); String reason = request() .getQueryString( "reason"); // remove the cluster header from Tweets and add it to labelled at the // end. String databaseName = request().getQueryString("databaseName"); String timestamp = Long.toString(result); DataAccess.labelTweet(databaseName, id, label, timestamp); TweetDTO tweetDTO = DataAccess.getNextTweet(databaseName); return ok(labelling.render(tweetDTO, databaseName)); }
@Security.Authenticated(Secured.class) public static Result addNewMessageForm(Long id) { Form<MessageForm> mesForm = Form.form(MessageForm.class).bindFromRequest(); if (mesForm.hasErrors()) { return badRequest(postNewMessage.render(mesForm, id)); } else { Message m = new Message( mesForm.field("text").value().toString(), Student.find.byId(request().username())); Conversation c = null; c = Conversation.find.byId(id.toString()); c.messages.add(m); c.save(); return redirect(routes.Application.viewMyConversation(id)); } }