VIVO-297 Use /display form of URLs on pages, not /individual form.
Individuals that don't belong to the default namespace still use the /individual form.
This commit is contained in:
parent
b94cd7950d
commit
7cccf19e45
2 changed files with 5 additions and 26 deletions
|
@ -5,15 +5,12 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
//import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
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.IndividualImpl;
|
||||
|
@ -33,6 +30,7 @@ public class UrlBuilder {
|
|||
BROWSE("/browse"),
|
||||
CONTACT("/contact"),
|
||||
DATA_PROPERTY_EDIT("/datapropEdit"),
|
||||
DISPLAY("/display"),
|
||||
INDIVIDUAL("/individual"),
|
||||
INDIVIDUAL_EDIT("/entityEdit"),
|
||||
INDIVIDUAL_LIST("/individuallist"),
|
||||
|
@ -250,14 +248,14 @@ public class UrlBuilder {
|
|||
String defaultNamespace = wadf.getDefaultNamespace();
|
||||
|
||||
if (defaultNamespace.equals(namespace)) {
|
||||
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName);
|
||||
profileUrl = getUrl(Route.DISPLAY.path() + "/" + localName);
|
||||
} else {
|
||||
if (wadf.getApplicationDao().isExternallyLinkedNamespace(namespace)) {
|
||||
log.debug("Found externally linked namespace " + namespace);
|
||||
profileUrl = namespace + localName;
|
||||
} else {
|
||||
ParamMap params = new ParamMap("uri", individual.getURI());
|
||||
profileUrl = getUrl("/individual", params);
|
||||
profileUrl = getUrl(Route.INDIVIDUAL.path(), params);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -284,25 +282,6 @@ public class UrlBuilder {
|
|||
return getIndividualProfileUrl(new IndividualImpl(individualUri), vreq);
|
||||
}
|
||||
|
||||
protected static String getIndividualProfileUrl(
|
||||
String individualUri,
|
||||
String namespace, String localName,
|
||||
String defaultNamespace){
|
||||
String profileUrl = "";
|
||||
try{
|
||||
if ( isUriInDefaultNamespace( individualUri, defaultNamespace) ) {
|
||||
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName);
|
||||
} else {
|
||||
ParamMap params = new ParamMap("uri", individualUri);
|
||||
profileUrl = getUrl("/individual", params);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn(e);
|
||||
return null;
|
||||
}
|
||||
return profileUrl;
|
||||
}
|
||||
|
||||
public static boolean isUriInDefaultNamespace(String individualUri, VitroRequest vreq) {
|
||||
return isUriInDefaultNamespace(individualUri, vreq.getWebappDaoFactory());
|
||||
}
|
||||
|
|
|
@ -94,11 +94,11 @@ public class UrlBuilderTest extends AbstractTestClass {
|
|||
|
||||
String uri = "http://example.com/individual/n2343";
|
||||
String url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/individual/n2343", url);
|
||||
Assert.assertEquals("http://example.com/display/n2343", url);
|
||||
|
||||
uri = "http://example.com/individual/bob";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
Assert.assertEquals("http://example.com/individual/bob",url);
|
||||
Assert.assertEquals("http://example.com/display/bob",url);
|
||||
|
||||
uri = "http://nondefaultNS.com/individual/n2343";
|
||||
url = UrlBuilder.getIndividualProfileUrl(uri, vreq);
|
||||
|
|
Loading…
Add table
Reference in a new issue