Author: jleroux
Date: Wed Mar 2 06:34:18 2011 New Revision: 1076115 URL: http://svn.apache.org/viewvc?rev=1076115&view=rev Log: Fix possible NPEs in Content Component reported by Dimitri Valax on dev ML, close https://issues.apache.org/jira/browse/OFBIZ-4198 - OFBIZ-4198 Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java?rev=1076115&r1=1076114&r2=1076115&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentPermissionServices.java Wed Mar 2 06:34:18 2011 @@ -292,52 +292,46 @@ public class ContentPermissionServices { // boolean isMatchTo = false; // boolean isMatchFrom = false; Map<String, Object> permResults = FastMap.newInstance(); - String skipPermissionCheck = null; - if (UtilValidate.isEmpty(skipPermissionCheck) - || (!skipPermissionCheck.equalsIgnoreCase("true") && !skipPermissionCheck.equalsIgnoreCase("granted"))) { - // Use the purposes from the from entity for both cases. - List<String> relatedPurposes = EntityPermissionChecker.getRelatedPurposes(contentFrom, null); - List<String> relatedPurposesTo = EntityPermissionChecker.getRelatedPurposes(contentTo, relatedPurposes); - Map<String, Object> serviceInMap = FastMap.newInstance(); - serviceInMap.put("userLogin", userLogin); - serviceInMap.put("targetOperationList", UtilMisc.toList("CONTENT_LINK_TO")); - serviceInMap.put("contentPurposeList", relatedPurposesTo); - serviceInMap.put("currentContent", contentTo); - serviceInMap.put("displayFailCond", bDisplayFailCond); + // Use the purposes from the from entity for both cases. + List<String> relatedPurposes = EntityPermissionChecker.getRelatedPurposes(contentFrom, null); + List<String> relatedPurposesTo = EntityPermissionChecker.getRelatedPurposes(contentTo, relatedPurposes); + Map<String, Object> serviceInMap = FastMap.newInstance(); + serviceInMap.put("userLogin", userLogin); + serviceInMap.put("targetOperationList", UtilMisc.toList("CONTENT_LINK_TO")); + serviceInMap.put("contentPurposeList", relatedPurposesTo); + serviceInMap.put("currentContent", contentTo); + serviceInMap.put("displayFailCond", bDisplayFailCond); - try { - permResults = dispatcher.runSync("checkContentPermission", serviceInMap); - } catch (GenericServiceException e) { - Debug.logError(e, "Problem checking permissions", "ContentServices"); - } - permissionStatus = (String)permResults.get("permissionStatus"); - if (permissionStatus == null || !permissionStatus.equals("granted")) { - if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { - String errMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); - results.put(ModelService.ERROR_MESSAGE, errMsg); - } - return results; - } - serviceInMap.put("currentContent", contentFrom); - serviceInMap.put("targetOperationList", UtilMisc.toList("CONTENT_LINK_FROM")); - serviceInMap.put("contentPurposeList", relatedPurposes); - try { - permResults = dispatcher.runSync("checkContentPermission", serviceInMap); - } catch (GenericServiceException e) { - Debug.logError(e, "Problem checking permissions", "ContentServices"); - } - permissionStatus = (String)permResults.get("permissionStatus"); - if (permissionStatus != null && permissionStatus.equals("granted")) { - results.put("permissionStatus", "granted"); - } else { - if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { - String errMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); - results.put(ModelService.ERROR_MESSAGE, errMsg); - } + try { + permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + } catch (GenericServiceException e) { + Debug.logError(e, "Problem checking permissions", "ContentServices"); + } + permissionStatus = (String)permResults.get("permissionStatus"); + if (permissionStatus == null || !permissionStatus.equals("granted")) { + if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { + String errMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); + results.put(ModelService.ERROR_MESSAGE, errMsg); } - } else { + return results; + } + serviceInMap.put("currentContent", contentFrom); + serviceInMap.put("targetOperationList", UtilMisc.toList("CONTENT_LINK_FROM")); + serviceInMap.put("contentPurposeList", relatedPurposes); + try { + permResults = dispatcher.runSync("checkContentPermission", serviceInMap); + } catch (GenericServiceException e) { + Debug.logError(e, "Problem checking permissions", "ContentServices"); + } + permissionStatus = (String)permResults.get("permissionStatus"); + if (permissionStatus != null && permissionStatus.equals("granted")) { results.put("permissionStatus", "granted"); + } else { + if (bDisplayFailCond != null && bDisplayFailCond.booleanValue()) { + String errMsg = (String)permResults.get(ModelService.ERROR_MESSAGE); + results.put(ModelService.ERROR_MESSAGE, errMsg); + } } return results; } Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java?rev=1076115&r1=1076114&r2=1076115&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/ContentWorker.java Wed Mar 2 06:34:18 2011 @@ -1052,8 +1052,8 @@ public class ContentWorker implements or Map<String, Object> permResults = FastMap.newInstance(); String skipPermissionCheck = (String) context.get("skipPermissionCheck"); - if (UtilValidate.isEmpty(skipPermissionCheck) - || (!skipPermissionCheck.equalsIgnoreCase("true") && !skipPermissionCheck.equalsIgnoreCase("granted"))) { + if (UtilValidate.isEmpty(skipPermissionCheck) + || (!"true".equalsIgnoreCase(skipPermissionCheck) && !"granted".equalsIgnoreCase(skipPermissionCheck))) { GenericValue userLogin = (GenericValue) context.get("userLogin"); Map<String, Object> serviceInMap = FastMap.newInstance(); serviceInMap.put("userLogin", userLogin); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=1076115&r1=1076114&r2=1076115&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Wed Mar 2 06:34:18 2011 @@ -292,8 +292,8 @@ public class DataResourceWorker impleme String skipPermissionCheck = (String) context.get("skipPermissionCheck"); if (Debug.infoOn()) Debug.logInfo("in callDataResourcePermissionCheckResult, skipPermissionCheck:" + skipPermissionCheck,""); - if (UtilValidate.isEmpty(skipPermissionCheck) - || (!skipPermissionCheck.equalsIgnoreCase("true") && !skipPermissionCheck.equalsIgnoreCase("granted"))) { + if (UtilValidate.isEmpty(skipPermissionCheck) + || (!"true".equalsIgnoreCase(skipPermissionCheck) && !"granted".equalsIgnoreCase(skipPermissionCheck))) { GenericValue userLogin = (GenericValue) context.get("userLogin"); Map<String, Object> serviceInMap = FastMap.newInstance(); serviceInMap.put("userLogin", userLogin); |
Free forum by Nabble | Edit this page |