NIHVIVO-2508 Change template properties to methods so not pre-computed.
This commit is contained in:
parent
eabbe027e4
commit
ddd6469a3a
10 changed files with 53 additions and 25 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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<String> tags;
|
||||
|
@ -16,6 +18,7 @@ public class Tags extends BaseTemplateModel {
|
|||
this.tags = tags;
|
||||
}
|
||||
|
||||
|
||||
/* Template methods */
|
||||
|
||||
public void add(String... tags) {
|
||||
|
@ -28,13 +31,7 @@ public class Tags extends BaseTemplateModel {
|
|||
tags.add(tag);
|
||||
}
|
||||
|
||||
public String getList() {
|
||||
String tagList = "";
|
||||
|
||||
for (String tag : tags) {
|
||||
tagList += tag;
|
||||
}
|
||||
return tagList;
|
||||
public String list() {
|
||||
return StringUtils.join(tags, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ public class User extends BaseTemplateModel {
|
|||
return url;
|
||||
}
|
||||
|
||||
/* Template methods */
|
||||
|
||||
/* Template properties */
|
||||
|
||||
public boolean isLoggedIn() {
|
||||
|
|
|
@ -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);
|
||||
|
@ -166,12 +167,46 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
|||
return individual.getLocalName();
|
||||
}
|
||||
|
||||
public String getSelfEditingId() {
|
||||
public String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String emptyString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String[] nullArray() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] emptyArray() {
|
||||
String[] a = {};
|
||||
return a;
|
||||
}
|
||||
|
||||
public List<String> nullList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> emptyList() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Map<String, String> nullMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, String> emptyMap() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/* Template methods */
|
||||
|
||||
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<DataPropertyStatement> ids =
|
||||
wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty);
|
||||
|
|
|
@ -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) );
|
||||
|
|
|
@ -16,6 +16,4 @@ public class ListedIndividual extends BaseListedIndividual {
|
|||
super(individual, vreq);
|
||||
}
|
||||
|
||||
/* Access methods for templates */
|
||||
|
||||
}
|
||||
|
|
|
@ -81,8 +81,8 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
|||
}
|
||||
|
||||
enum Value {
|
||||
NULL("[null]"),
|
||||
UNDEFINED("[undefined]");
|
||||
NULL("<null>"),
|
||||
UNDEFINED("<undefined>");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<script type="text/javascript" src="${urls.base}/js/html5.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
${headScripts.list}
|
||||
${headScripts.list()}
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<script type="text/javascript" src="${urls.base}/js/jquery_plugins/supersleight.js"></script>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<#-- Template for scripts loaded at the end of the body element -->
|
||||
|
||||
${scripts.list}
|
||||
${scripts.list()}
|
||||
|
||||
<#include "googleAnalytics.ftl">
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!-- vitro base styles (application-wide) -->
|
||||
<link rel="stylesheet" href="${urls.base}/css/vitro.css" />
|
||||
|
||||
${stylesheets.list}
|
||||
${stylesheets.list()}
|
||||
|
||||
<#--temporary until edit controller can include this when needed -->
|
||||
<link rel="stylesheet" href="${urls.base}/css/edit.css" />
|
Loading…
Add table
Reference in a new issue