Author: channa
Date: Sat Mar 15 01:49:05 2008
New Revision: 14839
Log:
Shifted caching to getUserName method, so that the full name for any user name
is retrieved only once for a given user session (not just current users as
previously implemented).
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
Sat Mar 15 01:49:05 2008
@@ -240,14 +240,8 @@
currentUser = getCurrentUser(registry);
- currentUserFullName = (String)
session.getAttribute(MashupConstants.FULL_NAME +
- currentUser);
+ currentUserFullName = getFullName(request, currentUser);
- // If it's not been cached in the session, retrieve it and add to
cache.
- if (currentUserFullName == null || "".equals(currentUserFullName)) {
- currentUserFullName = getFullName(request, currentUser);
- session.setAttribute(MashupConstants.FULL_NAME + currentUser,
currentUserFullName);
- }
return currentUserFullName;
}
@@ -262,22 +256,30 @@
throws RegistryException {
String fullName = null;
Map userProperties;
+ HttpSession session = request.getSession();
- SecureRegistry registry =
- (SecureRegistry)
request.getSession().getAttribute(MashupConstants.USER_REGISTRY);
- UserRealm realm = registry.getUserRealm();
-
- // If the user name can be retrieved, try to get the full name.
+ // If a user name has been provided, get his or her full name.
if (userName != null) {
- try {
- userProperties =
realm.getUserStoreReader().getUserProperties(userName);
- } catch (UserStoreException e) {
- throw new RegistryException("Error retrieving user name", e);
- }
+ fullName = (String) session.getAttribute(MashupConstants.FULL_NAME
+ userName);
+
+ // If the full name has not been cached in the session, retrieve
it and add to cache.
+ if (fullName == null || "".equals(fullName)) {
+ SecureRegistry registry = (SecureRegistry) request.getSession()
+ .getAttribute(MashupConstants.USER_REGISTRY);
+ UserRealm realm = registry.getUserRealm();
- // If user properties are available, get the names.
- if (userProperties != null &&
userProperties.containsKey(MashupConstants.FULL_NAME)) {
- fullName =
userProperties.get(MashupConstants.FULL_NAME).toString();
+ try {
+ userProperties =
realm.getUserStoreReader().getUserProperties(userName);
+ } catch (UserStoreException e) {
+ throw new RegistryException("Error retrieving user name",
e);
+ }
+
+ // If user properties are available, get the names.
+ if (userProperties != null &&
+ userProperties.containsKey(MashupConstants.FULL_NAME))
{
+ fullName =
userProperties.get(MashupConstants.FULL_NAME).toString();
+ session.setAttribute(MashupConstants.FULL_NAME + userName,
fullName);
+ }
}
}
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev