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,85 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClassGroup,edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
<%@ page import="java.util.Iterator" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %><%/* this odd thing points to something in web.xml */ %>
<%@ page errorPage="/error.jsp"%>
<jsp:useBean id="loginHandler" class="edu.cornell.mannlib.vedit.beans.LoginFormBean" scope="session" />
<% /***********************************************
Display Browse Results (the "Index" menu command)
request.attributes:
a List with the name "classgroups"
collatedGroupNames
additionalParameterStr
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
for debugging info.
**********************************************/
if (request.getAttribute("classgroups") == null){
String e="browsesGroup.jsp expects that request attribute 'classgroups' be set to a List of classgroups to display.";
throw new JspException(e);
}
if (request.getAttribute("portalState") == null){
String e="browsesGroup.jsp expects that request attribute 'portalState' be set to a portal state [PortalFlag] object.";
throw new JspException(e);
}
String additionalParameterStr = ""; //we expect this to already be encoded as a url.
if(request.getAttribute("passthru") != null){
additionalParameterStr = (String)request.getAttribute("passthru");
}
if( request.getAttribute("classgroupsIsEmpty") != null && ((Boolean)request.getAttribute("classgroupsIsEmpty")) == true){
%>
<div id="content" class="siteMap">
<p>There not yet any items in the system.</p>
</div> <!-- content -->
<% } else { %>
<div id="content" class="siteMap">
<form name="filterForm" action="browsecontroller" method="post" class="padded" >
<jsp:include page="portalFlagChoices.jsp" flush="true" >
<jsp:param name="action" value="browse" />
</jsp:include>
</form>
<%
Collection classgroupList = (Collection) request.getAttribute("classgroups");
if (classgroupList != null) {
Iterator groupIter = classgroupList.iterator();
Object groupObj = null;
while (groupIter.hasNext()) {
groupObj = groupIter.next();
if (groupObj != null && groupObj instanceof VClassGroup) {
VClassGroup theGroup = (VClassGroup) groupObj; %>
<h2><%=theGroup.getPublicName()%></h2>
<% if (theGroup.getVitroClassList()!=null && theGroup.getVitroClassList().size()>0) {%>
<ul>
<% Iterator classIter=theGroup.getVitroClassList().iterator();
Object classObj=null;
while (classIter.hasNext()) {
classObj = classIter.next();
if (classObj!=null && classObj instanceof VClass) {
VClass theClass=(VClass)classObj;
String linkStr=response.encodeURL("entitylist");
if (theClass.getURI() == null)
theClass.setURI("null://null");
String queryStr="?vclassId="+URLEncoder.encode(theClass.getURI(),"UTF-8")+additionalParameterStr; %>
<li><a href="<%=linkStr+queryStr%>"><%=theClass.getName()%></a> (<%=theClass.getEntityCount()%>)</li>
<% }
}%>
</ul>
<% } else {%>
<ul><li>no entities</li></ul>
<% }
}
}
}%>
</div> <!-- content -->
<% } %>

View file

