Modify IndividualTemplateModel.getProfileUrl() to return correct url for individuals with uris that are not in the default namespace.
This commit is contained in:
parent
ca7cf6d861
commit
f71dc53a63
2 changed files with 19 additions and 4 deletions
|
@ -7,11 +7,13 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.openrdf.model.URI;
|
||||||
|
import org.openrdf.model.impl.URIImpl;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Link;
|
import edu.cornell.mannlib.vitro.webapp.beans.Link;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Params;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder;
|
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder.ClassView;
|
import edu.cornell.mannlib.vitro.webapp.web.ViewFinder.ClassView;
|
||||||
|
|
||||||
|
@ -39,9 +41,22 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
// There may be other urls associated with the individual. E.g., we might need
|
// There may be other urls associated with the individual. E.g., we might need
|
||||||
// getEditUrl(), getDeleteUrl() to return the links computed by PropertyEditLinks.
|
// getEditUrl(), getDeleteUrl() to return the links computed by PropertyEditLinks.
|
||||||
// RY **** Need to account for everything in URLRewritingHttpServlet
|
// RY **** Need to account for everything in URLRewritingHttpServlet
|
||||||
// Currently this is incorrect for individuals that are not in the default namespace (e.g., geographic individuals).
|
|
||||||
public String getProfileUrl() {
|
public String getProfileUrl() {
|
||||||
return getUrl(PATH + "/" + individual.getLocalName());
|
String profileUrl = null;
|
||||||
|
String individualUri = individual.getURI();
|
||||||
|
|
||||||
|
URI uri = new URIImpl(individualUri);
|
||||||
|
String namespace = uri.getNamespace();
|
||||||
|
String defaultNamespace = vreq.getWebappDaoFactory().getDefaultNamespace();
|
||||||
|
|
||||||
|
if (defaultNamespace.equals(namespace)) {
|
||||||
|
profileUrl = getUrl(PATH + "/" + individual.getLocalName());
|
||||||
|
} else {
|
||||||
|
Params params = new Params("uri", individualUri);
|
||||||
|
profileUrl = getUrl("/individual", params);
|
||||||
|
}
|
||||||
|
|
||||||
|
return profileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSearchView() {
|
public String getSearchView() {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<a href="${individual.profileUrl}">${individual.name}</a>
|
<a href="${individual.profileUrl}">${individual.name}</a>
|
||||||
<ul class="individualData">
|
<ul class="individualData">
|
||||||
<@l.firstLastList>
|
<@l.firstLastList>
|
||||||
<li>${individual.moniker}</li>,
|
<#if individual.moniker??><li>${individual.moniker}</li>,</#if>
|
||||||
<#list individual.links as link>
|
<#list individual.links as link>
|
||||||
<li><a class="externalLink" href="${link.url}">${link.anchor}</a></li>,
|
<li><a class="externalLink" href="${link.url}">${link.anchor}</a></li>,
|
||||||
</#list>
|
</#list>
|
||||||
|
|
Loading…
Add table
Reference in a new issue