Author: channa
Date: Wed Jan 23 03:21:11 2008
New Revision: 12763
Log:
Corrected user profile edit behavior - MASHUP-560.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Wed Jan 23 03:21:11 2008
@@ -572,24 +572,34 @@
public static void updateUser(SecureRegistry registry, UserStoreAdmin
userStoreAdmin,
String userName, String fullName, String
eMailId, String bio)
throws UserManagerException, RegistryException {
-
- // Add some predefined queries for the new user.
- String profilePath = "/users/" + userName + "/profile";
-
+ String profilePath = null;
Map properties = userStoreAdmin.getUserProperties(userName);
properties.put(MashupConstants.FULL_NAME, fullName);
userStoreAdmin.setUserProperties(userName, properties);
- // Create instance of user object and assign property values.
+ if (properties.containsKey(MashupConstants.PROFILE_PATH)) {
+ profilePath =
properties.get(MashupConstants.PROFILE_PATH).toString();
+ }
+
+ Resource authorProfile = registry.get(profilePath);
+ String userData = new String((byte[]) authorProfile.getContent());
+
User user = new User();
- user.setEmailAddress(eMailId);
- user.setUsername(userName);
- user.setBio(bio);
-
- // Add profile as a new registry resource.
- Resource userProfile = registry.get(profilePath);
- userProfile.setContent(user.serializeUserProfile().getBytes());
- registry.put(profilePath, userProfile);
+ user.deserializeUserProfile(userData);
+
+ boolean changed = false;
+ if (!eMailId.equals(user.getEmailAddress())) {
+ user.setEmailAddress(eMailId);
+ changed = true;
+ }
+ if (!bio.equals(user.getBio())) {
+ user.setBio(bio);
+ changed = true;
+ }
+ if (changed) {
+ authorProfile.setContent(user.serializeUserProfile().getBytes());
+ registry.put(profilePath, authorProfile);
+ }
}
/**
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev