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 {
|
protected void handleException(VitroRequest vreq, HttpServletResponse response, Throwable t) throws ServletException {
|
||||||
try {
|
try {
|
||||||
doResponse(vreq, response, new ExceptionResponseValues(t));
|
doResponse(vreq, response, new ExceptionResponseValues(t, HttpServletResponse.SC_INTERNAL_SERVER_ERROR));
|
||||||
} catch (TemplateProcessingException e) {
|
} catch (TemplateProcessingException e) {
|
||||||
throw new ServletException();
|
throw new ServletException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.web.templatemodels;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
public class Tags extends BaseTemplateModel {
|
public class Tags extends BaseTemplateModel {
|
||||||
|
|
||||||
protected final LinkedHashSet<String> tags;
|
protected final LinkedHashSet<String> tags;
|
||||||
|
@ -15,6 +17,7 @@ public class Tags extends BaseTemplateModel {
|
||||||
public Tags(LinkedHashSet<String> tags) {
|
public Tags(LinkedHashSet<String> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Template methods */
|
/* Template methods */
|
||||||
|
|
||||||
|
@ -27,14 +30,8 @@ public class Tags extends BaseTemplateModel {
|
||||||
public void add(String tag) {
|
public void add(String tag) {
|
||||||
tags.add(tag);
|
tags.add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getList() {
|
public String list() {
|
||||||
String tagList = "";
|
return StringUtils.join(tags, "");
|
||||||
|
|
||||||
for (String tag : tags) {
|
|
||||||
tagList += tag;
|
|
||||||
}
|
|
||||||
return tagList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,6 @@ public class User extends BaseTemplateModel {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Template methods */
|
|
||||||
|
|
||||||
/* Template properties */
|
/* Template properties */
|
||||||
|
|
||||||
public boolean isLoggedIn() {
|
public boolean isLoggedIn() {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -74,7 +75,7 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||||
return isVClass;
|
return isVClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* These methods perform some manipulation of the data returned by the Individual methods */
|
/* Template properties */
|
||||||
|
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
return UrlBuilder.getIndividualProfileUrl(individual, vreq);
|
return UrlBuilder.getIndividualProfileUrl(individual, vreq);
|
||||||
|
@ -165,13 +166,47 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||||
public String getLocalName() {
|
public String getLocalName() {
|
||||||
return individual.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<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 getSelfEditingId() {
|
public String selfEditingId() {
|
||||||
String id = null;
|
String id = null;
|
||||||
String idMatchingProperty = ConfigurationProperties.getBean(getServletContext()).getProperty("selfEditing.idMatchingProperty");
|
String idMatchingProperty =
|
||||||
|
ConfigurationProperties.getBean(getServletContext()).getProperty("selfEditing.idMatchingProperty");
|
||||||
if (! StringUtils.isBlank(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();
|
WebappDaoFactory wdf = vreq.getUnfilteredWebappDaoFactory();
|
||||||
Collection<DataPropertyStatement> ids =
|
Collection<DataPropertyStatement> ids =
|
||||||
wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty);
|
wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public abstract class BaseListedIndividual extends BaseTemplateModel {
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Template properties */
|
||||||
|
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
return cleanURIForDisplay( UrlBuilder.getIndividualProfileUrl(individual, vreq) );
|
return cleanURIForDisplay( UrlBuilder.getIndividualProfileUrl(individual, vreq) );
|
||||||
|
|
|
@ -15,7 +15,5 @@ public class ListedIndividual extends BaseListedIndividual {
|
||||||
public ListedIndividual(Individual individual, VitroRequest vreq) {
|
public ListedIndividual(Individual individual, VitroRequest vreq) {
|
||||||
super(individual, vreq);
|
super(individual, vreq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Access methods for templates */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ public abstract class BaseDumpDirective implements TemplateDirectiveModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Value {
|
enum Value {
|
||||||
NULL("[null]"),
|
NULL("<null>"),
|
||||||
UNDEFINED("[undefined]");
|
UNDEFINED("<undefined>");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<script type="text/javascript" src="${urls.base}/js/html5.js"></script>
|
<script type="text/javascript" src="${urls.base}/js/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
${headScripts.list}
|
${headScripts.list()}
|
||||||
|
|
||||||
<!--[if lt IE 7]>
|
<!--[if lt IE 7]>
|
||||||
<script type="text/javascript" src="${urls.base}/js/jquery_plugins/supersleight.js"></script>
|
<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 -->
|
<#-- Template for scripts loaded at the end of the body element -->
|
||||||
|
|
||||||
${scripts.list}
|
${scripts.list()}
|
||||||
|
|
||||||
<#include "googleAnalytics.ftl">
|
<#include "googleAnalytics.ftl">
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<!-- vitro base styles (application-wide) -->
|
<!-- vitro base styles (application-wide) -->
|
||||||
<link rel="stylesheet" href="${urls.base}/css/vitro.css" />
|
<link rel="stylesheet" href="${urls.base}/css/vitro.css" />
|
||||||
|
|
||||||
${stylesheets.list}
|
${stylesheets.list()}
|
||||||
|
|
||||||
<#--temporary until edit controller can include this when needed -->
|
<#--temporary until edit controller can include this when needed -->
|
||||||
<link rel="stylesheet" href="${urls.base}/css/edit.css" />
|
<link rel="stylesheet" href="${urls.base}/css/edit.css" />
|
Loading…
Add table
Reference in a new issue