Author: amarkhel
Date: 2009-03-23 10:09:13 -0400 (Mon, 23 Mar 2009)
New Revision: 13104
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/FileWrapper.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
14:02:33 UTC (rev 13103)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-03-23
14:09:13 UTC (rev 13104)
@@ -78,15 +78,10 @@
public synchronized void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
- FileItem file = new FileItem();
- file.setLength(item.getFileSize());
- file.setFile(item.getFile());
- file.setSelected(false);
- file.setName(event.getUploadItem().getFileName());
- Image image = constructImage(item, file);
- fileManager.writeFile(file.getFile().getPath(), file.getFile().getPath(),
"_mini", 100, false);
+ Image image = constructImage(item);
+ fileManager.writeFile(item.getFile().getPath(), item.getFile().getPath(),
"_mini", 100, false);
try {
- extractMetadata(file, image);
+ extractMetadata(item, image);
} catch (JpegProcessingException e1) {
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
return;
@@ -95,26 +90,25 @@
return;
}
image.setAlbum(model.getSelectedAlbum());
- file.setImage(image);
- fileWrapper.getFiles().add(file);
- if(!fileManager.addImage(file.getName(), file.getFile().getPath())){
+ fileWrapper.getFiles().add(image);
+ if(!fileManager.addImage(item.getFileName(), item.getFile().getPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_SAVE_ERROR));
}
- file.getFile().delete();
+ item.getFile().delete();
}
- private Image constructImage(UploadItem item, FileItem file) {
+ private Image constructImage(UploadItem item) {
Image image = new Image();
image.setUploaded(new Date());
image.setDescription(SAMPLE_DESCRIPTION);
image.setName(SAMPLE_NAME);
- image.setSize(file.getLength());
+ image.setSize(item.getFileSize());
return image;
}
- private void extractMetadata(FileItem file, Image image)
+ private void extractMetadata(UploadItem item, Image image)
throws JpegProcessingException, MetadataException, FileNotFoundException {
- InputStream in = new FileInputStream(file.getFile());
+ InputStream in = new FileInputStream(item.getFile());
Metadata metadata = JpegMetadataReader.readMetadata(in);
Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-03-23
14:02:33 UTC (rev 13103)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-03-23
14:09:13 UTC (rev 13104)
@@ -28,22 +28,23 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Image;
@Name("fileWrapper")
@Scope(ScopeType.SESSION)
@AutoCreate
public class FileWrapper {
- private List<FileItem> files = new ArrayList<FileItem>();
+ private List<Image> files = new ArrayList<Image>();
public int getSize() {
return getFiles().size();
}
- public List<FileItem> getFiles() {
+ public List<Image> getFiles() {
return files;
}
- public void setFiles(List<FileItem> files) {
+ public void setFiles(List<Image> files) {
this.files = files;
}
Show replies by date