Update of
/var/cvs/contributions/CMSContainer_Modules/subsite/src/java/com/finalist/cmsc/subsite/forms
In directory
james.mmbase.org:/tmp/cvs-serv4387/subsite/src/java/com/finalist/cmsc/subsite/forms
Modified Files:
SubSiteAction.java
Log Message:
CMSC-815 - The subsites screen will throw a NPE if no subsites are present
See also:
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Modules/subsite/src/java/com/finalist/cmsc/subsite/forms
See also: http://www.mmbase.org/jira/browse/CMSC-815
Index: SubSiteAction.java
===================================================================
RCS file:
/var/cvs/contributions/CMSContainer_Modules/subsite/src/java/com/finalist/cmsc/subsite/forms/SubSiteAction.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- SubSiteAction.java 26 Feb 2008 12:18:09 -0000 1.6
+++ SubSiteAction.java 17 Mar 2008 11:39:14 -0000 1.7
@@ -51,26 +51,24 @@
private static Logger log =
Logging.getLoggerInstance(SearchAction.class.getName());
@Override
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response, Cloud cloud)
- throws Exception {
+ public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response, Cloud cloud) throws
Exception {
// Initialize
SearchForm searchForm = (SearchForm) form;
String subsite = request.getParameter("subsite");
- /* Purpose of this file
- * - retrieve list of subsites
- * - retrieve list of pages if
- * channel parameter (subsite) is given (or only 1 subsite exists)
- * -> and put it in a List
+ /*
+ * Purpose of this file - retrieve list of subsites - retrieve list of
+ * pages if channel parameter (subsite) is given (or only 1 subsite
+ * exists) -> and put it in a List
*/
- //Retrieve list of pages of subsite
+ // Retrieve list of pages of subsite
Node subsiteNode = null;
if (StringUtils.isBlank(subsite) || !cloud.hasNode(subsite)) {
- //If the subsiteNode does not exist or is not valid, get the first
found subsite
+ // If the subsiteNode does not exist or is not valid, get the first
+ // found subsite
NodeManager nm = cloud.getNodeManager(SubSiteUtil.SUBSITE);
NodeQuery subsitesQuery = nm.createQuery();
SearchUtil.addLimitConstraint(subsitesQuery, 0, 1);
@@ -79,20 +77,20 @@
if (results.size() > 0) {
subsiteNode = (Node) results.get(0);
}
- }
- else {
+ } else {
subsiteNode = cloud.getNode(subsite);
}
- request.setAttribute("subsite", String.valueOf(subsiteNode.getNumber()));
-
- if (subsiteNode == null){ //If there are no subsites at all, return
empty list
+ if (subsiteNode == null) {
+ // If there are no subsites at all, return an empty list
searchForm.setResultCount(0);
NodeList results = cloud.createNodeList();
searchForm.setResults(results);
return mapping.findForward(SUCCESS);
}
+ request.setAttribute("subsite", String.valueOf(subsiteNode.getNumber()));
+
NodeManager nodeManager = subsiteNode.getNodeManager();
// Order the result by:
String order = searchForm.getOrder();
@@ -124,7 +122,7 @@
searchForm.setKeywords(resultsPerPage);
String direction = null;
- NodeQuery query = createLinkedElementsQuery(subsiteNode, order,
direction, offset*maxNumber, maxNumber, -1, -1, -1);
+ NodeQuery query = createLinkedElementsQuery(subsiteNode, order,
direction, offset * maxNumber, maxNumber, -1, -1, -1);
// Add the title constraint:
if (!StringUtil.isEmpty(searchForm.getTitle())) {
@@ -160,16 +158,16 @@
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
- if(year != -1 || month != -1 || day != -1) {
- Field field =
query.getCloud().getNodeManager(destinationManager).getField("publishdate");
//Does this work?
+ if (year != -1 || month != -1 || day != -1) {
+ Field field =
query.getCloud().getNodeManager(destinationManager).getField("publishdate"); //
Does this work?
StepField basicStepField = query.getStepField(field);
- if(year != -1) {
+ if (year != -1) {
SearchUtil.addConstraint(query, new
BasicFieldValueDateConstraint(basicStepField, new Integer(year),
FieldValueDateConstraint.YEAR));
}
- if(month != -1) {
+ if (month != -1) {
SearchUtil.addConstraint(query, new
BasicFieldValueDateConstraint(basicStepField, new Integer(month),
FieldValueDateConstraint.MONTH));
}
- if(day != -1) {
+ if (day != -1) {
SearchUtil.addConstraint(query, new
BasicFieldValueDateConstraint(basicStepField, new Integer(day),
FieldValueDateConstraint.DAY_OF_MONTH));
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs