Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -r5ba75a338c76b23778bf80ab835209d38e2316cb -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 5ba75a338c76b23778bf80ab835209d38e2316cb) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -23,6 +23,9 @@ import java.util.List; import org.lamsfoundation.lams.tool.BasicToolVO; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; @@ -83,7 +86,7 @@ */ public QaSession retrieveQaSession(long qaSessionId); - public QaSession retrieveQaSessionOrNullById(long qaSessionId); + public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException; public void createQaSession(QaSession qaSession); @@ -104,6 +107,8 @@ public void createQa(QaContent qa); public void deleteQa(QaContent qa); + + public void deleteQaSession(QaSession QaSession) throws QaApplicationException; public void deleteUsrRespByQueId(Long qaQueId); @@ -124,13 +129,13 @@ * @param fromContentId * @param toContentId */ - public void copyToolContent(Long fromContentId, Long toContentId); + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException; - public void setAsDefineLater(Long toolContentId); + public void setAsDefineLater(Long toolContentId) throws DataMissingException, ToolException; public void unsetAsDefineLater(Long toolContentId); - public void setAsRunOffline(Long toolContentId); + public void setAsRunOffline(Long toolContentId) throws DataMissingException, ToolException; /** * TO BE DEFINED AS PART OF MAIN TOOL API @@ -168,7 +173,7 @@ * @param toolSessionId * @param toolContentId */ - public void createToolSession(Long toolSessionId, Long toolContentId); + public void createToolSession(Long toolSessionId, Long toolContentId) throws ToolException; /** * leaveToolSession(Long toolSessionId, User learner) should ideally should not be part this interface as it is @@ -179,7 +184,7 @@ * @param toolSessionId * @param toolContentId */ - public String leaveToolSession(Long toolSessionId, User learner); + public String leaveToolSession(Long toolSessionId,User learner) throws DataMissingException, ToolException; public BasicToolVO getToolBySignature(String toolSignature); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -r65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -33,6 +33,7 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; @@ -70,10 +71,9 @@ */ public class QaServicePOJO implements - IQaService, ToolContentManager, ToolSessionManager + IQaService, ToolContentManager, ToolSessionManager, QaAppConstants { - private IQaContentDAO qaDAO; private IQaQueContentDAO qaQueContentDAO; private IQaSessionDAO qaSessionDAO; @@ -125,7 +125,7 @@ } - public void createQa(QaContent qaContent) + public void createQa(QaContent qaContent) throws QaApplicationException { try { @@ -140,7 +140,7 @@ } - public QaContent retrieveQa(long toolContentId) + public QaContent retrieveQa(long toolContentId) throws QaApplicationException { try { @@ -157,7 +157,7 @@ /** * same as retrieveQa(long toolContentId) except that returns null if not found */ - public QaContent loadQa(long toolContentId) + public QaContent loadQa(long toolContentId) throws QaApplicationException { try { @@ -173,7 +173,7 @@ - public void createQaQue(QaQueContent qaQueContent) + public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException { try { @@ -187,7 +187,7 @@ } } - public void createQaSession(QaSession qaSession) + public void createQaSession(QaSession qaSession) throws QaApplicationException { try { @@ -201,7 +201,7 @@ } } - public void createQaQueUsr(QaQueUsr qaQueUsr) + public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException { try { @@ -216,7 +216,7 @@ } - public QaQueUsr loadQaQueUsr(Long userId) + public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException { try { @@ -232,7 +232,7 @@ } - public void createQaUsrResp(QaUsrResp qaUsrResp) + public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException { try { @@ -247,7 +247,7 @@ } - public QaUsrResp retrieveQaUsrResp(long responseId) + public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException { try { @@ -263,7 +263,7 @@ } - public void updateQaUsrResp(QaUsrResp qaUsrResp) + public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException { try { @@ -279,7 +279,7 @@ - public QaQueContent retrieveQaQue(long qaQueContentId) + public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException { try { @@ -294,7 +294,7 @@ } - public QaSession retrieveQaSession(long qaSessionId) + public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException { try { @@ -308,9 +308,7 @@ } } - - - public QaSession retrieveQaSessionOrNullById(long qaSessionId) + public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException { try { @@ -325,9 +323,7 @@ } - - - public QaContent retrieveQaBySession(long qaSessionId) + public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException { try { @@ -342,7 +338,7 @@ } - public void updateQa(QaContent qa) + public void updateQa(QaContent qa) throws QaApplicationException { try { @@ -357,7 +353,7 @@ } - public void updateQaSession(QaSession qaSession) + public void updateQaSession(QaSession qaSession) throws QaApplicationException { try { @@ -372,8 +368,7 @@ } } - - public void deleteQa(QaContent qa) + public void deleteQa(QaContent qa) throws QaApplicationException { try { @@ -387,7 +382,7 @@ } } - public void deleteQaById(Long qaId) + public void deleteQaById(Long qaId) throws QaApplicationException { try { @@ -401,8 +396,22 @@ } } + public void deleteQaSession(QaSession QaSession) throws QaApplicationException + { + try + { + qaSessionDAO.deleteQaSession(QaSession); + } + catch(DataAccessException e) + { + throw new QaApplicationException("Exception occured when lams is deleting" + + " the qa session: " + + e.getMessage(),e); + } + } - public void removeUserResponse(QaUsrResp resp) + + public void removeUserResponse(QaUsrResp resp) throws QaApplicationException { try { @@ -417,7 +426,7 @@ } - public void deleteUsrRespByQueId(Long qaQueId) + public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException { try { @@ -431,7 +440,7 @@ } } - public void deleteQaQueUsr(QaQueUsr qaQueUsr) + public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException { try { @@ -447,7 +456,7 @@ - public int countTotalNumberOfUserResponsed(QaContent qa) + public int countTotalNumberOfUserResponsed(QaContent qa) throws QaApplicationException { try { @@ -487,16 +496,23 @@ } } - - public Lesson getCurrentLesson(long lessonId) + /** + * + * Unused method + * @param lessonId + * @return + * @throws QaApplicationException + */ + public Lesson getCurrentLesson(long lessonId) throws QaApplicationException { try { - //this is a mock implementation to make the project compile and - //work. When the Lesson service is ready, we need to switch to - //real service implmenation. + /**this is a mock implementation to make the project compile and + work. When the Lesson service is ready, we need to switch to + real service implmenation. + */ return new Lesson(); - //return lsDAO.find(lsessionId); + /**return lsDAO.find(lsessionId); */ } catch (DataAccessException e) { @@ -507,72 +523,10 @@ } } - - /** - * Persistent user response into database. - * @see com.webmcq.ld.tool.survey.ISurveyService#saveUserResponses(java.util.List, - * long, long) - */ - public void saveUserResponses(List responses, long toolSessionId, User user) + public void saveQaContent(QaContent qa) throws QaApplicationException { try { - QaSession curSession = qaSessionDAO.getQaSessionById(toolSessionId); - - curSession.setSession_status(QaSession.INCOMPLETE); - //remove the question user no longer exist - curSession.removeQueUsersBy(responses); - //update the existing question user. - curSession.updateQueUsersBy(responses); - //add new question users - curSession.addNewQueUsersBy(responses); - //persist the updates - qaSessionDAO.UpdateQaSession(curSession); - - } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is saving" - + " user responses: " - + e.getMessage(), - e); - } - } - - - public int getQaClassSize(Long qaContentId) - { - //pre-condition validation - if (qaContentId == null) - throw new QaApplicationException("We can't calculate number" - + "of potential qa learner with null qa content id."); -/** - try - { - return toolService.getAllPotentialLearners(surveyContentId.longValue()) - .size(); - } - catch (LamsToolServiceException e) - { - throw new SurveyApplicationException("Exception occured when lams is caculating" - + " potential survey learners: " - + e.getMessage(), - e); - } -*/ - //TODO need to change to above implementation once it is done. - return 10; - } - - - - // public QaSession retrieveQaSession(long toolSessionId){} - - - public void saveQaContent(QaContent qa) - { - try - { qaDAO.saveQa(qa); } catch (DataAccessException e) @@ -583,7 +537,7 @@ } } - public QaQueUsr retrieveQaQueUsr(long qaQaQueUsrId) + public QaQueUsr retrieveQaQueUsr(long qaQaQueUsrId) throws QaApplicationException { try { @@ -595,11 +549,10 @@ + e.getMessage(), e); } - } - public int countSessionUser(QaSession qaSession) + public int countSessionUser(QaSession qaSession) throws QaApplicationException { try { @@ -686,44 +639,79 @@ * gets called by Container+Flash * */ - public void copyToolContent(Long fromContentId, Long toContentId) throws QaApplicationException + + public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { logger.debug("start of copyToolContent with ids: " + fromContentId + " and " + toContentId); - if (fromContentId == null || toContentId == null) - throw new QaApplicationException("Failed to copy content" - + " based on null toolSessionId or null toolContentId"); + if (fromContentId == null) + { + logger.debug("fromContentId is null."); + logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); + long defaultContentId=0; + try + { + defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); + fromContentId= new Long(defaultContentId); + } + catch(Exception e) + { + logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); + } + } + + if (toContentId == null) + { + logger.debug("throwing ToolException: toContentId is null"); + throw new ToolException("toContentId is missing"); + } + logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId); + try { QaContent fromContent = qaDAO.loadQaById(fromContentId.longValue()); + if (fromContent == null) { - logger.debug("WARNING!, retrieved fromContent is null: "); - throw new QaApplicationException("WARNING! Fail to create fromContent. Can't continue!"); + logger.debug("fromContent is null."); + logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); + long defaultContentId=0; + try + { + defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); + fromContentId= new Long(defaultContentId); + } + catch(Exception e) + { + logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); + } + + fromContent = qaDAO.loadQaById(fromContentId.longValue()); + logger.debug("using fromContent: " + fromContent); } + + logger.debug("final - retrieved fromContent: " + fromContent); + logger.debug("final - before new instance using " + fromContent + " and " + toContentId); + QaContent toContent = QaContent.newInstance(fromContent,toContentId); + if (toContent == null) + { + logger.debug("throwing ToolException: WARNING!, retrieved toContent is null."); + throw new ToolException("WARNING! Fail to create toContent. Can't continue!"); + } else { - logger.debug("retrieved fromContent: " + fromContent); - QaContent toContent = QaContent.newInstance(fromContent,toContentId); - if (toContent == null) - { - logger.debug("WARNING!, retrieved fromContent is null: "); - throw new QaApplicationException("WARNING! Fail to create toContent. Can't continue!"); - } - else - { - logger.debug("retrieved toContent: " + toContent); - qaDAO.saveQa(toContent); - logger.debug("toContent has been saved successfully: " + toContent); - } + logger.debug("retrieved toContent: " + toContent); + qaDAO.saveQa(toContent); + logger.debug("toContent has been saved successfully: " + toContent); } logger.debug("end of copyToolContent with ids: " + fromContentId + " and " + toContentId); } catch (DataAccessException e) { - throw new QaApplicationException("Exception occured when lams is copying content between content ids: fromContentId: " + fromContentId + - " and " + toContentId - + e.getMessage(),e); + logger.debug("throwing ToolException: Exception occured when lams is copying content between content ids."); + throw new ToolException("Exception occured when lams is copying content between content ids."); } } @@ -843,21 +831,19 @@ * @param toolContentId * return void */ - public void setAsDefineLater(Long toolContentId) throws QaApplicationException + public void setAsDefineLater(Long toolContentId) throws DataMissingException, ToolException { logger.debug("request for setAsDefineLater with toolContentId: " + toolContentId); if (toolContentId == null) { - logger.debug("WARNING!: retrieved toolContentId is null."); - throw new QaApplicationException("Fail to setAsDefineLater" - + " based on null toolContentId."); + logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); + throw new DataMissingException("toolContentId is missing"); } QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); if (qaContent == null) { - logger.debug("WARNING!: retrieved qaContent is null."); - throw new QaApplicationException("Fail to setAsDefineLater" - + " based on null qaContent."); + logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); + throw new DataMissingException("qaContent is missing"); } qaContent.setDefineLater(true); updateQa(qaContent); @@ -871,30 +857,29 @@ * @param toolContentId * return void */ - public void setAsRunOffline(Long toolContentId) throws QaApplicationException + public void setAsRunOffline(Long toolContentId) throws DataMissingException, ToolException { logger.debug("request for setAsRunOffline with toolContentId:" + toolContentId); if (toolContentId == null) { - logger.debug("WARNING!: retrieved toolContentId is null."); - throw new QaApplicationException("Fail to setAsRunOffline" - + " based on null toolContentId."); + logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentId is null."); + throw new DataMissingException("toolContentId is missing"); } QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); if (qaContent == null) { - logger.debug("WARNING!: retrieved qaContent is null."); - throw new QaApplicationException("Fail to setAsRunOffline" - + " based on null qaContent."); + logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null."); + throw new DataMissingException("qaContent is missing"); } qaContent.setRunOffline(true); updateQa(qaContent); - logger.debug("qaContent has been updated for RunOffline: " + qaContent); + logger.debug("qaContent has been updated for runOffline: " + qaContent); } /** + * !!! UNUSED !!! * TESTED * gets automatically called only in monitoring mode when the author chooses to delete a lesson. * @@ -942,9 +927,67 @@ } + /* + * DOUBLE CHECK! + * Will need an update on the core tool signature: reason : when qaContent is null throw an exception + * (non-Javadoc) + * @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long, boolean) + */ public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { - + logger.debug("start of: removeToolContent(Long toolContentId, boolean removeSessionData"); + logger.debug("start of removeToolContent with toolContentId: " + toolContentId + "removeSessionData: " + removeSessionData); + + if (toolContentId == null) + { + logger.debug("toolContentId is null"); + throw new ToolException("toolContentId is missing"); + } + + QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); + logger.debug("retrieving qaContent: " + qaContent); + + if (qaContent != null) + { + Iterator sessionIterator=qaContent.getQaSessions().iterator(); + while (sessionIterator.hasNext()) + { + if (removeSessionData == false) + { + logger.debug("removeSessionData is false, throwing SessionDataExistsException."); + throw new SessionDataExistsException(); + } + + QaSession qaSession=(QaSession)sessionIterator.next(); + logger.debug("iterated qaSession : " + qaSession); + + Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator(); + while (sessionUsersIterator.hasNext()) + { + QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next(); + logger.debug("iterated qaQueUsr : " + qaQueUsr); + + Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator(); + while (sessionUsersResponsesIterator.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next(); + logger.debug("iterated qaUsrResp : " + qaUsrResp); + removeUserResponse(qaUsrResp); + logger.debug("removed qaUsrResp : " + qaUsrResp); + } + } + } + + logger.debug("removed all existing responses of toolContent with toolContentId:" + + toolContentId); + qaDAO.removeQa(toolContentId); + logger.debug("removed qaContent:" + qaContent); + } + else + { + logger.debug("Warning!!!, We should have not come here. qaContent is null."); + throw new ToolException("toolContentId is missing"); + } } @@ -955,7 +998,7 @@ * @param toolSessionId * @return boolean */ - protected boolean existsSession(long toolSessionId) + protected boolean existsSession(long toolSessionId) { QaSession qaSession=retrieveQaSessionOrNullById(toolSessionId); @@ -979,62 +1022,129 @@ * All the learners in the same group have the same toolSessionId. * */ - public void createToolSession(Long toolSessionId, Long toolContentId) throws QaApplicationException + public void createToolSession(Long toolSessionId, Long toolContentId) throws ToolException { logger.debug("start of createToolSession with ids: " + toolSessionId + " and " + toolContentId); - if (toolSessionId == null || toolContentId == null) - throw new QaApplicationException("Fail to create a qa session" - + " based on null toolSessionId or toolContentId"); - - logger.debug("Start to create qa session based on toolSessionId[" - + toolSessionId.longValue() + "] and toolContentId[" - + toolContentId.longValue() + "]"); - try + if (toolSessionId == null) + { + logger.debug("toolSessionId is null"); + throw new ToolException("toolSessionId is missing"); + } + + long defaultContentId=0; + if (toolContentId == null) { - QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); - logger.debug("created qaContent: " + qaContent); - - if (qaContent == null) - { - logger.debug("WARNING!: qaContent is null! . " + - "We can't create a new tool session based on a null qa content. Can't continue!"); - throw new QaApplicationException("WARNING! Fail to create tool session since there is no content with toolContentId:" + toolContentId); - } + logger.debug("toolContentId is null."); + logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); + + try + { + defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); + toolContentId=new Long(defaultContentId); + logger.debug("updated toolContentId to: " + toolContentId); + } + catch(Exception e) + { + logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); + } + } + logger.debug("final toolSessionId and toolContentId: " + toolSessionId + " " + toolContentId); + + QaContent qaContent = qaDAO.loadQaById(toolContentId.longValue()); + logger.debug("retrieved qaContent: " + qaContent); + + if (qaContent == null) + { + logger.debug("qaContent is null."); + logger.debug("attempt retrieving tool's default content id with signatute : " + MY_SIGNATURE); + + try + { + defaultContentId=getToolDefaultContentIdBySignature(MY_SIGNATURE); + toolContentId=new Long(defaultContentId); + logger.debug("updated toolContentId to: " + toolContentId); + } + catch(Exception e) + { + logger.debug("default content id has not been setup for signature: " + MY_SIGNATURE); + throw new ToolException("WARNING! default content has not been setup for signature" + MY_SIGNATURE + " Can't continue!"); + } + qaContent = qaDAO.loadQaById(toolContentId.longValue()); + } + logger.debug("final - retrieved qaContent: " + qaContent); + - /** - * create a new a new tool session if it does not already exist in the tool session table - */ - if (!existsSession(toolSessionId.longValue())) - { - QaSession qaSession = new QaSession(toolSessionId, + /** + * create a new a new tool session if it does not already exist in the tool session table + */ + if (!existsSession(toolSessionId.longValue())) + { + try + { + QaSession qaSession = new QaSession(toolSessionId, new Date(System.currentTimeMillis()), QaSession.INCOMPLETE, qaContent, new TreeSet()); - - logger.debug("created qaSession: " + qaSession); - qaSessionDAO.CreateQaSession(qaSession); - logger.debug("created qaSession in the db: " + qaSession); - } + + logger.debug("created qaSession: " + qaSession); + qaSessionDAO.CreateQaSession(qaSession); + logger.debug("created qaSession in the db: " + qaSession); + + } + catch(Exception e) + { + logger.debug("Error creating new toolsession in the db"); + throw new ToolException("Error creating new toolsession in the db: " + e); + } } - catch (DataAccessException e) - { - throw new QaApplicationException("Exception occured when lams is creating" - + " a qa Session: " - + e.getMessage(),e); - } - } public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException { + logger.debug("start of removeToolSession with id: " + toolSessionId); + if (toolSessionId == null) + { + logger.debug("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); + } + QaSession qaSession=null; + try + { + qaSession=retrieveQaSessionOrNullById(toolSessionId.longValue()); + logger.debug("retrieved qaSession: " + qaSession); + } + catch(QaApplicationException e) + { + throw new DataMissingException("error retrieving qaSession: " + e); + } + catch(Exception e) + { + throw new ToolException("error retrieving qaSession: " + e); + } + + if (qaSession == null) + { + logger.debug("qaSession is null"); + throw new DataMissingException("qaSession is missing"); + } + + try + { + qaSessionDAO.deleteQaSession(qaSession); + logger.debug("qaSession " + qaSession + " has been deleted successfully."); + } + catch(QaApplicationException e) + { + throw new ToolException("error deleting qaSession:" + e); + } } + - - /**FIX THIS ONE!!!! * TO BE TESTED * ToolSessionManager CONTRACT @@ -1043,23 +1153,35 @@ * Call controller service to complete the qa session * @see org.lamsfoundation.lams.tool.ToolSessionManager#leaveToolSession(java.lang.Long) */ - public String leaveToolSession(Long toolSessionId,User learner) throws QaApplicationException + public String leaveToolSession(Long toolSessionId,User learner) throws DataMissingException, ToolException { logger.debug("start of leaveToolSession with toolSessionId:" + toolSessionId); logger.debug("start of leaveToolSession with learner:" + learner); + + if (toolSessionId == null) + { + logger.debug("toolSessionId is null"); + throw new DataMissingException("toolSessionId is missing"); + } + + if (learner == null) + { + logger.debug("learner is null"); + throw new DataMissingException("learner is missing"); + } + try { /* String nextUrl=learnerService.completeToolSession(toolSessionId,learner); logger.debug(logger + " " + this.getClass().getName() + " " + "nextUrl: " + nextUrl); return nextUrl; */ - return "completionUrl"; + return "nextUrl"; } catch(DataAccessException e) { - throw new QaApplicationException("Exception occured when user is leaving tool session: " - + e.getMessage(),e); + throw new ToolException("Exception occured when user is leaving tool session: " + e); } } @@ -1068,20 +1190,19 @@ * ToolSessionManager CONTRACT * */ - public ToolSessionExportOutputData exportToolSession(Long toolSessionId) + public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("not yet implemented"); + throw new ToolException("not yet implemented"); } /** * ToolSessionManager CONTRACT * */ - public ToolSessionExportOutputData exportToolSession(List toolSessionIds) + public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("not yet implemented"); + + throw new ToolException("not yet implemented"); } public BasicToolVO getToolBySignature(String toolSignature) throws QaApplicationException Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== diff -u -r65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -19,6 +19,8 @@ import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaComparator; import org.lamsfoundation.lams.tool.qa.QaContent; @@ -32,7 +34,7 @@ * @author Ozgur Demirtas * */ -public class AuthoringUtil implements QaAppConstants{ +public class AuthoringUtil implements QaAppConstants { static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); /** @@ -159,7 +161,7 @@ protected void findSelectedTab(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) + HttpServletResponse response) { QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; String choiceBasic=qaAuthoringForm.getChoiceBasic(); @@ -217,7 +219,18 @@ IQaService qaService =QaUtils.getToolService(request); Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); - qaService.setAsDefineLater(monitoredContentId); + + try + { + qaService.setAsDefineLater(monitoredContentId); + } + catch (ToolException e) + { + logger.debug("We should never come here."); + logger.debug("Warning! ToolException occurred"); + } + + logger.debug("MONITORED_CONTENT_ID has been marked as defineLater: "); request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); } @@ -452,7 +465,15 @@ if ((toolContentId != null) && (!toolContentId.equals(""))) { logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); - qaService.setAsRunOffline(new Long(toolContentId)); + try + { + qaService.setAsRunOffline(new Long(toolContentId)); + } + catch(ToolException e) + { + logger.debug("we should never come here"); + } + logger.debug("post-RunAsOffline"); } logger.debug("end of simulating RunOffline on content id: " + toolContentId); @@ -471,7 +492,15 @@ if ((toolContentId != null) && (!toolContentId.equals(""))) { logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId)); - qaService.setAsDefineLater(new Long(toolContentId)); + try + { + qaService.setAsDefineLater(new Long(toolContentId)); + } + catch(ToolException e) + { + logger.debug("we should never come here"); + } + logger.debug("post-setAsDefineLater"); } logger.debug("end of simulating setAsDefineLater on content id: " + toolContentId); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java =================================================================== diff -u -r5ba75a338c76b23778bf80ab835209d38e2316cb -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 5ba75a338c76b23778bf80ab835209d38e2316cb) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -12,6 +12,7 @@ import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaContent; @@ -85,7 +86,7 @@ } - public void startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) + public void startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) throws ToolException { IQaService qaService=QaUtils.getToolService(request); @@ -113,7 +114,16 @@ throw new QaApplicationException("Exception occured: " + "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!"); } - qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId)); + + try + { + qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId)); + } + catch(ToolException e) + { + logger.debug("exception copying content."); + throw e; + } /** calls to these two methods will be made from Monitoring Service bean optionally depending on * the the tool is setup for DefineLater and (or) RunOffline Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java =================================================================== diff -u -r4447ae1bb802ba8a16df65d880f25575d1174003 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (.../QAction.java) (revision 4447ae1bb802ba8a16df65d880f25575d1174003) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java (.../QAction.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -36,6 +36,8 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.actions.DispatchAction; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaSession; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== diff -u -r65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 65dbef6ba8b7c63e1b36662a6ddfb2f352c0dce6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -21,6 +21,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaComparator; @@ -220,8 +221,16 @@ Long currentToolContentId= new Long(1234); logger.debug("simulating container behaviour: calling createToolSession with toolSessionId : " + new Long(toolSessionId) + " and toolContentId: " + currentToolContentId); - qaService.createToolSession(new Long(toolSessionId), currentToolContentId); - logger.debug("simulated container behaviour."); + try + { + qaService.createToolSession(new Long(toolSessionId), currentToolContentId); + logger.debug("simulated container behaviour."); + } + catch(ToolException e) + { + logger.debug("we should never come here."); + } + } /** Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== diff -u -rb767cd01abafe96e9ba61d83ba88cacb5a622558 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision b767cd01abafe96e9ba61d83ba88cacb5a622558) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -39,6 +39,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaApplicationException; import org.lamsfoundation.lams.tool.qa.QaContent; @@ -53,7 +54,7 @@ static Logger logger = Logger.getLogger(QaMonitoringStarterAction.class.getName()); public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, QaApplicationException + throws IOException, ServletException, QaApplicationException, ToolException { QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; @@ -278,7 +279,15 @@ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID); logger.debug("TO_TOOL_CONTENT_ID: " + strToToolContentId); - qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId)); + try + { + qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId)); + } + catch(ToolException e) + { + logger.debug("exception copying content."); + throw e; + } logger.debug("test successfull: copyToolContent."); /** calls to these two methods will be made from Monitoring Service bean optionally depending on Index: lams_tool_laqa/test/web/WEB-INF/web.xml =================================================================== diff -u -r4447ae1bb802ba8a16df65d880f25575d1174003 -rd231fdf18f3da49f3ca42f543c784f4d09a59332 --- lams_tool_laqa/test/web/WEB-INF/web.xml (.../web.xml) (revision 4447ae1bb802ba8a16df65d880f25575d1174003) +++ lams_tool_laqa/test/web/WEB-INF/web.xml (.../web.xml) (revision d231fdf18f3da49f3ca42f543c784f4d09a59332) @@ -10,11 +10,11 @@ contextConfigLocation - classpath:/org/lamsfoundation/lams/applicationContext.xml - classpath:/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml - classpath:/org/lamsfoundation/lams/tool/toolApplicationContext.xml - classpath:/org/lamsfoundation/lams/learning/learningApplicationContext.xml - classpath:/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml + classpath:/org/lamsfoundation/lams/applicationContext.xml + classpath:/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml + classpath:/org/lamsfoundation/lams/tool/toolApplicationContext.xml + classpath:/org/lamsfoundation/lams/learning/learningApplicationContext.xml + classpath:/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml @@ -82,32 +82,41 @@ true 2 - - - - Connector - com.fredck.FCKeditor.connector.ConnectorServlet - - baseDir - /UserFiles/ - - - debug - false - - 1 + + + + Connector + com.fredck.FCKeditor.connector.ConnectorServlet + + baseDir + /UserFiles/ + + + debug + false + + 1 action - *.do - Connector - /editor/filemanager/browser/default/connectors/jsp/connector + *.do + + Connector + /editor/filemanager/browser/default/connectors/jsp/connector + + + 120 + + + fck-editor + /WEB-INF/fckEditor/tlds/FCKeditor.tld +