@ -0,0 +1,201 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ page import="java.lang.Integer"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.flags.PortalFlagChoices" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.flags.AuthFlag" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.flags.PortalFlag" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
<%@ page errorPage="/error.jsp"%>
<%
/***********************************************
Display A Form for filling out Portal Flags
request.attributes:
PortalFlag object via attribute "portalState".
request.parameters:
None yet.
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output for debugging info.
This was written by jc55 and split into this file from browseGroups.jsp by bdc34.
**********************************************/
PortalFlag portalFilterState = (PortalFlag) request.getAttribute("portalFlag");
if (portalFilterState == null) {
String e = "portalFlagChoices.jsp expects that request attribute 'portalFlag' be set to a portal state [PortalFlag] object.";
throw new JspException(e);
}
AuthFlag authFlag = (AuthFlag) request.getAttribute("authFlag");
if (authFlag == null) {
String e = "portalFlagChoices.jsp expects that request attribute 'authFlag' be set to a authorization state [AuthFlag] object.";
throw new JspException(e);
}
ApplicationBean appBean = (ApplicationBean) request.getAttribute("appBean");
if (appBean == null) {
String e = "portalFlagChoices.jsp expects request attribute 'appBean' be set to an application bean object";
throw new JspException(e);
}
Portal portal = (Portal) request.getAttribute("portalBean");
if( portal == null )
portal = new Portal();
int portalId = portal.getPortalId();
%>
<script type="text/javascript" language="Javascript" >
//<!--
function submitFilterValue(element) {
if (element.value==-1) {
; // do nothing
} else {
document.filterForm.filter.value=element.value;
document.filterForm.submit();
}
}
function checkAllFlag1( whichForm ) {
if (whichForm.flag1.length) {
for (i=0; i<whichForm.flag1.length; i++) {
whichForm.flag1[i].checked="checked";
}
} else {
whichForm.flag1.checked="checked";
}
}
function unCheckAllFlag1( whichForm ) {
if (whichForm.flag1.length) {
for (i=0; i<whichForm.flag1.length; i++) {
whichForm.flag1[i].checked="";
}
} else {
whichForm.flag1.checked="";
}
}
function checkAllFlag2( whichForm ) {
if (whichForm.flag2.length) {
for (i=0; i<whichForm.flag2.length; i++) {
whichForm.flag2[i].checked="checked";
}
} else {
whichForm.flag2.checked="checked";
}
}
function unCheckAllFlag2( whichForm ) {
if (whichForm.flag2.length) {
for (i=0; i<whichForm.flag2.length; i++) {
whichForm.flag2[i].checked="";
}
} else {
whichForm.flag2.checked="";
}
}
function checkAllFlag3( whichForm ) {
if (whichForm.flag3.length) {
for (i=0; i<whichForm.flag3.length; i++) {
whichForm.flag3[i].checked="checked";
}
} else {
whichForm.flag3.checked="checked";
}
}
function unCheckAllFlag3( whichForm ) {
if (whichForm.flag3.length) {
for (i=0; i<whichForm.flag3.length; i++) {
whichForm.flag3[i].checked="";
}
} else {
whichForm.flag3.checked="";
}
}
//-->
</script>
<%
String width1Str=request.getParameter("width1");
int width1=14;
if (width1Str!=null && !width1Str.equals("")) {
try {
width1=Integer.parseInt(width1Str);
} catch (NumberFormatException ex) {
throw new JspException("Error: width1 parameter cannot be decoded as integer in portalFlagChoices.jsp");
}
}
%>
<div class="browseFilter">
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center" >
<%
// Draw the appropriate checkboxes if they have been populated
// We are dealing with 3 situations for showing portal options in browsing:
// #1 For normal browsing (not in one of the application's shared portals [the CALS research portals] the user has 2 radio button choices:
// ___ [portal appName] only OR ___ don't filter
//
// #2 When browsing in one of the application's shared portals [1 of the 4 CALS research portals or the composite "All CALS Research" portal],
// the user has the same number of checkbox choices as there are shared portals (e.g, 4 for CALS)
// Optionally limit to:
// ___ New life sciences ___ Environmental sciences ___ Land grant mission ___ Applied social sciences
//
// #3 When an editor has logged in and starts browsing, all portals with an id less <= the application's maxPortalId are always shown as options
// unless filters are turned completely off by an incoming request parameter
boolean haveFlag1Choices=false;
if (appBean.isFlag1Active()&& appBean.getFlag1List()!=null && appBean.getFlag1List().size()>1) {
if (portalFilterState.getFlag1DisplayStatus()==PortalFlag.SHOW_SHARED_PORTALS || authFlag.getUserSecurityLevel()>=ApplicationBean.FILTER_SECURITY_LEVEL) {
haveFlag1Choices=true;%>
<tr valign="top" align="left">
<td width="<%=width1%>%" class="form-item">
<input type="radio" name="omit1" value="false" <%=portalFilterState.getFlag1Exclusive()?"":"checked='checked'"%> /> limit to
<input type="radio" name="omit1" value="true" <%=portalFilterState.getFlag1Exclusive()?"checked='checked'":""%> /> omit
</td>
<td class="form-item">
<%=PortalFlagChoices.getFlag1Choices(portalFilterState,appBean,portalId)%>
</td></tr>
<% }
}
String actionStr=request.getParameter("action");
boolean haveFlag2Choices=false;
if (appBean.isFlag2Active() && appBean.getFlag2List()!=null
&& appBean.getFlag2List().size()>1
&& (actionStr==null || (actionStr.equals("browse") && authFlag.getUserSecurityLevel()>=ApplicationBean.FILTER_SECURITY_LEVEL))) {
haveFlag2Choices=true;%>
<tr valign="top" align="left">
<td class="form-item">
<input type="radio" name="omit2" value="false" <%=portalFilterState.getFlag2Exclusive()?"":"checked='checked'"%> /> limit to
<input type="radio" name="omit2" value="true" <%=portalFilterState.getFlag2Exclusive()?"checked='checked'":""%> /> omit
</td><td class="form-item">
<%=PortalFlagChoices.getFlag2Choices(portalFilterState, appBean)%>
</td></tr><%
}
boolean haveFlag3Choices=false;
if (appBean.isFlag3Active() && appBean.getFlag3List()!=null
&& appBean.getFlag3List().size()>1
&& (actionStr==null || (actionStr.equals("browse") && authFlag.getUserSecurityLevel()>=ApplicationBean.FILTER_SECURITY_LEVEL))) {
haveFlag3Choices=true;%>
<tr valign="top" align="left">
<td class="form-item">
<input type="radio" name="omit3" value="false" <%=portalFilterState.getFlag3Exclusive()?"":"checked='checked'"%> /> limit to
<input type="radio" name="omit3" value="true" <%=portalFilterState.getFlag3Exclusive()?"checked='checked'":""%> /> omit
</td><td class="form-item">
<%=PortalFlagChoices.getFlag3Choices(portalFilterState,appBean,portal)%>
</td></tr><%
}
//if (actionStr!=null && actionStr.equals("browse")){
if (haveFlag1Choices || haveFlag2Choices || haveFlag3Choices) {%>
<tr><td colspan="2">
<input type="radio" name="filter" value="true" onclick="submitFilterValue(this);" /> filter as indicated above
<% if (authFlag.getUserSecurityLevel()>=appBean.FILTER_SECURITY_LEVEL) {%>
<input type="radio" name="filter" value="false" onclick="submitFilterValue(this);" /> don't filter at all<%
}%>
</td></tr><%
}%>
</table>
</div><!--browseFilter-->