@RequestMapping(value = "/addfriend", method = RequestMethod.POST) @Transactional public String postAddFriend( Model model, final AddFriendForm addFriendForm, BindingResult result) { final User user = service.getCurrentUser(); // from SocialUserImpl userImpl = socailUserRepo.findOne(user.getId()); final AddFriendLinkImpl link = linkRepo.findOne(addFriendForm.getId()); SocialRelationshipImpl relation = socialRelationRepo.findByFrom_IdAndTo_Id(user.getId(), link.getUser().getId()); if (relation == null) { relation = new SocialRelationshipImpl(); relation.setId(userImpl.getId() + "_" + link.getUser().getId()); relation.setFrom(userImpl); relation.setTo(link.getUser()); // check whether reverse relation exists SocialRelationshipImpl reverse = socialRelationRepo.findByFrom_IdAndTo_Id(link.getUser().getId(), userImpl.getId()); if (reverse == null) { // TODO something here AddFriendRequestImpl request = new AddFriendRequestImpl(); request.setFrom(userImpl); request.setTo(link.getUser()); request.setMessage( userImpl.getNickname() + " accept your add friend link, he also want to add you as friend!"); request.setType(AddFriendRequestType.CONFIRM); request.setCreateDate(new Date()); addFriendRequestRepo.save(request); } } relation.setLastUpdate(new Date()); relation.setRating(addFriendForm.getRating()); relation.setRelationType(Arrays.toString(addFriendForm.getFriendshipType())); socialRelationRepo.save(relation); // dfggffg /** * jmsTemplate.send(new MessageCreator() { public Message createMessage(Session session) throws * JMSException { // return session.createTextMessage("hello queue world"); AddRelationCommand * command = new AddRelationCommand(); command.setFromUser(user.getId()); * command.setToUser(link.getUser().getId()); * command.setTypes(addFriendForm.getFriendshipType()); * command.setRating(addFriendForm.getRating()); return session.createObjectMessage(command); } * }); */ return "redirect:/user/index.do"; }