return;
}
try {
Album album =albumService.getAlbumById(albumId);
Spot spot=spotService.getSpot(spotId);
MultipartFile file = ((MultipartHttpServletRequest) request).getFile("file");
if (file == null) {
jsonMap = resultToJsonMap(ResultState.NO_FILE_EXIST, null);
OutputStream out = response.getOutputStream();
outputJsonResult(out, jsonMap);
return;
}
MultipartImageResizeTask resizeTask = new MultipartImageResizeTask(file, baseSizes,
null, false);
resizeTask.setAlbumId(albumId);
resizeTask.setUserId(spotId);
resizeTask.setSupportMulitFrame(false);
ImageResizeResult processResult = imagine.processSingleImage(basePath, resizeTask);
ResultState resultState = processResult.getResultState();
if (resultState != ResultState.SUCCESS) {
jsonMap = resultToJsonMap(resultState, null);
OutputStream out = response.getOutputStream();
outputJsonResult(out, jsonMap);
return;
}
/**
* 构造一个spot的user
*/
User tempuser=new User();
tempuser.setId(spot.getId());
tempuser.setNickname(spot.getName());
tempuser.setPortrait(spot.getPortrait());
Photo portrait = albumService.createPortraitPhoto(tempuser, album, processResult);
String smallFile = portrait.getSmallFile();
String ext = portrait.getExt();
String remoteFileKey = smallFile + '.' + ext;
SkylineImageCropTask cropTask = new SkylineImageCropTask(remoteFileKey, portraitSize);
cropTask.setAlbumId(albumId);
cropTask.setUserId(spotId);
ImageCropResult cropResult = crop.processImage(basePath, cropTask);
String portraitFile = cropResult.getFileKey();
spotService.updateSpotPortrait(spotId, portraitFile);
spot.setPortrait(portraitFile);
//WebHelper.setSessionAttribute(request, Constant.SESSION_USER, user);
jsonMap = toJsonMap(true, "上传头像成功");
jsonMap.put("fileKey", remoteFileKey);
} catch (Exception e) {