This is an automated email from the ASF dual-hosted git repository.

danwatford pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 81bac9ab31 Fixed: ModelPermission handles errors from 
permission-services (OFBIZ-12741)
81bac9ab31 is described below

commit 81bac9ab31c66ef6052a8cb784fd0e9971d5e41e
Author: Daniel Watford <dan...@watfordconsulting.com>
AuthorDate: Thu Jan 12 09:17:52 2023 +0000

    Fixed: ModelPermission handles errors from permission-services (OFBIZ-12741)
    
    Responses from permission services are checked for errors. Errors are
    returned to the caller.
---
 .../src/main/java/org/apache/ofbiz/service/ModelPermission.java    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java 
b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java
index e5e45f277e..2c502958ab 100644
--- 
a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java
+++ 
b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java
@@ -262,6 +262,11 @@ public class ModelPermission implements Serializable {
             } else {
                 resp = dispatcher.runSync(permission.getName(), ctx);
             }
+
+            if (ServiceUtil.isError(resp)) {
+                return resp;
+            }
+
             failMessage = (String) resp.get("failMessage");
         } catch (GenericServiceException e) {
             Debug.logError(failMessage + e.getMessage(), MODULE);
@@ -271,7 +276,7 @@ public class ModelPermission implements Serializable {
             Debug.logVerbose("Service permission result : hasPermission " + 
resp.get("hasPermission") + ", failMessage " + failMessage, MODULE);
         }
         if (permissionReturnErrorOnFailure
-                && (UtilValidate.isNotEmpty(failMessage) || !((Boolean) 
resp.get("hasPermission")).booleanValue())) {
+                && (UtilValidate.isNotEmpty(failMessage) || 
resp.get("hasPermission") == null || !(Boolean) resp.get("hasPermission"))) {
             if (UtilValidate.isEmpty(failMessage)) {
                 failMessage = UtilProperties.getMessage(RESOURCE, 
"ServicePermissionErrorRefused", locale);
             }

Reply via email to