Improve output: distinguish between failed assertions (failures) and unexpected exceptions (errors), and print a filtered stack trace for any exception.

This commit is contained in:
jeb228 2010-01-29 22:13:57 +00:00
commit 4f2e303079
1839 changed files with 235630 additions and 0 deletions

View file

@ -0,0 +1,157 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="java.util.*"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.*" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<%@ page errorPage="/error.jsp"%>
<%
/***********************************************
Display a}x9n;:[
Search Results
request.attributes:
a Map object with the name "collatedResultsLists"
collatedGroupNames
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
for debugging info.
**********************************************/
if (request.getAttribute("collatedResultsLists") == null) {
String e = "searchBaisc.jsp expects that request attribute " +
"'collatedResultsLists' be set to a Map of Lists of results to display.";
throw new JspException(e);
}
if (request.getAttribute("collatedGroupNames") == null) {
String e = "searchBaisc.jsp expects that request attribute "
+ "'collatedGroupNames' be set to a list of keys in collatedResultsLists.";
throw new JspException(e);
}
int switchdivs = 0; // for making IDs for the plus-icon expansion divs
edu.cornell.mannlib.vitro.webapp.beans.Portal portal = (Portal) request.getAttribute("portalBean");
int portalId = portal.getPortalId();
Map results = (Map) request.getAttribute("collatedResultsLists");
out.println("<div id='content' class='contentsBrowseGroup'>");
//do classgroup toc
Iterator it = results.keySet().iterator();
out.println("<p class='searchTOC'>Jump to results of type: ");
while (it.hasNext()) {
Object key = it.next();
VClassGroup grp = (VClassGroup) results.get(key);
out.println(" <a href='#" + grp.getLocalName() + "'>" + key + "</a> ");
}
out.println(" </p>");
//get each ClassGroup
it = results.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
VClassGroup grp = (VClassGroup) results.get(key);
out.println("<h2 id='" + grp.getLocalName() + "'>" + key + "</h2>");
//get each VClassList
Iterator it2 = grp.iterator();
while (it2.hasNext()) {
VClassList vcl = (VClassList) it2.next();
int resultSetSize = vcl.getEntities().size();
int displayLimit = vcl.getDisplayLimit();
if (resultSetSize - displayLimit == 1)
++displayLimit;
boolean hiddenDivStarted = false;
out.println("<h3>" + vcl.getName() + " (" + resultSetSize + ")</h3>");
out.println("<ul>");
List ents = vcl.getEntities();
if (ents == null || ents.size() == 0)
out.println("<li>none</li>");
else {
//get each entity
Iterator it3 = ents.iterator();
int count = 0;
while (it3.hasNext()) {
Individual ent = (Individual) it3.next();
++count;
String escapedURIStr = "";
try {
escapedURIStr = URLEncoder.encode(ent.getURI(),"UTF-8");
} catch (Exception e) {
/*unsupported encoding?*/
}
out.println("<li>");
out.println("<a href='"
+ response.encodeURL(request.getContextPath()+"/entity?uri=" + escapedURIStr + "&amp;home=" + portalId)
+ "'>" + ent.getName().replaceAll("&","&amp;") + "</a>");
if (ent.getMoniker() != null && ent.getMoniker().length() > 0) {
out.println(" | " + ent.getMoniker().replaceAll("&","&amp;"));
}
if (portal.getPortalId() == 6) { //show anchors in impact portal for submitter's name
if (ent.getAnchor() != null && ent.getAnchor().length() > 0) {
out.println(" | <span class='externalLink'>" + ent.getAnchor() + "</span>");
}
}
/* if (portal.getAppName().equalsIgnoreCase("VIVO") || portal.getAppName().equalsIgnoreCase("Research")) {
//Medha's desired display
if (ent.getUrl() != null && ent.getUrl().length() > 0) {
out.println(" | <a class='externalLink' href='"
+ response.encodeURL(ent.getUrl().replaceAll("&","&amp;")) + "'>"
+ ent.getAnchor().replaceAll("&","&amp;") + "</a>");
} else if (ent.getAnchor() != null && ent.getAnchor().length() > 0) {
out.println(" | <span class='externalLink'>" + ent.getAnchor().replaceAll("&","&amp;") + "</span>");
}
List linksList = ent.getLinksList();
if (linksList != null) {
Iterator lit = linksList.iterator();
while (lit.hasNext()) {
Link l = (Link) lit.next();
if (l.getUrl() != null && l.getUrl().length() > 0) {
out.println(" | <a class='externalLink' href='"
+ response.encodeURL(l.getUrl().replaceAll("&","&amp;")) + "'>"
+ l.getAnchor().replaceAll("&","&amp;") + "</a>");
} else {
out.println(" | <span class='externalLink'>" + l.getAnchor().replaceAll("&","&amp;") + "</span>");
}
}
}
} else { //show the Google-like excerpt */
if (ent.getDescription() != null && ent.getDescription().length() > 0) {
out.println("<div>" + ent.getDescription() + "</div>");
}
/* } */
out.println("</li>");
int remaining = resultSetSize - count;
if (count == displayLimit && remaining > 0) {
hiddenDivStarted = true; switchdivs++; %>
</ul>
<div style="color: black; cursor: pointer;" onclick="javascript:switchGroupDisplay('extra_ib<%=switchdivs%>','extraSw_ib<%=switchdivs%>','<%= response.encodeURL(portal.getThemeDir())%>site_icons')"
title="click to toggle additional entities on or off" class="navlinkblock" onmouseover="onMouseOverHeading(this)"
onmouseout="onMouseOutHeading(this)">
<span class="resultsMoreSpan"><img src='<%= response.encodeURL( portal.getThemeDir() )+"site_icons/plus.gif"%>' id="extraSw_ib<%=switchdivs%>" alt="more results"/>
<% out.println("<strong>"+remaining+" more</strong>"); %>
</span>
</div>
<% out.println("<div id='extra_ib"+switchdivs+"' style='display:none'>");
out.println(" <ul>");
}
if ((count == resultSetSize) && (hiddenDivStarted)) {
out.println("</ul></div> <!-- extra_ib"+switchdivs+"-->");
}
} // END while it3.hasNext()
if (!hiddenDivStarted) {
out.println("</ul>");
}
} // END else have entities
} // END while it2.hasNext()
} // END while it.hasNext()
%>
</div><!--contentsBrowseGroup-->

