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(); Portal portal = vreq.getPortal();
int tabId = portal.getRootTabId(); int tabId = portal.getRootTabId();
Tab tab = vreq.getWebappDaoFactory().getTabDao().getTab(tabId,0,vreq.getAppBean()); Tab tab = vreq.getWebappDaoFactory().getTabDao().getTab(tabId,0,vreq.getAppBean());
return tab.getBody(); String body = tab.getBody();
if (body == null) {
body = "";
}
return body;
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils;
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.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.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.filters.PortalPickerFilter; import edu.cornell.mannlib.vitro.webapp.filters.PortalPickerFilter;
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
public class UrlBuilder { public class UrlBuilder {
@ -291,7 +291,8 @@ public class UrlBuilder {
private static String getIndividualProfileUrl(Individual individual, String individualUri, WebappDaoFactory wadf) { private static String getIndividualProfileUrl(Individual individual, String individualUri, WebappDaoFactory wadf) {
String profileUrl = null; String profileUrl = null;
URI uri = new URIImpl(individualUri); try {
URI uri = new URIImpl(individualUri); // throws exception if individualUri is invalid
String namespace = uri.getNamespace(); String namespace = uri.getNamespace();
String defaultNamespace = wadf.getDefaultNamespace(); String defaultNamespace = wadf.getDefaultNamespace();
@ -308,7 +309,10 @@ public class UrlBuilder {
profileUrl = getUrl("/individual", params); profileUrl = getUrl("/individual", params);
} }
} }
} catch (Exception e) {
log.warn(e);
return null;
}
return profileUrl; return profileUrl;
} }

View file

@ -24,7 +24,8 @@ public class IndividualProfileUrlMethod implements TemplateMethodModel {
Environment env = Environment.getCurrentEnvironment(); Environment env = Environment.getCurrentEnvironment();
HttpServletRequest request = (HttpServletRequest) env.getCustomAttribute("request"); HttpServletRequest request = (HttpServletRequest) env.getCustomAttribute("request");
VitroRequest vreq = new VitroRequest(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
} }
} }