Index: /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/controller/SiteStatusViewController.java===================================================================--- /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/controller/SiteStatusViewController.java (revision 5273)+++ /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/controller/SiteStatusViewController.java (working copy)@@ -40,8 +40,10 @@ import org.opennms.netmgt.model.AggregateStatusView; import org.opennms.web.svclayer.AggregateStatus; import org.opennms.web.svclayer.SiteStatusViewService;+import org.opennms.web.svclayer.SiteStatusViewError; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.AbstractController;+import org.springframework.orm.ObjectRetrievalFailureException; /** * Controller servlet for presenting aggregate (propogated) status of nodes@@ -72,7 +74,14 @@ String statusView = req.getParameter("statusView"); String statusSite = req.getParameter("statusSite"); String nodeId = req.getParameter("nodeid");- AggregateStatusView view = m_service.createAggregateStatusView(statusView);+ AggregateStatusView view = null;+ try {+ view = m_service.createAggregateStatusView(statusView);+ } catch (ObjectRetrievalFailureException e) {+ SiteStatusViewError viewError = createSiteStatusViewError((String)e.getIdentifier(), e.getMessage());+ return new ModelAndView("siteStatusError", "error", viewError);+ }+ Collection<AggregateStatus> aggrStati; if (nodeId != null && Integer.parseInt(nodeId) > 0) {@@ -90,4 +99,11 @@ return mav; }+ private SiteStatusViewError createSiteStatusViewError(String shortDescr, String longDescr) {+ SiteStatusViewError viewError = new SiteStatusViewError();+ viewError.setShortDescr(shortDescr);+ viewError.setLongDescr(longDescr);+ return viewError;+ }+ }Index: /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/SiteStatusViewError.java===================================================================--- /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/SiteStatusViewError.java (revision 0)+++ /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/SiteStatusViewError.java (revision 0)@@ -0,0 +1,24 @@+package org.opennms.web.svclayer;++public class SiteStatusViewError {+ + private String m_shortDescr;+ private String m_longDescr;++ public String getShortDescr() {+ return m_shortDescr;+ }++ public void setShortDescr(String shortDescr) {+ m_shortDescr = shortDescr;+ }+ + public String getLongDescr() {+ return m_longDescr;+ }++ public void setLongDescr(String longDescr) {+ m_longDescr = longDescr;+ }+ +}Index: /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultSiteStatusViewService.java===================================================================--- /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultSiteStatusViewService.java (revision 5273)+++ /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultSiteStatusViewService.java (working copy)@@ -1,18 +1,23 @@ // // This file is part of the OpenNMS(R) Application. //-// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc. All rights reserved.-// OpenNMS(R) is a derivative work, containing both original code, included code and modified-// code that was published under the GNU General Public License. Copyrights for modified +// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc. All rights+// reserved.+// OpenNMS(R) is a derivative work, containing both original code, included+// code and modified+// code that was published under the GNU General Public License. Copyrights+// for modified // and included code are below. // // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc. // // Modifications: //-// 2006 Sep 10: Catch some null arguments that might cause problems. - dj@opennms.org+// 2006 Sep 10: Catch some null arguments that might cause problems. -+// dj@opennms.org //-// Original code base Copyright (C) 1999-2001 Oculan Corp. All rights reserved.+// Original code base Copyright (C) 1999-2001 Oculan Corp. All rights+// reserved. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by@@ -21,7 +26,7 @@ // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License@@ -29,9 +34,9 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // For more information contact:-// OpenNMS Licensing <license@opennms.org>-// http://www.opennms.org/-// http://www.opennms.com/+// OpenNMS Licensing <license@opennms.org>+// http://www.opennms.org/+// http://www.opennms.com/ // package org.opennms.web.svclayer.support;@@ -57,67 +62,60 @@ import org.opennms.web.svclayer.SiteStatusViewService; import org.opennms.web.svclayer.dao.SiteStatusViewConfigDao; import org.springframework.dao.DataRetrievalFailureException;+import org.springframework.orm.ObjectRetrievalFailureException; /** * This service layer class creates a collection that represents the current * status of devices per site (a column from the asset table such as building,- * floor, etc.) The status per site is broken down into rows of categories from- * the categories table.+ * floor, etc.) The status per site is broken down into rows of categories+ * from the categories table. example: site: HQBLDB |Routers/Switches | 1 of+ * 20 | |Servers | 0 of 200 | |Hubs/APs | 5 of 30 | * - * example:- * - * site: HQBLDB- * - * |Routers/Switches | 1 of 20 |- * |Servers | 0 of 200 |- * |Hubs/APs | 5 of 30 |- * - * * @author david hustace- * */ public class DefaultSiteStatusViewService implements SiteStatusViewService {-+ private NodeDao m_nodeDao;+ private CategoryDao m_categoryDao;+ private SiteStatusViewConfigDao m_siteStatusViewConfigDao;--+ /**- * This creator looks up a configured status view by name and calls the creator that - * accepts the AggregateStatusView model object.+ * This creator looks up a configured status view by name and calls the+ * creator that accepts the AggregateStatusView model object. * * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusView(java.lang.String) */ public AggregateStatusView createAggregateStatusView(String statusViewName) { AggregateStatusView statusView = new AggregateStatusView();- statusViewName = (statusViewName == null ? m_siteStatusViewConfigDao.getDefaultView().getName() : statusViewName);-+ statusViewName = (statusViewName == null ? m_siteStatusViewConfigDao.getDefaultView().getName()+ : statusViewName);+ View view = m_siteStatusViewConfigDao.getView(statusViewName);-+ statusView.setName(statusViewName); statusView.setColumnName(view.getColumnName()); statusView.setColumnValue(view.getColumnValue()); statusView.setTableName(view.getTableName());-- Set<AggregateStatusDefinition> statusDefs =- getAggregateStatusDefinitionsForView(view);++ Set<AggregateStatusDefinition> statusDefs = getAggregateStatusDefinitionsForView(view); statusView.setStatusDefinitions(statusDefs); return statusView; }- @SuppressWarnings("unchecked")- private Set<AggregateStatusDefinition> getAggregateStatusDefinitionsForView(View view) {+ private Set<AggregateStatusDefinition> getAggregateStatusDefinitionsForView(+ View view) { Set<AggregateStatusDefinition> statusDefs = new LinkedHashSet<AggregateStatusDefinition>(); ArrayList<RowDef> rowDefs = view.getRows().getRowDefCollection();-- //Loop over the defined site status rows++ // Loop over the defined site status rows for (RowDef rowDef : rowDefs) { AggregateStatusDefinition def = new AggregateStatusDefinition(); def.setName(rowDef.getLabel()); def.setReportCategory(rowDef.getReportCategory());-+ Set<OnmsCategory> categories = getCategoriesForRowDef(rowDef); def.setCategories(categories); statusDefs.add(def);@@ -125,87 +123,106 @@ return statusDefs; }- @SuppressWarnings("unchecked") private Set<OnmsCategory> getCategoriesForRowDef(RowDef rowDef) { Set<OnmsCategory> categories = new LinkedHashSet<OnmsCategory>();-- //Loop over the defined categories and create model categories (OnmsCategory)++ // Loop over the defined categories and create model categories+ // (OnmsCategory) ArrayList<Category> cats = rowDef.getCategoryCollection(); for (Category cat : cats) { OnmsCategory category = m_categoryDao.findByName(cat.getName());-+ if (category == null) {- throw new IllegalArgumentException("Site status configured category not found: "+cat.getName());+ throw new ObjectRetrievalFailureException(+ OnmsCategory.class,+ cat.getName(),+ "Unable to locate OnmsCategory named: "+ + cat.getName()+ + " as specified in the site status view configuration file",+ null); }-+ categories.add(category); } return categories; }- /**- * Use the node id to find the value assciated with column defined in the view. The view defines a column- * and column value to be used by default. This method determines the column value using the value associated- * with the asset record for the given nodeid.+ * Use the node id to find the value assciated with column defined in the+ * view. The view defines a column and column value to be used by default.+ * This method determines the column value using the value associated with+ * the asset record for the given nodeid. * - * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusesUsingNodeId(int, java.lang.String)+ * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusesUsingNodeId(int,+ * java.lang.String) */- public Collection<AggregateStatus> createAggregateStatusesUsingNodeId(int nodeId, String viewName) {+ public Collection<AggregateStatus> createAggregateStatusesUsingNodeId(+ int nodeId, String viewName) { OnmsNode node = m_nodeDao.load(nodeId);-- //TODO this is a hack. need to use reflection to get the right column instead of building.- return createAggregateStatuses(createAggregateStatusView(viewName), node.getAssetRecord().getBuilding());++ // TODO this is a hack. need to use reflection to get the right column+ // instead of building.+ return createAggregateStatuses(createAggregateStatusView(viewName),+ node.getAssetRecord().getBuilding()); }-- /**- * This creator is used when wanting to use a different value than the defined column value defined- * for the requested view.+ * This creator is used when wanting to use a different value than the+ * defined column value defined for the requested view. * - * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatuses(org.opennms.netmgt.model.AggregateStatusView, java.lang.String)+ * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatuses(org.opennms.netmgt.model.AggregateStatusView,+ * java.lang.String) */- public Collection<AggregateStatus> createAggregateStatuses(AggregateStatusView statusView, String statusSite) {+ public Collection<AggregateStatus> createAggregateStatuses(+ AggregateStatusView statusView, String statusSite) { if (statusView == null) {- throw new IllegalArgumentException("statusView argument cannot be null");+ throw new IllegalArgumentException(+ "statusView argument cannot be null"); } statusView.setColumnValue(statusSite); return createAggregateStatusUsingAssetColumn(statusView); }-- public Collection<AggregateStatus> createAggregateStatusUsingAssetColumn(AggregateStatusView statusView) {-+ public Collection<AggregateStatus> createAggregateStatusUsingAssetColumn(+ AggregateStatusView statusView) {+ if (statusView == null) {- throw new IllegalArgumentException("statusView argument cannot be null");+ throw new IllegalArgumentException(+ "statusView argument cannot be null"); }-+ /*- * We'll return this collection populated with all the aggregated statuss for the- * devices in the building (site) by for each group of categories.+ * We'll return this collection populated with all the aggregated+ * statuss for the devices in the building (site) by for each group of+ * categories. */ Collection<AggregateStatus> stati = new ArrayList<AggregateStatus>();-+ /* * Iterate over the status definitions and create aggregated statuss */ for (AggregateStatusDefinition statusDef : statusView.getStatusDefinitions()) {- Collection<OnmsNode> nodes = m_nodeDao.findAllByVarCharAssetColumnCategoryList(statusView.getColumnName(), statusView.getColumnValue(), statusDef.getCategories());- AggregateStatus status = new AggregateStatus(new HashSet<OnmsNode>(nodes));+ Collection<OnmsNode> nodes = m_nodeDao.findAllByVarCharAssetColumnCategoryList(+ statusView.getColumnName(),+ statusView.getColumnValue(),+ statusDef.getCategories());+ AggregateStatus status = new AggregateStatus(+ new HashSet<OnmsNode>(+ nodes)); status.setLabel(statusDef.getName());-+ status.setLink(createNodePageUrl(statusView, status)); stati.add(status); }-+ return stati; }-- private String createNodePageUrl(AggregateStatusView statusView, AggregateStatus status) {-++ private String createNodePageUrl(AggregateStatusView statusView,+ AggregateStatus status) {+ if (status.getDownEntityCount() == 0) { StringBuffer buf = new StringBuffer("element/nodelist.jsp?"); buf.append("statusViewName=");@@ -237,9 +254,9 @@ buf.append("nodesWithDownAggregateStatus"); return buf.toString(); }-+ }-+ public NodeDao getNodeDao() { return m_nodeDao; }@@ -247,51 +264,63 @@ public void setNodeDao(NodeDao nodeDao) { m_nodeDao = nodeDao; }-+ public void setCategoryDao(CategoryDao dao) { m_categoryDao = dao; }-+ public void setSiteStatusViewConfigDao(SiteStatusViewConfigDao dao) { m_siteStatusViewConfigDao = dao; }-- public Collection<AggregateStatus> createAggregateStatuses(AggregateStatusView statusView) {- if (! "assets".equalsIgnoreCase("assets")) {- throw new IllegalArgumentException("statusView only currently supports asset table columns");+ public Collection<AggregateStatus> createAggregateStatuses(+ AggregateStatusView statusView) {+ if (!"assets".equalsIgnoreCase("assets")) {+ throw new IllegalArgumentException(+ "statusView only currently supports asset table columns"); } return createAggregateStatusUsingAssetColumn(statusView); }- public AggregateStatus getAggregateStatus(String statusViewName, String statusSite, String rowLabel) {-+ public AggregateStatus getAggregateStatus(String statusViewName,+ String statusSite, String rowLabel) {+ AggregateStatusView statusView = createAggregateStatusView(statusViewName);- Collection<AggregateStatus> stati = createAggregateStatuses(statusView, statusSite);-+ Collection<AggregateStatus> stati = createAggregateStatuses(+ statusView,+ statusSite);+ for (AggregateStatus status : stati) { if (status.getLabel().equals(rowLabel)) { return status; } }- throw new DataRetrievalFailureException("Unable to locate row: "+rowLabel+" for status view: "+statusViewName);+ throw new DataRetrievalFailureException("Unable to locate row: "+ + rowLabel + " for status view: " + statusViewName); }-- public Collection<OnmsNode> getNodes(String statusViewName, String statusSite, String rowLabel) {+ public Collection<OnmsNode> getNodes(String statusViewName,+ String statusSite, String rowLabel) { if (statusViewName == null) { statusViewName = m_siteStatusViewConfigDao.getDefaultView().getName(); }-+ View view = m_siteStatusViewConfigDao.getView(statusViewName); RowDef rowDef = getRowDef(view, rowLabel);-- Set<OnmsCategory> categories = getCategoriesForRowDef(rowDef);-- return m_nodeDao.findAllByVarCharAssetColumnCategoryList(view.getColumnName(), statusSite, categories);+ Set<OnmsCategory> categories = null;++ try {+ categories = getCategoriesForRowDef(rowDef);+ } catch (ObjectRetrievalFailureException e) {+ throw e;+ }++ return m_nodeDao.findAllByVarCharAssetColumnCategoryList(+ view.getColumnName(),+ statusSite,+ categories); }- @SuppressWarnings("unchecked") private RowDef getRowDef(View view, String rowLabel) { Rows rows = view.getRows();@@ -301,8 +330,9 @@ return rowDef; } }-- throw new DataRetrievalFailureException("Unable to locate row: "+rowLabel+" for status view: "+view.getName());++ throw new DataRetrievalFailureException("Unable to locate row: "+ + rowLabel + " for status view: " + view.getName()); } }Index: /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/webapp/WEB-INF/jsp/siteStatusError.jsp===================================================================--- /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/webapp/WEB-INF/jsp/siteStatusError.jsp (revision 0)+++ /home/joed/Onms-Trunk/opennms/opennms-webapp/src/main/webapp/WEB-INF/jsp/siteStatusError.jsp (revision 0)@@ -0,0 +1,15 @@+<%@ page contentType="text/html;charset=UTF-8" language="java"%>+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>++<jsp:include page="/includes/header.jsp" flush="false">+ <jsp:param name="title" value="Site Status" />+ <jsp:param name="headTitle" value="Site Status Error" />+ <jsp:param name="breadcrumb" value="Site Status" />+</jsp:include>++<h3>Site Status View Error: ${error.shortDescr}</h3>++<p>${error.longDescr}</p>++<jsp:include page="/includes/footer.jsp" flush="false" />