View file

@ -0,0 +1,35 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<%@ page errorPage="/error.jsp"%>
<% /***********************************************
Used when the search results are empty.
request.attributes:
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
for debugging info.
**********************************************/
%>
<c:set var='lists' value='${requestScope.collatedResultsLists}'/>
<c:set var='groupNames' value='${requestScope.collatedGroupNames}'/>
<c:set var='portal' value='${requestScope.portal}'/>
<c:set var='portalBean' value='${requestScope.portalBean}'/>
<c:set var='portalId' scope='request' value='${portalBean.portalId}'/>
<c:set var='entitiesListJsp' value='/templates/entity/entityList.jsp'/>
<div id="content">
<div class="contents searchFailed">
<p class="warning">
<c:out value='${requestScope.message}'
default='No results were found for your query. Please modify your search and try again.'
escapeXml='false'/>
</p>
<jsp:include page="searchTips.jsp"/>
</div><!-- contents -->
</div><!-- content -->

View file

@ -0,0 +1,45 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<!-- %@ page errorPage="/error.jsp"% -->
<% /***********************************************
Used to display a search form.
request.attributes:
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
for debugging info.
**********************************************/
%>
<c:set var='portal' value='${requestScope.portal}'/>
<c:set var='portalBean' value='${requestScope.portalBean}'/>
<c:set var='themeDir' >
<c:out value='${portal.themeDir}'/>
</c:set>
<div class='contents searchForm'>
<div class="advancedSearchForm">
<form name="filterForm" method="post" action="search">
<h3>Search</h3>
<input class="top_padded" style="width:97%;" name="querytext" value="" type="text"/>
<!-- supplanted by including OR, NOT etc. with search terms
<input name="inclusion" value="all" checked="checked" type="radio"/> all terms entered
<input name="inclusion" value="any" type="radio"/> any terms entered
</p>
-->
<p><input class="form-button" value=" Search" type="submit"/></p>
</form>
</div><!--advancedSearchForm-->
<div class='searchTips'>
<jsp:include page="searchTips.jsp"/>
</div>
</div>

View file

