private boolean evalPermissionService( ModelService origService, DispatchContext dctx, Map<String, ? extends Object> context) { ModelService permission; if (permissionServiceName == null) { Debug.logWarning("No ModelService found; no service name specified!", module); return false; } try { permission = dctx.getModelService(permissionServiceName); } catch (GenericServiceException e) { Debug.logError(e, "Failed to get ModelService: " + e.toString(), module); return false; } if (permission == null) { Debug.logError("No ModelService found with the name [" + permissionServiceName + "]", module); return false; } permission.auth = true; Map<String, Object> ctx = permission.makeValid(context, ModelService.IN_PARAM); if (UtilValidate.isNotEmpty(action)) { ctx.put("mainAction", action); } if (UtilValidate.isNotEmpty(permissionResourceDesc)) { ctx.put("resourceDescription", permissionResourceDesc); } else if (origService != null) { ctx.put("resourceDescription", origService.name); } LocalDispatcher dispatcher = dctx.getDispatcher(); Map<String, Object> resp; String failMessage = null; try { resp = dispatcher.runSync(permission.name, ctx, 300, true); failMessage = (String) resp.get("failMessage"); } catch (GenericServiceException e) { Debug.logError(failMessage + e.getMessage(), module); return false; } if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) { Debug.logError(failMessage, module); return false; } return ((Boolean) resp.get("hasPermission")).booleanValue(); }