From 20ab4cc157996928254c6825adb4fb2ae2ca97c1 Mon Sep 17 00:00:00 2001 From: nac26 Date: Sat, 5 Feb 2011 17:24:40 +0000 Subject: [PATCH] NIHVIVO-1965 Better message for authenticated users with access to the site admin when accessing the site with little or no content. Also refactored BrowseController so that it doesn't attempt to override template and provide it's own message if no content is found. --- .../freemarker/BrowseController.java | 63 +++++++++---------- .../body/partials/browse-classgroups.ftl | 8 ++- .../partials/classgroups-checkForData.ftl | 6 +- .../menupage/menupage-checkForData.ftl | 6 +- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java index a284f2d69..100b7b25c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/BrowseController.java @@ -43,56 +43,51 @@ import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateMo public class BrowseController extends FreemarkerHttpServlet { static final long serialVersionUID=2006030721126L; - + private static final Log log = LogFactory.getLog(BrowseController.class); - private static final String TEMPLATE_DEFAULT = "classGroups.ftl"; + private static final String TEMPLATE_DEFAULT = "classGroups.ftl"; @Override protected String getTitle(String siteName, VitroRequest vreq) { - return "Index to " + siteName + " Contents"; + return "Index of Contents"; } - + @Override protected ResponseValues processRequest(VitroRequest vreq) { - + Map body = new HashMap(); String message = null; String templateName = TEMPLATE_DEFAULT; - if( vreq.getParameter("clearcache") != null ) //mainly for debugging - clearGroupCache(); - - int portalId = vreq.getPortalId(); - - List groups = null; - VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(getServletContext()); - if( vcgc == null ){ - log.error("Could not get VClassGroupCache"); - message = "The system is not configured correctly. Please check your logs for error messages."; - }else{ - groups =vcgc.getGroups( vreq.getPortalId()); - if (groups == null || groups.isEmpty()) { - message = "There are not yet any items in the system."; + if ( vreq.getParameter("clearcache") != null ) //mainly for debugging + clearGroupCache(); + + int portalId = vreq.getPortalId(); + + List groups = null; + VClassGroupCache vcgc = VClassGroupCache.getVClassGroupCache(getServletContext()); + if ( vcgc == null ) { + log.error("Could not get VClassGroupCache"); + message = "The system is not configured correctly. Please check your logs for error messages."; + } else { + groups =vcgc.getGroups( vreq.getPortalId()); + List vcgroups = new ArrayList(groups.size()); + for (VClassGroup group : groups) { + vcgroups.add(new VClassGroupTemplateModel(group)); } - else { - List vcgroups = new ArrayList(groups.size()); - for (VClassGroup group : groups) { - vcgroups.add(new VClassGroupTemplateModel(group)); - } - body.put("classGroups", vcgroups); - } - } - - if (message != null) { - body.put("message", message); - templateName = Template.TITLED_MESSAGE.toString(); - } - + body.put("classGroups", vcgroups); + } + + if (message != null) { + body.put("message", message); + templateName = Template.TITLED_MESSAGE.toString(); + } + return new TemplateResponseValues(templateName, body); } protected void clearGroupCache(){ VClassGroupCache.getVClassGroupCache(getServletContext()).clearGroupCache(); } -} +} \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/partials/browse-classgroups.ftl b/webapp/web/templates/freemarker/body/partials/browse-classgroups.ftl index 8bb721ac6..cf97e76d2 100644 --- a/webapp/web/templates/freemarker/body/partials/browse-classgroups.ftl +++ b/webapp/web/templates/freemarker/body/partials/browse-classgroups.ftl @@ -90,9 +90,13 @@ ${stylesheets.add("/css/browseClassGroups.css")} <#-- <#include "classgroups-checkForData.ftl"> -->

There is currently no content in the system

- <#if !user.loggedIn> + <#if user.loggedIn> + <#if user.hasSiteAdminAccess> +

You can add content and manage this site from the Site Administration page.

+ + <#else>

Please log in to manage content.

- + diff --git a/webapp/web/templates/freemarker/body/partials/classgroups-checkForData.ftl b/webapp/web/templates/freemarker/body/partials/classgroups-checkForData.ftl index 2f45a0c37..a5f2aa40d 100644 --- a/webapp/web/templates/freemarker/body/partials/classgroups-checkForData.ftl +++ b/webapp/web/templates/freemarker/body/partials/classgroups-checkForData.ftl @@ -17,7 +17,11 @@ <#assign noDataNotification>

There is currently no content in the system

- <#if !user.loggedIn> + <#if user.loggedIn> + <#if user.hasSiteAdminAccess> +

You can add content and manage this site from the Site Administration page.

+ + <#else>

Please log in to manage content.

\ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/partials/menupage/menupage-checkForData.ftl b/webapp/web/templates/freemarker/body/partials/menupage/menupage-checkForData.ftl index 34867e28e..1c68d30a5 100644 --- a/webapp/web/templates/freemarker/body/partials/menupage/menupage-checkForData.ftl +++ b/webapp/web/templates/freemarker/body/partials/menupage/menupage-checkForData.ftl @@ -19,7 +19,11 @@ <#assign noDataNotification>

There is currently no ${page.title} content in the system

- <#if !user.loggedIn> + <#if user.loggedIn> + <#if user.hasSiteAdminAccess> +

You can add content and manage this site from the Site Administration page.

+ + <#else>

Please log in to manage content.