diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java index 2c51b8017..b972e4327 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/FreemarkerHttpServlet.java @@ -108,7 +108,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet { protected void handleException(VitroRequest vreq, HttpServletResponse response, Throwable t) throws ServletException { try { - doResponse(vreq, response, new ExceptionResponseValues(t)); + doResponse(vreq, response, new ExceptionResponseValues(t, HttpServletResponse.SC_INTERNAL_SERVER_ERROR)); } catch (TemplateProcessingException e) { throw new ServletException(); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/Tags.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/Tags.java index cf07516b8..8488fd2ae 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/Tags.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/Tags.java @@ -4,6 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.web.templatemodels; import java.util.LinkedHashSet; +import org.apache.commons.lang.StringUtils; + public class Tags extends BaseTemplateModel { protected final LinkedHashSet tags; @@ -15,6 +17,7 @@ public class Tags extends BaseTemplateModel { public Tags(LinkedHashSet tags) { this.tags = tags; } + /* Template methods */ @@ -27,14 +30,8 @@ public class Tags extends BaseTemplateModel { public void add(String tag) { tags.add(tag); } - - public String getList() { - String tagList = ""; - - for (String tag : tags) { - tagList += tag; - } - return tagList; + + public String list() { + return StringUtils.join(tags, ""); } - } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/User.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/User.java index e326a7ca3..8c55e19b3 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/User.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/User.java @@ -43,8 +43,6 @@ public class User extends BaseTemplateModel { return url; } - /* Template methods */ - /* Template properties */ public boolean isLoggedIn() { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java index ec02720d7..401d477bd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/BaseIndividualTemplateModel.java @@ -3,6 +3,7 @@ package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -74,7 +75,7 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel { return isVClass; } - /* These methods perform some manipulation of the data returned by the Individual methods */ + /* Template properties */ public String getProfileUrl() { return UrlBuilder.getIndividualProfileUrl(individual, vreq); @@ -165,13 +166,47 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel { public String getLocalName() { return individual.getLocalName(); } + + public String nullString() { + return null; + } + + public String emptyString() { + return ""; + } + + public String[] nullArray() { + return null; + } + + public String[] emptyArray() { + String[] a = {}; + return a; + } + + public List nullList() { + return null; + } + + public List emptyList() { + return Collections.emptyList(); + } + + public Map nullMap() { + return null; + } + + public Map emptyMap() { + return Collections.emptyMap(); + } + + /* Template methods */ - public String getSelfEditingId() { + public String selfEditingId() { String id = null; - String idMatchingProperty = ConfigurationProperties.getBean(getServletContext()).getProperty("selfEditing.idMatchingProperty"); + String idMatchingProperty = + ConfigurationProperties.getBean(getServletContext()).getProperty("selfEditing.idMatchingProperty"); if (! StringUtils.isBlank(idMatchingProperty)) { - // Use assertions model to side-step filtering. We need to get the value regardless of whether the property - // is visible to the current user. WebappDaoFactory wdf = vreq.getUnfilteredWebappDaoFactory(); Collection ids = wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/BaseListedIndividual.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/BaseListedIndividual.java index 799cf33b6..3b93429ae 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/BaseListedIndividual.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/BaseListedIndividual.java @@ -35,7 +35,7 @@ public abstract class BaseListedIndividual extends BaseTemplateModel { return models; } - /* Access methods for templates */ + /* Template properties */ public String getProfileUrl() { return cleanURIForDisplay( UrlBuilder.getIndividualProfileUrl(individual, vreq) ); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/ListedIndividual.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/ListedIndividual.java index 12fbc098b..328b4bfd8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/ListedIndividual.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individuallist/ListedIndividual.java @@ -15,7 +15,5 @@ public class ListedIndividual extends BaseListedIndividual { public ListedIndividual(Individual individual, VitroRequest vreq) { super(individual, vreq); } - - /* Access methods for templates */ } diff --git a/webapp/src/freemarker/ext/dump/BaseDumpDirective.java b/webapp/src/freemarker/ext/dump/BaseDumpDirective.java index 189474b8d..0d2e12a79 100644 --- a/webapp/src/freemarker/ext/dump/BaseDumpDirective.java +++ b/webapp/src/freemarker/ext/dump/BaseDumpDirective.java @@ -81,8 +81,8 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel { } enum Value { - NULL("[null]"), - UNDEFINED("[undefined]"); + NULL(""), + UNDEFINED(""); private final String value; diff --git a/webapp/web/templates/freemarker/page/partials/headScripts.ftl b/webapp/web/templates/freemarker/page/partials/headScripts.ftl index f7c8a6488..b1c47905c 100644 --- a/webapp/web/templates/freemarker/page/partials/headScripts.ftl +++ b/webapp/web/templates/freemarker/page/partials/headScripts.ftl @@ -10,7 +10,7 @@ -${headScripts.list} +${headScripts.list()} -${scripts.list} +${scripts.list()} <#include "googleAnalytics.ftl"> diff --git a/webapp/web/templates/freemarker/page/partials/stylesheets.ftl b/webapp/web/templates/freemarker/page/partials/stylesheets.ftl index 4cad88372..f9865f2ef 100644 --- a/webapp/web/templates/freemarker/page/partials/stylesheets.ftl +++ b/webapp/web/templates/freemarker/page/partials/stylesheets.ftl @@ -5,7 +5,7 @@ -${stylesheets.list} +${stylesheets.list()} <#--temporary until edit controller can include this when needed --> \ No newline at end of file