Author: amarkhel
Date: 2009-04-29 10:57:36 -0400 (Wed, 29 Apr 2009)
New Revision: 13911
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/ImageLoader.java
trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/avatar.xhtml
Log:
Fix RF 6933
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-04-29
14:10:56 UTC (rev 13910)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-04-29
14:57:36 UTC (rev 13911)
@@ -119,6 +119,7 @@
FileManager fileManager =
(FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(fileManager == null || !fileManager.saveAvatar(avatarData, user)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.AVATAR_SAVING_ERROR);
+ return;
}
}
try{
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileManager.java 2009-04-29
14:10:56 UTC (rev 13910)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileManager.java 2009-04-29
14:57:36 UTC (rev 13911)
@@ -120,8 +120,9 @@
}
public boolean saveAvatar(File avatarData, User user) {
- return writeFile(user.getPath() +
- Constants.AVATAR_JPG, avatarData.getPath(), "", Constants.AVATAR_SIZE,
true);
+ String avatarPath = File.separator + user.getLogin() + File.separator +
Constants.AVATAR_JPG;
+ createDirectoryIfNotExist(avatarPath);
+ return writeFile(avatarPath, avatarData.getPath(), "", Constants.AVATAR_SIZE,
true);
}
@Restrict("#{s:hasRole('admin')}")
@@ -237,7 +238,7 @@
}
private void createDirectoryIfNotExist(String fileNameNew) {
- final int lastIndexOf = fileNameNew.lastIndexOf(Constants.SLASH);
+ final int lastIndexOf = fileNameNew.lastIndexOf(File.separator);
if (lastIndexOf > 0) {
final String directory = fileNameNew.substring(0, lastIndexOf);
final File file = getFileByPath(directory);
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/ImageLoader.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/ImageLoader.java 2009-04-29
14:10:56 UTC (rev 13910)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/ImageLoader.java 2009-04-29
14:57:36 UTC (rev 13911)
@@ -31,6 +31,8 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.contexts.Contexts;
+import org.richfaces.photoalbum.domain.User;
import org.richfaces.photoalbum.manager.FileManager;
import org.richfaces.photoalbum.service.Constants;
@@ -53,10 +55,13 @@
public void paintAvatarImage(OutputStream out, Object data) throws IOException {
if (null == data) {
- return;
- }
- File imageResource = fileManager.getFileByAbsolutePath(data.toString());
- paintImageToBrowser(out, imageResource);
+ return;
+ }
+ File imageResource = fileManager.getFileByPath(data.toString());
+ if (imageResource == null || !imageResource.exists()) {
+ imageResource = fileManager.getFileByAbsolutePath(data.toString());
+ }
+ paintImageToBrowser(out, imageResource);
}
private void paintImageToBrowser(OutputStream out, File imageResource) throws
IOException {
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/avatar.xhtml
===================================================================
(Binary files differ)
Show replies by date