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. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@680054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -432,7 +432,6 @@ under the License.
|
||||
<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 @@ under the License.
|
||||
<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"/>
|
||||
|
||||
@@ -62,8 +62,11 @@ public class PreferenceServices {
|
||||
* @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 @@ public class PreferenceServices {
|
||||
* @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");
|
||||
|
||||
@@ -27,13 +27,11 @@ import org.ofbiz.base.util.GeneralException;
|
||||
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 class PreferenceWorker {
|
||||
*/
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user