Author: adrianc
Date: Sat Jul 26 16:21:03 2008
New Revision: 680054
URL: http://svn.apache.org/viewvc?rev=680054&view=rev
Log:
Slight change to the user preference services. Using the permission service on
the getPreferences services threw an exception: user must be logged in. We
might want to get default preferences before the user is logged in, so I moved
the permission checking inside the getPreferences services.
Internationalization note: this commit contains a new UI label.
Modified:
ofbiz/trunk/framework/common/config/PrefErrorUiLabels.xml
ofbiz/trunk/framework/common/servicedef/services.xml
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
Modified: ofbiz/trunk/framework/common/config/PrefErrorUiLabels.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/config/PrefErrorUiLabels.xml?rev=680054&r1=680053&r2=680054&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/config/PrefErrorUiLabels.xml (original)
+++ ofbiz/trunk/framework/common/config/PrefErrorUiLabels.xml Sat Jul 26
16:21:03 2008
@@ -36,6 +36,9 @@
<value xml:lang="fr">Impossible d'obtenir les préférences de
l'utilisateur : argument(s) non valides</value>
<value
xml:lang="th">à¹à¸¡à¹à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸£à¸µà¸¢à¸à¸à¹à¸²à¸ªà¸´à¸à¸à¸´à¸à¸´à¹à¸¨à¸©à¸à¸à¸à¸à¸¹à¹à¹à¸à¹:à¸à¹à¸à¸à¸´à¸ªà¸¹à¸à¸à¹à¹à¸à¹à¹à¸¡à¹à¹à¸à¹</value>
</property>
+ <property key="getPreference.permissionError">
+ <value xml:lang="en">Permissions error while getting user
preferences</value>
+ </property>
<property key="getPreference.readFailure">
<value xml:lang="de">Benutzereinstellungen konnte nicht geholt werden,
Lesefehler: {0}</value>
<value xml:lang="en">Could not get user preferences (read failure):
{0}</value>
Modified: ofbiz/trunk/framework/common/servicedef/services.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/servicedef/services.xml?rev=680054&r1=680053&r2=680054&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/servicedef/services.xml (original)
+++ ofbiz/trunk/framework/common/servicedef/services.xml Sat Jul 26 16:21:03
2008
@@ -432,7 +432,6 @@
<service name="getUserPreference" engine="java"
location="org.ofbiz.common.preferences.PreferenceServices"
invoke="getUserPreference">
<description>Gets a single user preference.</description>
- <permission-service service-name="preferenceGetSetPermission"
main-action="VIEW"/>
<attribute name="userPrefTypeId" type="String" mode="IN"
optional="false"/>
<attribute name="userLoginId" type="String" mode="IN" optional="true"/>
<attribute name="userPrefGroupId" type="String" mode="IN"
optional="true"/>
@@ -443,7 +442,6 @@
<service name="getUserPreferenceGroup" engine="java"
location="org.ofbiz.common.preferences.PreferenceServices"
invoke="getUserPreferenceGroup">
<description>Gets a group of user preferences.</description>
- <permission-service service-name="preferenceGetSetPermission"
main-action="VIEW"/>
<attribute name="userPrefGroupId" type="String" mode="IN"
optional="false"/>
<attribute name="userLoginId" type="String" mode="IN" optional="true"/>
<attribute name="userPrefMap" type="Map" mode="OUT" optional="true"/>
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=680054&r1=680053&r2=680054&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
Sat Jul 26 16:21:03 2008
@@ -62,8 +62,11 @@
* @return Map with the result of the service, the output parameters.
*/
public static Map<String, Object> getUserPreference(DispatchContext ctx,
Map<String, ?> context) {
- GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
+ if (!PreferenceWorker.isValidGetId(ctx, context)) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"getPreference.permissionError", locale));
+ }
+ GenericDelegator delegator = ctx.getDelegator();
String userPrefTypeId = (String) context.get("userPrefTypeId");
if (UtilValidate.isEmpty(userPrefTypeId)) {
@@ -112,9 +115,12 @@
* @return Map with the result of the service, the output parameters.
*/
public static Map<String, Object> getUserPreferenceGroup(DispatchContext
ctx, Map<String, ?> context) {
+ Locale locale = (Locale) context.get("locale");
+ if (!PreferenceWorker.isValidGetId(ctx, context)) {
+ return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"getPreference.permissionError", locale));
+ }
GenericDelegator delegator = ctx.getDelegator();
LocalDispatcher dispatcher = ctx.getDispatcher();
- Locale locale = (Locale) context.get("locale");
GenericValue userLogin = (GenericValue) context.get("userLogin");
String userPrefGroupId = (String) context.get("userPrefGroupId");
Modified:
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java?rev=680054&r1=680053&r2=680054&view=diff
==============================================================================
---
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
(original)
+++
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
Sat Jul 26 16:21:03 2008
@@ -27,13 +27,11 @@
import org.ofbiz.base.util.ObjectType;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.security.Security;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
-
/**
* User preference worker methods.
*/
@@ -44,11 +42,10 @@
*/
public static final String ADMIN_PERMISSION = "USERPREF_ADMIN";
- /**
- * Default userLoginId. Currently set to "DEFAULT_USER_PREFS". This
userLoginId is used to
- * retrieve preferences when the user is not logged in.
+ /** Default userLoginId. Currently set to "_NA_". This userLoginId is used
to
+ * retrieve default preferences when the user is not logged in.
*/
- public static final String DEFAULT_UID = "DEFAULT_USER_PREFS";
+ public static final String DEFAULT_UID = "_NA_";
/**
* Add a UserPreference GenericValue to a Map.