throws Exception {
if (log.isDebugEnabled()) {
log.debug("entering 'onSubmit' method...");
}
Hint hint = (Hint) command;
boolean isNew = (hint.getHintId() == null);
Locale locale = request.getLocale();
if (request.getParameter("delete") != null) {
hintManager.removeHint(hint.getHintId().toString());
saveMessage(request, getText("hint.deleted", locale));
} else {
MultipartHttpServletRequest multipartRequest =
(MultipartHttpServletRequest) request;
CommonsMultipartFile file =
(CommonsMultipartFile) multipartRequest.getFile("file");
if (file.getSize() > 0) {
String fileName = ImageUtil.getUniqueJPEGFile(request);
FileOutputStream fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
fileOutputStream.write(file.getBytes());
fileOutputStream.close();
InputStream imageStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 200, 200);
fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileName);
byte[] bufer = new byte[62000];
while (imageStream.read(bufer) != -1) {
fileOutputStream.write(bufer);
}
fileOutputStream.close();
hint.setWayToPhoto(fileName);
hint.setPhotoBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + fileName)));
InputStream imageSmallStream = ImageUtil.scaleImage(new FileInputStream(FileHelper.getCurrentPath(request) + fileName), 50, 50);
String fileSmallName = ImageUtil.getUniqueJPEGFile(request);
fileOutputStream = new FileOutputStream(FileHelper.getCurrentPath(request) + fileSmallName);
bufer = new byte[62000];
while (imageSmallStream.read(bufer) != -1) {
fileOutputStream.write(bufer);
}
fileOutputStream.close();
hint.setWayToSmallPhoto(fileSmallName);
hint.setPhotoSmallBlob(Hibernate.createBlob(new FileInputStream(FileHelper.getCurrentPath(request) + fileSmallName)));
} else {
if (!isNew) {
Hint curHint = hintManager.getHint(hint.getHintId().toString());
hint.setWayToSmallPhoto(curHint.getWayToSmallPhoto());
hint.setPhotoSmallBlob(curHint.getPhotoSmallBlob());
hint.setWayToPhoto(curHint.getWayToPhoto());
hint.setPhotoBlob(curHint.getPhotoBlob());
hintManager.evict(curHint);
}
}
List questionList = hint.getQuestions();