This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ... | |
| registry.addInterceptor(new LocaleChangeInterceptor()); | |
| // ... | |
| @Bean | |
| public LocaleResolver localeResolver() { | |
| SessionLocaleResolver sessionLocaleResolver = new SessionLocaleResolver(); | |
| sessionLocaleResolver.setDefaultLocale(Locale.ENGLISH); | |
| return sessionLocaleResolver; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_ENTRY_URL, method = RequestMethod.GET) | |
| @ResponseBody | |
| public User getUserById(@PathVariable("userId") Long userId) { | |
| return this.userService.getUserById(userId); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static public final String USER_COLLECTION_URL = "/api/users"; | |
| static public final String USER_COLLECTION_ENTRY_URL = USER_COLLECTION_URL + "/{userId}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "id":58, | |
| "customers":null, | |
| "importedFromServiceProvider":true, | |
| "firstName":"Josh", | |
| "lastName":"Long", | |
| "username":"josh@joshlong.com", | |
| "password":"myPassword", | |
| "profilePhotoImported":true, | |
| "profilePhotoExt":null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
| <user | |
| username="josh@joshlong.com" | |
| signupDate="2013-02-21T23:38:30.936-08:00" | |
| profilePhotoImported="true" | |
| password="myPassword" | |
| lastName="Long" | |
| importedFromServiceProvider="true" | |
| id="58" | |
| firstName="Josh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.POST) | |
| @ResponseBody | |
| public Long uploadBasedOnPathVariable(@PathVariable("userId") Long userId, @RequestParam("file") MultipartFile file) throws Throwable { | |
| // ... | |
| } | |
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.GET) | |
| public void renderMedia(HttpServletResponse httpServletResponse, OutputStream os, @PathVariable("userId") Long userId) throws Throwable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.POST) | |
| @ResponseBody | |
| public Long uploadBasedOnPathVariable(@PathVariable("userId") Long userId, @RequestParam("file") MultipartFile file) throws Throwable { | |
| byte[] bytesForImage = file.getBytes(); | |
| userService.writeUserProfilePhotoAndQueueForConversion(userId, file.getName(), bytesForImage); | |
| return userId; | |
| } | |
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.GET) | |
| public void renderMedia(HttpServletResponse httpServletResponse, OutputStream os, @PathVariable("userId") Long userId) throws Throwable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_URL, method = RequestMethod.POST) | |
| public ResponseEntity<User> registerUser(@RequestParam("username") String username, | |
| @RequestParam("password") String password, | |
| @RequestParam("firstname") String fn, | |
| @RequestParam("lastname") String ln, | |
| @RequestParam("imported") boolean importedFromServiceProvider, | |
| UriComponentsBuilder componentsBuilder) throws Throwable { | |
| User user = this.userService.createOrGet(username, password, fn, ln, importedFromServiceProvider); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.POST) | |
| @ResponseBody | |
| public Long uploadBasedOnPathVariable(@PathVariable("userId") Long userId, @RequestParam("file") MultipartFile file) throws Throwable { | |
| byte[] bytesForImage = file.getBytes(); | |
| userService.writeUserProfilePhotoAndQueueForConversion(userId, file.getName(), bytesForImage); | |
| return userId; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(value = USER_COLLECTION_ENTRY_PHOTO_URL, method = RequestMethod.GET) | |
| public ResponseEntity<byte[]> renderMedia(@PathVariable("userId") Long userId) throws Throwable { | |
| InputStream is = userService.readUserProfilePhoto(userId); | |
| HttpHeaders httpHeaders = new HttpHeaders(); | |
| httpHeaders.setContentType(MediaType.IMAGE_JPEG); | |
| byte buffer[] = IOUtils.toByteArray(is); | |
| return new ResponseEntity<byte[]>(buffer, httpHeaders, HttpStatus.OK); | |
| } |