Zwei kleinere Änderungen:

- Besseres Logging bei Exceptions, die in einer JSP auftreten
- Fehlerkorrektur im SelectFilter für CustomizableObjectList. Der SelectFilter war nicht null sicher, das heißt wenn der Wert für den der Select-Filter definiert ist bei einem Item nicht 
  vorhanden ist, kam es zu einer NPE.


git-svn-id: https://svn.libreccm.org/ccm/trunk@1194 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-10-25 09:39:48 +00:00
parent 722275e115
commit 86d98cb4c7
2 changed files with 46 additions and 49 deletions

View File

@ -75,23 +75,18 @@ public class DefinePage extends DefineContainer implements JSPConstants {
private boolean m_cache = true; private boolean m_cache = true;
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(DefinePage.class.getName()); Logger.getLogger(DefinePage.class.getName());
private static CacheTable s_pageCache = new CacheTable("PageCache"); private static CacheTable s_pageCache = new CacheTable("PageCache");
// maps URL(/packages/foo/www/asdf.jsp) -> {Page, creation date} // maps URL(/packages/foo/www/asdf.jsp) -> {Page, creation date}
// should this be a CacheTable or not? // should this be a CacheTable or not?
private static Map s_pageLocks = new HashMap(); private static Map s_pageLocks = new HashMap();
/** /**
* Creates a Bebop Page instance. A page tag is a special case * Creates a Bebop Page instance. A page tag is a special case
* because we don't expect it to have a parent tag. * because we don't expect it to have a parent tag.
*/ */
public int doStartTag() throws JspException { public int doStartTag() throws JspException {
if (m_cache) { if (m_cache) {
String cacheKey = DispatcherHelper.getCurrentResourcePath String cacheKey = DispatcherHelper.getCurrentResourcePath((HttpServletRequest) pageContext.getRequest());
((HttpServletRequest)pageContext.getRequest());
Object pageLock; Object pageLock;
// First off all we have the global synchronization // First off all we have the global synchronization
// block to get the page's unique sync object. // block to get the page's unique sync object.
@ -110,8 +105,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
Object[] pair = cached.getPageTimeStampPair(); Object[] pair = cached.getPageTimeStampPair();
long pageDate = ((Long) pair[1]).longValue(); long pageDate = ((Long) pair[1]).longValue();
File jspFile = new File(pageContext.getServletContext() File jspFile = new File(pageContext.getServletContext().getRealPath(cacheKey));
.getRealPath(cacheKey));
if (jspFile.lastModified() <= pageDate) { if (jspFile.lastModified() <= pageDate) {
// jsp file is not newer than cached page, // jsp file is not newer than cached page,
// and page hasn't been marked as dirty by anyone so we can use the cached page. // and page hasn't been marked as dirty by anyone so we can use the cached page.
@ -167,7 +161,6 @@ public class DefinePage extends DefineContainer implements JSPConstants {
s_pageCache.remove(resourceURL); s_pageCache.remove(resourceURL);
} }
private Page buildPage() throws JspException { private Page buildPage() throws JspException {
Page page; Page page;
@ -219,8 +212,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
public int doEndTag() throws JspException { public int doEndTag() throws JspException {
try { try {
if (m_cache) { if (m_cache) {
String cacheKey = DispatcherHelper.getCurrentResourcePath String cacheKey = DispatcherHelper.getCurrentResourcePath((HttpServletRequest) pageContext.getRequest());
((HttpServletRequest)pageContext.getRequest());
Object pageLock; Object pageLock;
// Global lock to get hold of page sync object // Global lock to get hold of page sync object
synchronized (s_pageLocks) { synchronized (s_pageLocks) {
@ -265,8 +257,7 @@ public class DefinePage extends DefineContainer implements JSPConstants {
} else if (m_master != null) { } else if (m_master != null) {
// if we have a master page, then we pass control to it, // if we have a master page, then we pass control to it,
// with the current (m_page) as a request attribute. // with the current (m_page) as a request attribute.
pageContext.getRequest() pageContext.getRequest().setAttribute("com.arsdigita.bebop.SlavePage", m_page);
.setAttribute("com.arsdigita.bebop.SlavePage", m_page);
DispatcherHelper.forwardRequestByPath(m_master, pageContext); DispatcherHelper.forwardRequestByPath(m_master, pageContext);
} else { } else {
// pass on the document to the ShowAll code. Note ugly // pass on the document to the ShowAll code. Note ugly
@ -282,11 +273,9 @@ public class DefinePage extends DefineContainer implements JSPConstants {
try { try {
doc = new Document(); doc = new Document();
state = m_page.process(req, resp); state = m_page.process(req, resp);
} } catch (ParserConfigurationException ex) {
catch (ParserConfigurationException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} } catch (ServletException ex) {
catch (ServletException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
m_page.generateXML(state, doc); m_page.generateXML(state, doc);
@ -302,6 +291,8 @@ public class DefinePage extends DefineContainer implements JSPConstants {
} catch (Throwable nested) { } catch (Throwable nested) {
// serving error page failed, so // serving error page failed, so
// percolate error up to top-level // percolate error up to top-level
s_log.error("PageContext failed to handle exceptionb exception: ",
nested);
throw new UncheckedWrapperException(e); throw new UncheckedWrapperException(e);
} }
return SKIP_PAGE; return SKIP_PAGE;

View File

@ -16,6 +16,7 @@ import java.util.Set;
* paginator) and using each distinct value of the property as option. * paginator) and using each distinct value of the property as option.
* *
* @author Jens Pelzetter * @author Jens Pelzetter
* @version $Id$
*/ */
public class SelectFilter implements Filter { public class SelectFilter implements Filter {
@ -129,9 +130,14 @@ public class SelectFilter implements Filter {
while (objects.next()) { while (objects.next()) {
dobj = objects.getDataObject(); dobj = objects.getDataObject();
option = (dobj.get(property)).toString(); final Object propValue = dobj.get(property);
if (propValue == null) {
continue;
} else {
option = propValue.toString();
optionsSet.add(option); optionsSet.add(option);
} }
}
options = new ArrayList<String>(optionsSet); options = new ArrayList<String>(optionsSet);
Collections.sort(options); Collections.sort(options);