@Override public boolean eval(Map<String, Object> context) { // if no user is logged in, treat as if the user does not have permission GenericValue userLogin = (GenericValue) context.get("userLogin"); if (userLogin != null) { String serviceName = serviceExdr.expandString(context); String mainAction = actionExdr.expandString(context); String contextMap = ctxMapExdr.expandString(context); String resource = resExdr.expandString(context); if (UtilValidate.isEmpty(resource)) { resource = serviceName; } if (UtilValidate.isEmpty(serviceName)) { Debug.logWarning("No permission service-name specified!", module); return false; } Map<String, Object> serviceContext = UtilGenerics.toMap(context.get(contextMap)); if (serviceContext != null) { // copy the required internal fields serviceContext.put("userLogin", context.get("userLogin")); serviceContext.put("locale", context.get("locale")); } else { serviceContext = context; } // get the service objects LocalDispatcher dispatcher = this.modelScreen.getDispatcher(context); DispatchContext dctx = dispatcher.getDispatchContext(); // get the service ModelService permService; try { permService = dctx.getModelService(serviceName); } catch (GenericServiceException e) { Debug.logError(e, module); return false; } if (permService != null) { // build the context Map<String, Object> svcCtx = permService.makeValid(serviceContext, ModelService.IN_PARAM); svcCtx.put("resourceDescription", resource); if (UtilValidate.isNotEmpty(mainAction)) { svcCtx.put("mainAction", mainAction); } // invoke the service Map<String, Object> resp; try { resp = dispatcher.runSync(permService.name, svcCtx, 300, true); } catch (GenericServiceException e) { Debug.logError(e, module); return false; } if (ServiceUtil.isError(resp) || ServiceUtil.isFailure(resp)) { Debug.logError(ServiceUtil.getErrorMessage(resp), module); return false; } Boolean hasPermission = (Boolean) resp.get("hasPermission"); if (hasPermission != null) { return hasPermission.booleanValue(); } } } return false; }