From b8fefaee00621b0933809a1885eeb8b7ecb7e1e5 Mon Sep 17 00:00:00 2001 From: jeb228 Date: Wed, 27 Oct 2010 19:47:35 +0000 Subject: [PATCH] NIHVIVO-1229 break out a method for getBean(ServletContext) --- .../vitro/webapp/config/RevisionInfoBean.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/RevisionInfoBean.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/RevisionInfoBean.java index eb9eda6d0..472f0505b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/RevisionInfoBean.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/RevisionInfoBean.java @@ -62,7 +62,16 @@ public class RevisionInfoBean { return DUMMY_BEAN; } - Object o = session.getServletContext().getAttribute(ATTRIBUTE_NAME); + return getBean(session.getServletContext()); + } + + public static RevisionInfoBean getBean(ServletContext context) { + if (context == null) { + log.warn("Tried to get revision info bean from a null context"); + return DUMMY_BEAN; + } + + Object o = context.getAttribute(ATTRIBUTE_NAME); if (o == null) { log.warn("Tried to get revision info bean, but didn't find any."); return DUMMY_BEAN; @@ -88,8 +97,7 @@ public class RevisionInfoBean { private final long buildDate; private final List levelInfos; - public RevisionInfoBean(Date buildDate, - Collection levelInfos) { + RevisionInfoBean(Date buildDate, Collection levelInfos) { this.buildDate = buildDate.getTime(); this.levelInfos = Collections .unmodifiableList(new ArrayList(levelInfos));