Author: amarkhel
Date: 2009-03-23 12:37:30 -0400 (Mon, 23 Mar 2009)
New Revision: 13112
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
Log:
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-03-23
15:36:04 UTC (rev 13111)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-03-23
16:37:30 UTC (rev 13112)
@@ -37,8 +37,12 @@
import org.richfaces.model.UploadItem;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.manager.FileManager;
+import org.richfaces.realworld.manager.ImageManager;
import org.richfaces.realworld.manager.Model;
+import org.richfaces.realworld.manager.NavigationEnum;
import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.IImageAction;
+import org.richfaces.realworld.util.FlushStrategy;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.imaging.jpeg.JpegProcessingException;
@@ -62,6 +66,8 @@
@In("#{messages['file_saving_error']}")
private String FILE_SAVE_ERROR;
+ @In IImageAction imageAction;
+ @In FlushStrategy flushStrategy;
@In @Out
FileWrapper fileWrapper;
@@ -79,7 +85,7 @@
public synchronized void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
Image image = constructImage(item);
- fileManager.writeFile(item.getFile().getPath(), item.getFile().getPath(),
"_mini", 100, false);
+ //fileManager.writeFile(item.getFile().getPath(), item.getFile().getPath(),
"_mini", 100, false);
try {
extractMetadata(item, image);
} catch (JpegProcessingException e1) {
@@ -90,10 +96,14 @@
return;
}
image.setAlbum(model.getSelectedAlbum());
+ String newPath = model.getSelectedAlbum().getOwner().getLogin() + "/" +
model.getSelectedAlbum().getName() + "/" +item.getFileName();
+ image.setPath(newPath);
fileWrapper.getFiles().add(image);
- if(!fileManager.addImage(item.getFileName(), item.getFile().getPath())){
+ if(!fileManager.addImage(newPath, item.getFile().getPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_SAVE_ERROR));
}
+ imageAction.addImage(image, flushStrategy.isDatabaseStoreStrategy());
+ Events.instance().raiseEvent("imageAdded");
item.getFile().delete();
}
Show replies by date