@ -0,0 +1,55 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<%@ page errorPage="/error.jsp"%>
<% /***********************************************
Display a single search result group
request.attributes:
a List with objects with the named "entities"
a ClassGroup object named "classgroup"
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
for debugging info.
**********************************************/
if (request.getAttribute("entities") == null){
String e="searchGroup.jsp expects that request attribute 'entities' be set to the Entity object to display.";
throw new JspException(e);
}
if (request.getAttribute("classgroup") == null){
String e="searchGroup.jsp expects that request attribute 'classgroup' be set to the Entity object to display.";
throw new JspException(e);
}
%>
<c:set var='imageDir' value='images' />
<c:set var='entities' value='${requestScope.entities}'/><%/* just moving this into page scope for easy use */ %>
<c:set var='classgroup' value='${requestScope.classgroup}'/>
<c:set var='portal' value='${requestScope.portal}'/>
<c:set var='portalBean' value='${requestScope.portalBean}'/>
<div class='contents entity entity${entity.id}'>
<h1><c:out value="${entity.name}"/></h1>
<c:out value="${entity.moniker}" default="moniker?"/>
<c:if test="${!empty entity.anchor}">
<a href='<c:url value="${entity.url}"/>'>${entity.anchor}</a>
</c:if>
<c:forEach items="${entity.linksList}" var='link'>
| <a href='<c:url value="${link.url}"/>'${link.anchor}</a>
</c:forEach>
<c:if test="${!empty entity.imageThumb}">
<div class="thumbnail">
<c:if test="${!empty entity.imageFile}"><a target="_new" href="<c:url value='${imageDir}/${entity.imageFile}'/>"></c:if>
<img src="<c:url value='${imageDir}/${entity.imageThumb}'/>" title="click to view larger image in new window" width="150">
<c:if test="${!empty entity.imageFile}"></a></c:if>
</div>
</c:if>
<c:import url="${entityPropsListJsp}" /><%/* here we import the properties for the entity */ %>
<div class='description'>
<c:out value="${entity.description}" escapeXml ='false'/>
</div>
<jsp:include page="entityAdmin.jsp"/>
</div>

View file

@ -0,0 +1,173 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="java.util.*"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.*" %>
<%@ page import="org.apache.commons.lang.StringEscapeUtils" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ page errorPage="/error.jsp"%>
<%
/***********************************************
Display Paged Search Results
request.attributes:
List object with the name "beans"
request.parameters:
None yet.
********************************************* */
if (request.getAttribute("beans") == null) {
String e = "searchBaisc.jsp expects that request attribute " +
"'beans' be set to a List of Individuals to display.";
throw new JspException(e);
}
Portal portal = (Portal) request.getAttribute("portalBean");
String portalParm = "&amp;home=" + portal.getPortalId();
%>
<div id='content'><!-- searchPaged.jsp -->
<h2>Search Results for '<c:out value="${querytext}"></c:out>'
<c:if test="${! (empty requestScope.classgroupName)}">
limited to type '${requestScope.classgroupName}'</c:if>
<c:if test="${! (empty requestScope.typeName)}">
limited to type '${requestScope.typeName}'</c:if>
</h2>
<div class='contentsBrowseGroup'>
<%
if( request.getAttribute("classgroups") != null ){
%> <div class="searchTOC"><span class="jumpText">Show only results of this <b>type</b>:</span> <%
List groups = (List) request.getAttribute("classgroups");
Iterator it = groups.iterator();
while(it.hasNext()){
VClassGroup grp = (VClassGroup)it.next();
out.println("<a href='"
+ "./search?querytext="
+ URLEncoder.encode(request.getParameter("querytext"))
+ "&classgroup="
+ URLEncoder.encode(grp.getURI())
+ "'>");
out.println(StringEscapeUtils.escapeHtml(grp.getPublicName()));
out.println("</a>");
}
out.println("</div>");
}
if( request.getAttribute("types") != null ){
%> <div class="searchTOC"><span class="jumpText">Show only results of this <b>sub-type</b>:</span> <%
List types = (List) request.getAttribute("types");
Iterator it = types.iterator();
while(it.hasNext()){
VClass type = (VClass)it.next();
out.println("<a href='"
+ "./search?querytext="
+ URLEncoder.encode(request.getParameter("querytext"))
+ "&type="
+ URLEncoder.encode(type.getURI())
+ "'>");
out.println(StringEscapeUtils.escapeHtml(type.getName()));
out.println("</a>");
}
out.println("</div>");
}
/* generate search result list */
List beans = (List) request.getAttribute("beans");
Iterator it = beans.iterator();
out.println("<ul class='searchhits'>");
while (it.hasNext()) {
Individual ent = (Individual) it.next();
String escapedURIStr = "";
try {
escapedURIStr = URLEncoder.encode(ent.getURI(),"UTF-8");
} catch (Exception e) { } // unsupported encoding?
out.println("<li>");
out.print("<a href='"
+ response.encodeURL(
getServletContext().getContextPath()
+"/entity?uri=" + escapedURIStr
+ portalParm )
+ "'>"
+ StringEscapeUtils.escapeHtml( ent.getName() )
+ "</a> ");
if (ent.getMoniker() != null && ent.getMoniker().length() > 0)
out.println(" | " + StringEscapeUtils.escapeHtml(ent.getMoniker()));
// For now, custom search views just add additional information to the name and moniker
String searchViewPrefix = "/templates/search/";
String customSearchView = null;
for (VClass type : ent.getVClasses(true)) { // first get directly asserted class(es)
if (type!=null) {
customSearchView = type.getCustomSearchView();
if (customSearchView!=null && customSearchView.length()>0 ) {
// NOTE we are NOT putting "individualURL" in the request scope
// An included custom search view jsp can optionally implement a test for "individualURL"
// as a way to optionally render additional text as a link
// SEE entityList.jsp and searchViewWithTimekey.jsp as an example
request.setAttribute("individual",ent); %>
| <jsp:include page="<%=searchViewPrefix+type.getCustomSearchView()%>"/>
<% request.removeAttribute("individual");
// TODO: figure out which of the directly asserted classes should have precedence; for now, just take the 1st
break; // have to break because otherwise customSearchView may get reset to null and trigger more evaluation
}
}
}
if (customSearchView == null ) { // try inferred classes, too
for (VClass type : ent.getVClasses()) {
if (type!=null) {
customSearchView = type.getCustomSearchView();
if (customSearchView!=null && customSearchView.length()>0 ) {
// SEE NOTE just above
request.setAttribute("individual",ent);
%><jsp:include page="<%=searchViewPrefix+type.getCustomSearchView()%>"/><%
request.removeAttribute("individual");
//TODO: figure out which of the inferred classes should have precedence; for now, just take the 1st
break;
}
}
}
}
if (ent.getDescription() != null && ent.getDescription().length() > 0) {
out.println("<div class='searchFragment'>" + ent.getDescription() + "</div>");
}
out.println("</li>");
} // END while it.hasNext()
out.println("</ul>");
/* generate pageing list */
int startIndex = (Integer)request.getAttribute("startIndex");
int hitsPerPage = (Integer)request.getAttribute("hitsPerPage");
int hitsLength = (Integer)request.getAttribute("hitsLength");
int maxHitSize = (Integer)request.getAttribute("maxHitSize");
String basePageUrl =
getServletContext().getContextPath() + "/search?querytext="
+URLEncoder.encode(request.getParameter("querytext"),"UTF-8") +
request.getAttribute("refinment");
out.println("<div class='searchpages'>");
out.println("Pages:");
for(int i=0; i<hitsLength; i=i+hitsPerPage){
if( i < maxHitSize - hitsPerPage){
String classCurrentPage = i >= (startIndex) && i < (startIndex+ hitsPerPage)?"class='currentPage'":"";
out.println("<a "+classCurrentPage+" href='"+ basePageUrl
+ "&startIndex="+ i + "&hitsPerPage=" + hitsPerPage
+ "'>" + ((i/hitsPerPage) + 1) + "</a>");
}else{
out.println("<a class='moreHits' href='"+ basePageUrl
+ "&startIndex="+ i + "&hitsPerPage=" + hitsPerPage
+ "'>more...</a>");
break;
}
}
out.println("</div>");
%>
</div>
</div><!--content from searchPaged.jsp -->

