Author: amarkhel
Date: 2009-04-29 10:10:50 -0400 (Wed, 29 Apr 2009)
New Revision: 13909
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/Controller.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/manager/UserManager.java
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.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
13:43:25 UTC (rev 13908)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-04-29
14:10:50 UTC (rev 13909)
@@ -20,6 +20,7 @@
*/
package org.richfaces.photoalbum.manager;
+import java.io.File;
import java.io.Serializable;
import java.security.MessageDigest;
@@ -112,6 +113,14 @@
}
user.setPasswordHash(hash(user.getPassword()));
user.setPreDefined(false);
+ File avatarData =
(File)Contexts.getConversationContext().get(Constants.AVATAR_DATA_COMPONENT);
+ if(avatarData != null){
+ user.setHasAvatar(true);
+ 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);
+ }
+ }
try{
userAction.register(user);
}
@@ -126,7 +135,7 @@
public void goToRegister(){
Contexts.getSessionContext().set("user", new User());
- Contexts.getConversationContext().set("avatarData", null);
+ Contexts.getConversationContext().set(Constants.AVATAR_DATA_COMPONENT, null);
setLoginFailed(false);
Events.instance().raiseEvent(Constants.START_REGISTER_EVENT);
}
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java 2009-04-29
13:43:25 UTC (rev 13908)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java 2009-04-29
14:10:50 UTC (rev 13909)
@@ -236,7 +236,7 @@
public void showUser(User user){
model.resetModel(NavigationEnum.USER_PREFS, user, null, null, null, null);
- Contexts.getConversationContext().set("avatarData", null);
+ Contexts.getConversationContext().set(Constants.AVATAR_DATA_COMPONENT, null);
}
public void showUnvisitedImages(Shelf shelf){
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
13:43:25 UTC (rev 13908)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileManager.java 2009-04-29
14:10:50 UTC (rev 13909)
@@ -119,10 +119,9 @@
FileUtils.addDirectory(directory);
}
- @Restrict("#{s:hasRole('admin')}")
- public boolean saveAvatar(String path, User user) {
+ public boolean saveAvatar(File avatarData, User user) {
return writeFile(user.getPath() +
- Constants.AVATAR_JPG, path, "", Constants.AVATAR_SIZE, true);
+ Constants.AVATAR_JPG, avatarData.getPath(), "", Constants.AVATAR_SIZE,
true);
}
@Restrict("#{s:hasRole('admin')}")
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-04-29
13:43:25 UTC (rev 13908)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-04-29
14:10:50 UTC (rev 13909)
@@ -53,7 +53,7 @@
@Observer(Constants.EDIT_USER_EVENT)
public void editUser(){
if (avatarData != null) {
- if(!fileManager.saveAvatar(avatarData.getPath(), user)){
+ if(!fileManager.saveAvatar(avatarData, user)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.FILE_IO_ERROR);
return;
}
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Show replies by date