svn commit: r685588 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r685588 - /ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java

adrianc
Author: adrianc
Date: Wed Aug 13 08:44:16 2008
New Revision: 685588

URL: http://svn.apache.org/viewvc?rev=685588&view=rev
Log:
Small change to user preferences. The getUserPreferenceGroup service will simply retrieve default values instead of copying them to the user's preferences. This should help reduce the amount of data generated.

Modified:
    ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java

Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java?rev=685588&r1=685587&r2=685588&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java Wed Aug 13 08:44:16 2008
@@ -35,7 +35,6 @@
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ServiceUtil;
 
 /**
@@ -107,7 +106,7 @@
 
     /**
      * Retrieves a group of user preferences from persistent storage. Call with
-     * userPrefGroupId  and optional userLoginId. If userLoginId isn't
+     * userPrefGroupId and optional userLoginId. If userLoginId isn't
      * specified, then the currently logged-in user's userLoginId will be
      * used. The retrieved preferences group is contained in the <b>userPrefMap</b> element.
      * @param ctx The DispatchContext that this service is operating in.
@@ -120,8 +119,6 @@
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.permissionError", locale));
         }
         GenericDelegator delegator = ctx.getDelegator();
-        LocalDispatcher dispatcher = ctx.getDispatcher();
-        GenericValue userLogin = (GenericValue) context.get("userLogin");
 
         String userPrefGroupId = (String) context.get("userPrefGroupId");
         if (UtilValidate.isEmpty(userPrefGroupId)) {
@@ -131,15 +128,10 @@
 
         Map<String, Object> userPrefMap = null;
         try {
-            Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefGroupId", userPrefGroupId);
+            Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", "_NA_", "userPrefGroupId", userPrefGroupId);
             userPrefMap = PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference", fieldMap));
-            
-            // if preference map not found, copy from the "_NA_" userlogin being the default settings
-            if (UtilValidate.isEmpty(userPrefMap)) {
-             dispatcher.runSync("copyUserPrefGroup", UtilMisc.toMap("userLogin", userLogin, "fromUserLoginId", "_NA_", "userPrefGroupId", userPrefGroupId));
-                userPrefMap = PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference", fieldMap));
-            }
-            
+            fieldMap.put("userLoginId", userLoginId);
+            userPrefMap.putAll(PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference", fieldMap)));
         } catch (GenericEntityException e) {
             Debug.logWarning(e.getMessage(), module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.readFailure", new Object[] { e.getMessage() }, locale));