ModelAndView returnMav = toUpload(albumId);
return processValidationErrors("errMsg", errMsg, returnMav);
}
long userId = user.getId();
Album album = albumService.getAlbumForChange(albumId, userId);
List<MultipartFile> files = request.getFiles("file");
StringBuilder message = new StringBuilder();
List<SkylineImageResizeTask> tasks = prepareResizeTask(files, userId, albumId, message);
if (CollectionUtils.isEmpty(tasks)) {
ModelAndView mav = new ModelAndView(ViewPaths.ALBUM_TOUPLOAD);
mav.addObject("message", "没有找到您想传的图片");
mav.addObject("album", album);
return mav;
}
List<ImageResizeResult> results = imagine.processImage(localStorePath, tasks);
List<ImageResizeResult> filesInfo = processResizeResult(results, message);
List<Photo> photos = null;
if (!CollectionUtils.isEmpty(filesInfo)) {
photos = albumService.createPhotos(user, album, filesInfo);
}
ModelAndView mav = new ModelAndView(ViewPaths.ALBUM_UPLOADOK);
mav.addObject("album", album);
mav.addObject("message", message);
Map<Long, List<Photo>> filesMap = (Map<Long, List<Photo>>) WebHelper.getSessionAttribute(
request, Constant.SESSION_UPLOAD_OK_FILES);
if (filesMap == null) {
filesMap = new HashMap<Long, List<Photo>>();
}
filesMap.put(album.getId(), photos);
WebHelper.setSessionAttribute(request, Constant.SESSION_UPLOAD_OK_FILES, filesMap);
return mav;
}