Author: jonesde
Date: Wed Feb 14 20:10:26 2007
New Revision: 507808

URL: http://svn.apache.org/viewvc?view=rev&rev=507808
Log:
Small improvements to the permission-service code to show service name in 
exception messages, and to throw a descriptive exception instead of an NPE with 
no hasPermission field is returned from a permission-service

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java

Modified: 
ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?view=diff&rev=507808&r1=507807&r2=507808
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java 
(original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java 
Wed Feb 14 20:10:26 2007
@@ -763,19 +763,22 @@
         if (UtilValidate.isNotEmpty(origService.permissionServiceName)) {
             Map permResp = origService.evalPermission(dctx, context);          
  
             Boolean hasPermission = (Boolean) permResp.get("hasPermission");
+            if (hasPermission == null) {
+                throw new ServiceAuthException("ERROR: the permission-service 
did not return a result. Not running the service [" + origService.name + "]");
+            }
             if (hasPermission.booleanValue()) {
                 context.putAll(permResp);
                 context = origService.makeValid(context, 
ModelService.IN_PARAM);
             } else {
                 String message = (String) permResp.get("failMessage");
                 if (UtilValidate.isEmpty(message)) {
-                    message = "You do not have permission to invoke this 
service";
+                    message = "You do not have permission to invoke the 
service [" + origService.name + "]";
                 }
                 throw new ServiceAuthException(message);
             }
         } else {
             if (!origService.evalPermissions(dctx, context)) {
-                throw new ServiceAuthException("You do not have permission to 
invoke this service");
+                throw new ServiceAuthException("You do not have permission to 
invoke the service [" + origService.name + "]");
             }
         }
 


Reply via email to