Author: amarkhel
Date: 2009-04-06 10:31:17 -0400 (Mon, 06 Apr 2009)
New Revision: 13390
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RealworldException.java
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
Log:
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-04-06
12:22:40 UTC (rev 13389)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-04-06
14:31:17 UTC (rev 13390)
@@ -25,6 +25,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Synchronized;
@@ -140,6 +141,15 @@
model.setMainArea(NavigationEnum.ALBUM_IMAGE_PREVIEW);
}
+ @Observer("resetModel")
+ public void resetModel(){
+ if(user.getId() != null){
+ model.resetModel(NavigationEnum.ALL_SHELFS, user, null, null, null);
+ }else{
+ model.resetModel(NavigationEnum.ANONYM, user, null, null, null);
+ }
+ }
+
public void showShelf(Shelf shelf){
model.resetModel(NavigationEnum.SHELF_PREVIEW, shelf.getOwner(), shelf, null, null);
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-04-06
12:22:40 UTC (rev 13389)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-04-06
14:31:17 UTC (rev 13390)
@@ -26,6 +26,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Events;
@@ -85,6 +86,7 @@
this.selectedImage.getAlbum().visitImage(selectedImage, true);
}
+ @Observer("stopSlideshow")
public void stopSlideshow(){
active = false;
this.selectedImage = null;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-04-06
12:22:40 UTC (rev 13389)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-04-06
14:31:17 UTC (rev 13390)
@@ -25,9 +25,13 @@
@In Identity identity;
public synchronized void paintImage(OutputStream out, Object data)
- throws IOException {
+ throws IOException, RealworldException {
Long id=Long.valueOf(data.toString());
Image im = em.find(Image.class, id);
+ if(im == null || im.getAlbum() == null || im.getAlbum().getShelf() == null){
+ imageLoader.paintImage(out, "default/noimage.jpg");
+ return;
+ }
//TODO nick - '&&' so only admins can see their own unshared images?
if(im.getAlbum().getShelf().isShared() || (identity.hasRole("admin")
&& im.getAlbum().getOwner().getLogin().equals(identity.getUsername()))){
imageLoader.paintImage(out, im.getPath());
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2009-04-06
12:22:40 UTC (rev 13389)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2009-04-06
14:31:17 UTC (rev 13390)
@@ -64,8 +64,9 @@
}else{
imageResource = fileManager.getFileByPath(data.toString());
}
- if (imageResource != null) {
+ if (imageResource != null && imageResource.exists()) {
FileInputStream fileInputStream = new FileInputStream(imageResource);
+
BufferedInputStream bufferedInputStream = new
BufferedInputStream(fileInputStream);
InputStream paintData = bufferedInputStream;
try {
@@ -78,6 +79,10 @@
} finally {
bufferedInputStream.close();
}
+ }else{
+ Events.instance().raiseEvent("stopSlideshow");
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "Images was
deleted. Sorry");
+ Events.instance().raiseEvent("resetModel");
}
}
}
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RealworldException.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RealworldException.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RealworldException.java 2009-04-06
14:31:17 UTC (rev 13390)
@@ -0,0 +1,11 @@
+package org.richfaces.realworld.util;
+
+public class RealworldException extends Exception {
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -5437284703541833879L;
+
+ public RealworldException(String message) {
+ super(message);
+ }
+}
Property changes on:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/RealworldException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Show replies by date