Merge r7477, r7485-7486 from nihvivo-rel-1.2-maint

This commit is contained in:
rjy7 2011-02-15 15:16:04 +00:00
parent fe2373d853
commit 3ce140a05b
3 changed files with 27 additions and 18 deletions

View file

@ -58,7 +58,11 @@ public class HomePageController extends FreemarkerHttpServlet {
Portal portal = vreq.getPortal();
int tabId = portal.getRootTabId();
Tab tab = vreq.getWebappDaoFactory().getTabDao().getTab(tabId,0,vreq.getAppBean());
return tab.getBody();
String body = tab.getBody();
if (body == null) {
body = "";
}
return body;
}
@Override

View file

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openrdf.model.URI;
@ -19,7 +20,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.filters.PortalPickerFilter;
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
public class UrlBuilder {
@ -291,24 +291,28 @@ public class UrlBuilder {
private static String getIndividualProfileUrl(Individual individual, String individualUri, WebappDaoFactory wadf) {
String profileUrl = null;
URI uri = new URIImpl(individualUri);
String namespace = uri.getNamespace();
String defaultNamespace = wadf.getDefaultNamespace();
String localName = individual.getLocalName();
if (defaultNamespace.equals(namespace)) {
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName);
} else {
if (wadf.getApplicationDao().isExternallyLinkedNamespace(namespace)) {
log.debug("Found externally linked namespace " + namespace);
profileUrl = namespace + "/" + localName;
try {
URI uri = new URIImpl(individualUri); // throws exception if individualUri is invalid
String namespace = uri.getNamespace();
String defaultNamespace = wadf.getDefaultNamespace();
String localName = individual.getLocalName();
if (defaultNamespace.equals(namespace)) {
profileUrl = getUrl(Route.INDIVIDUAL.path() + "/" + localName);
} else {
ParamMap params = new ParamMap("uri", individualUri);
profileUrl = getUrl("/individual", params);
if (wadf.getApplicationDao().isExternallyLinkedNamespace(namespace)) {
log.debug("Found externally linked namespace " + namespace);
profileUrl = namespace + "/" + localName;
} else {
ParamMap params = new ParamMap("uri", individualUri);
profileUrl = getUrl("/individual", params);
}
}
} catch (Exception e) {
log.warn(e);
return null;
}
return profileUrl;
}

View file

@ -24,7 +24,8 @@ public class IndividualProfileUrlMethod implements TemplateMethodModel {
Environment env = Environment.getCurrentEnvironment();
HttpServletRequest request = (HttpServletRequest) env.getCustomAttribute("request");
VitroRequest vreq = new VitroRequest(request);
return UrlBuilder.getIndividualProfileUrl(uri, vreq.getWebappDaoFactory());
String url = UrlBuilder.getIndividualProfileUrl(uri, vreq.getWebappDaoFactory());
return (url == null) ? "" : url; // don't return a null to the template
}
}