View file

@ -0,0 +1,18 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<h3>Search Tips</h3>
<ul>
<li>Use short, single terms unless your searches are returning too many results</li>
<li>When you enter more than one term, the search will look for records containing <strong>all</strong> of them unless you add the word "OR" between your terms.</li>
<li>"NOT" can help limit searches -- e.g., <i>climate NOT change</i></li>
<li>Except for boolean operators, searches are <strong>not</strong> case-sensitive, so "Geneva" and "geneva" are equivalent</li>
<li>Enclose a phrase in quotes (") to search for the whole phrase, not individual words (e.g., "protein folding") -- <i>both leading and ending quotes are required</i></li>
<li>Phrase searches may be combined with boolean operators: <i>"climate change" OR "global warming"</i></li>
<li>The search uses <strong>stemming</strong> by default so that close word variations will also be found (e.g., "sequence" also matches "sequences" and "sequencing").
Use the wildcard <strong>*</strong> character to match wider variation (e.g., <strong>nano*</strong> to match both
<i>nanotechnology</i> and <i>nanofabrication</i>), but note that searching uses <i>stemmed</i>, or shortened, versions of words,
so "cogniti*" finds nothing while "cognit*" finds both <i>cognitive</i> and <i>cognition</i></li>
<li>If you're not sure of the spelling, put a <strong>~</strong> at the end -- e.g., <i>cabage~</i> finds <i>cabbage</i>,
<i>steven~</i> finds <i>Stephen</i> and <i>Stefan</i> (as well as a few unwanted extra words)</li>
<li>To match a person or unit's primary entry, enter <i>name: Smith</i> or <i>name: Biology</i></li>
</ul>