|
From: <mb...@re...> - 2005-02-25 16:21:45
|
Author: mbooth
Date: 2005-02-25 17:20:27 +0100 (Fri, 25 Feb 2005)
New Revision: 306
Modified:
ccm-cms/trunk/src/com/arsdigita/cms/ContentItem.java
Log:
Don't NPE if asked to fetch categories for a non existant use context. Just
display a warning in the log and return nothing.
Modified: ccm-cms/trunk/src/com/arsdigita/cms/ContentItem.java
===================================================================
--- ccm-cms/trunk/src/com/arsdigita/cms/ContentItem.java 2005-02-25 16:13:12 UTC (rev 305)
+++ ccm-cms/trunk/src/com/arsdigita/cms/ContentItem.java 2005-02-25 16:20:27 UTC (rev 306)
@@ -60,6 +60,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
@@ -1388,6 +1389,13 @@
Category root = Category.getRootForObject(getContentSection(), useContext);
+ if (null == root) {
+ s_log.warn("No root category for " +
+ getContentSection().getOID().toString() +
+ " with context " + useContext);
+ return Collections.EMPTY_LIST.iterator();
+ }
+
CategoryCollection cats = root.getDescendants();
cats.addEqualsFilter("childObjects.id", getID());
|