Index: lams_central/src/java/org/lamsfoundation/lams/web/FlashCrashDumpServlet.java =================================================================== diff -u -r9cf6f80b33044116d7378e7eb384f771ac486a6b -rf1e3737e24004d9695e91768b4ce163bd6a6c146 --- lams_central/src/java/org/lamsfoundation/lams/web/FlashCrashDumpServlet.java (.../FlashCrashDumpServlet.java) (revision 9cf6f80b33044116d7378e7eb384f771ac486a6b) +++ lams_central/src/java/org/lamsfoundation/lams/web/FlashCrashDumpServlet.java (.../FlashCrashDumpServlet.java) (revision f1e3737e24004d9695e91768b4ce163bd6a6c146) @@ -1,12 +1,17 @@ package org.lamsfoundation.lams.web; +import java.util.Hashtable; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.wddx.FlashMessage; +import org.lamsfoundation.lams.util.wddx.WDDXProcessor; +import org.lamsfoundation.lams.util.wddx.WDDXTAGS; import org.lamsfoundation.lams.web.servlet.AbstractStoreWDDXPacketServlet; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -15,6 +20,10 @@ /** * Write a WDDX packet out to a log file for bug reporting / troubleshooting. * + * If the Flash packet contains a variable "crashDataBatch" at the top level of the packet, + * then the value of this field will be included in the name of the file. This is handy + * for grouping packets. + * * @author Fiona Malikoff * * @web:servlet name="flashCrashDump" @@ -34,11 +43,25 @@ HttpSession ss = SessionManager.getSession(); UserDTO user = ss !=null ? (UserDTO) ss.getAttribute(AttributeNames.USER) : null; if ( user == null ) { - log.warn("Attempt to dump file by someone not logged in. SessionManager session is "+ss); + log.warn("FlashCrashDumpServlet: Attempt to dump file by someone not logged in."); return new FlashMessage(MESSAGE_KEY,"User not logged in - unable to dump file.", FlashMessage.ERROR).serializeMessage(); } String id = PREFIX + user.getLogin(); + try { + // attempt to get the special Flash flag which groups packets together - not + // all the crash dump data can come in one packet as Flash can't cope with large + // packets. + Hashtable table = (Hashtable)WDDXProcessor.deserialize(wddxPacket); + String batch = (String) table.get(WDDXTAGS.CRASH_DUMP_BATCH); + log.debug("FlashCrashDumpServlet: batch value is "+batch); + if ( batch != null ) { + batch = StringUtils.deleteWhitespace(batch); + id = id + "_" + batch; + } + } catch ( Exception e ) { + log.warn("FlashCrashDumpServlet: Unable to deserialize packet - invalid data. Just writing out packet "+id,e); + } String filename = FileUtil.createDumpFile(wddxPacket.getBytes(), id, "xml"); FlashMessage flashMessage = new FlashMessage(MESSAGE_KEY,filename);