@Override public void addMail(String username, String mail, String password) { // TODO Auto-generated method stub username = "******"; User user = userRepository.findOne(username); user.addMail(mail, password); userRepository.saveAndFlush(user); }
@Override public void deleteMessage(String username, String message) { // TODO Auto-generated method stub username = "******"; User user = userRepository.findOne(username); System.out.println("MESSAGE"); System.out.println(message); Iterator<HashMap<String, String>> iter = user.inbox.iterator(); ArrayList<HashMap<String, String>> newInbox = new ArrayList<HashMap<String, String>>(); ArrayList<HashMap<String, String>> newSent = new ArrayList<HashMap<String, String>>(); while (iter.hasNext()) { HashMap<String, String> messageMap = iter.next(); if (messageMap.containsKey(message)) { user.deleted.add(messageMap); iter.remove(); } else { newInbox.add(messageMap); } } user.inbox.clear(); user.inbox = newInbox; Iterator<HashMap<String, String>> iterSent = user.sent.iterator(); while (iterSent.hasNext()) { HashMap<String, String> messageMap = iterSent.next(); if (messageMap.containsKey(message)) { iterSent.remove(); } else { newSent.add(messageMap); } } user.sent.clear(); user.sent = newSent; userRepository.saveAndFlush(user); }