From: <hs...@us...> - 2011-11-17 21:46:00
|
Revision: 982 http://treebase.svn.sourceforge.net/treebase/?rev=982&view=rev Author: hshyket Date: 2011-11-17 21:45:53 +0000 (Thu, 17 Nov 2011) Log Message: ----------- Updating the error message for when no study is found (and also handling no Taxa found). Adding JavaMelody monitoring system Modified Paths: -------------- trunk/treebase-web/pom.xml trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchSummaryController.java trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml trunk/treebase-web/src/main/webapp/WEB-INF/web.xml Added Paths: ----------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/exceptions/NoStudySpecifiedError.java trunk/treebase-web/src/main/webapp/WEB-INF/pages/errors/itemNotFound.jsp Modified: trunk/treebase-web/pom.xml =================================================================== --- trunk/treebase-web/pom.xml 2011-11-16 17:08:00 UTC (rev 981) +++ trunk/treebase-web/pom.xml 2011-11-17 21:45:53 UTC (rev 982) @@ -393,6 +393,33 @@ <version>1.0</version> </dependency> +<!-- javamelody-core --> + <dependency> + <groupId>net.bull.javamelody</groupId> + <artifactId>javamelody-core</artifactId> + <version>1.32.1</version> + </dependency> + <!-- itext, option to add PDF export --> + <dependency> + <groupId>com.lowagie</groupId> + <artifactId>itext</artifactId> + <version>2.1.7</version> + <exclusions> + <exclusion> + <artifactId>bcmail-jdk14</artifactId> + <groupId>bouncycastle</groupId> + </exclusion> + <exclusion> + <artifactId>bcprov-jdk14</artifactId> + <groupId>bouncycastle</groupId> + </exclusion> + <exclusion> + <artifactId>bctsp-jdk14</artifactId> + <groupId>bouncycastle</groupId> + </exclusion> + </exclusions> + </dependency> + </dependencies> </project> Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchSummaryController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchSummaryController.java 2011-11-16 17:08:00 UTC (rev 981) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/SearchSummaryController.java 2011-11-17 21:45:53 UTC (rev 982) @@ -50,6 +50,7 @@ import org.cipres.treebase.web.util.AnalyzedDataComparator; import org.cipres.treebase.web.util.ControllerUtil; +import org.cipres.treebase.web.exceptions.NoStudySpecifiedError; import org.springframework.validation.BindException; import org.springframework.web.servlet.ModelAndView; @@ -71,7 +72,6 @@ String defaultPage = null; private static final Logger LOGGER = Logger.getLogger(SearchSummaryController.class); - class NoStudySpecifiedError extends Error { } class UnknownStudyError extends Error { } class RestrictedStudyError extends Error { } @@ -90,7 +90,7 @@ theStudy = null; { Long studyID = getIDParam(param, "id"); - if (studyID == null) { throw new NoStudySpecifiedError(); } + if (studyID == null) { throw new NoStudySpecifiedError("No study was found"); } theStudy = getStudyService().findByID(studyID); if (theStudy == null) { throw new UnknownStudyError(); } LOGGER.debug("formBackingObject found study " + theStudy); @@ -268,7 +268,17 @@ */ private Long getIDParam(Map<String, String []> params, String paramName) { String [] IDParam = params.get(paramName); - return IDParam.length == 0 ? null : Long.parseLong(IDParam[0]); + if (IDParam == null || IDParam.length == 0) { + return null; + } + else { + try { + return Long.parseLong(IDParam[0]); + } + catch(Exception e) { + return null; + } + } } @Override Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java 2011-11-16 17:08:00 UTC (rev 981) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/TaxonSearchController.java 2011-11-17 21:45:53 UTC (rev 982) @@ -239,7 +239,7 @@ switch(namingAuthority) { case TREEBASE : LOGGER.debug("Going to search for TreeBASE IDs"); - if ( ! index.endsWith(".tb1") ) { + if (null != index && ! index.endsWith(".tb1") ) { TreebaseIDString idstr; try { idstr = new TreebaseIDString(identifier, Taxon.class, true); @@ -261,7 +261,7 @@ addMessage(request, "Ignoring malformed TreeBASE1 ID string '" + identifier + "', because: " + e.getMessage()); LOGGER.error("Couldn't parse legacy ID: "+e.getMessage()); } - if ( null != tb1LegacyId && index.matches(".*taxonVariant.*") ) { + if ( null != tb1LegacyId && null != index && index.matches(".*taxonVariant.*") ) { TaxonVariant tv = getTaxonHome().findVariantByTB1LegacyId(tb1LegacyId); LOGGER.debug("Found taxon variant: " + tv.getId()); if ( null != tv.getTaxon() ) { Added: trunk/treebase-web/src/main/java/org/cipres/treebase/web/exceptions/NoStudySpecifiedError.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/exceptions/NoStudySpecifiedError.java (rev 0) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/exceptions/NoStudySpecifiedError.java 2011-11-17 21:45:53 UTC (rev 982) @@ -0,0 +1,19 @@ + +package org.cipres.treebase.web.exceptions; + +/** + * EmptySubmissionException.java + * + * Created on Jun 7, 2006 + * @author lcchan + * + */ +public class NoStudySpecifiedError extends RuntimeException { + + /** + * Constructor. + */ + public NoStudySpecifiedError(String s) { + super(s); + } +} Added: trunk/treebase-web/src/main/webapp/WEB-INF/pages/errors/itemNotFound.jsp =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/pages/errors/itemNotFound.jsp (rev 0) +++ trunk/treebase-web/src/main/webapp/WEB-INF/pages/errors/itemNotFound.jsp 2011-11-17 21:45:53 UTC (rev 982) @@ -0,0 +1,3 @@ +<%@ include file="/common/taglibs.jsp" %> + +${requestScope.exception.message} \ No newline at end of file Modified: trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-11-16 17:08:00 UTC (rev 981) +++ trunk/treebase-web/src/main/webapp/WEB-INF/treebase-servlet.xml 2011-11-17 21:45:53 UTC (rev 982) @@ -1112,7 +1112,8 @@ <props> <prop key="org.springframework.dao.DataAccessException">/errors/dataAccessFailure</prop> <prop key="org.springframework.transaction.TransactionException">/errors/dataAccessFailure</prop> - <prop key="org.cipres.treebase.web.exceptions.EmptyStudyException">/errors/studyAccessFailure</prop> + <prop key="org.cipres.treebase.web.exceptions.EmptyStudyException">/errors/studyAccessFailure</prop> + <prop key="org.cipres.treebase.web.exceptions.NoStudySpecifiedError">/errors/itemNotFound</prop> </props> </property> </bean> Modified: trunk/treebase-web/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2011-11-16 17:08:00 UTC (rev 981) +++ trunk/treebase-web/src/main/webapp/WEB-INF/web.xml 2011-11-17 21:45:53 UTC (rev 982) @@ -111,7 +111,17 @@ <filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> - </filter> + </filter> + + <filter> + <filter-name>monitoring</filter-name> + <filter-class>net.bull.javamelody.MonitoringFilter</filter-class> + <init-param> + <param-name>system-actions-enabled</param-name> + <param-value>true</param-value> + </init-param> + </filter> + @@ -200,6 +210,12 @@ <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> + + <filter-mapping> + <filter-name>monitoring</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + @@ -215,6 +231,9 @@ <listener> <listener-class>net.sf.navigator.menu.MenuContextListener</listener-class> </listener> + <listener> + <listener-class>net.bull.javamelody.SessionListener</listener-class> + </listener> <!-- listener> <listener-class>org.cipres.treebase.web.listeners.EventListener</listener-class> </listener --> @@ -356,6 +375,10 @@ <exception-type>java.lang.Exception</exception-type> <location>/WEB-INF/pages/errors/uncaughtException.jsp</location> </error-page> + <error-page> + <exception-type>java.lang.Exception</exception-type> + <location>/WEB-INF/pages/errors/uncaughtException.jsp</location> + </error-page> <!-- Internal Server Error --> <error-page> <error-code>500</error-code> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |