Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/AbstractTest$1.class =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/AbstractTest.class =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/MockUser$HashUtil.class =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/MockUser.class =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/TestSuite.class =================================================================== diff -u Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/learner/MockLearner.class =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/monitor/MockMonitor.class =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 Binary files differ Index: TestHarness4LAMS2/build/org/lamsfoundation/testharness/monitor/MonitorTest.class =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 Binary files differ Index: TestHarness4LAMS2/monitorTest1.properties =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 --- TestHarness4LAMS2/monitorTest1.properties (.../monitorTest1.properties) (revision 8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7) +++ TestHarness4LAMS2/monitorTest1.properties (.../monitorTest1.properties) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -26,8 +26,8 @@ #----------------------------------------------------------------- # A few URLs have to be defined when CallType is WEB. #----------------------------------------------------------------- -InitLessonURL = /monitoring/monitoring.do?method=initializeLesson&learningDesignID=%ldId%&userID=%uid%&lessonName=%name%&lessonDescription= -CreateLessonClassURL = /monitoring/createLessonClass?userID=%uid% +InitLessonURL = /monitoring/monitoring.do?method=initializeLesson&learningDesignID=%ldId%&organisationID=%orgId%&userID=%uid%&lessonName=%name% +CreateLessonClassURL = /monitoring/monitoring.do?method=createLessonClass&userID=%uid% StartLessonURL = /monitoring/monitoring.do?method=startLesson&lessonID=%lsId%&userID=%uid% GetLessonDetailsURL = /monitoring/monitoring.do?method=getLessonDetailsJSON&lessonID=%lsId% Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java =================================================================== diff -u -r84a30dc664676f42b1dbe5ed1699597a194ed7b7 -r86f8f142891162680c6f7ed66a8c4edf574df991 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 84a30dc664676f42b1dbe5ed1699597a194ed7b7) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/learner/MockLearner.java (.../MockLearner.java) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -98,6 +98,9 @@ private static final String SCRATCHIE_RESULTS_SUBSTRING = "/lams/tool/lascrt11/learning/showResults.do"; private static final Pattern SCRATCHIE_SCRATCH_PATTERN = Pattern.compile("scratchItem\\((\\d+), (\\d+)\\)"); + private static final Pattern ASSESSMENT_FINISH_PATTERN = Pattern + .compile("'(/lams/tool/laasse10/learning/finish\\.do\\?.*)'"); + private static final Pattern SESSION_MAP_ID_PATTERN = Pattern.compile("sessionMapID=(.+)\\&"); private static final String LOAD_TOOL_ACTIVITY_SUBSTRING = "Load Tool Activity"; @@ -281,7 +284,7 @@ String httpString = respAsText.substring(index + 1, indexEnd); if ((httpString.indexOf("www.w3.org") == -1) && !httpString.endsWith(".js") && !httpString.endsWith(".css")) { - MockLearner.log.debug("Forwarding to discovered link " + httpString); + MockLearner.log.debug("Forwarding user " + username + " to discovered link " + httpString); return (WebResponse) new Call(wc, test, "", httpString).execute(); } } @@ -348,7 +351,7 @@ } String scratchURL = "/lams/tool/lascrt11/learning/isAnswerCorrect.do?answerUid="; - m = SESSION_MAP_ID_PATTERN.matcher(asText); + m = MockLearner.SESSION_MAP_ID_PATTERN.matcher(asText); String sessionMapID = null; String recordScratchedURL = null; @@ -359,7 +362,7 @@ + "&answerUid="; refreshQuestionsURL = "/lams/tool/lascrt11/learning/refreshQuestionList.do?sessionMapID=" + sessionMapID; } else { - log.warn("Session map ID was not found in Scratchie Tool"); + MockLearner.log.warn("Session map ID was not found in Scratchie Tool"); } Random generator = new Random(); @@ -394,7 +397,7 @@ try { Thread.sleep(3000); } catch (InterruptedException e) { - log.warn("Waiting to scratch was interuppted"); + MockLearner.log.warn("Waiting to scratch was interuppted"); } } } @@ -505,7 +508,16 @@ } form = forms[index]; } - return (WebResponse) new Call(wc, test, "", fillFormArbitrarily(form)).execute(); + WebResponse resp = (WebResponse) new Call(wc, test, "", fillFormArbitrarily(form)).execute(); + + // check if it is assessment activity + String asText = resp.getText(); + Matcher m = MockLearner.ASSESSMENT_FINISH_PATTERN.matcher(asText); + if (m.find()) { + resp = (WebResponse) new Call(wc, test, "", m.group(1)).execute(); + } + + return resp; } private String getLesson(String getLessonURL, String lsId) throws WddxDeserializationException, IOException { Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java =================================================================== diff -u -r8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7 -r86f8f142891162680c6f7ed66a8c4edf574df991 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java (.../MockMonitor.java) (revision 8e1ed196bfc1c28860729d8b0a23878bb3ecf1e7) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MockMonitor.java (.../MockMonitor.java) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -64,6 +64,8 @@ private static final String LESSON_ID_PATTERN = "%lsId%"; + private static final String ORGANISATION_ID_PATTERN = "%orgId%"; + private static final String LESSON_ID_KEY = "messageValue"; private static final String LESSON_CREATED_FLAG = "true"; @@ -83,15 +85,16 @@ super(test, username, password, userId); } - public String initLesson(String initLessonURL, String ldId, String userId, String name) { + public String initLesson(String initLessonURL, String ldId, String organisationID, String userId, String name) { try { if (userId == null) { throw new TestHarnessException( "User id is missing. If you have set UserCreated (admin properties) to true, then you must set UserId in the monitor properties."); } - MockMonitor.log.debug("initLessonURL " + initLessonURL + " ldId " + ldId + " userId " + userId + " name " - + name); + MockMonitor.log.debug("initLessonURL " + initLessonURL + " ldId " + ldId + " orgId " + organisationID + + " userId " + userId + " name " + name); String url = initLessonURL.replace(MockMonitor.LDID_PATTERN, ldId) + .replace(MockMonitor.ORGANISATION_ID_PATTERN, organisationID) .replace(MockMonitor.USER_ID_PATTERN, userId).replace(MockMonitor.LESSON_NAME_PATTERN, name); WebResponse resp = (WebResponse) new Call(wc, test, "Init Lesson", url).execute(); Hashtable hashtable = (Hashtable) TestUtil.deserialize(resp.getText()); Index: TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MonitorTest.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r86f8f142891162680c6f7ed66a8c4edf574df991 --- TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MonitorTest.java (.../MonitorTest.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ TestHarness4LAMS2/src/org/lamsfoundation/testharness/monitor/MonitorTest.java (.../MonitorTest.java) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -25,150 +25,143 @@ import java.util.concurrent.CountDownLatch; import org.lamsfoundation.testharness.AbstractTest; -import org.lamsfoundation.testharness.TestUtil; import org.lamsfoundation.testharness.Call.CallType; +import org.lamsfoundation.testharness.TestUtil; /** * @version - * - *

- * View Source - *

- * + * + *

+ * View Source + *

+ * * @author Fei Yang */ public class MonitorTest extends AbstractTest { - - public static final String DEFAULT_LESSON_NAME = "Lesson"; - + + public static final String DEFAULT_LESSON_NAME = "Lesson"; + private String initLessonURL; - + private String createLessonClassURL; - + private String startLessonURL; - + private String getLessonDetailsURL; - + private String getContributeActivitiesURL; - + private String getLearningDesignDetailsURL; - + private String getAllLearnersProgressURL; - + private String lessonName; - + private String lsId; - + private Thread monitorThread; /** * MonitorTest Construtor * */ - public MonitorTest(String testName, CallType callType, String rmiRegistryName, String webServiceAddress, Integer minDelay, Integer maxDelay, String initLessonURL, String createLessonClassURL, String startLessonURL, String getLessonDetailsURL, String getContributeActivitiesURL, String getLearningDesignDetailsURL, String getAllLearnersProgressURL, String lessonName, String lsId) { - super(testName, callType, rmiRegistryName, webServiceAddress, minDelay, maxDelay); - this.initLessonURL = initLessonURL; - this.createLessonClassURL = createLessonClassURL; - this.startLessonURL = startLessonURL; - this.getLessonDetailsURL = getLessonDetailsURL; - this.getContributeActivitiesURL = getContributeActivitiesURL; - this.getLearningDesignDetailsURL = getLearningDesignDetailsURL; - this.getAllLearnersProgressURL = getAllLearnersProgressURL; - this.lessonName = lessonName==null? TestUtil.buildName(testName,DEFAULT_LESSON_NAME) : TestUtil.buildName(testName, lessonName); - this.lsId = lsId; + public MonitorTest(String testName, CallType callType, String rmiRegistryName, String webServiceAddress, + Integer minDelay, Integer maxDelay, String initLessonURL, String createLessonClassURL, + String startLessonURL, String getLessonDetailsURL, String getContributeActivitiesURL, + String getLearningDesignDetailsURL, String getAllLearnersProgressURL, String lessonName, String lsId) { + super(testName, callType, rmiRegistryName, webServiceAddress, minDelay, maxDelay); + this.initLessonURL = initLessonURL; + this.createLessonClassURL = createLessonClassURL; + this.startLessonURL = startLessonURL; + this.getLessonDetailsURL = getLessonDetailsURL; + this.getContributeActivitiesURL = getContributeActivitiesURL; + this.getLearningDesignDetailsURL = getLearningDesignDetailsURL; + this.getAllLearnersProgressURL = getAllLearnersProgressURL; + this.lessonName = lessonName == null ? TestUtil.buildName(testName, MonitorTest.DEFAULT_LESSON_NAME) : TestUtil + .buildName(testName, lessonName); + this.lsId = lsId; } - - @Override - protected void startWEB(){ - MockMonitor monitor = (MockMonitor)users[0]; - if(lsId == null){ - monitor.login(); - String ldId = getTestSuite().getAuthorTest().getLdId(); - setLsId(monitor.initLesson(initLessonURL,ldId,monitor.getUserId(),lessonName)); - monitor.createLessonClass(createLessonClassURL,monitor.getUserId()); - monitor.startLesson(startLessonURL,lsId,monitor.getUserId()); - } - //monitor learners progress - monitorThread = new Thread(monitor, monitor.getUsername()); - monitorThread.start(); + @Override + protected void startWEB() { + MockMonitor monitor = (MockMonitor) users[0]; + if (lsId == null) { + monitor.login(); + String organisationID = getTestSuite().getAdminTest().getCourseId(); + String ldId = getTestSuite().getAuthorTest().getLdId(); + setLsId(monitor.initLesson(initLessonURL, ldId, organisationID, monitor.getUserId(), lessonName)); + monitor.createLessonClass(createLessonClassURL, monitor.getUserId()); + monitor.startLesson(startLessonURL, lsId, monitor.getUserId()); } + // monitor learners progress + monitorThread = new Thread(monitor, monitor.getUsername()); + monitorThread.start(); + } - @Override - protected void startWS(){ - //TODO implement me - } + @Override + protected void startWS() { + // TODO implement me + } - @Override - protected void startRMI(){ - //TODO implement me - } + @Override + protected void startRMI() { + // TODO implement me + } - public void notifyMonitorToStop(CountDownLatch stopSignal){ - if((monitorThread != null) && monitorThread.isAlive()){ - ((MockMonitor)users[0]).setStopFlag(stopSignal); - }else{ - stopSignal.countDown(); - } + public void notifyMonitorToStop(CountDownLatch stopSignal) { + if ((monitorThread != null) && monitorThread.isAlive()) { + ((MockMonitor) users[0]).setStopFlag(stopSignal); + } else { + stopSignal.countDown(); } + } - public final String getCreateLessonClassURL() { - return createLessonClassURL; - } + public final String getCreateLessonClassURL() { + return createLessonClassURL; + } + public final void setCreateLessonClassURL(String createLessonClassURL) { + this.createLessonClassURL = createLessonClassURL; + } - public final void setCreateLessonClassURL(String createLessonClassURL) { - this.createLessonClassURL = createLessonClassURL; - } + public final String getInitLessonURL() { + return initLessonURL; + } + public final void setInitLessonURL(String initLessonURL) { + this.initLessonURL = initLessonURL; + } - public final String getInitLessonURL() { - return initLessonURL; - } + public final String getStartLessonURL() { + return startLessonURL; + } + public final void setStartLessonURL(String startLessonURL) { + this.startLessonURL = startLessonURL; + } - public final void setInitLessonURL(String initLessonURL) { - this.initLessonURL = initLessonURL; - } + public final String getLsId() { + return lsId; + } + public final void setLsId(String lsId) { + this.lsId = lsId; + } - public final String getStartLessonURL() { - return startLessonURL; - } + public final String getGetAllLearnersProgressURL() { + return getAllLearnersProgressURL; + } + public final String getGetContributeActivitiesURL() { + return getContributeActivitiesURL; + } - public final void setStartLessonURL(String startLessonURL) { - this.startLessonURL = startLessonURL; - } + public final String getGetLearningDesignDetailsURL() { + return getLearningDesignDetailsURL; + } + public final String getGetLessonDetailsURL() { + return getLessonDetailsURL; + } - public final String getLsId() { - return lsId; - } - - - public final void setLsId(String lsId) { - this.lsId = lsId; - } - - - public final String getGetAllLearnersProgressURL() { - return getAllLearnersProgressURL; - } - - - public final String getGetContributeActivitiesURL() { - return getContributeActivitiesURL; - } - - - public final String getGetLearningDesignDetailsURL() { - return getLearningDesignDetailsURL; - } - - - public final String getGetLessonDetailsURL() { - return getLessonDetailsURL; - } - } Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r668a627903b72826f7dffa148a7e775139af8b5e -r86f8f142891162680c6f7ed66a8c4edf574df991 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/web/servlet/AbstractStoreWDDXPacketServlet.java =================================================================== diff -u -rc8c2ba7d3dc97478709b5d00b01c0cdde3bf9f6b -r86f8f142891162680c6f7ed66a8c4edf574df991 --- lams_common/src/java/org/lamsfoundation/lams/web/servlet/AbstractStoreWDDXPacketServlet.java (.../AbstractStoreWDDXPacketServlet.java) (revision c8c2ba7d3dc97478709b5d00b01c0cdde3bf9f6b) +++ lams_common/src/java/org/lamsfoundation/lams/web/servlet/AbstractStoreWDDXPacketServlet.java (.../AbstractStoreWDDXPacketServlet.java) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -24,16 +24,13 @@ package org.lamsfoundation.lams.web.servlet; import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -45,143 +42,132 @@ import org.springframework.web.context.support.WebApplicationContextUtils; /** - * Base servlet for handling WDDX packets sent by Flash. - * This servlet takes care of reading the packet from the - * POST body. A subclass must implement the process() method - * and the getMessageKey() method. + * Base servlet for handling WDDX packets sent by Flash. This servlet takes care of reading the packet from the POST + * body. A subclass must implement the process() method and the getMessageKey() method. *

- * If an error occurs during processing, the process method - * should throw an exception. The base class will log the exception - * and return an error message to Flash. + * If an error occurs during processing, the process method should throw an exception. The base class will log the + * exception and return an error message to Flash. *

- * We cannot use Struts actions as the WDDX packet is the - * complete contents POST body and Struts consumes the body + * We cannot use Struts actions as the WDDX packet is the complete contents POST body and Struts consumes the body * before we can get to it. *

- * If this servlet receives a GET rather than a POST, then an - * error packet (in wddx format) will be returned. + * If this servlet receives a GET rather than a POST, then an error packet (in wddx format) will be returned. *

- * If the log level is set to debug, then the both the received packet - * and the reply packet will be logged. + * If the log level is set to debug, then the both the received packet and the reply packet will be logged. * * @author Fiona Malikoff */ public abstract class AbstractStoreWDDXPacketServlet extends HttpServlet { - private static Logger log = Logger.getLogger(AbstractStoreWDDXPacketServlet.class); - private static IAuditService auditService; + private static Logger log = Logger.getLogger(AbstractStoreWDDXPacketServlet.class); + private static IAuditService auditService; - /** - * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest, HttpServletResponse) - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - Writer writer = response.getWriter(); - FlashMessage flashMessage = FlashMessage.getWDDXPacketGetReceived(getMessageKey(null,request)); + /** + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest, HttpServletResponse) + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + Writer writer = response.getWriter(); + FlashMessage flashMessage = FlashMessage.getWDDXPacketGetReceived(getMessageKey(null, request)); + writer.write(flashMessage.serializeMessage()); + } + + /** + * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, HttpServletResponse) + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { + AbstractStoreWDDXPacketServlet.auditService = getAuditService(); + PrintWriter writer = null; + String packet = null; + String replyPacket = null; + try { + writer = response.getWriter(); + + packet = AbstractStoreWDDXPacketServlet.getBody(request); + if (AbstractStoreWDDXPacketServlet.log.isDebugEnabled()) { + AbstractStoreWDDXPacketServlet.log.debug("Request " + request.getRequestURI() + + " received packet length " + packet); + } + + if (containsNulls(packet)) { + FlashMessage flashMessage = new FlashMessage(getMessageKey(packet, request), + "WDDXPacket contains null", FlashMessage.ERROR); writer.write(flashMessage.serializeMessage()); - } + } - /** - * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest, HttpServletResponse) - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws IOException - { - auditService = getAuditService(); - PrintWriter writer = null; - String packet = null; - String replyPacket = null; - try { - writer = response.getWriter(); + replyPacket = process(packet, request); - packet = getBody(request); - if ( log.isDebugEnabled() ) { - log.debug("Request "+request.getRequestURI()+" received packet length "+packet); - } + if (AbstractStoreWDDXPacketServlet.log.isDebugEnabled()) { + AbstractStoreWDDXPacketServlet.log.debug("Request " + request.getRequestURI() + " sending back packet " + + replyPacket); + } - if(containsNulls(packet)){ - FlashMessage flashMessage = new FlashMessage(getMessageKey(packet,request), - "WDDXPacket contains null", - FlashMessage.ERROR); - writer.write(flashMessage.serializeMessage()); - } + } catch (Exception e) { + // Don't want exceptions flowing back to Flash if we can help it. + String uri = request.getRequestURI(); + AbstractStoreWDDXPacketServlet.log.error(uri + " request triggered exception ", e); - replyPacket = process(packet, request); + FlashMessage flashMessage = FlashMessage.getExceptionOccured(getMessageKey(packet, request), + e.getMessage() != null ? e.getMessage() : e.getClass().getName()); + writer.write(flashMessage.serializeMessage()); - if ( log.isDebugEnabled() ) { - log.debug("Request "+request.getRequestURI()+" sending back packet "+replyPacket); - } - - } catch ( Exception e ) { - // Don't want exceptions flowing back to Flash if we can help it. - String uri = request.getRequestURI(); - log.error(uri+" request triggered exception ",e); - - FlashMessage flashMessage = FlashMessage.getExceptionOccured(getMessageKey(packet,request), - e.getMessage()!=null?e.getMessage():e.getClass().getName()); - writer.write(flashMessage.serializeMessage()); - - auditService.log(AbstractStoreWDDXPacketServlet.class.getName(),"URL:"+uri+" triggered exception"+e.toString()); - return; - } - - // can't inform Flash if an exception occurs now... - if ( writer != null ) - writer.println(replyPacket); + AbstractStoreWDDXPacketServlet.auditService.log(AbstractStoreWDDXPacketServlet.class.getName(), "URL:" + + uri + " triggered exception" + e.toString()); + return; } - - /** - * Checks whether the WDDX packet contains any invalid - * "". It returns true if there exists any such null - */ - protected boolean containsNulls(String packet) - { - if (packet.indexOf("") != -1) - return true; - else - return false; + // can't inform Flash if an exception occurs now... + if (writer != null) { + writer.println(replyPacket); } + } - /** - * Method to get the post body. - * Retrieves the body of the post as binary data, and then converts back to a character stream. - * The reason why we didn't use getReader() which retrieves the body of the post as character - * data, is because for very large learning designs, the wddx packet read in gets corrupted - * or truncated. The reason for this, is still unknown, however using getInputStream() doesn't - * seem to have this problem. - * TODO: investigate why getReader() doesn't work for large learning designs. The original code has - * been commented out below. - * @param req - * @return - * @throws IOException - */ - protected String getBody(HttpServletRequest req) - throws IOException - { - int tempContentLength = req.getContentLength(); - InputStream sis = req.getInputStream(); -/* byte[] content = new byte[1024*4]; - OutputStream bos = new ByteArrayOutputStream(tempContentLength>0 ? tempContentLength : 200); - int len; - while((len = sis.read(content)) != -1){ - bos.write(content,0,len); - } - return bos.toString(); - */ - BufferedReader buff = new BufferedReader(new InputStreamReader(sis, "UTF-8")); - - StringBuffer tempStrBuf = new StringBuffer( tempContentLength>0 ? tempContentLength : 200 ); - String tempStr; - tempStr = buff.readLine(); - while ( tempStr != null ) - { - tempStrBuf.append(tempStr); - tempStr = buff.readLine(); - } + /** + * Checks whether the WDDX packet contains any invalid "". It returns true if there exists any such null + */ + protected boolean containsNulls(String packet) { + if (packet.indexOf("") != -1) { + return true; + } else { + return false; + } + } - return(tempStrBuf.toString()); - + /** + * Method to get the post body. Retrieves the body of the post as binary data, and then converts back to a character + * stream. The reason why we didn't use getReader() which retrieves the body of the post as character data, is + * because for very large learning designs, the wddx packet read in gets corrupted or truncated. The reason for + * this, is still unknown, however using getInputStream() doesn't seem to have this problem. TODO: investigate why + * getReader() doesn't work for large learning designs. The original code has been commented out below. + * + * @param req + * @return + * @throws IOException + */ + public static String getBody(HttpServletRequest req) throws IOException { + int tempContentLength = req.getContentLength(); + InputStream sis = req.getInputStream(); + /* byte[] content = new byte[1024*4]; + OutputStream bos = new ByteArrayOutputStream(tempContentLength>0 ? tempContentLength : 200); + int len; + while((len = sis.read(content)) != -1){ + bos.write(content,0,len); + } + return bos.toString(); + */ + BufferedReader buff = new BufferedReader(new InputStreamReader(sis, "UTF-8")); + + StringBuffer tempStrBuf = new StringBuffer(tempContentLength > 0 ? tempContentLength : 200); + String tempStr; + tempStr = buff.readLine(); + while (tempStr != null) { + tempStrBuf.append(tempStr); + tempStr = buff.readLine(); + } + + return (tempStrBuf.toString()); + /* BufferedReader tempReader = req.getReader(); int tempContentLength = req.getContentLength(); @@ -195,42 +181,41 @@ } return(tempStrBuf.toString()); */ - - } - /** - * Process the packet received from Flash. - *

- * If an error occurs, this method should throw an exception - * so that the base class will log the exception and return an error message - * to Flash. - * @return A string which is a WDDX packet containing a FlashMessage. - */ - abstract protected String process(String packet, HttpServletRequest request) - throws Exception; + } - /** - * Get the "name" of the servlet. This must match the name - * that is returned in the messageKey section of the FlashMessage - * when the packet is successfully stored. - *

- * If an exception is thrown by process(), the base class - * generates an error packet to send back to Flash. It will include - * this messageKey in the error message, so that the Flash client - * can match the error to the call. - * @return messageKey - */ - abstract protected String getMessageKey(String packet, HttpServletRequest request); - - /** - * Get AuditService bean. - * @return - */ - private IAuditService getAuditService(){ - if(auditService==null){ - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext()); - auditService = (IAuditService) ctx.getBean("auditService"); - } - return auditService; + /** + * Process the packet received from Flash. + *

+ * If an error occurs, this method should throw an exception so that the base class will log the exception and + * return an error message to Flash. + * + * @return A string which is a WDDX packet containing a FlashMessage. + */ + abstract protected String process(String packet, HttpServletRequest request) throws Exception; + + /** + * Get the "name" of the servlet. This must match the name that is returned in the messageKey section of the + * FlashMessage when the packet is successfully stored. + *

+ * If an exception is thrown by process(), the base class generates an error packet to send back to Flash. It will + * include this messageKey in the error message, so that the Flash client can match the error to the call. + * + * @return messageKey + */ + abstract protected String getMessageKey(String packet, HttpServletRequest request); + + /** + * Get AuditService bean. + * + * @return + */ + private IAuditService getAuditService() { + if (AbstractStoreWDDXPacketServlet.auditService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this + .getServletContext()); + AbstractStoreWDDXPacketServlet.auditService = (IAuditService) ctx.getBean("auditService"); } + return AbstractStoreWDDXPacketServlet.auditService; + } } Index: lams_tool_assessment/web/pages/learning/parts/allquestions.jsp =================================================================== diff -u -rd89dfbd4b29efec465fba9bb517dea1d173c3844 -r86f8f142891162680c6f7ed66a8c4edf574df991 --- lams_tool_assessment/web/pages/learning/parts/allquestions.jsp (.../allquestions.jsp) (revision d89dfbd4b29efec465fba9bb517dea1d173c3844) +++ lams_tool_assessment/web/pages/learning/parts/allquestions.jsp (.../allquestions.jsp) (revision 86f8f142891162680c6f7ed66a8c4edf574df991) @@ -1,5 +1,5 @@ <%@ include file="/common/taglibs.jsp"%> -

+