Author: mbrohl
Date: Tue Dec 19 13:36:37 2017 New Revision: 1818667 URL: http://svn.apache.org/viewvc?rev=1818667&view=rev Log: Fixed: Potential Nullpointer in ContentWorker.checkConditions() (OFBIZ-10051) Thanks Dennis Balkir for reporting and providing the patch. Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java Modified: ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java?rev=1818667&r1=1818666&r2=1818667&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/content/ContentWorker.java Tue Dec 19 13:36:37 2017 @@ -1233,37 +1233,39 @@ public class ContentWorker implements or public static void checkConditions(Delegator delegator, Map<String, Object> trailNode, Map<String, Object> contentAssoc, Map<String, Object> whenMap) { Map<String, Object> context = new HashMap<String, Object>(); GenericValue content = (GenericValue)trailNode.get("value"); - if (contentAssoc == null && content != null && (content.getEntityName().indexOf("Assoc") >= 0)) { - contentAssoc = delegator.makeValue("ContentAssoc"); + if (content != null) { + context.put("content", content); + List<Object> purposes = getPurposes(content); + context.put("purposes", purposes); + List<Object> sections = getSections(content); + context.put("sections", sections); + List<Object> topics = getTopics(content); + context.put("topics", topics); + String contentTypeId = (String)content.get("contentTypeId"); + List<String> contentTypeAncestry = new LinkedList<String>(); try { - // TODO: locale needs to be gotten correctly - SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", content, contentAssoc, new LinkedList<Object>(), Locale.getDefault()); - context.put("contentAssocTypeId", contentAssoc.get("contentAssocTypeId")); - context.put("contentAssocPredicateId", contentAssoc.get("contentAssocPredicateId")); - context.put("mapKey", contentAssoc.get("mapKey")); - } catch (MiniLangException e) { + getContentTypeAncestry(delegator, contentTypeId, contentTypeAncestry); + } catch (GenericEntityException e) { Debug.logError(e.getMessage(), module); } - } else { - context.put("contentAssocTypeId", null); - context.put("contentAssocPredicateId", null); - context.put("mapKey", null); - } - context.put("content", content); - List<Object> purposes = getPurposes(content); - context.put("purposes", purposes); - List<Object> sections = getSections(content); - context.put("sections", sections); - List<Object> topics = getTopics(content); - context.put("topics", topics); - String contentTypeId = (String)content.get("contentTypeId"); - List<String> contentTypeAncestry = new LinkedList<String>(); - try { - getContentTypeAncestry(delegator, contentTypeId, contentTypeAncestry); - } catch (GenericEntityException e) { - Debug.logError(e.getMessage(), module); + context.put("typeAncestry", contentTypeAncestry); + if (contentAssoc == null && (content.getEntityName().indexOf("Assoc") >= 0)) { + contentAssoc = delegator.makeValue("ContentAssoc"); + try { + // TODO: locale needs to be gotten correctly + SimpleMapProcessor.runSimpleMapProcessor("component://content/minilang/ContentManagementMapProcessors.xml", "contentAssocIn", content, contentAssoc, new LinkedList<Object>(), Locale.getDefault()); + context.put("contentAssocTypeId", contentAssoc.get("contentAssocTypeId")); + context.put("contentAssocPredicateId", contentAssoc.get("contentAssocPredicateId")); + context.put("mapKey", contentAssoc.get("mapKey")); + } catch (MiniLangException e) { + Debug.logError(e.getMessage(), module); + } + } else { + context.put("contentAssocTypeId", null); + context.put("contentAssocPredicateId", null); + context.put("mapKey", null); + } } - context.put("typeAncestry", contentTypeAncestry); boolean isReturnBefore = checkWhen(context, (String)whenMap.get("returnBeforePickWhen"), false); trailNode.put("isReturnBefore", Boolean.valueOf(isReturnBefore)); boolean isPick = checkWhen(context, (String)whenMap.get("pickWhen"), true); |
Free forum by Nabble | Edit this page |