From: <pn...@hy...> - 2010-04-09 03:46:15
|
Author: pnguyen Date: 2010-04-08 20:46:06 -0700 (Thu, 08 Apr 2010) New Revision: 14489 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14489 Modified: trunk/src/org/hyperic/hq/control/server/session/ControlHistoryDAO.java trunk/src/org/hyperic/hq/control/server/session/ControlManagerEJBImpl.java Log: [HQ-2080] Use get() instead of findById() to improve error handling when the control history record cannot be found Modified: trunk/src/org/hyperic/hq/control/server/session/ControlHistoryDAO.java =================================================================== --- trunk/src/org/hyperic/hq/control/server/session/ControlHistoryDAO.java 2010-04-09 03:41:19 UTC (rev 14488) +++ trunk/src/org/hyperic/hq/control/server/session/ControlHistoryDAO.java 2010-04-09 03:46:06 UTC (rev 14489) @@ -6,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * Copyright (C) [2004-2010], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -44,6 +44,10 @@ return (ControlHistory)super.findById(id); } + public ControlHistory get(Integer id) { + return (ControlHistory)super.get(id); + } + void save(ControlHistory entity) { super.save(entity); } Modified: trunk/src/org/hyperic/hq/control/server/session/ControlManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/control/server/session/ControlManagerEJBImpl.java 2010-04-09 03:41:19 UTC (rev 14488) +++ trunk/src/org/hyperic/hq/control/server/session/ControlManagerEJBImpl.java 2010-04-09 03:46:06 UTC (rev 14489) @@ -6,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004-2009], Hyperic, Inc. + * Copyright (C) [2004-2010], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -552,13 +552,19 @@ } // Update the control history - try { - ControlHistoryDAO historyLocalHome = getControlHistoryDAO(); - Integer pk = new Integer(id); - cLocal = historyLocalHome.findById(pk); - } catch (ObjectNotFoundException e) { - // We know the ID, this won't happen - throw new SystemException(e); + ControlHistoryDAO historyLocalHome = getControlHistoryDAO(); + Integer pk = new Integer(id); + cLocal = historyLocalHome.get(pk); + + if (cLocal == null) { + // We know the ID, this should not happen + throw new SystemException( + "Failure getting control history id=" + id + + ". Could not update history {status=" + status + + ", startTime=" + startTime + + ", endTime=" + endTime + + ", message=" + msg + + "}"); } cLocal.setStatus(status); |