/** A-Team feature: forming xml|json files with notes 26-04-2012 */ @RequestMapping(value = "/api/user/notes", method = RequestMethod.GET) public String exportExecute( @RequestParam Map<String, Object> reqMap, @RequestParam("email") String email, @RequestParam("pass") String password, @RequestParam("type") String formatXmlJson, HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out = response.getWriter(); response.setContentType("text/plain"); User currentUser = null; currentUser = userService.getUserByEmail(email); String encodedPass = passwordEncoder.encodePassword(password, null); if (currentUser != null && encodedPass.equals(currentUser.getPassword())) { List<Record> records = recordService.getRecords( currentUser, accessService.getAccess(2), recordTypeService.getRecordType(1), ""); xmlService = new XMLService(); if (formatXmlJson.equals("xml")) { xmlService.formXml(records, currentUser, accessService.getAccess(2)); } else { xmlService.formJson(records, currentUser, accessService.getAccess(2)); } out.print(xmlService.getXmlText().toString()); out.close(); } else { out.println("Access denied"); out.close(); } return null; }
private User getCurrentUser() { String login = SecurityContextHolder.getContext().getAuthentication().getName(); User currentuser = userService.getUserByLogin(login); return currentuser; }
@RequestMapping(value = "/userlist.html") public String userList(Locale locale, Model model) { model.addAttribute("currentuser", getCurrentUser()); model.addAttribute("userList", userService.userList()); return "userlist"; }